add event beginAt/endAt
This commit is contained in:
@@ -33,8 +33,10 @@
|
||||
variant="light-outline"
|
||||
:content="getRoleName(roleCode)"
|
||||
/>
|
||||
<span v-if="!(item.roleCodeList || []).length" class="muted" v-text="'未配置'" />
|
||||
</div>
|
||||
<div class="line" v-text="getLimitText(item)" />
|
||||
<div class="line" v-text="getPeriodText(item)" />
|
||||
</div>
|
||||
</template>
|
||||
</t-cell>
|
||||
@@ -51,7 +53,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Toast } from "tdesign-mobile-vue";
|
||||
import { useUserStore, type Role } from "timi-web";
|
||||
import { Time, useUserStore, type Role } from "timi-web";
|
||||
import RegistrationEventAPI from "@/api/RegistrationEventAPI";
|
||||
import GaoUserAPI from "@/api/GaoUserAPI";
|
||||
import type { RegistrationEvent, RegistrationLimitType } from "@/types/RegistrationEvent";
|
||||
@@ -89,17 +91,20 @@ function handleRegistrationEventClick(item: RegistrationEvent): void {
|
||||
}
|
||||
|
||||
function isRegistrationEventActive(item: RegistrationEvent): boolean {
|
||||
return item.enabled !== false && (item.status || "ACTIVE") === "ACTIVE";
|
||||
return (item.status || "ACTIVE") === "ACTIVE";
|
||||
}
|
||||
|
||||
function getStatusText(item: RegistrationEvent): string {
|
||||
if (item.status === "DRAFT") {
|
||||
return "草稿";
|
||||
}
|
||||
if (item.status === "INACTIVE") {
|
||||
return "无效";
|
||||
return "不可登记";
|
||||
}
|
||||
if (item.status === "DELETED") {
|
||||
return "已删除";
|
||||
}
|
||||
return item.enabled === false ? "停用" : "有效";
|
||||
return "可登记";
|
||||
}
|
||||
|
||||
function getLimitText(item: RegistrationEvent): string {
|
||||
@@ -109,11 +114,30 @@ function getLimitText(item: RegistrationEvent): string {
|
||||
NATURAL_DAY: "每天一次",
|
||||
INTERVAL_HOUR: `每隔 ${item.limitValue || 0} 小时`,
|
||||
NATURAL_MONTH: "每月一次",
|
||||
TOTAL_LIMIT: `累计限 ${item.limitValue || 0} 次`
|
||||
TOTAL_LIMIT: `事件总上限 ${item.limitValue || 0} 次`,
|
||||
CUSTOMER_TOTAL_LIMIT: `单客户总上限 ${item.limitValue || 0} 次`
|
||||
};
|
||||
return limitTextMap[item.limitType || "NONE"];
|
||||
}
|
||||
|
||||
function getPeriodText(item: RegistrationEvent): string {
|
||||
const beginText = formatTime(item.beginAt);
|
||||
const endText = formatTime(item.endAt);
|
||||
if (!beginText && !endText) {
|
||||
return "有效期:不限";
|
||||
}
|
||||
return `有效期:${beginText || "不限"} 至 ${endText || "不限"}`;
|
||||
}
|
||||
|
||||
function formatTime(value?: number): string {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const date = new Date(value);
|
||||
return Number.isNaN(date.getTime()) ? "" : Time.formatDateTime(date);
|
||||
}
|
||||
|
||||
function getRoleName(code: string): string {
|
||||
const role = roleOptions.value.find(item => item.code === code);
|
||||
return role?.name || code;
|
||||
@@ -170,6 +194,10 @@ onMounted(async () => {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.muted {
|
||||
color: #52607a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user