feat(workbench): 工程量公式、另存为导出与字段编辑历史等多项功能
This commit is contained in:
@@ -6,10 +6,19 @@
|
||||
<style>
|
||||
:root{--c1:#123a6b;--c2:#1f5fae;--line:#e2e8f0;--head:#f6f9fd;--muted:#7b8794}
|
||||
*{box-sizing:border-box}
|
||||
body{margin:0;font:13px/1.5 -apple-system,"Segoe UI","Microsoft YaHei",sans-serif;color:#1f2937;background:#f5f6f8;height:100vh;display:flex;flex-direction:column}
|
||||
.btn{padding:5px 12px;border:1px solid #b8c4d4;border-radius:6px;background:#fff;cursor:pointer;font:inherit;font-size:12.5px;color:#26405e;text-decoration:none;display:inline-block}
|
||||
.btn:hover{background:#f2f6fb}
|
||||
body{margin:0;font:13px/1.5 "Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSans","HarmonyOS Sans SC","Microsoft YaHei",sans-serif;color:#1f2937;background:#f5f6f8;height:100vh;display:flex;flex-direction:column}
|
||||
.btn{display:inline-flex;align-items:center;justify-content:center;gap:4px;height:28px;padding:0 12px;border:1px solid #b8c4d4;border-radius:6px;background:#fff;cursor:pointer;font:inherit;font-size:12.5px;color:#26405e;text-decoration:none;line-height:1;white-space:nowrap;vertical-align:middle;user-select:none}
|
||||
.btn:hover{background:#eef3fa}
|
||||
.btn:active{background:#e0effc}
|
||||
.btn.pri{background:var(--c2);border-color:var(--c2);color:#fff;font-weight:600}
|
||||
.tabs .btn{height:24px;padding:0 9px;font-size:12px;border-radius:5px}
|
||||
/* 语言段(规格2:最左 简体/繁体/English);工作态蓝底(规格5) */
|
||||
.langseg{display:inline-flex}
|
||||
.langseg button{height:24px;padding:0 9px;font-size:12px;border:1px solid #b8c4d4;border-right-width:0;background:#fff;color:#26405e;cursor:pointer;font-family:inherit;line-height:1;user-select:none}
|
||||
.langseg button:first-child{border-radius:5px 0 0 5px}
|
||||
.langseg button:last-child{border-right-width:1px;border-radius:0 5px 5px 0}
|
||||
.langseg button:hover{background:#eef3fa}
|
||||
.langseg button.on{background:var(--c2);border-color:var(--c2);color:#fff;font-weight:600}
|
||||
/* ---- 标签栏(2026-09-29:原 A 区顶栏删除,两个按钮移到这里右侧,工程信息放中间;高度调低)---- */
|
||||
.tabs{display:flex;align-items:center;gap:2px;padding:0 16px;background:#fff;border-bottom:2px solid var(--c1);min-height:34px}
|
||||
.tab{padding:4px 14px;cursor:pointer;color:#456;font-size:13px;border-bottom:2px solid transparent;margin-bottom:-2px;line-height:1.35}
|
||||
@@ -27,6 +36,8 @@ body{margin:0;font:13px/1.5 -apple-system,"Segoe UI","Microsoft YaHei",sans-seri
|
||||
#pan3{overflow:hidden}
|
||||
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)与表头都固定 */
|
||||
#t1 thead th,#t2 thead th{top:34px}
|
||||
td{padding:5px 8px;border-bottom:1px solid #eef1f6;border-right:1px solid #f4f6f9;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
/* 来源徽章(2026-10-08 主人定,仅项目工料机对比框):工程绿 / 信息价蓝 / 市场价橙 */
|
||||
.srcbadge{display:inline-block;padding:1px 7px;border-radius:9px;font-size:11px;line-height:16px;white-space:nowrap}
|
||||
@@ -36,7 +47,7 @@ td{padding:5px 8px;border-bottom:1px solid #eef1f6;border-right:1px solid #f4f6f
|
||||
/* 规格型号灰字(结果表名称列第二行,工料机比价的关键区分项) */
|
||||
.spec2{display:block;color:#8a97a8;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
tbody tr:hover td{background:#f6f9fd}
|
||||
tr.sel td{background:#e0effc} /* 选中行=淡蓝无边框(2026-10-11 主人定,全软件统一;common.css 有同款全局规则) */
|
||||
tr.sel td, tr.subsel td{background:#d8e9fc} /* 选中行=淡蓝(规格 2026-10-16③:点选格 .cellhit=#a8e3d2、整行绿框,统一样式在 common.css) */
|
||||
.c{text-align:center}.r{text-align:right}.num{text-align:right;font-variant-numeric:tabular-nums}
|
||||
/* 项目特征:原文里一个换行符都没有(实测 0 条),全靠 (1) / 1、 / 1. 这种编号写法,
|
||||
pre-wrap 只对「已存在的 \n」生效 —— 所以必须由 fmtAttr() 先按编号拆行,这里再负责折行与顶对齐 */
|
||||
@@ -273,7 +284,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
.inqfoot{display:flex;align-items:center;justify-content:space-between;gap:10px}
|
||||
.inqfoot .cnt{font-size:12px;color:#5a6b7e}
|
||||
</style>
|
||||
<link rel="stylesheet" href="common.css">
|
||||
<link rel="stylesheet" href="common.css?v=20261017c">
|
||||
</head>
|
||||
<body data-page-node-id="ACmQmECh3NUWp5TCbBL7BM">
|
||||
|
||||
@@ -287,16 +298,25 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
<div class="tabright" data-page-node-id="sOfM468xWOKqTjwNbIVMFC">
|
||||
<!-- 2026-10-10 主人定:右上按钮一字排开,从左到右 =
|
||||
分组/匹配 → 后台管理 → 询价附件 → 最近审核 → 打开项目。 -->
|
||||
<button class="btn" onclick="cfgOpen()" title="类似清单分组 / 历史匹配过滤词">⚙ 分组&过滤</button>
|
||||
<!-- 语言条(规格 工具栏2:最左 简体/繁体/English;工作态蓝底) -->
|
||||
<div class="langseg" id="langseg" title="语言 / Language">
|
||||
<button type="button" data-lang="zh-CN" class="on">简体</button>
|
||||
<button type="button" data-lang="zh-TW">繁体</button>
|
||||
<button type="button" data-lang="en">English</button>
|
||||
</div>
|
||||
<button class="btn" onclick="cfgOpen()" title="类似清单分组 / 历史匹配过滤词" data-i18n="btn.cfg">分组&过滤</button>
|
||||
<!-- 时间戳参数:老 WebView2 对 no-store 不完全遵守,跨页跳转带新 URL 强制绕缓存(2026-10-12) -->
|
||||
<a class="btn" href="javascript:location.href='/admin.html?v='+Date.now()" data-page-node-id="soJGFd2PWIpS6Hbp6B2s0w">后台管理</a>
|
||||
<a class="btn" href="javascript:location.href='/admin.html?v='+Date.now()" data-page-node-id="soJGFd2PWIpS6Hbp6B2s0w" data-i18n="btn.admin">后台管理</a>
|
||||
<!-- 询价附件(2026-10-09 改版;2026-10-10 决策 28 改会话级 主人定):**常驻按钮**。
|
||||
数据 = 当前会话在对比框点「采纳」收进来的附件(按内容去重;切会话跟着切,删会话才清,
|
||||
没打开项目=空),不再是后台绑定关系的只读展示。 -->
|
||||
<!-- 导出(规格 工料机汇总13:上升一级放询价附件左边,只能导工作台数据;蓝底主按钮) -->
|
||||
<button class="btn pri" onclick="exportSession()" data-i18n="btn.export"
|
||||
title="按原格式导出本工程(含全部编辑:临删已省略、新增/采纳已写入)。只能对工作台的数据进行导出">导出</button>
|
||||
<button class="btn" id="btnInq" onclick="openInq()"
|
||||
title="当前会话收进的附件目录(切会话跟着切,删会话才清);勾选后可批量下载">询价附件</button>
|
||||
<a class="btn" href="javascript:location.href='/sessions.html?t='+Date.now()">最近审核</a>
|
||||
<button class="btn pri" onclick="openDlg()" data-page-node-id="rlEedAWfYgLJDVpuFxmmxq">打开项目</button>
|
||||
title="当前会话收进的附件目录(切会话跟着切,删会话才清);勾选后可批量下载" data-i18n="btn.inq">询价附件</button>
|
||||
<a class="btn" href="javascript:location.href='/sessions.html?t='+Date.now()" data-i18n="btn.recent">最近审核</a>
|
||||
<button class="btn" onclick="openDlg()" data-page-node-id="rlEedAWfYgLJDVpuFxmmxq" data-i18n="btn.open">打开项目</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -319,7 +339,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
<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>
|
||||
<a class="lk" onclick="reloadIncon()" title="按当前工程数据与规则重算组价不一致" data-i18n="lk.reload">⟳ 重载</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>
|
||||
@@ -334,7 +354,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
<div class="grpmain">
|
||||
<!-- ⟳ 重载(2026-10-13 决策 46 主人定):分组结果服务端有缓存,重载=跳过缓存按当前数据与规则重算 -->
|
||||
<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>
|
||||
<a class="lk" onclick="reloadSim()" title="不用缓存,按当前工程数据与分组规则重新分组(工程大要稍等)" data-i18n="lk.reload">⟳ 重载</a>
|
||||
<!-- 原数据单位工程级的层级按钮挂点(2026-10-13 决策 58:分组/清单/定额/默认列宽 迁到这里最右) -->
|
||||
<span id="rawLvMount" class="rawLvMount" style="margin-left:auto;display:inline-flex;gap:4px;align-items:center"></span>
|
||||
</div>
|
||||
@@ -487,6 +507,25 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 导出进度模态(决策 92,主人定流程):先另存为选路径 → 这里显示进度(生成逐条目% + 写盘%),
|
||||
期间模态阻塞不可做其他操作;唯一出口=「后台导出」→ 收起模态回软件继续干活,后台完成后右下角提醒。 -->
|
||||
<div class="mask" id="expmask">
|
||||
<div class="dlg" style="width:480px;max-width:92vw">
|
||||
<h4>正在按原格式导出</h4>
|
||||
<div class="mbody">
|
||||
<div id="expname" style="font-weight:600;color:#243b53;word-break:break-all"></div>
|
||||
<div style="height:10px;background:#e6ecf4;border-radius:5px;overflow:hidden;margin:14px 0 8px">
|
||||
<div id="expbar" style="height:100%;width:0;background:#1f66d1;transition:width .25s"></div>
|
||||
</div>
|
||||
<div id="expstage" style="color:#5b6b80;font-size:12px;min-height:16px">准备中…</div>
|
||||
</div>
|
||||
<div class="mfoot" style="display:flex;justify-content:space-between;align-items:center">
|
||||
<span style="color:#8a97a8;font-size:12px">导出完成前软件暂不可操作</span>
|
||||
<button class="btn" onclick="exportToBackground()">后台导出</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================= 询价附件(2026-10-09 改版)==================
|
||||
数据 = 对比框里**工料机行**点「采纳」时该行跟随的附件(工程行=绑定的询价资料,
|
||||
价格行=刊物原件),全局收集、按内容去重。不是后台绑定关系的只读展示。
|
||||
@@ -520,7 +559,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="common.js?v=20261016a"></script>
|
||||
<script src="common.js?v=20261017h"></script>
|
||||
<script src="period.js"></script>
|
||||
<script>
|
||||
let SID=0, CUR=null, CURTYPE='lme', HROWS=[];
|
||||
@@ -688,8 +727,8 @@ async function billCtxApply(t, bid){
|
||||
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');
|
||||
if(p==='p1') await loadGroups('inconsistent',false,true);
|
||||
else if(p==='p2') await loadGroups('similar',false,true);
|
||||
else await refreshRaw();
|
||||
}
|
||||
/* 共享层规格⑥(决策 71):原数据·分部分项/措施项目 选中清单行 → 底部历史对比框加载该行比对 */
|
||||
@@ -701,11 +740,97 @@ window.rawBillPick = function(tr){
|
||||
pick('bill', bid, tr);
|
||||
};
|
||||
|
||||
/* 导出回写(批次D,决策 70):按原格式下载本工程(全部编辑已体现为文件内容) */
|
||||
function exportSession(){
|
||||
/* 导出回写(批次D,决策 70):按原格式导出本工程(全部编辑已体现为文件内容)。
|
||||
决策 91:另存为样式;决策 92(主人定流程):壳内点导出=①先弹原生另存为选路径(此刻还没开始
|
||||
生成,大工程不再干等)→②弹进度模态(生成逐条目% + 写盘字节%),期间软件不可操作 →③模态上
|
||||
「后台导出」是唯一出口=收起回软件继续干活,后台完成后右下角提醒。普通浏览器仍走 FSA 另存为。 */
|
||||
let EXP_BG = false; // 是否已「后台导出」(后台完成只提醒,不弹回界面)
|
||||
function exportModalShow(name){
|
||||
EXP_BG = false;
|
||||
$('expname').textContent = name || '';
|
||||
expSet(0, '已选保存位置,开始生成…');
|
||||
$('expmask').classList.add('on');
|
||||
}
|
||||
function expSet(pct, stage){
|
||||
$('expbar').style.width = Math.max(0, Math.min(100, pct)) + '%';
|
||||
$('expstage').textContent = stage || '';
|
||||
}
|
||||
function exportToBackground(){
|
||||
EXP_BG = true;
|
||||
$('expmask').classList.remove('on');
|
||||
$('msg').textContent = '导出已转后台,完成后右下角提醒';
|
||||
dlMsg('导出已转后台,完成后会提醒', 'ok');
|
||||
}
|
||||
/* 桥线程推上来的进度(生成 gen / 写盘 put / 完成 done / 失败 done=false) */
|
||||
window.__exportProgress = function(p){
|
||||
if (p && p.phase === 'gen'){
|
||||
if (EXP_BG) return;
|
||||
if (p.total) expSet(p.done / p.total * 90, '正在生成 ' + p.done + ' / ' + p.total + ' 个文件…');
|
||||
else expSet(5, '正在按原格式导出(大工程稍等)…');
|
||||
} else if (p && p.phase === 'put'){
|
||||
if (!EXP_BG) expSet(90 + (p.pct || 0) * 0.1, '正在写入文件…');
|
||||
} else if (p && p.done){
|
||||
$('expmask').classList.remove('on');
|
||||
$('msg').textContent = '已导出:' + (p.name || '');
|
||||
dlMsg('已另存为:' + p.path, 'ok');
|
||||
} else if (p && p.done === false){
|
||||
$('expmask').classList.remove('on');
|
||||
$('msg').textContent = '导出失败:' + (p.msg || '');
|
||||
dlMsg('导出失败:' + (p.msg || ''), 'err');
|
||||
}
|
||||
};
|
||||
async function exportSession(){
|
||||
if(!SID){ $('msg').textContent = '先打开工程再导出'; return; }
|
||||
$('msg').textContent = '正在按原格式导出(大工程稍等,浏览器会下载 zip 同款文件)…';
|
||||
location.href = '/api/session/export?session_id=' + SID;
|
||||
if ($('expmask').classList.contains('on')){ $('msg').textContent = '已有导出进行中(可点「后台导出」转后台)'; return; }
|
||||
$('msg').textContent = '正在按原格式导出(大工程稍等)…';
|
||||
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, '');
|
||||
if (r && r.cancel){ $('msg').textContent = '已取消导出'; return; }
|
||||
if (r && r.msg){ $('msg').textContent = '导出失败:' + r.msg; return; }
|
||||
if (r && r.started){ exportModalShow(r.name); return; }
|
||||
/* 老壳没有这个方法 → 落到下面的旧桥/浏览器分支 */
|
||||
}
|
||||
// ② 老壳(只有决策 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, '');
|
||||
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);
|
||||
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''真名(原工程名-审核版.原后缀)。
|
||||
// 必须**优先吃 filename***——旧正则 filename\*? 先命中兜底名,另存为永远建议 export.zip,
|
||||
// 后缀跟导入对不上(2026-10-17 主人报导出失效的根因)。后缀不写死:今后 excel 等导入啥导出啥。
|
||||
const m = cd.match(/filename\*=(?:UTF-8'')?([^;]+)/i) || cd.match(/filename="?([^";]+)"?/i);
|
||||
let fname = '';
|
||||
try{ fname = decodeURIComponent((m && m[1]) || '').replace(/"/g, '').trim(); }catch(e){}
|
||||
if(!fname){ fname = '工程导出.cos4'; }
|
||||
const blob = await resp.blob();
|
||||
if(window.showSaveFilePicker){
|
||||
try{
|
||||
// File System Access 的 accept 只认小写扩展名(.COS4 这类大写会 TypeError 掉进静默下载)
|
||||
const ext = ((fname.match(/(\.[^.]+)$/) || ['','.cos4'])[1]).toLowerCase();
|
||||
const h = await showSaveFilePicker({suggestedName: fname,
|
||||
types: [{description: '计价文件', accept: {'application/octet-stream': [ext]}}]});
|
||||
const w = await h.createWritable(); await w.write(blob); await w.close();
|
||||
$('msg').textContent = '已导出:' + h.name;
|
||||
dlMsg('导出完成,已存为 ' + h.name, 'ok');
|
||||
return;
|
||||
}catch(e){ if(e && e.name === 'AbortError'){ $('msg').textContent = '已取消导出'; return; } }
|
||||
}
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url; a.download = fname; a.click();
|
||||
setTimeout(()=>URL.revokeObjectURL(url), 5000);
|
||||
$('msg').textContent = '已导出(浏览器下载):' + fname;
|
||||
}catch(e){
|
||||
$('msg').textContent = '导出失败:' + (e.message || e);
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================== 合并工料机(批次C,决策 69;方案 §6)==================== */
|
||||
@@ -757,6 +882,7 @@ function renderMergeTree(){
|
||||
}
|
||||
async function mergeApply(){
|
||||
const groups = [];
|
||||
const emptyGrp = []; // 一行都没勾的组(合并后会整组隐藏——多半是误操作)
|
||||
document.querySelectorAll('#mtree .mgrp').forEach(box => {
|
||||
const keep = [], hide = [];
|
||||
Array.from(box.querySelectorAll('.mrow')).forEach(row => {
|
||||
@@ -767,7 +893,16 @@ async function mergeApply(){
|
||||
else hide.push({ id: id });
|
||||
});
|
||||
groups.push({ keep: keep, hide: hide });
|
||||
if (!keep.length) {
|
||||
const gi = Number(box.dataset.gi), g = (MDATA.groups || [])[gi];
|
||||
emptyGrp.push(g ? (g.name || '—') + ' | ' + (g.spec || '—') + ' | ' + (g.unit || '—') : ('第 ' + (gi + 1) + ' 组'));
|
||||
}
|
||||
});
|
||||
// 空选守卫:一行都没勾就点合并 = 整组隐藏,十有八九是误操作(不静默、不误伤)
|
||||
if (!groups.some(g => g.keep.length)) { dlMsg('请先勾选每组要保留的工料机行,再点合并', 'warn'); return; }
|
||||
if (emptyGrp.length && !confirm('以下 ' + emptyGrp.length + ' 组一行都没勾,合并后整组隐藏:\n'
|
||||
+ emptyGrp.slice(0, 5).join('\n') + (emptyGrp.length > 5 ? '\n…' : '')
|
||||
+ '\n\n确认继续合并?')) return;
|
||||
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; }
|
||||
@@ -840,6 +975,95 @@ function editCell(td, api, id, field, cur){
|
||||
inp.addEventListener('blur', ()=>fin(true));
|
||||
}
|
||||
|
||||
/* ---- 组表双击改工程量(规格 2026-10-16 工作台·组价不一致清单;类似清单同共享层一并生效)----
|
||||
组表列位:0把手 1序号/耗 2编码 3类别 4单位工程 5名称 6特征 7单位 8工程量 9单价 10合价 11取消采纳 12备注
|
||||
只开放工程量格(idx 8)。清单行(data-bid)只能输入数字;定额子行(data-nid)支持
|
||||
GCL+-*() 连环公式——GCL=清单工程量÷定额单位从左到右数字(到字母截断;纯字母单位=
|
||||
清单工程量),求值在服务端(与 MCP/AI 同一入口),成功后前端按落库值原位回填。
|
||||
原位回填不整页重拉:编辑本身不产生任何跳动。 */
|
||||
document.addEventListener('dblclick', function(e){
|
||||
if(!SID || (typeof WB_OPTS!=='undefined' && WB_OPTS && WB_OPTS.backend)) return;
|
||||
const td = e.target.closest && (e.target.closest('#tb1 td') || e.target.closest('#tb2 td'));
|
||||
if(!td || td.querySelector('input')) return;
|
||||
const tr = td.closest('tr'); if(!tr) return;
|
||||
const idx = Array.prototype.indexOf.call(tr.children, td);
|
||||
if(idx !== 8) return;
|
||||
e.preventDefault();
|
||||
const cur0 = td.textContent.trim();
|
||||
if(tr.classList.contains('sub') && tr.dataset.nid) grpNormQtyEdit(td, tr, cur0);
|
||||
else if(tr.dataset.bid && !tr.classList.contains('grp') && !tr.classList.contains('grp2')) grpBillQtyEdit(td, tr, cur0);
|
||||
});
|
||||
function grpBillQtyEdit(td, tr, cur0){
|
||||
const bid = Number(tr.dataset.bid);
|
||||
const inp = document.createElement('input');
|
||||
inp.className = 'cellin'; inp.value = cur0.replace(/,/g, ''); 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 === cur0.replace(/,/g, '')){ td.textContent = cur0; return; }
|
||||
if(!/^-?\d+(\.\d+)?$/.test(v)){ $('msg').textContent = '清单工程量只能输入数字'; td.textContent = cur0; return; }
|
||||
const r = await J('/api/session/bill/op',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID, op:'edit', bill_id:bid, fields:{Quantity:v}})});
|
||||
if(!r.ok){ $('msg').textContent = r.msg || '保存失败'; td.textContent = cur0; return; }
|
||||
$('msg').textContent = '已保存';
|
||||
const n = Number(v);
|
||||
td.textContent = num(n, 3);
|
||||
const grow = grpRowById(bid); if(grow) grow[5] = n; // GRP_DATA 留底同步(组内排序/右键按它取数)
|
||||
loadEditLog().then(()=>{ markGroupEH('tb1'); markGroupEH('tb2'); }); // ⑮ 红三角即时点亮
|
||||
};
|
||||
inp.addEventListener('keydown', ev=>{
|
||||
if(ev.key==='Enter'){ ev.preventDefault(); fin(true); }
|
||||
else if(ev.key==='Escape'){ fin(false); }
|
||||
});
|
||||
inp.addEventListener('blur', ()=>fin(true));
|
||||
}
|
||||
function grpNormQtyEdit(td, tr, cur0){
|
||||
const nid = Number(tr.dataset.nid);
|
||||
const inp = document.createElement('input');
|
||||
inp.className = 'cellin'; inp.value = cur0.replace(/,/g, ''); inp.spellcheck = false;
|
||||
inp.title = '可输入数字、数字四则(如 5+9.25+6.36)或带 GCL 的公式(GCL=清单工程量÷定额单位数字,'
|
||||
+ '纯字母单位=清单工程量),如 GCL*(5+9.25+6.36)+GCL;公式按原文保存,导出时按清单工程量求值';
|
||||
td.textContent = ''; td.appendChild(inp);
|
||||
inp.focus(); inp.select();
|
||||
let done = false;
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
const v = inp.value.trim();
|
||||
if(!save || v === cur0.replace(/,/g, '')){ td.textContent = cur0; return; }
|
||||
const r = await J('/api/session/norm/op',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID, norm_id:nid, fields:{Quantity:v}})});
|
||||
if(!r.ok){ $('msg').textContent = r.msg || '保存失败'; td.textContent = cur0; return; }
|
||||
// 决策 90:公式按原文回填(GCL/GCL*0.5…),纯数字回填数字;提示带即时求值结果
|
||||
td.textContent = (r.expr != null && r.expr !== '') ? r.expr : numG(r.quantity);
|
||||
$('msg').textContent = '已保存' + (r.quantity != null ? ':= ' + numG(r.quantity) : '');
|
||||
loadEditLog().then(()=>{ markGroupEH('tb1'); markGroupEH('tb2'); }); // ⑮ 红三角即时点亮
|
||||
};
|
||||
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 ③:定额子行点选=纯视觉选中(.subsel 与清单行 tr.sel 同配色整套)。
|
||||
不动 tr.sel/CUR——比对与采纳的基准仍跟着清单行走(规格⑤:采纳不因展开/子行点选失效)。 */
|
||||
document.addEventListener('click', function(e){
|
||||
if(!SID) return;
|
||||
const tr = e.target.closest && e.target.closest('tr.sub');
|
||||
if(!tr || !tr.dataset.nid) return;
|
||||
document.querySelectorAll('tr.subsel').forEach(x=>x.classList.remove('subsel'));
|
||||
tr.classList.add('subsel');
|
||||
// 规格 2026-10-17 ⑭:一个工作区只保持最后点选的一行——点定额后清单的点选消失
|
||||
//(对比框仍按该清单比对:CUR 不动;采纳改按 CUR 基准,见 adopt 守卫)
|
||||
document.querySelectorAll('tr.sel').forEach(x=>x.classList.remove('sel'));
|
||||
document.querySelectorAll('td.cellhit').forEach(x=>x.classList.remove('cellhit'));
|
||||
const ptd=window.__lastPickedTd;
|
||||
if(ptd && tr.contains(ptd)) ptd.classList.add('cellhit');
|
||||
});
|
||||
|
||||
/* ==================== 工料机汇总 三价行内编辑(2026-10-16 主人口径)====================
|
||||
仅项目级工料机汇总(行带 data-lmeid);单位工程级保持只读。
|
||||
恒满足 除税编制价 × (1 + 税率/100) = 含税编制价,金额四舍五入 2 位,税率空按 0:
|
||||
@@ -920,10 +1144,10 @@ function lmeEditCell(td, tr, field, cur){
|
||||
|
||||
/* ---------- 打开工程 ---------- */
|
||||
async function openDlg(){
|
||||
$('ofile').value=''; $('oname').value=''; $('oname').dataset.auto=''; $('omsg').textContent='';
|
||||
$('oper').value=''; $('oprov').value=''; $('ocity').value=''; $('odist').value='';
|
||||
$('obuid').value=''; $('obuid').dispatchEvent(new Event('input', {bubbles:true}));
|
||||
$('omask').classList.add('on');
|
||||
$('omask').classList.add('on'); // 规格 打开工程BUG2:先显示弹框再清值——此前清值派发的
|
||||
$('ofile').value=''; $('oname').value=''; $('oname').dataset.auto=''; $('omsg').textContent=''; // input
|
||||
$('oper').value=''; $('oprov').value=''; $('ocity').value=''; $('odist').value=''; // 事件在
|
||||
$('obuid').value=''; $('obuid').dispatchEvent(new Event('input', {bubbles:true})); // 隐藏态测量
|
||||
}
|
||||
|
||||
// 选好文件后,工程名称默认 = 文件名(去掉扩展名),可手动改
|
||||
@@ -1085,8 +1309,23 @@ async function loadLme(){
|
||||
const WB_OPTS = { rowClick: 'pick', normApi: '/api/session/bill/'
|
||||
/* 「取消采纳」列已由 common.js 统一渲染(lmeAdoptCellHTML,2026-10-13 收编):
|
||||
有采纳备注的行给链接、其余灰 —,本页提供 cancelAdopt(id) 全局函数供其调用。 */ };
|
||||
async function loadGroups(kind, fresh){
|
||||
async function loadGroups(kind, fresh, keepView){
|
||||
// fresh=true(⟳ 重载按钮,决策 46):服务端跳过缓存强制重算,算完回填缓存
|
||||
// keepView=true(采纳/取消采纳/右键操作后重拉,规格 2026-10-16「点采纳跳至第一组」修复):
|
||||
// 重画前留底 左树选中/展开的组/选中的清单行,重画后原样恢复——视图停在原地,不跳回第 1 组。
|
||||
const treeEl = kind==='inconsistent' ? $('grptree1') : $('grptree');
|
||||
const tbId = kind==='inconsistent' ? 'tb1' : 'tb2';
|
||||
let keep=null;
|
||||
if(keepView){
|
||||
const heads=[...$(tbId).querySelectorAll('tr.grp,tr.grp2')];
|
||||
const on=(treeEl.querySelector('.rn.on')||{}).dataset;
|
||||
keep={ pk:(on&&on.pk)||'all',
|
||||
open:heads.map((tr,i)=>tr.querySelector('.tog').dataset.open==='1'?i:-1).filter(i=>i>=0),
|
||||
normOpen:[...$(tbId).querySelectorAll('tr[data-bid] .tog[data-open="1"]')]
|
||||
.map(t=>t.closest('tr').dataset.bid),
|
||||
sel:$(tbId).querySelector('tr.sel')?.dataset.bid||null,
|
||||
subsel:$(tbId).querySelector('tr.subsel')?.dataset.nid||null }; // 规格⑥:定额选中态也留底
|
||||
}
|
||||
const d=await J(`/api/session/${kind}?session_id=${SID}` + (fresh ? '&fresh=1' : ''));
|
||||
// 徽标口径与左树根一致:含末尾落单组(2026-10-11 主人定);组价不一致没有落单组,extra 恒空、数值不变
|
||||
(kind==='inconsistent'?$('n1'):$('n2')).textContent=d.total+(d.extra||[]).length+' 组';
|
||||
@@ -1100,6 +1339,37 @@ async function loadGroups(kind, fresh){
|
||||
// 点选行为在公共层 grpTreeBind(两侧唯一实现),本页只给树容器和表体 id
|
||||
if(kind==='similar') grpTreeBind($('grptree'), 'tb2', d);
|
||||
else grpTreeBind($('grptree1'), 'tb1', d, { kind: 'inconsistent', rootName: '组价不一致清单' });
|
||||
if(keep){
|
||||
if(keep.pk && keep.pk!=='all'){
|
||||
const node=treeEl.querySelector('.rn[data-pk="'+keep.pk+'"]');
|
||||
if(node) node.click(); // 复原树过滤(单组显示);组没了就落回默认全显
|
||||
}
|
||||
const heads=[...$(tbId).querySelectorAll('tr.grp,tr.grp2')];
|
||||
keep.open.forEach(i=>{ const tr=heads[i];
|
||||
if(tr && tr.querySelector('.tog').dataset.open!=='1') tgGrp(tr.dataset.grp, tr); });
|
||||
// 规格 2026-10-16 ④:固定工作区显示状态——展开着的定额子行也原样展开(重拉接口,即新状态)
|
||||
(keep.normOpen||[]).forEach(bid=>{
|
||||
const tr=$(tbId).querySelector('tr[data-bid="'+bid+'"]');
|
||||
const tg=tr && tr.querySelector('.tog');
|
||||
if(tg && tg.dataset.open!=='1') tg.click();
|
||||
});
|
||||
if(keep.sel && !keep.subsel){ // 规格 ⑭:单选语义——定额是最后点选时不再补清单高亮
|
||||
const srow=$(tbId).querySelector('tr[data-bid="'+keep.sel+'"]');
|
||||
if(srow && srow.style.display!=='none') srow.classList.add('sel'); // 只补选中态,不重发比对请求
|
||||
}
|
||||
// 规格 2026-10-17 ⑥:选中过的定额子行,采纳/操作后仍是选中态。定额子行由 tgNorm
|
||||
// 异步拉取,可能晚于这里——短轮询几拍等它进 DOM。
|
||||
if(keep.subsel){
|
||||
let n=0;
|
||||
const iv=setInterval(()=>{
|
||||
const srow=$(tbId).querySelector('tr.sub[data-nid="'+keep.subsel+'"]');
|
||||
if(srow && srow.style.display!=='none'){ srow.classList.add('subsel'); clearInterval(iv); }
|
||||
else if(++n>12) clearInterval(iv);
|
||||
},150);
|
||||
}
|
||||
}
|
||||
// 规格 2026-10-17 ⑮:编辑历史红三角(取全会话日志 → 本表打标)
|
||||
loadEditLog().then(()=>{ markGroupEH('tb1'); markGroupEH('tb2'); });
|
||||
}
|
||||
|
||||
/* ⟳ 重载(组价不一致,决策 72):与类似清单 reloadSim 同款 */
|
||||
@@ -1119,7 +1389,12 @@ function reloadSim(){
|
||||
async function pick(type,id,tr){
|
||||
const same=tr.classList.contains('sel'); // 重复点同一行≠「换了行」,不清遗留
|
||||
document.querySelectorAll('tr.sel').forEach(x=>x.classList.remove('sel'));
|
||||
document.querySelectorAll('tr.subsel').forEach(x=>x.classList.remove('subsel')); // 换行连带清子行选中
|
||||
document.querySelectorAll('td.cellhit').forEach(x=>x.classList.remove('cellhit'));
|
||||
tr.classList.add('sel');
|
||||
// 规格 2026-10-16 ③:鼠标点的那一格贴 .cellhit(#a8e3d2)——取捕获监听记下的最近 td
|
||||
const ptd=window.__lastPickedTd;
|
||||
if(ptd && tr.contains(ptd)) ptd.classList.add('cellhit');
|
||||
CURTYPE=type; CUR={id};
|
||||
// 搜索框/屏蔽词框**非粘性**(2026-10-11 主人定):所在行换了 → 必须清除上一次遗留的
|
||||
// **所有**信息(关键字模式/检索结果状态/屏蔽词/框内文字),再带入本行名称——每行都从
|
||||
@@ -1166,8 +1441,15 @@ async function search(){
|
||||
// 2026-09-29:原来按 children[6]/children[7] 取单价,加「类别」列后下标会错位;
|
||||
// 改成读行上的 data-price(原始数值,不带千分位),以后再加/减列都不受影响
|
||||
function curPrice(){
|
||||
const tr=document.querySelector('tr.sel'); if(!tr) return null;
|
||||
const v = parseFloat(tr.dataset.price); return isNaN(v)?null:v;
|
||||
const tr=document.querySelector('tr.sel');
|
||||
if(tr){ const v = parseFloat(tr.dataset.price); if(!isNaN(v)) return v; }
|
||||
// 规格 ⑭:定额点选后清单行无 .sel——基准单价改从 GRP_DATA 取(对比基准仍是被选清单)
|
||||
if(CURTYPE==='bill' && CUR && CUR.id){
|
||||
const r = grpRowById(CUR.id);
|
||||
const v = r==null ? NaN : parseFloat(r[6]);
|
||||
if(!isNaN(v)) return v;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/* 当前基准行的采纳备注(对比框「已采纳」灰徽标判定依据,2026-10-11 主人定):
|
||||
清单 = GRP_DATA 里 r[0]===CUR.id 的 r[10];工料机 = LME_ROWS 同查。无选中/无备注 = 空。 */
|
||||
@@ -1400,8 +1682,11 @@ function grpRowById(id){
|
||||
}
|
||||
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;
|
||||
if(CURTYPE!=='bill' || !CUR){ dlMsg('请先在上方点选清单行,再采纳历史价','warn'); return; } // 规格⑤:不静默
|
||||
// 规格 ⑭:点过定额后清单行不再带 .sel——采纳基准跟着 CUR 走(CUR 在 pick 时已定),
|
||||
// 不再要求可见 .sel;行被删等异常由服务端「清单不存在」兜底。
|
||||
const tr=document.querySelector('tr.sel') || (grpRowById(CUR.id) ? {basis:1} : null);
|
||||
if(!tr){ dlMsg('请先在上方点选清单行,再采纳历史价','warn'); return; }
|
||||
// ① 数据采纳(决策 68 批次B:规格 9.1 新增清单覆盖 / 9.3 原清单定额追加+原定额临删 /
|
||||
// 9.4 汇总品类追加)。有 bill_id 的入库清单行才落数据;连续采纳认最后一次(服务端语义)。
|
||||
let r0=null;
|
||||
@@ -1423,10 +1708,11 @@ async function adopt(i){
|
||||
}catch(e){ r=null; }
|
||||
if(!r || !r.ok){ dlMsg('备注写入失败:'+(r&&r.msg?r.msg:'服务未响应'),'err'); return; }
|
||||
// ③ 刷新当前视图(9.1 清单行字段被覆盖、9.3 追加定额带临删——重拉才是真状态)
|
||||
// keepView:采纳后停在原组原行(规格 2026-10-16:点采纳跳至第一组 = bug,修复)
|
||||
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');
|
||||
if(p==='p1') await loadGroups('inconsistent',false,true);
|
||||
else if(p==='p2') await loadGroups('similar',false,true);
|
||||
else await refreshRaw();
|
||||
renderHist(); // 已采纳灰标记:旧行复原、新行点亮(传递)
|
||||
dlMsg('已采纳'+(r0?('('+r0.mode+':定额 '+r0.n_norm+' 条'+(r0.n_sum?('、汇总补品类 '+r0.n_sum+' 行'):'')+')'):'(仅备注)')+':'+txt,'ok');
|
||||
@@ -1449,12 +1735,12 @@ async function cancelBillAdopt(billId, el){
|
||||
body:JSON.stringify({bill_id:billId,remark:''})});
|
||||
}catch(e){ r2=null; }
|
||||
if(!r2 || !r2.ok){ dlMsg('取消采纳失败:'+(r2&&r2.msg?r2.msg:'备注清空未响应'),'err'); return; }
|
||||
// ③ 刷新当前视图(原数据/组表都可能是取消来源;撤缓存重拉即真状态)
|
||||
// ③ 刷新当前视图(原数据/组表都可能是取消来源;撤缓存重拉即真状态;keepView 停在原地)
|
||||
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');
|
||||
if(p==='p1') await loadGroups('inconsistent',false,true);
|
||||
else if(p==='p2') await loadGroups('similar',false,true);
|
||||
else await refreshRaw();
|
||||
renderHist();
|
||||
dlMsg('已取消采纳'+(r.noop?'(该清单无数据采纳,仅清了备注)':'(数据已反向恢复)'),'ok');
|
||||
@@ -1574,7 +1860,10 @@ async function recLoad(){
|
||||
try{ d=await J('/api/sessions'); }
|
||||
catch(e){ return; } // 读不到就静默:错误提示归管理页管,工作台不该弹
|
||||
RECS=d.items||[]; RECMAP={};
|
||||
(RECS||[]).forEach(r=>(r.all||[]).forEach(x=>RECMAP[x.id]=x));
|
||||
(RECS||[]).forEach(r=>(r.all||[]).forEach(x=>{
|
||||
x.can_reparse = r.can_reparse; // 决策 94:组按源文件去重,can_reparse 对组内每个会话同样成立
|
||||
RECMAP[x.id]=x;
|
||||
}));
|
||||
}
|
||||
async function recOpen(sid,keep){
|
||||
const m=RECMAP[sid]||{};
|
||||
@@ -1994,14 +2283,19 @@ async function initFromUrl(){
|
||||
// 2026-10-10 主人定:完成提示改右下角浮层,只报条数(不再顶栏长句)
|
||||
if(r && r.ok){ await recLoad();
|
||||
toast('清单 ' + r.n_bill + ' 条、定额 ' + r.n_norm + ' 条、工料机 ' + r.n_lme + ' 条'); }
|
||||
else if(r && r.msg){ dlMsg(r.msg, 'err'); } // 决策 94:重解析失败要说出来(多半=源文件没了),别静默吞掉
|
||||
}catch(e){}
|
||||
}
|
||||
ldPct(86,'正在加载清单、分组与工料机…');
|
||||
await recOpen(sid, true);
|
||||
if(['p0','p1','p2','p3'].includes(savedTab) && savedTab !== 'p3') await tab(savedTab);
|
||||
// 决策 94:源文件缺失要进门就知道——数据可看,但导出/重解析都没了(最近审核列表也有红标)
|
||||
if(RECMAP[sid] && RECMAP[sid].can_reparse === false){
|
||||
dlMsg('该工程源文件已缺失:数据仍可查看,但无法导出、无法重新解析', 'warn');
|
||||
}
|
||||
} finally { ldHide(); }
|
||||
if(!fromUrl) $('msg').textContent = '已恢复上次审核:《' +
|
||||
(($('sinfo').querySelector('b')||{}).textContent || '') + '》(「最近审核」页可切换其他工程)';
|
||||
// 规格 2026-10-17 工具栏8:取消「已恢复上次审核:《…》」提示(工程名已在顶栏,不再赘述)
|
||||
if(!fromUrl) $('msg').textContent = '';
|
||||
} else if(fromUrl){ ldHide(); }
|
||||
}
|
||||
initFromUrl();
|
||||
|
||||
Reference in New Issue
Block a user