Files
gao-customer-h5/src/api/EventRecordAPI.ts
T
2026-08-14 18:45:03 +08:00

61 lines
1.8 KiB
TypeScript

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