From 020d187860f71ccdad55ec2b0a4fefdabb2631f9 Mon Sep 17 00:00:00 2001 From: Timi Date: Fri, 14 Aug 2026 18:45:03 +0800 Subject: [PATCH] add NumberValueTotal --- src/api/EventRecordAPI.ts | 4 ++-- src/pages/event/EventRecordList.vue | 31 ++++++++++++++++++++++------- src/types/EventRecord.ts | 6 +++++- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/api/EventRecordAPI.ts b/src/api/EventRecordAPI.ts index 17b1b6b..c3d32a2 100644 --- a/src/api/EventRecordAPI.ts +++ b/src/api/EventRecordAPI.ts @@ -1,11 +1,11 @@ import { axios, type PageResult } from "timi-web"; -import type { CustomerEventRankView, EventRecord, EventRecordPage, EventRecordRankPage } from "@/types/EventRecord"; +import type { CustomerEventRankView, EventRecord, EventRecordPage, EventRecordPageResult, EventRecordRankPage } from "@/types/EventRecord"; import type { Customer } from "@/types/Customer.ts"; import { withCurrentStoreId } from "@/utils/store"; const BASE_URI = "/gao/event/record"; -async function list(page: EventRecordPage): Promise> { +async function list(page: EventRecordPage): Promise { return await axios.post(`${BASE_URI}/list`, withCurrentStoreId(page)); } diff --git a/src/pages/event/EventRecordList.vue b/src/pages/event/EventRecordList.vue index 9189a0a..873a6cf 100644 --- a/src/pages/event/EventRecordList.vue +++ b/src/pages/event/EventRecordList.vue @@ -42,6 +42,7 @@
+
import { DialogPlugin, Toast, type DropdownValue } from "tdesign-mobile-vue"; -import { Time, Toolkit, type PageResult, useUserStore } from "timi-web"; +import { Time, Toolkit, useUserStore } from "timi-web"; import EventAPI from "@/api/EventAPI"; import EventRecordAPI from "@/api/EventRecordAPI"; import { useNavBarStore } from "@/store/navBarStore"; import type { EventItem } from "@/types/EventItem"; -import type { EventRecordListItemView, EventRecordPage } from "@/types/EventRecord"; +import type { EventRecordPage, EventRecordPageResult, EventRecordListItemView } from "@/types/EventRecord"; import { getCustomerPhotoURL } from "@/utils/customer"; import { getErrorMessage } from "@/utils/error"; +import { formatEventNumberValue } from "@/utils/eventValue"; import { permissionCodes } from "@/utils/permission"; type DateFilterType = "today" | "yesterday" | "beforeYesterday" | "lastWeek" | "all" | "custom"; @@ -192,6 +194,13 @@ const eventFilterLabel = computed(() => { .join("、"); }); const summaryBehaviorText = computed(() => `事件:${eventFilterLabel.value}`); +const selectedNumberEvent = computed(() => { + if (actionFilter.value.length !== 1) { + return undefined; + } + const event = eventList.value.find(item => item.id === actionFilter.value[0]); + return event?.valueType === "NUMBER" ? event : undefined; +}); const canDeleteRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.delete)); const summaryText = computed(() => { if (!isCustomRange.value) { @@ -244,13 +253,20 @@ const page = reactive({ index: 0, size: pageSize }); -const pageResult = reactive>({ +const pageResult = reactive({ total: 0, - list: [] + list: [], + numberValueTotal: null }); let loadToken = 0; const summaryTotalText = computed(() => `共 ${pageResult.total} 条数据,已加载 ${pageResult.list.length} 条`); +const summaryNumberValueText = computed(() => { + if (!selectedNumberEvent.value || pageResult.numberValueTotal === undefined || pageResult.numberValueTotal === null) { + return ""; + } + return `数值合计:${formatEventNumberValue(selectedNumberEvent.value, pageResult.numberValueTotal)}`; +}); const loadStateText = computed(() => { if (isLoading.value) { return "正在加载更多"; @@ -264,6 +280,7 @@ async function reloadRecords(): Promise { page.index = 0; pageResult.total = 0; pageResult.list = []; + pageResult.numberValueTotal = null; isNoMore.value = false; await loadRecords(); } finally { @@ -289,6 +306,7 @@ async function loadRecords(): Promise { } pageResult.list = pageResult.list.concat(result.list || []); pageResult.total = result.total || 0; + pageResult.numberValueTotal = result.numberValueTotal ?? null; page.index += 1; isNoMore.value = pageResult.list.length >= pageResult.total || (result.list || []).length < page.size; } finally { @@ -394,8 +412,7 @@ async function removeRecord(id: string): Promise { deletingId.value = id; try { await EventRecordAPI.remove(id); - pageResult.list = pageResult.list.filter(item => item.id !== id); - pageResult.total = Math.max(0, pageResult.total - 1); + await reloadRecords(); Toast.success("登记记录已删除"); } catch (error) { const message = getErrorMessage(error, "登记记录删除失败"); @@ -446,7 +463,7 @@ function buildRangeReq(): Omit { endAt, customerId: customerId.value || undefined, keyword: keyword.value.trim() || undefined, - eventIdList: selectedAllEvent ? undefined : actionFilter.value + eventIdList: actionFilter.value.length === 1 ? actionFilter.value : selectedAllEvent ? undefined : actionFilter.value }; } diff --git a/src/types/EventRecord.ts b/src/types/EventRecord.ts index 0d2d0ca..9e01545 100644 --- a/src/types/EventRecord.ts +++ b/src/types/EventRecord.ts @@ -1,4 +1,4 @@ -import type { Attachment, BasePage, Model, User } from "timi-web"; +import type { Attachment, BasePage, Model, PageResult, User } from "timi-web"; import type { Customer } from "@/types/Customer"; import type { EventItem } from "@/types/EventItem"; @@ -31,6 +31,10 @@ export type EventRecordListItemView = { registeredAt?: number; }; +export type EventRecordPageResult = PageResult & { + numberValueTotal?: number | null; +}; + export type EventRecordPage = { storeId?: string; customerId?: string;