import type IProductCategory from '@/domain/iProductCategory.ts'; import type ISupplier from '@/domain/iSupplier.ts'; import type {ISysFileInfo} from "@/domain/iSysFile.ts"; /** 商品等级展示价(后端按等级上浮比例换算:售价 = 成本价 × (100 + percent) / 100) */ export interface IProductPrice { /** 客户等级ID */ level_id?: number; /** 该等级的价格上浮比例(%) */ percent?: string | number; /** 换算后的售价(两位小数字符串) */ price?: string | number | null; level?: { id: number; name: string }; } /** 商品档案 */ export default interface IProduct { /** 商品ID */ id?: number; /** 分类ID */ category_id?: number; /** 供应商ID */ supplier_id?: number; /** 市场(如:新发地、岳各庄) */ market?: string; /** 商品名称 */ name?: string; /** 规格/包规 */ spec?: string; /** 计价单位 */ unit?: string; /** 封面 */ image_ids?: string; images_arr?: ISysFileInfo[]; /** 商品图文详情(富文本 HTML) */ content?: string; /** 排序 */ sort?: number; /** 保质期 */ shelf_life?: number; /** 库存 */ stock?: number; /** 状态 */ status?: number; /** 成本价(元,等级上浮计价的基数) */ cost_price?: string | number; /** 描述 */ remark?: string; /** 分类关联数据 */ category?: IProductCategory; /** 供应商关联数据 */ supplier?: ISupplier; /** 各启用等级的换算展示价 */ prices?: IProductPrice[]; /** 创建时间 */ created_at?: string; } export const PRODUCT_STATUS_MAP: Record = { 0: { text: '下架', color: 'default' }, 1: { text: '上架', color: 'success' }, }; /** * 价格矩阵行:固定列 + price_{level_id}(按等级上浮比例换算的售价)动态列 */ export type IPriceMatrixRow = { id: number; name: string; spec?: string; unit?: string; /** 成本价(null = 未设置或已清除) */ cost_price?: string | number | null; } & Record; export interface IPriceMatrix { levels: { id: number; name: string; percent: string | number }[]; rows: IPriceMatrixRow[]; total: number; } /** * 批量调价更新行:{ product_id, cost_price } * (等级售价 = 成本价 × (100 + 等级上浮比例) / 100,调价即调成本价) */ export interface IBatchPriceUpdate { product_id: number; /** 成本价 */ cost_price?: number; }