From 8e679da8e3a81c7c7f94b703ab880baaf2294f71 Mon Sep 17 00:00:00 2001 From: wuzilong <704541015@qq.com> Date: Sat, 7 Nov 2026 12:41:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(pl):=20=E5=9C=A8=E7=8E=B0=E5=9C=BA?= =?UTF-8?q?=E6=97=A5=E5=8E=86=E5=A4=8D=E5=88=B6=E6=96=87=E6=9C=AC=E4=B8=AD?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=85=A5=E5=BA=93=E5=92=8C=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E8=BD=A6=E6=AC=A1=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 便于按产品一眼看出入出数量,并把入库明细排在出库前面。 Co-authored-by: Cursor --- .../scripts/manual-dispatch-calendar.test.ts | 54 ++++++++++++++++--- .../pl/dispatch-calendar/manual-model.ts | 35 ++++++++++-- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/web-admin/scripts/manual-dispatch-calendar.test.ts b/web-admin/scripts/manual-dispatch-calendar.test.ts index 118824d85..23ff1d4a4 100644 --- a/web-admin/scripts/manual-dispatch-calendar.test.ts +++ b/web-admin/scripts/manual-dispatch-calendar.test.ts @@ -151,6 +151,12 @@ test('数量是可空文本,复制逐条展示,日汇总仍只计车次', () }) test('现场复制隐藏起止地和备注,单据类型放在每条记录末尾的中文括号中', () => { + const summary: Record = { + 入库计划: '(入2车)', + 出库计划: '(出2车)', + 出入库计划: '', + 现场调拨: '' + } for (const documentType of ['入库计划', '出库计划', '出入库计划', '现场调拨']) { const record = { ...row('site'), @@ -165,7 +171,7 @@ test('现场复制隐藏起止地和备注,单据类型放在每条记录末 [ '2026-10-26 派车计划:', '', - '液碱2车', + `液碱 2车${summary[documentType]}`, ` ·皖H12345 液碱 32.50吨(${documentType})`, ` ·皖H12345 液碱(${documentType})` ] @@ -185,7 +191,7 @@ test('现场复制隐藏起止地和备注,单据类型放在每条记录末 } assert.equal( manualCopyText('2026-10-26', [record]), - '2026-10-26 派车计划:\n\n液碱1车\n ·皖H12345 液碱' + '2026-10-26 派车计划:\n\n液碱 1车\n ·皖H12345 液碱' ) } }) @@ -226,12 +232,12 @@ test('现场按产品分组统计,交错产品集中展示且符合指定复 [ '2026-11-01 派车计划:', '', - '98% 工业硫酸1车', + '98% 工业硫酸 1车(出1车)', ' ·皖H10291 98% 工业硫酸 32吨(出库计划)', - '精制硫酸2车', + '精制硫酸 2车(出2车)', ' ·皖H57837 精制硫酸 32吨(出库计划)', ' ·皖HA3190 精制硫酸 32吨(出库计划)', - '50% 工业硫酸1车', + '50% 工业硫酸 1车(出1车)', ' ·皖HA3690 50% 工业硫酸 28吨(出库计划)' ].join('\n') ) @@ -241,6 +247,40 @@ test('现场按产品分组统计,交错产品集中展示且符合指定复 ) }) +test('现场产品组统计入出车次,入库排在出库前面,其他类型不计入入出', () => { + const site = ( + id: string, + licensePlate: string, + documentType: string, + createTime: string + ) => ({ + ...row(id, '2026-11-01', licensePlate), + calendarKind: 'site' as const, + productName: '98%工业硫酸', + licensePlate, + quantity: '32', + documentType, + createTime + }) + assert.equal( + manualCopyText('2026-11-01', [ + site('out-later', '皖H58559', '出库计划', '2026-11-01 10:00:00'), + site('direct', '皖H10001', '直销计划', '2026-11-01 07:00:00'), + site('in', '皖H57837', ' 入库计划 ', '2026-11-01 11:00:00'), + site('out-early', '皖H56153', '出库计划', '2026-11-01 08:00:00') + ]), + [ + '2026-11-01 派车计划:', + '', + '98%工业硫酸 4车(入1车 出2车)', + ' ·皖H57837 98%工业硫酸 32吨(入库计划)', + ' ·皖H56153 98%工业硫酸 32吨(出库计划)', + ' ·皖H58559 98%工业硫酸 32吨(出库计划)', + ' ·皖H10001 98%工业硫酸 32吨(直销计划)' + ].join('\n') + ) +}) + test('现场同车重复记录逐条计车,同名不同产品ID保持独立且组内按创建顺序', () => { const first = { ...row('1'), calendarKind: 'site' as const, createTime: '2026-10-26 01:00:00' } const later = { ...first, id: '2', createTime: '2026-10-26 02:00:00', quantity: '20' } @@ -250,10 +290,10 @@ test('现场同车重复记录逐条计车,同名不同产品ID保持独立且 [ '2026-10-26 派车计划:', '', - '液碱2车', + '液碱 2车', ' ·皖H12345 液碱', ' ·皖H12345 液碱 20吨', - '液碱1车', + '液碱 1车', ' ·皖H12345 液碱' ].join('\n') ) diff --git a/web-admin/src/views/pl/dispatch-calendar/manual-model.ts b/web-admin/src/views/pl/dispatch-calendar/manual-model.ts index 22e4d8a10..31b8c1e9f 100644 --- a/web-admin/src/views/pl/dispatch-calendar/manual-model.ts +++ b/web-admin/src/views/pl/dispatch-calendar/manual-model.ts @@ -104,11 +104,40 @@ export function manualQuantityLabel(quantity?: string | null) { return text ? `${text}吨` : '' } +function siteDocumentType(row: DispatchCalendarRecord) { + return (row.documentType || '').trim().replace(/\s+/g, ' ') +} + +/** 入库、出库单独计车;直销、调拨等其他类型不进入括号统计。 */ +function siteFlowSummary(rows: DispatchCalendarRecord[]) { + let inbound = 0 + let outbound = 0 + for (const row of rows) { + const documentType = siteDocumentType(row) + if (documentType === '入库计划') inbound += 1 + else if (documentType === '出库计划') outbound += 1 + } + const parts = [] + if (inbound) parts.push(`入${inbound}车`) + if (outbound) parts.push(`出${outbound}车`) + return parts.length ? `(${parts.join(' ')})` : '' +} + +function siteCopyOrder(a: DispatchCalendarRecord, b: DispatchCalendarRecord) { + const rank = (row: DispatchCalendarRecord) => { + const documentType = siteDocumentType(row) + if (documentType === '入库计划') return 0 + if (documentType === '出库计划') return 1 + return 2 + } + return rank(a) - rank(b) || byCreateOrder(a, b) +} + function manualTripText(row: DispatchCalendarRecord) { const quantity = manualQuantityLabel(row.quantity) const amount = quantity ? ` ${quantity}` : '' if (row.calendarKind === 'site') { - const documentType = (row.documentType || '').trim().replace(/\s+/g, ' ') + const documentType = siteDocumentType(row) return `${row.productName}${amount}${documentType ? `(${documentType})` : ''}` } const remark = row.remark ? `(${row.remark.replace(/\s+/g, ' ')})` : '' @@ -129,9 +158,9 @@ export function manualCopyText(date: string, rows: DispatchCalendarRecord[]) { `${date} 派车计划:`, '', ...[...products.values()].flatMap((group) => [ - `${group.name}${group.rows.length}车`, + `${group.name} ${group.rows.length}车${siteFlowSummary(group.rows)}`, ...group.rows - .sort(byCreateOrder) + .sort(siteCopyOrder) .map((row) => ` ·${row.licensePlate} ${manualTripText(row)}`) ]) ].join('\n')