chore: 以 AI 生鲜配送系统 当前版本作为 SupplierSystem 起点
来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
// @vitest-environment jsdom
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import {
|
||||
buildDeliveryNotePrintHtml,
|
||||
type DeliveryNotePrintPayload,
|
||||
} from './deliveryNotePrint';
|
||||
import { buildDeliveryHtmlTemplateDocument } from './deliveryHtmlTemplateRender';
|
||||
import type { DeliveryHtmlTemplate } from './deliveryHtmlTemplates';
|
||||
import type { DeliveryNotePrintGroup } from './deliveryNotePrint';
|
||||
import { DELIVERY_ITEM_COLUMNS } from './exportColumnPresets';
|
||||
import { DEFAULT_DELIVERY_NOTE_LAYOUT } from './printTemplates';
|
||||
|
||||
const FULL_CODE = 'ORD_WEB_20260923_BR002_0001';
|
||||
const SHORT_CODE = '20260923_BR002_0001';
|
||||
|
||||
const order = {
|
||||
order_code: FULL_CODE,
|
||||
delivery_date: '2026-09-23',
|
||||
branch_name: '分公司',
|
||||
};
|
||||
|
||||
const group: DeliveryNotePrintGroup = {
|
||||
groupKey: FULL_CODE,
|
||||
customer_code: 'C001',
|
||||
customer_name: '客户甲',
|
||||
orders: [order],
|
||||
lines: [
|
||||
{
|
||||
order_code: FULL_CODE,
|
||||
sku_code: 'S1',
|
||||
sku_name: '土豆',
|
||||
quantity: 1,
|
||||
unit: '斤',
|
||||
price: 12,
|
||||
amount: 12,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* 单据上的订单号只显示短号(2026-10-06 用户要求):
|
||||
* `ORD_WEB_20260923_BR002_0001` → `20260923_BR002_0001`。
|
||||
* 两种版式(旧版明细表 / AI HTML 模板)都要一致;分组键仍用完整单号。
|
||||
*/
|
||||
describe('配送单订单号展示', () => {
|
||||
it('旧版打印文档:单据编号与抬头订单号都是短号', () => {
|
||||
const payload: DeliveryNotePrintPayload = {
|
||||
title: '配送单',
|
||||
groups: [group],
|
||||
columns: DELIVERY_ITEM_COLUMNS as DeliveryNotePrintPayload['columns'],
|
||||
selectedColumnIds: DELIVERY_ITEM_COLUMNS.map((col) => col.id),
|
||||
metaFields: ['order_code'],
|
||||
layout: DEFAULT_DELIVERY_NOTE_LAYOUT,
|
||||
};
|
||||
|
||||
const { html } = buildDeliveryNotePrintHtml(payload);
|
||||
|
||||
expect(html).toContain(SHORT_CODE);
|
||||
expect(html).not.toContain(FULL_CODE);
|
||||
});
|
||||
|
||||
it('AI HTML 模板:{{order.order_code}} 渲染成短号', () => {
|
||||
const template: DeliveryHtmlTemplate = {
|
||||
id: 'oc', name: 'oc',
|
||||
html:
|
||||
'<table><tbody>{{#items}}<tr><td>{{item.sku_name}}</td></tr>{{/items}}</tbody></table>' +
|
||||
'<div>订单号:{{order.order_code}}</div>',
|
||||
css: '',
|
||||
paper: { widthMm: 210, heightMm: 297, marginMm: 8 },
|
||||
bindings: [], isDefault: false, updatedAt: '',
|
||||
};
|
||||
|
||||
const html = buildDeliveryHtmlTemplateDocument(template, [group]);
|
||||
|
||||
expect(html).toContain(`订单号:${SHORT_CODE}`);
|
||||
expect(html).not.toContain(FULL_CODE);
|
||||
});
|
||||
|
||||
it('分组键没有被改写(仍是完整单号)', () => {
|
||||
expect(group.groupKey).toBe(FULL_CODE);
|
||||
});
|
||||
|
||||
it('打印配送单弹窗:标题变量也走短号(默认标题模板是 `配送订单 {{order_code}}`)', () => {
|
||||
const src = readFileSync(
|
||||
path.join(__dirname, '../components/export/DeliveryNotePrintModal.tsx'),
|
||||
'utf8'
|
||||
);
|
||||
expect(src).toContain('orderCodeDisplayTitleVars(titleVars)');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user