48 lines
2.0 KiB
TypeScript
48 lines
2.0 KiB
TypeScript
import type { DataExportModule, DataExportModuleStat } from "@/types/DataExport";
|
|
import { IOSize } from "timi-ts";
|
|
|
|
export type DataExportModuleOption = {
|
|
label: string;
|
|
value: DataExportModule;
|
|
};
|
|
|
|
export const dataExportModuleOptionList: DataExportModuleOption[] = [
|
|
{ label: "客户档案", value: "CUSTOMER" },
|
|
{ label: "客户消费记录", value: "CUSTOMER_CONSUMPTION_RECORD" },
|
|
{ label: "客户跟进提醒", value: "CUSTOMER_FOLLOW_UP_REMINDER" },
|
|
{ label: "客户套餐", value: "CUSTOMER_PACKAGE" },
|
|
{ label: "事件登记", value: "EVENT_RECORD" },
|
|
{ label: "销售订单", value: "SALES_ORDER" },
|
|
{ label: "履约记录", value: "ORDER_FULFILLMENT" },
|
|
{ label: "资金流水", value: "FUND_RECORD" },
|
|
{ label: "积分账户", value: "POINT_ACCOUNT" },
|
|
{ label: "积分流水", value: "POINT_LEDGER" },
|
|
{ label: "积分兑换", value: "POINT_REDEMPTION" },
|
|
{ label: "营业日", value: "STORE_BUSINESS_DAY" },
|
|
{ label: "门店日记", value: "STORE_DIARY" },
|
|
{ label: "库存流水", value: "PRODUCT_STOCK_RECORD" }
|
|
];
|
|
|
|
const moduleLabelMap = new Map(dataExportModuleOptionList.map(item => [item.value, item.label]));
|
|
const numberFormatter = new Intl.NumberFormat("zh-CN");
|
|
|
|
export function getDataExportModuleLabel(module: DataExportModule): string {
|
|
return moduleLabelMap.get(module) || module;
|
|
}
|
|
|
|
export function formatDataExportCount(value: number): string {
|
|
return numberFormatter.format(value);
|
|
}
|
|
|
|
export function formatDataExportFileSize(size: number): string {
|
|
return IOSize.format(size);
|
|
}
|
|
|
|
export function formatDataExportModuleCount(stat: DataExportModuleStat): string {
|
|
return `数据 ${formatDataExportCount(stat.recordCount)} 条 · 附件 ${formatDataExportCount(stat.attachmentCount)} 个`;
|
|
}
|
|
|
|
export function formatDataExportModuleSize(stat: DataExportModuleStat): string {
|
|
return `业务 ${formatDataExportFileSize(stat.businessEstimateSize)} · 附件 ${formatDataExportFileSize(stat.attachmentSize)} · 合计 ${formatDataExportFileSize(stat.estimateSize)}`;
|
|
}
|