feat(export): 决策263-266 单一骨架导出通路/数据全量入库/空骨架规则标注/导入按内容判族

- 决策 263:定额单价专题(三同合并全字段统一、原价三级链、LME Summary 26 属性收口、x_flags 采集、e2e 回归)
- 决策 264 补记五:原格式导出只保留骨架回灌一条通路;删除 export_cos.export_zip 旧引擎;新增 skeleton_engine(内容判族/唯一结构位/结构旁注/路径指纹);单位级/项目级非数据层 x_attr/x_side 采集与回灌;导出件成员名改 GBK 原始字节(_GbkZipInfo);后台「导出设置」导出空骨架(标注)
- 决策 265:导入按内容判族(zip 内含 ConstructProject→SWT 族,否则 COS 族;裸 XML 同),扩展名不参与拦截;api_scan 取消 EXT_OK 过滤
- 决策 266:结构位统一「自增区域/自增块/自增行」,取消「固定」;min_count(区域1/块行0),导出条数=max;区域数据0条保底1空壳;LME 汇总两形态(带组成闭合块/普通自闭合行)按行硬分派
- 前序未提交:HTML 导出整体移除(export_html.py 删除)、Excel 导出加序号列并移除说明页、.yhy 导入(import_yhy.py)
- 测试:367 passed / 3 skipped;新增 test_topic_price/test_yhy_import/test_import_suffix 等
This commit is contained in:
lianjianwei2024
2026-11-03 23:39:46 +08:00
parent 5470286f66
commit 78e58a40c7
40 changed files with 2700 additions and 1373 deletions

View File

@@ -634,8 +634,6 @@ body.histdrag{user-select:none}
<div class="mbody" style="display:flex;flex-direction:column;gap:10px;font-size:14px">
<label id="expf_xlsx_lbl" style="display:flex;align-items:center;gap:8px;cursor:pointer">
<input type="checkbox" id="expf_xlsx" onchange="expPick('xlsx')">导出excel</label>
<label id="expf_html_lbl" style="display:flex;align-items:center;gap:8px;cursor:pointer">
<input type="checkbox" id="expf_html" onchange="expPick('html')">导出html</label>
<label id="expf_yhy_lbl" style="display:flex;align-items:center;gap:8px;cursor:pointer">
<input type="checkbox" id="expf_yhy" onchange="expPick('yhy')">导出yhy</label>
<label id="expf_nat_lbl" style="display:flex;align-items:center;gap:8px;cursor:pointer">
@@ -1018,7 +1016,7 @@ window.__exportProgress = function(p){
function exportAsk(){
if(!SID){ $('msg').textContent = '先打开工程再导出'; return; }
if ($('expmask').classList.contains('on')){ $('msg').textContent = '已有导出进行中(可点「后台导出」转后台)'; return; }
['expf_xlsx','expf_html','expf_yhy','expf_nat'].forEach(function(id){
['expf_xlsx','expf_yhy','expf_nat'].forEach(function(id){
document.getElementById(id).checked = false;
});
const manual = !!MANUAL;
@@ -1029,14 +1027,13 @@ function exportAsk(){
document.getElementById('expoptmask').classList.add('on');
}
function expPick(which){ /* 复选框限勾一个:勾谁清别人 */
const ids = {xlsx:'expf_xlsx', html:'expf_html', yhy:'expf_yhy', nat:'expf_nat'};
const ids = {xlsx:'expf_xlsx', yhy:'expf_yhy', nat:'expf_nat'};
for(const k in ids){ if(k !== which) document.getElementById(ids[k]).checked = false; }
}
function expClose(){ document.getElementById('expoptmask').classList.remove('on'); }
function expGo(){
let fmt = '';
if(document.getElementById('expf_xlsx').checked) fmt = 'xlsx';
else if(document.getElementById('expf_html').checked) fmt = 'html';
else if(document.getElementById('expf_yhy').checked) fmt = 'yhy';
else if(document.getElementById('expf_nat').checked && !document.getElementById('expf_nat').disabled) fmt = '';
else { $('msg').textContent = '先勾选一种导出格式'; return; }
@@ -1050,7 +1047,7 @@ async function exportSession(fmt){
fmt=(fmt||'').toLowerCase();
if(MANUAL && fmt===''){ $('msg').textContent = '手工工程没有源格式,不可按原格式导出'; return; }
if ($('expmask').classList.contains('on')){ $('msg').textContent = '已有导出进行中(可点「后台导出」转后台)'; return; }
const FNAME = {xlsx:'Excel', html:'HTML', yhy:'YHY'};
const FNAME = {xlsx:'Excel', yhy:'YHY'};
$('msg').textContent = '正在按' + (FNAME[fmt] || '原格式') + '导出(大工程稍等)…';
try{
const hasBridge = window.pywebview && window.pywebview.api;
@@ -1069,7 +1066,7 @@ async function exportSession(fmt){
if (r && r.cancel){ $('msg').textContent = '已取消导出'; return; }
if (r && r.msg){ $('msg').textContent = '导出失败:' + r.msg; return; }
}
const resp = await fetch('/api/session/export?session_id=' + SID + (fmt?('&fmt='+encodeURIComponent(fmt)):''));
const resp = await fetch('/api/session/export?session_id=' + SID + (fmt?('&fmt='+encodeURIComponent(fmt)):''));
if(!resp.ok){ const j = await resp.json().catch(()=>null); throw new Error((j && j.msg) || ('HTTP ' + resp.status)); }
const cd = resp.headers.get('Content-Disposition') || '';
// 服务端同时发 filename="export.zip"(ASCII 兜底)和 filename*=UTF-8''真名(原工程名-审核版.原后缀)。
@@ -1172,7 +1169,7 @@ function renderMergeTree(){
+ ' data-ntp-org="' + (r.ntp_org == null ? '' : r.ntp_org) + '" data-ntp-expr="' + (r.ntp_expr == null ? '' : r.ntp_expr) + '"'
+ ' data-taxp-org="' + (r.taxp_org == null ? '' : r.taxp_org) + '" data-taxp-expr="' + (r.taxp_expr == null ? '' : r.taxp_expr) + '"'
+ (isUw ? ' data-ucode="' + esc(r.code || '') + '" data-uwids="' + esc((r.uw_ids || []).join(',')) + '"'
+ ' data-kind="' + (r.kind == null ? '' : r.kind) + '"' : '')
+ ' data-kind="' + (r.kind == null ? '' : r.kind) + '" data-xflags="' + esc(r.x_flags == null ? '' : r.x_flags) + '"' : '')
+ (r.def ? ' checked' : '') + ' title="单选:合并后全组按此行归并(数值=行现值;改价在外面·行级改价/原数据)"></td>'
+ '<td class="c">' + no + '</td>'
+ '<td class="c">' + esc(r.code || '—') + '</td>'
@@ -1215,7 +1212,8 @@ async function mergeApply(){
taxp_org: cb.dataset.taxpOrg === '' || cb.dataset.taxpOrg == null ? null : Number(cb.dataset.taxpOrg),
taxp_expr: cb.dataset.taxpExpr === '' || cb.dataset.taxpExpr == null ? null : Number(cb.dataset.taxpExpr),
name: g.name || '', spec: g.spec || '', unit: g.unit || '',
kind: cb.dataset.kind === '' ? null : Number(cb.dataset.kind), qty: 0 };
kind: cb.dataset.kind === '' ? null : Number(cb.dataset.kind),
x_flags: cb.dataset.xflags || null, qty: 0 }; // 定额单价专题:合并全列随勾选行(2026-11-03)
} else {
// 决策 184:弹框全部字段只读(纯勾选归并,数值=行现值;改价在外面·行级改价/原数据)
const d6 = k => cb.dataset[k] === '' || cb.dataset[k] == null ? null : Number(cb.dataset[k]);
@@ -1836,6 +1834,35 @@ async function doOpen(){
if(!$('oprov').value||!$('ocity').value||!$('odist').value){ $('omsg').textContent='请填写:地区(省/市/区)'; return; }
if(!$('obuid').value.trim()){ $('omsg').textContent='请填写:建设单位'; return; }
if(!$('okind').value){ $('omsg').textContent='请选择单价类型'; return; }
// .yhy 工程包(决策 261 补三,2026-11-03 主人定):上传→id 整体平移导入→原地打开新会话;
// 名称/期次/地区/建设单位/单价类型一切按本弹框字段(覆盖包内值)
if(/\.yhy$/i.test(f.name)){
ldShow($('oname').value||f.name,'正在上传工程包…',6);
const upy=await uploadFile('/api/admin/upload', f);
if(!upy.ok){ ldHide(); $('omsg').textContent=upy.msg; return; }
try{
const r=await J('/api/session/yhy/import',{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({path:upy.path,name:$('oname').value||f.name,
period_from:pv.f, period_to:pv.t,
province:$('oprov').value,city:$('ocity').value,district:$('odist').value,
bulid_unit:$('obuid').value,file_kind:+$('okind').value})});
if(!r.ok){
$('omsg').textContent=r.msg||'导入失败';
if(/同名/.test(r.msg)) alert(r.msg);
return;
}
SID=r.session_id;
setManualMode(!!r.manual);
try{ localStorage.setItem('wb_sid', SID); }catch(e){}
loadAdopt();
$('sinfo').innerHTML='<b>'+esc($('oname').value||f.name)+'</b>';
$('omask').classList.remove('on');
ldStage(86,'正在加载清单与原数据…');
await loadLme(); await tab('p3');
$('msg').textContent=r.msg;
} finally { ldHide(); }
return;
}
$('omsg').textContent='正在上传并解析…';
// 2026-10-13 主人定:打开工程的全程(上传→解析→首屏)挂进度条,工程名+阶段可见
ldShow($('oname').value||f.name,'正在上传工程文件…',6);
@@ -2719,7 +2746,7 @@ async function adoptLme(i){
let rp=null;
try{
rp=await J('/api/session/lme/price',{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({session_id:SID,id:CUR.id,ntp:x.price,taxrate:x.tax,taxp:x.price_tax})});
body:JSON.stringify({session_id:SID,id:CUR.id,ntp:x.price,taxrate:x.tax,taxp:x.price_tax,adopt:1})});
}catch(e){ rp=null; }
if(!rp || !rp.ok){ dlMsg('采纳改价失败:'+(rp&&rp.msg?rp.msg:'服务未响应'),'err'); return; }
if(rp.ntp0!=null) _lmeAnchor={price:rp.ntp0,tax:rp.rate0,taxp:rp.taxp0}; // 决策 219:锚由改价端点带回