修复:快照合并分析图并支持导出订单对应表

快照将不良构成与柏拉图合并为一个选项,完整保留页面容器,黑片和亮片继续并排展示两张分析图;迁移旧快照选项并等待组合图的数据准备完成。

销售订单类型对应表支持下载当前生效版本的完整Excel,订单号按文本写入,保留前导零,沿用管理员角色与来源字段权限。导出开始时固定版本,使用滚动工作簿限制内存。

菜单、页面及快照标题统一改为黑片数据和亮片数据。

验证:11项前端检查、8项后端单元测试通过;157698条实际对应关系与数据库逐条一致,重新导入预览零变更;黑片完整快照和亮片单模块快照均通过视觉检查。
This commit is contained in:
2026-11-04 09:06:07 +08:00
parent 80cd9e79eb
commit 147b56d0fd
11 changed files with 133 additions and 20 deletions
+6 -6
View File
@@ -1,14 +1,15 @@
export const QUERY_SNAPSHOT_MODULES = [
{ key: 'filters', label: '查询条件' }, { key: 'metrics', label: '指标卡片' },
{ key: 'trend', label: '变化趋势' }, { key: 'table', label: '汇总表' },
{ key: 'defects', label: '不良构成' }, { key: 'pareto', label: '细分缺陷柏拉图' },
{ key: 'defects', label: '不良构成与柏拉图' },
] as const;
export type QuerySnapshotModule = typeof QUERY_SNAPSHOT_MODULES[number]['key'];
const KEYS = new Set<string>(QUERY_SNAPSHOT_MODULES.map(module => module.key));
export function parseSnapshotModules(raw: unknown): QuerySnapshotModule[] {
if (!Array.isArray(raw)) return QUERY_SNAPSHOT_MODULES.map(module => module.key);
return QUERY_SNAPSHOT_MODULES.filter(module => raw.includes(module.key) && KEYS.has(module.key)).map(module => module.key);
const migrated = raw.map(key => key === 'pareto' ? 'defects' : key);
return QUERY_SNAPSHOT_MODULES.filter(module => migrated.includes(module.key) && KEYS.has(module.key)).map(module => module.key);
}
export function snapshotImageSize(width: number, height: number) {
@@ -48,16 +49,16 @@ export async function captureQuerySnapshot(root: HTMLElement, selected: QuerySna
if (!selected.length) throw new Error('请至少选择一个模块');
const check = () => { if (cancelled() || !root.isConnected || !root.offsetWidth) throw new Error('查询页面已变化,请重新生成快照'); };
check();
root.dispatchEvent(new CustomEvent('quality:query-snapshot', { detail: { modules: selected } }));
root.dispatchEvent(new CustomEvent('quality:query-snapshot', { detail: { modules: selected.includes('defects') ? [...selected, 'pareto'] : selected } }));
const modules = snapshotModuleElements(root, selected);
progress('正在等待所选模块加载完成…');
const started = performance.now();
let previous = '', stableSince = performance.now();
while (true) {
check();
const failed = modules.find(({ node }) => node.dataset.snapshotReady === 'error');
const failed = modules.find(({ node }) => node.dataset.snapshotReady === 'error' || node.querySelector('[data-snapshot-ready="error"]'));
if (failed) throw new Error(`“${failed.label}”读取失败,请重试后生成快照`);
const busy = modules.some(({ node }) => node.dataset.snapshotReady === 'false' || node.matches('[aria-busy="true"],[inert]') || node.querySelector('[aria-busy="true"],[inert]'));
const busy = modules.some(({ node }) => node.dataset.snapshotReady === 'false' || node.matches('[aria-busy="true"],[inert]') || node.querySelector('[aria-busy="true"],[inert],[data-snapshot-ready="false"]'));
const signature = modules.map(({ node }) => node.innerHTML).join('');
if (signature !== previous || busy) { previous = signature; stableSince = performance.now(); }
if (!busy && performance.now() - stableSince >= 250) break;
@@ -108,7 +109,6 @@ export async function captureQuerySnapshot(root: HTMLElement, selected: QuerySna
}
}
clone.querySelectorAll('.query-snapshot-controls,.query-toolbar-tail,.query-status,.query-more-toggle,.query-export-button,.ant-select-dropdown,.ant-table-filter-trigger,.ant-tooltip,.mobile-scroll-hint').forEach(element => element.remove());
if (key === 'defects' || key === 'pareto') clone.classList.add('query-snapshot-defect-module');
frame.append(clone);
}
root.append(frame);