feat(ui): 目录树把手加竖轨连线、行垂直居中,并落实决策 321/316补十一 导出与勘察修复

This commit is contained in:
lianjianwei2024
2026-11-14 11:31:40 +08:00
parent 5d86c95402
commit b05b34ffbf
10 changed files with 522 additions and 137 deletions

View File

@@ -688,9 +688,9 @@ function billTR(r, grp, hide, opts) {
// data-bid:组内排序按它对回 GRP_DATA 里的数据行(billSortDOM);右键菜单也按它定位清单
return '<tr class="' + cls + '" data-grp="' + grp + '" data-bid="' + r[0] + '"' + st + clk + ' data-name="' + esc(r[2] || '') + '" data-price="' + esc(pr) + '">'
+ (opts.checkbox ? '<td class="c"><input type="checkbox" class="qbindck" data-id="' + r[0] + '" onclick="event.stopPropagation()"></td>' : '')
+ '<td class="tg"><span class="tog" title="展开/收起该清单下的定额" onclick="event.stopPropagation();tgNorm(this,' + r[0] + ')">+</span></td>'
+ '<td class="tg rail1"><span class="tog" title="展开/收起该清单下的定额" onclick="event.stopPropagation();tgNorm(this,' + r[0] + ')">+</span></td>'
+ '<td class="c">' + ((r[8] == null || r[8] === '') ? '—' : esc(r[8])) + '</td>'
+ '<td class="c">' + ell(r[1], '—') + '</td>'
+ '<td class="l">' + ell(r[1], '—') + '</td>'
+ '<td class="c"><span class="kind">清单</span></td>'
+ '<td>' + ((opts.locate && r[14])
? '<a class="lk" title="定位到原始数据中的这条清单" onclick="event.stopPropagation();return locBill(' + r[0] + ',' + r[14] + ')">' + ell(r[9], '—') + '</a>'
@@ -1000,7 +1000,7 @@ function tgNorm(el, billId) {
const gp = tr.dataset.grp || '';
const rows = (d && d.rows) || [];
if (!rows.length) {
frag.innerHTML = '<tr class="sub" data-grp="' + gp + '"><td class="tg"></td>'
frag.innerHTML = '<tr class="sub" data-grp="' + gp + '"><td class="tg rail2"></td>'
+ '<td colspan="' + (billColsO((typeof GRP_DATA !== 'undefined' && GRP_DATA && GRP_DATA.opts) || {}).length - 1) + '">(该清单下没有定额)</td></tr>';
} else {
// 定额 0=编码 1=名称 2=单位 3=工程量 4=单价 5=合价,其余列按清单的对应位置排空(含取消采纳/备注两空位)
@@ -1020,7 +1020,7 @@ function tgNorm(el, billId) {
+ (r[8] ? '' : ' title="展开/收起该清单下的定额"')
+ '>'
+ (gopts.checkbox ? '<td class="c"></td>' : '')
+ '<td class="tg"></td><td class="c">' + haoBtn(r[8]) + '</td><td class="c">' + ell(r[0], '—') + '</td>'
+ '<td class="tg rail2"></td><td class="c">' + haoBtn(r[8]) + '</td><td class="l" style="padding-left:18px">' + ell(r[0], '—') + '</td>'
+ '<td class="c"><span class="kind d">定额</span></td>'
+ '<td class="c">—</td>'
+ '<td><span class="ind">    </span>' + ell(r[1], '—') + '</td>'
@@ -1689,9 +1689,17 @@ function rawTreeHTML(d) {
const _sv = JSON.parse(localStorage.getItem('rvst_' + (_sm ? _sm[1] : '')) || 'null');
if (_sv && _sv.tree) _applyTree(_sv.tree);
} catch (e) {}
const tgi = (key, off) => {
/* 把手轨(2026-11-13 主人定「把手前后相连」,参考图口径):td.tgc 按祖先层级画实线竖线,
x=把手盒中线(td padding 4 + 把手 18/2 = 13,每层 +18)。n=祖先层数,0=不画。 */
const _tgcRail = n => {
if (!n) return '';
const g = [];
for (let i = 0; i < n; i++) g.push('transparent ' + (13 + i * 18) + 'px,#c9d4e2 ' + (13 + i * 18) + 'px,#c9d4e2 ' + (14 + i * 18) + 'px,transparent ' + (14 + i * 18) + 'px');
return ' style="background-image:linear-gradient(90deg,' + g.join(',') + ')"';
};
const tgi = (key, off, rail) => {
const open = _rvExp(key);
return '<td class="tgc"><span class="tgi" data-node="' + key + '" title="展开/收起"'
return '<td class="tgc"' + (rail ? _tgcRail(rail) : '') + '><span class="tgi" data-node="' + key + '" title="展开/收起"'
+ (off ? ' style="margin-left:' + off + 'px"' : '')
+ ' onclick="rawTog(\'' + key + '\',this)">' + (open ? '−' : '+') + '</span></td>';
};
@@ -1699,7 +1707,7 @@ function rawTreeHTML(d) {
rows += '<tr class="uwrow" data-vis="" data-path="uw">' + tgi('uw', TGI_UW)
+ '<td class="c">—</td>'
// 编码列:单位工程编号已按主人 2026-10-08 要求全软件不显示,根行留「—」占位
+ '<td class="c">—</td><td class="c"><span class="kind uw">单位工程</span></td>'
+ '<td class="l">—</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(rootSum) + '</b></td><td></td><td></td></tr>';
const billRow = (b, path, dp) => {
@@ -1713,9 +1721,9 @@ 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_DIV + dp * TGI_STEP) : '<td class="tgc"></td>')
+ (hasNorms ? tgi('b' + b.id, TGI_DIV + dp * TGI_STEP, dp + 1) : '<td class="tgc"' + _tgcRail(dp + 1) + '></td>')
// 序号 = 单位工程内行号(2026-10-10 主人定:每个单位工程的清单从 1 起排,不跨工程连号)
+ '<td class="c">' + n + '</td><td class="c">' + ell(b.Number, '—') + '</td>'
+ '<td class="c">' + n + '</td><td class="l">' + ell(b.Number, '—') + '</td>'
+ '<td class="c"><span class="kind">清单</span></td>'
+ '<td class="l" style="' + ind(dp) + '">' + ell(b.Name, '—') + '</td>'
+ '<td class="attr">' + ell(fmtAttr(b.Attr)) + '</td>'
@@ -1743,7 +1751,7 @@ function rawTreeHTML(d) {
// data-nid:定额行内编辑(规格5 双击 名称|工程量)按它定位——此前子行没带这个属性,
// 双击分支永远进不去(存量雷,规格 2026-10-16 顺手修);x[0]=定额 id
rows += '<tr class="' + ncls + '" data-nid="' + x[0] + '" data-vis="uw/' + path + '/b' + b.id + '" data-path="' + path + '/b' + b.id + '">'
+ '<td class="tgc"></td><td class="c">' + haoBtn(x[0]) + '</td><td class="c">' + ell(x[1], '—') + '</td>'
+ '<td class="tgc"' + _tgcRail(dp + 2) + '></td><td class="c">' + haoBtn(x[0]) + '</td><td class="l" style="padding-left:18px">' + ell(x[1], '—') + '</td>'
+ '<td class="c"><span class="kind d">定额</span></td>'
+ '<td class="l" style="' + ind(dp + 1) + '">' + ell(x[2], '—') + '</td>'
+ '<td class="attr nv">—</td><td class="c u">' + esc(x[3] || '—') + '</td>'
@@ -1760,8 +1768,8 @@ 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 + dp * TGI_STEP) : '<td class="tgc"></td>')
+ '<td class="c">—</td><td class="c">' + ell(nd.Number, '—') + '</td>'
+ (has ? tgi(key, TGI_DIV + dp * TGI_STEP, dp + 1) : '<td class="tgc"' + _tgcRail(dp + 1) + '></td>')
+ '<td class="c">—</td><td class="l">' + 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>'
@@ -2431,7 +2439,7 @@ function haoPop(btn, nid, from, bid0) {
pop.innerHTML = '<div class="haobar"><span class="ht">工料机</span>'
+ '<span class="pin" title="关闭" onclick="haoPopClose()">✕</span></div>'
+ '<table><colgroup>'
+ '<col style="width:44px"><col style="width:96px"><col style="width:170px"><col style="width:120px">'
+ '<col style="width:64px"><col style="width:96px"><col style="width:170px"><col style="width:120px">'
+ '<col style="width:52px"><col style="width:64px"><col style="width:72px"><col style="width:52px">'
+ '<col style="width:72px"></colgroup>'
+ '<thead><tr><th>序号<span class="rs"></span></th><th>编码<span class="rs"></span></th>'
@@ -2487,9 +2495,9 @@ function haoRow(x, i, noSub) {
return '<tr class="haorow" data-code="' + esc(x[0] || '') + '"' + (has ? ' data-sub="1"' : '')
+ ' title="' + (noSub ? '入库项目定额工料机(只读;台班/配合比可展开下一级组成)'
: '单击 ' + (has ? '含量(消耗量)' : '含量/除税价/税率/含税价') + ' 可编辑(汇总实时联动)')
+ '"><td class="c">' + (has ? '<span class="haosub" title="展开/收起下一级组成" data-code="'
+ '"><td class="c">' + (has ? '<span class="haosub" style="left:8px" title="展开/收起下一级组成" data-code="'
+ esc(x[0] || '') + '" onclick="haoRes(this)">+</span>' : '') + (i + 1) + '</td>'
+ '<td class="c">' + ell(x[0], '—') + '</td>'
+ '<td class="l">' + ell(x[0], '—') + '</td>'
+ '<td class="l">' + ell(x[1], '—') + '</td>'
+ '<td class="l">' + ell(x[2], '—') + '</td>'
+ '<td class="c u">' + esc(x[3] || '—') + '</td>'
@@ -2500,6 +2508,14 @@ function haoRow(x, i, noSub) {
}
/* 台班 / 配合比的下一级组成(tr.resk):_lme_res 返回 10 列(x[8]=has_sub、x[9]=税率),
子行可继续 ± 展开;按 data-depth 只清自己的后代,同级兄弟不误删。 */
/* 把手轨(2026-11-13 主人定「把手前后相连」):序号格按祖先层级画实线竖线,
x=把手盒中线(td padding 8 + 把手 14/2 = 15,每层 +16,与把手 left 内联值同一步长) */
function _haoRail(n) {
if (!n) return '';
const g = [];
for (let i = 0; i < n; i++) g.push('transparent ' + (15 + i * 16) + 'px,#c9d4e2 ' + (15 + i * 16) + 'px,#c9d4e2 ' + (16 + i * 16) + 'px,transparent ' + (16 + i * 16) + 'px');
return ' style="background-image:linear-gradient(90deg,' + g.join(',') + ')"';
}
function haoRes(tg) {
const tr = tg.closest('tr');
const _pop = tg.closest('.haopop');
@@ -2536,14 +2552,15 @@ function haoRes(tg) {
frag.innerHTML = rows.length
? rows.map(x => {
const _hs = (x[8] === 1 || x[8] === '1');
return '<tr class="resk" data-depth="' + (_depth + 1) + '" data-pcode="' + esc(tg.dataset.code) + '" data-ccode="' + esc(x[0]) + '"'
const _d = _depth + 1; // 2026-11-13 层次感:把手/编码/名称/规格按层级右移 16px/层
return '<tr class="resk" data-depth="' + _d + '" data-pcode="' + esc(tg.dataset.code) + '" data-ccode="' + esc(x[0]) + '"'
+ (_hs ? ' data-sub="1"' : '')
+ ' title="' + (_adm ? '入库项目子级组成(只读)' : (_hs ? '带子级:含量可编辑;单价/税率=Σ子级现算,修改请改它的子数据' : '单击 含量/除税价/含税价 可编辑(母行单价=Σ子级自动联动)')) + '">'
+ '<td class="c">' + (_hs ? '<span class="haosub" title="展开/收起下一级组成" data-code="'
+ '<td class="c"' + _haoRail(_d) + '>' + (_hs ? '<span class="haosub" style="left:' + (8 + _d * 16) + 'px" title="展开/收起下一级组成" data-code="'
+ esc(x[0] || '') + '" onclick="event.stopPropagation();haoRes(this)">+</span>' : '') + '</td>'
+ '<td class="c">' + ell(x[0], '—') + '</td>'
+ '<td class="l">' + ell(x[1], '—') + '</td>'
+ '<td class="l">' + ell(x[2], '—') + '</td><td class="c u">' + esc(x[3] || '—') + '</td>'
+ '<td class="l" style="padding-left:' + (8 + _d * 16) + 'px">' + ell(x[0], '—') + '</td>'
+ '<td class="l" style="padding-left:' + (8 + _d * 16) + 'px">' + ell(x[1], '—') + '</td>'
+ '<td class="l" style="padding-left:' + (8 + _d * 16) + 'px">' + ell(x[2], '—') + '</td><td class="c u">' + esc(x[3] || '—') + '</td>'
+ '<td class="r">' + r3(x[5]) + '</td><td class="r">' + rm(x[6]) + '</td>'
+ '<td class="r">' + (_hs ? '—' : (x[9] == null ? '—' : num(x[9], 2))) + '</td>'
+ '<td class="r">' + rm(x[7]) + '</td></tr>';
@@ -2683,8 +2700,13 @@ function dialogsDraggable(){
const dh = dlg.querySelector('.dh');
if (dh) {
dh.style.cursor = 'move';
dh.addEventListener('mousedown', e => {
/* 2026-11-13 主人报「很多弹框移动会出现漂移」:旧版把 mousemove/mouseup 挂在 document 上,
鼠标拖出窗口外松开时 mouseup 可能不派发 → 监听器残留,之后光标一动弹框就跟着漂。
改 Pointer Events + setPointerCapture:按下后移动事件始终派发给标题栏,
pointerup / pointercancel / 窗口失焦三路兜底解除,从根上杜绝监听器残留。 */
dh.addEventListener('pointerdown', e => {
if (e.target.closest('a,button,input,select,.close')) return; // 控件不拖
if (e.button !== 0) return; // 只响应左键
const r = dlg.getBoundingClientRect();
const ox = e.clientX - r.left, oy = e.clientY - r.top;
let moved = false;
@@ -2698,9 +2720,18 @@ function dialogsDraggable(){
dlg.style.left = L + 'px';
dlg.style.top = T + 'px';
};
const up = () => { document.removeEventListener('mousemove', move); document.removeEventListener('mouseup', up); };
document.addEventListener('mousemove', move);
document.addEventListener('mouseup', up);
const up = () => {
dh.removeEventListener('pointermove', move);
dh.removeEventListener('pointerup', up);
dh.removeEventListener('pointercancel', up);
window.removeEventListener('blur', up);
try { dh.releasePointerCapture(e.pointerId); } catch (_) {}
};
try { dh.setPointerCapture(e.pointerId); } catch (_) {}
dh.addEventListener('pointermove', move);
dh.addEventListener('pointerup', up);
dh.addEventListener('pointercancel', up);
window.addEventListener('blur', up);
e.preventDefault();
});
}