From 9c30891f2c9fa9bcbeb0a17e894664957d2a9663 Mon Sep 17 00:00:00 2001 From: Timi Date: Tue, 11 Aug 2026 22:54:57 +0800 Subject: [PATCH] fix event limit type --- src/pages/event/EventEdit.vue | 29 ++++++++++++++++++++++++----- src/pages/event/EventList.vue | 20 ++++++++++++++------ src/pages/point/PointRuleEdit.vue | 2 +- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/pages/event/EventEdit.vue b/src/pages/event/EventEdit.vue index 9234fb9..0a9d9fb 100644 --- a/src/pages/event/EventEdit.vue +++ b/src/pages/event/EventEdit.vue @@ -310,10 +310,10 @@ const colorSwatchList = [ const limitOptions: LimitOption[] = [ { label: "不限", value: "NONE" }, - { label: "上午和下午各一次", value: "DAILY_HALF_DAY" }, + { label: "上午和下午各自限次", value: "DAILY_HALF_DAY" }, { label: "间隔小时内一次", value: "INTERVAL_HOUR" }, - { label: "每个自然日一次", value: "NATURAL_DAY" }, - { label: "每个自然月一次", value: "NATURAL_MONTH" }, + { label: "每个自然日限次", value: "NATURAL_DAY" }, + { label: "每个自然月限次", value: "NATURAL_MONTH" }, { label: "事件总次数", value: "TOTAL_LIMIT" }, { label: "单客户总次数", value: "CUSTOMER_TOTAL_LIMIT" } ]; @@ -347,9 +347,18 @@ const defaultEndAtText = computed(() => { return Time.formatDateTime(date); }); const limitValuePlaceholder = computed(() => { + if (formModel.limitType === "DAILY_HALF_DAY") { + return "请输入上午和下午各自次数上限"; + } if (formModel.limitType === "INTERVAL_HOUR") { return "请输入间隔小时数"; } + if (formModel.limitType === "NATURAL_DAY") { + return "请输入每天次数上限"; + } + if (formModel.limitType === "NATURAL_MONTH") { + return "请输入每月次数上限"; + } if (formModel.limitType === "CUSTOMER_TOTAL_LIMIT") { return "请输入单客户总次数上限"; } @@ -402,6 +411,9 @@ function confirmLimitPicker(value: Array): void { const limitType = value[0]; if (typeof limitType === "string") { formModel.limitType = limitType as EventLimitType; + if (isValueLimitType(formModel.limitType) && !formModel.limitValueText) { + formModel.limitValueText = "1"; + } } limitPickerVisible.value = false; } @@ -422,7 +434,7 @@ function confirmStatusPicker(value: Array): void { } function isValueLimitType(value: EventLimitType): boolean { - return value === "INTERVAL_HOUR" || value === "TOTAL_LIMIT" || value === "CUSTOMER_TOTAL_LIMIT"; + return value !== "NONE"; } function resolveLimitValue(): number | undefined { @@ -434,6 +446,13 @@ function resolveLimitValue(): number | undefined { return 0 < value ? Math.floor(value) : undefined; } +function resolveLimitValueText(value?: number): string { + if (value !== undefined && Number.isFinite(value) && 0 < value) { + return String(Math.floor(value)); + } + return isValueLimitType(formModel.limitType) ? "1" : ""; +} + // ---------- 表单转换 ---------- function resolveTimestamp(valueText: string): number | undefined { @@ -613,11 +632,11 @@ async function fillForm(): Promise { status: current.status === "DRAFT" ? "DRAFT" : current.status === "INACTIVE" ? "INACTIVE" : "ACTIVE", requirePhoto: current.requirePhoto ?? false, limitType: current.limitType || "NONE", - limitValueText: current.limitValue ? String(current.limitValue) : "", beginAtText: current.beginAt ? Time.toDateTime(current.beginAt) : "", endAtText: current.endAt ? Time.toDateTime(current.endAt) : "", roleCodeList: [...(current.roleCodeList || [])] }); + formModel.limitValueText = resolveLimitValueText(current.limitValue); colorDraft.value = formModel.color; } diff --git a/src/pages/event/EventList.vue b/src/pages/event/EventList.vue index 075150d..a1b1338 100644 --- a/src/pages/event/EventList.vue +++ b/src/pages/event/EventList.vue @@ -186,18 +186,26 @@ function getStatusTag(item: EventItem): StatusTag { } function getLimitText(item: EventItem): string { + const limitValue = resolveLimitValue(item.limitValue); const limitTextMap: Record = { NONE: "不限次数", - DAILY_HALF_DAY: "上午/下午各一次", - INTERVAL_HOUR: `每隔 ${item.limitValue || 0} 小时`, - NATURAL_DAY: "每个自然日一次", - NATURAL_MONTH: "每个自然月一次", - TOTAL_LIMIT: `事件总上限 ${item.limitValue || 0} 次`, - CUSTOMER_TOTAL_LIMIT: `单客户总上限 ${item.limitValue || 0} 次` + DAILY_HALF_DAY: `上午/下午各 ${limitValue} 次`, + INTERVAL_HOUR: `每隔 ${limitValue} 小时`, + NATURAL_DAY: `每个自然日 ${limitValue} 次`, + NATURAL_MONTH: `每个自然月 ${limitValue} 次`, + TOTAL_LIMIT: `事件总上限 ${limitValue} 次`, + CUSTOMER_TOTAL_LIMIT: `单客户总上限 ${limitValue} 次` }; return limitTextMap[item.limitType || "NONE"]; } +function resolveLimitValue(value?: number): number { + if (value !== undefined && Number.isFinite(value) && 0 < value) { + return Math.floor(value); + } + return 1; +} + function getRoleName(code: string): string { const role = roleOptions.value.find(item => item.code === code); return role?.name || code; diff --git a/src/pages/point/PointRuleEdit.vue b/src/pages/point/PointRuleEdit.vue index d485a16..e8f7633 100644 --- a/src/pages/point/PointRuleEdit.vue +++ b/src/pages/point/PointRuleEdit.vue @@ -1,6 +1,6 @@