Files
xin-procurement/web/domain/iPurchaseOrder.ts
T
2026-08-13 00:11:44 +08:00

116 lines
3.2 KiB
TypeScript

/** 采购明细门店单元格(溯源订货明细) */
export interface IPurchaseStoreCell {
order_item_id: number;
store_id: number;
quantity: number;
weight: number;
/** 金额 = 称重>0 ? 称重×单价 : 数量×单价(单价 = 成本/包规) */
amount: number;
}
/** 采购明细行(商品维度聚合,行 × 门店列矩阵) */
export interface IPurchaseDetailRow {
product_id: number;
product_name: string;
/** 规格/包规 */
product_spec: string;
unit: string;
supplier_id: number;
supplier?: { id: number; name: string } | null;
/** 成本 */
cost_price: number;
/** 合计数量 */
quantity: number;
/** 合计实际称重 */
weight: number;
cells: Record<number, number>;
}
/** 采购单 */
export default interface IPurchaseOrder {
id?: number;
purchase_no?: string;
purchase_date?: string;
/** 0进行中 3已完成 */
status?: number;
total_quantity?: string;
total_weight?: string;
estimate_amount?: string;
actual_amount?: string;
operator_id?: number;
operator?: { id: number; nickname: string };
remark?: string;
created_at?: string;
}
/** 采购单详情(矩阵数据) */
export interface IPurchaseDetail {
purchase: IPurchaseOrder;
stores: { id: number; name: string }[];
items: IPurchaseDetailRow[];
}
/** 单元格下钻明细行(溯源订货单明细,附订单号/状态/可编辑标记) */
export interface IPurchaseCellItem {
id: number;
order_id: number;
order_no: string;
order_date: string;
/** 订货单状态:0待接单 1已接单 2采购中 3配送中 4已完成 9已取消 */
order_status: number;
product_name: string;
product_spec: string;
unit: string;
supplier_id: number;
supplier?: { id: number; name: string } | null;
/** 等级单价 */
price: string;
cost_price: string;
quantity: number;
weight: string;
/** 金额 = 数量×单价(整数金额返回 number) */
amount: number | string;
remark: string;
/** 首图 */
image?: string;
/** 是否可编辑/同步(采购单进行中且订货单未锁定) */
editable: boolean;
}
/** 单元格下钻数据(门店 + 商品 + 全部订货明细) */
export interface IPurchaseCell {
store: { id: number; name: string } | null;
product: { id: number; name: string } | null;
items: IPurchaseCellItem[];
}
/** 门店购买详情行(门店采购汇总,按商品聚合) */
export interface IPurchaseStoreItem {
product_id: number;
product_name: string;
/** 规格/包规 */
product_spec: string;
unit: string;
/** 单价(每包;多笔单价时为加权平均,保证 单价×数量=预计金额) */
price: string;
/** 数量(包数) */
quantity: number;
/** 预计金额 = Σ 明细 amount */
amount: string;
weight: string;
}
/** 门店购买详情(采购单内某门店的采购汇总) */
export interface IPurchaseStoreSummary {
store: { id: number; name: string } | null;
items: IPurchaseStoreItem[];
}
export const PURCHASE_STATUS_MAP: Record<number, { text: string; color: string }> = {
0: { text: '进行中', color: 'processing' },
3: { text: '已完成', color: 'success' },
};
export type PurchaseExportType = 'all' | 'category';
export type ExportFormat = 'xlsx' | 'pdf';