add event verify

This commit is contained in:
Timi
2026-08-29 15:35:28 +08:00
parent 24cf6fc714
commit 904af04cdd
9 changed files with 233 additions and 16 deletions
+80 -2
View File
@@ -15,6 +15,13 @@
:hover="canReadEvent && !!(record.event?.id || record.eventId)"
@click="toEventDetail"
/>
<t-cell title="核销状态" :note="getVerificationStatusText(record.verificationStatus)" />
<t-cell v-if="record.verificationStatus === 'VERIFIED'" title="核销人" :note="Text.display(record.verifier?.nick || record.verifier?.name)" />
<t-cell v-if="record.verificationStatus === 'VERIFIED'" title="核销时间">
<template #note>
<pass-time-label :timestamp="record.verifiedAt" underline />
</template>
</t-cell>
<t-cell v-if="record.numberValue !== undefined && record.numberValue !== null" title="事件数值" :note="getNumberValueText(record)" />
<t-cell v-if="record.pointValue !== undefined && record.pointValue !== null" title="提交积分值" :note="getPointValueText(record.pointValue, pointLedgerChangeType)" />
<t-cell v-if="record.earnedPointValue !== undefined && record.earnedPointValue !== null" title="本次积分变化" :note="getPointValueText(record.earnedPointValue, pointLedgerChangeType)" />
@@ -26,7 +33,17 @@
<t-cell title="登记人" :note="Text.display(record.operator?.nick || record.operator?.name)" />
<t-cell title="备注" :note="Text.display(record.remark)" />
</t-cell-group>
<div v-if="record" class="photo-wrapper" v-entrance-transition="140">
<t-button
v-if="canVerifyRecord && record?.verificationStatus === 'PENDING'"
class="verify-button cell-button"
theme="primary"
:loading="isVerifying"
@click="confirmVerifyRecord"
v-entrance-transition="140"
>
核销登记记录
</t-button>
<div v-if="record" class="photo-wrapper" v-entrance-transition="210">
<photo-scroller
:model-value="recordPhotoList"
:photo-items="recordPhotoItemList"
@@ -37,11 +54,12 @@
title="登记照片"
/>
</div>
<t-empty v-else :description="isLoading ? '正在加载登记事件记录' : '登记事件记录不存在'" />
<t-empty v-if="!record" :description="isLoading ? '正在加载登记事件记录' : '登记事件记录不存在'" />
</div>
</template>
<script setup lang="ts">
import { DialogPlugin } from "tdesign-mobile-vue";
import { PassTimeLabel, Text } from "timi-web";
import { useUserStore, type Attachment } from "timi-web-api";
import EventRecordAPI from "@/api/EventRecordAPI";
@@ -53,6 +71,8 @@ import type { PhotoItem } from "@/types/Photo";
import type { PointLedgerChangeType } from "@/types/Point";
import { getAttachmentReadURL } from "@/utils/attachment";
import { formatEventNumberValue } from "@/utils/eventValue";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
defineOptions({
@@ -68,8 +88,10 @@ const userStore = useUserStore();
const record = ref<EventRecord>();
const isLoading = ref(false);
const isVerifying = ref(false);
const canUpdateRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.update));
const canVerifyRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.verify));
const canReadEvent = computed(() => userStore.hasPermissions(permissionCodes.event.read));
const recordPhotoItemList = computed(() => (record.value?.attachmentList || [])
.filter(item => !!item.id)
@@ -121,6 +143,19 @@ function getNumberValueText(value: EventRecord): string {
return formatEventNumberValue(value.event, value.numberValue);
}
function getVerificationStatusText(status?: EventRecord["verificationStatus"]): string {
if (status === "PENDING") {
return "待核销";
}
if (status === "VERIFIED") {
return "已核销";
}
if (status === "NOT_REQUIRED") {
return "无需核销";
}
return "未知";
}
const pointLedgerChangeType = computed(() => record.value?.changeType || parsePointLedgerChangeType(route.query.changeType));
function getPointValueText(value?: number | null, changeType?: PointLedgerChangeType): string {
@@ -161,6 +196,44 @@ async function loadRecord(): Promise<void> {
}
}
async function confirmVerifyRecord(): Promise<void> {
const currentRecord = record.value;
if (!currentRecord?.id || currentRecord.verificationStatus !== "PENDING") {
return;
}
const dialog = DialogPlugin.confirm({
title: "核销登记记录",
content: `确定核销 ${currentRecord.customer?.name || "未知客户"} 的 ${currentRecord.event?.name || "未知事件"} 记录吗?`,
cancelBtn: "取消",
confirmBtn: "核销",
onCancel() {
dialog.destroy();
},
async onConfirm() {
dialog.destroy();
await verifyRecord(currentRecord.id || "");
}
});
}
async function verifyRecord(id: string): Promise<void> {
if (!id || isVerifying.value) {
return;
}
isVerifying.value = true;
try {
await EventRecordAPI.verify(id);
record.value = await EventRecordAPI.detail(id);
Message.success("登记记录已核销");
} catch (error) {
Message.error(getErrorMessage(error, "登记记录核销失败"));
} finally {
isVerifying.value = false;
}
}
// ---------- 导航 ----------
async function toEdit(): Promise<void> {
@@ -239,6 +312,11 @@ onUnmounted(() => {
box-shadow: var(--td-shadow-1);
border-radius: 1.4rem;
}
.verify-button {
width: calc(100% - 2rem);
margin: 0 1rem;
}
}
:global(html.theme-dark) {