add event record calendar to record list

This commit is contained in:
Timi
2026-08-12 19:57:41 +08:00
parent 44a6153413
commit 6463abd93b
8 changed files with 140 additions and 11 deletions
+32
View File
@@ -39,6 +39,7 @@
v-model:selected-event-id-list="selectedEventIdList"
:customer-id="selectedCustomer.id || ''"
:customer-name="selectedCustomer.name"
@list="toEventRecordList"
/>
<customer-record-trend-chart
v-if="selectedCustomer"
@@ -66,6 +67,7 @@ import { Time } from "timi-web";
import CustomerAPI from "@/api/CustomerAPI";
import CodeScanner from "@/components/CodeScanner.vue";
import CustomerSelector from "@/components/CustomerSelector.vue";
import type { EventRecordCalendarListPayload } from "@/components/EventRecordCalendar.vue";
import CustomerChartSummary from "@/pages/customer/component/CustomerChartSummary.vue";
import CustomerEventRecordCalendarSection from "@/pages/customer/component/CustomerEventRecordCalendarSection.vue";
import CustomerEventStructureChart from "@/pages/customer/component/CustomerEventStructureChart.vue";
@@ -79,6 +81,7 @@ defineOptions({
});
const route = useRoute();
const router = useRouter();
const settingStore = useSettingStore();
// ---------- 路由 ----------
@@ -160,6 +163,35 @@ function clearLoadedCustomer(): void {
selectedCustomerId.value = "";
}
async function toEventRecordList(payload: EventRecordCalendarListPayload): Promise<void> {
if (!selectedCustomer.value?.id) {
return;
}
await router.push({
name: "EventRecordList",
query: buildEventRecordListQuery(payload.monthCursor, payload.selectedEventIdList, selectedCustomer.value)
});
}
function buildEventRecordListQuery(monthCursor: Date, eventIdList: string[], customer: Customer): Record<string, string> {
const monthStart = getMonthStart(monthCursor);
const monthEnd = getDateEnd(addDays(addMonths(monthStart, 1), -1));
return {
customerId: customer.id || "",
customerName: customer.name || "",
dateType: "custom",
beginAt: `${Time.formatDate(monthStart)} 00:00`,
endAt: `${Time.formatDate(monthEnd)} 23:59`,
transitionDepth: String(getCurrentRouteDepth() + 1),
eventIds: eventIdList.join(",")
};
}
function getCurrentRouteDepth(): number {
return Number(route.meta.depth ?? 0);
}
// ---------- 扫码 ----------
const scannerVisible = ref(false);