chore(AdminCost): 移除 COS4 数据结构迁移的一次性脚本与参考资料
This commit is contained in:
@@ -183,6 +183,25 @@ a:hover{text-decoration:underline}
|
||||
#dbody.simflex{display:flex}
|
||||
#simtree{width:230px;flex:none;border-right:1px solid var(--line);overflow:auto;padding:6px 4px;background:#fcfdfe}
|
||||
.close{cursor:pointer;color:#8899aa;font-size:20px;line-height:1}
|
||||
/* 决策 245(2026-11-01):导入弹框「导入Excel」树区——样式照工作台 #itree 同款(同码同形) */
|
||||
#aitree .ied{display:flex;align-items:center;gap:6px;padding:4px 8px;border-radius:4px}
|
||||
#aitree .ied:hover{background:#f0f4fa}
|
||||
#aitree .itag{flex:none;font-size:11px;border-radius:3px;padding:1px 6px}
|
||||
#aitree .tg0{background:#e8edf5;color:#41506e}#aitree .tg1{background:#e3ecfa;color:#1c4f9c}#aitree .tg2{background:#dcf0e2;color:#17663a}
|
||||
#aitree .inm{overflow:hidden;text-overflow:ellipsis;cursor:text;white-space:nowrap}
|
||||
#aitree .iact{margin-left:auto;display:flex;gap:4px;align-items:center;flex:none}
|
||||
#aitree .iab{font-size:11px;border:1px solid #c3cad6;background:#fff;border-radius:3px;padding:1px 6px;cursor:pointer;color:#41506e}
|
||||
#aitree .iab:disabled{opacity:.35;cursor:default}
|
||||
#aitree .iab.x{color:#b03a2e;border-color:#e3b6b0}
|
||||
#aitree .iab.imp{color:#1c66d6;border-color:#9db9e8}
|
||||
#aitree .iok{font-size:11px;color:#1f8f4d;white-space:nowrap;flex:none}
|
||||
#aitree .ierr{font-size:11px;color:#b03a2e;max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:none}
|
||||
#aitree .ied input{border:1px solid #9db9e8;border-radius:3px;padding:2px 6px;font-size:13px;min-width:140px;flex:1}
|
||||
#idlg{width:min(640px,92vw)}
|
||||
#idlg.exp{height:672px}
|
||||
#idlg.exp #ibody{flex:1;min-height:0}
|
||||
#ileft{flex:1}
|
||||
#idlg.exp #ileft{flex:none;width:388px}
|
||||
.tip{color:var(--muted);font-size:12px;padding:6px 0}
|
||||
/* 明细:左侧目录 + 右侧内容(照上传 HTML 的版式) */
|
||||
#dpage .db.fx{display:flex;overflow:hidden}
|
||||
@@ -466,56 +485,70 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
</div>
|
||||
|
||||
<div class="mask" id="imask">
|
||||
<div class="dlg" style="width:min(720px,92vw)">
|
||||
<div class="dh"><b>导入工程文件</b><span class="close" onclick="closeImp()">×</span></div>
|
||||
<div class="bar" style="flex-direction:column;align-items:stretch;gap:10px">
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">文件 *</span>
|
||||
<input type="file" id="ifile" style="flex:1" onchange="pickFile(this)">
|
||||
<!-- 决策 245(2026-11-01 主人定):后台弹框与工作台「打开项目」弹框统一,以工作台为准——
|
||||
字段/顺序/提示/按钮一致,唯一区别=写入库(这里写 history.db 批次,工作台写 session.db 会话);
|
||||
底部提示词两侧逐字相同。价格类(信息价/市场价)仍用本框的价格字段,工程类走同款字段。 -->
|
||||
<div class="dlg" id="idlg">
|
||||
<div class="dh"><b id="impTitle">打开项目</b><span class="close" onclick="closeImp()">×</span></div>
|
||||
<div class="bar" id="ibody" style="flex-direction:row;align-items:stretch;gap:16px;overflow:hidden">
|
||||
<div id="ileft" style="min-width:0;display:flex;flex-direction:column;gap:10px">
|
||||
<div id="irowFile" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">全国电子标书</span>
|
||||
<input type="file" id="ifile" style="flex:1" onchange="pickFile(this)">
|
||||
</div>
|
||||
<div id="ifileInfo" class="tip" style="padding:0 0 0 82px"></div>
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">工程名称 *</span>
|
||||
<input id="iname" style="flex:1" placeholder="选文件后自动带出文件名,可改">
|
||||
</div>
|
||||
<div id="irowPer" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">基准期次 *</span>
|
||||
<input id="iper" style="flex:1" placeholder="点这里选起~止(同月就选同一个)">
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">地区 *</span>
|
||||
<select id="iprov" style="flex:1"><option value="">省</option></select>
|
||||
<select id="icity" style="flex:1"><option value="">市</option></select>
|
||||
<select id="idist" style="flex:1"><option value="">区/县/镇</option></select>
|
||||
</div>
|
||||
<div id="irowBuid" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">建设单位 *</span>
|
||||
<input id="ibuid" style="flex:1" placeholder="输入或从历史项目选择" autocomplete="off">
|
||||
</div>
|
||||
<div id="irowFk" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">单价类型 *</span>
|
||||
<select id="ifk" style="flex:1"></select>
|
||||
</div>
|
||||
<div id="irowPub" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">发布单位 *</span>
|
||||
<select id="ipub" style="flex:1"></select>
|
||||
</div>
|
||||
<div id="irowPdf" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">附件</span>
|
||||
<input type="file" id="ipdf" style="flex:1">
|
||||
<span class="tip" style="width:110px">任意格式,选填</span>
|
||||
</div>
|
||||
<div id="irowNote" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:88px">备注</span>
|
||||
<input id="inote" style="flex:1" placeholder="选填">
|
||||
</div>
|
||||
<div id="irowTip" class="tip" style="padding:0 0 0 82px"></div>
|
||||
</div>
|
||||
<div id="ifileInfo" class="tip" style="padding:0 0 0 82px"></div>
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">名称 *</span>
|
||||
<input id="iname" style="flex:1" placeholder="必填:工程名称">
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">地区 *</span>
|
||||
<select id="iprov" style="flex:1"><option value="">省</option></select>
|
||||
<select id="icity" style="flex:1"><option value="">市</option></select>
|
||||
<select id="idist" style="flex:1"><option value="">区/县/镇</option></select>
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">期次 *</span>
|
||||
<input id="iper" style="flex:1" placeholder="点这里选起~止(同一个月就选同一个)">
|
||||
</div>
|
||||
<div id="irowBuid" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">建设单位 *</span>
|
||||
<input id="ibuid" style="flex:1" placeholder="输入或从历史项目选择" autocomplete="off">
|
||||
</div>
|
||||
<div id="irowFk" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">单价类型 *</span>
|
||||
<select id="ifk" style="flex:1"></select>
|
||||
</div>
|
||||
<div id="irowPub" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">发布单位 *</span>
|
||||
<select id="ipub" style="flex:1"></select>
|
||||
</div>
|
||||
<div id="irowPdf" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">附件</span>
|
||||
<input type="file" id="ipdf" style="flex:1">
|
||||
<span class="tip" style="width:110px">任意格式,选填</span>
|
||||
</div>
|
||||
<div id="irowNote" style="display:flex;gap:8px;align-items:center">
|
||||
<span style="width:74px">备注</span>
|
||||
<input id="inote" style="flex:1" placeholder="选填">
|
||||
</div>
|
||||
<div id="irowTip" class="tip" style="padding:0 0 0 82px"></div>
|
||||
<div style="display:flex;gap:8px;align-items:center;justify-content:flex-end">
|
||||
<span class="tip" id="imsg"></span>
|
||||
<button class="btn" onclick="closeImp()">取消</button>
|
||||
<button class="btn pri" onclick="doImport()">开始导入</button>
|
||||
<!-- 导入Excel 右侧目录树面板(决策 245):与工作台同一套树/模板/按钮,Excel 建的工程落批次库 -->
|
||||
<div id="apanel" style="display:none;flex:1;min-width:0;flex-direction:column">
|
||||
<div id="aitree" style="flex:1;min-height:0;overflow:auto;border:1px solid #e3eaf2;border-radius:6px;padding:6px 4px;background:#fbfcfe"></div>
|
||||
<div class="tip" id="aimsg" style="padding-top:8px"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex;gap:10px;align-items:center;padding:10px 16px;border-top:1px solid #e3eaf2;background:#fafcff">
|
||||
<span class="tip" id="imRemind" style="flex:1;min-width:0;color:#b03a2e;line-height:1.45">提醒:建议在打开或导入项目时,先把工程独有的增加费(暗室、超高降效、预算包干、垂直运输等)取消后再入库或工作台的审核对比,否则容易造成数据失真!</span>
|
||||
<span class="tip" id="imsg"></span>
|
||||
<button class="btn" onclick="closeImp()">取消</button>
|
||||
<button class="btn" id="impBtnX" onclick="aimpToggle()" title="右边展开目录树:按单位工程导入 Excel 建工程(与工作台同一套模板)">导入Excel</button>
|
||||
<input type="file" id="iprojfile" accept=".xlsx" style="display:none" onchange="aimpProjFile()">
|
||||
<input type="file" id="ifile2" accept=".xlsx" style="display:none" onchange="aimpFile()">
|
||||
<button class="btn pri" id="ibtnGo" onclick="doImport()">打开</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1225,6 +1258,11 @@ function almeRender(){
|
||||
const view=sortRows(ALME_ROWS, ALME_SORT.k, ALME_SORT.dir, ALME_NUM);
|
||||
document.getElementById('dtbd').innerHTML=renderLme(view, WB_OPTS)
|
||||
||`<tr><td colspan="${AC_LME.length}" class="tip" style="text-align:center;padding:16px">没有数据</td></tr>`;
|
||||
// 决策 243 补记三:切页签回来找回上次选中的工料机行(同工作台 wantLme 手法)
|
||||
if(window.ALME_ID){
|
||||
const tr=document.querySelector('#dtbd tr[data-id="'+window.ALME_ID+'"]');
|
||||
if(tr){ tr.classList.add('sel'); tr.scrollIntoView({block:'center'}); }
|
||||
}
|
||||
}
|
||||
// 定额(挂在清单下):定额编码 / 定额名称 / 单位 / 单价(COL_PRICE 已上移进价格明细模块,2026-10-12)
|
||||
const COL_NORM=[{t:'定额编码',a:'c',w:130},{t:'定额名称',a:'l',w:300},
|
||||
@@ -1244,9 +1282,17 @@ var _rawPickBaseAdm = rawPick;
|
||||
rawPick = async function(k, id, el){
|
||||
if(RVSEL.k==='uw' && RVSEL.id){
|
||||
const sel=document.querySelector('#drawbody tr.sel');
|
||||
const sp=(function(e){for(let x=e&&e.parentElement;x&&x!==document.body;x=x.parentElement){const cs=getComputedStyle(x);if(/(auto|scroll)/.test(cs.overflowY)&&x.scrollHeight>x.clientHeight+2)return x;}return null;})(document.querySelector('#drawbody'));
|
||||
RAWSEL_MEM[DID+':'+RVSEL.id]={ bid: sel?sel.dataset.bid:((RAWSEL_MEM[DID+':'+RVSEL.id]||{}).bid||null),
|
||||
rvtab: RVTAB, scroll: sp?sp.scrollTop:null };
|
||||
const sub=document.querySelector('#drawbody tr.subsel');
|
||||
// 决策 243 补记三:**有现场才写存档**——WB_RAW.load() 内部恢复树也会调 rawPick,
|
||||
// 此刻 drawbody 是重画初的空表,空抓拍会把已有存档覆盖成全 null(实测踩坑)
|
||||
if(sel || sub){
|
||||
const sp=(function(e){for(let x=e;x&&x!==document.body;x=x.parentElement){const cs=getComputedStyle(x);if(/(auto|scroll)/.test(cs.overflowY)&&x.scrollHeight>x.clientHeight+2)return x;}return null;})(document.querySelector('#drawbody'));
|
||||
const o=RAWSEL_MEM[DID+':'+RVSEL.id]||{};
|
||||
RAWSEL_MEM[DID+':'+RVSEL.id]=Object.assign(o, {
|
||||
bid: sel?sel.dataset.bid:(sub?sub.dataset.bid:(o.bid||null)),
|
||||
rvtab: RVTAB, scroll: sp?sp.scrollTop:null,
|
||||
normsel: sub?sub.dataset.nid:(o.normsel||null) });
|
||||
}
|
||||
}
|
||||
await _rawPickBaseAdm(k, id, el);
|
||||
if(k==='uw'){
|
||||
@@ -1260,6 +1306,9 @@ rawPick = async function(k, id, el){
|
||||
else tr.scrollIntoView({block:'center'});
|
||||
}
|
||||
}
|
||||
// 决策 243 补记三:恢复 sel+定额(守窗自愈)
|
||||
if(rec && (rec.bid || rec.normsel))
|
||||
_rawSceneGuard(document.getElementById('drawbody'), rec.bid || null, rec.normsel || null, 3000);
|
||||
}
|
||||
};
|
||||
var WB_RAW = RawView({
|
||||
@@ -1269,8 +1318,24 @@ var WB_RAW = RawView({
|
||||
normApi: function(nid){ return '/api/admin/norm/' + nid + '/res'; },
|
||||
lmeApi: function(){ return '/api/admin/lme/res?batch_id=' + DID; },
|
||||
treeEl: 'drawtree', tabsEl: 'drawstabs', bodyEl: 'drawbody',
|
||||
rowClick: 'admPick', // 决策 243 补记三:后台原数据清单/定额可点选(记忆+守窗恢复的前提)
|
||||
lmeBackend: true // 决策 147:后台原数据项目级卡=后台项目工料机列集(无取消采纳/备注列)
|
||||
});
|
||||
/* 决策 243 补记三:后台原数据清单行点选(同工作台 pick 的视觉语义:单选 sel、清定额 subsel;
|
||||
纯视觉+记忆,后台无对比框/采纳链路,不动 CUR) */
|
||||
window.admPick = function(type, id, tr) {
|
||||
document.querySelectorAll('#drawbody tr.sel').forEach(x => x.classList.remove('sel'));
|
||||
document.querySelectorAll('#drawbody tr.subsel').forEach(x => x.classList.remove('subsel'));
|
||||
if (tr) tr.classList.add('sel');
|
||||
};
|
||||
/* 决策 243 补记三:后台定额子行点选(同工作台规格 2026-10-16③,无 SID 条件的后台版) */
|
||||
document.addEventListener('click', function(e) {
|
||||
const tr = e.target.closest && e.target.closest('#drawbody tr.sub');
|
||||
if (!tr || !tr.dataset.nid) return;
|
||||
document.querySelectorAll('#drawbody tr.subsel').forEach(x => x.classList.remove('subsel'));
|
||||
tr.classList.add('subsel');
|
||||
document.querySelectorAll('#drawbody tr.sel').forEach(x => x.classList.remove('sel'));
|
||||
});
|
||||
|
||||
/* 明细弹框布局编排(2026-10-13 收编,**单一写入点**):
|
||||
弹框是同一个 DOM 被四种内容复用 —— price=价格明细(左目录树+右一张表)/
|
||||
@@ -1413,6 +1478,25 @@ window.addEventListener('resize', ()=>{ if(XACT>=0){ const t=XTABS[XACT];
|
||||
showPage(t && t.kind==='inq' ? 'inq' : 'detail'); } });
|
||||
|
||||
async function loadTab(pid, fresh){
|
||||
// 决策 243 补记三:切走前抓拍现场——p3=原数据(清单/定额选中+展开+滚动);p0=工料机选中行
|
||||
if(KIND==='project'){
|
||||
if(pid!=='p3' && document.querySelector('#drawbody tr.brow')){ // 正在**离开** p3 → 抓拍现场
|
||||
if (RVSEL.k==='uw') {
|
||||
const rec=RAWSEL_MEM[DID+':'+RVSEL.id]||{};
|
||||
const scene=_normSceneCapture(document.getElementById('drawbody'));
|
||||
const sel=document.querySelector('#drawbody tr.sel');
|
||||
const sp=(function(e){for(let x=e;x&&x!==document.body;x=x.parentElement){const cs=getComputedStyle(x);if(/(auto|scroll)/.test(cs.overflowY)&&x.scrollHeight>x.clientHeight+2)return x;}return null;})(document.querySelector('#drawbody'));
|
||||
RAWSEL_MEM[DID+':'+RVSEL.id]=Object.assign(rec, {
|
||||
bid: sel?sel.dataset.bid:(rec.bid||null), rvtab: RVTAB,
|
||||
scroll: sp?sp.scrollTop:(rec.scroll!=null?rec.scroll:null),
|
||||
normsel: scene.normsel });
|
||||
}
|
||||
}
|
||||
if(pid==='p0'){
|
||||
const sel=document.querySelector('#dtbd tr.sel');
|
||||
window.ALME_ID = sel ? (sel.dataset.id||null) : (window.ALME_ID||null);
|
||||
}
|
||||
}
|
||||
document.querySelectorAll('#dtabs .tab').forEach(x=>x.classList.toggle('on',x.dataset.p===pid));
|
||||
dPgReset(); // 决策 229:换页签=搜索复位(关键词/黄底/跳转钮路由)
|
||||
const cg=document.getElementById('dcg'), th=document.getElementById('dth'), tb=document.getElementById('dtbd');
|
||||
@@ -1432,12 +1516,11 @@ async function loadTab(pid, fresh){
|
||||
ldStage(40,'正在加载原数据(目录树+汇总卡)…');
|
||||
await WB_RAW.load();
|
||||
// 决策 214 补:回到明细原数据 → 恢复该单位工程上次选中行
|
||||
// 决策 243 补记三:恢复用**守窗自愈**(同工作台 _p3RestoreSel,防异步重画洗掉)
|
||||
(function(){
|
||||
const rec=RAWSEL_MEM[DID+':'+RVSEL.id];
|
||||
if(rec && rec.bid && !document.querySelector('#drawbody tr.sel')){
|
||||
const tr=document.querySelector('#drawbody tr.brow[data-bid="'+rec.bid+'"]');
|
||||
if(tr){ tr.classList.add('sel'); tr.scrollIntoView({block:'center'}); }
|
||||
}
|
||||
if(!rec || (!rec.bid && !rec.normsel)) return;
|
||||
_rawSceneGuard(document.getElementById('drawbody'), rec.bid || null, rec.normsel || null, 3500);
|
||||
})();
|
||||
return;
|
||||
}
|
||||
@@ -1488,11 +1571,17 @@ async function loadTab(pid, fresh){
|
||||
async function openImp(){
|
||||
imask.classList.add('on');
|
||||
const isPrice = (KIND!=='project');
|
||||
// 决策 245(2026-11-01 主人定):工程类弹框与工作台「打开项目」一模一样——字段/顺序/提示/按钮同款
|
||||
document.getElementById('impTitle').textContent = isPrice ? '导入工程文件' : '打开项目';
|
||||
document.getElementById('irowBuid').style.display = isPrice?'none':'flex';
|
||||
document.getElementById('irowFk').style.display = isPrice?'none':'flex';
|
||||
document.getElementById('irowNote').style.display = isPrice?'flex':'none';
|
||||
document.getElementById('irowPub').style.display = isPrice?'flex':'none';
|
||||
document.getElementById('irowPdf').style.display = isPrice?'flex':'none';
|
||||
document.getElementById('impBtnX').style.display = isPrice?'none':'inline-block';
|
||||
document.getElementById('ibtnGo').textContent = isPrice ? '开始导入' : '打开';
|
||||
document.getElementById('imRemind').style.display = isPrice?'none':'block';
|
||||
if(AIOPEN) aimpToggle(); // 每次打开先收回树区(与工作台 openDlg 同款)
|
||||
ipdf.value='';
|
||||
// 每次只能导入一个文件:从你自己电脑的任意位置选,选完会传进软件目录
|
||||
ifile.value=''; UPF=null;
|
||||
@@ -1502,12 +1591,15 @@ async function openImp(){
|
||||
//(深圳数据交换标准,散装 XML 或压缩包内 XML;扩展名不分大小写)。
|
||||
ifile.accept = isPrice ? '.xlsx' : '.cos4,.cos,.swt,.swz';
|
||||
document.getElementById('ifileInfo').textContent='';
|
||||
document.getElementById('ifileInfo').style.display = isPrice?'block':'none';
|
||||
document.getElementById('irowTip').textContent = isPrice
|
||||
? '信息价/市场价:只收「标准模板」Excel(.xlsx,每次一个)+ 附件原件(任意格式,选填)。'
|
||||
+ '名称留空或点文件后自动带出文件名(可改);期次留空时自动从文件名里认(如「珠海信息价_2026年7月」→ 2026-07)。'
|
||||
: '工程:选择一个 .cos4 / .cos / .swt / .swz 文件(可从电脑任意位置选,每次只能一个)。全部必填。';
|
||||
: '';
|
||||
imsg.textContent='';
|
||||
await loadImpFilters();
|
||||
// 单价类型默认「预算综合单价」(与工作台打开项目弹框同一默认)
|
||||
try{ if(ifk.options.length) ifk.value='1'; }catch(e){}
|
||||
}
|
||||
|
||||
async function pickFile(inp){
|
||||
@@ -1532,6 +1624,133 @@ async function pickFile(inp){
|
||||
|
||||
function closeImp(){ imask.classList.remove('on') }
|
||||
|
||||
/* ================= 导入Excel(决策 245,2026-11-01 主人定):后台弹框与工作台同款树区 =================
|
||||
项目行:单位模板/项目模板/项目导入/+单项工程;单位工程行:↑↓/导入单位工程/✕。
|
||||
与工作台唯一区别=落库目标:这里写 history.db 批次(工作台写 session.db 会话);
|
||||
模板与校验完全同一套(/api/session/manual/* 只读或模板下载)。 */
|
||||
let AITREE=null, AISEL='', AIOPEN=false;
|
||||
function aimpToggle(){
|
||||
const isPrice = (KIND!=='project');
|
||||
if(isPrice && !AIOPEN) return; // 价格类没有树区;但切到价格类时允许收起
|
||||
AIOPEN=!AIOPEN;
|
||||
const on=AIOPEN;
|
||||
$('apanel').style.display=on?'flex':'none';
|
||||
$('irowFile').style.display=on?'none':'flex';
|
||||
$('impBtnX').classList[on?'add':'remove']('pri');
|
||||
$('idlg').style.width=on?'1100px':'';
|
||||
$('idlg').classList[on?'add':'remove']('exp');
|
||||
$('ibtnGo').textContent=on?'创建工程':(isPrice?'开始导入':'打开');
|
||||
$('ibtnGo').onclick=on?aimpSave:doImport;
|
||||
$('impTitle').textContent=on?'打开项目 · 导入Excel':(isPrice?'导入工程文件':'打开项目');
|
||||
if(typeof dlgPin==='function') dlgPin($('idlg')); // 改宽后重居中(与工作台 impExcelToggle 同款)
|
||||
if(on){
|
||||
AITREE=[{name:'单项工程 1',units:[{name:'单位工程 1'}]}];
|
||||
$('iprojfile').value=''; $('aimsg').textContent='';
|
||||
aimpRender();
|
||||
}
|
||||
}
|
||||
function aimpRender(){
|
||||
if(!AITREE) return;
|
||||
const nm=$('iname').value.trim()||'(工程名称)';
|
||||
let h='<div class="ied"><span class="itag tg0">项目</span><span class="inm" onclick="$(\'iname\').focus()" style="cursor:pointer" title="点改名(左侧工程名称共用字段)">'+esc(nm)+'</span>'
|
||||
+'<span class="iact">'
|
||||
+'<button class="iab" onclick="aimpTemplate()" title="下载单位工程数据结构 Excel(填写说明/分部分项/措施项目)">单位模板</button>'
|
||||
+'<button class="iab" onclick="aimpProjPick()" title="下载项目导入模板(项目目录+多对 Sheet,每对 Sheet=1 个单位工程,一把导入建项目)">项目模板</button>'
|
||||
+'<button class="iab" onclick="$(\'iprojfile\').click()" title="选项目模板 Excel:项目目录 Sheet 定目录树,分部分项N/措施项目N 对应序号 N 的单位工程,一把建项目">项目导入</button>'
|
||||
+'<button class="iab" onclick="aimpAddSec()">+单项工程</button></span></div>';
|
||||
AITREE.forEach((s,si)=>{
|
||||
h+='<div class="ied" style="padding-left:26px"><span class="itag tg1">单项工程</span><span class="inm" onclick="aimpRename(this,'+si+',-1)">'+esc(s.name)+'</span>'
|
||||
+'<span class="iact"><button class="iab" title="组内上移" onclick="aimpMovSec('+si+',-1)"'+(si===0?' disabled':'')+'>↑</button>'
|
||||
+'<button class="iab" title="组内下移" onclick="aimpMovSec('+si+',1)"'+(si===AITREE.length-1?' disabled':'')+'>↓</button>'
|
||||
+'<button class="iab" onclick="aimpAddUw('+si+')">+单位工程</button><button class="iab x" onclick="aimpDelSec('+si+')">✕</button></span></div>';
|
||||
s.units.forEach((u,ui)=>{
|
||||
let st='';
|
||||
if(u.err) st='<span class="ierr" title="'+esc(u.err)+'">✗ '+esc(u.err)+'</span>';
|
||||
else if(u.file) st='<span class="iok">✓ 清单'+u.n_item+'+措施'+u.n_prelim+'</span>';
|
||||
h+='<div class="ied" style="padding-left:52px"><span class="itag tg2">单位工程</span><span class="inm" title="'+esc(u.name)+'" onclick="aimpRename(this,'+si+','+ui+')">'+esc(u.name)+'</span>'
|
||||
+st
|
||||
+'<span class="iact"><button class="iab" title="组内上移" onclick="aimpMovUw('+si+','+ui+',-1)"'+(ui===0?' disabled':'')+'>↑</button>'
|
||||
+'<button class="iab" title="组内下移" onclick="aimpMovUw('+si+','+ui+',1)"'+(ui===s.units.length-1?' disabled':'')+'>↓</button>'
|
||||
+'<button class="iab imp" onclick="aimpPick('+si+','+ui+')" title="按模板导入(整单位工程覆盖)">导入单位工程</button><button class="iab x" onclick="aimpDelUw('+si+','+ui+')">✕</button></span></div>';
|
||||
});
|
||||
});
|
||||
$('aitree').innerHTML=h;
|
||||
}
|
||||
function aimpRename(sp,si,ui){
|
||||
const cur=sp.textContent, inp=document.createElement('input'); inp.value=cur;
|
||||
sp.replaceWith(inp); inp.focus(); inp.select();
|
||||
const done=()=>{ const v=inp.value.trim()||cur;
|
||||
if(ui<0) AITREE[si].name=v; else AITREE[si].units[ui].name=v;
|
||||
aimpRender(); };
|
||||
inp.onblur=done;
|
||||
inp.onkeydown=e=>{ if(e.key==='Enter')inp.blur(); if(e.key==='Escape'){inp.value=cur;inp.blur();} };
|
||||
}
|
||||
function aimpAddSec(){ AITREE.push({name:'单项工程 '+(AITREE.length+1),units:[{name:'单位工程 1'}]}); aimpRender(); }
|
||||
function aimpDelSec(i){ if(AITREE.length<=1){$('aimsg').textContent='至少保留一个单项工程';return;} AITREE.splice(i,1); aimpRender(); }
|
||||
function aimpAddUw(si){ AITREE[si].units.push({name:'单位工程 '+(AITREE[si].units.length+1)}); aimpRender(); }
|
||||
function aimpDelUw(si,ui){ AITREE[si].units.splice(ui,1); aimpRender(); }
|
||||
function aimpMovSec(i,d){ const j=i+d; if(j<0||j>=AITREE.length) return;
|
||||
const t=AITREE[i]; AITREE[i]=AITREE[j]; AITREE[j]=t; aimpRender(); }
|
||||
function aimpMovUw(si,ui,d){ const us=AITREE[si].units, j=ui+d; if(j<0||j>=us.length) return;
|
||||
const t=us[ui]; us[ui]=us[j]; us[j]=t; aimpRender(); }
|
||||
function aimpPick(si,ui){ AISEL=si+','+ui; $('ifile2').value=''; $('ifile2').click(); }
|
||||
async function aimpFile(){
|
||||
const f=$('ifile2').files[0]; $('ifile2').value='';
|
||||
if(!f||!AISEL) return;
|
||||
const [si,ui]=AISEL.split(',').map(Number), u=AITREE[si].units[ui];
|
||||
$('aimsg').textContent='正在上传并校验 '+f.name+'…';
|
||||
const up=await uploadFile('/api/admin/upload',f);
|
||||
if(!up.ok){ $('aimsg').textContent=up.msg; return; }
|
||||
const r=await J('/api/session/manual/parse',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({path:up.path})});
|
||||
if(!r.ok){ u.file=''; u.err=r.msg||'校验失败'; $('aimsg').textContent='✗ '+u.err; aimpRender(); return; }
|
||||
u.file=up.path; u.n_item=r.n_item; u.n_prelim=r.n_prelim; delete u.err;
|
||||
$('aimsg').textContent=''; aimpRender();
|
||||
}
|
||||
function aimpTemplate(){ return saveAs('/api/session/manual/template','单位工程导入模板.xlsx'); }
|
||||
function aimpProjPick(){ return saveAs('/api/session/manual/project_template','整项目导入模板.xlsx'); }
|
||||
async function aimpProjFile(){
|
||||
const f=$('iprojfile').files[0]; $('iprojfile').value='';
|
||||
if(!f) return;
|
||||
const v=aimpCommon(); if(!v) return;
|
||||
$('aimsg').textContent='正在上传 '+f.name+'…';
|
||||
const up=await uploadFile('/api/admin/upload',f);
|
||||
if(!up.ok){ $('aimsg').textContent=up.msg; return; }
|
||||
$('aimsg').textContent='正在导入整项目…';
|
||||
const r=await J('/api/admin/import_project',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify(Object.assign(v,{path:up.path}))});
|
||||
if(!r.ok){ $('aimsg').textContent=r.msg||'导入失败'; return; }
|
||||
alert('导入成功!\n'+r.msg); closeImp(); load(1); loadSummary(); loadFilters();
|
||||
}
|
||||
function aimpCommon(){
|
||||
const name=$('iname').value.trim(), pv=PVAL($('iper'));
|
||||
if(!name){ $('aimsg').textContent='工程名称必填(左边共用字段)'; return null; }
|
||||
if(pv.f==null||pv.t==null){ $('aimsg').textContent='基准期次必填:点开选起~止(同月就选同一个)'; return null; }
|
||||
if(!iprov.value||!icity.value||!idist.value){ $('aimsg').textContent='请填写:地区(省/市/区)'; return null; }
|
||||
if(!ibuid.value.trim()){ $('aimsg').textContent='请填写:建设单位'; return null; }
|
||||
if(!ifk.value){ $('aimsg').textContent='请选择单价类型'; return null; }
|
||||
return {name,period_from:pv.f,period_to:pv.t,
|
||||
province:iprov.value,city:icity.value,district:idist.value,
|
||||
bulid_unit:ibuid.value.trim(),file_kind:+ifk.value};
|
||||
}
|
||||
async function aimpSave(){
|
||||
if(!AITREE) return;
|
||||
const v=aimpCommon(false); if(!v) return;
|
||||
for(const s of AITREE){
|
||||
if(!s.name.trim()){ $('aimsg').textContent='单项工程名称不能为空'; return; }
|
||||
if(!s.units.length){ $('aimsg').textContent='「'+s.name+'」下至少一个单位工程'; return; }
|
||||
for(const u of s.units) if(!u.name.trim()){ $('aimsg').textContent='单位工程名称不能为空'; return; }
|
||||
}
|
||||
$('ibtnGo').disabled=true; $('aimsg').textContent='正在保存…';
|
||||
try{
|
||||
const r=await J('/api/admin/import_project',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify(Object.assign(v,{tree:AITREE.map(s=>({name:s.name.trim(),
|
||||
units:s.units.map(u=>({name:u.name.trim(),file:u.file||''}))}))}))});
|
||||
if(!r.ok){ $('aimsg').textContent=r.msg||'保存失败'; return; }
|
||||
alert('导入成功!\n'+r.msg); closeImp(); load(1); loadSummary(); loadFilters();
|
||||
} finally { $('ibtnGo').disabled=false; }
|
||||
}
|
||||
|
||||
async function loadImpFilters(){
|
||||
const f=await J('/api/admin/filters');
|
||||
// 2026-10-08 主人定:地区/建设单位 改「历史项目搜索」——选项来自已导入项目的实际数据
|
||||
@@ -1561,17 +1780,22 @@ function kindOptions(kinds, cur){
|
||||
|
||||
async function doImport(){
|
||||
const isPrice = (KIND!=='project');
|
||||
// 决策 245:工程类校验文案与工作台「打开项目」逐字同款(两侧同规则)
|
||||
if(!isPrice){
|
||||
if(!UPF){ imsg.textContent='请选择文件'; return; }
|
||||
if(!iname.value.trim()){ imsg.textContent='请填写:工程名称'; return; }
|
||||
const pv0=PVAL($('iper'));
|
||||
if(pv0.f==null||pv0.t==null){ imsg.textContent='基准期次必填:点开选起~止(同一个月就选同一个)'; return; }
|
||||
if(!iprov.value||!icity.value||!idist.value){ imsg.textContent='请填写:地区(省/市/区)'; return; }
|
||||
if(!ibuid.value.trim()){ imsg.textContent='请填写:建设单位'; return; }
|
||||
if(!ifk.value){ imsg.textContent='请选择单价类型'; return; }
|
||||
}
|
||||
const miss=[];
|
||||
if(!UPF) miss.push(isPrice?'标准模板 Excel 文件(每次只能一个)':'文件(每次只能一个)');
|
||||
if(!iname.value.trim()) miss.push('名称');
|
||||
if(!iprov.value||!icity.value||!idist.value) miss.push('地区(省/市/区)');
|
||||
if(isPrice && !UPF) miss.push('标准模板 Excel 文件(每次只能一个)');
|
||||
if(!iname.value.trim()) miss.push('工程名称');
|
||||
const pv=PVAL($('iper'));
|
||||
const p1=pv.f, p2=pv.t;
|
||||
if(p1==null||p2==null) miss.push('期次(点开选起~止,同一个月就选同一个)');
|
||||
if(!isPrice){
|
||||
if(!ibuid.value.trim()) miss.push('建设单位');
|
||||
if(!ifk.value) miss.push('单价类型');
|
||||
} // 发布单位、备注:选填,不校验
|
||||
if(isPrice && (p1==null||p2==null)) miss.push('基准期次(点开选起~止,同一个月就选同一个)');
|
||||
// 备注选填,不校验
|
||||
if(miss.length){ imsg.textContent='请填写:'+miss.join('、'); return; }
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ const COLS = {
|
||||
// 类型列不显示,数据下标 9=类型 保持不变)
|
||||
// 标记 'F' = 固定宽列;无标记 = 伸缩列(名称/规格型号),平分容器剩余宽度
|
||||
// —— 表宽始终贴合容器撑满屏幕,见 flexFit() / flexRedistribute()。
|
||||
lme: [['序号', 52, 'c', 'F'], ['编码', 120, 'c', 'F'], ['名称', 220, 'l'], ['规格型号', 200, 'l'],
|
||||
lme: [['序号', 52, 'c', 'F'], ['源', 44, 'c', 'F'], ['编码', 120, 'c', 'F'], ['名称', 220, 'l'], ['规格型号', 200, 'l'],
|
||||
['单位', 56, 'c', 'F'], ['数量', 135, 'r', 'F'], ['除税编制价', 110, 'r', 'F'], ['税率', 70, 'r', 'F'], // 决策 145:数量列宽 ×1.5(90→135)
|
||||
['含税编制价', 110, 'r', 'F'], ['取消采纳', 76, 'c', 'F', 'ns', 'wb'], ['备注', 550, 'l', '', '', 'wb']] // 2026-10-22 主人定:备注默认宽 550(取代决策 145 的 160),其余列宽不变]
|
||||
};
|
||||
@@ -940,6 +940,7 @@ function renderLme(rows, opts) {
|
||||
return (rows || []).map((r, i) =>
|
||||
'<tr class="' + (opts.rowClass || '') + '"' + click(r[0]) + ' data-id="' + r[0] + '" data-code="' + esc(r[1] || '') + '" data-name="' + esc(r[2] || '') + '" data-price="' + esc(r[6] == null ? '' : r[6]) + '">'
|
||||
+ '<td class="c">' + (i + 1) + '</td>'
|
||||
+ '<td class="c">' + lmeSrcCellHTML(r) + '</td>' // 决策 243:来源追溯钮(两侧同形)
|
||||
+ '<td class="c">' + ell(r[1], '—') + '</td>'
|
||||
+ '<td>' + ell(r[2], '—') + '</td>'
|
||||
+ '<td>' + ell(r[3], '—') + '</td>'
|
||||
@@ -1034,8 +1035,10 @@ function tgNorm(el, billId) {
|
||||
—— 数据流独立(会话库 / 批次库),渲染逻辑共用,改这里 = 两侧同时生效。 */
|
||||
// 2026-10-08 主人定:隐藏「基本信息」「项目特征信息」两张项目级标签卡(只藏 UI,不动 x_info/x_feat 数据列)。
|
||||
// 数据照常入库/可取,只是原数据视图不再显示这两张卡。前后台共用本 RawView,改这里=两侧同时隐藏。
|
||||
const RAW_PT = [['sum', '汇总分析'], ['lme', '工料机汇总']];
|
||||
const RAW_UT = [['item', '分部分项'], ['prelim', '措施项目'], ['lme', '工料机汇总'], ['cost', '汇总分析']];
|
||||
// 决策 244(2026-11-01):项目级加「项目汇总分析」卡(图5:费用汇总树 XMQDF…按原生码显示,
|
||||
// 「不汇总」列取消);单位工程级加「其他项目」卡(图3)。两侧(工作台/后台)同一份渲染同时生效。
|
||||
const RAW_PT = [['sum', '汇总分析'], ['lme', '工料机汇总'], ['psum', '项目汇总分析']];
|
||||
const RAW_UT = [['item', '分部分项'], ['prelim', '措施项目'], ['sundry', '其他项目'], ['lme', '工料机汇总'], ['cost', '汇总分析']];
|
||||
/* 原数据「工料机汇总」表里要不要显示「类别」列(1人工 / 2材料 / 3机械)。
|
||||
0=不显示(主人 2026-10-06 定:数据照取照算,只是不占一列)。
|
||||
⚠️ 关掉时必须**真的不输出**这一列的 col/th/td —— 用 display:none 会让它退出列模型,
|
||||
@@ -1044,6 +1047,7 @@ const RAW_LME_KIND = 0;
|
||||
|
||||
// 模块级状态:每页只有一个原数据视图(工作台 / 后台各一个),够用。
|
||||
let RVO = null, RVT = null, RVSEL = { k: 'proj', id: 0 }, RVTAB = 'sum', RVLV = 2, RV_TREE_KEEP = false;
|
||||
let RV_LV_RESTORED = false; // 决策 244 补三:rvst.lv 只在页面加载后第一次 rawTreeHTML 恢复一次
|
||||
/* 树的「展开」与「选中」必须分开记(2026-10-07 修交互):
|
||||
此前单项工程节点"被选中才展开",于是 ① 默认全是收起的(主人要的默认打开没有);
|
||||
② 点开单位工程后,父级单项工程整个收起、刚选中的节点直接消失(看着就是"点了没反应/树乱跳");
|
||||
@@ -1209,7 +1213,8 @@ function rawTabs() {
|
||||
if (!st) return;
|
||||
if (RVSEL.k === 'sec') { st.style.display = 'none'; st.innerHTML = ''; return; }
|
||||
st.style.display = 'flex';
|
||||
const T = RVSEL.k === 'proj' ? RAW_PT : RAW_UT;
|
||||
const T = (RVSEL.k === 'proj' ? RAW_PT : RAW_UT)
|
||||
.filter(t => t[0] !== 'psum' || RVSUM_HAS_PSUM); // 决策 244 补一:无 PIC 数据隐藏「项目汇总分析」
|
||||
let h = T.map(t => '<div class="stab' + (RVTAB === t[0] ? ' on' : '') + '" onclick="rawTab(\'' + t[0] + '\')">' + t[1] + '</div>').join('');
|
||||
// 2026-10-13 主人定:层级按钮(分组/清单/定额/默认列宽)迁到「类似清单」⟳ 重载行的最右
|
||||
// (挂点 #rawLvMount,两页同款),原数据标签行内不再显示;非该挂点的页面走旧路兜底。
|
||||
@@ -1243,13 +1248,15 @@ function rawTabs() {
|
||||
}
|
||||
st.innerHTML = h;
|
||||
}
|
||||
function rawTab(t) { RVTAB = t; _rvStateSave(); rawTabs(); rawDraw(); }
|
||||
function rawTab(t) { RVTAB = t; RVSUM_OPEN = {}; RVSUM_REDRAW = null; _rvStateSave(); rawTabs(); rawDraw(); }
|
||||
function rawLv(v) {
|
||||
RVLV = v;
|
||||
RV_TREE = { root: true, divs: {}, bills: {} }; // 新档:树状态交给 rawTreeHTML 重建
|
||||
RV_LV_RESTORED = true; // 决策 244 补三:显式换档是权威值,rawTreeHTML 不再回读 rvst.lv
|
||||
RV_CACHE[_rvCacheKey()] = null; // 该视图换档了,旧缓存作废
|
||||
delete RV_CACHE[_rvCacheKey()];
|
||||
rawTabs(); rawDraw();
|
||||
_rvStateSave(); // 决策 244 补三:新档位即时落会话记忆
|
||||
}
|
||||
function rawRst() {
|
||||
// 规格 2026-10-17 ⑨:组价不一致/类似清单面板里点「默认列宽」= 复位本组表——
|
||||
@@ -1298,7 +1305,9 @@ function grpRst(tbId) {
|
||||
async function rawPick(k, id, el) {
|
||||
RVSEL = { k: k, id: id };
|
||||
RVTAB = k === 'uw' ? 'item' : 'sum';
|
||||
RVLV = 2; // 默认「只展开到清单」(主人 2026-10-07 定)
|
||||
// 决策 244 补三(2026-11-01 主人定「记忆的规则」):切换单位工程**不再重置层级档位**——
|
||||
// 当时停在定额档就还是定额档、清单档就还是清单档(此前这里硬置 RVLV=2 把档位打回清单层)。
|
||||
// 默认档 RVLV=2(主人 2026-10-07 定)只在首次进入生效;刷新/重开按 rvst_<sid>.lv 恢复。
|
||||
// 决策 195:保存放渲染完成后——开头存会把 rvst 里的展开状态用空树盖掉(实测踩坑)
|
||||
// 点名字 = 选中**并**展开自己所在的分支(收起只走 ± 把手,两条线分开)
|
||||
if (RVOPEN === null) RVOPEN = new Set(((RVT && RVT.sections) || []).map(s => s.id));
|
||||
@@ -1404,8 +1413,9 @@ async function rawDraw(quiet) { // 决策 221:quiet=true 编辑保存静默
|
||||
let html = '';
|
||||
if (RVSEL.k === 'proj') {
|
||||
const d = await rawFetch('/proj', _qid(RVO.idParam, oid) + '&tab=' + encodeURIComponent(RVTAB));
|
||||
if (RVTAB === 'sum') html = rawProj('sum', d.rows);
|
||||
if (RVTAB === 'sum') html = rawProj('sum', d.rows, d.proj, d.has_psum); // 决策 244:三层树表 + 项目抬头 + psum 有无
|
||||
else if (RVTAB === 'lme') html = rawLmeTbl(d.rows, '', '总数量', { ids: d.ids, sub: d.sub }); // 2026-10-13 主人定:取消顶部说明行;2026-10-16 带行 id/子级组成集
|
||||
else if (RVTAB === 'psum') html = rawFeeTree(d.rows, 'psum'); // 决策 244:项目汇总分析卡(PIC 树原样)
|
||||
else if (RVTAB === 'info') html = rawKV(Object.entries(d.rows || {}), '项目级 · 基本信息(Project.xml 根节点属性)');
|
||||
else html = rawKV((d.rows || []).map(f => [f.n, f.v]), '项目级 · 项目特征信息(Project.xml 的 AttrInfo / AddiInfo 条目,最多 60 条)');
|
||||
} else if (RVSEL.k === 'sec') {
|
||||
@@ -1417,7 +1427,8 @@ async function rawDraw(quiet) { // 决策 221:quiet=true 编辑保存静默
|
||||
d.src === 'summary' ? '' // 2026-10-13 主人定:读 xml 原样口径取消说明行
|
||||
: '单位工程级 · 工料机汇总(按本单位工程的清单→定额→消耗量归集;点列名可排序)',
|
||||
'数量'); // 决策 190(2026-10-24 主人定):列头统一「数量」,原 总数量/消耗量 双轨撤除
|
||||
else html = rawUw('cost', d.rows);
|
||||
else if (RVTAB === 'sundry') html = rawSundry(d.rows); // 决策 244:其他项目卡(Sundry 原样)
|
||||
else html = rawFeeTree(d.rows, 'cost'); // 决策 244:汇总分析卡改 UnitWorksSummary 树(原键值卡取代)
|
||||
}
|
||||
b.innerHTML = html;
|
||||
colwApply(b.querySelector('table'));
|
||||
@@ -1483,7 +1494,8 @@ function rawTreeSync(key) {
|
||||
function _rvStateSave() { // 决策 195:展开/收起+原数据视图上下文按会话记忆(重开/刷新页面后原样恢复)
|
||||
try {
|
||||
const m = (typeof location !== 'undefined' ? (location.search || '') : '').match(/[?&]sid=(\d+)/);
|
||||
localStorage.setItem('rvst_' + (m ? m[1] : ''), JSON.stringify({ tree: RV_TREE, sel: RVSEL, tab: RVTAB }));
|
||||
// 决策 244 补三:层级档位(清单/定额)一并按会话记忆——切换单位工程/刷新/重开都回到当时档
|
||||
localStorage.setItem('rvst_' + (m ? m[1] : ''), JSON.stringify({ tree: RV_TREE, sel: RVSEL, tab: RVTAB, lv: RVLV }));
|
||||
} catch (e) {}
|
||||
}
|
||||
function rawTog(key, el) {
|
||||
@@ -1498,20 +1510,42 @@ function rawTog(key, el) {
|
||||
function rawTreeHTML(d) {
|
||||
const uw = d.uw || {}, divs = d.tree || [], loose = d.loose || [];
|
||||
const ind = dp => 'padding-left:' + (4 + dp * 14) + 'px';
|
||||
// 决策 244 补四(2026-11-01 主人定):①分部/单位工程合价=按层级**动态现算**(分部=其下清单合价
|
||||
// 逐级上卷、单位工程=全部清单合计),不存库——导出口径另见台账(与决策 231 已验收的
|
||||
// 「分部导出与原件一致」存在口径分叉,导出端待主人拍板);临删行(x_tdel)与 0 量行
|
||||
// (Quantity=null,决策 232)不计入。②把手 ± 按层级错位:竖向中心线每偏离一层级偏移 5px
|
||||
// (此前分部嵌套完全平齐 16px,层次不显——主人指出不如原版清晰)。
|
||||
const sumB = b => (b.x_tdel || b.Quantity == null ? 0 : (b.Total || 0));
|
||||
const DIV_SUM = new Map();
|
||||
const calcDiv = nd => {
|
||||
let s = 0;
|
||||
(nd.bills || []).forEach(b => { s += sumB(b); });
|
||||
(nd.children || []).forEach(c => { s += calcDiv(c); });
|
||||
DIV_SUM.set(nd.id, s);
|
||||
return s;
|
||||
};
|
||||
let rootSum = 0;
|
||||
(divs || []).forEach(nd => { rootSum += calcDiv(nd); });
|
||||
(loose || []).forEach(b => { rootSum += sumB(b); });
|
||||
let maxDp = 0;
|
||||
(function go(arr, d) { (arr || []).forEach(nd => { maxDp = Math.max(maxDp, d); go(nd.children, d + 1); }); })(divs, 0);
|
||||
// 2026-10-08 主人定:①「项目特征」列弹性宽('',尽量宽、吸收容器剩余),其余列收窄到最小所需宽;
|
||||
// ②「类型」列 52→88px,让根目录「单位工程」徽章不再溢出(4 字 ~62px + 内边距);
|
||||
// 两处均不再标 data-sumw,表退回 width:100% 填满弹框/屏幕;表头统一居中见 common.css。
|
||||
const head = ['', '序号', ['编码', 'c'], ['类型', 'c'], ['名称', 'l'], ['项目特征', 'l'],
|
||||
['单位', 'c'], ['工程量', 'r'], ['单价', 'r'], ['合价', 'r'], ['取消采纳', 'c'], ['备注', 'l']];
|
||||
// 把手列(第一列):单位工程最左、分部统一 16px、清单统一 32px —— 三档错开、各成一条直线
|
||||
const TGI_UW = 0, TGI_DIV = 16, TGI_BILL = 32;
|
||||
// 把手列(第一列):单位工程最左(层0);决策 244 补四(主人定):**层级错位=一个把手位置
|
||||
// (把手盒宽 18px)**——父把手的右边线与子把手的左边线正好衔接对齐,把手盒排成连续阶梯
|
||||
// (同层级同一条竖线:清单=其父分部深度+1 层,与同深度分部把手同线);
|
||||
// 把手列宽动态 = 8 + 最深把手位置 + 把手盒 18 + 右距 4,以不覆盖把手为准。
|
||||
const TGI_UW = 0, TGI_DIV = 18, TGI_STEP = 18;
|
||||
// 2026-10-08 主人定(修「± 把手外溢」):把手列宽不再写死 40。table-layout:fixed 的列
|
||||
// 不会按内容撑开,而清单行把手 = 4px 内边距 + 32px 缩进 + 20px 把手盒 = 56px,
|
||||
// 早超出 40px 列宽,溢进「序号」列。列宽从缩进常量推导(左右内边距 8 + 最深缩进 + 把手 20),
|
||||
// 以后调整进/把手尺寸列宽自动跟上,结构上不可能再外溢。
|
||||
// 2026-10-08 主人定:源文件备注显示在备注栏 —— 列宽 56→220 放得下备注文字(悬停有全文提示),
|
||||
// 「项目特征」仍是伸缩列('')吸收剩余宽度。
|
||||
const cols = [8 + TGI_BILL + 20, 40, 100, 88, 160, '', 64, 76, 74, 86, 86, 220];
|
||||
const cols = [8 + TGI_DIV + 18 + (maxDp + 1) * TGI_STEP, 40, 100, 88, 160, '', 64, 76, 74, 86, 86, 220];
|
||||
let n = 0, rows = '';
|
||||
// 展开状态按当前层级档重建(切层级按钮 / 换单位工程都会走到这里)
|
||||
// RVLV=1 只到分部(分部全收) RVLV=2 只到清单(清单全收) RVLV=3 全展开
|
||||
@@ -1521,6 +1555,18 @@ function rawTreeHTML(d) {
|
||||
const _keepTree = (typeof RV_TREE_KEEP !== 'undefined' && RV_TREE_KEEP && RV_TREE) ? RV_TREE : null;
|
||||
if (typeof RV_TREE_KEEP !== 'undefined') RV_TREE_KEEP = false;
|
||||
RV_TREE = { root: true, divs: {}, bills: {} };
|
||||
// 决策 244 补三:重开/刷新时层级档位按会话记忆恢复(rvst_<sid>.lv)——当时停在定额档
|
||||
// 就回到定额档、清单档回到清单档。**只在页面加载后第一次渲染时读一次**(RV_LV_RESTORED
|
||||
// 置位后不再回读):层级按钮显式换档(rawLv)与切换单位工程(rawPick 保持模块值)都是
|
||||
// 权威值,不能被旧存储盖掉(实测:rawLv(3) 后被 rvst 旧 lv=2 盖回清单档的坑)。
|
||||
if (!_keepTree && !RV_LV_RESTORED) {
|
||||
RV_LV_RESTORED = true;
|
||||
try {
|
||||
const _sm0 = (typeof location !== 'undefined' ? (location.search || '') : '').match(/[?&]sid=(\d+)/);
|
||||
const _sv0 = JSON.parse(localStorage.getItem('rvst_' + (_sm0 ? _sm0[1] : '')) || 'null');
|
||||
if (_sv0 && _sv0.lv >= 1 && _sv0.lv <= 3) RVLV = _sv0.lv;
|
||||
} catch (e) {}
|
||||
}
|
||||
const initState = nodes => nodes.forEach(nd => {
|
||||
RV_TREE.divs['d' + nd.id] = (RVLV >= 2);
|
||||
(nd.bills || []).forEach(b => { RV_TREE.bills['b' + b.id] = (RVLV >= 3); });
|
||||
@@ -1550,7 +1596,7 @@ function rawTreeHTML(d) {
|
||||
// 编码列:单位工程编号已按主人 2026-10-08 要求全软件不显示,根行留「—」占位
|
||||
+ '<td class="c">—</td><td class="c"><span class="kind uw">单位工程</span></td>'
|
||||
+ '<td class="l">' + ell(uw.Name, '—') + '</td><td class="attr nv">—</td><td class="c">—</td>'
|
||||
+ '<td class="r"></td><td class="r"></td><td class="r"><b>' + rm(uw.Total) + '</b></td><td></td><td></td></tr>';
|
||||
+ '<td class="r"></td><td class="r"></td><td class="r"><b>' + rm(rootSum) + '</b></td><td></td><td></td></tr>';
|
||||
const billRow = (b, path, dp) => {
|
||||
n++;
|
||||
const hasNorms = (b.norms || []).length > 0;
|
||||
@@ -1562,7 +1608,7 @@ function rawTreeHTML(d) {
|
||||
+ ' data-price="' + (b.Price == null ? '' : b.Price) + '"'
|
||||
+ (window.rawBillPick ? ' onclick="rawBillPick(this)"' : '')
|
||||
+ ' data-vis="' + vis + '" data-path="' + path + '/b' + b.id + '">'
|
||||
+ (hasNorms ? tgi('b' + b.id, TGI_BILL) : '<td class="tgc"></td>')
|
||||
+ (hasNorms ? tgi('b' + b.id, TGI_DIV + dp * TGI_STEP) : '<td class="tgc"></td>')
|
||||
// 序号 = 单位工程内行号(2026-10-10 主人定:每个单位工程的清单从 1 起排,不跨工程连号)
|
||||
+ '<td class="c">' + n + '</td><td class="c">' + ell(b.Number, '—') + '</td>'
|
||||
+ '<td class="c"><span class="kind">清单</span></td>'
|
||||
@@ -1609,12 +1655,12 @@ function rawTreeHTML(d) {
|
||||
const has = (nd.children && nd.children.length) || (nd.bills && nd.bills.length);
|
||||
rows += '<tr class="divrow d' + Math.min(dp, 2) + '" data-vis="'
|
||||
+ (parentPath ? 'uw/' + parentPath : 'uw') + '" data-path="' + path + '">'
|
||||
+ (has ? tgi(key, TGI_DIV) : '<td class="tgc"></td>')
|
||||
+ (has ? tgi(key, TGI_DIV + dp * TGI_STEP) : '<td class="tgc"></td>')
|
||||
+ '<td class="c">—</td><td class="c">' + ell(nd.Number, '—') + '</td>'
|
||||
+ '<td class="c"><span class="kind dv">分部</span></td>'
|
||||
+ '<td class="l" style="' + ind(dp) + '">' + ell(nd.Name, '—') + '</td>'
|
||||
+ '<td class="attr nv">—</td><td class="c">—</td><td class="r"></td><td class="r"></td>'
|
||||
+ '<td class="r">' + rm(nd.Total) + '</td><td></td><td></td></tr>';
|
||||
+ '<td class="r">' + rm(DIV_SUM.get(nd.id) || 0) + '</td><td></td><td></td></tr>';
|
||||
(nd.bills || []).forEach(b => billRow(b, path, dp + 1));
|
||||
walk(nd.children || [], path, dp + 1);
|
||||
});
|
||||
@@ -1624,36 +1670,161 @@ function rawTreeHTML(d) {
|
||||
// 2026-10-13 主人定:取消「N 个分部 · N 条清单(原文件全量,未做任何过滤)」提示行
|
||||
return rawTbl(cols, head, rows, null, 'auto');
|
||||
}
|
||||
function rawProj(tab, rows) {
|
||||
if (!rows || !rows.length) return '<div class="empty">没有数据</div>';
|
||||
const tot = rows.reduce((a, r) => a + (r.Total || 0), 0) || 1;
|
||||
// 2026-10-08 主人定:汇总分析的**结构与排序以左侧目录树为准** —— 单项工程做分组
|
||||
// 标题行(=树的单项工程层)。后端已按树序排好(单项工程按入库顺序、组内编号
|
||||
// 自然序、未挂单项工程的排最后),这里按 sec_name 相邻归组即可。
|
||||
const groups = [];
|
||||
/* ---- 决策 244(2026-11-01):汇总类树卡的展开状态 ----
|
||||
独立于分部分项的 RV_TREE(那套绑 分部/清单 节点键,别混用)。
|
||||
RVSUM_OPEN[key]:false=收起,缺省=展开。key:'p' 项目 / 's…' 单项 / 'n<Number>' 费用树行。
|
||||
rawSumTog 切换后就地重画(不重新取数);RVSUM_REDRAW 由各渲染函数挂当前闭包。 */
|
||||
let RVSUM_OPEN = {}, RVSUM_REDRAW = null;
|
||||
/* 决策 244 补一(2026-11-01 主人定):「项目汇总分析」卡只有 cos4 才有(.COS 无
|
||||
ProjectInstallationWorkCostSummary 节点)→ 无数据时整张标签隐藏。
|
||||
标志由 sum 卡响应的 has_psum 带回(rawProj 里落全局并重画标签行)。 */
|
||||
let RVSUM_HAS_PSUM = false;
|
||||
function _rsOpen(k) { return RVSUM_OPEN[k] !== false; }
|
||||
function rawSumTog(k) { RVSUM_OPEN[k] = !_rsOpen(k); rawSumSync(); }
|
||||
function rawSumSync() {
|
||||
if (!RVSUM_REDRAW) return;
|
||||
const b = document.getElementById(RVO.bodyEl);
|
||||
if (!b) return;
|
||||
b.innerHTML = RVSUM_REDRAW();
|
||||
if (typeof colwApply === 'function') colwApply(b.querySelector('table'));
|
||||
if (typeof rvCachePut === 'function') rvCachePut();
|
||||
}
|
||||
function _rsTgi(key, dp, leaf) { // ± 把手格(复用分部树的 .tgc/.tgi 样式)
|
||||
if (leaf) return '<td class="tgc"></td>';
|
||||
return '<td class="tgc"><span class="tgi" title="展开/收起" style="margin-left:' + (dp * 14) + 'px"'
|
||||
+ ' onclick="rawSumTog(\'' + key + '\')">' + (_rsOpen(key) ? '−' : '+') + '</span></td>';
|
||||
}
|
||||
/* 金额/费率显示:null 与 0 都显示空白(照主人图3/图4:零值行留空,非原样 0.00) */
|
||||
const _rsAmt = v => (v ? rm(v) : '');
|
||||
const _rsRate = v => (v ? String(v) : '');
|
||||
/* 决策 244:项目级「汇总分析」卡改三层树表(整个项目 → 单项工程 → 单位工程),
|
||||
列照主人 2026-11-01 图1b:序号/属性/工程编号/工程名称/专业/建设规模/单位/总造价/经济指标/占总价(%)/备注。
|
||||
总造价=单位 ztotal(决策 244 口径,老数据缺列回退 Total);经济指标=总造价÷建设规模;
|
||||
占总价%=总造价÷全项目合计;项目/单项行金额=子行合计(图1b/图B 同口径,图B 单项 38,612,441.08=Σ单位)。
|
||||
结构/排序仍以左侧目录树为准(2026-10-08 口径不变,后端已按树序排好);
|
||||
未挂单项工程的照图1b 补一层单项行(图上「一 单项工程」即三溪未挂的例子)。 */
|
||||
const RAW_SPEC = { 1: '建筑', 2: '装饰', 3: '安装', 4: '市政', 5: '园林绿化' };
|
||||
function rawProj(tab, rows, proj, hasPsum) {
|
||||
rows = rows || []; proj = proj || {};
|
||||
if (!rows.length) return '<div class="empty">没有数据</div>';
|
||||
// 决策 244 补一:has_psum 落全局并重画标签行——cos4 显示「项目汇总分析」、.COS/手工工程隐藏
|
||||
RVSUM_HAS_PSUM = !!hasPsum;
|
||||
if (typeof rawTabs === 'function') rawTabs();
|
||||
const zt = r => (r.ztotal != null ? r.ztotal : (r.Total || 0));
|
||||
const tot = rows.reduce((a, r) => a + zt(r), 0);
|
||||
const CN = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十'];
|
||||
// 单项层:按 section_id 相邻归组(后端已按树序排好);全未挂 → 补一层同名单项行
|
||||
const secs = [];
|
||||
rows.forEach(r => {
|
||||
const key = r.sec_name || '(未挂单项工程)';
|
||||
const last = groups[groups.length - 1];
|
||||
if (last && last.key === key) last.rows.push(r);
|
||||
else groups.push({ key: key, rows: [r] });
|
||||
const k = r.section_id ? ('s' + r.section_id) : 's_';
|
||||
const last = secs[secs.length - 1];
|
||||
if (last && last.key === k) last.rows.push(r);
|
||||
else secs.push({ key: k, name: r.sec_name || '', rows: [r] });
|
||||
});
|
||||
// 2026-10-13 主人定:加「序号」列——只有单位工程参与编号(单项工程标题行不编);
|
||||
// 取消 分部分项/措施项目/税金 三列与顶部 hint 行;名称列弹性吃余宽(≈65%),拖列走公共 .rs。
|
||||
if (secs.length === 1 && secs[0].key === 's_' && !secs[0].name) secs[0].name = proj.name || '';
|
||||
let no = 0;
|
||||
const body = groups.map(g => {
|
||||
const sum = g.rows.reduce((a, r) => a + (r.Total || 0), 0);
|
||||
return '<tr class="gsec"><td class="l" colspan="4">' + esc(g.key)
|
||||
+ ' · ' + g.rows.length + ' 个单位工程 · 合计 ' + rm(sum) + '</td></tr>'
|
||||
+ g.rows.map(r =>
|
||||
'<tr><td class="c">' + (++no) + '</td>'
|
||||
const scale = v => (v ? rm(v) : '—'); // 决策 244 补一:.COS 无规模的行是 0.00 → 照图1b 显示 —
|
||||
const unit = v => esc(v || '—');
|
||||
const body = ['<tr class="uwrow">' + _rsTgi('p', 0, false)
|
||||
+ '<td class="c"></td><td class="c">项目</td>'
|
||||
+ '<td class="c">' + esc(proj.number || '—') + '</td>'
|
||||
+ '<td class="l"><b>' + esc(proj.name || '—') + '</b></td><td class="c">—</td>'
|
||||
+ '<td class="r">' + scale(proj.scale) + '</td>'
|
||||
+ '<td class="c">' + unit(proj.unit) + '</td>'
|
||||
+ '<td class="r"><b>' + rm(tot) + '</b></td>'
|
||||
+ '<td class="r">' + (proj.scale ? rm(tot / proj.scale) : '—') + '</td>'
|
||||
+ '<td class="r">' + (tot ? '100.00' : '—') + '</td><td></td></tr>'];
|
||||
secs.forEach((s, si) => {
|
||||
if (!_rsOpen('p') || !_rsOpen(s.key)) return;
|
||||
const stot = s.rows.reduce((a, r) => a + zt(r), 0);
|
||||
body.push('<tr>' + _rsTgi(s.key, 1, false)
|
||||
+ '<td class="c">' + (si < 10 ? CN[si] : String(si + 1)) + '</td>'
|
||||
+ '<td class="c">单项工程</td><td class="c">—</td>'
|
||||
+ '<td class="l">' + ell(s.name || proj.name, '—') + '</td><td class="c">—</td>'
|
||||
+ '<td class="r">' + scale(proj.scale) + '</td>'
|
||||
+ '<td class="c">' + unit(proj.unit) + '</td>'
|
||||
+ '<td class="r"><b>' + rm(stot) + '</b></td>'
|
||||
+ '<td class="r">' + (proj.scale ? rm(stot / proj.scale) : '—') + '</td>'
|
||||
+ '<td class="r">' + (tot ? (stot / tot * 100).toFixed(2) : '—') + '</td><td></td></tr>');
|
||||
s.rows.forEach(r => {
|
||||
const z = zt(r), sc = (r.Scale != null ? r.Scale : proj.scale);
|
||||
body.push('<tr>' + _rsTgi('u' + r.id, 2, true)
|
||||
+ '<td class="c">' + (++no) + '</td>'
|
||||
+ '<td class="c">单位工程</td>'
|
||||
+ '<td class="c">' + esc(r.Number || '—') + '</td>'
|
||||
+ '<td class="l">' + ell(r.Name, '—') + '</td>'
|
||||
+ '<td class="r">' + rm(r.Total) + '</td>'
|
||||
+ '<td class="r">' + ((r.Total || 0) / tot * 100).toFixed(3) + '</td></tr>').join('');
|
||||
}).join('');
|
||||
// 单位工程名称列弹性宽('')吸收余宽(≈65%),其余固定;拖列/列宽记忆走公共 rawTbl 口径
|
||||
return rawTbl([40, '', 110, 60],
|
||||
[['序号', 'c'], ['单位工程名称', 'l'], ['总造价', 'r'], ['占总价%', 'r']],
|
||||
body);
|
||||
+ '<td class="c">' + (r.Specialty != null ? esc(RAW_SPEC[Number(r.Specialty)] || String(r.Specialty)) : '—') + '</td>'
|
||||
+ '<td class="r">' + scale(r.Scale != null ? r.Scale : proj.scale) + '</td>'
|
||||
+ '<td class="c">' + unit(r.Unit || proj.unit) + '</td>'
|
||||
+ '<td class="r">' + rm(z) + '</td>'
|
||||
+ '<td class="r">' + (sc ? rm(z / sc) : '—') + '</td>'
|
||||
+ '<td class="r">' + (tot ? (z / tot * 100).toFixed(2) : '—') + '</td><td></td></tr>');
|
||||
});
|
||||
});
|
||||
RVSUM_REDRAW = () => rawProj(tab, rows, proj);
|
||||
// 名称列弹性宽('')吸收余宽;拖列/列宽记忆走公共 rawTbl 口径
|
||||
return rawTbl([36, 44, 70, 80, '', 72, 84, 48, 110, 80, 76, 110],
|
||||
[['', 'c'], ['序号', 'c'], ['属性', 'c'], ['工程编号', 'c'], ['工程名称', 'l'], ['专业', 'c'],
|
||||
['建设规模', 'r'], ['单位', 'c'], ['总造价', 'r'], ['经济指标', 'r'], ['占总价(%)', 'r'], ['备注', 'l']],
|
||||
body.join(''));
|
||||
}
|
||||
/* 决策 244:费用汇总树卡(项目级「项目汇总分析」= ProjectInstallationWorkCostSummary;
|
||||
单位级「汇总分析」= UnitWorksSummary——原键值卡按主人 2026-11-01 拍板取代)。
|
||||
行原样出库(Kind grp/item),前端按 Number 前缀归层('2.1' 的父=Number '2');
|
||||
列照图4/图A:序号/名称/计算基础/费率(%)/合计/代号/备注(「不汇总」列取消,主人拍板)。
|
||||
全部源文件原值(计算基础/代号=文件原生码原文,主人拍板),前端不做任何计算。 */
|
||||
function rawFeeTree(rows, kind) {
|
||||
rows = rows || [];
|
||||
if (!rows.length) return '<div class="empty">没有数据</div>';
|
||||
const byNo = {};
|
||||
rows.forEach(r => { if (r.Number) byNo[r.Number] = r; r._kids = []; });
|
||||
const tops = [];
|
||||
rows.forEach(r => {
|
||||
const n = r.Number || '';
|
||||
const dot = n.lastIndexOf('.');
|
||||
const pn = dot > 0 ? n.slice(0, dot) : '';
|
||||
if (pn && byNo[pn]) byNo[pn]._kids.push(r);
|
||||
else tops.push(r);
|
||||
});
|
||||
const emit = (r, dp) => {
|
||||
let h = '<tr' + (r.Kind === 'grp' ? ' class="gsec"' : '') + '>'
|
||||
+ _rsTgi('n' + r.Number, dp, !(r._kids || []).length)
|
||||
+ '<td class="c">' + esc(r.Number || '') + '</td>'
|
||||
+ '<td class="l">' + ell(r.Name, '—') + '</td>'
|
||||
+ '<td class="l">' + esc(r.Formula || '') + '</td>'
|
||||
+ '<td class="r">' + _rsRate(r.Rate) + '</td>'
|
||||
+ '<td class="r">' + _rsAmt(r.Total) + '</td>'
|
||||
+ '<td class="c">' + esc(r.Code || '') + '</td>'
|
||||
+ '<td class="l">' + esc(r.Remark || '') + '</td></tr>';
|
||||
if (_rsOpen('n' + r.Number)) (r._kids || []).forEach(k => { h += emit(k, dp + 1); });
|
||||
return h;
|
||||
};
|
||||
RVSUM_REDRAW = () => rawFeeTree(rows, kind);
|
||||
return rawTbl([36, 40, '', 170, 64, 110, 110, 220],
|
||||
[['', 'c'], ['序号', 'c'], ['名称', 'l'], ['计算基础', 'l'], ['费率(%)', 'r'],
|
||||
['合计', 'r'], ['代号', 'c'], ['备注', 'l']],
|
||||
tops.map(r => emit(r, 0)).join(''));
|
||||
}
|
||||
/* 决策 244:单位工程「其他项目」卡 = Sundry 容器行(Kind='root')+ SundryCostsItem 平铺。
|
||||
列照主人图3:序号/名称/单位/取费基数工程量/基数公式/费率(%)/单价/合价/代号/备注。
|
||||
全部源文件原值(无值与 0 留空照图);前端不做任何计算。 */
|
||||
function rawSundry(rows) {
|
||||
rows = rows || [];
|
||||
if (!rows.length) return '<div class="empty">没有数据</div>';
|
||||
const body = rows.map(r => '<tr' + (r.Kind === 'root' ? ' class="gsec"' : '') + '>'
|
||||
+ '<td class="c">' + esc(r.Number || '') + '</td>'
|
||||
+ '<td class="l">' + ell(r.Name, '—') + '</td>'
|
||||
+ '<td class="c">' + esc(r.Unit || '') + '</td>'
|
||||
+ '<td class="r">' + (r.Quantity ? r3(r.Quantity) : '') + '</td>'
|
||||
+ '<td class="c">' + esc(r.Formula || '') + '</td>'
|
||||
+ '<td class="r">' + _rsRate(r.Rate) + '</td>'
|
||||
+ '<td class="r">' + _rsAmt(r.Price) + '</td>'
|
||||
+ '<td class="r">' + _rsAmt(r.Total) + '</td>'
|
||||
+ '<td class="c">' + esc(r.Code || '') + '</td>'
|
||||
+ '<td class="l">' + esc(r.Remark || '') + '</td></tr>').join('');
|
||||
return rawTbl([44, 150, 48, 100, 90, 64, 90, 100, 70, ''],
|
||||
[['序号', 'c'], ['名称', 'l'], ['单位', 'c'], ['取费基数工程量', 'r'], ['基数公式', 'c'],
|
||||
['费率(%)', 'r'], ['单价', 'r'], ['合价', 'r'], ['代号', 'c'], ['备注', 'l']], body);
|
||||
}
|
||||
function rawSec(d) {
|
||||
const s = d.sec || {}, rows = d.rows || [];
|
||||
@@ -1668,12 +1839,8 @@ function rawSec(d) {
|
||||
+ '<td class="r">' + rm(r.Preliminaries) + '</td><td class="r">' + rm(r.Total) + '</td>'
|
||||
+ '<td class="r">' + ((r.Total || 0) / tot * 100).toFixed(3) + '</td></tr>').join(''));
|
||||
}
|
||||
function rawUw(tab, rows) {
|
||||
const r = rows || {};
|
||||
const K = [['Total', '总造价'], ['Construction', '建筑安装工程费'], ['DivisionalAndElementalWorks', '分部分项工程费'],
|
||||
['Preliminaries', '措施项目费'], ['CostForHSE', '绿色施工安全防护费'], ['SundryCosts', '其他项目费'], ['Tax', '税金']];
|
||||
return rawKV(K.map(x => [x[1], r[x[0]] == null ? '—' : rm(r[x[0]])]), ''); // 2026-10-13 主人定:取消说明行
|
||||
}
|
||||
/* 旧 rawUw 键值卡已撤(决策 244,2026-11-01 主人拍板):单位级「汇总分析」= rawFeeTree
|
||||
(UnitWorksSummary 原样树),「其他项目」= rawSundry。 */
|
||||
|
||||
/* ---- 定额行「耗」按钮 → 工料机浮层(2026-10-15 公共功能4/5)----
|
||||
四个视图的定额子行序号格共用:原数据 分部分项/措施项目(rawTreeHTML)+ 类似清单/组价不一致
|
||||
@@ -1717,6 +1884,78 @@ function haoPin(el) {
|
||||
el.classList.toggle('on', on);
|
||||
el.title = on ? '已钉住:鼠标离开不关闭(点空白处或再点取消)' : '钉住:鼠标离开不关闭(点空白处关闭)';
|
||||
}
|
||||
|
||||
/* ================= 决策 243(2026-11-01 主人定):工料机「源」——来源追溯 =================
|
||||
工料机表序号列右侧「源」钮(两侧同形)→ 浮层:序号|单位工程名称|清单|数量,底部合计=数量之和;
|
||||
数量与汇总现算同口径(含量×定额量,台班/配合比子级传导一层),聚合到清单粒度。
|
||||
点行 → locBill(bid, uwid) 穿越到原数据那条清单(工作台/后台明细两侧同名现成,决策 213 补记七)。 */
|
||||
function lmeSrcCellHTML(r) {
|
||||
const code = String((r && r[1]) || '').trim();
|
||||
return code
|
||||
? '<span class="haobtn" title="查看本工料机的来源(定额/清单),点行可跳转" onclick="lmeSrcPop(this,\'' + esc(code) + '\')">源</span>'
|
||||
: '<span style="color:#b9c4d2">—</span>';
|
||||
}
|
||||
function lmeSrcPop(btn, code) {
|
||||
if (HAO_POP && HAO_POP.dataset.code === code) { haoPopClose(); return; } // 再点同一个 = 收起
|
||||
haoPopClose();
|
||||
const pop = document.createElement('div');
|
||||
pop.className = 'haopop'; pop.dataset.code = code;
|
||||
pop.innerHTML = '<div class="haobar"><span class="ht">来源 · ' + esc(code) + '</span>'
|
||||
+ '<span class="pin" title="钉住:鼠标离开不关闭(点空白处关闭)" onclick="haoPin(this)">📌</span></div>'
|
||||
+ '<table><colgroup>'
|
||||
+ '<col style="width:44px"><col style="width:170px"><col style="width:270px"><col style="width:84px">'
|
||||
+ '</colgroup>'
|
||||
+ '<thead><tr><th>序号<span class="rs"></span></th><th>单位工程名称<span class="rs"></span></th>'
|
||||
+ '<th>清单<span class="rs"></span></th><th>数量<span class="rs"></span></th></tr></thead>'
|
||||
+ '<tbody><tr><td colspan="4" class="empty">正在读取…</td></tr></tbody></table>';
|
||||
document.body.appendChild(pop);
|
||||
HAO_POP = pop; HAO_BTN = btn;
|
||||
haoPlace(pop, btn);
|
||||
colwApply(pop.querySelector('table'));
|
||||
sumw(pop.querySelector('table'));
|
||||
pop.addEventListener('mouseleave', () => {
|
||||
if (!HAO_POP || HAO_POP.dataset.pinned === '1') return;
|
||||
haoPopClose();
|
||||
});
|
||||
window.addEventListener('scroll', haoPopAway, true);
|
||||
window.addEventListener('resize', haoPopAway);
|
||||
document.addEventListener('mousedown', haoOutside, true);
|
||||
const url = (typeof SID !== 'undefined' && SID)
|
||||
? '/api/session/lme/src?session_id=' + SID + '&code=' + encodeURIComponent(code)
|
||||
: '/api/admin/batch/' + (typeof DID !== 'undefined' ? DID : 0) + '/lme/src?code=' + encodeURIComponent(code);
|
||||
// ⚠️ 后台明细的当前批次 = **DID**(det() 里 DID=id;QBID 是类似清单页签的变量、顶层 let
|
||||
// 均不挂 window,必须裸名 typeof 探测)——写成 window.QBID 取 undefined→batch 0→
|
||||
// 后台「源」恒空(2026-11-01 主人实测抓到,已修)。
|
||||
fetch(url).then(r => r.json()).then(d => {
|
||||
if (HAO_POP !== pop) return; // 浮层已被收掉,丢弃迟到响应
|
||||
const rows = (d && d.rows) || [];
|
||||
if (!rows.length) {
|
||||
pop.querySelector('tbody').innerHTML = '<tr><td colspan="4" class="empty">没有找到消耗量来源(本码未被任何清单/定额直挂或经台班/配合比引用)</td></tr>';
|
||||
} else {
|
||||
let sum = 0;
|
||||
pop.querySelector('tbody').innerHTML = rows.map((x, i) => {
|
||||
sum += (Number(x.qty) || 0);
|
||||
return '<tr class="lmesrc-row" data-bid="' + x.bid + '" data-uwid="' + (x.uw_id == null ? '' : x.uw_id) + '"'
|
||||
+ ' onclick="lmeSrcGo(this)" title="点击跳转到原数据该清单">'
|
||||
+ '<td class="c">' + (i + 1) + '</td><td>' + esc(x.uw_name || '—') + '</td>'
|
||||
+ '<td>' + esc(x.bill || '—') + '</td><td class="r">' + num(x.qty, 3) + '</td></tr>';
|
||||
}).join('')
|
||||
+ '<tr style="background:#eef4fb;font-weight:600"><td colspan="3" class="c">总数量</td>'
|
||||
+ '<td class="r">' + num(sum, 3) + '</td></tr>';
|
||||
}
|
||||
colwApply(pop.querySelector('table'));
|
||||
sumw(pop.querySelector('table'));
|
||||
haoPlace(pop, btn);
|
||||
}).catch(() => {
|
||||
if (HAO_POP !== pop) return;
|
||||
pop.querySelector('tbody').innerHTML = '<tr><td colspan="4" class="empty">读取失败</td></tr>';
|
||||
});
|
||||
}
|
||||
function lmeSrcGo(tr) {
|
||||
haoPopClose();
|
||||
const bid = Number(tr.dataset.bid), uwid = tr.dataset.uwid;
|
||||
if (typeof locBill === 'function') locBill(bid, uwid === '' ? null : Number(uwid));
|
||||
}
|
||||
/* 按按钮右下角定位:默认浮层左上角贴按钮右下角;下方放不下翻转成浮层左下角贴按钮右下角;
|
||||
右边溢出则整体收进视口。数据到货后尺寸会变,须再 place 一次。 */
|
||||
function haoPlace(pop, btn) {
|
||||
@@ -1729,6 +1968,71 @@ function haoPlace(pop, btn) {
|
||||
else y = Math.max(M, r.bottom - h);
|
||||
pop.style.left = x + 'px'; pop.style.top = y + 'px';
|
||||
}
|
||||
|
||||
/* ================= 决策 243 补记三(2026-11-01 主人定「切换选项卡,仍然定位到上一次的清单和定额」):
|
||||
定额现场抓拍/恢复(两侧同款:工作台原数据 / 后台明细原数据)。
|
||||
机理:定额点选会**清掉清单 sel**(规格⑭「只保持最后点选的一行」)——旧存档只记清单 sel,
|
||||
最后点的是定额时切走 → 存档全空 → 切回什么都不定位。
|
||||
事实勘察(2026-11-01 实测):原数据页定额子行**平铺直挂**(tr.sub[data-nid] 常在 DOM,无展开
|
||||
概念——±把手 tgi/rawTog 只折叠树,勿套用 p1/p2 组表的 .tog/tgNorm 机制)。
|
||||
抓拍=选中定额 nid;恢复=轮询定位该定额行加 subsel+居中(rvtab 恢复链先行,行必在)。 */
|
||||
function _normSceneCapture(bodyEl) {
|
||||
const sub = bodyEl.querySelector('tr.subsel');
|
||||
return { normsel: sub ? (sub.dataset.nid || null) : null };
|
||||
}
|
||||
/* 一次 apply:sel + 定额 subsel(子行不在则点展开钮)+ 滚动定位。返回是否全部到位。 */
|
||||
function _rawSceneApply(bodyEl, bid, normsel) {
|
||||
let subDone = !normsel;
|
||||
let billEl = null;
|
||||
if (bid) {
|
||||
billEl = bodyEl.querySelector('tr.brow[data-bid="' + bid + '"]');
|
||||
if (!billEl) return false; // 重画中,行还没回来
|
||||
if (!billEl.classList.contains('sel')) {
|
||||
bodyEl.querySelectorAll('tr.sel').forEach(x => x.classList.remove('sel'));
|
||||
billEl.classList.add('sel');
|
||||
}
|
||||
}
|
||||
if (normsel) {
|
||||
const sub = bodyEl.querySelector('tr.sub[data-nid="' + normsel + '"]');
|
||||
if (sub) {
|
||||
if (!sub.classList.contains('subsel')) {
|
||||
document.querySelectorAll('tr.subsel').forEach(x => x.classList.remove('subsel'));
|
||||
sub.classList.add('subsel');
|
||||
}
|
||||
sub.scrollIntoView({ block: 'center' });
|
||||
subDone = true;
|
||||
} else if (billEl) {
|
||||
const btn = billEl.querySelector('.tgi[data-node="b' + bid + '"]') || billEl.querySelector('.tog');
|
||||
if (btn) btn.click(); // 展开定额区(rawTog/tgNorm 通吃),下轮 guard 补 subsel
|
||||
}
|
||||
}
|
||||
if (billEl) billEl.scrollIntoView({ block: 'center' });
|
||||
return subDone;
|
||||
}
|
||||
/* 守窗自愈:切页签后 rawbody 仍会被异步重画(骨架条/搜索重高亮/对比联动)洗掉 sel/subsel——
|
||||
每轮校验:恢复的行元素断链(重画)或 sel/subsel 被清 → 重放 apply;用户点击新行(pick 清旧)
|
||||
视为接管,停止守窗。默认守 3s,够所有已知异步重画落地。 */
|
||||
function _rawSceneGuard(bodyEl, bid, normsel, ms) {
|
||||
const mark = { bill: null, sub: null, tries: 0 };
|
||||
const stop0 = Date.now() + (ms || 3000);
|
||||
const guard = () => {
|
||||
if (Date.now() > stop0 || mark.tries > 4) return;
|
||||
const billEl = bid ? bodyEl.querySelector('tr.brow[data-bid="' + bid + '"]') : null;
|
||||
// 用户点了别的行(sel 换了且不是恢复目标)→ 停止守窗
|
||||
const cur = bodyEl.querySelector('tr.sel');
|
||||
if (cur && bid && cur.dataset.bid && cur.dataset.bid !== bid) return;
|
||||
const subEl = normsel ? bodyEl.querySelector('tr.subsel') : null;
|
||||
const ok = (!bid || (billEl && billEl.classList.contains('sel'))) &&
|
||||
(!normsel || (subEl && subEl.dataset.nid === normsel));
|
||||
if (!ok) {
|
||||
mark.tries++;
|
||||
_rawSceneApply(bodyEl, bid, normsel);
|
||||
}
|
||||
setTimeout(guard, 400);
|
||||
};
|
||||
_rawSceneApply(bodyEl, bid, normsel);
|
||||
setTimeout(guard, 400);
|
||||
}
|
||||
function haoPop(btn, nid) {
|
||||
if (HAO_POP && HAO_POP.dataset.nid === String(nid)) { haoPopClose(); return; } // 再点同一个 = 收起
|
||||
haoPopClose();
|
||||
@@ -2974,6 +3278,11 @@ const APP_I18N = {
|
||||
'期次 全部 ▾': '期次 全部 ▾', '条数': '條數', '来源': '來源', '来源 全部 ▾': '來源 全部 ▾',
|
||||
'档位': '檔位', '清单': '清單', '源文件': '源文件', '相似度': '相似度', '省': '省',
|
||||
'汇总分析': '匯總分析', '工料机汇总': '工料機匯總', '分部分项': '分部分項',
|
||||
'项目汇总分析': '項目匯總分析', '其他项目': '其他項目',
|
||||
'属性': '屬性', '工程编号': '工程編號', '专业': '專業', '建设规模': '建設規模',
|
||||
'经济指标': '經濟指標', '占总价(%)': '佔總價(%)', '计算基础': '計算基礎',
|
||||
'费率(%)': '費率(%)', '合计': '合計', '代号': '代號',
|
||||
'取费基数工程量': '取費基數工程量', '基数公式': '基數公式', '单项工程': '單項工程',
|
||||
'措施项目': '措施項目', '定额(编码 / 名称)': '定額(編碼 / 名稱)',
|
||||
'确认': '確認', '提示': '提示', '税率': '稅率', '类似清单': '類似清單', '类别': '類別',
|
||||
'组价不一致清单': '組價不一致清單', '组名': '組名', '编码': '編碼', '规格型号': '規格型號',
|
||||
@@ -3084,6 +3393,11 @@ const APP_I18N = {
|
||||
'来源 全部 ▾': 'Source: All ▾', '档位': 'Tier', '清单': 'Bill', '源文件': 'Source File',
|
||||
'相似度': 'Match', '省': 'Province', '确认': 'Confirm', '提示': 'Notice',
|
||||
'汇总分析': 'Summary Analysis', '工料机汇总': 'L&M Summary', '分部分项': 'Divisional Works',
|
||||
'项目汇总分析': 'Project Summary', '其他项目': 'Sundries',
|
||||
'属性': 'Attribute', '工程编号': 'Project No.', '专业': 'Specialty', '建设规模': 'Scale',
|
||||
'经济指标': 'Econ. Index', '占总价(%)': 'Share (%)', '计算基础': 'Base',
|
||||
'费率(%)': 'Rate (%)', '合计': 'Total', '代号': 'Code',
|
||||
'取费基数工程量': 'Base Qty', '基数公式': 'Base Formula', '单项工程': 'Section',
|
||||
'措施项目': 'Preliminaries', '定额(编码 / 名称)': 'Norm (Code / Name)',
|
||||
'税率': 'Tax Rate', '类似清单': 'Similar Bills', '类别': 'Type',
|
||||
'组价不一致清单': 'Price Mismatch', '组名': 'Group', '编码': 'Code',
|
||||
|
||||
@@ -206,7 +206,7 @@ function render(){
|
||||
let h='';
|
||||
rowsToShow.forEach(r=>{
|
||||
const srcCell = r[9]
|
||||
? `<span class="manualtag" title="手工工程:没有源文件,不能按原格式导出/重新解析;用「打开项目」选择同名源文件可补传">手工创建</span>`
|
||||
? `<span class="manualtag" title="手工工程:没有源文件,不能按原格式导出/重新解析;要上源文件数据请先删除本工程,再按源文件重新导入(同名导入会被拒,决策 242)">手工创建</span>`
|
||||
: (r[8]
|
||||
? esc(r[4]) + ' <span class="srcmiss" style="color:#c0392b;font-weight:600;white-space:nowrap" title="原文件已不在软件里:该工程无法导出、无法重新解析(已解析的数据仍可查看)。删除会话不受影响">源文件缺失</span>'
|
||||
: esc(r[4]));
|
||||
|
||||
@@ -306,6 +306,12 @@ body.histdrag{user-select:none}
|
||||
.copylist .cnt{color:#5a6b7e;font-size:12px}
|
||||
/* 询价附件(2026-10-09 改版:采纳收集目录,左树右项目) */
|
||||
.inq2{display:flex;gap:10px;align-items:stretch}
|
||||
/* 决策 243:附件分「清单附件/工料机附件」两标签 */
|
||||
.inqtabs{display:flex;gap:8px}
|
||||
.inqtab{padding:5px 14px;border:1px solid #c9d4e3;border-radius:16px;background:#fff;
|
||||
font:inherit;font-size:12.5px;color:#3d4f63;cursor:pointer}
|
||||
.inqtab:hover{background:#eef3fa}
|
||||
.inqtab.on{background:#1f5fae;border-color:#1f5fae;color:#fff;font-weight:600}
|
||||
.inqtree{width:47%;min-width:300px;border:1px solid #d8e0ec;border-radius:8px;background:#fff;
|
||||
overflow:auto;max-height:56vh;padding:6px}
|
||||
.inqright{flex:1;border:1px solid #d8e0ec;border-radius:8px;background:#fff;
|
||||
@@ -563,12 +569,14 @@ body.histdrag{user-select:none}
|
||||
<div class="row" id="ofileRow" data-page-node-id="TgF4geYkFIZIFYQD6sNZHB"><span data-page-node-id="Ve3MJBmbfhkGXf26tQdqAA">全国电子标书</span><input type="file" id="ofile" onchange="autoName()" data-page-node-id="I2kkcqsdiXGL40535vRd25"></div>
|
||||
<div class="row" data-page-node-id="uWAVJwQc4PGXMkVwrLTAWX"><span data-page-node-id="A69LDfDYOD8sJ9RNmYrp7u">工程名称 *</span><input id="oname" placeholder="选文件后自动带出文件名,可改" data-page-node-id="M0HGCQ9uGkUnRnXEshiiDD"></div>
|
||||
<div class="row" data-page-node-id="3Yg2dLI3BNEr0iDvHyyFZR"><span data-page-node-id="a4VMhIZdcf8l3z3znIflbI">基准期次 *</span><input id="oper" placeholder="点这里选起~止(同月就选同一个)" data-page-node-id="NZlB1CroFZvcWL0CyQTZDE"></div>
|
||||
<div class="row" data-page-node-id="chlcT8xdVI2rRjz4HZDVWA"><span data-page-node-id="x8RmHqmvGQTydhqMUR8xAP">地区</span>
|
||||
<div class="row" data-page-node-id="chlcT8xdVI2rRjz4HZDVWA"><span data-page-node-id="x8RmHqmvGQTydhqMUR8xAP">地区 *</span>
|
||||
<select id="oprov" data-page-node-id="xhlO6Gx4yDx7nR51RQWFOf"><option value="" data-page-node-id="A14GaEGzaPfGDepXQCDkfg">省</option></select>
|
||||
<select id="ocity" data-page-node-id="thtavuoK0KGQ5SF2mFRfHj"><option value="" data-page-node-id="TSyGUu116TjZCdD2xkgVZ2">市</option></select>
|
||||
<select id="odist" data-page-node-id="QB7NuG51dQutua0IUQ8Bo4"><option value="" data-page-node-id="A3GttbLNDNTXLIjVf8RCqA">区/县/镇</option></select>
|
||||
</div>
|
||||
<div class="row" data-page-node-id="yRE3EzGcdeMqaEC2oz71Oy"><span data-page-node-id="HhgkcRHxvZgzjC5BXXGDGC">建设单位</span><input id="obuid" placeholder="输入或从历史项目选择" autocomplete="off"></div>
|
||||
<div class="row" data-page-node-id="yRE3EzGcdeMqaEC2oz71Oy"><span data-page-node-id="HhgkcRHxvZgzjC5BXXGDGC">建设单位 *</span><input id="obuid" placeholder="输入或从历史项目选择" autocomplete="off"></div>
|
||||
<!-- 决策 245(2026-11-01 主人定):单价类型——与后台「打开项目」弹框同款同枚举(1..4,默认预算综合单价) -->
|
||||
<div class="row" id="okindRow"><span>单价类型 *</span><select id="okind"><option value="1">预算综合单价</option><option value="2">投标综合单价</option><option value="3">预算全费用</option><option value="4">投标全费用</option></select></div>
|
||||
<div class="tip" id="omsg" data-page-node-id="aQ4algswtlQMoiDgBrVN1u"></div>
|
||||
</div>
|
||||
<!-- 导入Excel 右侧目录树面板(决策 233):展开时随弹框定高,树内滚动不加高弹框 -->
|
||||
@@ -577,14 +585,13 @@ body.histdrag{user-select:none}
|
||||
<div class="tip" id="imsg" style="padding-top:8px"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mfoot" data-page-node-id="cIfN6fkvNTvkVdk85JJyPJ">
|
||||
<div class="mfoot" data-page-node-id="cIfN6fkvNTvkVdk85JJyPJ" style="align-items:center;justify-content:space-between">
|
||||
<!-- 决策 245(2026-11-01 主人定):按钮行左侧提示词,后台「打开项目」弹框逐字同款 -->
|
||||
<span class="tip" id="omRemind" style="flex:1;min-width:0;color:#b03a2e;line-height:1.45">提醒:建议在打开或导入项目时,先把工程独有的增加费(暗室、超高降效、预算包干、垂直运输等)取消后再入库或工作台的审核对比,否则容易造成数据失真!</span>
|
||||
<button class="btn" onclick="omask.classList.remove('on')" data-page-node-id="IAVuhdrc4Ln1HQDrn0cvBd">取消</button>
|
||||
<button class="btn" onclick="impTemplate()" title="下载单位工程数据结构 Excel(填写说明/分部分项/措施项目)">模板</button>
|
||||
<button class="btn" id="impBtnX" onclick="impExcelToggle()" title="右边展开目录树:建新工程或编辑手工工程目录(有项目打开时也可建新工程)">导入Excel</button>
|
||||
<!-- 决策 238(2026-10-28 主人定):整项目一把导入——一个 Excel(项目目录+多对 Sheet,每对=1 个单位工程)直接建项目 -->
|
||||
<button class="btn" onclick="impProjPick()" title="下载整项目导入模板(项目目录+多对 Sheet,每对 Sheet=1 个单位工程,一把导入建项目)">整项目模板</button>
|
||||
<button class="btn" onclick="$('iprojfile').click()" title="选整项目模板 Excel:项目目录 Sheet 定目录树,分部分项N/措施项目N 对应序号 N 的单位工程,一把建项目">整项目导入</button>
|
||||
<input type="file" id="iprojfile" accept=".xlsx" style="display:none" onchange="impProjFile()">
|
||||
<!-- 决策 242(2026-10-31 主人定):模板/整项目模板/整项目导入三钮移至树区「+单项工程」同排并改名(单位模板/项目模板/项目导入),底部只留 取消|导入Excel|创建工程 -->
|
||||
<!-- 决策 233 补记:创建工程与打开合并为一个主按钮——展开态=创建工程(impSave),收起态=打开(doOpen),放最右 -->
|
||||
<button class="btn pri" id="obtnGo" onclick="doOpen()" data-page-node-id="TE1Xb1738DYzPd3zBDAEAAT9o2">打开</button>
|
||||
</div>
|
||||
@@ -647,9 +654,13 @@ body.histdrag{user-select:none}
|
||||
|
||||
<div class="mask" id="inqmask">
|
||||
<div class="dlg" style="width:min(880px,94vw)">
|
||||
<div class="dh"><b>询价附件</b><span class="close" onclick="closeInq()">×</span></div>
|
||||
<div class="dh"><b>附件</b><span class="close" onclick="closeInq()">×</span></div>
|
||||
<div style="padding:14px 16px;display:flex;flex-direction:column;gap:10px">
|
||||
<div class="tip" style="padding:0">附件来自对比框点「采纳」的工料机行——同一附件被采纳多次只显示一个。点附件名,右侧显示它对应的项目;勾选后点「批量下载」,选一次位置即可全部存入。</div>
|
||||
<div class="tip" style="padding:0">附件来自对比框点「采纳」的清单或工料机行——同一附件被采纳多次只显示一个。清单采纳的进「清单附件」,工料机采纳的进「工料机附件」。点附件名,右侧显示它对应的项目;勾选后点「批量下载」,选一次位置即可全部存入。</div>
|
||||
<div class="inqtabs" id="inqTabs">
|
||||
<button class="inqtab on" id="inqTabBill" onclick="inqTab('bill')">清单附件(0)</button>
|
||||
<button class="inqtab" id="inqTabLme" onclick="inqTab('lme')">工料机附件(0)</button>
|
||||
</div>
|
||||
<div class="inq2">
|
||||
<div class="inqtree" id="inqTree"></div>
|
||||
<div class="inqright">
|
||||
@@ -799,6 +810,10 @@ let _apT = 0;
|
||||
const _apPick = () => {
|
||||
clearTimeout(_apT);
|
||||
_apT = setTimeout(() => {
|
||||
// 决策 243 补记三:记忆恢复守窗期内不抢选——守窗期 _rawSceneGuard 全权负责 sel/subsel
|
||||
//(此前 _apPick 与守窗拉锯:guard 加上→重画洗掉→_apPick 抢第一行→guard 重放…终态错乱)
|
||||
if (window.__P3_KEEP && Date.now() < window.__P3_KEEP &&
|
||||
(document.querySelector('.tab.on')||{}).dataset?.p === 'p3') return;
|
||||
// 决策 214:选中判定按当前页签的表——别页签的选中行不再挡住本页的默认选中
|
||||
const cur = document.querySelector('.tab.on') ? document.querySelector('.tab.on').dataset.p : null;
|
||||
const cont = { p0: '#tb0', p1: '#tb1', p2: '#tb2', p3: '#rawbody' }[cur];
|
||||
@@ -1060,9 +1075,14 @@ async function rawMergeOpen(view){
|
||||
if(_l1) _l1.classList.toggle('on', MV !== 'sub');
|
||||
if(_sb) _sb.classList.toggle('on', MV === 'sub');
|
||||
if(!d.groups.length){
|
||||
$('msg').textContent = MV === 'sub'
|
||||
? '没有可合并的子级组(被台班/配合比子级引用的工料机里,没有「名称|规格|单位相同但编码不同」的)'
|
||||
: '没有可合并的组(项目级+各单位工程汇总里没有「名称|规格|单位相同但编码不同」的工料机)';
|
||||
// 决策 241 补记(2026-10-31 实测抓到):切页签后 0 组必须**清空表格**显示空态——
|
||||
// 此前 return 时 mtree 残留上一视野渲染内容(页签已高亮、表还是旧的)=「两个页签一样」假象。
|
||||
$('mtree').innerHTML = '<div style="padding:48px 0;text-align:center;color:#8a97a8;font-size:13px">'
|
||||
+ esc(MV === 'sub'
|
||||
? '子级视野:没有可合并的组(被台班/配合比子级引用的工料机里,没有「名称|规格|单位相同但编码不同」的)'
|
||||
: '没有可合并的组(项目级+各单位工程汇总里没有「名称|规格|单位相同但编码不同」的工料机)')
|
||||
+ '</div>';
|
||||
$('msg').textContent = '';
|
||||
return;
|
||||
}
|
||||
renderMergeTree();
|
||||
@@ -1750,9 +1770,10 @@ async function openDlg(){
|
||||
$('ofile').value=''; $('oname').value=''; $('oname').dataset.auto=''; $('omsg').textContent=''; // input
|
||||
$('oper').value=''; $('oprov').value=''; $('ocity').value=''; $('odist').value=''; // 事件在
|
||||
$('obuid').value=''; $('obuid').dispatchEvent(new Event('input', {bubbles:true})); // 隐藏态测量
|
||||
$('okind').value='1'; // 决策 245:单价类型每次打开回默认「预算综合单价」
|
||||
// 2026-10-19 主人报:清空后下拉框自己展开。输入事件会把自由输入面板打开,这里立刻收起。
|
||||
if(typeof comboCloseAllPanels==='function') comboCloseAllPanels();
|
||||
if(MANUAL) $('omsg').textContent='当前是手工工程:选择同名源文件后点「打开」即可补传并恢复正常';
|
||||
if(MANUAL) $('omsg').textContent='当前是手工工程:要上源文件数据请先在最近审核删除本工程,再按源文件导入(同名会被拒,决策 242)';
|
||||
}
|
||||
|
||||
// 选好文件后,工程名称默认 = 文件名(去掉扩展名),可手动改
|
||||
@@ -1769,6 +1790,10 @@ async function doOpen(){
|
||||
if(!f){ $('omsg').textContent='请选择文件'; return; }
|
||||
const pv=PVAL($('oper'));
|
||||
if(pv.f==null||pv.t==null){ $('omsg').textContent='基准期次必填:点开选起~止(同一个月就选同一个)'; return; }
|
||||
// 决策 245(2026-11-01 主人定):地区/建设单位/单价类型也必填——与后台「打开项目」同规则、同文案
|
||||
if(!$('oprov').value||!$('ocity').value||!$('odist').value){ $('omsg').textContent='请填写:地区(省/市/区)'; return; }
|
||||
if(!$('obuid').value.trim()){ $('omsg').textContent='请填写:建设单位'; return; }
|
||||
if(!$('okind').value){ $('omsg').textContent='请选择单价类型'; return; }
|
||||
$('omsg').textContent='正在上传并解析…';
|
||||
// 2026-10-13 主人定:打开工程的全程(上传→解析→首屏)挂进度条,工程名+阶段可见
|
||||
ldShow($('oname').value||f.name,'正在上传工程文件…',6);
|
||||
@@ -1780,7 +1805,7 @@ async function doOpen(){
|
||||
body:JSON.stringify({path:up.path,name:$('oname').value||f.name,
|
||||
period_from:pv.f, period_to:pv.t, base_period_m:pv.f,
|
||||
province:$('oprov').value,city:$('ocity').value,district:$('odist').value,
|
||||
bulid_unit:$('obuid').value})});
|
||||
bulid_unit:$('obuid').value,file_kind:+$('okind').value})});
|
||||
if(!r.ok){
|
||||
let m=r.msg||'打开失败';
|
||||
if(/无法识别|不是计价文件|不再支持 xml|文件头/.test(m)) m='本文件暂不支持,请与软件商联系';
|
||||
@@ -1818,8 +1843,8 @@ function setManualMode(manual){
|
||||
2026-10-09 晚:旧「后台绑定」口径的行标/行高亮(询价小标)整套撤掉——
|
||||
工作台不再展示后台绑定关系,绑定是后台的事;目录里只看采纳。 */
|
||||
|
||||
/* ---- 采纳收集目录(顶栏「询价附件」按钮)---- */
|
||||
let ADOPT={atts:[],projs:[],sel:'',checked:new Set()};
|
||||
/* ---- 采纳收集目录(顶栏「附件」按钮)---- */
|
||||
let ADOPT={atts:[],projs:[],sel:'',checked:new Set(),tab:'bill'}; // tab:决策 243——清单附件/工料机附件分标签
|
||||
|
||||
async function loadAdopt(){
|
||||
try{
|
||||
@@ -1828,16 +1853,36 @@ async function loadAdopt(){
|
||||
ADOPT.atts=d.atts||[]; ADOPT.projs=d.projs||[];
|
||||
if(ADOPT.sel && !ADOPT.atts.some(a=>a.sha===ADOPT.sel)) ADOPT.sel='';
|
||||
const n=ADOPT.atts.length;
|
||||
$('btnInq').textContent=n?`询价附件(${n})`:'询价附件';
|
||||
$('btnInq').textContent=n?`附件(${n})`:'附件'; // 决策 243 补记(主人定):入口按钮就叫「附件」
|
||||
updInqTabs();
|
||||
}
|
||||
}catch(e){}
|
||||
}
|
||||
|
||||
/* 决策 243:附件分「清单附件/工料机附件」两标签——清单采纳带进来的进前者,
|
||||
工料机采纳带进来的进后者(同一附件两条路都采过 → 两边都出现)。
|
||||
cats 为空的旧数据归工料机标签。 */
|
||||
function inqTabAtts(){
|
||||
return ADOPT.atts.filter(a=>((a.cats&&a.cats.length)?a.cats:['lme']).includes(ADOPT.tab));
|
||||
}
|
||||
function updInqTabs(){
|
||||
const catsOf=a=>(a.cats&&a.cats.length)?a.cats:['lme'];
|
||||
$('inqTabBill').textContent=`清单附件(${ADOPT.atts.filter(a=>catsOf(a).includes('bill')).length})`;
|
||||
$('inqTabLme').textContent=`工料机附件(${ADOPT.atts.filter(a=>catsOf(a).includes('lme')).length})`;
|
||||
$('inqTabBill').classList.toggle('on',ADOPT.tab==='bill');
|
||||
$('inqTabLme').classList.toggle('on',ADOPT.tab==='lme');
|
||||
}
|
||||
function inqTab(t){
|
||||
ADOPT.tab=t;
|
||||
if(ADOPT.sel && !inqTabAtts().some(a=>a.sha===ADOPT.sel)) ADOPT.sel='';
|
||||
renderInqTree(); renderInqRight(); updInqCnt(); updInqTabs();
|
||||
}
|
||||
|
||||
async function openInq(){
|
||||
await loadAdopt(); // 打开时现取:会话切换/别处采纳都最新
|
||||
ADOPT.sel=''; // 打开停在根目录:右侧显示全部项目名称
|
||||
ADOPT.checked=new Set(ADOPT.atts.map(a=>a.sha)); // 每次打开默认全选(主人定)
|
||||
renderInqTree(); renderInqRight(); updInqCnt();
|
||||
renderInqTree(); renderInqRight(); updInqCnt(); updInqTabs();
|
||||
$('inqmask').classList.add('on');
|
||||
}
|
||||
function closeInq(){ $('inqmask').classList.remove('on'); }
|
||||
@@ -1845,21 +1890,25 @@ $('inqmask').onclick=e=>{ if(e.target===$('inqmask')) closeInq(); };
|
||||
|
||||
function renderInqTree(){
|
||||
const el=$('inqTree');
|
||||
if(!ADOPT.atts.length){
|
||||
const list=inqTabAtts();
|
||||
if(!list.length){
|
||||
el.innerHTML='<div class="empty" style="padding:16px 10px">'
|
||||
+(!SID?'还没打开项目。<br>打开项目后,在对比框点工料机行的「采纳」,该行跟随的附件就归到这个会话名下。'
|
||||
:'这个会话还没有收进附件。<br>在对比框点工料机行的「采纳」,该行跟随的附件就会收进这里。')
|
||||
+(!SID?'还没打开项目。<br>打开项目后,在对比框点清单或工料机行的「采纳」,该行跟随的附件就归到这个会话名下。'
|
||||
:(ADOPT.tab==='bill'
|
||||
?'这个会话还没有清单附件。<br>在对比框点入库清单行的「采纳」,那条清单挂的附件就会收进这里。'
|
||||
:'这个会话还没有工料机附件。<br>在对比框点工料机行的「采纳」,该行跟随的附件就会收进这里。'))
|
||||
+'</div>';
|
||||
return;
|
||||
}
|
||||
const allOn=ADOPT.checked.size===ADOPT.atts.length;
|
||||
const cur=new Set(list.map(a=>a.sha));
|
||||
const allOn=[...cur].every(s=>ADOPT.checked.has(s));
|
||||
el.innerHTML=
|
||||
`<div class="inqrow root ${ADOPT.sel?'':'on'}" onclick="inqPick('')" title="点这行:右侧显示全部项目名称">
|
||||
<span class="mk">▣</span><span class="nm">附件目录</span>
|
||||
<span class="sz">${ADOPT.atts.length} 个</span>
|
||||
<input type="checkbox" ${allOn?'checked':''} title="全选/全不选"
|
||||
<span class="sz">${list.length} 个</span>
|
||||
<input type="checkbox" ${allOn?'checked':''} title="全选/全不选(本标签)"
|
||||
onclick="event.stopPropagation();inqChkAll(this.checked)"></div>`
|
||||
+ADOPT.atts.map(a=>`<div class="inqrow sub ${ADOPT.sel===a.sha?'on':''}" onclick="inqPick('${a.sha}')"
|
||||
+list.map(a=>`<div class="inqrow sub ${ADOPT.sel===a.sha?'on':''}" onclick="inqPick('${a.sha}')"
|
||||
title="${esc(a.name)}">
|
||||
<span class="mk">▪</span><span class="nm">${esc(a.name)}</span>
|
||||
<span class="ext">${esc((a.ext||'').replace('.','').toUpperCase()||'文件')}</span>
|
||||
@@ -1869,26 +1918,37 @@ function renderInqTree(){
|
||||
}
|
||||
function renderInqRight(){
|
||||
const a=ADOPT.atts.find(x=>x.sha===ADOPT.sel);
|
||||
const list=a?(a.projs||[]):ADOPT.projs;
|
||||
$('inqRightH').textContent=a?`项目名称 · ${a.name}`:(ADOPT.atts.length?`项目名称 · 全部(${ADOPT.atts.length} 个附件)`:'项目名称');
|
||||
$('inqRightB').innerHTML=list.length
|
||||
? list.map(p=>`<div class="pj" title="${esc(p)}">${esc(p)}</div>`).join('')
|
||||
let pj;
|
||||
if(a){ pj=a.projs||[]; }
|
||||
else{ // 根目录:当前标签下各附件的项目名(去重保序)
|
||||
pj=[]; for(const t of inqTabAtts()) for(const p of (t.projs||[])) if(!pj.includes(p)) pj.push(p);
|
||||
}
|
||||
$('inqRightH').textContent=a?`项目名称 · ${a.name}`:(inqTabAtts().length?`项目名称 · 全部(${inqTabAtts().length} 个附件)`:'项目名称');
|
||||
$('inqRightB').innerHTML=pj.length
|
||||
? pj.map(p=>`<div class="pj" title="${esc(p)}">${esc(p)}</div>`).join('')
|
||||
: '<div class="pj" style="border:none;color:#8a97a8">'+(a?'(这个附件还没有带项目名的采纳记录)':'(还没有采纳记录)')+'</div>';
|
||||
}
|
||||
function inqPick(sha){ ADOPT.sel=sha; renderInqTree(); renderInqRight(); }
|
||||
function inqChk(sha,on){ if(on) ADOPT.checked.add(sha); else ADOPT.checked.delete(sha); renderInqTree(); updInqCnt(); }
|
||||
function inqChkAll(on){ ADOPT.checked=new Set(on?ADOPT.atts.map(a=>a.sha):[]); renderInqTree(); updInqCnt(); }
|
||||
function inqChkAll(on){ // 只动当前标签的勾选,另一标签的勾选保留
|
||||
const cur=new Set(inqTabAtts().map(a=>a.sha));
|
||||
ADOPT.checked=on?new Set([...ADOPT.checked,...cur])
|
||||
:new Set([...ADOPT.checked].filter(s=>!cur.has(s)));
|
||||
renderInqTree(); updInqCnt();
|
||||
}
|
||||
function updInqCnt(){
|
||||
const has=ADOPT.atts.length>0;
|
||||
$('inqSelCnt').textContent=has?`已选 ${ADOPT.checked.size} / ${ADOPT.atts.length} 个附件`:'';
|
||||
$('btnInqDl').disabled=!has||!ADOPT.checked.size;
|
||||
const list=inqTabAtts();
|
||||
const n=list.filter(a=>ADOPT.checked.has(a.sha)).length;
|
||||
$('inqSelCnt').textContent=list.length?`已选 ${n} / ${list.length} 个附件`:'';
|
||||
$('btnInqDl').disabled=!n;
|
||||
}
|
||||
|
||||
/* 批量下载(主人定 2026-10-09):点一次→弹一次保存框选位置→其余按该位置逐个自动写入,
|
||||
不用再点。重名自动加 (2)(3);单个失败不中断,继续下一个。
|
||||
浏览器不支持目录选择时退回逐个另存为(saveAs 内部会兜底成直接下载)。 */
|
||||
async function inqBatchDl(){
|
||||
const list=ADOPT.atts.filter(a=>ADOPT.checked.has(a.sha));
|
||||
/* 决策 243:批量下载随标签走——清单附件/工料机附件各是各的批量下载(只下当前标签勾选的) */
|
||||
const list=inqTabAtts().filter(a=>ADOPT.checked.has(a.sha));
|
||||
if(!list.length){ dlMsg('先在目录里勾选要下载的附件','warn'); return; }
|
||||
if(window.showDirectoryPicker){
|
||||
let dir;
|
||||
@@ -1995,24 +2055,37 @@ function _tabStateSave(p){
|
||||
const sel=$('tb0').querySelector('tr.sel');
|
||||
TABSTATE.p0={ lmeid: sel ? (sel.dataset.lmeid||sel.dataset.id) : ((TABSTATE.p0||{}).lmeid||null) };
|
||||
} else if(p==='p3'){
|
||||
// 决策 214 补:原数据页内**单位工程之间切换**也各自记忆(byUw:每 uw 记上次选中行+视图)
|
||||
// 决策 243 补记三(主人报「切选项卡不再定位上次的清单和定额」):存档补**定额现场**——
|
||||
// 定额点选会清清单 sel(规格⑭),最后点的是定额时切走 → 旧存档 bid=null → 切回全丢。
|
||||
// 现在:bid 锚=清单 sel 优先、否则定额子行的 data-bid;并记 normsel 供恢复。
|
||||
const sel=document.querySelector('#rawbody tr.sel');
|
||||
const sub=document.querySelector('#rawbody tr.subsel');
|
||||
const scene=_normSceneCapture(document.getElementById('rawbody'));
|
||||
const st = TABSTATE.p3 = TABSTATE.p3 || {byUw:{}};
|
||||
st.byUw = st.byUw || {};
|
||||
const anchorBid = sel ? sel.dataset.bid : (sub ? sub.dataset.bid : null);
|
||||
if(RVSEL.k==='uw'){
|
||||
st.byUw[RVSEL.id] = { bid: sel ? sel.dataset.bid : ((st.byUw[RVSEL.id]||{}).bid||null), rvtab: RVTAB };
|
||||
const o = st.byUw[RVSEL.id] || {};
|
||||
st.byUw[RVSEL.id] = Object.assign(o, {
|
||||
bid: sel ? sel.dataset.bid : (sub ? sub.dataset.bid : (o.bid||null)),
|
||||
rvtab: RVTAB, normsel: scene.normsel });
|
||||
}
|
||||
if(sel && sel.dataset.bid) st.bid = sel.dataset.bid;
|
||||
if(anchorBid) st.bid = anchorBid;
|
||||
st.normsel = scene.normsel;
|
||||
}
|
||||
}
|
||||
function _p3RestoreSel(){
|
||||
// 决策 243 补记三:恢复用**守窗自愈**——tab('p3') 后 rawbody 仍会被异步重画(骨架条/
|
||||
// 搜索重高亮/对比联动)洗掉 sel/subsel,与重画赛跑必输;_rawSceneGuard 每轮校验被洗
|
||||
// 即重放(用户点新行=接管,自动停)。此前同步找行全扑空=「记忆消失」的根因之一。
|
||||
const st=TABSTATE.p3;
|
||||
if(!st || document.querySelector('#rawbody tr.sel')) return;
|
||||
if(!st) return;
|
||||
const rec = (RVSEL.k==='uw' && st.byUw) ? st.byUw[RVSEL.id] : null;
|
||||
const bid = rec ? rec.bid : st.bid;
|
||||
if(!bid) return;
|
||||
const tr=document.querySelector('#rawbody tr.brow[data-bid="' + bid + '"]');
|
||||
if(tr){ tr.classList.add('sel'); tr.scrollIntoView({block:'center'}); }
|
||||
const normsel = rec && rec.normsel != null ? rec.normsel : st.normsel;
|
||||
if(!bid && !normsel) return;
|
||||
window.__P3_KEEP = Date.now() + 3500; // 守窗:_apPick 让位(见其入口注释)
|
||||
_rawSceneGuard(document.getElementById('rawbody'), bid, normsel, 3500);
|
||||
}
|
||||
/* 决策 214 补:原数据页内**单位工程间切换**也记忆——每 uw 记 上次选中行+视图+滚动,切回即恢复 */
|
||||
const _rawPickBase = rawPick;
|
||||
@@ -2022,8 +2095,12 @@ rawPick = async function(k, id, el){
|
||||
st.byUw = st.byUw || {};
|
||||
const sel = document.querySelector('#rawbody tr.sel');
|
||||
const sp = _scrollAncestor(document.querySelector('#rawbody'));
|
||||
st.byUw[RVSEL.id] = { bid: sel ? sel.dataset.bid : ((st.byUw[RVSEL.id]||{}).bid||null),
|
||||
rvtab: RVTAB, scroll: sp ? sp.scrollTop : null };
|
||||
const scene = _normSceneCapture(document.getElementById('rawbody'));
|
||||
const o = st.byUw[RVSEL.id] || {};
|
||||
st.byUw[RVSEL.id] = Object.assign(o, {
|
||||
bid: sel ? sel.dataset.bid : (scene.normsel ? (document.querySelector('#rawbody tr.subsel')||{}).dataset.bid : (o.bid||null)),
|
||||
rvtab: RVTAB, scroll: sp ? sp.scrollTop : null,
|
||||
normsel: scene.normsel });
|
||||
}
|
||||
await _rawPickBase(k, id, el);
|
||||
if(k==='uw'){
|
||||
@@ -2042,6 +2119,9 @@ rawPick = async function(k, id, el){
|
||||
if(rec.scroll!=null && sp){ sp.scrollTop=rec.scroll; } else { tr.scrollIntoView({block:'center'}); }
|
||||
}
|
||||
}
|
||||
// 决策 243 补记三:恢复 sel+定额(守窗自愈,防异步重画洗掉)
|
||||
if(rec && (rec.bid || rec.normsel))
|
||||
_rawSceneGuard(document.getElementById('rawbody'), rec.bid || null, rec.normsel || null, 3000);
|
||||
}
|
||||
};
|
||||
async function loadGroups(kind, fresh, keepView, restore){
|
||||
@@ -2312,8 +2392,7 @@ function renderHist(){
|
||||
let d='—',cls='';
|
||||
if(cur && x.price!=null){ const p=(x.price-cur)/cur*100;
|
||||
d=(p>=0?'+':'')+p.toFixed(1)+'%'; cls=p>=0?'up':'down'; }
|
||||
const op=[];
|
||||
if(x.file) op.push(`<a class="lk" href="/api/admin/file/${x.file_sha}" target="_blank">原件</a>`);
|
||||
const op=[]; // 决策 245(2026-11-01 主人定):操作列取消「原件」链接——附件列「下载」同文件同通道,重复入口;清单行与工料机框对齐
|
||||
if(!isLme && CURTYPE==='bill')
|
||||
op.push(i===adoptedIdx ? adoptedBadge : `<a class="lk" onclick="adopt(${i})">采纳</a>`);
|
||||
// ± 把手:只有历史「清单」行(带 bill_id)可展开定额 —— 同「类似清单」的交互;
|
||||
@@ -2558,7 +2637,7 @@ async function adopt(i){
|
||||
else await refreshRaw(true); // 决策 222:采纳(追加定额)静默重绘——界面像素不动,新定额行/合计/取消采纳列是合法内容变化
|
||||
renderHist(); // 已采纳灰标记:旧行复原、新行点亮(传递)
|
||||
lmeSyncAll(); // 决策 209:采纳动到消耗量/品类行 → 工料机三面即时跟随
|
||||
dlMsg('已采纳'+(r0?('('+r0.mode+':定额 '+r0.n_norm+' 条'+(r0.n_sum?('、汇总补品类 '+r0.n_sum+' 行'):'')+')'):'(仅备注)')+':'+txt,'ok');
|
||||
dlMsg('已采纳'+(r0?('('+r0.mode+':定额 '+r0.n_norm+' 条'+(r0.n_sum?('、汇总补品类 '+r0.n_sum+' 行'):'')+(r0.n_att?('、附件 '+r0.n_att+' 个已收进「清单附件」'):'')+')'):'(仅备注)')+':'+txt,'ok');
|
||||
}
|
||||
/* 清单取消采纳(2026-10-09 主人定):只清备注,不动「询价附件」目录(清单采纳本就不收附件)。
|
||||
2026-10-11:上方行数据/备注格同步清空,对比框灰「已采纳」复原为「采纳」(renderHist)。 */
|
||||
@@ -2602,7 +2681,7 @@ async function adoptAtt(x){
|
||||
const r=await J('/api/adopt/record',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({url:x.file_url,name:x.file||'',proj:x.proj||'',
|
||||
session_id:SID,lme_id:CUR.id})});
|
||||
if(r&&r.ok){ loadAdopt(); return ';附件已收进「询价附件」'; }
|
||||
if(r&&r.ok){ loadAdopt(); return ';附件已收进「工料机附件」'; }
|
||||
}catch(e){}
|
||||
return '';
|
||||
}
|
||||
@@ -2838,6 +2917,15 @@ function buildKinds(list){
|
||||
).join('')||'<span class="tip">(无)</span>';
|
||||
updKindBtn();
|
||||
}
|
||||
/* 决策 245(2026-11-01):打开项目弹框「单价类型 *」下拉——与后台同源枚举、默认「预算综合单价」 */
|
||||
function buildOpenKinds(list){
|
||||
const L=(list&&list.length)?list:[{code:1,name:'预算综合单价'},{code:2,name:'投标综合单价'},
|
||||
{code:3,name:'预算全费用'},{code:4,name:'投标全费用'}];
|
||||
const el=$('okind'); if(!el) return;
|
||||
const cur=el.value;
|
||||
el.innerHTML=L.map(k=>`<option value="${k.code}">${esc(k.name)}</option>`).join('');
|
||||
el.value=(cur&&[...el.options].some(o=>o.value===cur))?cur:'1';
|
||||
}
|
||||
function onKind(){
|
||||
FLT.kinds=selVals('fkind').map(Number); updKindBtn(); fltMark();
|
||||
if(!kwActive()) search(); // 无关键字=比对方式:条件即改即查;有关键字只记录,等「查询」
|
||||
@@ -3218,6 +3306,7 @@ async function initFilters(){
|
||||
void fill; // fill 仍可能被下面其它下拉用到,保留
|
||||
// 单价类型:只取 4 个正式枚举值(排除 0 未标注)
|
||||
buildKinds((f.file_kind||[]).filter(k=>Number(k.code)!==0));
|
||||
buildOpenKinds((f.file_kind||[]).filter(k=>Number(k.code)!==0)); // 决策 245:打开项目弹框同源
|
||||
// 地区树:省 → 市 → 区/县/镇,根「全国」
|
||||
ATREE=f.area_tree||{name:'全国',key:'',children:[]};
|
||||
$('areapop').innerHTML=trowHTML(ATREE,0);
|
||||
@@ -3283,7 +3372,7 @@ async function initFromUrl(){
|
||||
}catch(e){}
|
||||
// 决策 94 / 2026-10-19:源文件缺失与手工工程分开提示
|
||||
if(RECMAP[sid] && RECMAP[sid].manual){
|
||||
dlMsg('手工工程:没有源文件,原格式导出/重新解析不可用;要补传请用「打开项目」选择同名源文件', 'warn');
|
||||
dlMsg('手工工程:没有源文件,原格式导出/重新解析不可用;要上源文件数据请先删除本工程,再按源文件重新导入(同名会被拒)', 'warn');
|
||||
}else if(RECMAP[sid] && RECMAP[sid].can_reparse === false){
|
||||
dlMsg('该工程源文件已缺失:数据仍可查看,但无法导出、无法重新解析', 'warn');
|
||||
}
|
||||
@@ -3587,6 +3676,7 @@ function impExcelToggle(){
|
||||
}
|
||||
impSelSet('oprov',d.province); impSelSet('ocity',d.city); impSelSet('odist',d.district);
|
||||
$('obuid').value=d.bulid_unit||'';
|
||||
if(d.file_kind) $('okind').value=String(d.file_kind); // 决策 245:单价类型回填
|
||||
$('otitle').textContent='打开项目 · 导入Excel · 编辑目录树';
|
||||
$('obtnGo').textContent='保存(更新目录树)';
|
||||
impTreeRender();
|
||||
@@ -3613,7 +3703,12 @@ function impExportUw(si,ui){ // 决策 233 方案a:单单位工
|
||||
function impTreeRender(){
|
||||
const nm=$('oname').value.trim()||'(工程名称)';
|
||||
let h='<div class="ied"><span class="itag tg0">项目</span><span class="inm" onclick="$(\'oname\').focus()" style="cursor:pointer" title="点改名(左侧工程名称共用字段)">'+esc(nm)+'</span>'
|
||||
+'<span class="iact"><button class="iab" onclick="impAddSec()">+单项工程</button></span></div>';
|
||||
+'<span class="iact">'
|
||||
// 决策 242(2026-10-31 主人定):三钮从弹框底部移至此排并改名——单位模板/项目模板/项目导入
|
||||
+'<button class="iab" onclick="impTemplate()" title="下载单位工程数据结构 Excel(填写说明/分部分项/措施项目)">单位模板</button>'
|
||||
+'<button class="iab" onclick="impProjPick()" title="下载项目导入模板(项目目录+多对 Sheet,每对 Sheet=1 个单位工程,一把导入建项目)">项目模板</button>'
|
||||
+'<button class="iab" onclick="$(\'iprojfile\').click()" title="选项目模板 Excel:项目目录 Sheet 定目录树,分部分项N/措施项目N 对应序号 N 的单位工程,一把建项目">项目导入</button>'
|
||||
+'<button class="iab" onclick="impAddSec()">+单项工程</button></span></div>';
|
||||
ITREE.forEach((s,si)=>{
|
||||
h+='<div class="ied" style="padding-left:26px"><span class="itag tg1">单项工程</span><span class="inm" onclick="impRename(this,'+si+',-1)">'+esc(s.name)+'</span>'
|
||||
+'<span class="iact"><button class="iab" title="组内上移" onclick="impMovSec('+si+',-1)"'+(si===0?' disabled':'')+'>↑</button>'
|
||||
@@ -3668,7 +3763,7 @@ async function impFile(){
|
||||
}
|
||||
function impTemplate(){ return saveAs('/api/session/manual/template','单位工程导入模板.xlsx'); }
|
||||
/* 决策 238:整项目一把导入——项目目录 Sheet 定目录树,分部分项N/措施项目N=序号 N 的单位工程。
|
||||
工程名称/基准期次/地区/建设单位共用左侧字段;同名手工工程再次导入=整项目覆盖。 */
|
||||
工程名称/基准期次/地区/建设单位共用左侧字段;同名已存在于最近审核=拒绝(决策 242,整项目覆盖退役)。 */
|
||||
function impProjPick(){ return saveAs('/api/session/manual/project_template','整项目导入模板.xlsx'); }
|
||||
async function impProjFile(){
|
||||
const f=$('iprojfile').files[0]; $('iprojfile').value='';
|
||||
@@ -3676,12 +3771,15 @@ async function impProjFile(){
|
||||
const name=$('oname').value.trim(), pv=PVAL($('oper'));
|
||||
if(!name){ $('imsg').textContent='工程名称必填(左边共用字段)'; return; }
|
||||
if(pv.f==null||pv.t==null){ $('imsg').textContent='基准期次必填:点开选起~止(同月就选同一个)'; return; }
|
||||
if(!$('oprov').value||!$('ocity').value||!$('odist').value){ $('imsg').textContent='请填写:地区(省/市/区)'; return; }
|
||||
if(!$('obuid').value.trim()){ $('imsg').textContent='请填写:建设单位'; return; }
|
||||
if(!$('okind').value){ $('imsg').textContent='请选择单价类型'; return; }
|
||||
$('imsg').textContent='正在上传 '+f.name+'…';
|
||||
const up=await uploadFile('/api/admin/upload',f);
|
||||
if(!up.ok){ $('imsg').textContent=up.msg; return; }
|
||||
$('imsg').textContent='正在导入整项目…';
|
||||
const r=await J('/api/session/manual/import_project',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({name,period_from:pv.f,period_to:pv.t,path:up.path,
|
||||
body:JSON.stringify({name,period_from:pv.f,period_to:pv.t,path:up.path,file_kind:+$('okind').value,
|
||||
province:$('oprov').value,city:$('ocity').value,district:$('odist').value,bulid_unit:$('obuid').value})});
|
||||
if(!r.ok){ $('imsg').textContent=r.msg||'导入失败'; return; }
|
||||
location.href='/workbench.html?sid='+r.sid; // 导入完成直接进工程(与 impSave 同款跳转)
|
||||
@@ -3690,6 +3788,10 @@ async function impSave(){
|
||||
const name=$('oname').value.trim(), pv=PVAL($('oper'));
|
||||
if(!name){ $('imsg').textContent='工程名称必填(左边共用字段)'; return; }
|
||||
if(pv.f==null||pv.t==null){ $('imsg').textContent='基准期次必填:点开选起~止(同月就选同一个)'; return; }
|
||||
// 决策 245:地区/建设单位/单价类型必填(与后台同规则)
|
||||
if(!$('oprov').value||!$('ocity').value||!$('odist').value){ $('imsg').textContent='请填写:地区(省/市/区)'; return; }
|
||||
if(!$('obuid').value.trim()){ $('imsg').textContent='请填写:建设单位'; return; }
|
||||
if(!$('okind').value){ $('imsg').textContent='请选择单价类型'; return; }
|
||||
for(const s of ITREE){
|
||||
if(!s.name.trim()){ $('imsg').textContent='单项工程名称不能为空'; return; }
|
||||
if(!s.units.length){ $('imsg').textContent='「'+s.name+'」下至少一个单位工程'; return; }
|
||||
@@ -3700,6 +3802,7 @@ async function impSave(){
|
||||
const r=await J('/api/session/manual/save',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({sid:(SID&&MANUAL)?SID:0,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,
|
||||
tree:ITREE.map(s=>({id:s.id||0,name:s.name.trim(),
|
||||
units:s.units.map(u=>({id:u.id||0,name:u.name.trim(),file:u.file||''}))}))})});
|
||||
if(!r.ok){ $('imsg').textContent=r.msg||'保存失败'; return; }
|
||||
|
||||
Reference in New Issue
Block a user