feat(in-transit-transfer): 更新证据下载与待匹配清单逻辑

- 修改证据下载接口,分别签发预览地址与带保存名的下载地址,避免浏览器使用对象键哈希作为保存名。
- 待匹配清单接口调整,按外部单号合计数量,不再返回外部项次,提升数据展示的清晰度。
- 移除待匹配桶的「清空并重新解析」功能,简化操作流程,确保用户体验一致性。
- 新增跨页全选支持的 API,允许用户在待处理池中选择全部待处理明细 ID,优化批量操作体验。
This commit is contained in:
hugo committed 2026-10-22 22:08:20 +08:00
1 parent 4c2a7e2a23
commit 663f401873
50 files changed
+2156 -1309

No files matched your search

@@ -0,0 +1,127 @@
/**
* features/chat/components/messages/TransferBacklogSummaryCard.spec.ts
* 用途:锁定待处理异常卡「跨页全选」(Gmail 式,2026-10-22)交互契约。
* 依赖:@vue/test-utils、i18n、vi.mock transfer.api / useMessage。
* 逻辑:服务端分页下表头全选只覆盖当前页——未全选时透出「选择全部 N 行
* (按当前筛选)」独立入口(testid=transfer-backlog-select-all-matching,
* 与表头全选 checkbox 的 transfer-backlog-select-all 区分),点击按当前
* keyword/resultFilter 拉全量 id 合并进勾选集合(批量条计数随之计入
* 全量),全选后入口自动隐藏;API 失败经 useMessage 行内报错且不改
* 勾选集合。
*/
import { mount, flushPromises } from '@vue/test-utils';
import { describe, expect, it, vi, beforeEach } from 'vitest';
const fetchIds = vi.fn();
const messageMocks = vi.hoisted(() => ({
error: vi.fn(),
success: vi.fn(),
warning: vi.fn(),
info: vi.fn(),
}));
vi.mock('@/shared/composables/useMessage', () => ({
useMessage: () => messageMocks,
}));
vi.mock('../../api/transfer.api', async (importOriginal) => ({
...(await importOriginal<object>()),
fetchBacklogSelectableItemIds: (...args: unknown[]) => fetchIds(...args),
}));
import i18n from '@/i18n';
import TransferBacklogSummaryCard from './TransferBacklogSummaryCard.vue';
import type { TransferTypeOption } from '../../types/transfer.types';
const mountOptions = { global: { plugins: [i18n] } };
/** 构造一行可恢复阻断行(status/result_code 决定可勾选与批量可用性)。 */
const row = (id: number, invoice: string) => ({
item_id: id,
invoice_no: invoice,
source_code: 'DBS-AWSBI',
material_no: 'MAT-1',
material_name: '物料',
movement_date: '2026-10-01',
lot_no: '',
from_warehouse: 'DBS-TRANSIT',
from_quantity: '1',
to_warehouse: 'HUB-CN01',
to_quantity: '1',
status: 'blocked_recoverable',
result_code: 'blocked_quantity_mismatch',
result_message: '',
aging_level: 'normal',
updated_at: '',
});
describe('待处理异常卡跨页全选(Gmail 式)', () => {
beforeEach(() => {
fetchIds.mockReset();
messageMocks.error.mockReset();
});
it('未全选时透出「选择全部 N 行」,点击按当前筛选拉全量 id 合并勾选集合', async () => {
// [断言意图] 服务端分页(当前页 2 行/总量 3 行)下表头全选只覆盖当前页;
// 独立入口文案带全量计数;点击携带当前 keyword/resultFilter 拉取 id;
// 合并后批量条计入全量勾选数,入口因「未选中行=0」自动隐藏(表头全选
// checkbox 的 testid 不受影响)。
fetchIds.mockResolvedValue({ ids: [11, 12, 13], total: 3, truncated: false });
const wrapper = mount(TransferBacklogSummaryCard, {
props: { items: [row(11, 'INV-1'), row(12, 'INV-2')], total: 3 },
...mountOptions,
});
await flushPromises();
const link = wrapper.find('[data-testid="transfer-backlog-select-all-matching"]');
expect(link.exists()).toBe(true);
expect(link.text()).toContain('3');
await link.trigger('click');
await flushPromises();
expect(fetchIds).toHaveBeenCalledWith({ keyword: '', resultFilter: 'all' });
expect(
wrapper.find('[data-testid="transfer-backlog-selected-count"]').text(),
).toContain('3');
expect(wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').exists()).toBe(false);
});
it('拉取失败行内报错且不改勾选集合;入口保持可重试', async () => {
// [断言意图] API 异常不吞错(useMessage.error 透出)也不部分改写勾选集合
//(批量条不出现);入口保留供重试。
fetchIds.mockRejectedValue(new Error('backlog ids unavailable'));
const wrapper = mount(TransferBacklogSummaryCard, {
props: { items: [row(11, 'INV-1')], total: 2 },
...mountOptions,
});
await flushPromises();
await wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').trigger('click');
await flushPromises();
expect(messageMocks.error).toHaveBeenCalledTimes(1);
expect(wrapper.find('[data-testid="transfer-backlog-selected-count"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').exists()).toBe(true);
});
it('调拨类型列显示当前语言名称', async () => {
// [断言意图] 待恢复行展示出生匹配的类型名称,而不是只留仓库编码。
const types: TransferTypeOption[] = [{
code: 'in_transit_to_hub',
names: { 'zh-CN': '在途仓至HUB仓', en: 'In-transit to HUB' },
sort_order: 1,
transform_rules: [],
record_kinds: ['inbound'],
}];
const wrapper = mount(TransferBacklogSummaryCard, {
props: {
items: [{ ...row(11, 'INV-1'), transfer_type: 'in_transit_to_hub' }],
total: 1,
transferTypes: types,
},
...mountOptions,
});
await flushPromises();
expect(wrapper.find('[data-testid="transfer-backlog-type-INV-1"]').text()).toBe('在途仓至HUB仓');
});
});