diff --git a/server/src/services/productTraceService.ts b/server/src/services/productTraceService.ts index 979c811..ced2a77 100644 --- a/server/src/services/productTraceService.ts +++ b/server/src/services/productTraceService.ts @@ -238,6 +238,8 @@ const TRACE_LOG_TYPE_LABELS: Record = { delivery_loading_out: '配送核货出库', delivery_loading_restore: '发车撤销回补', processing_out: '加工出库', + processing_in: '加工入库', + processing_return: '加工退料', adjust: '库存调整', order_item_return: '退货回冲入库', in: '入库', diff --git a/src/i18n/locales/en/inventory.ts b/src/i18n/locales/en/inventory.ts index 6344314..09843d3 100644 --- a/src/i18n/locales/en/inventory.ts +++ b/src/i18n/locales/en/inventory.ts @@ -91,6 +91,7 @@ export const inventory: MessageDict = { 'op.picking_out': 'Picking out', 'op.delivery_loading_out': 'Delivery loading out', 'op.retail_out': 'Walk-in sale outbound', + 'op.processing_in': 'Processing stock-in', 'op.processing_out': 'Processing out', 'op.processing_return': 'Processing return', 'op.in': 'In', diff --git a/src/i18n/locales/id/inventory.ts b/src/i18n/locales/id/inventory.ts index f75d13a..7e0c03e 100644 --- a/src/i18n/locales/id/inventory.ts +++ b/src/i18n/locales/id/inventory.ts @@ -95,6 +95,7 @@ export const inventory: MessageDict = { 'op.picking_out': 'Keluar picking', 'op.delivery_loading_out': 'Keluar muat kirim', 'op.retail_out': 'Keluar penjualan eceran', + 'op.processing_in': 'Masuk stok hasil proses', 'op.processing_out': 'Keluar olah', 'op.processing_return': 'Retur olah', 'op.in': 'Masuk', diff --git a/src/i18n/locales/zh-CN/inventory.ts b/src/i18n/locales/zh-CN/inventory.ts index ae6102e..bbf33f0 100644 --- a/src/i18n/locales/zh-CN/inventory.ts +++ b/src/i18n/locales/zh-CN/inventory.ts @@ -90,6 +90,7 @@ export const inventory: MessageDict = { 'op.picking_out': '分拣出库', 'op.delivery_loading_out': '配送核货出库', 'op.retail_out': '散客出库', + 'op.processing_in': '加工入库(成品)', 'op.processing_out': '加工出库', 'op.processing_return': '加工退料', 'op.in': '入库', diff --git a/src/pages/inventory/InventoryManagement.opLabels.contract.test.ts b/src/pages/inventory/InventoryManagement.opLabels.contract.test.ts new file mode 100644 index 0000000..6a72fa4 --- /dev/null +++ b/src/pages/inventory/InventoryManagement.opLabels.contract.test.ts @@ -0,0 +1,34 @@ +import { readFileSync } from 'node:fs'; +import { describe, expect, it } from 'vitest'; + +/** + * 库存流水「操作类型」必须有中文标签(2026-10-23 开发者报障: + * 独立加工产出的流水显示成裸代码 `processing_in`)。 + * 口径:缺 key 时会原样显示代码 ⇒ 新增流水类型必须三语齐全,并在颜色映射里归类。 + */ +const zh = readFileSync(new URL('../../i18n/locales/zh-CN/inventory.ts', import.meta.url), 'utf8'); +const en = readFileSync(new URL('../../i18n/locales/en/inventory.ts', import.meta.url), 'utf8'); +const id = readFileSync(new URL('../../i18n/locales/id/inventory.ts', import.meta.url), 'utf8'); +const page = readFileSync(new URL('./InventoryManagement.tsx', import.meta.url), 'utf8'); + +describe('库存流水操作类型:processing_in 有中文标签', () => { + it('三语都有 op.processing_in', () => { + expect(zh).toContain("'op.processing_in'"); + expect(en).toContain("'op.processing_in'"); + expect(id).toContain("'op.processing_in'"); + }); + + it('中文名明确是「加工入库」而不是裸代码', () => { + expect(zh).toMatch(/'op\.processing_in':\s*'加工入库[^']*'/); + }); + + it('入库类流水在颜色映射里归为入库(绿色),不落到中性灰', () => { + const block = page.slice(page.indexOf('const getOperationTypeColor'), page.indexOf('/** 流水 quantity 存正数')); + expect(block).toContain('processing_in:'); + expect(block).toMatch(/processing_in:\s*'bg-emerald-50/); + }); + + it('渲染时通过 i18n key 取标签,缺 key 才回退代码(不是硬编码中文)', () => { + expect(page).toContain('const key = `inventory.op.${type}`;'); + }); +}); diff --git a/src/pages/inventory/InventoryManagement.tsx b/src/pages/inventory/InventoryManagement.tsx index 40fb471..1998460 100644 --- a/src/pages/inventory/InventoryManagement.tsx +++ b/src/pages/inventory/InventoryManagement.tsx @@ -792,6 +792,7 @@ export const InventoryManagement: React.FC = () => { delivery_loading_out: 'bg-red-50 text-red-700 dark:bg-red-950/50 dark:text-red-300', processing_out: 'bg-red-50 text-red-700 dark:bg-red-950/50 dark:text-red-300', processing_return: 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/50 dark:text-emerald-300', + processing_in: 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/50 dark:text-emerald-300', in: 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/50 dark:text-emerald-300', out: 'bg-red-50 text-red-700 dark:bg-red-950/50 dark:text-red-300', adjust: 'bg-amber-50 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300',