feat(chat): 调拨工作台接入类型配置与待匹配面板

来源选择卡改为加载启用类型(单一飞行请求,空态引导先到管理页配置),
调拨类型为匹配必选项(422 提示);批次号派生接转换规则(deriveBatchNo 三态:
原始值/前缀替换/无规则),与后端转换引擎同口径。

首页面板新增第四张待匹配卡(indigo):待匹配桶=启用类型范围并集内无有效明细的
异动档记录,只读抽屉查看、去匹配直达;四语言文案补齐。
This commit is contained in:
hugo committed 2026-10-15 13:08:04 +08:00
1 parent 3a19f9c27d
commit e4100815a0
18 files changed
+651 -100

No files matched your search

@@ -1,18 +1,22 @@
/**
* features/chat/components/messages/TransferSourceSelectCard.spec.ts
* 用途:来源实例选择卡——平台分组、全选已启用、清空、按收料文件状态门禁确认、
* 确认提交、重试收料 RPA。
* 确认提交、重试收料 RPA;调拨类型选项=接口下发(Task 7 接口化):
* 选项渲染/名称多语言回退/空配置空态/确认禁用,「即将上线」占位不再出现。
* 依赖:@vue/test-utils、i18n。
* 逻辑:平台 DBS/Crane 仅分组;实例为选择与执行边界(决策 2/3/4);
* 确认需至少一个 has_ready_file(兜底告警);混合选择(含非就绪项)先披露范围
* 再确认(知情部分确认 2026-10-09,替代历史静默剔除),提交范围 ready-only;
* 重试门禁=仅 fetching 在途不可重试(ready 亦可强制重抓,2026-09-29 去管控)。
* 重试门禁=仅 fetching 在途不可重试(ready 亦可强制重抓,2026-09-29 去管控);
* 类型选项=props.transferTypes 接口真相(enabled 过滤与排序在后端契约内,
* 前端不过滤),名称 names[locale]→zh-CN→en→code 回退,空列表空态+确认禁用。
*/
import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import i18n from '@/i18n';
import TransferSourceSelectCard from './TransferSourceSelectCard.vue';
import { eligibleReceiptDateTo } from './transferDate';
import type { TransferTypeOption } from '../../types/transfer.types';
const readySources = [
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI 在途仓', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
@@ -20,9 +24,25 @@ const readySources = [
{ source_code: 'CRANE-SZ', display_name: '深圳在途仓', platform: 'crane', enabled: true, has_ready_file: true, file_status: 'ready' },
];
function mountCard(props = {}, sources = readySources) {
/** 接口下发的调拨类型选项(GET /transfer-types data 逐项形状,最小暴露四键)。 */
const defaultTransferTypes: TransferTypeOption[] = [
{
code: 'in_transit_to_hub',
names: { 'zh-CN': '在途仓至HUB仓', 'en': 'In-transit to HUB' },
sort_order: 10,
transform_rules: [{ field: 'lot_no', op: 'prefix_replace', source: 'WTP', target: 'HOW' }],
},
{
code: 'hub_to_hub',
names: { 'zh-CN': 'HUB仓间调拨' },
sort_order: 30,
transform_rules: [],
},
];
function mountCard(props = {}, sources = readySources, transferTypes: TransferTypeOption[] = defaultTransferTypes) {
return mount(TransferSourceSelectCard, {
props: { sources, ...props },
props: { sources, transferTypes, ...props },
global: { plugins: [i18n] },
});
}
@@ -261,19 +281,62 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['CRANE-EXP']);
});
it('确认默认携带调拨类型 in_transit_to_hub', async () => {
// [断言意图] 类型 1 为缺省选中值,确认事件第三参回传类型。
it('确认默认携带首个接口选项的调拨类型 code(缺省选中第一项)', async () => {
// [断言意图] 类型选项接口化(Task 7)后缺省选中不再是写死字面量,
// 而是接口下发列表的首项(现行配置首项= in_transit_to_hub),确认事件第三参回传。
const wrapper = mountCard();
expect(wrapper.find('[data-testid="transfer-type-option-in_transit_to_hub"]').classes()).toContain('bg-brand-600');
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.emitted('confirm')?.[0][2]).toBe('in_transit_to_hub');
});
it('调拨类型 2/3 占位禁用且不可选中', async () => {
// [断言意图] 一期仅开放类型 1;占位类型按钮 disabled,防止发起未支持链路。
it('调拨类型选项=接口下发数据逐项渲染,名称按 names 多语言显示,「即将上线」占位不再出现', () => {
// [断言意图] 选项即接口真相:props 给几个渲染几个(enabled 过滤与排序在后端契约内),
// 名称取 names[locale];写死三选项数组与「即将上线」徽标必须彻底消失。
const wrapper = mountCard();
expect((wrapper.find('[data-testid="transfer-type-option-hub_repair_out"]').element as HTMLButtonElement).disabled).toBe(true);
expect((wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').element as HTMLButtonElement).disabled).toBe(true);
expect((wrapper.find('[data-testid="transfer-type-option-in_transit_to_hub"]').element as HTMLButtonElement).disabled).toBe(false);
const options = wrapper.findAll('button[data-testid^="transfer-type-option-"]');
expect(options).toHaveLength(2);
expect(wrapper.find('[data-testid="transfer-type-option-in_transit_to_hub"]').text()).toContain('在途仓至HUB仓');
expect(wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').text()).toContain('HUB仓间调拨');
expect(wrapper.text()).not.toContain('即将上线');
});
it('类型名称回退:names 缺当前 locale 时依次回退 zh-CN → en → code', () => {
// [断言意图] 规格 §12.2 名称回退链:locale → zh-CN → en → code(code 是终极兜底,
// 未配置任何名称也不出现空白按钮)。
const types: TransferTypeOption[] = [
{ code: 'only_en', names: { en: 'Only EN' }, sort_order: 1, transform_rules: [] },
{ code: 'no_names', names: {}, sort_order: 2, transform_rules: [] },
];
const wrapper = mountCard({}, readySources, types);
expect(wrapper.find('[data-testid="transfer-type-option-only_en"]').text()).toContain('Only EN');
expect(wrapper.find('[data-testid="transfer-type-option-no_names"]').text()).toContain('no_names');
});
it('点击类型按钮切换选中(选中态高亮),确认携带所选 code', async () => {
// [断言意图] 选中类型 code 随 confirm 事件上抛(现有签名不变):
// 点击第二项后确认,第三参必须是其 code 而非缺省首项。
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').trigger('click');
expect(wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').classes()).toContain('bg-brand-600');
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.emitted('confirm')?.[0][2]).toBe('hub_to_hub');
});
it('类型配置为空:渲染空态文案,确认按钮禁用且 title 说明原因', () => {
// [断言意图] 空配置空态(规格 §12.2):空态文案 chat.transfer.transferTypeEmpty +
// 确认禁用(disabled + tooltip 说明原因),防止用户在无类型可配时发起匹配。
const wrapper = mountCard({}, readySources, []);
const empty = wrapper.find('[data-testid="transfer-type-empty"]');
expect(empty.exists()).toBe(true);
expect(empty.text()).toContain('暂无可用调拨类型');
const confirm = wrapper.find('[data-testid="transfer-source-confirm"]');
expect((confirm.element as HTMLButtonElement).disabled).toBe(true);
expect(confirm.attributes('title') ?? '').toContain('暂无可用调拨类型');
// 空态下不再渲染任何类型按钮,也不出现「即将上线」历史占位。
expect(wrapper.find('button[data-testid^="transfer-type-option-"]').exists()).toBe(false);
expect(wrapper.text()).not.toContain('即将上线');
});
});