furniture-3d-system-Wu/furniture-3d-system/src/lib/supply-chain-product-archive-change-log.ts

108 lines
3.6 KiB
TypeScript

export const PRODUCT_ARCHIVE_CHANGE_LOG_SCOPE = 'SUPPLY_CHAIN_PRODUCT_ARCHIVE'
export const PRODUCT_ARCHIVE_CHANGE_FIELDS = [
{ key: 'inOutWarehouse', label: '出入库仓库(采购类型)' },
{ key: 'spu', label: 'SPU' },
{ key: 'sku', label: 'SKU' },
{ key: 'businessCreatedAt', label: '创建时间' },
{ key: 'categoryL1', label: '一级类目' },
{ key: 'categoryL2', label: '二级类目' },
{ key: 'productName', label: '商品名称' },
{ key: 'designer', label: '设计师' },
{ key: 'productStatus', label: '商品状态' },
{ key: 'material', label: '材质' },
{ key: 'color', label: '颜色' },
{ key: 'weight', label: '重量' },
{ key: 'length', label: '长' },
{ key: 'width', label: '宽' },
{ key: 'height', label: '高' },
{ key: 'volume', label: '体积' },
{ key: 'packType', label: '单双包' },
{ key: 'productTag', label: '商品标签' },
{ key: 'installDocId', label: '安装图纸/视频ID' },
{ key: 'hasDrawing', label: '是否有图纸' },
{ key: 'hasVideo', label: '是否有视频' },
{ key: 'spec', label: '产品尺寸' },
{ key: 'brand', label: '品牌' },
{ key: 'orderType', label: '叫货类型' },
{ key: 'storageType', label: '入库/代发' },
{ key: 'isSeasonal', label: '是否季节性产品' },
{ key: 'replaceCount', label: '替换款数量' },
{ key: 'supplierName', label: '供应商' },
{ key: 'supplierType', label: '供应商类型' },
{ key: 'supplierStatus', label: '供应商状态' },
{ key: 'purchaseOwner', label: '采购' },
{ key: 'settlementMethod', label: '结算方式' },
{ key: 'boardProvider', label: '板材提供方' },
{ key: 'penaltyStatus', label: '违约金赔付状态' },
{ key: 'warehouseType', label: '仓库属性' },
{ key: 'warehouseHead', label: '仓库负责人' },
{ key: 'minimumOrderQuantity', label: '产品起订量' },
{ key: 'firstLeadTime', label: '首单生产周期' },
{ key: 'palletSpec', label: '托盘参数' },
{ key: 'dailySales', label: '采购日销' },
{ key: 'sales3d', label: '3日日销' },
{ key: 'sales7d', label: '7日日销' },
{ key: 'sales15d', label: '15日日销' },
{ key: 'purchasePrice', label: '采购价' },
{ key: 'costPrice', label: '成本价(聚水潭)' },
{ key: 'costPriceSecondary', label: '成本价(新品)' },
] as const
export type ProductArchiveChangeFieldKey =
(typeof PRODUCT_ARCHIVE_CHANGE_FIELDS)[number]['key']
export type ProductArchiveFieldChange = {
field: ProductArchiveChangeFieldKey
fieldLabel: string
previousValue: string
nextValue: string
}
export type ProductArchiveChangeLogDetails = {
kind: 'IMPORTED' | 'UPDATED'
barcode: string
field?: ProductArchiveChangeFieldKey
fieldLabel?: string
previousValue?: string
nextValue?: string
sourceSystem?: string
sourceSchema?: string
sourceObject?: string
sourceRecordedAt?: string
}
export type ProductArchiveChangeLogItem = {
id: string
barcode: string
action: string
source: 'USER' | 'SYSTEM'
actorName: string
message: string
details: ProductArchiveChangeLogDetails
createdAt: string
}
export type ProductArchiveChangeLogPage = {
logs: ProductArchiveChangeLogItem[]
pageInfo: {
page: number
pageSize: number
total: number
totalPages: number
}
}
export function formatProductArchiveChangeSource(
source: 'USER' | 'SYSTEM',
actorName: string,
details: ProductArchiveChangeLogDetails,
) {
if (source === 'USER') return actorName || '系统用户'
const sourceName = [details.sourceSystem, details.sourceSchema, details.sourceObject]
.filter(Boolean)
.join(' / ')
return sourceName ? `数据库推送:${sourceName}` : actorName || '数据库推送'
}