add NumberValueTotal
This commit is contained in:
@@ -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<PageResult<EventRecord>> {
|
||||
async function list(page: EventRecordPage): Promise<EventRecordPageResult> {
|
||||
return await axios.post(`${BASE_URI}/list`, withCurrentStoreId(page));
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
<div v-text="summaryText" />
|
||||
<div v-text="summaryBehaviorText" />
|
||||
<div v-text="summaryTotalText" />
|
||||
<div v-if="summaryNumberValueText" v-text="summaryNumberValueText" />
|
||||
</div>
|
||||
<t-pull-down-refresh
|
||||
v-model="isRefreshing"
|
||||
@@ -131,14 +132,15 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
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<EventRecordPage>({
|
||||
index: 0,
|
||||
size: pageSize
|
||||
});
|
||||
const pageResult = reactive<PageResult<EventRecordListItemView>>({
|
||||
const pageResult = reactive<EventRecordPageResult>({
|
||||
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<void> {
|
||||
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<void> {
|
||||
}
|
||||
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<void> {
|
||||
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<EventRecordPage, "index" | "size"> {
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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<EventRecordListItemView> & {
|
||||
numberValueTotal?: number | null;
|
||||
};
|
||||
|
||||
export type EventRecordPage = {
|
||||
storeId?: string;
|
||||
customerId?: string;
|
||||
|
||||
Reference in New Issue
Block a user