feat(manual): 手工工程导入导出(决策229/230)与本页搜索共享层
This commit is contained in:
@@ -335,6 +335,12 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
<span class="tip" id="cnt"></span>
|
||||
<!-- 下载结果提示条(2026-10-06):替代 alert,保存成功/失败在这里说,3 秒后淡出 -->
|
||||
<span class="dlmsg" id="dlmsg"></span>
|
||||
<!-- 决策 229(2026-10-27 主人定):本页搜索(共享层)——当前页内黄底 + 上一个/下一个;
|
||||
#fq + 「查询」的服务端筛选原样保留,两不耽误 -->
|
||||
<input id="pgsrch_al" class="pgsrch" placeholder="搜索本页数据" title="搜索本页数据,命中黄底"
|
||||
oninput="pageSearchGo('alist', this.value)" onkeydown="if(event.key==='Enter')pageSearchNav('alist',1)">
|
||||
<button class="pgsnav" data-pg="alist" data-dir="-1" title="上一个命中" onclick="pageSearchNav('alist',-1)" disabled>上一个</button>
|
||||
<button class="pgsnav" data-pg="alist" data-dir="1" title="下一个命中(首击=从头查找)" onclick="pageSearchNav('alist',1)" disabled>下一个</button>
|
||||
<!-- 分页(2026-10-07 主人定):挪进查询栏同一行、放最右 -->
|
||||
<span class="tip" id="pg" style="margin-left:auto"></span>
|
||||
<button class="btn" onclick="go(-1)">上一页</button>
|
||||
@@ -356,8 +362,18 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
#dt 隐藏保留:价格目录树根名(pdFold 渲染)与导出文件名(pdExport)仍取它。 -->
|
||||
<div id="dpage">
|
||||
<b id="dt" style="display:none"></b>
|
||||
<!-- 4 个标签由 common.js 的 TABS 生成(与工作台同一份顺序/名称/默认页),禁止在此硬编码 -->
|
||||
<div class="tabs" id="dtabs"></div>
|
||||
<!-- 4 个标签由 common.js 的 TABS 生成(与工作台同一份顺序/名称/默认页),禁止在此硬编码。
|
||||
决策 229:页签行右挂本页搜索(共享层)——输入随页签路由 dPgKey():p3=原数据(drawbody)、
|
||||
p0/p1/p2 与价格明细=dtb;p3 时此框隐藏,原数据用自己的标签卡行框(rawTabs 同款) -->
|
||||
<div style="display:flex;align-items:stretch">
|
||||
<div class="tabs" id="dtabs" style="flex:1;min-width:0;border-bottom:none"></div>
|
||||
<span id="dpagwrap" style="display:inline-flex;gap:4px;align-items:center;padding:0 12px;flex:none;align-self:stretch;border-bottom:2px solid var(--c1)">
|
||||
<input id="pgsrch_ad" class="pgsrch" placeholder="搜索本页数据" title="搜索本页数据,命中黄底"
|
||||
oninput="pageSearchGo(dPgKey(), this.value)" onkeydown="if(event.key==='Enter')pageSearchNav(dPgKey(),1)">
|
||||
<button class="pgsnav" data-pg="adet" data-dyn="d" data-dir="-1" title="上一个命中" onclick="pageSearchNav(dPgKey(),-1)" disabled>上一个</button>
|
||||
<button class="pgsnav" data-pg="adet" data-dyn="d" data-dir="1" title="下一个命中(首击=从头查找)" onclick="pageSearchNav(dPgKey(),1)" disabled>下一个</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="db" id="dbody">
|
||||
<div id="dside" style="display:none"></div>
|
||||
<!-- 价格明细目录栏分隔条(2026-10-13 决策 49 主人定:换原数据左树同款把手及形式——
|
||||
@@ -412,7 +428,12 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
<span class="tip" id="qcov" style="white-space:nowrap;color:#1273a6;font-weight:700"></span>
|
||||
<span class="tip" id="qc" style="white-space:nowrap"></span>
|
||||
<span class="tip" id="qbmsg" style="flex:1;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap"></span>
|
||||
<input id="qkw" placeholder="搜索当前工作区" style="width:180px;margin-left:8px" oninput="qSearchSoon()">
|
||||
<!-- 决策 229(2026-10-27 主人定):改工作台同款本页搜索(共享层)——不筛行、命中黄底 + 上一个/下一个;
|
||||
输入随页签路由 qPgKey():工料机=qlme(qtb)、类似清单=qsim(qgt)。取代决策 154② 行级过滤 -->
|
||||
<input id="qkw" class="pgsrch" placeholder="搜索本页数据" title="搜索本页数据,命中黄底" style="margin-left:8px"
|
||||
oninput="pageSearchGo(qPgKey(), this.value)" onkeydown="if(event.key==='Enter')pageSearchNav(qPgKey(),1)">
|
||||
<button class="pgsnav" data-pg="qlme" data-dir="-1" title="上一个命中" onclick="pageSearchNav(qPgKey(),-1)" disabled>上一个</button>
|
||||
<button class="pgsnav" data-pg="qlme" data-dir="1" title="下一个命中(首击=从头查找)" onclick="pageSearchNav(qPgKey(),1)" disabled>下一个</button>
|
||||
<button class="btn pri" onclick="qfile.click()">上传附件</button>
|
||||
<button class="btn wb" onclick="qUnbind()">解绑选中</button>
|
||||
<button class="btn wb" onclick="qBind()">绑定选中</button>
|
||||
@@ -798,6 +819,8 @@ async function load(p){
|
||||
}).join('')+'</tr>';
|
||||
tb.tBodies[0].innerHTML=d.rows.map(r=>isP?rowPrice(r):rowProj(r)).join('')
|
||||
||`<tr><td colspan="${cols.length}" class="tip" style="text-align:center;padding:16px">没有数据</td></tr>`;
|
||||
// 决策 229:本页搜索——换页/重查后黄底重挂(只搜当前页),命中序号复位
|
||||
if (PAGESRCH.alist) { PGS_NAV.alist.i = -1; hlContainer($('tb'), PAGESRCH.alist); pgsSetNav('alist'); }
|
||||
const tw=document.querySelector('.tw');
|
||||
if(tw) tw.style.maxHeight=availHeight()+'px'; // 容器高与行数同源:不空白、不出竖向滚动条
|
||||
// 伸缩列定宽:用户拖过的比例记忆优先(2026-10-11 主人定),无记忆才按内容定宽(期次不再过宽、名称不再截断)
|
||||
@@ -1390,6 +1413,7 @@ window.addEventListener('resize', ()=>{ if(XACT>=0){ const t=XTABS[XACT];
|
||||
|
||||
async function loadTab(pid, fresh){
|
||||
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');
|
||||
if(KIND!=='project'){
|
||||
// 面板复位由 detLayout 统一负责(见其注释):价格明细 = 左目录树 + 右一张表
|
||||
@@ -1751,6 +1775,46 @@ mkPeriod($('eper')); // 编辑(只读,只用于显示)
|
||||
========================================================================= */
|
||||
let QBID=0, QFID=0, QLMES=[];
|
||||
let QTAB='lme', QBILLS=null; // 决策 152:右侧双页签(lme=项目工料机 / bill=类似清单,bills 懒加载)
|
||||
|
||||
/* ==================== 本页搜索共享层接入(决策 229,2026-10-27 主人定)====================
|
||||
工作台同款(输入即搜黄底 + 上一个/下一个 + 定位自动展开收起的 ± 把手)注册三处内容区:
|
||||
入库项目列表(#tb)、明细页(#dtb;p3 原数据路由 #drawbody,把手展开 pgRawExpand/pgGrpExpand)、
|
||||
附件页双页签(#qtb 工料机 / #qgt 类似清单)。#fq+「查询」服务端筛选原样保留;
|
||||
附件页取代决策 154② 行级过滤;历史对比框检索不动(主人定)。 */
|
||||
pgReg('alist', 'tb');
|
||||
pgReg('adet', 'dtb', pgGrpExpand);
|
||||
pgReg('raw', function(){ return document.getElementById('drawbody'); }, pgRawExpand);
|
||||
pgReg('qlme', 'qtb');
|
||||
pgReg('qsim', function(){ return document.getElementById('qgt'); }, pgGrpExpand);
|
||||
function dPgKey(){ // 明细页当前搜索键:p3 原数据=raw,其余页签与价格明细=adet
|
||||
const t = document.querySelector('#dtabs .tab.on');
|
||||
return (t && t.dataset.p === 'p3') ? 'raw' : 'adet';
|
||||
}
|
||||
function dPgSync(){ // 两枚跳转钮的 data-pg 跟随页签;p3 时隐藏此框(原数据用自己的标签卡行框)
|
||||
const k = dPgKey();
|
||||
document.querySelectorAll('button.pgsnav[data-dyn="d"]').forEach(b => { b.dataset.pg = k; });
|
||||
const w = document.getElementById('dpagwrap');
|
||||
if (w) w.style.display = (k === 'raw') ? 'none' : '';
|
||||
pgsSetNav(k);
|
||||
}
|
||||
function dPgReset(){ // 换明细页签/换批次:清两处关键词与黄底,搜索框复位(同工作台改词复位口径)
|
||||
['adet','raw'].forEach(k => {
|
||||
PAGESRCH[k] = ''; if (PGS_NAV[k]) PGS_NAV[k].i = -1;
|
||||
const a = pgArea(k); if (a) hlContainer(a, '');
|
||||
});
|
||||
const i = document.getElementById('pgsrch_ad'); if (i) i.value = '';
|
||||
dPgSync();
|
||||
}
|
||||
function qPgKey(){ return QTAB === 'lme' ? 'qlme' : 'qsim'; } // 附件页当前搜索键
|
||||
function qPgSync(){ // 切附件页签:两枚钮跟随、旧页签关键词与黄底清掉、框复位
|
||||
const k = qPgKey();
|
||||
document.querySelectorAll('#qpage button.pgsnav').forEach(b => { b.dataset.pg = k; });
|
||||
['qlme','qsim'].forEach(x => {
|
||||
if (x !== k) { PAGESRCH[x] = ''; if (PGS_NAV[x]) PGS_NAV[x].i = -1; const a = pgArea(x); if (a) hlContainer(a, ''); }
|
||||
});
|
||||
const i = $('qkw'); if (i) i.value = '';
|
||||
pgsSetNav(k);
|
||||
}
|
||||
const qPost=(u,b)=>J(u,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(b||{})});
|
||||
|
||||
/** 项目列表「询价附件」列:按你的选择显示个数;0 个时显示灰色「上传」 */
|
||||
@@ -1847,33 +1911,17 @@ async function qTab(t){
|
||||
document.querySelectorAll('.qtab').forEach(x=>x.classList.toggle('on',x.dataset.t===t));
|
||||
$('qlmew').style.display = t==='lme' ? '' : 'none';
|
||||
$('qbw').style.display = t==='bill' ? '' : 'none';
|
||||
$('qkw').value='';
|
||||
qPgSync(); // 决策 229:切页签=钮路由跟随 + 旧页签关键词/黄底清掉(同工作台改词复位口径)
|
||||
if(t==='lme') qRender(); else await qRenderBill();
|
||||
}
|
||||
|
||||
/* 决策 153⑦:搜索关键词黄色底显示(对转义后的文本逐词高亮) */
|
||||
function qhl(s){
|
||||
s = esc(s==null?'':String(s));
|
||||
const kw=($('qkw').value||'').trim();
|
||||
if(!kw) return s;
|
||||
return kw.split(/\s+/).filter(Boolean).reduce((acc,t)=>{
|
||||
try{ return acc.replace(new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,'\\$&'),'gi'),
|
||||
m=>'<mark class="qhl">'+m+'</mark>'); }
|
||||
catch(e){ return acc; }
|
||||
}, s);
|
||||
}
|
||||
|
||||
/* 决策 154①:搜索输入防抖(工料机上千行逐键重建表格导致删字卡顿) */
|
||||
let _qT=null;
|
||||
function qSearchSoon(){ clearTimeout(_qT); _qT=setTimeout(()=>{ QTAB==='lme'?qRender():qFilterBill(); },160); }
|
||||
|
||||
/* 工料机页签:列定义(复选框+编码固定,名称/规格伸缩)——决策 154③ 列宽拖动同工作台项目工料机 */
|
||||
const QCOLS_LME=[['',36,'c','F'],['编码',110,'c','F'],['名称',220,'l'],['规格型号',200,'l'],
|
||||
['单位',56,'c','F'],['除税价',100,'r','F'],['含税价',100,'r','F']]; // 决策 213 补记六:数量列隐藏(主人定,仅本页)
|
||||
function qRender(){
|
||||
const kw=($('qkw').value||'').trim().toLowerCase();
|
||||
let rows = kw ? QLMES.filter(r=>(r.name+' '+r.spec+' '+r.code).toLowerCase().includes(kw)) : QLMES.slice();
|
||||
// 决策 213 补记三:绑定筛选与类似清单同款(全部/只看未绑/只看已绑)
|
||||
// 决策 229:搜索不再筛行(原 kw 过滤与 qhl 逐格高亮退役,改共享层整区黄底 + 上一个/下一个);
|
||||
// 只留绑定筛选(决策 213 补记三)
|
||||
let rows = QLMES.slice();
|
||||
const flt=$('qflt') ? $('qflt').value : 'all';
|
||||
if(flt!=='all') rows = rows.filter(r=> flt==='bound' ? !!r.file_id : !r.file_id);
|
||||
$('qthl').innerHTML = '<tr>' + QCOLS_LME.map((c,i)=> i===0
|
||||
@@ -1881,16 +1929,18 @@ function qRender(){
|
||||
: '<th class="'+(c[2]||'c')+'" title="左右拖动调宽">'+esc(c[0])+'<span class="rs"></span></th>').join('') + '</tr>';
|
||||
$('qtbl').innerHTML = rows.length ? rows.map(r=>{
|
||||
const bd=!!r.file_id;
|
||||
const tag=bd?`<span class="qtag bnd" style="margin-left:6px">已绑:${qhl((r.file_name||'其他').slice(0,18))}</span>`:'';
|
||||
const tag=bd?`<span class="qtag bnd" style="margin-left:6px">已绑:${esc((r.file_name||'其他').slice(0,18))}</span>`:'';
|
||||
return `<tr class="${bd?'bound':''}"><td class="c"><input type="checkbox" data-id="${r.id}"></td>`
|
||||
+ `<td class="c">${qhl(r.code||'—')}</td>`
|
||||
+ `<td>${qhl(r.name)}${tag}</td><td>${qhl(r.spec||'—')}</td><td class="c">${esc(r.unit||'—')}</td>`
|
||||
+ `<td class="c">${esc(r.code||'—')}</td>`
|
||||
+ `<td>${esc(r.name)}${tag}</td><td>${esc(r.spec||'—')}</td><td class="c">${esc(r.unit||'—')}</td>`
|
||||
+ `<td style="text-align:right">${num(r.price)}</td><td style="text-align:right">${num(r.price_tax)}</td></tr>`;
|
||||
}).join('')
|
||||
: '<tr><td colspan="8" class="tip" style="text-align:center;padding:16px">没有工料机</td></tr>';
|
||||
$('qc').textContent = '共 ' + rows.length + ' 条' + (kw ? '(筛选自 ' + QLMES.length + ')' : '');
|
||||
$('qc').textContent = '共 ' + rows.length + ' 条';
|
||||
$('qcgl').innerHTML = colgHTML(QCOLS_LME);
|
||||
flexFit($('qtb'), QCOLS_LME); // 公共拖动器:固定+伸缩、拖动只动被拖列、窗口缩放自动重贴
|
||||
// 决策 229:重建后(绑定筛选/换页签)黄底重挂,命中序号复位
|
||||
if (PAGESRCH.qlme) { PGS_NAV.qlme.i = -1; hlContainer($('qtb'), PAGESRCH.qlme); pgsSetNav('qlme'); }
|
||||
}
|
||||
|
||||
/* 类似清单页签(决策 153③):与后台明细 p2 同一份共享代码 —— /similar 同源取数 +
|
||||
@@ -1926,6 +1976,8 @@ async function qRenderBill(){
|
||||
$('qcov').textContent = '已绑 ' + nb + ' / ' + QBILLS.length + '(' + (QBILLS.length ? Math.round(nb/QBILLS.length*100) : 0) + '%)';
|
||||
const visN = ((enr.groups||[]).reduce((s,g)=>s+(g.rows||[]).length,0)) + ((enr.extra||[]).reduce((s,g)=>s+(g.rows||[]).length,0));
|
||||
$('qc').textContent = '共 ' + visN + ' 条' + (flt!=='all' ? '(筛选自 ' + QBILLS.length + ')' : '');
|
||||
// 决策 229:重建后(绑定筛选/切回页签)黄底重挂,命中序号复位
|
||||
if (PAGESRCH.qsim) { PGS_NAV.qsim.i = -1; hlContainer($('qgt'), PAGESRCH.qsim); pgsSetNav('qsim'); }
|
||||
}
|
||||
/* 决策 154④:类似清单默认列宽——名称收窄(210→150)、项目特征加宽(260→330),复选框列固定 36;
|
||||
表格走 colg(colgHTML+sumw+colwApply)→ 公共拖动器,拖动效果与后台类似清单一致 */
|
||||
@@ -1936,13 +1988,7 @@ function qBindCols(){
|
||||
return c;
|
||||
})); // 决策 213 补记六:工程量/合价列隐藏(仅本页)
|
||||
}
|
||||
/* 决策 154②:类似清单搜索 = 行级过滤(组头保留),不重建共享组表 */
|
||||
function qFilterBill(){
|
||||
const kw=($('qkw').value||'').trim().toLowerCase();
|
||||
document.querySelectorAll('#qtbb tr[data-bid]').forEach(tr=>{
|
||||
tr.style.display = (!kw || tr.textContent.toLowerCase().includes(kw)) ? '' : 'none';
|
||||
});
|
||||
}
|
||||
/* (决策 154② 行级过滤 qFilterBill 已随决策 229 退役:搜索改工作台口径,不筛行只黄底+跳转) */
|
||||
|
||||
function qChecked(){ return QTAB==='lme'
|
||||
? [...$('qtbl').querySelectorAll('input[data-id]:checked')].map(x=>+x.dataset.id)
|
||||
|
||||
@@ -322,3 +322,11 @@ td.eh::after{content:'';position:absolute;right:0;bottom:0;width:0;height:0;
|
||||
.ehpop td{padding:3px 8px;border-bottom:1px solid #f1f5f9;vertical-align:top}
|
||||
.ehpop td.n{color:#8a97a8;width:26px;text-align:right}
|
||||
.ehpop td.at{color:#51606f;white-space:nowrap}
|
||||
|
||||
/* ==================== 本页搜索(决策 172/209;2026-10-27 决策 229 上移共享)====================
|
||||
前后台共用一套:工作台四页 + 后台(入库项目列表/明细页/附件页双页签)。样式随代码上移。 */
|
||||
mark.pghl{background:#ffe58a;color:inherit;padding:0}
|
||||
mark.pghlcur{background:#ff9c40;color:#fff;padding:0} /* 决策 209:当前命中橙底 */
|
||||
.pgsrch{width:200px;height:24px;box-sizing:border-box}
|
||||
.pgsnav{height:24px;padding:0 8px;font:inherit;font-size:12px;border:1px solid #b8c4d4;border-radius:5px;background:#fff;color:#24425f;cursor:pointer;box-sizing:border-box} /* 决策 209:跳转按钮 */
|
||||
.pgsnav:disabled{background:#f0f2f5;color:#a8b4c4;border-color:#d5dde8;cursor:default}
|
||||
|
||||
@@ -3391,3 +3391,136 @@ function wbApplyLang() {
|
||||
else appBoot();
|
||||
setTimeout(appBoot, 350); // 晚渲染的页签/表头补一次
|
||||
})();
|
||||
|
||||
/* ==================== 本页搜索共享层(决策 229,2026-10-27 主人定)====================
|
||||
决策 172/209 的「本页搜索」(输入即搜黄底 + 上一个/下一个 + 五态灰)从 workbench.html
|
||||
上移到这里:工作台四页 + 后台三处(入库项目列表 / 明细页 / 附件页双页签)共用一套。
|
||||
页面用 pgReg(key, area, expander) 注册内容区:area = 元素 id 或 ()=>Element(后台明细
|
||||
随页签切换);expander(mark) 可选——定位时命中行被 ± 把手收起(display:none 藏着)
|
||||
先展开再滚动居中(决策 229 主人报「搜索内容是把手收起状态,定位应展开并显示」)。
|
||||
收起 = 从 DOM 移除的内容(定额子行 tgNorm、组表懒渲染未展开过的组)不在搜索范围
|
||||
(主人 2026-10-27 定「定额不在搜索范围」,组懒渲染同口径);历史对比框检索不迁移、
|
||||
行为不变(主人 2026-10-27 定),只继续复用 hlContainer。 */
|
||||
const PG_AREAS = {}; // key -> 元素 id 或 ()=>Element
|
||||
const PG_EXPAND = {}; // key -> expander(mark)
|
||||
const PAGESRCH = {}; // key -> 当前关键词
|
||||
const PG_TIMER = {}; // key -> 300ms 防抖句柄
|
||||
const PGS_NAV = {}; // key -> { i: 当前命中序号(-1=未定位) }
|
||||
function pgReg(key, area, expander) {
|
||||
PG_AREAS[key] = area;
|
||||
if (expander) PG_EXPAND[key] = expander;
|
||||
PAGESRCH[key] = '';
|
||||
PGS_NAV[key] = { i: -1 };
|
||||
}
|
||||
function pgArea(key) {
|
||||
const a = PG_AREAS[key];
|
||||
return (typeof a === 'function') ? a() : document.getElementById(a);
|
||||
}
|
||||
/* 决策 229:原数据 ± 把手展开器(工作台原数据 / 后台明细 p3 共用)——命中行的 data-vis
|
||||
祖先链上有收起的 根/分部/清单 → 逐个展开再整表重算可见性。只改 display 不重建 DOM,
|
||||
pageSearchNav 里的 marks 引用保持有效。 */
|
||||
function pgRawExpand(mark) {
|
||||
const tr = mark.closest && mark.closest('tr[data-vis]');
|
||||
if (!tr || tr.style.display !== 'none') return;
|
||||
let changed = false;
|
||||
(tr.dataset.vis || '').split('/').forEach(k => {
|
||||
if (k === 'uw') { if (!RV_TREE.root) { RV_TREE.root = true; changed = true; } }
|
||||
else if (k && k !== 'loose') {
|
||||
if (k.charAt(0) === 'd' && RV_TREE.divs[k] === false) { RV_TREE.divs[k] = true; changed = true; }
|
||||
if (k.charAt(0) === 'b' && RV_TREE.bills[k] === false) { RV_TREE.bills[k] = true; changed = true; }
|
||||
}
|
||||
});
|
||||
if (changed) { rawTreeSync(null); _rvStateSave(); }
|
||||
}
|
||||
/* 决策 229:组表 ± 把手展开器(工作台 t1/t2、后台明细 p1/p2、附件 qsim 共用)——
|
||||
渲染过再收起的组行是 display:none 藏着的,定位前把所在组点开(懒渲染组不在搜索范围)。 */
|
||||
function pgGrpExpand(mark) {
|
||||
const tr = mark.closest && mark.closest('tr[data-grp]');
|
||||
if (!tr || tr.style.display !== 'none') return;
|
||||
const tg = document.getElementById('gt_' + tr.dataset.grp);
|
||||
if (tg && tg.dataset.open !== '1') tgGrp(tr.dataset.grp, tg.closest('tr'));
|
||||
}
|
||||
/* 决策 209:搜索框右边「上一个/下一个」两枚的 HTML(初始灰,由 pgsSetNav 刷新) */
|
||||
function pgsNavBtnsHtml(key) {
|
||||
return '<button class="pgsnav" data-pg="' + key + '" data-dir="-1" title="上一个命中"'
|
||||
+ ' onclick="pageSearchNav(\'' + key + '\',-1)" disabled>上一个</button>'
|
||||
+ '<button class="pgsnav" data-pg="' + key + '" data-dir="1" title="下一个命中(首击=从头查找)"'
|
||||
+ ' onclick="pageSearchNav(\'' + key + '\',1)" disabled>下一个</button>';
|
||||
}
|
||||
/* 决策 209:五态灰活唯一入口(框空/无命中/唯一已定位/第1处/末尾) */
|
||||
function pgsSetNav(key) {
|
||||
const el = pgArea(key);
|
||||
const n = el ? el.querySelectorAll('mark.pghl').length : 0;
|
||||
const i = PGS_NAV[key] ? PGS_NAV[key].i : -1;
|
||||
document.querySelectorAll('button.pgsnav[data-pg="' + key + '"]').forEach(b => {
|
||||
const d = Number(b.dataset.dir);
|
||||
b.disabled = !PAGESRCH[key] ? true
|
||||
: d < 0 ? (i <= 0)
|
||||
: (i < 0 ? n < 1 : i >= n - 1);
|
||||
});
|
||||
}
|
||||
/* 决策 209:命中间跳转;缺高亮(重画后)先补挂再跳;决策 229:命中被把手收起先展开再滚 */
|
||||
function pageSearchNav(key, dir) {
|
||||
const kw = PAGESRCH[key];
|
||||
if (!kw) return;
|
||||
const el = pgArea(key);
|
||||
if (!el) return;
|
||||
let marks = el.querySelectorAll('mark.pghl');
|
||||
if (!marks.length) { if (PGS_NAV[key]) PGS_NAV[key].i = -1; hlContainer(el, kw); marks = el.querySelectorAll('mark.pghl'); }
|
||||
const n = marks.length;
|
||||
if (!n) { pgsSetNav(key); return; }
|
||||
let i = PGS_NAV[key] ? PGS_NAV[key].i : -1;
|
||||
if (dir > 0) { if (i >= n - 1) return; i = i < 0 ? 0 : i + 1; }
|
||||
else { if (i <= 0) return; i -= 1; }
|
||||
if (PGS_NAV[key]) PGS_NAV[key].i = i;
|
||||
marks.forEach(m => m.classList.remove('pghlcur'));
|
||||
marks[i].classList.add('pghlcur');
|
||||
if (PG_EXPAND[key]) PG_EXPAND[key](marks[i]); // 决策 229:先展开收起的把手(只改 display,marks 仍有效)
|
||||
marks[i].scrollIntoView({ block: 'center' });
|
||||
pgsSetNav(key);
|
||||
}
|
||||
window.pageSearchBox = function(){ // 原数据标签卡行用(rawTabs 渲染;工作台原数据 + 后台明细 p3 同款)
|
||||
return '<input class="mi pgsrch" placeholder="搜索本页数据"'
|
||||
+ ' title="搜索本页数据,命中黄底(目录树不参与)" value="' + esc(PAGESRCH.raw || '') + '"'
|
||||
+ ' oninput="pageSearchGo(\'raw\', this.value)"'
|
||||
+ ' onkeydown="if(event.key===\'Enter\')pageSearchNav(\'raw\',1)">'
|
||||
+ pgsNavBtnsHtml('raw');
|
||||
};
|
||||
function hlContainer(root, kw){
|
||||
root.querySelectorAll('mark.pghl').forEach(m => { m.replaceWith(document.createTextNode(m.textContent)); });
|
||||
root.normalize();
|
||||
if (!kw) return 0;
|
||||
const kwU = kw.toUpperCase();
|
||||
const bad = { SCRIPT:1, STYLE:1, MARK:1, INPUT:1, TEXTAREA:1, SELECT:1 };
|
||||
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
|
||||
acceptNode: nd => {
|
||||
if (!nd.nodeValue || !nd.nodeValue.trim()) return NodeFilter.FILTER_REJECT;
|
||||
if (bad[nd.parentNode.nodeName]) return NodeFilter.FILTER_REJECT;
|
||||
return nd.nodeValue.toUpperCase().indexOf(kwU) >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
|
||||
}});
|
||||
const hits = []; let nd;
|
||||
while ((nd = walker.nextNode())) hits.push(nd);
|
||||
hits.forEach(node => {
|
||||
const s = node.nodeValue, up = s.toUpperCase();
|
||||
const frag = document.createDocumentFragment();
|
||||
let i = 0, j;
|
||||
while ((j = up.indexOf(kwU, i)) >= 0) {
|
||||
if (j > i) frag.appendChild(document.createTextNode(s.slice(i, j)));
|
||||
const m = document.createElement('mark'); m.className = 'pghl'; m.textContent = s.slice(j, j + kw.length);
|
||||
frag.appendChild(m); i = j + kw.length;
|
||||
}
|
||||
if (i < s.length) frag.appendChild(document.createTextNode(s.slice(i)));
|
||||
node.replaceWith(frag);
|
||||
});
|
||||
return hits.length;
|
||||
}
|
||||
function pageSearchGo(key, val){
|
||||
PAGESRCH[key] = val || '';
|
||||
clearTimeout(PG_TIMER[key]);
|
||||
PG_TIMER[key] = setTimeout(() => {
|
||||
const el = pgArea(key);
|
||||
if (el) hlContainer(el, PAGESRCH[key]);
|
||||
if (PGS_NAV[key]) PGS_NAV[key].i = -1; // 决策 209:改词=回未查找态,首击「下一个」重新从头定位
|
||||
pgsSetNav(key);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,21 @@ body{margin:0;font:13px/1.5 "Source Han Sans SC","Noto Sans SC","Source Han Sans
|
||||
.panel.on{display:block}
|
||||
/* 原数据标签:左侧目录树 + 右侧标签卡,各自独立滚动 */
|
||||
#pan3{overflow:hidden}
|
||||
#pan3 .rawbox{position:relative}
|
||||
/* 导入项目弹框(决策 230,2026-10-27):同框建目录树 + 单位工程行旁导 Excel */
|
||||
#itree .ied{display:flex;align-items:center;gap:6px;padding:4px 8px;border-radius:4px}
|
||||
#itree .ied:hover{background:#f0f4fa}
|
||||
#itree .itag{flex:none;font-size:11px;border-radius:3px;padding:1px 6px}
|
||||
#itree .tg0{background:#e8edf5;color:#41506e}#itree .tg1{background:#e3ecfa;color:#1c4f9c}#itree .tg2{background:#dcf0e2;color:#17663a}
|
||||
#itree .inm{overflow:hidden;text-overflow:ellipsis;cursor:text;white-space:nowrap}
|
||||
#itree .iact{margin-left:auto;display:flex;gap:4px;align-items:center;flex:none}
|
||||
#itree .iab{font-size:11px;border:1px solid #c3cad6;background:#fff;border-radius:3px;padding:1px 6px;cursor:pointer;color:#41506e}
|
||||
#itree .iab:disabled{opacity:.35;cursor:default}
|
||||
#itree .iab.x{color:#b03a2e;border-color:#e3b6b0}
|
||||
#itree .iab.imp{color:#1c66d6;border-color:#9db9e8}
|
||||
#itree .iok{font-size:11px;color:#1f8f4d;white-space:nowrap;flex:none}
|
||||
#itree .ierr{font-size:11px;color:#b03a2e;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:none}
|
||||
#itree .ied input{border:1px solid #9db9e8;border-radius:3px;padding:2px 6px;font-size:13px;min-width:140px;flex:1}
|
||||
table{width:100%;border-collapse:collapse;font-size:12.5px;table-layout:fixed}
|
||||
th{position:sticky;top:0;background:var(--head);color:var(--c1);font-weight:600;padding:6px 8px;border-bottom:1px solid var(--line);border-right:1px solid #eef1f6;white-space:nowrap;z-index:2}
|
||||
/* 规格 2026-10-17 ⑪:组表下拉时 ⟳ 工具行(sticky top:0)与表头都固定 */
|
||||
@@ -72,12 +87,6 @@ tr.sel td, tr.subsel td{background:#d8e9fc} /* 选中行=淡蓝(规格 2026-
|
||||
/* 拖动中:整页光标强制为 ns-resize(鼠标跑到哪儿都不丢拖动光标),并禁止选中文字 */
|
||||
body.histdrag, body.histdrag *{cursor:ns-resize !important}
|
||||
body.histdrag{user-select:none}
|
||||
/* ---- 本页搜索(决策 172,2026-10-22 主人定):命中关键字黄底 ---- */
|
||||
mark.pghl{background:#ffe58a;color:inherit;padding:0}
|
||||
mark.pghlcur{background:#ff9c40;color:#fff;padding:0} /* 决策 209:当前命中橙底 */
|
||||
.pgsrch{width:200px;height:24px;box-sizing:border-box}
|
||||
.pgsnav{height:24px;padding:0 8px;font:inherit;font-size:12px;border:1px solid #b8c4d4;border-radius:5px;background:#fff;color:#24425f;cursor:pointer;box-sizing:border-box} /* 决策 209:跳转按钮 */
|
||||
.pgsnav:disabled{background:#f0f2f5;color:#a8b4c4;border-color:#d5dde8;cursor:default}
|
||||
/* ---- 组价不一致/类似清单:左组目录树 + 分隔条(2026-10-08 主人定,样式/行为同原数据左树)---- */
|
||||
/* 决策 224(2026-10-27 主人定):#pan1 与 #pan2 同款 flex——.grpbox 拉伸满高:左树区
|
||||
不管有没有数据都分割出来、分隔条通高、收展把手恒在正中(同原数据)。
|
||||
@@ -342,6 +351,7 @@ mark.pghlcur{background:#ff9c40;color:#fff;padding:0} /* 决策 209:当前
|
||||
<div class="panel on" id="pan3">
|
||||
<div class="rawbox">
|
||||
<div class="rawtree" id="rawtree"></div>
|
||||
<div id="impWrap" style="position:absolute;top:6px;right:10px;z-index:6"></div>
|
||||
<div class="rawmain">
|
||||
<div class="stabs" id="rawstabs"></div>
|
||||
<div class="rawbody" id="rawbody"></div>
|
||||
@@ -540,11 +550,34 @@ mark.pghlcur{background:#ff9c40;color:#fff;padding:0} /* 决策 209:当前
|
||||
</div>
|
||||
<div class="mfoot" data-page-node-id="cIfN6fkvNTvkVdk85JJyPJ">
|
||||
<button class="btn" onclick="omask.classList.remove('on')" data-page-node-id="IAVuhdrc4Ln1HQDrn0cvBd">取消</button>
|
||||
<button class="btn pri" onclick="doOpen()" data-page-node-id="TE1Xb1738DYzBDAEAAT9o2">打开</button>
|
||||
<button class="btn pri" onclick="doOpen()" data-page-node-id="TE1Xb1738DYzPd3zBDAEAAT9o2">打开</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 导入项目(决策 230,2026-10-27 主人定):手工工程——同框建目录树(项目→单项工程→单位工程,
|
||||
点名改名、行尾 +/✕ 增删)+ 每个单位工程行旁「导入单位工程」选 Excel(两个 Sheet 落对应页签) -->
|
||||
<div class="mask" id="imask">
|
||||
<div class="dlg" style="width:680px;max-width:94vw">
|
||||
<h4 id="ititle">导入项目</h4>
|
||||
<div class="mbody">
|
||||
<div class="row"><span>工程名称 *</span><input id="iname" placeholder="如:某某住宅小区施工总承包"></div>
|
||||
<div class="row"><span>基准期次 *</span><input id="iper" placeholder="点这里选起~止(同月就选同一个)"></div>
|
||||
<div class="row" style="align-items:flex-start"><span style="padding-top:6px;flex:none">目录树 *</span>
|
||||
<div id="itree" style="flex:1;min-height:200px;max-height:46vh;overflow:auto;border:1px solid #e3eaf2;border-radius:6px;padding:6px 4px;background:#fbfcfe"></div>
|
||||
</div>
|
||||
<div class="tip" id="imsg"></div>
|
||||
</div>
|
||||
<div class="mfoot">
|
||||
<button class="btn" onclick="impTemplate()">模板</button>
|
||||
<span style="flex:1;font-size:12px;color:#8a97a8">模板=单位工程数据结构 Excel(Sheet:填写说明/分部分项/措施项目)</span>
|
||||
<button class="btn" onclick="imask.classList.remove('on')">取消</button>
|
||||
<button class="btn pri" id="ibtnSave" onclick="impSave()">保存并创建工程</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="file" id="ifile" accept=".xlsx" style="display:none" onchange="impFile()">
|
||||
|
||||
<!-- 导出进度模态(决策 92,主人定流程):先另存为选路径 → 这里显示进度(生成逐条目% + 写盘%),
|
||||
期间模态阻塞不可做其他操作;唯一出口=「后台导出」→ 收起模态回软件继续干活,后台完成后右下角提醒。 -->
|
||||
<div class="mask" id="expmask">
|
||||
@@ -564,6 +597,23 @@ mark.pghlcur{background:#ff9c40;color:#fff;padding:0} /* 决策 209:当前
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 手工工程导出格式三选(决策 229,2026-10-27 主人定):cos/cos4 走经典整件骨架,
|
||||
Excel=每单位工程一个 xlsx(项目名文件夹打包 zip)。选完走决策 92 同款另存为+进度流程。 -->
|
||||
<div class="mask" id="fmtmask">
|
||||
<div class="dlg" style="width:420px;max-width:92vw">
|
||||
<h4>手工工程导出</h4>
|
||||
<div class="mbody" style="display:flex;flex-direction:column;gap:8px">
|
||||
<button class="btn pri" onclick="exportSession('cos4')">.cos4 经典骨架(易达新版格式)</button>
|
||||
<button class="btn" onclick="exportSession('cos')">.cos 经典骨架(易达老版格式)</button>
|
||||
<button class="btn" onclick="exportSession('xlsx')">Excel 每单位工程一个 xlsx(zip 包)</button>
|
||||
<div style="color:#8a97a8;font-size:12px">cos/cos4=经典项目整件骨架当模板,我方只落分部分项/措施价格信息;该后缀还没收过骨架时请先在后台或工作台导入一份原件。</div>
|
||||
</div>
|
||||
<div class="mfoot" style="text-align:right">
|
||||
<button class="btn" onclick="document.getElementById('fmtmask').classList.remove('on')">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================= 询价附件(2026-10-09 改版)==================
|
||||
数据 = 对比框里**工料机行**点「采纳」时该行跟随的附件(工程行=绑定的询价资料,
|
||||
价格行=刊物原件),全局收集、按内容去重。不是后台绑定关系的只读展示。
|
||||
@@ -919,16 +969,21 @@ window.__exportProgress = function(p){
|
||||
dlMsg('导出失败:' + (p.msg || ''), 'err');
|
||||
}
|
||||
};
|
||||
async function exportSession(){
|
||||
async function exportSession(fmt){
|
||||
if(!SID){ $('msg').textContent = '先打开工程再导出'; return; }
|
||||
if(MANUAL){ $('msg').textContent = '手工工程没有源文件,不能按原格式导出;请用「打开项目」选择同名源文件补传'; return; }
|
||||
/* 决策 229:手工工程三选(cos4/cos/xlsx);未选格式先弹选择框。普通工程忽略 fmt。 */
|
||||
fmt=(fmt||'').toLowerCase();
|
||||
if(MANUAL && ['cos4','cos','xlsx'].indexOf(fmt)<0){
|
||||
document.getElementById('fmtmask').classList.add('on'); return;
|
||||
}
|
||||
document.getElementById('fmtmask').classList.remove('on');
|
||||
if ($('expmask').classList.contains('on')){ $('msg').textContent = '已有导出进行中(可点「后台导出」转后台)'; return; }
|
||||
$('msg').textContent = '正在按原格式导出(大工程稍等)…';
|
||||
$('msg').textContent = MANUAL ? '正在按经典骨架导出(稍等)…' : '正在按原格式导出(大工程稍等)…';
|
||||
try{
|
||||
const hasBridge = window.pywebview && window.pywebview.api;
|
||||
// ① 新壳(决策 92):先另存为选路径 → 页面进度模态 → 后台生成写盘 → __exportProgress 收尾
|
||||
if (hasBridge && typeof window.pywebview.api.export_save_as === 'function'){
|
||||
const r = await window.pywebview.api.export_save_as(SID, '');
|
||||
const r = await window.pywebview.api.export_save_as(SID, '', fmt);
|
||||
if (r && r.cancel){ $('msg').textContent = '已取消导出'; return; }
|
||||
if (r && r.msg){ $('msg').textContent = '导出失败:' + r.msg; return; }
|
||||
if (r && r.started){ exportModalShow(r.name); return; }
|
||||
@@ -936,12 +991,12 @@ async function exportSession(){
|
||||
}
|
||||
// ② 老壳(只有决策 91 的通用下载桥):生成完才弹框,凑合用
|
||||
if (hasBridge && typeof window.pywebview.api.download_save_as === 'function'){
|
||||
const r = await window.pywebview.api.download_save_as('/api/session/export?session_id=' + SID, '');
|
||||
const r = await window.pywebview.api.download_save_as('/api/session/export?session_id=' + SID + (fmt?('&fmt='+encodeURIComponent(fmt)):''), '');
|
||||
if (r && r.ok){ $('msg').textContent = '已导出:' + (r.name || ''); dlMsg('已另存为:' + r.path, 'ok'); return; }
|
||||
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);
|
||||
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''真名(原工程名-审核版.原后缀)。
|
||||
@@ -1134,102 +1189,14 @@ async function refreshRaw(quiet){
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================== 本页搜索(决策 172,2026-10-22 主人定)====================
|
||||
四个工作台页面各一个约 200px 搜索框(原数据=标签卡行·全层级、类似清单/组价=重载行、
|
||||
项目工料机=顶部行),输入即搜(300ms 防抖、不分大小写、包含匹配),本页主数据表
|
||||
命中文字黄底(mark.pghl);目录树不参与;清空恢复。
|
||||
原数据页关键字跨层级/标签保留,重画后自动重新高亮(rawDraw 包一层);
|
||||
其余三页重画后高亮消失、重输即可(第一版口径)。
|
||||
决策 209(2026-10-26 主人定):框右加「上一个/下一个」两枚跳转钮(灰=不可跳:
|
||||
框空/无命中/唯一命中已定位/在第1处无上/在末尾无下),首击「下一个」=从头查找,
|
||||
当前命中橙底(mark.pghlcur)并滚动到可视区,回车=点「下一个」,改词复位,到底不循环。 */
|
||||
let PAGESRCH = { raw: '', incon: '', sim: '', wb: '' };
|
||||
const PG_AREAS = { raw: 'rawbody', incon: 't1', sim: 't2', wb: 't0' };
|
||||
const PG_TIMER = {};
|
||||
const PGS_NAV = { raw: { i: -1 }, incon: { i: -1 }, sim: { i: -1 }, wb: { i: -1 } }; // 决策 209:各页当前命中序号(-1=未定位)
|
||||
// 决策 209:搜索框右边「上一个/下一个」两枚的 HTML(初始灰)
|
||||
function pgsNavBtnsHtml(key){ // 决策 209:搜索框右边的「上一个/下一个」两枚(初始灰,由 pgsSetNav 刷新)
|
||||
return '<button class="pgsnav" data-pg="' + key + '" data-dir="-1" title="上一个命中"'
|
||||
+ ' onclick="pageSearchNav(\'' + key + '\',-1)" disabled>上一个</button>'
|
||||
+ '<button class="pgsnav" data-pg="' + key + '" data-dir="1" title="下一个命中(首击=从头查找)"'
|
||||
+ ' onclick="pageSearchNav(\'' + key + '\',1)" disabled>下一个</button>';
|
||||
}
|
||||
// 决策 209:五态灰活唯一入口(框空/无命中/唯一已定位/第1处/末尾)
|
||||
function pgsSetNav(key){ // 决策 209:按 框空/无命中/当前位置 刷两枚钮的灰活
|
||||
const el = document.getElementById(PG_AREAS[key]);
|
||||
const n = el ? el.querySelectorAll('mark.pghl').length : 0;
|
||||
const i = PGS_NAV[key].i;
|
||||
document.querySelectorAll('button.pgsnav[data-pg="' + key + '"]').forEach(b => {
|
||||
const d = Number(b.dataset.dir);
|
||||
b.disabled = !PAGESRCH[key] ? true
|
||||
: d < 0 ? (i <= 0)
|
||||
: (i < 0 ? n < 1 : i >= n - 1);
|
||||
});
|
||||
}
|
||||
// 决策 209:命中间跳转;缺高亮(非 raw 三页重画后)先补挂再跳
|
||||
function pageSearchNav(key, dir){ // 决策 209:命中间跳转;重画丢高亮先补黄底再跳
|
||||
const kw = PAGESRCH[key];
|
||||
if (!kw) return;
|
||||
const el = document.getElementById(PG_AREAS[key]);
|
||||
if (!el) return;
|
||||
let marks = el.querySelectorAll('mark.pghl');
|
||||
if (!marks.length) { PGS_NAV[key].i = -1; hlContainer(el, kw); marks = el.querySelectorAll('mark.pghl'); }
|
||||
const n = marks.length;
|
||||
if (!n) { pgsSetNav(key); return; }
|
||||
let i = PGS_NAV[key].i;
|
||||
if (dir > 0) { if (i >= n - 1) return; i = i < 0 ? 0 : i + 1; }
|
||||
else { if (i <= 0) return; i -= 1; }
|
||||
PGS_NAV[key].i = i;
|
||||
marks.forEach(m => m.classList.remove('pghlcur'));
|
||||
marks[i].classList.add('pghlcur');
|
||||
marks[i].scrollIntoView({ block: 'center' });
|
||||
pgsSetNav(key);
|
||||
}
|
||||
window.pageSearchBox = function(){ // 原数据标签卡行用(common.js rawTabs 渲染,工作台专用)
|
||||
return '<input class="mi pgsrch" placeholder="搜索本页数据"'
|
||||
+ ' title="搜索本页数据,命中黄底(目录树不参与)" value="' + esc(PAGESRCH.raw || '') + '"'
|
||||
+ ' oninput="pageSearchGo(\'raw\', this.value)"'
|
||||
+ ' onkeydown="if(event.key===\'Enter\')pageSearchNav(\'raw\',1)">'
|
||||
+ pgsNavBtnsHtml('raw');
|
||||
};
|
||||
function hlContainer(root, kw){
|
||||
root.querySelectorAll('mark.pghl').forEach(m => { m.replaceWith(document.createTextNode(m.textContent)); });
|
||||
root.normalize();
|
||||
if (!kw) return 0;
|
||||
const kwU = kw.toUpperCase();
|
||||
const bad = { SCRIPT:1, STYLE:1, MARK:1, INPUT:1, TEXTAREA:1, SELECT:1 };
|
||||
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
|
||||
acceptNode: nd => {
|
||||
if (!nd.nodeValue || !nd.nodeValue.trim()) return NodeFilter.FILTER_REJECT;
|
||||
if (bad[nd.parentNode.nodeName]) return NodeFilter.FILTER_REJECT;
|
||||
return nd.nodeValue.toUpperCase().indexOf(kwU) >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
|
||||
}});
|
||||
const hits = []; let nd;
|
||||
while ((nd = walker.nextNode())) hits.push(nd);
|
||||
hits.forEach(node => {
|
||||
const s = node.nodeValue, up = s.toUpperCase();
|
||||
const frag = document.createDocumentFragment();
|
||||
let i = 0, j;
|
||||
while ((j = up.indexOf(kwU, i)) >= 0) {
|
||||
if (j > i) frag.appendChild(document.createTextNode(s.slice(i, j)));
|
||||
const m = document.createElement('mark'); m.className = 'pghl'; m.textContent = s.slice(j, j + kw.length);
|
||||
frag.appendChild(m); i = j + kw.length;
|
||||
}
|
||||
if (i < s.length) frag.appendChild(document.createTextNode(s.slice(i)));
|
||||
node.replaceWith(frag);
|
||||
});
|
||||
return hits.length;
|
||||
}
|
||||
function pageSearchGo(key, val){
|
||||
PAGESRCH[key] = val || '';
|
||||
clearTimeout(PG_TIMER[key]);
|
||||
PG_TIMER[key] = setTimeout(() => {
|
||||
const el = document.getElementById(PG_AREAS[key]);
|
||||
if (el) hlContainer(el, PAGESRCH[key]);
|
||||
PGS_NAV[key].i = -1; // 决策 209:改词=回未查找态,首击「下一个」重新从头定位
|
||||
pgsSetNav(key);
|
||||
}, 300);
|
||||
}
|
||||
/* ==================== 本页搜索(决策 172/209;2026-10-27 决策 229 上移共享层)====================
|
||||
输入即搜黄底、上一个/下一个、五态灰、定位前自动展开收起的 ± 把手——核心全在 common.js
|
||||
(工作台四页 + 后台入库项目列表/明细/附件 共用一套)。本页只注册四个页签的内容区;
|
||||
原数据页重画后自动重新高亮 + 搜索框 × 重挂见下方 rawDraw 包一层(工作台专用)。 */
|
||||
pgReg('raw', 'rawbody', pgRawExpand); // 决策 229:命中在收起的分部/清单里 → 定位时自动展开再滚
|
||||
pgReg('incon', 't1', pgGrpExpand); // 决策 229:组表把手同款(渲染过再收起的组行定位时自动点开)
|
||||
pgReg('sim', 't2', pgGrpExpand);
|
||||
pgReg('wb', 't0');
|
||||
(function(){ // 原数据页重画后自动重新高亮 + 搜索框 × 重挂(切层级/标签/排序都走 rawDraw)
|
||||
const _rd = rawDraw;
|
||||
rawDraw = async function(){
|
||||
@@ -1806,9 +1773,10 @@ function setManualMode(manual){
|
||||
MANUAL=!!manual;
|
||||
const b=document.getElementById('btnExport');
|
||||
if(b){
|
||||
b.disabled=!!manual;
|
||||
/* 决策 229:手工工程放开导出——cos/cos4(经典骨架)与 Excel 三选,点导出先弹格式选择 */
|
||||
b.disabled=false;
|
||||
b.title=manual
|
||||
? '手工工程没有源文件,不能按原格式导出;请用「打开项目」选择同名源文件补传'
|
||||
? '手工工程导出:.cos/.cos4(经典整件骨架当模板)或 Excel(每单位工程一个文件)'
|
||||
: '按原格式导出本工程(含全部编辑:临删已省略、新增/采纳已写入)。只能对工作台的数据进行导出';
|
||||
}
|
||||
}
|
||||
@@ -3516,6 +3484,122 @@ function cfgTab(name){
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
/* ================= 导入项目(手工工程·决策 230):同框建目录树 + 按单位工程导 Excel =================
|
||||
按钮显隐三态:空态(未打开工程)显示;源文件工程隐藏;手工工程常驻(再点回弹框补目录/覆盖导入)。 */
|
||||
let ITREE=null, ISEL='';
|
||||
mkPeriod($('iper'));
|
||||
function impVis(){
|
||||
const w=$('impWrap'); if(!w) return;
|
||||
w.innerHTML = (!SID || MANUAL)
|
||||
? '<button class="btn pri" style="padding:3px 12px;font-size:12px" onclick="impDlgOpen()">导入项目</button>' : '';
|
||||
const t=document.getElementById('rawtree');
|
||||
if(t && !SID) t.innerHTML='<div style="padding:28px 14px;color:#8a97a8;text-align:center;line-height:2">尚未打开工程<br>点右上角「导入项目」:建目录树、按单位工程导入 Excel</div>';
|
||||
}
|
||||
(function(){ const _sm=setManualMode; setManualMode=function(m){ _sm(m); impVis(); }; })();
|
||||
impVis();
|
||||
|
||||
function impDlgOpen(){
|
||||
ITREE=[{name:'单项工程 1',units:[{name:'单位工程 1'}]}];
|
||||
$('iname').value=''; $('iper').value=''; $('ifile').value=''; $('imsg').textContent='';
|
||||
$('ititle').textContent='导入项目';
|
||||
$('ibtnSave').textContent='保存并创建工程';
|
||||
imask.classList.add('on');
|
||||
impTreeRender();
|
||||
if(SID && MANUAL){ // 手工工程:回填现有目录树
|
||||
J('/api/session/manual/state?session_id='+SID).then(d=>{
|
||||
if(d && d.ok && d.sections && d.sections.length){
|
||||
ITREE=d.sections.map(s=>({id:s.id,name:s.name,
|
||||
units:(s.units||[]).map(u=>({id:u.id,name:u.name,n_item:u.n_item,n_prelim:u.n_prelim}))}));
|
||||
$('iname').value=d.name||'';
|
||||
if(d.period_from){ // 基准期次回填(月序号 → YYYY-MM)
|
||||
const f2s=v=>{const y=Math.floor(v/12),m=v%12||12;return (m===12?y-1:y)+'-'+String(m).padStart(2,'0');};
|
||||
setPeriod($('iper'), f2s(d.period_from), f2s(d.period_to||d.period_from));
|
||||
}
|
||||
$('ititle').textContent='导入项目 · 编辑目录树';
|
||||
$('ibtnSave').textContent='保存(更新目录树)';
|
||||
impTreeRender();
|
||||
}
|
||||
}).catch(()=>{});
|
||||
}
|
||||
}
|
||||
function impTreeRender(){
|
||||
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="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>'
|
||||
+'<button class="iab" title="组内下移" onclick="impMovSec('+si+',1)"'+(si===ITREE.length-1?' disabled':'')+'>↓</button>'
|
||||
+'<button class="iab" onclick="impAddUw('+si+')">+单位工程</button><button class="iab x" onclick="impDelSec('+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>';
|
||||
else if(u.id && (u.n_item||u.n_prelim)) 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" onclick="impRename(this,'+si+','+ui+')">'+esc(u.name)+'</span>'
|
||||
+st
|
||||
+'<span class="iact"><button class="iab" title="组内上移" onclick="impMovUw('+si+','+ui+',-1)"'+(ui===0?' disabled':'')+'>↑</button>'
|
||||
+'<button class="iab" title="组内下移" onclick="impMovUw('+si+','+ui+',1)"'+(ui===s.units.length-1?' disabled':'')+'>↓</button>'
|
||||
+'<button class="iab imp" onclick="impPick('+si+','+ui+')" title="按模板导入(整单位工程覆盖)">导入单位工程</button><button class="iab x" onclick="impDelUw('+si+','+ui+')">✕</button></span></div>';
|
||||
});
|
||||
});
|
||||
$('itree').innerHTML=h;
|
||||
}
|
||||
function impRename(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) ITREE[si].name=v; else ITREE[si].units[ui].name=v;
|
||||
impTreeRender(); };
|
||||
inp.onblur=done;
|
||||
inp.onkeydown=e=>{ if(e.key==='Enter')inp.blur(); if(e.key==='Escape'){inp.value=cur;inp.blur();} };
|
||||
}
|
||||
function impAddSec(){ ITREE.push({name:'单项工程 '+(ITREE.length+1),units:[{name:'单位工程 1'}]}); impTreeRender(); }
|
||||
function impDelSec(i){ if(ITREE.length<=1){$('imsg').textContent='至少保留一个单项工程';return;} ITREE.splice(i,1); impTreeRender(); }
|
||||
function impAddUw(si){ ITREE[si].units.push({name:'单位工程 '+(ITREE[si].units.length+1)}); impTreeRender(); }
|
||||
function impDelUw(si,ui){ ITREE[si].units.splice(ui,1); impTreeRender(); }
|
||||
/* 决策 230 补记:单项/单位只在组内上下移动(单项换位=整组跟着走;单位不跨单项组) */
|
||||
function impMovSec(i,d){ const j=i+d; if(j<0||j>=ITREE.length) return;
|
||||
const t=ITREE[i]; ITREE[i]=ITREE[j]; ITREE[j]=t; impTreeRender(); }
|
||||
function impMovUw(si,ui,d){ const us=ITREE[si].units, j=ui+d; if(j<0||j>=us.length) return;
|
||||
const t=us[ui]; us[ui]=us[j]; us[j]=t; impTreeRender(); }
|
||||
function impPick(si,ui){ ISEL=si+','+ui; $('ifile').value=''; $('ifile').click(); }
|
||||
async function impFile(){
|
||||
const f=$('ifile').files[0]; $('ifile').value='';
|
||||
if(!f||!ISEL) return;
|
||||
const [si,ui]=ISEL.split(',').map(Number), u=ITREE[si].units[ui];
|
||||
$('imsg').textContent='正在上传并校验 '+f.name+'…';
|
||||
const up=await uploadFile('/api/admin/upload',f);
|
||||
if(!up.ok){ $('imsg').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||'校验失败'; $('imsg').textContent='✗ '+u.err; impTreeRender(); return; }
|
||||
u.file=up.path; u.n_item=r.n_item; u.n_prelim=r.n_prelim; delete u.err;
|
||||
$('imsg').textContent=''; impTreeRender();
|
||||
}
|
||||
function impTemplate(){ return saveAs('/api/session/manual/template','单位工程导入模板.xlsx'); }
|
||||
async function impSave(){
|
||||
const name=$('iname').value.trim(), pv=PVAL($('iper'));
|
||||
if(!name){ $('imsg').textContent='工程名称必填'; return; }
|
||||
if(pv.f==null||pv.t==null){ $('imsg').textContent='基准期次必填:点开选起~止(同月就选同一个)'; return; }
|
||||
for(const s of ITREE){
|
||||
if(!s.name.trim()){ $('imsg').textContent='单项工程名称不能为空'; return; }
|
||||
if(!s.units.length){ $('imsg').textContent='「'+s.name+'」下至少一个单位工程'; return; }
|
||||
for(const u of s.units) if(!u.name.trim()){ $('imsg').textContent='单位工程名称不能为空'; return; }
|
||||
}
|
||||
$('ibtnSave').disabled=true; $('imsg').textContent='正在保存…';
|
||||
try{
|
||||
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,
|
||||
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; }
|
||||
imask.classList.remove('on');
|
||||
location.href='/workbench.html?sid='+r.session_id; // 手工工程:initFromUrl 跳过重解析
|
||||
} finally { $('ibtnSave').disabled=false; }
|
||||
}
|
||||
</script>
|
||||
<script>licMount('.tabright');</script><!-- 统一设置窗口+到期预警(决策 31,实现在 common.js) -->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user