feat: 决策64-81——共享层地基/数据采纳/合并工料机/导出回写/子级物理整字段替换 + MCP工具接入层 + 规格收工存档
- 决策65-72 批次A-E:共享层清单插入/临删/恢复/删除/行内编辑、数据采纳全语义、合并工料机弹框+税率采集、导出原格式回写、历史对比框共享到分部分项/措施/组价不一致 - 决策73-77:5.0 正式样本验收、导出管线三连修、工料机改价口径定稿(有子级改子数据) - 决策78-81+追记:合并弹框带子级放回/固定表头、s_lme_res 子级物理整字段替换、recode_map/recode_children 落库、导出 _apply_recode 重建子级全字段、修 _find_summary_span 自闭合判断恒 False - 新增 server/mcp_server.py:Streamable HTTP /mcp(stateless JSON-RPC),mcp_enabled 默认关+Bearer 令牌+license 403,复用 api_* 处理器,零新增依赖 - 新增测试 mcp_switch/lme_price/export_ext/norm_op/norm_res_name,test_source_guards 扩充 - 收尾:.gitignore 忽略 .mimosa/(曾被全量暂存5785个缓存文件);删 备份代码.bat;规格完工存档 20261016_2051;新增方案文档 清单替换与共享层
This commit is contained in:
@@ -326,8 +326,6 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
<div class="rawmain">
|
||||
<div class="stabs" id="drawstabs"></div>
|
||||
<div class="rawbody" id="drawbody"></div>
|
||||
<!-- 点定额 → 子目工料机(下方分区面板,可收起/展开) -->
|
||||
<div class="rawnorm" id="rawnorm" style="display:none"></div>
|
||||
</div>
|
||||
</div>
|
||||
<table id="dtb"><colgroup id="dcg"></colgroup><thead id="dth"></thead><tbody id="dtbd"></tbody></table>
|
||||
@@ -339,7 +337,7 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
onclick="ldWrap('','正在重新分组(不用缓存,工程大要稍等)…',()=>loadTab('p2',true))"
|
||||
title="不用缓存,按当前批次数据与分组规则重新分组(工程大要稍等)">⟳ 重载</a>
|
||||
<!-- 原数据单位工程级的层级按钮挂点(2026-10-13 决策 58:分组/清单/定额/默认列宽 迁到这里最右) -->
|
||||
<span id="rawLvMount" style="margin-left:auto;display:inline-flex;gap:4px;align-items:center"></span>
|
||||
<span id="rawLvMount" class="rawLvMount" style="margin-left:auto;display:inline-flex;gap:4px;align-items:center"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -552,7 +550,7 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="common.js?v=20261013p"></script>
|
||||
<script src="common.js?v=20261016a"></script>
|
||||
<script src="period.js"></script>
|
||||
<script>
|
||||
const $=id=>document.getElementById(id);
|
||||
@@ -1174,6 +1172,7 @@ var WB_RAW = RawView({
|
||||
「+新增行/导出/附件」按钮,操作的还是上一个价格批次的 PD 状态)。
|
||||
(2026-10-13 追加 reloadsim:⟳ 重载仅类似清单标签显示。) */
|
||||
function detLayout(mode){
|
||||
haoPopClose(); // 切明细内容 = 原数据面板可能被收起,浮层锚点随之失效,先收(公共功能4)
|
||||
const price=mode==='price', raw=mode==='raw', sim=mode==='sim';
|
||||
$('drawbox').style.display = raw?'flex':'none';
|
||||
$('dtb').style.display = raw?'none':'';
|
||||
@@ -1222,6 +1221,7 @@ async function det(id,name,kind){
|
||||
}
|
||||
function closeDlg(){
|
||||
mask.classList.remove('on');
|
||||
haoPopClose(); // 明细弹框关掉 = 浮层锚点没了,一并收(公共功能4)
|
||||
try{ sessionStorage.removeItem('admin_det'); }catch(e){}
|
||||
}
|
||||
/* 回到后台页时把上次的明细恢复出来(关掉明细=主动结束,不再恢复) */
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
.rawbody{flex:1;overflow:auto;min-height:0;position:relative}
|
||||
/* 2026-10-08 主人定(第 2 次):**前后台所有表头**统一居中(td 内容保持各自对齐不变)。
|
||||
两页各自的 th.l/th.r 覆盖规则已同步删除 —— 居中只允许这一条规则,别处再写会局部改回去。
|
||||
带 data-sumw 的表(如子目工料机面板)有内联 width,本规则不覆盖宽度,仍按各自尺寸。 */
|
||||
带 data-sumw 的定宽表有内联 width,本规则不覆盖宽度,仍按各自尺寸。 */
|
||||
thead th{text-align:center}
|
||||
.rawmain > table, .rawmain .rawbody > table{width:100%}
|
||||
/* ---- 原数据加载无感(2026-10-07)----
|
||||
@@ -172,10 +172,10 @@ tr.uwrow td{font-weight:700;color:#123a6b}
|
||||
.rn .nm .spec{padding:0 4px;font-size:10px}
|
||||
/* ⚠️ 这里原本有一段 `.kind.uw{background:#123a6b}`(重复定义,且没重设 color)
|
||||
→ 根目录徽章变成深蓝底 + 深蓝字,字彻底看不见(主人反馈"根目录被颜色覆盖")。已删除。 */
|
||||
/* 定额行:整行可点开「子目工料机」(没有把手),选中行高亮 + 手型光标 */
|
||||
/* 定额子行(组表 / 原数据共用):手型与选中高亮样式保留;行上动作现走序号格的「耗」按钮 */
|
||||
tr.sub{cursor:pointer}
|
||||
tr.sub.on td{background:#e8f0fb;outline:1px solid var(--c2);outline-offset:-1px}
|
||||
/* 子目工料机面板里,台班 / 配合比展开的**组成明细**(下一级):缩进去 + 淡底,别跟主行抢视觉 */
|
||||
/* 工料机浮层里,台班 / 配合比展开的**组成明细**(下一级):淡底小字,别跟主行抢视觉 */
|
||||
tr.resk td{background:#f7f9fc;color:#5a6b7e;font-size:12px}
|
||||
|
||||
/* 数字列必须等宽数字:金额/工程量小数点对齐后才扫得动(审计表格最容易翻车的地方)。
|
||||
@@ -184,27 +184,27 @@ td.r, td.num, .r, .num{font-variant-numeric:tabular-nums}
|
||||
/* 表格选中态(2026-10-11 主人定):淡蓝底、无边框、无竖条——全页面含弹框统一 */
|
||||
tr.sel td{background:#e0effc}
|
||||
|
||||
/* 点定额 → 下方「子目工料机」分区面板(可收起/展开,非行内子行)
|
||||
与面板上方那条 .rawvsplit 分隔条配套:margin-top 归零,间距由分隔条给。 */
|
||||
.rawnorm{flex:none;display:flex;flex-direction:column;max-height:40%;min-height:120px;
|
||||
margin-top:0;border-top:2px solid var(--c1);background:#fcfdfe}
|
||||
/* ---- 子目工料机 上下分隔条(2026-10-07)----
|
||||
7px 命中区:按住上下拖 = 调面板高度;正中间 44×15 小把手:点一下收起/展开整块面板。 */
|
||||
.rawvsplit{height:7px;flex:none;position:relative;cursor:row-resize;margin-top:6px;background:transparent}
|
||||
.rawvsplit:hover{background:#dbe7f6}
|
||||
.rawvsplit .vsplitbtn{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);
|
||||
width:44px;height:15px;line-height:13px;text-align:center;font-size:9px;color:var(--c2);
|
||||
background:#eef3fa;border:1px solid var(--line);border-radius:4px;cursor:pointer;user-select:none;z-index:2}
|
||||
.rawvsplit .vsplitbtn:hover{background:#dbe8f7;border-color:var(--c2)}
|
||||
body.rawrow-dragging{cursor:row-resize !important;user-select:none}
|
||||
body.rawrow-dragging .rawnorm{pointer-events:none} /* 拖过面板表面时不选中文字 */
|
||||
.rawnorm .nphd{display:flex;align-items:center;gap:8px;padding:4px 10px;background:#eef3fa;
|
||||
border-bottom:1px solid var(--line);font-size:12px;color:var(--c1);flex:none}
|
||||
.rawnorm .nphd b{font-weight:500}
|
||||
.rawnorm .npname{color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.rawnorm .npclose{margin-left:auto;cursor:pointer;color:var(--c2);font-size:11.5px;white-space:nowrap}
|
||||
.rawnorm .npclose:hover{text-decoration:underline}
|
||||
.rawnorm .npbody{flex:1;overflow:auto;min-height:0}
|
||||
/* ---- 定额「耗」按钮 + 工料机浮层(2026-10-15 公共功能4,取代旧「子目工料机」底板)----
|
||||
圆按钮嵌在定额子行序号格里;浮层挂 body + fixed 定位(z-600 高于明细弹框遮罩),
|
||||
不受表格滚动容器裁剪;表头 sticky,内容超 60vh 在浮层内滚。 */
|
||||
.haobtn{display:inline-block;width:17px;height:17px;line-height:15px;text-align:center;
|
||||
border:1px solid var(--c2);border-radius:50%;background:#fff;color:var(--c2);
|
||||
font-size:11px;font-weight:700;cursor:pointer;user-select:none}
|
||||
.haobtn:hover{background:var(--c2);color:#fff}
|
||||
.haopop{position:fixed;z-index:600;background:#fff;border:1px solid var(--line);border-radius:6px;
|
||||
box-shadow:0 6px 18px rgba(15,40,80,.18);overflow:auto;max-height:60vh;max-width:760px}
|
||||
.haopop table{border-collapse:collapse;font-size:12px}
|
||||
.haopop th{position:sticky;top:0;background:#eef3fa;color:var(--c1);padding:3px 8px;
|
||||
border-bottom:1px solid var(--line);white-space:nowrap;text-align:center}
|
||||
.haopop td{padding:2px 8px;border-bottom:1px solid #f1f5f9;vertical-align:top}
|
||||
.haopop tbody tr:hover td{background:#f4f8fc}
|
||||
.haopop td.c{text-align:center}
|
||||
.haopop td.r{text-align:right;font-variant-numeric:tabular-nums}
|
||||
/* 浮层序号格里的 ± 把手:台班 / 配合比展开下一级组成 */
|
||||
.haosub{display:inline-block;width:14px;height:14px;line-height:12px;text-align:center;margin-right:4px;
|
||||
border:1px solid #9fb3cb;border-radius:3px;background:#fff;color:var(--c2);
|
||||
font-weight:700;font-size:11px;cursor:pointer;user-select:none}
|
||||
.haosub:hover{background:#e7eefb}
|
||||
|
||||
/* ---- 提示条(2026-10-06,替代 alert:页面内、不打断操作、3 秒淡出)----
|
||||
两处形态共用一套配色:内联 #dlmsg 写在查询栏里;没有它时右下角浮 .toast。
|
||||
@@ -250,3 +250,14 @@ body.rawrow-dragging .rawnorm{pointer-events:none} /* 拖过面板表面时不
|
||||
box-shadow:0 4px 14px rgba(18,58,107,.15);padding:4px 0;min-width:150px}
|
||||
.grpctx .gi{padding:7px 14px;font-size:12.5px;cursor:pointer;white-space:nowrap;color:#1c2733}
|
||||
.grpctx .gi:hover{background:#eef3fa;color:#123a6b}
|
||||
|
||||
/* ================= 共享层批次A(决策 67,2026-10-14 主人定「开工」)=================
|
||||
清单编辑状态视觉:x_new=本软件新增(淡绿底);x_tdel=临时删除(浅灰底+整行横线)。
|
||||
取消临删=移除类名即恢复原底色(规格:恢复成临删前的状态及底色)。
|
||||
原数据树表(.brow)与组表明细行(billTR)同款一套类名,四视图一致。 */
|
||||
tr.xnew > td { background: #e9f7ee !important; }
|
||||
tr.xtdel > td { background: #eef1f4 !important; color: #8a97a8; }
|
||||
tr.xtdel > td:not(.tgc), tr.xtdel > td:not(.tgc) span { text-decoration: line-through; }
|
||||
/* 双击行内编辑的输入框(原数据树表内) */
|
||||
#rawbody td input.cellin, .rawbody td input.cellin { width: 100%; box-sizing: border-box;
|
||||
border: 1px solid #7aa7d9; border-radius: 3px; font: inherit; padding: 0 4px; outline: none; }
|
||||
|
||||
@@ -331,34 +331,45 @@ function billSortDOM(tb) {
|
||||
});
|
||||
})();
|
||||
|
||||
/* ================= 组表右键菜单(2026-10-13 主人定:暂时只做弹框,功能后加)=================
|
||||
右键类似清单组表(data-grp 以 b 开头 = 工作台/后台的 similar 组表行)弹四项菜单:
|
||||
上方插入清单 / 下方插入清单 / 删除 / 临时删除。点菜单项或任意处收起,均暂无功能。 */
|
||||
/* ================= 组表/原数据 清单行右键菜单(决策 60 建占位 → 决策 66 改三项 → 决策 67 实装)=================
|
||||
右键**清单行**(tr[data-bid])弹菜单:原数据 brow 行 = 五项(插入×2/删除/临删/取消临删),
|
||||
组表明细行(类似清单 data-grp^=b、组价不一致 data-grp^=a)= 三项(删除/临时删除/取消临时删除)。
|
||||
菜单是**共享层地基**:document 级委托,前后台组表同款;工作台经 window.onBillCtxMenu(tr)
|
||||
接线真实操作,后台等无 handler 的页面维持占位(点了只收起,决策 60 口径)。 */
|
||||
(function () {
|
||||
let menu = null;
|
||||
function close() { if (menu) { menu.remove(); menu = null; } }
|
||||
function show(x, y) {
|
||||
function show(x, y, items, cb) {
|
||||
close();
|
||||
menu = document.createElement('div');
|
||||
menu.className = 'grpctx';
|
||||
menu.innerHTML = ['上方插入清单', '下方插入清单', '删除', '临时删除']
|
||||
.map(t => '<div class="gi">' + t + '</div>').join('');
|
||||
menu.innerHTML = items.map(t => '<div class="gi">' + t + '</div>').join('');
|
||||
menu._cb = cb || null;
|
||||
document.body.appendChild(menu);
|
||||
const r = menu.getBoundingClientRect();
|
||||
menu.style.left = Math.max(4, Math.min(x, window.innerWidth - r.width - 8)) + 'px';
|
||||
menu.style.top = Math.max(4, Math.min(y, window.innerHeight - r.height - 8)) + 'px';
|
||||
}
|
||||
document.addEventListener('contextmenu', function (e) {
|
||||
const tr = e.target.closest && e.target.closest('tr[data-grp^="b"]');
|
||||
// 只认清单行:组标题行/定额子行没有 data-bid,不弹(决策 67 收紧:菜单跟清单走)
|
||||
const tr = e.target.closest && (e.target.closest('tr.brow[data-bid]') || e.target.closest('tr[data-grp][data-bid]'));
|
||||
if (!tr) return;
|
||||
e.preventDefault();
|
||||
show(e.clientX, e.clientY);
|
||||
const h = (typeof window.onBillCtxMenu === 'function') ? window.onBillCtxMenu(tr) : null;
|
||||
show(e.clientX, e.clientY,
|
||||
(h && h.items && h.items.length) ? h.items : ['删除', '临时删除', '取消临时删除'],
|
||||
h ? h.cb : null);
|
||||
});
|
||||
document.addEventListener('mousedown', function (e) {
|
||||
if (menu && !(e.target.closest && e.target.closest('.grpctx'))) close();
|
||||
});
|
||||
document.addEventListener('click', function (e) {
|
||||
if (menu && e.target.closest && e.target.closest('.grpctx')) close(); // 菜单项暂无功能:点了只收起
|
||||
if (menu && e.target.closest && e.target.closest('.grpctx')) {
|
||||
const gi = e.target.closest('.gi');
|
||||
const cb = menu._cb, txt = gi ? gi.textContent : '';
|
||||
close();
|
||||
if (cb && txt) cb(txt); // 有接线才执行;占位菜单点了只收起
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -627,8 +638,10 @@ function billTR(r, grp, hide, opts) {
|
||||
const st = hide ? ' style="display:none"' : '';
|
||||
const clk = opts.rowClick ? ' onclick="' + opts.rowClick + "('bill'," + r[0] + ',this)"' : '';
|
||||
const pr = (r[6] == null ? '' : r[6]);
|
||||
// data-bid:组内排序按它对回 GRP_DATA 里的数据行(billSortDOM)
|
||||
return '<tr data-grp="' + grp + '" data-bid="' + r[0] + '"' + st + clk + ' data-name="' + esc(r[2] || '') + '" data-price="' + esc(pr) + '">'
|
||||
// 决策 67(批次A):r[11]=x_new 新增(淡绿)、r[12]=x_tdel 临删(浅灰+横线)——BILLROW 尾位
|
||||
const cls = (r[12] ? ' xtdel' : '') + (r[11] ? ' xnew' : '');
|
||||
// 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) + '">'
|
||||
+ '<td class="tg"><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>'
|
||||
@@ -646,12 +659,12 @@ function billTR(r, grp, hide, opts) {
|
||||
}
|
||||
/* 清单「取消采纳」列(2026-10-11 决策 39;2026-10-13 主人定:**工作台独有**,wb 标记、
|
||||
后台 noWB() 整列隐藏——后台批次库只是存有价值的不变数据,交互列不占列):
|
||||
有采纳备注(r[10],BILLROW 尾位)= 「取消采纳」链接;无 = —。
|
||||
亮灯条件(决策 68 批次B):有采纳备注(r[10])**或**有数据采纳标记(r[13],BILLROW 尾位)。
|
||||
后台不输出该格(opts.backend),链接永远不会出现在后台。 */
|
||||
function billAdoptCellHTML(r) {
|
||||
return (r && r[10])
|
||||
return (r && (r[10] || r[13]))
|
||||
? '<a class="lk" onclick="cancelBillAdopt(' + r[0] + ',this)"'
|
||||
+ ' title="清空本条采纳备注(清单采纳不收集附件)">取消采纳</a>'
|
||||
+ ' title="撤销采纳的数据(追加定额撤下、原定额恢复、汇总追加行撤下)并清空采纳备注">取消采纳</a>'
|
||||
: '<span style="color:#b9c4d2">—</span>';
|
||||
}
|
||||
/* 清单「备注」列内容 = 采纳备注全文(链接在左边的「取消采纳」列,2026-10-11 拆分)。 */
|
||||
@@ -742,11 +755,17 @@ function renderGroups(d, kind, opts) {
|
||||
末尾落单组不再叫「其他」,跟排为第 N+1 组 · 条数(2026-10-11 主人定;按类别分桶已废,决策 30)。
|
||||
pick(key):key='all'(根,显示全部)或 'bg3'/'bx0'(只显示该组)—— 过滤行为由页面
|
||||
各自实现(表格 id/取数不同),树只管画节点和**选中底色**(.rn.on,主人 10-08 定)。 */
|
||||
function grpTreeRender(box, d, pick) {
|
||||
function grpTreeRender(box, d, pick, opt) {
|
||||
if (!box) return;
|
||||
// 决策 72(批次E续):组价不一致清单共用此树(主人定「与类似清单界面功能一致」)——
|
||||
// kind 决定组 key 前缀(similar='b' / inconsistent='a')与根名
|
||||
opt = opt || {};
|
||||
const kind = opt.kind || 'similar';
|
||||
const pfx = kind === 'inconsistent' ? 'a' : 'b';
|
||||
const rootName = opt.rootName || '类似清单';
|
||||
const groups = (d && d.groups) || [], extra = (d && d.extra) || [];
|
||||
let h = '<div class="rn lv0 on" data-pk="all"><span class="arw" title="收起/展开">−</span>'
|
||||
+ '<span class="nm">类似清单(' + (groups.length + extra.length) + ' 组)</span></div><div class="rkids">';
|
||||
+ '<span class="nm">' + esc(rootName) + '(' + (groups.length + extra.length) + ' 组)</span></div><div class="rkids">';
|
||||
groups.forEach((g, i) => {
|
||||
const n = (g.rows || []).length;
|
||||
// 组号跟主表对齐(2026-10-10 主人定「按现有目录排序」):一律按显示位置连续编第 1~N 组,
|
||||
@@ -755,11 +774,11 @@ function grpTreeRender(box, d, pick) {
|
||||
const nm = g.cat
|
||||
? '第 ' + (i + 1) + ' 组 · ' + esc(g.cat) + '(' + n + ' 条)'
|
||||
: '第 ' + (i + 1) + ' 组 · ' + n + ' 条';
|
||||
h += '<div class="rn lv1" data-pk="bg' + i + '"><span class="nm">' + nm + '</span></div>';
|
||||
h += '<div class="rn lv1" data-pk="' + pfx + 'g' + i + '"><span class="nm">' + nm + '</span></div>';
|
||||
});
|
||||
extra.forEach((g, i) => {
|
||||
// 2026-10-13 主人定:落单组标题颜色与其他组一致(原灰色 #8a97a8 内联取消)
|
||||
h += '<div class="rn lv1" data-pk="bx' + i + '"><span class="nm">'
|
||||
h += '<div class="rn lv1" data-pk="' + pfx + 'x' + i + '"><span class="nm">'
|
||||
+ '第 ' + (groups.length + i + 1) + ' 组 · ' + ((g.rows || []).length) + ' 条</span></div>';
|
||||
});
|
||||
h += '</div>';
|
||||
@@ -782,18 +801,21 @@ function grpTreeRender(box, d, pick) {
|
||||
且交互还在调的阶段 —— 收进公共层,改一处两侧同步。
|
||||
grpTreeBind(树容器, 清单表 tbody 的 id, /similar 接口返回);
|
||||
opts 不用传 —— renderGroups 自己会取页面全局 WB_OPTS。 */
|
||||
function grpTreeBind(box, tbId, d) {
|
||||
function grpTreeBind(box, tbId, d, opt) {
|
||||
opt = opt || {};
|
||||
const kind = opt.kind || 'similar';
|
||||
const pfx = kind === 'inconsistent' ? 'a' : 'b';
|
||||
grpTreeRender(box, d, key => {
|
||||
const tb = document.getElementById(tbId);
|
||||
if (!tb) return;
|
||||
if (key === 'all') { tb.innerHTML = renderGroups(d, 'similar'); return; }
|
||||
if (key === 'all') { tb.innerHTML = renderGroups(d, kind); return; }
|
||||
const i = +key.slice(2);
|
||||
const g = key.charAt(1) === 'g' ? (d.groups || [])[i] : (d.extra || [])[i];
|
||||
if (!g) return;
|
||||
const lbl = key.charAt(1) === 'g' ? ('第 ' + (i + 1) + ' 组')
|
||||
: ('第 ' + ((d.groups || []).length + i + 1) + ' 组');
|
||||
tb.innerHTML = renderGroups({ groups: [g], labels: [lbl] }, 'similar');
|
||||
});
|
||||
tb.innerHTML = renderGroups({ groups: [g], labels: [lbl] }, kind);
|
||||
}, { kind: kind, rootName: opt.rootName });
|
||||
}
|
||||
|
||||
/* ---------------- ⑤ 工料机行 ----------------
|
||||
@@ -858,8 +880,13 @@ function tgNorm(el, billId) {
|
||||
+ '<td colspan="' + CB_LAST() + '">(该清单下没有定额)</td></tr>';
|
||||
} else {
|
||||
// 定额 0=编码 1=名称 2=单位 3=工程量 4=单价 5=合价,其余列按清单的对应位置排空(含取消采纳/备注两空位)
|
||||
frag.innerHTML = rows.map(r => '<tr class="sub" data-grp="' + gp + '">'
|
||||
+ '<td class="tg"></td><td class="c">—</td><td class="c">' + ell(r[0], '—') + '</td>'
|
||||
// 决策 68 批次B:会话侧 r[6]=x_tdel(原定额转临删→浅灰横线)、r[7]=x_adopt;批次侧恒 0
|
||||
// 公共功能4(2026-10-15):序号格挂圆形「耗」按钮 → 工料机浮层(r[8]=定额 id,两侧同形;
|
||||
// 无 id 的行没有按钮、退回「—」占位)
|
||||
frag.innerHTML = rows.map(r => '<tr class="sub' + (r[6] ? ' xtdel' : '') + '" data-grp="' + gp + '"'
|
||||
+ (r[8] ? '' : ' title="展开/收起该清单下的定额"')
|
||||
+ '>'
|
||||
+ '<td class="tg"></td><td class="c">' + haoBtn(r[8]) + '</td><td class="c">' + 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>'
|
||||
@@ -957,41 +984,73 @@ function rawKV(rows, tip) {
|
||||
+ '</tbody></table>';
|
||||
}
|
||||
/* 工料机汇总表:后端 _raw_proj(lme) 与 _raw_uw(lme) 的行序一致
|
||||
0=编码 1=名称 2=规格 3=单位 4=类别 5=数量 6=除税编制价 7=含税编制价
|
||||
0=编码 1=名称 2=规格 3=单位 4=类别 5=消耗量 6=除税编制价 7=税率 8=含税编制价
|
||||
(2026-10-16 主人口径:税率插在下标 7,前后端一次同改 —— 按下标取列是 BILLROW 铁律)
|
||||
数量列标签按层不同:项目级=「总数量」(源文件项目级汇总的 Quantity 原样,2026-10-11 主人定),
|
||||
单位工程级=「消耗量」(清单→定额→消耗量归集计算值)。
|
||||
RAW_LME_KIND=0 时把「类别」整列拿掉 —— 数据仍然取,只是不显示。 */
|
||||
/* 工料机汇总表的列排序(2026-10-07 主人要求):
|
||||
点列名按该列排序、再点反向;空值恒排最后(与方向无关);消耗量/两列价格按数值比,
|
||||
其余按中文比。排序状态跨重画保留(切单位工程后维持同一排序),换工程/重开明细复位。 */
|
||||
点列名按该列排序、再点反向;空值恒排最后(与方向无关);消耗量/价格/税率按数值比,
|
||||
其余按中文比。排序状态跨重画保留(切单位工程后维持同一排序),换工程/重开明细复位。
|
||||
⚠️ 两套下标:rawTbl 表头 onclick 传 **原始列下标**(含未显示的类别列),而数据行按
|
||||
数据下标取列、编辑按视图格位取列 —— 2026-10-13 加序号列时曾整列错位;
|
||||
2026-10-16 修:RV_LME_O2V 原始→视图、RV_LME_DS 视图→数据,rawLmeTbl 里两级翻译。 */
|
||||
let RV_LME_SORT = { k: -1, dir: 1 };
|
||||
let RV_LME_ROWS = null, RV_LME_TIP = '';
|
||||
const RV_LME_NUM = new Set([6, 7, 8]); // 消耗量 / 除税价 / 含税价(2026-10-13 前移加序号列后 +1)
|
||||
let RV_LME_ROWS = null, RV_LME_TIP = '', RV_LME_QL = '', RV_LME_IDS = null;
|
||||
const RV_LME_NUM = new Set([5, 6, 7, 8]); // 数据下标:消耗量/除税编制价/税率/含税编制价 按数值比
|
||||
let RV_LME_DS = null; // 视图列下标 → 数据 r[] 下标(rawLmeTbl 每次重建)
|
||||
let RV_LME_O2V = null; // 原始列下标 → 视图列下标(rawTbl 表头 onclick 传原始下标)
|
||||
const RAW_LME_SUB_TIP = '原软件按子级组成重算,改母价可能不生效';
|
||||
function rawLmeSort(k) {
|
||||
if (RV_LME_SORT.k === k) RV_LME_SORT.dir = -RV_LME_SORT.dir;
|
||||
else { RV_LME_SORT.k = k; RV_LME_SORT.dir = 1; }
|
||||
const b = document.getElementById(RVO.bodyEl);
|
||||
if (b && RV_LME_ROWS) { b.innerHTML = rawLmeTbl(RV_LME_ROWS, RV_LME_TIP); rvCachePut(); }
|
||||
if (b && RV_LME_ROWS) {
|
||||
b.innerHTML = rawLmeTbl(RV_LME_ROWS, RV_LME_TIP, RV_LME_QL, { ids: RV_LME_IDS });
|
||||
rvCachePut();
|
||||
}
|
||||
}
|
||||
function rawLmeTbl(rows, tip, qtyLabel) {
|
||||
function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
rows = rows || [];
|
||||
RV_LME_ROWS = rows; RV_LME_TIP = tip || '';
|
||||
const view = sortRows(rows, RV_LME_SORT.k, RV_LME_SORT.dir, RV_LME_NUM); // 共用比较器(2026-10-09 收编)
|
||||
RV_LME_ROWS = rows; RV_LME_TIP = tip || ''; RV_LME_QL = qtyLabel || '';
|
||||
RV_LME_IDS = (extra && extra.ids) || null; // 项目级带行 id(行级改价定位用);单位级无=只读
|
||||
const subSet = new Set((extra && extra.sub) || []); // 带子级组成的编码集 → 三格挂 title 提示
|
||||
// 视图列 = [序号, 编码, 名称, 规格, 类别?, 单位, 消耗量, 除税编制价, 税率, 含税编制价];
|
||||
// DS = 各视图列对应的数据下标(序号列无;类别列在 RAW_LME_KIND=0 时既不显示也不占视图下标)。
|
||||
// O2V = 原始列下标→视图下标:rawTbl 表头 onclick 传的是 cols 原始下标(common.js rawTbl),
|
||||
// 而编辑/排序映射都以视图下标为键 —— 两套键系差一位(类别列隐藏时),先翻译再查。
|
||||
const DS = [null, 0, 1, 2, 4, 3, 5, 6, 7, 8];
|
||||
RV_LME_DS = {}; RV_LME_O2V = {};
|
||||
for (let i = 0, vi = 0; i < DS.length; i++) {
|
||||
if (!RAW_LME_KIND && i === 4) continue;
|
||||
if (DS[i] != null) RV_LME_DS[vi] = DS[i];
|
||||
RV_LME_O2V[i] = vi;
|
||||
vi++;
|
||||
}
|
||||
const vk = (RV_LME_O2V && RV_LME_O2V[RV_LME_SORT.k] != null) ? RV_LME_O2V[RV_LME_SORT.k] : -1;
|
||||
const dk = (vk >= 0 && RV_LME_DS && RV_LME_DS[vk] != null) ? RV_LME_DS[vk] : -1;
|
||||
const view = sortRows(rows, dk, RV_LME_SORT.dir, RV_LME_NUM); // 共用比较器(2026-10-09 收编)
|
||||
const idOf = new Map(); // 行对象 → s_lme_proj.id(并行数组)
|
||||
(RV_LME_IDS || []).forEach((v, i) => { if (rows[i]) idOf.set(rows[i], v); });
|
||||
const body = view.map((r, i) => {
|
||||
const kind = RAW_LME_KIND
|
||||
? '<td class="c">' + esc(r[4] == null ? '—' : ({ 1: '人工', 2: '材料', 3: '机械', 4: '主材', 5: '设备' }[Number(r[4])] || r[4])) + '</td>'
|
||||
: '';
|
||||
const lid = idOf.get(r);
|
||||
const subT = subSet.has(r[0] || '') ? ' title="' + RAW_LME_SUB_TIP + '"' : '';
|
||||
// 2026-10-13 主人定:加「序号」列(视图行号,随排序重排)
|
||||
return '<tr><td class="c">' + (i + 1) + '</td><td class="c">' + ell(r[0], '—') + '</td><td class="l">' + ell(r[1], '—') + '</td>'
|
||||
return '<tr class="lmerow"' + (lid != null ? ' data-lmeid="' + esc(lid) + '"' : '')
|
||||
+ '><td class="c">' + (i + 1) + '</td><td class="c">' + ell(r[0], '—') + '</td><td class="l">' + ell(r[1], '—') + '</td>'
|
||||
+ '<td class="l">' + ell(r[2], '—') + '</td>' + kind
|
||||
+ '<td class="c u">' + esc(r[3] || '—') + '</td><td class="r">' + r3(r[5]) + '</td>'
|
||||
+ '<td class="r">' + rm(r[6]) + '</td><td class="r">' + rm(r[7]) + '</td></tr>';
|
||||
+ '<td class="r"' + subT + '>' + rm(r[6]) + '</td><td class="r"' + subT + '>' + rm(r[7]) + '</td>'
|
||||
+ '<td class="r"' + subT + '>' + rm(r[8]) + '</td></tr>';
|
||||
}).join('');
|
||||
// 2026-10-08 主人定:名称/规格两列都给弹性宽('')—— fixed 布局下自动列均摊剩余空间,
|
||||
// 两列严格等宽、随容器自适应;其余列宽不变。表头统一居中见 common.css。
|
||||
const cols = RAW_LME_KIND ? [40, 110, '', '', 60, 52, 90, 100, 100] : [40, 110, '', '', 0, 52, 90, 100, 100];
|
||||
const cols = RAW_LME_KIND ? [40, 110, '', '', 60, 52, 90, 90, 70, 100] : [40, 110, '', '', 0, 52, 90, 90, 70, 100];
|
||||
const head = [['序号', 'c'], ['编码', 'c'], ['名称', 'l'], ['规格', 'l'], ['类别', 'c'], ['单位', 'c'],
|
||||
[qtyLabel || '消耗量', 'r'], ['除税价', 'r'], ['含税价', 'r']];
|
||||
[qtyLabel || '消耗量', 'r'], ['除税编制价', 'r'], ['税率', 'r'], ['含税编制价', 'r']];
|
||||
return (tip ? '<div class="hint">' + esc(tip) + '</div>' : '')
|
||||
+ rawTbl(cols, head, body || '<tr><td class="empty">没有工料机数据</td></tr>', null,
|
||||
{ cur: RV_LME_SORT.k, dir: RV_LME_SORT.dir, fn: 'rawLmeSort' });
|
||||
@@ -1017,14 +1076,21 @@ function rawTabs() {
|
||||
}).join('')
|
||||
+ '<div class="lvbtn rst" onclick="rawRst()" title="把拖过的列宽全部还原">默认列宽</div></div>'
|
||||
: '';
|
||||
const mount = document.getElementById('rawLvMount');
|
||||
if (mount) mount.innerHTML = lv;
|
||||
const mounts = document.querySelectorAll('.rawLvMount');
|
||||
if (mounts.length) { mounts.forEach(m => m.innerHTML = lv); } // 决策 72:类似清单/组价不一致 双挂点同渲染
|
||||
else h += lv;
|
||||
// 2026-10-14 主人定:项目级标签行右侧加「导出」「合并工料机」占位按钮(功能后加)
|
||||
if (RVSEL.k === 'proj') {
|
||||
// 决策 69 批次C:合并工料机实装(工作台接 rawMergeOpen;后台批次库只读,维持占位)
|
||||
const canMerge = typeof window.rawMergeOpen === 'function';
|
||||
const canExport = typeof window.exportSession === 'function';
|
||||
h += '<div style="margin-left:auto;display:flex;gap:4px;align-items:center">'
|
||||
+ '<div class="lvbtn" title="功能即将上线">导出</div>'
|
||||
+ '<div class="lvbtn" title="功能即将上线">合并工料机</div></div>';
|
||||
+ (canExport
|
||||
? '<div class="lvbtn" onclick="exportSession()" title="按原格式导出本工程(含全部编辑:临删已省略、新增/采纳已写入)">导出</div>'
|
||||
: '<div class="lvbtn" title="功能即将上线">导出</div>')
|
||||
+ (canMerge
|
||||
? '<div class="lvbtn" onclick="rawMergeOpen()" title="按 名称|规格|单位 归并项目级工料机">合并工料机</div>'
|
||||
: '<div class="lvbtn" title="功能即将上线">合并工料机</div>') + '</div>';
|
||||
}
|
||||
st.innerHTML = h;
|
||||
}
|
||||
@@ -1054,7 +1120,6 @@ async function rawPick(k, id, el) {
|
||||
const tree = document.getElementById(RVO.treeEl);
|
||||
if (tree) tree.querySelectorAll('.rn').forEach(x => x.classList.remove('on'));
|
||||
if (el) el.classList.add('on');
|
||||
rawPanelClose();
|
||||
drawRawTree(); rawTabs(); await rawDraw();
|
||||
}
|
||||
/* ± 把手:只折叠/展开,不改变右侧选中(否则看个目录就把右边的表切走了) */
|
||||
@@ -1112,7 +1177,6 @@ const _qid = (k, v) => encodeURIComponent(k) + '=' + encodeURIComponent(v);
|
||||
② 未命中时不**清空**旧内容(那一下跳动最扎眼):旧内容压暗 + 右上角小角标,
|
||||
数据到了原位替换。配合索引优化,未命中加载本地也只有几十毫秒。 */
|
||||
let RV_CACHE = {};
|
||||
let RV_NORM_CACHE = {}; // 子目工料机面板:定额 id → 面板体 HTML(换工程清空)
|
||||
function _rvCacheKey() {
|
||||
const oid = (typeof RVO.getId === 'function') ? RVO.getId() : RVO.getId;
|
||||
return oid + '|' + RVSEL.k + ':' + (RVSEL.id || 0) + '|' + RVTAB;
|
||||
@@ -1140,7 +1204,7 @@ async function rawDraw() {
|
||||
if (RVSEL.k === 'proj') {
|
||||
const d = await rawFetch('/proj', _qid(RVO.idParam, oid) + '&tab=' + encodeURIComponent(RVTAB));
|
||||
if (RVTAB === 'sum') html = rawProj('sum', d.rows);
|
||||
else if (RVTAB === 'lme') html = rawLmeTbl(d.rows, '', '总数量'); // 2026-10-13 主人定:取消顶部说明行
|
||||
else if (RVTAB === 'lme') html = rawLmeTbl(d.rows, '', '总数量', { ids: d.ids, sub: d.sub }); // 2026-10-13 主人定:取消顶部说明行;2026-10-16 带行 id/子级组成集
|
||||
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') {
|
||||
@@ -1212,7 +1276,7 @@ function rawTreeHTML(d) {
|
||||
// ②「类型」列 52→88px,让根目录「单位工程」徽章不再溢出(4 字 ~62px + 内边距);
|
||||
// 两处均不再标 data-sumw,表退回 width:100% 填满弹框/屏幕;表头统一居中见 common.css。
|
||||
const head = ['', '序号', ['编码', 'c'], ['类型', 'c'], ['名称', 'l'], ['项目特征', 'l'],
|
||||
['单位', 'c'], ['工程量', 'r'], ['单价', 'r'], ['合价', 'r'], ['备注', 'l']];
|
||||
['单位', 'c'], ['工程量', 'r'], ['单价', 'r'], ['合价', 'r'], ['取消采纳', 'c'], ['备注', 'l']];
|
||||
// 把手列(第一列):单位工程最左、分部统一 16px、清单统一 32px —— 三档错开、各成一条直线
|
||||
const TGI_UW = 0, TGI_DIV = 16, TGI_BILL = 32;
|
||||
// 2026-10-08 主人定(修「± 把手外溢」):把手列宽不再写死 40。table-layout:fixed 的列
|
||||
@@ -1221,7 +1285,7 @@ function rawTreeHTML(d) {
|
||||
// 以后调整进/把手尺寸列宽自动跟上,结构上不可能再外溢。
|
||||
// 2026-10-08 主人定:源文件备注显示在备注栏 —— 列宽 56→220 放得下备注文字(悬停有全文提示),
|
||||
// 「项目特征」仍是伸缩列('')吸收剩余宽度。
|
||||
const cols = [8 + TGI_BILL + 20, 40, 100, 88, 160, '', 64, 76, 74, 86, 220];
|
||||
const cols = [8 + TGI_BILL + 20, 40, 100, 88, 160, '', 64, 76, 74, 86, 86, 220];
|
||||
let n = 0, rows = '';
|
||||
// 展开状态按当前层级档重建(切层级按钮 / 换单位工程都会走到这里)
|
||||
// RVLV=1 只到分部(分部全收) RVLV=2 只到清单(清单全收) RVLV=3 全展开
|
||||
@@ -1245,13 +1309,17 @@ 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></tr>';
|
||||
+ '<td class="r"></td><td class="r"></td><td class="r"><b>' + rm(uw.Total) + '</b></td><td></td><td></td></tr>';
|
||||
const billRow = (b, path, dp) => {
|
||||
n++;
|
||||
const hasNorms = (b.norms || []).length > 0;
|
||||
// 决策 67:x_new 淡绿(本软件新增)、x_tdel 浅灰+横线(临删);data-bid 供右键菜单/行内编辑定位
|
||||
const cls = 'brow' + (b.x_tdel ? ' xtdel' : '') + (b.x_new ? ' xnew' : '');
|
||||
// data-vis = 祖先容器链(不含自己):自己的 ± 只管自己的定额,不影响本行可见
|
||||
const vis = 'uw/' + path;
|
||||
rows += '<tr class="brow" data-vis="' + vis + '" data-path="' + path + '/b' + b.id + '">'
|
||||
rows += '<tr class="' + cls + '" data-bid="' + b.id + '" data-name="' + esc(b.Name || '') + '"'
|
||||
+ (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>')
|
||||
// 序号 = 单位工程内行号(2026-10-10 主人定:每个单位工程的清单从 1 起排,不跨工程连号)
|
||||
+ '<td class="c">' + n + '</td><td class="c">' + ell(b.Number, '—') + '</td>'
|
||||
@@ -1260,18 +1328,24 @@ function rawTreeHTML(d) {
|
||||
+ '<td class="attr">' + ell(fmtAttr(b.Attr)) + '</td>'
|
||||
+ '<td class="c u">' + esc(b.Unit || '—') + '</td><td class="r">' + r3(b.Quantity) + '</td>'
|
||||
+ '<td class="r">' + rm(b.Price) + '</td><td class="r">' + rm(b.Total) + '</td>'
|
||||
// 取消采纳列(决策 68 批次B 实装:有数据采纳标记 → 撤销链接;否则占位)
|
||||
+ '<td class="c">' + (b.x_adopt
|
||||
? '<a class="lk" onclick="event.stopPropagation();cancelBillAdopt(' + b.id + ',this)"'
|
||||
+ ' title="撤销采纳的数据并清空采纳备注">取消采纳</a>'
|
||||
: '—') + '</td>'
|
||||
// 源文件备注(2026-10-08 主人定:只显示在「原数据」备注栏);空则留白,不显示「—」
|
||||
+ '<td class="l">' + ell(b.Remark, '') + '</td></tr>';
|
||||
(b.norms || []).forEach(x => {
|
||||
// 定额行可点 → 下方「子目工料机」面板(x[0] = 定额 id);可见性含父清单
|
||||
rows += '<tr class="sub" data-vis="uw/' + path + '/b' + b.id + '" data-path="' + path + '/b' + b.id + '"'
|
||||
+ ' onclick="rawNorm(' + x[0] + ',\'' + esc(String(x[1] || '').replace(/'/g, '')) + '\',this)">'
|
||||
+ '<td class="tgc"></td><td class="c">—</td><td class="c">' + ell(x[1], '—') + '</td>'
|
||||
// 公共功能4(2026-10-15):序号格挂圆形「耗」按钮 → 工料机浮层(x[0] = 定额 id)
|
||||
// 决策 68 批次B:x[7]=x_tdel 原定额转临删(浅灰横线);x[8]=x_adopt 采纳追加
|
||||
const ncls = 'sub' + (x[7] ? ' xtdel' : '');
|
||||
rows += '<tr class="' + ncls + '" 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="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>'
|
||||
+ '<td class="r">' + r3(x[4]) + '</td><td class="r">' + rm(x[5]) + '</td>'
|
||||
+ '<td class="r">' + rm(x[6]) + '</td><td></td></tr>';
|
||||
+ '<td class="r">' + rm(x[6]) + '</td><td></td><td></td></tr>';
|
||||
});
|
||||
};
|
||||
const walk = (nodes, parentPath, dp) => {
|
||||
@@ -1285,7 +1359,7 @@ function rawTreeHTML(d) {
|
||||
+ '<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></tr>';
|
||||
+ '<td class="r">' + rm(nd.Total) + '</td><td></td><td></td></tr>';
|
||||
(nd.bills || []).forEach(b => billRow(b, path, dp + 1));
|
||||
walk(nd.children || [], path, dp + 1);
|
||||
});
|
||||
@@ -1346,145 +1420,107 @@ function rawUw(tab, rows) {
|
||||
return rawKV(K.map(x => [x[1], r[x[0]] == null ? '—' : rm(r[x[0]])]), ''); // 2026-10-13 主人定:取消说明行
|
||||
}
|
||||
|
||||
/* ---- 点定额行 → 下方「子目工料机」面板 ----
|
||||
数据源 opt.normApi(nid):会话库 /api/session/norm/{id}/res,批次库 /api/admin/norm/{id}/res。
|
||||
面板挂在 body 元素的父节点上(= .rawmain),跟着一起 flex 布局,不占表格的滚动区。
|
||||
面板与表格之间有一条**上下分隔条**:按住拖 = 调面板高度;正中间的小把手点一下 =
|
||||
收起/展开整块面板(rawVSplitInit)。 */
|
||||
function rawNorm(nid, name, tr) {
|
||||
const box = document.getElementById(RVO.bodyEl); if (!box || !box.parentNode) return;
|
||||
box.querySelectorAll('tr.sub.on').forEach(x => x.classList.remove('on'));
|
||||
if (tr) tr.classList.add('on');
|
||||
let np = document.getElementById('rawnp');
|
||||
if (!np) {
|
||||
np = document.createElement('div');
|
||||
np.className = 'rawnorm'; np.id = 'rawnp';
|
||||
box.parentNode.appendChild(np);
|
||||
rawVSplitInit(np);
|
||||
}
|
||||
// 2026-10-07:定额的工料机取数缓存 —— 同一条定额反复点不再闪「正在读取…」
|
||||
if (RV_NORM_CACHE[nid]) {
|
||||
np.querySelector('.npname').textContent = name || '';
|
||||
np.querySelector('.npbody').innerHTML = RV_NORM_CACHE[nid];
|
||||
bindNormRes(np);
|
||||
return;
|
||||
}
|
||||
np.innerHTML = '<div class="nphd"><b>子目工料机</b><span class="npname">' + esc(name || '') + '</span>'
|
||||
+ '<span class="npclose" onclick="rawPanelClose()">关闭</span></div>'
|
||||
+ '<div class="npbody"><div class="empty">正在读取…</div></div>';
|
||||
/* ---- 定额行「耗」按钮 → 工料机浮层(2026-10-15 公共功能4/5)----
|
||||
四个视图的定额子行序号格共用:原数据 分部分项/措施项目(rawTreeHTML)+ 类似清单/组价不一致
|
||||
组表(tgNorm,后台明细弹框同款自动生效)。点「耗」= 在按钮右下角弹只读浮层表(工料机,
|
||||
尾列税率);鼠标离开浮层即消失;视口下方放不下自动翻转(浮层左下角贴按钮右下角)。
|
||||
取数沿旧「子目工料机」同路:RVO.normApi(nid)(工作台会话库 / 后台批次库各自解析)。
|
||||
旧底板(#rawnp 面板 + 上下分隔条)已整块拆除(公共功能5),接口路由保留由本浮层继续用。 */
|
||||
let HAO_POP = null; // 浮层单例:同一时刻只弹一个
|
||||
function haoBtn(nid) { // 序号格里的圆形「耗」按钮(无 id 的定额行退回 —)
|
||||
return nid ? '<span class="haobtn" title="查看本定额的工料机" onclick="haoPop(this,' + nid + ')">耗</span>' : '—';
|
||||
}
|
||||
function haoPopClose() {
|
||||
if (!HAO_POP) return;
|
||||
HAO_POP.remove(); HAO_POP = null;
|
||||
window.removeEventListener('scroll', haoPopAway, true);
|
||||
window.removeEventListener('resize', haoPopAway);
|
||||
}
|
||||
/* 滚动/改尺寸时浮层(fixed 挂 body)会跟按钮脱钩 → 收掉;浮层自己内部的滚动也会进 capture,
|
||||
按 target 判掉不算 */
|
||||
function haoPopAway(e) {
|
||||
if (HAO_POP && !(e && e.target && HAO_POP.contains(e.target))) haoPopClose();
|
||||
}
|
||||
/* 按按钮右下角定位:默认浮层左上角贴按钮右下角;下方放不下翻转成浮层左下角贴按钮右下角;
|
||||
右边溢出则整体收进视口。数据到货后尺寸会变,须再 place 一次。 */
|
||||
function haoPlace(pop, btn) {
|
||||
const r = btn.getBoundingClientRect();
|
||||
const w = pop.offsetWidth, h = pop.offsetHeight;
|
||||
const vw = window.innerWidth, vh = window.innerHeight, M = 6;
|
||||
let x = r.right + M, y;
|
||||
if (x + w > vw - M) x = Math.max(M, vw - w - M);
|
||||
if (r.bottom + M + h <= vh - M) y = r.bottom + M;
|
||||
else y = Math.max(M, r.bottom - h);
|
||||
pop.style.left = x + 'px'; pop.style.top = y + 'px';
|
||||
}
|
||||
function haoPop(btn, nid) {
|
||||
if (HAO_POP && HAO_POP.dataset.nid === String(nid)) { haoPopClose(); return; } // 再点同一个 = 收起
|
||||
haoPopClose();
|
||||
const pop = document.createElement('div');
|
||||
pop.className = 'haopop'; pop.dataset.nid = String(nid);
|
||||
pop.innerHTML = '<table><thead><tr><th>序号</th><th>编码</th><th>名称</th><th>规格</th><th>单位</th>'
|
||||
+ '<th>含量</th><th>除税价</th><th>税率</th><th>含税价</th></tr></thead>'
|
||||
+ '<tbody><tr><td colspan="9" class="empty">正在读取…</td></tr></tbody></table>';
|
||||
document.body.appendChild(pop);
|
||||
HAO_POP = pop;
|
||||
haoPlace(pop, btn);
|
||||
pop.addEventListener('mouseleave', haoPopClose); // 鼠标离开浮层区域自动消失(规格原文)
|
||||
window.addEventListener('scroll', haoPopAway, true);
|
||||
window.addEventListener('resize', haoPopAway);
|
||||
const base = (typeof RVO.normApi === 'function') ? RVO.normApi(nid) : (RVO.normApi + nid + '/res');
|
||||
fetch(base).then(r => r.json()).then(d => {
|
||||
if (HAO_POP !== pop) return; // 浮层已被收掉(再点/滚屏/换工程),丢弃迟到响应
|
||||
const rows = (d && d.rows) || [];
|
||||
// 列序(后端 _norm_res):0编码 1名称 2规格 3单位 4类别 5含量 6除税价 7含税价 8有下一级
|
||||
// 2026-10-07 改版:① ± 把手**单独一列放最左**(与全软件的展开把手同款);
|
||||
// ② 「类别」列整个不输出(主人定;同 rawLmeTbl 的 RAW_LME_KIND=0 口径)。
|
||||
const body = rows.map((x, i) => {
|
||||
const has = x[8] === 1 || x[8] === '1';
|
||||
// 2026-10-13 主人定:把手右边加「序号」列(视图行号)
|
||||
return '<tr><td class="tgc">' + (has ? '<span class="tgi" title="展开/收起组成">+</span>' : '') + '</td>'
|
||||
+ '<td class="c">' + (i + 1) + '</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="r">' + r3(x[5]) + '</td>'
|
||||
+ '<td class="r">' + rm(x[6]) + '</td>'
|
||||
+ '<td class="r">' + rm(x[7]) + '</td></tr>';
|
||||
}).join('');
|
||||
np.querySelector('.npbody').innerHTML = rows.length
|
||||
? rawTbl([34, 40, 130, 220, 150, 56, 90, 100, 100],
|
||||
[['', 'c'], ['序号', 'c'], ['编码', 'c'], ['名称', 'l'], ['规格', 'l'], ['单位', 'c'], ['含量', 'r'], ['除税价', 'r'], ['含税价', 'r']], body)
|
||||
: '<div class="empty">这条定额下没有工料机</div>';
|
||||
RV_NORM_CACHE[nid] = np.querySelector('.npbody').innerHTML;
|
||||
bindNormRes(np);
|
||||
}).catch(() => { np.querySelector('.npbody').innerHTML = '<div class="empty">读取失败</div>'; });
|
||||
}
|
||||
function bindNormRes(np) {
|
||||
np.querySelectorAll('.tgi').forEach(s => {
|
||||
s.style.cursor = 'pointer';
|
||||
s.onclick = function (e) { e.stopPropagation(); rawRes(x_code(s), s.closest('tr')); };
|
||||
// 列序(后端 _norm_res):0编码 1名称 2规格 3单位 4类别(不显示) 5含量 6除税价 7含税价
|
||||
// 8有下一级 9税率(公共功能4 新增;无 = —)
|
||||
pop.querySelector('tbody').innerHTML = rows.length ? rows.map(haoRow).join('')
|
||||
: '<tr><td colspan="9" class="empty">这条定额下没有工料机</td></tr>';
|
||||
haoPlace(pop, btn);
|
||||
}).catch(() => {
|
||||
if (HAO_POP !== pop) return;
|
||||
pop.querySelector('tbody').innerHTML = '<tr><td colspan="9" class="empty">读取失败</td></tr>';
|
||||
});
|
||||
}
|
||||
function x_code(s) { return s.closest('tr').children[2].textContent.trim(); } // 2026-10-13 加序号列后编码移到第 3 格
|
||||
/* 台班 / 配合比的**下一级组成**(tr.resk):值与 _norm_res 同仰面料序,单独一行「组成」色 + 缩进。
|
||||
列与子目工料机主表同构(把手/编码/名称/规格/单位/含量/除税/含税),把手列只占位不挂 ±。 */
|
||||
function rawRes(code, tr) {
|
||||
if (!code) return;
|
||||
if (tr.dataset.open === '1') {
|
||||
function haoRow(x, i) {
|
||||
const has = x[8] === 1 || x[8] === '1';
|
||||
// ± 挂在序号格里(浮层不再单列把手):台班/配合比可展开下一级组成
|
||||
return '<tr><td class="c">' + (has ? '<span class="haosub" 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[1], '—') + '</td>'
|
||||
+ '<td class="l">' + 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">' + num(x[9], 2) + '</td>'
|
||||
+ '<td class="r">' + rm(x[7]) + '</td></tr>';
|
||||
}
|
||||
/* 台班 / 配合比的下一级组成(tr.resk):_lme_res 返回 8 列(无税率,恒 —),行插在当前行之后 */
|
||||
function haoRes(tg) {
|
||||
const tr = tg.closest('tr');
|
||||
if (tr.dataset.open === '1') { // 已展开 → 收起
|
||||
let nx = tr.nextElementSibling;
|
||||
while (nx && nx.classList.contains('resk')) { const n2 = nx.nextElementSibling; nx.remove(); nx = n2; }
|
||||
tr.dataset.open = '0'; const m = tr.querySelector('.tgi'); if (m) m.textContent = '+';
|
||||
tr.dataset.open = '0'; tg.textContent = '+';
|
||||
return;
|
||||
}
|
||||
const base = (typeof RVO.lmeApi === 'function') ? RVO.lmeApi() : RVO.lmeApi;
|
||||
fetch(base + '&code=' + encodeURIComponent(code)).then(r => r.json()).then(d => {
|
||||
fetch(base + '&code=' + encodeURIComponent(tg.dataset.code)).then(r => r.json()).then(d => {
|
||||
const rows = (d && d.rows) || [];
|
||||
tr.dataset.open = '1'; const m = tr.querySelector('.tgi'); if (m) m.textContent = '−';
|
||||
tr.dataset.open = '1'; tg.textContent = '−';
|
||||
const frag = document.createElement('tbody');
|
||||
frag.innerHTML = rows.length
|
||||
? rows.map(x => '<tr class="resk"><td class="tgc"></td><td></td><td class="c">' + ell(x[0], '—') + '</td>'
|
||||
? rows.map(x => '<tr class="resk"><td class="c"></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">' + esc(x[3] || '—') + '</td>'
|
||||
+ '<td class="l">' + 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">' + rm(x[7]) + '</td></tr>').join('')
|
||||
: '<tr class="resk"><td class="tgc"></td><td></td><td class="l" colspan="8">(没有下一级组成)</td></tr>';
|
||||
+ '<td class="c">—</td><td class="r">' + rm(x[7]) + '</td></tr>').join('')
|
||||
: '<tr class="resk"><td colspan="9" style="text-align:left">(没有下一级组成)</td></tr>';
|
||||
let nx = tr.nextElementSibling;
|
||||
while (nx && nx.classList.contains('resk')) nx = nx.nextElementSibling;
|
||||
while (frag.firstChild) tr.parentNode.insertBefore(frag.firstChild, nx);
|
||||
});
|
||||
}
|
||||
function rawPanelClose() {
|
||||
const np = document.getElementById('rawnp'); if (np) np.remove();
|
||||
const sp = document.getElementById('rawvsplit'); if (sp) sp.remove();
|
||||
const box = document.getElementById(RVO.bodyEl);
|
||||
if (box) box.querySelectorAll('tr.sub.on').forEach(x => x.classList.remove('on'));
|
||||
}
|
||||
/* ---- 子目工料机面板的上下分隔条(2026-10-07,主人要求)----
|
||||
① 按住分隔条上下拖 = 调面板高度(120px ~ 容器的 75%);
|
||||
② 分隔条正中间的小把手,点一下 = 收起/展开整块面板(收起后把手仍在,随时点回来)。
|
||||
面板被「关闭」(rawPanelClose)时分隔条一并移除,不留死把手。
|
||||
2026-10-13 决策 48:拖出的高度入公共记忆 —— 面板是点定额现建的(DOM 每次新建),
|
||||
创建时按记忆回放高度;容器还量不出尺寸(弹框未展开)就先不套,等下次创建。 */
|
||||
function rawVSplitInit(np) {
|
||||
const main = np.parentNode; // .rawmain
|
||||
const sp = document.createElement('div');
|
||||
sp.className = 'rawvsplit'; sp.id = 'rawvsplit';
|
||||
sp.innerHTML = '<span class="vsplitbtn" title="收起/展开子目工料机">▼</span>';
|
||||
main.insertBefore(sp, np);
|
||||
const btn = sp.querySelector('.vsplitbtn');
|
||||
const mh = panelMemLoad('rawnorm', 120, 1000000); // 决策 48:恢复上次拖的面板高
|
||||
const mhMax = Math.max(200, main.getBoundingClientRect().height * 0.75);
|
||||
if (mh && main.getBoundingClientRect().height > 0) {
|
||||
np.style.maxHeight = 'none';
|
||||
np.style.height = Math.min(mhMax, mh) + 'px';
|
||||
}
|
||||
let drag = null; // {y0, h0} 拖动起点与起始面板高
|
||||
sp.addEventListener('mousedown', e => {
|
||||
if (e.target === btn) return; // 把手只管收展,不参与拖动
|
||||
drag = { y0: e.clientY, h0: np.getBoundingClientRect().height };
|
||||
document.body.classList.add('rawrow-dragging');
|
||||
e.preventDefault();
|
||||
});
|
||||
document.addEventListener('mousemove', e => {
|
||||
if (!drag) return;
|
||||
const max = Math.max(200, main.getBoundingClientRect().height * 0.75);
|
||||
const h = Math.round(Math.min(max, Math.max(120, drag.h0 - (e.clientY - drag.y0))));
|
||||
np.style.maxHeight = 'none'; // 松开 CSS 的 40% 封顶,改听内联高度
|
||||
np.style.height = h + 'px';
|
||||
});
|
||||
document.addEventListener('mouseup', () => {
|
||||
if (!drag) return;
|
||||
panelMemSave('rawnorm', parseFloat(np.style.height) || 0); // 决策 48:拖完存记忆
|
||||
drag = null;
|
||||
document.body.classList.remove('rawrow-dragging');
|
||||
});
|
||||
btn.addEventListener('click', () => {
|
||||
const off = np.style.display === 'none';
|
||||
np.style.display = off ? '' : 'none';
|
||||
btn.textContent = off ? '▼' : '▲';
|
||||
btn.title = off ? '收起子目工料机' : '展开子目工料机';
|
||||
});
|
||||
}
|
||||
/* ---- 树 / 内容 分隔条(2026-10-07,主人要求)----
|
||||
① 按住分隔条左右拖 = 改左树宽度(150 ~ 560px,决策 48 起跨页/跨开关记忆);
|
||||
② 分隔条正中间一个小把手,点一下 = 收起/展开整棵树(树收起后把手仍在,随时点回来)。
|
||||
@@ -1562,8 +1598,7 @@ function RawView(opt) {
|
||||
RVSEL = { k: 'proj', id: 0 }; RVTAB = 'sum'; RVLV = 2;
|
||||
RVOPEN = null; RVROOT = true; // 换工程 / 重开明细:展开状态回到「默认全开」
|
||||
RV_LME_SORT = { k: -1, dir: 1 }; // 排序状态同步复位
|
||||
RV_NORM_CACHE = {}; // 换工程:定额面板缓存清空(不同工程定额 id 空间不同)
|
||||
rawPanelClose();
|
||||
haoPopClose(); // 换工程 / 重开明细:工料机浮层跟按钮脱钩,一并收掉
|
||||
drawRawTree(); rawTabs(); await rawDraw();
|
||||
}
|
||||
};
|
||||
@@ -2129,7 +2164,7 @@ function licEnsureStyle() {
|
||||
'.lic-row label{display:block;color:#51606f;margin-bottom:4px;font-size:12.5px}\n' +
|
||||
'.lic-row input{width:100%;padding:8px 10px;border:1px solid #c8d2dd;border-radius:6px;\n' +
|
||||
' font-size:13px;box-sizing:border-box;font-family:inherit}\n' +
|
||||
'.lic-tip{margin-top:12px;color:#8a97a5;font-size:12px;line-height:1.7}\n' +
|
||||
'.lic-sep{margin:10px 0 6px;padding-top:8px;border-top:1px solid #e3e6ee;font-weight:600;color:#33475b}.lic-tip{margin-top:12px;color:#8a97a5;font-size:12px;line-height:1.7}\n' +
|
||||
'.btn.lic-warn{color:#b02a2a;border-color:#e4b6b6;background:#fdf3f3;font-weight:600}';
|
||||
document.head.appendChild(st);
|
||||
}
|
||||
@@ -2196,6 +2231,9 @@ function licDlg() {
|
||||
'<input type="file" id="licImpFile" accept=".json,application/json" onchange="licImpPick(this)"></div>' +
|
||||
'<div id="licImpPv" class="lic-st" style="display:none"></div>' +
|
||||
'</div>' +
|
||||
'<div class="lic-sep">MCP 接入(AI 助手调用本软件 · 仅限本机内部通讯)</div>' +
|
||||
'<div id="mcpSt" class="lic-st">加载中…</div>' +
|
||||
'<div class="lic-btns"><button class="btn" id="mcpTg" onclick="mcpToggle()">加载中…</button></div>' +
|
||||
'<div class="lic-tip">续费由软件提供方在授权平台操作,在线状态下一分钟内自动生效,无需重装;' +
|
||||
'「立即刷新授权」可手动联网续租。激活密钥只保存在本机(Windows 加密存储),不会上传到别处。</div>' +
|
||||
'</div></div>';
|
||||
@@ -2211,9 +2249,32 @@ function licDlg() {
|
||||
const ipv = document.getElementById('licImpPv');
|
||||
if (ipv) { ipv.style.display = 'none'; ipv.innerHTML = ''; }
|
||||
licLoad();
|
||||
mcpLoad();
|
||||
clearInterval(_licPoll);
|
||||
_licPoll = setInterval(licLoad, 15000);
|
||||
}
|
||||
function mcpLoad() {
|
||||
fetch('/api/mcp/status').then(r => r.json()).then(d => {
|
||||
const el = document.getElementById('mcpSt');
|
||||
if (!el) return;
|
||||
let h = '状态:' + (d.enabled ? '<b class="ok">已开启(AI 可连接)</b>'
|
||||
: '<b class="bad">已关闭(不可连接)</b>') + '<br>';
|
||||
if (d.enabled) {
|
||||
h += '端点:http://127.0.0.1:' + d.port + '/mcp(仅限本机,数据不出电脑)<br>';
|
||||
h += '令牌:<input readonly spellcheck="false" style="width:250px" value="' + d.token + '">(AI 客户端按 Bearer 令牌填)<br>';
|
||||
h += '工具 ' + d.tools + ' 个 | 收费挂钩:' + (d.license_enforced ? '启用(未授权/过期自动断开)' : '开发模式不强制');
|
||||
}
|
||||
el.innerHTML = h;
|
||||
const b = document.getElementById('mcpTg');
|
||||
if (b) b.textContent = d.enabled ? '关闭 MCP 接入(断开)' : '打开 MCP 接入(可连接)';
|
||||
window._mcpOn = !!d.enabled;
|
||||
}).catch(() => {});
|
||||
}
|
||||
function mcpToggle() {
|
||||
fetch('/api/admin/mcp', {method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({enabled: !window._mcpOn})})
|
||||
.then(r => r.json()).then(() => mcpLoad());
|
||||
}
|
||||
function licClose() {
|
||||
const m = document.getElementById('licMask');
|
||||
if (m) m.classList.remove('on');
|
||||
@@ -2222,6 +2283,7 @@ function licClose() {
|
||||
function licLoad() {
|
||||
fetch('/api/license/status').then(r => r.json())
|
||||
.then(j => licRender(j.data || {})).catch(() => licRender(null));
|
||||
mcpLoad();
|
||||
}
|
||||
function licRender(d) {
|
||||
const el = document.getElementById('licSt');
|
||||
|
||||
@@ -61,7 +61,7 @@ a:hover{text-decoration:underline}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="common.js?v=20261013p"></script>
|
||||
<script src="common.js?v=20261016a"></script>
|
||||
<script>
|
||||
/* 会话管理页:照后台「项目界面」的版式,管的是**还没入库**的工作台会话。
|
||||
会话库不自动清(SESSION_KEEP_DAYS=0),要删只能在这里手动删。
|
||||
|
||||
@@ -156,6 +156,26 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
#histbar .hb:disabled{opacity:.45;cursor:not-allowed}
|
||||
.mask{position:fixed;inset:0;background:rgba(20,30,45,.45);display:none;align-items:center;justify-content:center;z-index:99}
|
||||
.mask.on{display:flex}
|
||||
|
||||
/* ---- 合并工料机弹框(批次C,决策 69)---- */
|
||||
#mtree .mn{display:flex;align-items:center;gap:6px;padding:4px 10px;font-size:12.5px;border-bottom:1px solid #f1f5f9}
|
||||
#mtree .mn.root{background:#f4f8fc;font-size:13px}
|
||||
#mtree .mn.grp{background:#fafcff;font-weight:600;cursor:default}
|
||||
#mtree .tg2{width:14px;text-align:center;cursor:pointer;color:#2a4a70;font-weight:700;user-select:none}
|
||||
#mtree .mgrp{background:#fff}
|
||||
#mtree .mrow{padding-left:30px}
|
||||
/* 2026-10-16 规格 第9条:固定顶部表头(随滚动钉住)+ 行内 名称/规格 列 + 子级标记 */
|
||||
#mtree .mhead{position:sticky;top:0;z-index:1;background:#eef4fb;font-weight:600;color:#3d4c5e;padding-left:30px;border-bottom:1px solid #d9e4f0}
|
||||
#mtree .mhead .c{width:110px}
|
||||
#mtree .mhead .n,#mtree .mhead .s{width:130px}
|
||||
#mtree .mhead .r{width:84px;text-align:right}
|
||||
#mtree .mnm{display:inline-block;width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:middle}
|
||||
#mtree .mnm.spec{width:110px;color:#5b6b7e}
|
||||
#mtree .subtag{background:#fff4e0;color:#a06a00;border:1px solid #eed9ac;border-radius:8px;font-size:11px;padding:0 6px;margin-left:2px;cursor:help}
|
||||
#mtree input[type=text]{border:1px solid #d6e0ec;border-radius:3px;padding:1px 5px;font:inherit;outline:none}
|
||||
#mtree input[type=text]:focus{border-color:#7aa7d9}
|
||||
#mtree .mi.c{width:110px}
|
||||
#mtree .mi.n{width:84px;text-align:right}
|
||||
.dlg{background:#fff;border-radius:10px;width:640px;max-width:94vw;display:flex;flex-direction:column;overflow:hidden}
|
||||
.dlg h4{margin:0;padding:13px 18px;font-size:14.5px;border-bottom:1px solid var(--line);background:var(--head);color:var(--c1)}
|
||||
.dlg .mbody{padding:14px 18px;display:flex;flex-direction:column;gap:10px}
|
||||
@@ -288,13 +308,23 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
<div class="rawmain">
|
||||
<div class="stabs" id="rawstabs"></div>
|
||||
<div class="rawbody" id="rawbody"></div>
|
||||
<!-- 点定额 → 子目工料机(下方分区面板,可收起/展开) -->
|
||||
<div class="rawnorm" id="rawnorm" style="display:none"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel" id="pan0" data-page-node-id="DDAHOeXzG1G71JwXqlB8N4"><table id="t0" data-page-node-id="wiHjUkOHHtafQFK4AcMWUn"><colgroup id="cg0" data-page-node-id="jrukeg9ggS0DZO8eKSBXsM"></colgroup><thead id="th0" data-page-node-id="tapJmvtyFyqqAOcTTiKGJ3"></thead><tbody id="tb0" data-page-node-id="L018lJjmeSEfM31wIxkb05"></tbody></table></div>
|
||||
<div class="panel" id="pan1" data-page-node-id="E2RTvOEoRvCZtcfhCfJ9w6"><table id="t1" data-page-node-id="uDB6bv40IJMHhH2Ykznir2"><colgroup id="cg1" data-page-node-id="3VeUjy8WVpqGteUh9Wnadz"></colgroup><thead id="th1" data-page-node-id="DQAXEDDJ0ZCOU6Qq6JMzOV"></thead><tbody id="tb1" data-page-node-id="a5ErEx7b9uetj4GY0v9rZu"></tbody></table></div>
|
||||
<div class="panel" id="pan1" data-page-node-id="E2RTvOEoRvCZtcfhCfJ9w6">
|
||||
<!-- 决策 72(批次E续,2026-10-15 主人定):组价不一致清单与类似清单界面功能一致 —— 同款左树/重载行/层级按钮 -->
|
||||
<div class="grpbox">
|
||||
<div class="grptree" id="grptree1"></div>
|
||||
<div class="grpsplit" id="grpsplit1"><span class="gsplitbtn" title="收起/展开目录树">◀</span></div>
|
||||
<div class="grpmain">
|
||||
<div style="display:flex;align-items:center;gap:10px;padding:5px 10px;border-bottom:1px solid var(--line);background:#fafcff;position:sticky;top:0;z-index:5;height:34px;box-sizing:border-box">
|
||||
<a class="lk" onclick="reloadIncon()" title="按当前工程数据与规则重算组价不一致">⟳ 重载</a>
|
||||
<span class="rawLvMount" style="margin-left:auto;display:inline-flex;gap:4px;align-items:center"></span>
|
||||
</div>
|
||||
<table id="t1" data-page-node-id="uDB6bv40IJMHhH2Ykznir2"><colgroup id="cg1" data-page-node-id="3VeUjy8WVpqGteUh9Wnadz"></colgroup><thead id="th1" data-page-node-id="DQAXEDDJ0ZCOU6Qq6JMzOV"></thead><tbody id="tb1" data-page-node-id="a5ErEx7b9uetj4GY0v9rZu"></tbody></table></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel" id="pan2" data-page-node-id="sJrWUsXpYlY94eEzccAte7">
|
||||
<!-- 2026-10-08 主人定:类似清单=左组目录树(根=类似清单,二级=各组,点击定位到组头行)+ 现有分组大表。
|
||||
树的样式/拖宽/收起展开同原数据标签的左树;主区表格与渲染逻辑零改动。 -->
|
||||
@@ -306,7 +336,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
<div style="display:flex;align-items:center;gap:10px;padding:5px 10px;border-bottom:1px solid var(--line);background:#fafcff;position:sticky;top:0;z-index:5;height:34px;box-sizing:border-box">
|
||||
<a class="lk" onclick="reloadSim()" title="不用缓存,按当前工程数据与分组规则重新分组(工程大要稍等)">⟳ 重载</a>
|
||||
<!-- 原数据单位工程级的层级按钮挂点(2026-10-13 决策 58:分组/清单/定额/默认列宽 迁到这里最右) -->
|
||||
<span id="rawLvMount" style="margin-left:auto;display:inline-flex;gap:4px;align-items:center"></span>
|
||||
<span id="rawLvMount" class="rawLvMount" style="margin-left:auto;display:inline-flex;gap:4px;align-items:center"></span>
|
||||
</div>
|
||||
<table id="t2" data-page-node-id="ta5tNexyK4bepH302bOYRs"><colgroup id="cg2" data-page-node-id="I2Ng536RW9f2GJQevDwZru"></colgroup><thead id="th2" data-page-node-id="NomC50uaobhcg7IggoJT6G"></thead><tbody id="tb2" data-page-node-id="Gs6bHmPPPXWmG8SrazuW6d"></tbody></table></div>
|
||||
</div>
|
||||
@@ -417,6 +447,24 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 合并工料机(批次C,决策 69;主人定稿树形:±把手、默认全展开、默认勾编码最短、右上 取消|合并) -->
|
||||
<div class="mask" id="mmask">
|
||||
<div class="dlg" style="width:920px;max-width:94vw">
|
||||
<h4 style="display:flex;align-items:center;gap:10px">合并工料机
|
||||
<span style="flex:1"></span>
|
||||
<button class="btn" onclick="mergeApply()">合并</button>
|
||||
<button class="btn" onclick="mergeClose()" style="background:#fff;color:#5b6b7e;border:1px solid #c9d4e2">取消</button>
|
||||
</h4>
|
||||
<div class="mbody">
|
||||
<div id="mtree" style="max-height:58vh;overflow:auto;border:1px solid #e3eaf2;border-radius:6px"></div>
|
||||
<div style="padding-top:8px;color:#8a97a8;font-size:12px">
|
||||
按 名称|规格|单位 归组,仅列编码/价格有差异的组(全量未过滤,带子级组成的台班/配合比也在列);勾选要保留的行(默认勾编码最短),编码/除税价/税率/含税价可直接改;
|
||||
合并后未勾选的行隐藏(不删除);各单位工程汇总中同组母行只把编码替换为保留行编码、子级以保留行为准(规格 第11/12 条),单位工程页面实时更新,导出同步生效。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mask" id="omask" data-page-node-id="NHET3zdzD9HkyEVocucLLz">
|
||||
<div class="dlg" data-page-node-id="rf6sdICi1GOOGBHgzR39N6">
|
||||
<h4 data-page-node-id="035yfGifzpBoUZgrI6XnyA">打开项目</h4>
|
||||
@@ -472,7 +520,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="common.js?v=20261013p"></script>
|
||||
<script src="common.js?v=20261016a"></script>
|
||||
<script src="period.js"></script>
|
||||
<script>
|
||||
let SID=0, CUR=null, CURTYPE='lme', HROWS=[];
|
||||
@@ -539,11 +587,14 @@ function colg(el,cols){
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
var bar=$('tabbar'); if(bar) bar.innerHTML=tabsHTML();
|
||||
});
|
||||
/* 底部「历史比对」容器显隐(2026-10-08 主人定):只在 类似清单(p2)/项目工料机(p0) 显示 ——
|
||||
组价不一致清单(p1) 取消对比框;原数据(p3) 只读还原也没有。标题/范围文案已按主人要求删除。 */
|
||||
/* 底部「历史比对」容器显隐(决策 71,2026-10-15 主人定):四个标签全显示 ——
|
||||
组价不一致清单(p1) 搬回来(**推翻 2026-10-08「p1 取消对比框」口径**,以本次为准);
|
||||
原数据(p3) 的 分部分项/措施项目 按共享层规格⑥搬进来:默认折叠,选中清单行自动展开。 */
|
||||
function syncHist(p){
|
||||
const w=$('histwrap'); if(!w) return;
|
||||
w.classList.toggle('rawmode', p==='p3'||p==='p1');
|
||||
w.classList.remove('rawmode');
|
||||
if(p==='p3' && !(typeof CUR!=='undefined' && CUR && CURTYPE==='bill')) w.classList.add('folded');
|
||||
else w.classList.remove('folded');
|
||||
// 2026-10-08 主人定:筛选条按标签分工 —— 单价类型仅类似清单;来源/价格范围仅项目工料机;
|
||||
// 「单位」两标签共用(工料机侧 = 建设单位 OR 发行单位 联查,按钮文字/选项随标签切换)。
|
||||
const isLme = (p==='p0');
|
||||
@@ -581,6 +632,7 @@ function syncHist(p){
|
||||
if(!w.classList.contains('rawmode') && w.classList.contains('folded')) toggleFold();
|
||||
}
|
||||
async function tab(p){
|
||||
if(p!=='p3') haoPopClose(); // 工料机浮层(公共功能4)只在原数据标签有意义,切走就收
|
||||
document.querySelectorAll('.tab').forEach(t=>t.classList.toggle('on',t.dataset.p===p));
|
||||
['p0','p1','p2','p3'].forEach((x,i)=>$('pan'+i).classList.toggle('on',x===p));
|
||||
syncHist(p);
|
||||
@@ -609,6 +661,263 @@ var WB_RAW = RawView({
|
||||
});
|
||||
function loadRaw(){ return WB_RAW.load(); }
|
||||
|
||||
/* ==================== 共享层·清单编辑(批次A,决策 67)====================
|
||||
右键菜单(common.js document 级委托 → onBillCtxMenu 接线)+ 双击行内编辑 + 操作后原位刷新。
|
||||
四视图同源:这里改完,切到 类似清单/组价不一致 重拉即是新状态(服务端分组缓存已被 API 失效)。 */
|
||||
window.onBillCtxMenu = function(tr){
|
||||
if(!SID) return null;
|
||||
const bid = tr.dataset.bid;
|
||||
if(!bid) return null;
|
||||
if(tr.classList.contains('brow')) // 原数据行:五项(规格·新增功能1)
|
||||
return {items:['上方插入清单','下方插入清单','删除','临时删除','取消临时删除'],
|
||||
cb:t=>billCtxApply(t,bid)};
|
||||
return {items:['删除','临时删除','取消临时删除'], // 类似清单/组价不一致行:三项(决策 66 文案)
|
||||
cb:t=>billCtxApply(t,bid)};
|
||||
};
|
||||
const BILL_OP = {'上方插入清单':'insert_above','下方插入清单':'insert_below',
|
||||
'删除':'del','临时删除':'tdel','取消临时删除':'untdel'};
|
||||
async function billCtxApply(t, bid){
|
||||
const op = BILL_OP[t];
|
||||
if(!op || !SID) return;
|
||||
const r = await J('/api/session/bill/op',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID,op:op,bill_id:bid})});
|
||||
if(!r.ok){ $('msg').textContent = r.msg || '操作失败'; return; }
|
||||
$('msg').textContent = r.msg || ('已'+t);
|
||||
// 四视图同源的关键:**无论当前在哪个视图**,先撤原数据全部取数缓存——
|
||||
// 否则在类似清单页改的状态,切回原数据会命中旧缓存读到旧样子(验收实测踩过)
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
const cur = document.querySelector('.tab.on');
|
||||
const p = cur ? cur.dataset.p : 'p3';
|
||||
if(p==='p1') await loadGroups('inconsistent');
|
||||
else if(p==='p2') await loadGroups('similar');
|
||||
else await refreshRaw();
|
||||
}
|
||||
/* 共享层规格⑥(决策 71):原数据·分部分项/措施项目 选中清单行 → 底部历史对比框加载该行比对 */
|
||||
window.rawBillPick = function(tr){
|
||||
if(!SID) return;
|
||||
const bid = Number(tr.dataset.bid);
|
||||
if(!bid) return;
|
||||
$('histwrap').classList.remove('folded'); // 选中即展开对比框
|
||||
pick('bill', bid, tr);
|
||||
};
|
||||
|
||||
/* 导出回写(批次D,决策 70):按原格式下载本工程(全部编辑已体现为文件内容) */
|
||||
function exportSession(){
|
||||
if(!SID){ $('msg').textContent = '先打开工程再导出'; return; }
|
||||
$('msg').textContent = '正在按原格式导出(大工程稍等,浏览器会下载 zip 同款文件)…';
|
||||
location.href = '/api/session/export?session_id=' + SID;
|
||||
}
|
||||
|
||||
/* ==================== 合并工料机(批次C,决策 69;方案 §6)==================== */
|
||||
let MDATA = null;
|
||||
async function rawMergeOpen(){
|
||||
if(!SID) return;
|
||||
const d = await J('/api/session/lme/merge/groups?session_id=' + SID);
|
||||
if(!d || !d.ok){ $('msg').textContent = (d && d.msg) || '读取合并分组失败'; return; }
|
||||
MDATA = d;
|
||||
if(!d.groups.length){ $('msg').textContent = '没有可合并的组(项目级汇总里没有「名称|规格|单位相同但编码/价格不同」的工料机)'; return; }
|
||||
renderMergeTree();
|
||||
$('mmask').classList.add('on');
|
||||
}
|
||||
function mergeClose(){ $('mmask').classList.remove('on'); }
|
||||
function mTog(el){
|
||||
const open = el.dataset.open === '1';
|
||||
el.dataset.open = open ? '0' : '1';
|
||||
el.textContent = open ? '+' : '−';
|
||||
const box = el.parentElement.nextElementSibling;
|
||||
if (box) box.style.display = open ? 'none' : '';
|
||||
}
|
||||
function renderMergeTree(){
|
||||
// 2026-10-16 规格 第9条:不过滤带子数据的工料机(决策78 废止)+ 补固定顶部表头 编码|名称|规格|除税价|税率|含税价
|
||||
let h = '<div class="mn root"><span class="tg2">−</span><b>合并工料机</b>'
|
||||
+ '<span style="color:#8a97a8">' + MDATA.groups.length + ' 组(源自 ' + MDATA.n_rows + ' 行项目级汇总,全量未过滤)</span></div>'
|
||||
+ '<div class="mn mhead"><span style="width:13px"></span>'
|
||||
+ '<span class="hc c">编码</span><span class="hc n">名称</span><span class="hc s">规格</span>'
|
||||
+ '<span class="hc r">除税价</span><span class="hc r">税率</span><span class="hc r">含税价</span><span class="hc">数量</span></div>';
|
||||
MDATA.groups.forEach((g, gi) => {
|
||||
h += '<div class="mn grp"><span class="tg2" data-open="1" onclick="mTog(this)">−</span>'
|
||||
+ '<span title="名称|规格|单位">' + esc(g.name || '—') + ' | ' + esc(g.spec || '—') + ' | ' + esc(g.unit || '—') + '</span>'
|
||||
+ '<span style="color:#8a97a8">' + g.rows.length + ' 条</span></div>'
|
||||
+ '<div class="mgrp" data-gi="' + gi + '">'
|
||||
+ g.rows.map(r => '<div class="mn mrow">'
|
||||
+ '<input type="checkbox" data-mid="' + r.id + '"' + (r.def ? ' checked' : '') + ' title="勾选=保留,不勾=合并后隐藏">'
|
||||
+ '<input type="text" class="mi c" data-f="code" data-mid="' + r.id + '" value="' + esc(r.code || '') + '" placeholder="编码">'
|
||||
+ '<span class="mnm" title="' + esc(r.name || '') + '">' + esc(r.name || '—') + (r.sub
|
||||
? ' <span class="subtag" title="带子级组成(台班/配合比):合并后各单位工程的子级以保留行为准,原软件按子级重算母价">子级</span>' : '')
|
||||
+ '</span>'
|
||||
+ '<span class="mnm spec" title="' + esc(r.spec || '') + '">' + esc(r.spec || '—') + '</span>'
|
||||
+ '<input type="text" class="mi n" data-f="ntp" data-mid="' + r.id + '" value="' + (r.ntp == null ? '' : r.ntp) + '" placeholder="除税价">'
|
||||
+ '<input type="text" class="mi n" data-f="taxrate" data-mid="' + r.id + '" value="' + (r.taxrate == null ? '' : r.taxrate) + '" placeholder="税率">'
|
||||
+ '<input type="text" class="mi n" data-f="taxp" data-mid="' + r.id + '" value="' + (r.taxp == null ? '' : r.taxp) + '" placeholder="含税价">'
|
||||
+ '<span style="color:#8a97a8">数量 ' + num(r.qty, 3) + '</span>'
|
||||
+ '</div>').join('')
|
||||
+ '</div>';
|
||||
});
|
||||
$('mtree').innerHTML = h;
|
||||
}
|
||||
async function mergeApply(){
|
||||
const groups = [];
|
||||
document.querySelectorAll('#mtree .mgrp').forEach(box => {
|
||||
const keep = [], hide = [];
|
||||
Array.from(box.querySelectorAll('.mrow')).forEach(row => {
|
||||
const cb = row.querySelector('input[type=checkbox]');
|
||||
const id = Number(cb.dataset.mid);
|
||||
const get = f => { const i = row.querySelector('input[data-f="' + f + '"]'); return i ? i.value.trim() : ''; };
|
||||
if (cb.checked) keep.push({ id: id, code: get('code'), ntp: get('ntp'), taxrate: get('taxrate'), taxp: get('taxp') });
|
||||
else hide.push({ id: id });
|
||||
});
|
||||
groups.push({ keep: keep, hide: hide });
|
||||
});
|
||||
const r = await J('/api/session/lme/merge', { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ session_id: SID, groups: groups }) });
|
||||
if(!r || !r.ok){ $('msg').textContent = (r && r.msg) || '合并失败'; return; }
|
||||
mergeClose();
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
await rawDraw();
|
||||
$('msg').textContent = '合并完成:保留 ' + r.kept + ' 行(含改值)、隐藏 ' + r.hidden + ' 行';
|
||||
}
|
||||
|
||||
/* 操作后原位刷新原数据:撤本会话取数缓存 → 重拉目录树 → 按当前选中/标签重画(不跳回项目根) */
|
||||
async function refreshRaw(){
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
try{
|
||||
RVT = await rawFetch('/tree', _qid(RVO.idParam, SID));
|
||||
RV_CACHE['tree|'+SID] = RVT;
|
||||
}catch(e){ return; }
|
||||
drawRawTree(); rawTabs(); await rawDraw();
|
||||
}
|
||||
/* ---- 双击行内编辑(规格4/5:清单 名称|项目特征|工程量|备注,定额 名称|工程量)----
|
||||
格位对应 rawTreeHTML:0把手 1序号 2编码 3类型 4名称 5特征 6单位 7工程量 8单价 9合价 10取消采纳 11备注 */
|
||||
document.addEventListener('dblclick', function(e){
|
||||
if(!SID) return;
|
||||
const td = e.target.closest && e.target.closest('#rawbody td');
|
||||
if(!td || td.querySelector('input')) return;
|
||||
const tr = td.closest('tr'); if(!tr) return;
|
||||
const idx = Array.prototype.indexOf.call(tr.children, td);
|
||||
let api=null, id=null, field=null;
|
||||
if(tr.classList.contains('brow') && tr.dataset.bid){
|
||||
const F = {4:'Name',5:'Attr',7:'Quantity',11:'Remark'};
|
||||
if(F[idx]){ api='bill'; id=tr.dataset.bid; field=F[idx]; }
|
||||
} else if(tr.classList.contains('sub') && tr.dataset.nid){
|
||||
const F = {4:'Name',7:'Quantity'};
|
||||
if(F[idx]){ api='norm'; id=tr.dataset.nid; field=F[idx]; }
|
||||
} else if(tr.classList.contains('lmerow') && tr.dataset.lmeid && RV_LME_DS){
|
||||
// 2026-10-16 主人口径:项目级工料机汇总 除税编制价|税率|含税编制价 三格可改(单位级行无 data-lmeid=只读)。
|
||||
// 视图下标经 RV_LME_DS 映射到数据下标:6=除税编制价 7=税率 8=含税编制价。
|
||||
const dk = RV_LME_DS[idx];
|
||||
if(dk===6 || dk===7 || dk===8){ api='lme'; field=({6:'ntp',7:'taxrate',8:'taxp'})[dk]; }
|
||||
}
|
||||
if(!api) return;
|
||||
e.preventDefault();
|
||||
const cur0 = td.textContent.trim();
|
||||
if(api==='lme'){ lmeEditCell(td, tr, field, (cur0==='—'?'':cur0)); return; }
|
||||
editCell(td, api, id, field, (cur0==='—'?'':cur0));
|
||||
});
|
||||
function editCell(td, api, id, field, cur){
|
||||
const inp = document.createElement('input');
|
||||
inp.className = 'cellin'; inp.value = cur; inp.spellcheck = false;
|
||||
td.textContent = ''; td.appendChild(inp);
|
||||
inp.focus(); inp.select();
|
||||
let done = false;
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
const v = inp.value.trim();
|
||||
if(!save || v === cur){ td.textContent = cur; return; }
|
||||
const body = {session_id:SID, fields:{}};
|
||||
body.fields[field] = v;
|
||||
if(api==='norm') body.norm_id = id;
|
||||
else { body.op='edit'; body.bill_id = id; }
|
||||
const r = await J('/api/session/'+api+'/op',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify(body)});
|
||||
if(!r.ok){ $('msg').textContent = r.msg || '保存失败'; td.textContent = cur; return; }
|
||||
$('msg').textContent = '已保存';
|
||||
await refreshRaw();
|
||||
};
|
||||
inp.addEventListener('keydown', ev=>{
|
||||
if(ev.key==='Enter'){ ev.preventDefault(); fin(true); }
|
||||
else if(ev.key==='Escape'){ fin(false); }
|
||||
});
|
||||
inp.addEventListener('blur', ()=>fin(true));
|
||||
}
|
||||
|
||||
/* ==================== 工料机汇总 三价行内编辑(2026-10-16 主人口径)====================
|
||||
仅项目级工料机汇总(行带 data-lmeid);单位工程级保持只读。
|
||||
恒满足 除税编制价 × (1 + 税率/100) = 含税编制价,金额四舍五入 2 位,税率空按 0:
|
||||
改除税 → 按当前税率算含税;改税率 → 按当前除税算含税;改含税 → 反解除税。
|
||||
交互沿用 editCell 口径(失焦/Enter 提交、Esc 取消、无防抖);提交成功后本地行原位
|
||||
同步三个格(序号/排序不动),RV_LME_ROWS 同步改,本会话其余视图缓存撤掉(单位级
|
||||
汇总按编码同步过,不能读旧值),当前视图 DOM 写回缓存。 */
|
||||
const LME_FIELDS = { ntp: 6, taxrate: 7, taxp: 8 }; // 字段 → 数据 r[] 下标
|
||||
function lmePriceCells(tr){
|
||||
const out = {};
|
||||
Array.prototype.forEach.call(tr.children, (td, i) => {
|
||||
const dk = RV_LME_DS ? RV_LME_DS[i] : null;
|
||||
if(dk===6 || dk===7 || dk===8) out[{6:'ntp',7:'taxrate',8:'taxp'}[dk]] = td;
|
||||
});
|
||||
return out;
|
||||
}
|
||||
// 表格显示值带 zh-CN 千分位(rm 的输出),解析要去掉逗号;'—'/空 = null
|
||||
function lmeParseNum(s){
|
||||
const t = String(s == null ? '' : s).replace(/,/g, '').trim();
|
||||
if(t === '' || t === '—') return null;
|
||||
const n = Number(t);
|
||||
return isFinite(n) ? n : NaN;
|
||||
}
|
||||
const lmeRound2 = v => Math.round((v + Number.EPSILON) * 100) / 100;
|
||||
function lmeEditCell(td, tr, field, cur){
|
||||
const cells = lmePriceCells(tr);
|
||||
const curV = f => lmeParseNum(cells[f].textContent);
|
||||
const inp = document.createElement('input');
|
||||
inp.className = 'cellin'; inp.value = cur; inp.spellcheck = false;
|
||||
td.textContent = ''; td.appendChild(inp);
|
||||
inp.focus(); inp.select();
|
||||
let done = false;
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
const v = inp.value.trim();
|
||||
if(!save || v === cur){ td.textContent = cur; return; }
|
||||
const nv = lmeParseNum(v);
|
||||
if(nv !== null && Number.isNaN(nv)){ $('msg').textContent = '请输入数字'; td.textContent = cur; return; }
|
||||
// 前端即时联动(服务端同口径复核,以后端返回值为准回填三格)
|
||||
let ntp, taxrate, taxp;
|
||||
if(field === 'ntp'){
|
||||
ntp = nv;
|
||||
taxrate = curV('taxrate');
|
||||
taxp = ntp == null ? null : lmeRound2(ntp * (1 + (taxrate || 0) / 100));
|
||||
} else if(field === 'taxrate'){
|
||||
taxrate = nv;
|
||||
ntp = curV('ntp');
|
||||
taxp = lmeRound2((ntp || 0) * (1 + (taxrate || 0) / 100));
|
||||
} else {
|
||||
taxp = nv;
|
||||
taxrate = curV('taxrate');
|
||||
const div = 1 + (taxrate || 0) / 100;
|
||||
if(div === 0){ $('msg').textContent = '税率为 -100,无法反解除税价'; td.textContent = cur; return; }
|
||||
ntp = taxp == null ? null : lmeRound2(taxp / div);
|
||||
}
|
||||
const r = await J('/api/session/lme/price', {method:'POST', headers:{'Content-Type':'application/json'},
|
||||
body: JSON.stringify({session_id:SID, id:Number(tr.dataset.lmeid), ntp:ntp, taxrate:taxrate, taxp:taxp})});
|
||||
if(!r || !r.ok){ $('msg').textContent = (r && r.msg) || '保存失败'; td.textContent = cur; return; }
|
||||
// 服务端复核后的三值原位回填(本地行/排序/序号都不动)
|
||||
cells.ntp.textContent = rm(r.ntp);
|
||||
cells.taxrate.textContent = rm(r.taxrate);
|
||||
cells.taxp.textContent = rm(r.taxp);
|
||||
if(RV_LME_IDS){
|
||||
const ri = RV_LME_IDS.indexOf(Number(tr.dataset.lmeid));
|
||||
if(ri >= 0 && RV_LME_ROWS[ri]){ RV_LME_ROWS[ri][6]=r.ntp; RV_LME_ROWS[ri][7]=r.taxrate; RV_LME_ROWS[ri][8]=r.taxp; }
|
||||
}
|
||||
const ck = _rvCacheKey(); // 当前视图写回缓存;本会话其余视图缓存撤掉(单位级同步过)
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0 && k!==ck) delete RV_CACHE[k]; });
|
||||
rvCachePut();
|
||||
$('msg').textContent = '已保存' + (r.synced ? '(已同步 ' + r.synced + ' 个单位工程汇总)' : '');
|
||||
};
|
||||
inp.addEventListener('keydown', ev=>{
|
||||
if(ev.key==='Enter'){ ev.preventDefault(); fin(true); }
|
||||
else if(ev.key==='Escape'){ fin(false); }
|
||||
});
|
||||
inp.addEventListener('blur', ()=>fin(true));
|
||||
}
|
||||
|
||||
/* ---------- 打开工程 ---------- */
|
||||
async function openDlg(){
|
||||
$('ofile').value=''; $('oname').value=''; $('oname').dataset.auto=''; $('omsg').textContent='';
|
||||
@@ -790,6 +1099,12 @@ async function loadGroups(kind, fresh){
|
||||
// 2026-10-08 主人定:类似清单左组目录树 —— 点根=显示全部,点组=只显示该组(后台同款)
|
||||
// 点选行为在公共层 grpTreeBind(两侧唯一实现),本页只给树容器和表体 id
|
||||
if(kind==='similar') grpTreeBind($('grptree'), 'tb2', d);
|
||||
else grpTreeBind($('grptree1'), 'tb1', d, { kind: 'inconsistent', rootName: '组价不一致清单' });
|
||||
}
|
||||
|
||||
/* ⟳ 重载(组价不一致,决策 72):与类似清单 reloadSim 同款 */
|
||||
function reloadIncon(){
|
||||
ldWrap('', '正在重算组价不一致…', ()=>loadGroups('inconsistent', true));
|
||||
}
|
||||
|
||||
/* ⟳ 重载(决策 46):跳过服务端缓存,按当前数据与分组规则强制重新分组 */
|
||||
@@ -1087,6 +1402,19 @@ async function adopt(i){
|
||||
const x=VISIBLE_ROWS[i]; if(!x) return;
|
||||
if(CURTYPE!=='bill') return; // 双保险:非清单一律不写
|
||||
const tr=document.querySelector('tr.sel'); if(!tr) return;
|
||||
// ① 数据采纳(决策 68 批次B:规格 9.1 新增清单覆盖 / 9.3 原清单定额追加+原定额临删 /
|
||||
// 9.4 汇总品类追加)。有 bill_id 的入库清单行才落数据;连续采纳认最后一次(服务端语义)。
|
||||
let r0=null;
|
||||
if(x.bill_id){
|
||||
try{
|
||||
r0=await J('/api/session/bill/adopt',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID,bill_id:CUR.id,src_bill_id:x.bill_id})});
|
||||
}catch(e){ r0=null; }
|
||||
if(!r0 || !r0.ok){ dlMsg('采纳失败:'+(r0&&r0.msg?r0.msg:'服务未响应'),'err'); return; }
|
||||
// 定额构成变了:撤原数据取数缓存(切页重拉即新状态,与 billCtxApply 同口径)
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
}
|
||||
// ② 采纳备注照旧(记录采纳了哪条、什么价——灰「已采纳」徽标与「取消采纳」列的数据源)
|
||||
const txt=`采纳:${x.name||''} ${Number(x.price).toFixed(2)} ${x.proj||''}`;
|
||||
let r=null;
|
||||
try{
|
||||
@@ -1094,34 +1422,42 @@ async function adopt(i){
|
||||
body:JSON.stringify({bill_id:CUR.id,remark:txt})});
|
||||
}catch(e){ r=null; }
|
||||
if(!r || !r.ok){ dlMsg('备注写入失败:'+(r&&r.msg?r.msg:'服务未响应'),'err'); return; }
|
||||
const row=grpRowById(CUR.id);
|
||||
if(row){ row[10]=txt;
|
||||
// 就地更新「取消采纳」+「备注」两格(显示位=末两列;数据先行,重渲染不丢)
|
||||
const cAdopt=tr.children[tr.children.length-2], cRem=tr.children[tr.children.length-1];
|
||||
if(cAdopt) cAdopt.innerHTML=billAdoptCellHTML(row);
|
||||
if(cRem) cRem.innerHTML=billRemarkCell(row);
|
||||
}
|
||||
// ③ 刷新当前视图(9.1 清单行字段被覆盖、9.3 追加定额带临删——重拉才是真状态)
|
||||
const cur=document.querySelector('.tab.on');
|
||||
const p=cur?cur.dataset.p:'p2';
|
||||
if(p==='p1') await loadGroups('inconsistent');
|
||||
else if(p==='p2') await loadGroups('similar');
|
||||
else await refreshRaw();
|
||||
renderHist(); // 已采纳灰标记:旧行复原、新行点亮(传递)
|
||||
dlMsg('已采纳,写入清单备注:'+txt,'ok');
|
||||
dlMsg('已采纳'+(r0?('('+r0.mode+':定额 '+r0.n_norm+' 条'+(r0.n_sum?('、汇总补品类 '+r0.n_sum+' 行'):'')+')'):'(仅备注)')+':'+txt,'ok');
|
||||
}
|
||||
/* 清单取消采纳(2026-10-09 主人定):只清备注,不动「询价附件」目录(清单采纳本就不收附件)。
|
||||
2026-10-11:上方行数据/备注格同步清空,对比框灰「已采纳」复原为「采纳」(renderHist)。 */
|
||||
async function cancelBillAdopt(billId, el){
|
||||
if(!confirm('取消采纳:清空该清单的采纳备注。(清单采纳不收集附件,目录不受影响)确定?')) return;
|
||||
if(!confirm('取消采纳:撤销采纳的数据(追加定额撤下、原定额恢复、汇总追加行撤下、新增清单清回空行)并清空采纳备注。确定?')) return;
|
||||
// ① 数据反向(决策 68 批次B;仅有备注式采纳时服务端 noop,不报错)
|
||||
let r=null;
|
||||
try{
|
||||
r=await J('/api/session/remark',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({bill_id:billId,remark:''})});
|
||||
r=await J('/api/session/bill/unadopt',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID,bill_id:billId})});
|
||||
}catch(e){ r=null; }
|
||||
if(!r || !r.ok){ dlMsg('取消采纳失败:'+(r&&r.msg?r.msg:'服务未响应'),'err'); return; }
|
||||
const row=grpRowById(billId);
|
||||
if(row) row[10]='';
|
||||
const tr0=el&&el.closest('tr');
|
||||
if(tr0){ const cAdopt=tr0.children[tr0.children.length-2], cRem=tr0.children[tr0.children.length-1];
|
||||
if(cAdopt) cAdopt.innerHTML=billAdoptCellHTML(row||[]);
|
||||
if(cRem) cRem.innerHTML=''; }
|
||||
// ② 备注清空(照旧)
|
||||
let r2=null;
|
||||
try{
|
||||
r2=await J('/api/session/remark',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({bill_id:billId,remark:''})});
|
||||
}catch(e){ r2=null; }
|
||||
if(!r2 || !r2.ok){ dlMsg('取消采纳失败:'+(r2&&r2.msg?r2.msg:'备注清空未响应'),'err'); return; }
|
||||
// ③ 刷新当前视图(原数据/组表都可能是取消来源;撤缓存重拉即真状态)
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
const cur=document.querySelector('.tab.on');
|
||||
const p=cur?cur.dataset.p:'p2';
|
||||
if(p==='p1') await loadGroups('inconsistent');
|
||||
else if(p==='p2') await loadGroups('similar');
|
||||
else await refreshRaw();
|
||||
renderHist();
|
||||
dlMsg('已取消采纳,清单备注已清空','ok');
|
||||
dlMsg('已取消采纳'+(r.noop?'(该清单无数据采纳,仅清了备注)':'(数据已反向恢复)'),'ok');
|
||||
}
|
||||
|
||||
/* 工料机采纳(2026-10-08 主人定):把这条历史价写进上方选中工料机的备注。
|
||||
@@ -1558,8 +1894,9 @@ document.addEventListener('mouseup', function(){
|
||||
|
||||
/* 类似清单左树分隔条(2026-10-08 主人定):拖动改树宽 150~560、中央小把手收起/展开 —— 与原数据左树一致。
|
||||
2026-10-13 决策 48:树宽入公共记忆(panelMem)——切页/关窗重开都照记忆恢复。 */
|
||||
(function(){
|
||||
const gt=$('grptree'), gs=$('grpsplit'); if(!gt||!gs) return;
|
||||
/* 类似清单/组价不一致 两棵左树的分隔条(决策 72):同款拖宽/收展/记忆(宽度记忆共用=两树同宽) */
|
||||
function initGrpSplit(gtId, gsId){
|
||||
const gt=$(gtId), gs=$(gsId); if(!gt||!gs) return;
|
||||
const btn=gs.querySelector('.gsplitbtn');
|
||||
{ const mw=panelMemLoad('grptree',150,560); if(mw) gt.style.width=mw+'px'; } // 进页面先恢复
|
||||
let gx0=0, gw0=0, gdrag=false;
|
||||
@@ -1582,7 +1919,9 @@ document.addEventListener('mouseup', function(){
|
||||
btn.textContent=closed?'▶':'◀';
|
||||
btn.title=closed?'展开目录树':'收起目录树';
|
||||
});
|
||||
})();
|
||||
}
|
||||
initGrpSplit('#grptree', '#grpsplit');
|
||||
initGrpSplit('#grptree1', '#grpsplit1');
|
||||
|
||||
/* 进页面就初始化:单价类型 + 地区树 + 建设单位选项(不依赖先打开工程) */
|
||||
async function initFilters(){
|
||||
|
||||
Reference in New Issue
Block a user