]*>全部动态 ›<\/a>/) || [])[0] || '';
assert.match(allLink, /\$emit\('open', 'io'\)/, '「全部动态 ›」仍落 V4 动态列表,不被本次改动带走');
console.log('J1 出入库动态入口断言通过:「查看动态 ›」发 navigate(\'/warehouseManagement/inboundRequests\', { warehouseId }),dashboard.vue 已接 @navigate,跳真实菜单路由(独立页签)、只带仓库、不带 dashboard=1;「全部动态 ›」与趋势柱体仍落 V4 动态列表。');
// —— K1 首页首屏遮罩:数据回来之前不显示内容,且只在首屏出现一次 ——
const dashSource = stripCodeComments(fs.readFileSync(path.join(folder, 'dashboard.vue'), 'utf8'));
const maskTag = (dashSource.match(/]*class="home-loading"[^>]*>/) || [])[0] || '';
assert.ok(maskTag, 'dashboard.vue 必须有首屏遮罩节点(.home-loading)');
assert.match(maskTag, /v-if="homeLoading && view === 'home'"/, '遮罩只能在首页视图且 homeLoading 为真时出现:明细视图有自己的 v-loading,不能被这块盖住');
assert.ok(dashSource.includes('正在加载首页数据'), '遮罩必须给出中文加载文案,不能只放一个转圈');
assert.equal(page.data().homeLoading, true, 'homeLoading 必须默认 true:首屏还没请求就不能先渲染空卡片');
const createdBlock = dashSource.slice(dashSource.indexOf('async created()'), dashSource.indexOf('activated()'));
assert.match(createdBlock, /this\.homeLoading = false;/, 'created 里首屏(筛选项 + 汇总)结束后必须撤掉遮罩');
assert.ok(createdBlock.indexOf('this.homeLoading = false') > createdBlock.indexOf('await this.refresh()'), '必须先 await refresh() 再撤遮罩,否则数据还没到就露出来了');
assert.ok((dashSource.match(/this\.homeLoading = false/g) || []).length === 1, 'homeLoading 只能在首屏置一次 false:定时刷新与筛选项切换不该闪遮罩');
const layoutScss = stripCodeComments(fs.readFileSync(path.join(folder, 'dashboard-layout.scss'), 'utf8'));
assert.match(layoutScss, /\.wms-home\s*\{[^}]*position:\s*relative/, '.wms-home 必须是定位上下文,否则遮罩会跑去页面别处');
assert.match(layoutScss, /\.wms-home \.home-loading\s*\{[^}]*position:\s*absolute/, '遮罩必须绝对定位在内容区内');
assert.doesNotMatch(layoutScss, /\.wms-home \.home-loading\s*\{[^}]*position:\s*fixed/, '遮罩不得用 fixed:会把系统页头、菜单、标签栏一起盖掉');
assert.match(layoutScss, /\.wms-home \.home-loading\s*\{[^}]*z-index:\s*\d+/, '遮罩必须显式抬层级,否则盖不住卡片');
assert.match(layoutScss, /@keyframes\s+home-loading-spin\s*\{[\s\S]{0,120}?rotate\(360deg\)/, '转圈动画必须存在,否则 spinner 静态不转');
console.log('K1 首页首屏遮罩断言通过:homeLoading 默认 true、created 中 await refresh() 之后置 false(且只置一次),遮罩仅在首页视图出现并带中文文案;样式为 .wms-home 内的 absolute 遮罩(非 fixed,不盖系统页头/菜单)+ z-index + 转圈关键帧。');
// 首页指标拆分:每张卡/图一条路由,限流并保持单项失败隔离。
const metricCalls = [];
let runningMetrics = 0;
let peakMetrics = 0;
const { value: metricPage, context: metricContext } = load('dashboard.vue', {
HomeOverview: {}, DashboardDetail: {}, DashboardActions: {}, ...utils,
screens: vm.runInContext('screens', screens),
homeSummaryMetric: async (metric) => {
metricCalls.push(metric);
peakMetrics = Math.max(peakMetrics, ++runningMetrics);
await Promise.resolve();
runningMetrics--;
if (metric === 'C2') throw new Error('缺少成本');
return metric === 'C1' ? { inventoryBatchCount: 12, capturedAt: '2026-11-07 12:00:00' } : {};
}
});
const metricNames = Object.keys(vm.runInContext('metricKeys', metricContext));
assert.equal(metricNames.length, 14, '13 项首页指标和 C6 明细须各有一条指标路由');
const metricApiSource = fs.readFileSync(path.join(root, 'src/api/warehouseManagement/dashboard.js'), 'utf8');
assert.match(metricApiSource, /home-summary\/metric\/\$\{metric\}/, '指标 API 必须带编号路径');
assert.doesNotMatch(metricApiSource, /export const homeSummary\s*=/, '页面停用后应移除旧整包请求入口');
assert.doesNotMatch(dashboardTplSource, /homeSummarySection/, '首页不得再调用七模块汇总接口');
(async () => {
const state = {
generation: 1, requests: {}, active: true, summary: {}, error: '', updatedAt: '',
parameters() { return { warehouseId: '1' }; }
};
await metricPage.methods.loadSummary.call(state);
assert.equal(metricCalls.join(','), metricNames.filter(metric => metric !== 'C6').join(','), '首页仅请求 13 项,不请求 C6');
assert.ok(peakMetrics <= 4, '首页统计并发不得超过 4');
assert.equal(state.summary.inventoryBatchCount, 12, 'C1 数据须独立落入首页');
assert.equal(state.summary.inventoryValue, undefined, 'C2 失败不得伪造金额');
assert.match(state.error, /C2:缺少成本/, '单项失败应标明指标编号');
const qcState = { generation: 1, requests: {}, active: true, view: 'qc', summary: {}, error: '', updatedAt: '', parameters() { return {}; } };
metricCalls.length = 0;
await metricPage.methods.loadSummary.call(qcState);
assert.equal(metricCalls.filter(metric => metric === 'C6').length, 1, '质检明细保留 C6 数据');
console.log('首页指标拆分断言通过:13 项独立请求、质检明细保留 C6、并发不超过 4,C2 失败不覆盖 C1。');
})().catch(error => { console.error(error); process.exitCode = 1; });