fix(export): 措施清单嵌章节节点导出改价丢失——按编码兜底配对;定额工程量界面改为永远显示数字(决策 96/97)

This commit is contained in:
lianjianwei2024
2026-10-17 15:38:40 +08:00
parent a4772bc97b
commit 9269541ee6
5 changed files with 139 additions and 28 deletions

View File

@@ -944,7 +944,9 @@ document.addEventListener('dblclick', function(e){
}
if(!api) return;
e.preventDefault();
const cur0 = td.textContent.trim();
let cur0 = td.textContent.trim();
// 决策 96:公式行的工程量格显示的是求值数字——双击编辑要预填**公式原文**(存在 td.data-expr 里)
if(api==='norm' && field==='Quantity' && td.dataset.expr) cur0 = td.dataset.expr;
if(api==='lme'){ lmeEditCell(td, tr, field, (cur0==='—'?'':cur0)); return; }
editCell(td, api, id, field, (cur0==='—'?'':cur0));
});
@@ -1023,21 +1025,26 @@ function grpBillQtyEdit(td, tr, cur0){
function grpNormQtyEdit(td, tr, cur0){
const nid = Number(tr.dataset.nid);
const inp = document.createElement('input');
inp.className = 'cellin'; inp.value = cur0.replace(/,/g, ''); inp.spellcheck = false;
// 决策 96:格子显示数字,但编辑框预填**公式原文**(公式行才能改公式);数字行预填数字
const pre = td.dataset.expr || cur0.replace(/,/g, '');
inp.className = 'cellin'; inp.value = pre; inp.spellcheck = false;
inp.title = '可输入数字、数字四则(如 5+9.25+6.36)或带 GCL 的公式(GCL=清单工程量÷定额单位数字,'
+ '纯字母单位=清单工程量),如 GCL*(5+9.25+6.36)+GCL;公式按原文保存,导出时按清单工程量求值';
+ '纯字母单位=清单工程量),如 GCL*(5+9.25+6.36)+GCL;公式按原文保存,界面显示求值数字,'
+ '导出时按清单工程量求值';
td.textContent = ''; td.appendChild(inp);
inp.focus(); inp.select();
let done = false;
const fin = async save => {
if(done) return; done = true;
const v = inp.value.trim();
if(!save || v === cur0.replace(/,/g, '')){ td.textContent = cur0; return; }
if(!save || v === pre){ td.textContent = cur0; return; }
const r = await J('/api/session/norm/op',{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({session_id:SID, norm_id:nid, fields:{Quantity:v}})});
if(!r.ok){ $('msg').textContent = r.msg || '保存失败'; td.textContent = cur0; return; }
// 决策 90:公式按原文回填(GCL/GCL*0.5…),纯数字回填数字;提示带即时求值结果
td.textContent = (r.expr != null && r.expr !== '') ? r.expr : numG(r.quantity);
// 决策 96:界面永远显示求值数字;公式原文收进 data-expr/悬停提示(双击再改还能取到)
td.textContent = r.quantity != null ? numG(r.quantity) : '—';
if(r.expr){ td.dataset.expr = r.expr; td.title = '公式:' + r.expr + '(按清单工程量求值,双击可改公式)'; }
else { delete td.dataset.expr; td.removeAttribute('title'); }
$('msg').textContent = '已保存' + (r.quantity != null ? ':= ' + numG(r.quantity) : '');
loadEditLog().then(()=>{ markGroupEH('tb1'); markGroupEH('tb2'); }); // ⑮ 红三角即时点亮
};