Files
xin-procurement/web/domain/iPurchaseOrder.ts
T
2026-08-14 21:28:55 +08:00

184 lines
5.5 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[];
/** 门店账单(采购单完成后按门店生成) */
bills: IBill[];
}
/** 门店账单(采购单完成后按门店生成,商品金额为订单汇总快照不可修改) */
export interface IBill {
id: number;
bill_no: string;
purchase_id: number;
store_id: number;
store_name?: string;
bill_date: string;
/** 商品金额(订单商品金额汇总) */
product_amount: string;
/** 配送费(生成账单时填写) */
delivery_fee: string;
box_num: number;
tray_num: number;
/** 周转筐单价(生成时快照) */
box_price: string;
/** 周转托盘单价(生成时快照) */
tray_price: string;
/** 附加金额 = 周转筐×筐单价 + 托盘×托盘单价 */
added_amount: string;
/** 账单总金额 = 商品金额 + 配送费 + 附加金额 */
total_amount: string;
/** 支付状态:0未支付 1已支付 */
status?: number;
/** 关联支付记录ID(0=未发起支付) */
payment_id?: number;
/** 付款时间(线下收款手动登记) */
paid_at?: string | null;
/** 付款备注(线下收款信息) */
pay_remark?: string;
paid_operator_id?: number;
order_count?: number;
remark?: string;
created_at?: string;
/** 门店账单列表/详情接口附带 */
store?: { id: number; name: string; address?: string; contact?: string; phone?: string } | null;
purchase?: { id: number; purchase_no: string; purchase_date: string; status?: number } | null;
operator?: { id: number; nickname: string } | null;
paid_operator?: { id: number; nickname: string } | null;
orders_count?: number;
}
/** 账单支付状态映射 */
export const BILL_STATUS_MAP: Record<number, { text: string; color: string }> = {
0: { text: '未支付', color: 'warning' },
1: { text: '已支付', color: 'success' },
};
/** 账单生成预览行(按门店汇总,金额只读) */
export interface IBillPrepareStore {
store_id: number;
store_name: string;
order_count: number;
/** 商品金额(订单汇总,不可修改) */
product_amount: string;
/** 周转筐单价(站点配置) */
box_price: string;
/** 周转托盘单价(站点配置) */
tray_price: string;
/** 已生成的账单(未生成为 null) */
bill: IBill | null;
}
/** 账单生成预览(采购单 + 门店行) */
export interface IBillPrepare {
purchase: { id: number; purchase_no: string; status: number };
stores: IBillPrepareStore[];
}
/** 单元格下钻明细行(溯源订货单明细,附订单号/状态/可编辑标记) */
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;
}
/** 单元格下钻数据(门店 + 商品 + 全部订货明细) */
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 ExportFormat = 'xlsx' | 'pdf';