update point tier rule

This commit is contained in:
Timi
2026-08-14 18:26:11 +08:00
parent 3b5ff75772
commit a43694daa3
16 changed files with 940 additions and 32 deletions
+106 -4
View File
@@ -1,6 +1,6 @@
<template>
<div v-can="pageAccess" class="registration-event-edit">
<t-form class="form" label-align="left">
<t-form class="form" label-align="left" label-width="7rem">
<t-form-item label="颜色">
<t-button
size="extra-small"
@@ -33,6 +33,15 @@
borderless
/>
</t-form-item>
<t-form-item label="数值类型" arrow @click="openValueTypePicker">
<div class="picker-text" v-text="getValueTypeText(formModel.valueType)" />
</t-form-item>
<t-form-item v-if="isNumberValueType(formModel.valueType)" label="数值单位" required-mark arrow @click="openValueUnitPicker">
<div class="picker-text" v-text="getValueUnitText(formModel.valueUnit)" />
</t-form-item>
<t-form-item v-if="isNumberValueType(formModel.valueType)" label="登记必填数值" content-align="right">
<t-switch v-model="formModel.requireValue" />
</t-form-item>
<t-form-item label="起始时间" arrow @click="openBeginAtPicker">
<div class="begin-at">
<div class="picker-text" v-text="formModel.beginAtText || '不限'" />
@@ -161,6 +170,24 @@
@confirm="confirmStatusPicker"
/>
</t-popup>
<t-popup v-model="valueTypePickerVisible" placement="bottom">
<t-picker
v-model="valueTypePickerDraft"
:columns="valueTypePickerColumns"
title="数值类型"
@cancel="valueTypePickerVisible = false"
@confirm="confirmValueType"
/>
</t-popup>
<t-popup v-model="valueUnitPickerVisible" placement="bottom">
<t-picker
v-model="valueUnitPickerDraft"
:columns="valueUnitPickerColumns"
title="数值单位"
@cancel="valueUnitPickerVisible = false"
@confirm="confirmValueUnit"
/>
</t-popup>
<t-popup v-model="beginAtPickerVisible" placement="bottom">
<div class="picker-popup">
<t-date-time-picker
@@ -198,7 +225,8 @@ import type { ColorObject } from "tdesign-mobile-vue";
import { useUserStore, type Role } from "timi-web";
import EventAPI from "@/api/EventAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import type { EventItem, EventStatus, EventLimitType } from "@/types/EventItem";
import type { EventItem, EventStatus, EventLimitType, EventValueType, EventValueUnit } from "@/types/EventItem";
import { getErrorMessage } from "@/utils/error";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
type PickerValue = string | number;
@@ -239,6 +267,9 @@ const formModel = reactive({
name: "",
description: "",
color: "#0f766e",
valueType: "NONE" as EventValueType,
valueUnit: null as EventValueUnit | null,
requireValue: false,
status: "ACTIVE" as EventStatus,
requirePhoto: false,
limitType: "NONE" as EventLimitType,
@@ -400,6 +431,71 @@ function getStatusText(value: EventStatus): string {
return statusOptions.find(option => option.value === value)?.label || "可登记";
}
// ---------- 数值定义 ----------
const valueTypeOptions: Array<{ label: string; value: EventValueType }> = [
{ label: "不携带数值", value: "NONE" },
{ label: "携带数值", value: "NUMBER" }
];
const valueUnitOptions: Array<{ label: string; value: EventValueUnit }> = [
{ label: "金额(元)", value: "CENT" },
{ label: "次数", value: "COUNT" }
];
const valueTypePickerVisible = ref(false);
const valueTypePickerDraft = ref<PickerValue[]>([]);
const valueTypePickerColumns = [valueTypeOptions];
const valueUnitPickerVisible = ref(false);
const valueUnitPickerDraft = ref<PickerValue[]>([]);
const valueUnitPickerColumns = [valueUnitOptions];
function isNumberValueType(value: EventValueType): boolean {
return value === "NUMBER";
}
function getValueTypeText(value: EventValueType): string {
return valueTypeOptions.find(option => option.value === value)?.label || "不携带数值";
}
function getValueUnitText(value: EventValueUnit | null): string {
return valueUnitOptions.find(option => option.value === value)?.label || "请选择单位";
}
function openValueTypePicker(): void {
valueTypePickerDraft.value = [formModel.valueType];
valueTypePickerVisible.value = true;
}
function confirmValueType(value: Array<string | number>): void {
const valueType = value[0];
if (valueType !== "NONE" && valueType !== "NUMBER") {
return;
}
formModel.valueType = valueType;
if (valueType === "NONE") {
formModel.valueUnit = null;
formModel.requireValue = false;
} else if (!formModel.valueUnit) {
formModel.valueUnit = "CENT";
}
valueTypePickerVisible.value = false;
}
function openValueUnitPicker(): void {
if (!isNumberValueType(formModel.valueType)) {
return;
}
valueUnitPickerDraft.value = [formModel.valueUnit || "CENT"];
valueUnitPickerVisible.value = true;
}
function confirmValueUnit(value: Array<string | number>): void {
const valueUnit = value[0];
if (valueUnit === "CENT" || valueUnit === "COUNT") {
formModel.valueUnit = valueUnit;
}
valueUnitPickerVisible.value = false;
}
// ---------- 次数限制 ----------
function openLimitPicker(): void {
@@ -539,6 +635,9 @@ async function saveEventItem(): Promise<void> {
name: formModel.name.trim(),
description: formModel.description,
color: formModel.color,
valueType: formModel.valueType,
valueUnit: isNumberValueType(formModel.valueType) ? formModel.valueUnit : null,
requireValue: isNumberValueType(formModel.valueType) && formModel.requireValue,
status: formModel.status,
requirePhoto: formModel.requirePhoto,
limitType: formModel.limitType,
@@ -554,8 +653,8 @@ async function saveEventItem(): Promise<void> {
}
Toast.success("登记事件已保存");
await router.replace("/management/registration-events");
} catch {
Toast.error("登记事件保存失败");
} catch (error) {
Toast.error(getErrorMessage(error, "登记事件保存失败"));
} finally {
isSaving.value = false;
}
@@ -629,6 +728,9 @@ async function fillForm(): Promise<void> {
name: current.name || "",
description: current.description || "",
color: current.color || "#2f88ff",
valueType: current.valueType || "NONE",
valueUnit: current.valueUnit || null,
requireValue: current.requireValue ?? false,
status: current.status === "DRAFT" ? "DRAFT" : current.status === "INACTIVE" ? "INACTIVE" : "ACTIVE",
requirePhoto: current.requirePhoto ?? false,
limitType: current.limitType || "NONE",