feat(storage): group archives by the BPM order field

This commit is contained in:
阿白叔 committed 2026-10-17 18:59:06 +08:00
1 parent 607b240aa3
commit fff2a29ec0
13 files changed
+163 -18

No files matched your search

+17 -4
View File
@@ -4,10 +4,23 @@ function captureOrder() {
if (!source) throw new Error('当前页面没有订单表单,请进入 BPM 订单详情。');
const bindings = { order:'OFR_WY_Applicant.OrderNum', project:'OFR_WY_BInfo.ProductNum', model:'OFR_WY_BInfo.ProductModelNEW', serial:'OFR_WY_Applicant.SN' };
const labels = { order:'订单号', project:'项目编号', model:'产品型号', serial:'通知书编号' };
const metadata = {};
const metadata = {}, warnings = [];
const orderBindings = ['OFR_LSCP_Applicant.OrderNum', 'OFR_BS_Applicant.OrderNum', 'OFR_KD_Applicant.OrderNum', 'OFR_WY_Applicant.OrderNum'];
function visibleValue(el) {
for (let node = el; node; node = node.parentElement) {
const style = getComputedStyle(node), type = (node.getAttribute('type') || '').toLowerCase();
if (node.hidden || ['hidden','password'].includes(type) || style.display === 'none' || ['hidden','collapse'].includes(style.visibility)) return '';
}
return (['INPUT','TEXTAREA','SELECT'].includes(el.tagName) ? el.value : el.innerText).trim();
}
let bpmOrder = null;
for (const [key, binding] of Object.entries(bindings)) {
const el = source.querySelector(`[xdatabind="${binding}"]`);
metadata[key] = (el?.value ?? el?.textContent ?? '').trim();
const candidates = (key === 'order' ? orderBindings : [binding]).flatMap(field =>
[...source.querySelectorAll(`[xdatabind="${field}"]`)].map(el => ({field, value:visibleValue(el)})).filter(item => item.value));
const values = [...new Set(candidates.map(item => item.value))];
metadata[key] = values.length === 1 ? values[0] : '';
if (values.length > 1) warnings.push(`BPM 表单中有多个不同的${labels[key]},请核实后重新导出。`);
if (key === 'order' && metadata.order) bpmOrder = candidates[0];
}
const clone = source.cloneNode(true);
const originals = [source, ...source.querySelectorAll('*')];
@@ -41,6 +54,6 @@ function captureOrder() {
const stylesheetUrls = [...document.querySelectorAll('link[rel="stylesheet"][href]')].map(el => el.href);
const styleSources = [...document.querySelectorAll('style,link[rel="stylesheet"][href]')].map(el => el.tagName.toLowerCase() === 'style' ? {text:el.textContent} : {url:el.href});
const imageUrls = [...clone.querySelectorAll('img[src]')].map(el => el.getAttribute('src'));
return { metadata, html:clone.outerHTML, styles, styleSources, stylesheetUrls, imageUrls:[...new Set(imageUrls)], width:1264, missing:Object.keys(bindings).filter(key => !metadata[key]).map(key => labels[key]), warnings:[] };
return { metadata, bpmOrder, html:clone.outerHTML, styles, styleSources, stylesheetUrls, imageUrls:[...new Set(imageUrls)], width:1264, missing:Object.keys(bindings).filter(key => !metadata[key]).map(key => labels[key]), warnings };
}
if (typeof module !== 'undefined') module.exports = { captureOrder };