feat(main-system): 免入库单取货链路 + 实收数量「事实登记 + 事后同步」
免入库(主系统骑手上门取货): - 50 展示「待取货」、副文案「待主系统骑手上门取货」、不建我方配送任务(守卫与开关解耦) - 我方 50 即回写备货完成;两开关(SKIP_INBOUND_AWAIT_PICKUP / FULFILLMENT_EVENTS)改默认开 核货事实镜像(「核货完毕」标记): - 按主系统 lookup 的 actual_qty 落台账,新增 GET/POST /orders/:orderCode/main-system-prep-facts[/refresh] - 详情行内显示「核货完毕」(含核货量),分配对账兜底刷新 实收数量/单位口径变更(对方先改 + 我方事后同步): - 台账加 applied_at;inbound 与 picking_check 同为事实登记(驳回不回滚) - 同意才落我方值:免入库改装车核货量、送仓改验收实收(已入库走既有库存调整)、已结算/已结案只留痕 - 计划量与金额一起改,并同步结算投影(syncStatementsForOrderSafe) - 审核页语义改「主系统实际值(已生效)/ 是否同步」+ 已处理历史(双方时间与落值结论) 台账对照与回写修复: - 行级对照改整单一次性(同名商品不再重复认领)+ 存量纠正 healOrderPrepMapping - 堵住客户绑定回填旁路(免入库单不再被派我方骑手) - 回写触发函数改对象参数(修 branch/order 传反导致的静默不回写) 文档:设计文档 4 篇 +《给主系统 AI 的对接改造清单》§2.9(第六批契约) 回归:服务端全量与 HEAD 基线一致(24 个失败文件同集合);前端 140 文件 / 699 测试全绿;tsc 双端干净
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildRuntimeMenuTree, mergeNavMenuLayout, type NavMenuLayoutConfig } from './menuLayout';
|
||||
|
||||
/**
|
||||
* 回归:**新增的二级菜单必须真的出现在已保存过布局的租户侧边栏里**。
|
||||
*
|
||||
* 背景(2026-10-11 实测到的用户问题):平台 `public.system_configs.nav_menu_layout`
|
||||
* (branch_code IS NULL)是 2026-10-08 保存的,分组只有「基础数据 / 业务流程 / 财务结算 / 系统管理」,
|
||||
* **没有** `DEFAULT_GROUPS` 里的 `grp-orders`(订单管理)。
|
||||
* 合并逻辑会为默认分组里"还没被安置"的条目**新建** `grp-orders` 分组,但随后
|
||||
* `merged.order` 被"保存的 order"整体覆盖 ⇒ 该分组存在于 `groups` 却不在 `order` 里,
|
||||
* 而 `buildRuntimeMenuTree` **只按 `order` 渲染** ⇒ 分组连同新菜单项永远不显示。
|
||||
*
|
||||
* 因此这里同时钉两条:
|
||||
* ① 合并结果里不允许存在"有可见条目却没有 order 条目"的孤儿分组;
|
||||
* ② 运行时菜单树(= 侧边栏真正用的数据)必须包含新菜单项。
|
||||
*/
|
||||
|
||||
const SAVED_LAYOUT_FIXTURE = {
|
||||
version: 1,
|
||||
order: [
|
||||
{ kind: 'standalone', menuKey: 'dashboard' },
|
||||
{ kind: 'standalone', menuKey: 'customer-order' },
|
||||
{ kind: 'group', groupId: 'grp-products' },
|
||||
{ kind: 'group', groupId: 'grp-suppliers' },
|
||||
{ kind: 'group', groupId: 'grp-finance' },
|
||||
{ kind: 'group', groupId: 'grp-system' },
|
||||
],
|
||||
standalone: [
|
||||
{ menuKey: 'customer-order', visible: true },
|
||||
{ menuKey: 'dashboard', visible: true },
|
||||
],
|
||||
groups: [
|
||||
{
|
||||
id: 'grp-products',
|
||||
label: '基础数据',
|
||||
icon: 'Store',
|
||||
visible: true,
|
||||
items: [
|
||||
{ menuKey: 'customers-list', visible: true },
|
||||
{ menuKey: 'products-skus', visible: true },
|
||||
{ menuKey: 'orders-bids', visible: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'grp-suppliers',
|
||||
label: '业务流程',
|
||||
icon: 'ClipboardCheck',
|
||||
visible: true,
|
||||
items: [
|
||||
{ menuKey: 'orders-list', visible: true },
|
||||
{ menuKey: 'purchase-list', visible: true },
|
||||
{ menuKey: 'purchase-preparations', visible: true },
|
||||
{ menuKey: 'delivery', visible: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'grp-finance',
|
||||
label: '财务结算',
|
||||
icon: 'Wallet',
|
||||
visible: true,
|
||||
items: [{ menuKey: 'finance-overview', visible: true }],
|
||||
},
|
||||
{
|
||||
id: 'grp-system',
|
||||
label: '系统管理',
|
||||
icon: 'Settings',
|
||||
visible: true,
|
||||
items: [{ menuKey: 'system-config', visible: true }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function collectRuntimeKeys(layout: NavMenuLayoutConfig): string[] {
|
||||
const keys: string[] = [];
|
||||
for (const node of buildRuntimeMenuTree(layout)) {
|
||||
if (node.menuKey) keys.push(node.menuKey);
|
||||
for (const child of node.children || []) {
|
||||
if (child.menuKey) keys.push(child.menuKey);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
describe('菜单布局合并:新增二级菜单不得因为"默认分组不存在"而丢失', () => {
|
||||
it('不允许出现"有可见条目却没有 order 条目"的孤儿分组', () => {
|
||||
const layout = mergeNavMenuLayout(SAVED_LAYOUT_FIXTURE);
|
||||
const orderedGroupIds = new Set(
|
||||
layout.order.filter((entry) => entry.kind === 'group').map((entry) => entry.groupId)
|
||||
);
|
||||
const orphans = layout.groups
|
||||
.filter((group) => group.visible && group.items.some((item) => item.visible))
|
||||
.filter((group) => !orderedGroupIds.has(group.id))
|
||||
.map((group) => `${group.id}/${group.label}`);
|
||||
expect(orphans, `孤儿分组(存在但不在 order 里,永远不会渲染):${orphans.join(', ')}`).toEqual([]);
|
||||
});
|
||||
|
||||
it('运行时菜单树(侧边栏数据源)必须包含 orders-price-qty', () => {
|
||||
const layout = mergeNavMenuLayout(SAVED_LAYOUT_FIXTURE);
|
||||
const keys = collectRuntimeKeys(layout);
|
||||
expect(keys).toContain('orders-price-qty');
|
||||
});
|
||||
|
||||
it('落在「业务流程」分组里,且**紧跟在「供应商备货表」下方**(用户指定位置)', () => {
|
||||
const layout = mergeNavMenuLayout(SAVED_LAYOUT_FIXTURE);
|
||||
const business = layout.groups.find((group) => group.label === '业务流程');
|
||||
expect(business, '找不到业务流程分组').toBeTruthy();
|
||||
const keys = (business?.items || []).map((item) => item.menuKey);
|
||||
const anchor = keys.indexOf('purchase-preparations');
|
||||
expect(anchor, '业务流程里找不到供应商备货表').toBeGreaterThanOrEqual(0);
|
||||
expect(keys[anchor + 1], `供应商备货表下一项应为 orders-price-qty,实际为 ${keys[anchor + 1]}`).toBe(
|
||||
'orders-price-qty'
|
||||
);
|
||||
// 不再单独建「订单管理」分组
|
||||
expect(layout.groups.some((group) => group.id === 'grp-orders')).toBe(false);
|
||||
});
|
||||
|
||||
it('已保存分组的顺序与既有条目不被破坏(只追加,不入侵)', () => {
|
||||
const layout = mergeNavMenuLayout(SAVED_LAYOUT_FIXTURE);
|
||||
const business = layout.groups.find((group) => group.id === 'grp-suppliers');
|
||||
const existingOrder = ['orders-list', 'purchase-list', 'purchase-preparations', 'delivery'];
|
||||
const keys = (business?.items || []).map((item) => item.menuKey);
|
||||
// 既有条目相对顺序不变(本次只插入了一项,没有重排)
|
||||
expect(keys.filter((key) => existingOrder.includes(key))).toEqual(existingOrder);
|
||||
expect(business?.label).toBe('业务流程');
|
||||
// 保存过的顺序不能被重排:前 6 项与保存一致
|
||||
expect(layout.order.slice(0, 6)).toEqual(SAVED_LAYOUT_FIXTURE.order);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user