import { axios, type PageResult } from "timi-web"; 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 { return await axios.post(`${BASE_URI}/list`, withCurrentStoreId(page)); } async function detail(id: string): Promise { return await axios.post(`${BASE_URI}/detail`, null, { params: { id } }); } async function create(record: EventRecord): Promise { await axios.post(`${BASE_URI}/create`, withCurrentStoreId(record)); } async function createBatch(recordList: EventRecord[]): Promise { await axios.post(`${BASE_URI}/create/batch`, recordList.map(record => withCurrentStoreId(record))); } async function createWithCustomer(customer: Customer): Promise { await axios.post(`${BASE_URI}/create/customer`, withCurrentStoreId(customer)); } async function update(record: EventRecord): Promise { await axios.post(`${BASE_URI}/update`, withCurrentStoreId(record)); } async function remove(id: string): Promise { await axios.post(`${BASE_URI}/delete`, undefined, { params: { id } }); } async function eventRank(page: EventRecordRankPage): Promise> { return await axios.post(`${BASE_URI}/rank`, withCurrentStoreId(page)); } async function exportXSSF(page: EventRecordPage): Promise { return await axios.post(`${BASE_URI}/export`, withCurrentStoreId(page), { responseType: "blob" }); } export default { list, detail, exportXSSF, create, createBatch, createWithCustomer, update, remove, eventRank };