feat(mcp): 新增 Excel 批量清单匹配工具并调整分页与采纳锚策略

This commit is contained in:
lianjianwei2024
2026-11-02 15:23:27 +08:00
parent d82b5e8676
commit 8701eaf739
13 changed files with 784 additions and 219 deletions

View File

@@ -14,7 +14,7 @@ body{font-family:"Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSan
用固定 height + flex 居中,而不是 padding —— 高度不再随字号 / 行高浮动,调一处就准。
align-items:flex-end —— 右侧「设置 / 工作台」两个按钮底部与标签对齐、保持自身自然高度(≈29px),
比标签矮 3px,一眼能分清「标签」和「按钮」,不用再靠 margin-bottom 人为错开。 */
.tabs{display:flex;align-items:flex-end;gap:4px;border-bottom:2px solid var(--c1)}
.tabs{display:flex;align-items:flex-end;gap:5px;border-bottom:2px solid var(--c1)}
.tab{height:24px;display:flex;align-items:center;padding:0 22px;cursor:pointer; /* 2026-10-21 决策 151 主人定:与工作台数据页签同高(原 32px 口径取消) */
border:1px solid var(--line);border-bottom:none;background:#e7edf5;
color:#34506f;font-weight:600;font-size:13px;border-radius:8px 8px 0 0;user-select:none}
@@ -54,13 +54,15 @@ body{font-family:"Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSan
.panel{background:#fff;border:1px solid var(--line);border-top:none}
/* 查询栏:**强制单行**(2026-10-07 主人定:保证一行,不要 2 行)——
可收缩控件按比例让宽,窗口放不下时查询栏内部出细横向滚动条(仍是一行)。 */
.bar{display:flex;gap:6px;align-items:center;flex-wrap:nowrap;overflow-x:auto;
.bar{display:flex;gap:5px;align-items:center;flex-wrap:nowrap;overflow-x:auto;
padding:8px 12px;border-bottom:1px solid var(--line);background:#fafcff}
.bar::-webkit-scrollbar{height:6px}
.bar::-webkit-scrollbar-thumb{background:#c4d2e3;border-radius:3px}
.bar input,.bar select{padding:6px 10px;border:1px solid #b8c4d4;border-radius:6px;font-size:13px}
/* 原生 select 的行高比 input 高 2px(31 vs 29),查询栏里会显得没对齐 —— 收一帧(2026-10-08) */
.bar select{padding-top:5px;padding-bottom:5px;line-height:1.4}
/* 2026-11-02 主人定:输入框/下拉与按钮统一 28px 高(对齐工作台) */
.bar input,.bar select{height:28px;padding:0 10px;border:1px solid #b8c4d4;border-radius:6px;font-size:13px;box-sizing:border-box;line-height:26px}
/* 本页搜索框/跳页钮:common.css 全局 24px(工作台共用不动),此处随查询栏统一 28px */
.bar .pgsrch{height:28px}
.bar .pgsnav{height:28px;white-space:nowrap;flex:none} /* 2026-11-02 主人定:「上一个/下一个」不许换行 */
.bar .btn,.bar .tip{flex:none}
.bar .dlmsg{flex:0 1 auto;min-width:0}
#fper{flex:0 1 140px;min-width:96px}
@@ -78,13 +80,16 @@ body{font-family:"Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSan
.cin[data-for=fq]{flex:1 1 150px;min-width:100px;max-width:320px}
.cin[data-for=ftotal_min],.cin[data-for=ftotal_max]{flex:0 1 92px;min-width:60px}
/* 地区三combo收窄(可输入搜索后不需要宽下拉,主人 10-07 指出太宽) */
.combo[data-for=fp],.combo[data-for=fc],.combo[data-for=fd]{flex:0 1 88px;min-width:60px}
.combo[data-for=fp],.combo[data-for=fc],.combo[data-for=fd]{flex:0 1 72px;min-width:56px} /* 2026-11-02 主人定:地区三框减窄 */
.combo[data-for=fkind]{flex:0 1 130px;min-width:90px}
.combo[data-for=fbu],.combo[data-for=fpub]{flex:0 1 170px;min-width:90px}
#ftotal_min,#ftotal_max{flex:0 1 92px;min-width:60px}
.btn{padding:6px 13px;border-radius:6px;border:1px solid #b8c4d4;background:#fff;cursor:pointer;font-size:12.5px}
/* 2026-11-02 主人定:按钮/输入框形式对齐工作台(28px 高 inline-flex 同款),间距 5px */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:4px;height:28px;padding:0 12px;border-radius:6px;border:1px solid #b8c4d4;background:#fff;cursor:pointer;font:inherit;font-size:12.5px;color:#26405e;line-height:1;white-space:nowrap;vertical-align:middle;user-select:none}
.btn:hover{background:#eef3fa}
.btn.pri{background:var(--c2);color:#fff;border-color:var(--c2)}
.btn:active{background:#e0effc}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn.pri{background:var(--c2);color:#fff;border-color:var(--c2);font-weight:600}
.btn.danger{color:#c0392b;border-color:#e0b4b4}
/* ---- 询价附件弹窗(2026-10-06)----
左 38% 上传区 / 右 62% 工料机:右边 7 列给窄了必然横滚,等于白做。
@@ -315,14 +320,18 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
放在标签栏最右(margin-left:auto),不参与上面三个数据标签的切换。
2026-10-10 决策 31:按钮名「设置」让位给统一的「⚙ 设置」窗口(common.js,
授权管理入口),本按钮改回原名「数据源」——功能一点没动。
margin-bottom:6px —— 让它比标签条矮半截,免得看起来像第四个标签。 -->
<button class="btn" id="btnDict" style="margin-left:auto;height:28px;padding:0 12px;display:inline-flex;align-items:center;justify-content:center;line-height:1" onclick="openDict()"
title="字典设置:地区 / 发布单位 / 建设单位 下拉选项 + 上传大小上限">⚙ 字典</button>
margin-bottom:5px(2026-11-02 主人定)—— 距蓝色线条的间距按工作台口径统一 5px,
也免得看起来像第四个标签。 -->
<button class="btn" id="btnFrames" style="margin-left:auto;margin-bottom:5px;height:28px;padding:0 12px;display:inline-flex;align-items:center;justify-content:center;line-height:1" onclick="openFrames()"
title="导出设置:管理各格式导出文件数据结构">导出设置</button>
<button class="btn" id="btnDict" style="margin-bottom:5px;height:28px;padding:0 12px;display:inline-flex;align-items:center;justify-content:center;line-height:1" onclick="openDict()"
title="字典设置:地区 / 询价单位 / 发布单位 / 建设单位 下拉选项 + 上传大小上限">⚙ 字典</button>
<!-- 工作台入口(2026-10-06 主人定):从标题行右上角搬到标签栏,排在「设置」右边。
2026-10-19 主人定:去掉 ▶ 图标,蓝底让位,尺寸样式对齐工作台顶栏按钮
(28px 高 / 左右 12px / 12.5px 字号白底,与工作台「打开项目」同款)。 -->
(28px 高 / 左右 12px / 12.5px 字号白底,与工作台「打开项目」同款)。
2026-11-02 主人定:距蓝线 5px,与「⚙ 字典」同款。 -->
<!-- 时间戳参数:老 WebView2 对 no-store 不完全遵守,跨页跳转带新 URL 强制绕缓存(2026-10-12) -->
<button class="btn" style="height:28px;padding:0 12px;display:inline-flex;align-items:center;justify-content:center;line-height:1"
<button class="btn pri" style="margin-bottom:5px;height:28px;padding:0 12px;display:inline-flex;align-items:center;justify-content:center;line-height:1"
onclick="location.href='/workbench.html?v='+Date.now()"
title="打开工作台:导入工程、做历史比对与审核">工作台</button>
</div>
@@ -342,17 +351,12 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
<input id="ftotal_min" type="text" inputmode="decimal" placeholder="总价≥" title="总价(元)下限">
<input id="ftotal_max" type="text" inputmode="decimal" placeholder="总价≤" title="总价(元)上限">
<select id="fpub" style="display:none" title="按发布单位筛选"><option value="">全部发布单位</option></select>
<button class="btn pri" onclick="load(1)">查询</button>
<button class="btn" onclick="load(1)">查询</button>
<button class="btn" onclick="resetF()">重置</button>
<!-- 标准模板下载:只在「市场价 / 信息价」标签下出现(工程导入用不上),
位置固定在「导入」左边 —— 先拿模板再填再导入,是这个按钮的顺序含义 -->
<button class="btn" id="btnTpl" style="display:none" onclick="dlTpl()"
title="另存为 Excel 标准模板(自己选保存位置),按模板填好后回来导入">标准模板</button>
<button class="btn pri" id="btnImp" onclick="openImp()">导入</button>
<!-- 清空模拟数据:测试数据隔离/一键回收。danger 样式 + 二次确认,避免误触真删。 -->
<button class="btn danger" id="btnClearMock" style="margin-left:auto" onclick="clearMock()"
title="清空全部「模拟」测试数据(is_mock=1 的批次及其价格/附件,真删除、不可恢复)">清空模拟数据</button>
<span class="tip" id="cnt"></span>
<!-- 「清空模拟数据」按钮已于 2026-11-02 按主人要求去掉(clearMock 函数一并撤除;
后端端点保留,需要时可在接口层调用)。「共 N 个」计数顶替原推右位。 -->
<span class="tip" id="cnt" style="margin-left:auto"></span>
<!-- 下载结果提示条(2026-10-06):替代 alert,保存成功/失败在这里说,3 秒后淡出 -->
<span class="dlmsg" id="dlmsg"></span>
<!-- 决策 229(2026-10-27 主人定):本页搜索(共享层)——当前页内黄底 + 上一个/下一个;
@@ -493,12 +497,12 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
<div class="bar" id="ibody" style="flex-direction:row;align-items:stretch;gap:16px;overflow:hidden">
<div id="ileft" style="min-width:0;display:flex;flex-direction:column;gap:10px">
<div id="irowFile" style="display:flex;gap:8px;align-items:center">
<span style="width:88px">全国电子标书</span>
<span style="width:88px">导入</span>
<input type="file" id="ifile" style="flex:1" onchange="pickFile(this)">
</div>
<div id="ifileInfo" class="tip" style="padding:0 0 0 82px"></div>
<div style="display:flex;gap:8px;align-items:center">
<span style="width:88px">工程名称 *</span>
<span style="width:88px">名称 *</span>
<input id="iname" style="flex:1" placeholder="选文件后自动带出文件名,可改">
</div>
<div id="irowPer" style="display:flex;gap:8px;align-items:center">
@@ -520,7 +524,7 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
<select id="ifk" style="flex:1"></select>
</div>
<div id="irowPub" style="display:flex;gap:8px;align-items:center">
<span style="width:88px">发布单位 *</span>
<span style="width:88px" id="ipubLbl">发布单位 *</span>
<select id="ipub" style="flex:1"></select>
</div>
<div id="irowPdf" style="display:flex;gap:8px;align-items:center">
@@ -543,6 +547,8 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
<div style="display:flex;gap:10px;align-items:center;padding:10px 16px;border-top:1px solid #e3eaf2;background:#fafcff">
<span class="tip" id="imRemind" style="flex:1;min-width:0;color:#b03a2e;line-height:1.45">提醒:建议在打开或导入项目时,先把工程独有的增加费(暗室、超高降效、预算包干、垂直运输等)取消后再入库或工作台的审核对比,否则容易造成数据失真!</span>
<span class="tip" id="imsg"></span>
<button class="btn" id="btnTpl" style="display:none;margin-left:auto" onclick="dlTpl()"
title="另存为 Excel 标准模板(自己选保存位置),按模板填好后回来导入">标准模板</button>
<button class="btn" onclick="closeImp()">取消</button>
<button class="btn" id="impBtnX" onclick="aimpToggle()" title="右边展开目录树:按单位工程导入 Excel 建工程(与工作台同一套模板)">导入Excel</button>
<input type="file" id="iprojfile" accept=".xlsx" style="display:none" onchange="aimpProjFile()">
@@ -577,7 +583,7 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
<span style="width:74px">名称 *</span><input id="ename" style="flex:1">
</div>
<div id="irowEpub" style="display:flex;gap:8px;align-items:center">
<span style="width:74px">发布单位 *</span><select id="epub" style="flex:1"></select>
<span style="width:74px" id="epubLbl">发布单位 *</span><select id="epub" style="flex:1"></select>
</div>
<div id="irowEbuid" style="display:flex;gap:8px;align-items:center">
<span style="width:74px">建设单位 *</span><select id="ebuid" style="flex:1"></select>
@@ -617,6 +623,7 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
<div style="padding:14px 16px;display:flex;flex-direction:column;gap:10px">
<div style="display:flex;gap:4px;border-bottom:2px solid var(--c1)">
<div class="dtab on" id="dtab-region" onclick="dictTab('region')">地区</div>
<div class="dtab" id="dtab-inquirer" onclick="dictTab('inquirer')">询价单位</div>
<div class="dtab" id="dtab-publisher" onclick="dictTab('publisher')">发布单位</div>
<div class="dtab" id="dtab-builder" onclick="dictTab('builder')">建设单位</div>
<div class="dtab" id="dtab-upload" onclick="dictTab('upload')">上传设置</div>
@@ -663,10 +670,34 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
</div>
<input type="file" id="afile" style="display:none">
<!-- ================= 导出设置(导出文件数据结构库)=================
2026-11-02 主人定:弹框开即列表(序号|后缀|上传日期|导出文件数据结构,同后缀聚簇、
组间明显横线、组首行标件数);右上「添加」=选文件即入库(.cos/.cos4 原件或骨架包),
同名结构入库前确认升级替换;每文件带 下载 / 删(删=二次确认,该后缀最后一件加警示不阻止)。
阶段二(上市版)切「骨架包升级分发」时本弹框撤添加钮、客户端静默接收(决策台账 257)。 -->
<div class="mask" id="fmask">
<div class="dlg" style="width:min(760px,94vw)">
<div class="dh"><b>导出设置</b><span class="close" onclick="closeFrames()">×</span></div>
<div style="padding:14px 16px;display:flex;flex-direction:column;gap:10px">
<div style="display:flex;justify-content:flex-end">
<button class="btn pri" onclick="framesAdd()" title="选择 .cos / .cos4 原件或骨架包(zip 内含 cos 族件),入库后自动按后缀归类">添加</button>
<input type="file" id="ffile" style="display:none" onchange="framesSeed(this)">
</div>
<div class="tw" style="max-height:52vh">
<table><colgroup><col style="width:56px"><col style="width:110px"><col style="width:110px"><col></colgroup>
<thead><tr><th class="c">#</th><th>后缀</th><th>上传日期</th><th>导出文件数据结构</th></tr></thead>
<tbody id="frameBody"></tbody>
</table>
</div>
<div class="tip" id="fmsg" style="padding:0;min-height:18px"></div>
</div>
</div>
</div>
<!-- ===== 询价附件(2026-10-21 决策 152 主人定:左=附件目录树(根目录「附件目录」,上传/删除挂根行右侧);
右=项目工料机/类似清单 双页签 + 行最右搜索框;两类都可绑附件,工作台对比框可下载) ===== -->
<script src="common.js?v=20261021e"></script>
<script src="common.js?v=20261101a"></script>
<script src="period.js"></script>
<script>
const $=id=>document.getElementById(id);
@@ -749,21 +780,8 @@ function fitFlexByContent(cols){
async function J(u,o){const r=await fetch(u,o);return r.json()}
// 清空模拟测试数据:整批删除 is_mock=1 的批次(及其价格/附件),并顺手扫掉孤儿附件文件。
async function clearMock(){
if(!confirm("确认清空全部模拟测试数据?\n将真删除所有 is_mock=1 的批次、价格与附件(不可恢复)。")) return;
try{
const r = await J('/api/admin/clear_mock',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({})});
if(r && r.ok){
let s = "已清空模拟数据:批次 "+r.n_batch+" 份、价格 "+r.n_price+" 条";
if(r.n_attach_file) s += "、附件文件 "+r.n_attach_file+" 个";
if(r.n_orphan_file) s += "、孤儿附件 "+r.n_orphan_file+" 个";
dlmsg(s);
load(1);
} else {
dlmsg("清空失败:" + ((r && r.msg) || "未知错误"), "err");
}
}catch(e){ dlmsg("清空请求异常:" + e, "err"); }
}
/* 「清空模拟数据」入口已于 2026-11-02 按主人要求撤除(按钮+本函数);
后端 /api/admin/clear_mock 端点保留,需要时可在接口层调用。 */
function ym(s){const m=/^(\d{4})-(\d{2})$/.exec((s||'').trim());return m?(+m[1])*12+(+m[2]):null}
// esc / num / fmtAttr 由 common.js 提供(前后台唯一来源)。
// ⚠️ 原先后台用 toLocaleString(undefined) 且无最小小数位,工作台用 zh-CN —— 同一数字两侧显示不一样,
@@ -809,8 +827,10 @@ async function loadFilters(){
fkind.innerHTML = '<option value="">全部单价类型</option>' + kindOptions(f.file_kind, null);
fbu.innerHTML = '<option value="">全部建设单位</option>'
+ (f.bu_rows||[]).map(u=>`<option value="${esc(u)}">${esc(u)}</option>`).join('');
fpub.innerHTML = '<option value="">全部发布单位</option>'
// 2026-11-02 主人定:市场价页签过滤文案=询价单位;选项=库内实际值(两字典∪不受影响)
fpub.innerHTML = `<option value="">${KIND==='market' ? '全部询价单位' : '全部发布单位'}</option>`
+ (f.pub_rows||[]).map(u=>`<option value="${esc(u)}">${esc(u)}</option>`).join('');
fpub.title = KIND==='market' ? '按询价单位筛选' : '按发布单位筛选';
// 可搜索下拉(2026-10-07 主人定):地区三级 + 建设单位 + 发布单位,输入过滤、点选精确值
['fp','fc','fd','fbu','fpub'].forEach(id=>comboAttach($(id))); // 单价类型只有 4 个枚举值,保持普通下拉
comboSyncAll();
@@ -1574,8 +1594,11 @@ async function openImp(){
document.getElementById('irowFk').style.display = isPrice?'none':'flex';
document.getElementById('irowNote').style.display = isPrice?'flex':'none';
document.getElementById('irowPub').style.display = isPrice?'flex':'none';
// 2026-11-02 主人定:市场价(市场询价)用「询价单位」字典,信息价保持「发布单位」——两类主体独立
document.getElementById('ipubLbl').textContent = (isPrice && KIND==='market') ? '询价单位 *' : '发布单位 *';
document.getElementById('irowPdf').style.display = isPrice?'flex':'none';
document.getElementById('impBtnX').style.display = isPrice?'none':'inline-block';
document.getElementById('btnTpl').style.display = isPrice?'':'none'; // 标准模板只对信息价/市场价有意义
document.getElementById('ibtnGo').textContent = isPrice ? '开始导入' : '打开';
document.getElementById('imRemind').style.display = isPrice?'none':'block';
if(AIOPEN) aimpToggle(); // 每次打开先收回树区(与工作台 openDlg 同款)
@@ -1596,11 +1619,9 @@ async function openImp(){
ifile.accept = isPrice ? '.xlsx' : '.cos4,.cos,.swt,.swz';
document.getElementById('ifileInfo').textContent='';
document.getElementById('ifileInfo').style.display = isPrice?'block':'none';
document.getElementById('irowTip').textContent = isPrice
? '信息价/市场价:只收「标准模板」Excel(.xlsx,每次一个)+ 附件原件(任意格式,选填)。'
+ '名称留空或点文件后自动带出文件名(可改);期次留空时自动从文件名里认(如「珠海信息价_2026年7月」→ 2026-07)。'
: '';
document.getElementById('irowTip').textContent = '';
imsg.textContent='';
dupCheckSha(ifile, '', 'admin', 'ibtnGo', 'imsg'); // 决策 243 补记五:弹框每开必清预检状态——上一文件的命中结论绝不带给新文件
await loadImpFilters();
// 单价类型默认「预算综合单价」(与工作台打开项目弹框同一默认)
try{ if(ifk.options.length) ifk.value='1'; }catch(e){}
@@ -1611,8 +1632,11 @@ async function pickFile(inp){
const info=document.getElementById('ifileInfo');
info.textContent='正在上传到软件目录…';
const r = await uploadFile('/api/admin/upload', f);
if(!r.ok){ info.textContent='× '+r.msg; UPF=null; return; }
if(!r.ok){ info.textContent='× '+r.msg; UPF=null;
dupCheckSha(inp, '', 'admin', 'ibtnGo', 'imsg'); // 上传失败:清预检状态不残留(决策 243 补记五)
return; }
UPF=r;
dupCheckSha(inp, r.sha256, 'admin', 'ibtnGo', 'imsg'); // 决策 243 补记五:选完文件即预检(命中提醒+打开钮禁用)
// 2026-10-12 重设计:价格类只认标准模板 Excel;工程类认 .cos4/.cos;
// 2026-10-19 加 .swt(深圳数据交换标准,classify 返回 "swt")
const ok = (KIND!=='project') ? (r.state==='price_xlsx')
@@ -1728,7 +1752,7 @@ async function aimpProjFile(){
}
function aimpCommon(){
const name=$('iname').value.trim(), pv=PVAL($('iper'));
if(!name){ $('aimsg').textContent='工程名称必填(左边共用字段)'; return null; }
if(!name){ $('aimsg').textContent='名称必填(左边共用字段)'; return null; }
if(pv.f==null||pv.t==null){ $('aimsg').textContent='基准期次必填:点开选起~止(同月就选同一个)'; return null; }
if(!iprov.value||!icity.value||!idist.value){ $('aimsg').textContent='请填写:地区(省/市/区)'; return null; }
if(!ibuid.value.trim()){ $('aimsg').textContent='请填写:建设单位'; return null; }
@@ -1767,7 +1791,9 @@ async function loadImpFilters(){
.sort((x,y)=>x.localeCompare(y,'zh'));
window.__BU_OPTS = buOpts;
comboFree($('ibuid'), () => window.__BU_OPTS);
dictFillSel(ipub, dictOrgs('publisher'), '', 'publisher');
// 2026-11-02 主人定:市场价下拉=询价单位字典(+新增也归询价单位);信息价保持发布单位
const pubCat = (KIND==='market') ? 'inquirer' : 'publisher';
dictFillSel(ipub, dictOrgs(pubCat), '', pubCat);
// 单价类型:排除 0「未标注」(与工作台同口径)。历史批次本身就是 0 的,编辑时要把它带回来,
// 否则下拉里没有对应项 → 值对不上 → 看着像"没选",一保存就把状态改没了。
ifk.innerHTML = kindOptions(f.file_kind, null);
@@ -1787,7 +1813,7 @@ async function doImport(){
// 决策 245:工程类校验文案与工作台「打开项目」逐字同款(两侧同规则)
if(!isPrice){
if(!UPF){ imsg.textContent='请选择文件'; return; }
if(!iname.value.trim()){ imsg.textContent='请填写:工程名称'; return; }
if(!iname.value.trim()){ imsg.textContent='请填写:名称'; return; }
const pv0=PVAL($('iper'));
if(pv0.f==null||pv0.t==null){ imsg.textContent='基准期次必填:点开选起~止(同一个月就选同一个)'; return; }
if(!iprov.value||!icity.value||!idist.value){ imsg.textContent='请填写:地区(省/市/区)'; return; }
@@ -1796,7 +1822,7 @@ async function doImport(){
}
const miss=[];
if(isPrice && !UPF) miss.push('标准模板 Excel 文件(每次只能一个)');
if(!iname.value.trim()) miss.push('工程名称');
if(!iname.value.trim()) miss.push('名称');
const pv=PVAL($('iper'));
const p1=pv.f, p2=pv.t;
if(isPrice && (p1==null||p2==null)) miss.push('基准期次(点开选起~止,同一个月就选同一个)');
@@ -1895,6 +1921,8 @@ async function edit(id){
const r=d.rows.find(x=>x.id===id); if(!r){ alert('找不到这一条'); return; }
const isP=(KIND!=='project');
document.getElementById('irowEpub').style.display = isP?'flex':'none';
// 2026-11-02 主人定:市场价编辑=「询价单位」,信息价=「发布单位」(随页签 KIND)
document.getElementById('epubLbl').textContent = (isP && KIND==='market') ? '询价单位 *' : '发布单位 *';
document.getElementById('irowEbuid').style.display = isP?'none':'flex';
document.getElementById('irowEfk').style.display = isP?'none':'flex';
ename.value=r.name||''; enote.value=r.note||'';
@@ -1902,7 +1930,8 @@ async function edit(id){
await dictLoad();
// 地区三联动 + 单位下拉:都取自数据源字典;老数据里字典没有的值会自动补进选项,不会丢
dictFillRegion([eprov,ecity,edist],[r.province||'',r.city||'',r.district||'']);
dictFillSel(epub, dictOrgs('publisher'), r.publisher||'', 'publisher');
const epubCat = (KIND==='market') ? 'inquirer' : 'publisher'; // 2026-11-02:市场价编辑用询价单位字典
dictFillSel(epub, dictOrgs(epubCat), r.publisher||'', epubCat);
dictFillSel(ebuid, dictOrgs('builder'), r.bulid_unit||'', 'builder');
if(!isP){
efk.innerHTML = kindOptions(f.file_kind, r.file_kind);
@@ -1953,7 +1982,7 @@ document.querySelectorAll('.tab[data-kind]').forEach(t=>t.onclick=()=>{
t.classList.add('on'); KIND=t.dataset.kind; SORT={key:'',dir:'DESC'}; syncBtns();
XLAST=KIND;
if(XACT>=0){ XACT=-1; renderXTabs(); showDetail(false); xsave(); } // 从明细标签切回列表区(动态标签保留)
ldWrap('','正在加载列表…',()=>load(1)); // 列表取数期间挂进度条(快则不闪)
ldWrap('','正在加载列表…',()=>{ load(1); loadFilters(); }); // 列表取数期间挂进度条(快则不闪);loadFilters=过滤文案随页签刷新(2026-11-02 询价单位/发布单位)
});
// 2026-10-13 主人定:切标签没出全数据前要有进度条 —— 走共享层 ldWrap(det() 进来的路径
// 已有即时遮罩,ldWrap 检测到就只报阶段不接管;这里兜住「直接点标签」的路径)
@@ -2057,8 +2086,6 @@ function inqCell(r){
}
function syncBtns(){
// 标准模板只对信息价/市场价有意义,工程标签下隐藏(显示了点了也没用)
$('btnTpl').style.display = (KIND==='project') ? 'none' : '';
// 新增筛选随标签显隐(2026-10-07):历史项目=单价类型/建设单位/总价区间;价格标签=发布单位
const isP = (KIND==='project');
// ⚠️ _combo 是组合框对象(无 .style),要切的是它的 wrap 外层;_cin 本身就是包装层
@@ -2437,11 +2464,15 @@ async function qUnbind(){
ids.forEach(id=>{ const ck=document.querySelector('input.qbindck[data-id="'+id+'"], #qtbl input[data-id="'+id+'"]'); if(ck) ck.checked=false; });
}
/* 决策 213 补记七:组表「单位工程名称」点击 → 追踪定位到本批次明细原数据树的那条清单。 */
window.locBill = async function(bid, uwid){
/* 决策 213 补记七:组表「单位工程名称」点击 → 追踪定位到本批次明细原数据树的那条清单。
决策 243 补记(2026-11-01):工料机「源」浮层行点击(from='src')从明细页发起,
当前批次=DID;此前一律 det(QBID) —— 明细直开时 QBID=0/旧批次,定位必失败还会把 DID 拽走(主人实测报障)。 */
window.locBill = async function(bid, uwid, from){
const bid_batch = from === 'src' ? DID : QBID;
showPage('detail');
await det(QBID, QBNAME || ('批次 #' + QBID), 'project');
onWBTab('p3');
const _t = XTABS.find(x => x.id === bid_batch && x.kind !== 'inq');
await det(bid_batch, (bid_batch === QBID && QBNAME) || (_t && _t.name) || ('批次 #' + bid_batch), 'project');
await onWBTab('p3'); // loadTab 是异步,不 await 会与 rawPick 抢渲染
await rawPick('uw', uwid, null);
const find = () => document.querySelector('#drawbody tr.brow[data-bid="' + bid + '"]');
let tr = find();
@@ -2475,10 +2506,94 @@ async function qDelFile(fid){
}
/* ============ 导出设置(导出文件数据结构库)====================
2026-11-02 主人定:四列列表(同后缀聚簇、组间明显横线、组首行标件数)、
右上「添加」选文件即入库(同名升级替换前确认)、每文件 下载/删
(删=二次确认,该后缀最后一件加警示不阻止)。口径详见弹框 DOM 注释。 */
let FRAMES = [];
async function openFrames(){
$('fmask').classList.add('on');
$('fmsg').textContent='';
await framesLoad();
}
function closeFrames(){ $('fmask').classList.remove('on'); }
fmask.onclick = e => { if(e.target===fmask) closeFrames() };
async function framesLoad(){
try{
const r = await (await fetch('/api/admin/frames')).json();
FRAMES = r.rows || [];
}catch(e){ FRAMES = []; $('fmsg').textContent='列表读取失败:'+e; }
framesRender();
}
function framesRender(){
const rows = FRAMES; // 后端已排:后缀聚簇(cos4 在前)、组内入库时间倒序
const cnt = {};
rows.forEach(r => cnt[r.suffix] = (cnt[r.suffix]||0)+1);
let html='', last=null, no=0;
for(const r of rows){
no++;
const first = r.suffix!==last;
const sep = (first && last!==null)
? ' style="border-top:3px double #7d92ad"' : ''; // 组间明显横线(双线)
html += `<tr${sep}>`
+ `<td class="c">${no}</td>`
+ `<td>${first ? r.suffix+'('+cnt[r.suffix]+'件)' : ''}</td>`
+ `<td>${(r.extracted_at||'').slice(0,10)}</td>`
+ `<td>${r.original_name||''}`
+ ` <a href="/api/admin/frames/file/${r.sig}" style="color:#26405e">下载</a>`
+ ` <a href="javascript:framesDel('${r.sig}')" style="color:#c0392b">删</a></td>`
+ `</tr>`;
last = r.suffix;
}
$('frameBody').innerHTML = html
|| '<tr><td colspan="4" class="c" style="color:#888">还没有导出文件数据结构,点右上「添加」导入</td></tr>';
}
function framesAdd(){ $('ffile').value=''; $('ffile').click(); }
async function framesSeed(inp){
const f = inp.files && inp.files[0];
if(!f) return;
const stem = f.name.replace(/\.[^.]*$/,'');
if(FRAMES.some(r => r.original_name===stem)
&& !confirm(`已存在同名结构《${stem}》,将升级替换(旧内容被覆盖)。\n继续?`)){ inp.value=''; return; }
try{
const res = await fetch('/api/admin/frames/seed', {method:'POST',
headers:{'Content-Type':'application/octet-stream',
'X-File-Name':encodeURIComponent(f.name)},
body:f});
const r = await res.json();
if(!r.ok){ $('fmsg').textContent = r.msg || '入库失败'; return; }
$('fmsg').textContent = r.kind==='pack'
? `骨架包已安装 ${r.installed.length} 件` : `已入库《${r.name}》`;
await framesLoad();
}catch(e){ $('fmsg').textContent='入库请求失败:'+e; }
finally{ inp.value=''; }
}
async function framesDel(sig){
const r = FRAMES.find(x=>x.sig===sig);
if(!r) return;
const isLast = FRAMES.filter(x=>x.suffix===r.suffix).length===1;
const warn = isLast
? `\n\n⚠ 这是 .${r.suffix} 最后一件:删除后手工导出该格式将不可用。` : '';
if(!confirm(`确定删除《${r.original_name}》?${warn}\n\n删除后可用同名文件重新「添加」恢复。`)) return;
try{
const res = await fetch('/api/admin/frames/delete', {method:'POST',
headers:{'Content-Type':'application/json'}, body: JSON.stringify({sig})});
const j = await res.json();
if(!j.ok){ $('fmsg').textContent = j.msg || '删除失败'; return; }
await framesLoad();
}catch(e){ $('fmsg').textContent='删除请求失败:'+e; }
}
/* ============ 数据源面板(地区 / 发布单位 / 建设单位)====================
这里的选项就是各页录入下拉的唯一来源。改完不需要重启,下次打开弹窗即生效。 */
let DCUR = 'region'; // region | publisher | builder
const DORG_TITLE = {publisher:'发布单位', builder:'建设单位'};
let DCUR = 'region'; // region | inquirer | publisher | builder
const DORG_TITLE = {publisher:'发布单位', inquirer:'询价单位', builder:'建设单位'}; // 2026-11-02 主人定:加询价单位(市场价专用)
function openDict(){ dmask.classList.add('on'); dmsg.textContent=''; dictTab(DCUR); }
/* 关闭前补一次保存:上传设置是「即改即存」,而 onchange 要等失焦才触发 ——
@@ -2498,14 +2613,14 @@ async function closeDict(){
function dictTab(cat){
DCUR = cat;
['region','publisher','builder','upload'].forEach(c=>{
['region','inquirer','publisher','builder','upload'].forEach(c=>{
const t=document.getElementById('dtab-'+c);
if(t) t.classList.toggle('on', c===cat);
});
document.getElementById('dpane-region').style.display = (cat==='region')?'':'none';
// ⚠️ org 面板只有「发布单位 / 建设单位」两个标签用;写成 cat!=='region' 会让 upload 也带上它,
// ⚠️ org 面板只有「询价单位 / 发布单位 / 建设单位」三个标签用;写成 cat!=='region' 会让 upload 也带上它,
// 于是上传设置里凭空多出一张表和一个「新增」按钮(2026-10-06 修)
document.getElementById('dpane-org').style.display = (cat==='publisher'||cat==='builder')?'':'none';
document.getElementById('dpane-org').style.display = (cat==='publisher'||cat==='inquirer'||cat==='builder')?'':'none';
// 「上传设置」不是字典,切过去时不渲染字典表(dictRender 会读 /api/dict,白跑一次)
document.getElementById('dpane-upload').style.display = (cat==='upload')?'':'none';
const bAdd = document.getElementById('btnDictAdd');
@@ -2597,7 +2712,8 @@ async function dictRender(){
}).join('');
rg.innerHTML = (DICT_ADD === 'region' ? dictAddRowRegion() : '') + rows;
} else {
const list = (DCUR === 'publisher' ? DICT.publishers : DICT.builders) || [];
const list = (DCUR === 'publisher' ? DICT.publishers
: DCUR === 'inquirer' ? DICT.inquirers : DICT.builders) || [];
DICT_ROWS = dictSort(list);
const rows = DICT_ROWS.map((o, i) => {
if (DICT_EDIT && DICT_EDIT.id === o.id) return dictEditRowOrg(o);

View File

@@ -1121,6 +1121,9 @@ 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 传原始下标)
/* 决策 243(2026-11-01)项目级视图 12 列(0序号 1源 2编码…9含税 10取消采纳 11备注)→ 数据 r[](0=id…10=备注)。
⚠️ 与 COLS.lme 列序联动改:原数据卡映射/排序 + p3 页签排序(workbench lmeRenderRows)共用这一张表。 */
const LME_VIEW_DS = { 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 11: 10 };
const RAW_LME_SUB_TIP = '原软件按子级组成重算,改母价可能不生效';
function rawLmeSort(k) {
if (RV_LME_SORT.k === k) RV_LME_SORT.dir = -RV_LME_SORT.dir;
@@ -1148,8 +1151,9 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
数据集差异按主人原文保留:项目工料机走单位过滤,此处全量(含台班/配合比)。
列头恒=COLS.lme(决策 148 统一「数量」);单位工程级卡走下方原路径,列头亦统一「数量」(决策 190)。 */
RV_LME_IDS = null; RV_LME_DS = {}; RV_LME_O2V = null;
for (let i = 1; i <= 10; i++) RV_LME_DS[i] = i; // 恒等映射:视图位=数据位(双击改价 lmePriceCells 用)
const view = sortRows(rows, RV_LME_SORT.k, RV_LME_SORT.dir, RV_LME_NUM);
for (const k in LME_VIEW_DS) RV_LME_DS[k] = LME_VIEW_DS[k]; // 决策 243 源列后视图位→数据位(单击编辑/lmePriceCells/找格共用)
const _sk = RV_LME_DS[RV_LME_SORT.k]; // 排序键翻译成数据位(RV_LME_SORT.k 存视图位,表头 ▲/▼ 靠它对位)
const view = sortRows(rows, _sk == null ? -1 : _sk, RV_LME_SORT.dir, RV_LME_NUM);
const backend = !!RVO.lmeBackend; // 决策 147/149:后台=后台项目工料机列集(剔除 wb 专列)
const cols = backend ? COLS.lme.filter(c => c[5] !== 'wb') : COLS.lme; // 决策 148:列头统一「数量」,与行格严格同列
const body = renderLme(view, { rowClass: 'lmerow', subSet: subSet,
@@ -1380,7 +1384,16 @@ function rvCachePutNow() { // 立即把当前 DOM 写回缓存(
if (RV_CACHE_PUT_T) { clearTimeout(RV_CACHE_PUT_T); RV_CACHE_PUT_T = null; }
const b = document.getElementById(RVO.bodyEl);
const k = _rvCacheKey();
if (b && RV_CACHE[k]) RV_CACHE[k] = { html: b.innerHTML, scroll: b.scrollTop };
if (b && RV_CACHE[k]) {
// 决策 252(2026-11-01 主人定):选中态(sel/subsel)不入缓存——它是易变状态,恢复
// 全权归 _p3RestoreSel/_rawSceneGuard(含「只选定额不清单」口径)。否则切回时缓存 html
// 自带旧 sel「复活」,与定额恢复叠加成双选中(实测报障)。
const h = b.innerHTML
.replace(/(class="[^"]*?)\bsel\b/g, '$1')
.replace(/(class="[^"]*?)\bsubsel\b/g, '$1')
.replace(/class="\s*"/g, '');
RV_CACHE[k] = { html: h, scroll: b.scrollTop };
}
}
function rvCachePut() { // DOM 变化(排序/树折叠)后把最新状态写回缓存
// 决策 204(2026-10-26 主人定,修把手 ± 卡顿):改防抖——停 250ms 才序列化一次整表 HTML。
@@ -1946,7 +1959,8 @@ function lmeSrcPop(btn, code) {
function lmeSrcGo(tr) {
haoPopClose();
const bid = Number(tr.dataset.bid), uwid = tr.dataset.uwid;
if (typeof locBill === 'function') locBill(bid, uwid === '' ? null : Number(uwid));
// 第 3 参 'src':源钮从明细页发起(后台当前批次=DID,与组表入口的 QBID 不同)——后台 locBill 据此选批次
if (typeof locBill === 'function') locBill(bid, uwid === '' ? null : Number(uwid), 'src');
}
/* 按按钮右下角定位:默认浮层左上角贴按钮右下角;下方放不下翻转成浮层左下角贴按钮右下角;
右边溢出则整体收进视口。数据到货后尺寸会变,须再 place 一次。 */
@@ -1972,19 +1986,23 @@ function _normSceneCapture(bodyEl) {
const sub = bodyEl.querySelector('tr.subsel');
return { normsel: sub ? (sub.dataset.nid || null) : null };
}
/* 一次 apply:sel + 定额 subsel(子行不在则点展开钮)+ 滚动定位。返回是否全部到位。 */
/* 一次 apply:sel + 定额 subsel(子行不在则点展开钮)+ 滚动定位。返回是否全部到位。
决策 252(2026-11-01 主人定):带 normsel(最后点的是定额)→ **只恢复定额 subsel**,
清单行只作展开宿主(保证子行能渲染出来),不点 sel、不滚动清单——不同时选中定额和清单。 */
function _rawSceneApply(bodyEl, bid, normsel) {
let subDone = !normsel;
let billEl = null;
if (bid) {
billEl = bodyEl.querySelector('tr.brow[data-bid="' + bid + '"]');
if (!billEl) return false; // 重画中,行还没回来
if (!billEl.classList.contains('sel')) {
if (!normsel && !billEl.classList.contains('sel')) {
bodyEl.querySelectorAll('tr.sel').forEach(x => x.classList.remove('sel'));
billEl.classList.add('sel');
}
}
if (normsel) {
// 决策 252:渲染缓存(rvCachePut)会把历史 sel 带回来——只选定额时先清掉,保单选
bodyEl.querySelectorAll('tr.sel').forEach(x => x.classList.remove('sel'));
const sub = bodyEl.querySelector('tr.sub[data-nid="' + normsel + '"]');
if (sub) {
if (!sub.classList.contains('subsel')) {
@@ -1998,7 +2016,7 @@ function _rawSceneApply(bodyEl, bid, normsel) {
if (btn) btn.click(); // 展开定额区(rawTog/tgNorm 通吃),下轮 guard 补 subsel
}
}
if (billEl) billEl.scrollIntoView({ block: 'center' });
if (billEl && !normsel) billEl.scrollIntoView({ block: 'center' });
return subDone;
}
/* 守窗自愈:切页签后 rawbody 仍会被异步重画(骨架条/搜索重高亮/对比联动)洗掉 sel/subsel——
@@ -2014,8 +2032,9 @@ function _rawSceneGuard(bodyEl, bid, normsel, ms) {
const cur = bodyEl.querySelector('tr.sel');
if (cur && bid && cur.dataset.bid && cur.dataset.bid !== bid) return;
const subEl = normsel ? bodyEl.querySelector('tr.subsel') : null;
const ok = (!bid || (billEl && billEl.classList.contains('sel'))) &&
(!normsel || (subEl && subEl.dataset.nid === normsel));
// 决策 252:定额模式只守 subsel,且 sel 必须不在(被重画带回就再清)
const ok = (!bid || normsel || (billEl && billEl.classList.contains('sel'))) &&
(!normsel || (!cur && subEl && subEl.dataset.nid === normsel));
if (!ok) {
mark.tries++;
_rawSceneApply(bodyEl, bid, normsel);
@@ -2558,7 +2577,9 @@ function dictRegions(level) {
}
/** 单位名列表。cat: publisher | builder */
function dictOrgs(cat) {
return (cat === 'publisher' ? DICT.publishers : DICT.builders || []).map(o => o.name);
// 2026-11-02 主人定:加「询价单位」(inquirer,市场价专用,与信息价的发布单位分开)
const key = { publisher: 'publishers', inquirer: 'inquirers', builder: 'builders' }[cat] || 'builders';
return (DICT[key] || []).map(o => o.name);
}
/** 字典口径的地区三联动(导入 / 编辑 / 打开工程这类**录入**下拉都走这里)。
签名沿用旧 dictFillRegion(els, cur),新增第三参 opt 透传给 regFill。 */
@@ -2696,6 +2717,79 @@ async function uploadFile(url, f) {
return r.json();
}
/* ---- 导入预检(决策 243 补记五,2026-11-02 主人定「选完文件就提醒」)----
选完工程文件本地算 SHA-256(不上传文件字节)→ /api/dup_check 查两侧已有 →
命中=弹框内红字提醒 +「打开」钮禁用;文案与提交拦截(决策 242/243)逐字同源。
⚠️ 防遗留误判铁律(主人 2026-11-02 令「不要记忆遗留,导致误判新项目的导入」):
检测状态严格绑定本次所选文件——每次进入令牌+1,旧异步结果一律丢弃;
清空选择即清全部状态恢复按钮;预检接口故障**不拦导入**(提交后服务端拦截兜底)。 */
function _dupReset(inp, btnId, msgId) {
delete inp.dataset.dupHit;
const btn = document.getElementById(btnId);
if (btn) { btn.disabled = false; if (btn.dataset.dupLabel) { btn.textContent = btn.dataset.dupLabel; delete btn.dataset.dupLabel; } }
const msg = document.getElementById(msgId);
if (msg && msg.dataset.dupErr === '1') { msg.textContent = ''; msg.style.color = ''; delete msg.dataset.dupErr; }
}
function _dupToken(inp) {
inp.dataset.dupToken = String(Number(inp.dataset.dupToken || 0) + 1);
const tk = inp.dataset.dupToken;
return () => inp.dataset.dupToken === tk; // false=期间又选了别的文件,本次结果作废
}
function _dupHitShow(inp, btnId, msgId, text) {
inp.dataset.dupHit = '1';
const btn = document.getElementById(btnId);
if (btn) btn.disabled = true;
const msg = document.getElementById(msgId);
if (msg) { msg.textContent = text; msg.style.color = '#d33'; msg.dataset.dupErr = '1'; }
}
function _dupBusy(btnId, msgId) { // 检测中:按钮占位防呆,返回还原函数
const btn = document.getElementById(btnId);
if (btn) { btn.dataset.dupLabel = btn.textContent; btn.textContent = '检测中…'; btn.disabled = true; }
return () => {
const b = document.getElementById(btnId);
if (b) { b.disabled = false; if (b.dataset.dupLabel) { b.textContent = b.dataset.dupLabel; delete b.dataset.dupLabel; } }
};
}
function _fileSha256(file) {
return file.arrayBuffer().then(buf => crypto.subtle.digest('SHA-256', buf))
.then(d => Array.prototype.map.call(new Uint8Array(d), b => ('0' + b.toString(16)).slice(-2)).join(''));
}
/* 给定 sha 直接查(后台用:pickFile 上传响应里就带 sha256,不必本地重算)。
sha 为空 = 上传失败等拿不到哈希 → 只清状态不查,绝不凭空判重复。 */
function dupCheckSha(inp, sha, side, btnId, msgId) {
_dupReset(inp, btnId, msgId);
const fresh = _dupToken(inp);
sha = String(sha || '').toLowerCase();
if (!/^[0-9a-f]{64}$/.test(sha)) return; // 与服务端同门槛:不是完整 sha256 不查(防误判)
const restore = _dupBusy(btnId, msgId);
fetch('/api/dup_check?side=' + side + '&sha256=' + encodeURIComponent(sha))
.then(r => r.json())
.then(r => {
if (!fresh()) return; // 遗留结果丢弃:期间已换文件
restore();
if (r && r.ok && r.hits && r.hits.length) _dupHitShow(inp, btnId, msgId, r.hits[0]);
})
.catch(() => { if (fresh()) restore(); }); // 故障不拦:静默放行,提交后服务端兜底
}
/* 工作台用:提交时才上传 → 选文件时本地算哈希预检(file input 的 onchange 调)。 */
function dupScanFile(inp, side, btnId, msgId) {
const fresh = _dupToken(inp); // 先领令牌再清状态:算哈希期间换文件=本次作废
_dupReset(inp, btnId, msgId);
const f = inp.files && inp.files[0];
if (!f) return; // 清空选择:状态已清,不残留任何旧结论
const restore = _dupBusy(btnId, msgId);
_fileSha256(f).then(sha => {
if (!fresh()) return; // 期间换了文件:本次哈希作废
return fetch('/api/dup_check?side=' + side + '&sha256=' + encodeURIComponent(sha))
.then(r => r.json())
.then(r => {
if (!fresh()) return;
restore();
if (r && r.ok && r.hits && r.hits.length) _dupHitShow(inp, btnId, msgId, r.hits[0]);
});
}).catch(() => { if (fresh()) restore(); }); // 哈希算不出/接口故障:放行,服务端兜底
}
async function saveAs(url, name) {
const nm = name || '下载文件';
// 决策 91(主人定「全部是另存为」):壳内(pywebview)优先原生另存为对话框——

View File

@@ -103,7 +103,7 @@ a:hover{text-decoration:underline}
</div>
</div>
<script src="common.js?v=20261021e"></script>
<script src="common.js?v=20261101a"></script>
<script>
/* 会话管理页:照后台「项目界面」的版式,管的是**还没入库**的工作台会话。
会话库不自动清(SESSION_KEEP_DAYS=0),要删只能在这里手动删。

View File

@@ -566,7 +566,7 @@ body.histdrag{user-select:none}
<div class="mbody" data-page-node-id="OoZAOtJ0ridSwFtXLChDyg" style="display:flex;flex-direction:row;gap:16px;align-items:stretch">
<!-- 左栏:宽由 CSS 管(#oleft 604;展开 .exp 388 等比缩小),行距补回 .mbody 的 column gap:10px -->
<div id="oleft" style="flex:none;min-width:0;display:flex;flex-direction:column;gap:10px">
<div class="row" id="ofileRow" data-page-node-id="TgF4geYkFIZIFYQD6sNZHB"><span data-page-node-id="Ve3MJBmbfhkGXf26tQdqAA">全国电子标书</span><input type="file" id="ofile" onchange="autoName()" data-page-node-id="I2kkcqsdiXGL40535vRd25"></div>
<div class="row" id="ofileRow" data-page-node-id="TgF4geYkFIZIFYQD6sNZHB"><span data-page-node-id="Ve3MJBmbfhkGXf26tQdqAA">全国电子标书</span><input type="file" id="ofile" onchange="autoName();dupScanFile(this,'wb','obtnGo','omsg')" data-page-node-id="I2kkcqsdiXGL40535vRd25"></div>
<div class="row" data-page-node-id="uWAVJwQc4PGXMkVwrLTAWX"><span data-page-node-id="A69LDfDYOD8sJ9RNmYrp7u">工程名称 *</span><input id="oname" placeholder="选文件后自动带出文件名,可改" data-page-node-id="M0HGCQ9uGkUnRnXEshiiDD"></div>
<div class="row" data-page-node-id="3Yg2dLI3BNEr0iDvHyyFZR"><span data-page-node-id="a4VMhIZdcf8l3z3znIflbI">基准期次 *</span><input id="oper" placeholder="点这里选起~止(同月就选同一个)" data-page-node-id="NZlB1CroFZvcWL0CyQTZDE"></div>
<div class="row" data-page-node-id="chlcT8xdVI2rRjz4HZDVWA"><span data-page-node-id="x8RmHqmvGQTydhqMUR8xAP">地区 *</span>
@@ -656,7 +656,6 @@ body.histdrag{user-select:none}
<div class="dlg" style="width:min(880px,94vw)">
<div class="dh"><b>附件</b><span class="close" onclick="closeInq()">×</span></div>
<div style="padding:14px 16px;display:flex;flex-direction:column;gap:10px">
<div class="tip" style="padding:0">附件来自对比框点「采纳」的清单或工料机行——同一附件被采纳多次只显示一个。清单采纳的进「清单附件」,工料机采纳的进「工料机附件」。点附件名,右侧显示它对应的项目;勾选后点「批量下载」,选一次位置即可全部存入。</div>
<div class="inqtabs" id="inqTabs">
<button class="inqtab on" id="inqTabBill" onclick="inqTab('bill')">清单附件(0)</button>
<button class="inqtab" id="inqTabLme" onclick="inqTab('lme')">工料机附件(0)</button>
@@ -676,10 +675,12 @@ body.histdrag{user-select:none}
</div>
</div>
<script src="common.js?v=20261021e"></script>
<script src="common.js?v=20261101a"></script>
<script src="period.js"></script>
<script>
let SID=0, CUR=null, CURTYPE='lme', HROWS=[];
let CUR_ADOPT=''; // 决策 250(2026-11-01 主人定):当前选中行的采纳备注(pick 时从行备注格取,
// 采纳/取消/手工编辑同步)——对比框「已采纳」标记按它反推,与库同源不漂
let MANUAL=false; // 2026-10-19:当前是手工工程(无源文件)→ 禁止原格式导出/重新解析
/* 当前渲染进历史表的那份(已按精确度过滤 + 按时间/价格排序)。
「采纳」必须从这里取值,不能用 HROWS —— HROWS 未过滤未排序,下标对不上会采纳错历史价。 */
@@ -818,7 +819,8 @@ const _apPick = () => {
const cur = document.querySelector('.tab.on') ? document.querySelector('.tab.on').dataset.p : null;
const cont = { p0: '#tb0', p1: '#tb1', p2: '#tb2', p3: '#rawbody' }[cur];
if (!cont) return;
if (document.querySelector(cont + ' tr.sel')) return; // 本页已有选中行不抢
// 决策 252:定额 subsel 也算「本页已有选中」——切回只恢复定额时,_apPick 不再抢点第一行清单
if (document.querySelector(cont + ' tr.sel, ' + cont + ' tr.subsel')) return;
const cand = [...document.querySelectorAll(cont + ' tr')]
.find(tr => tr.offsetParent && /pick\(/i.test(tr.getAttribute('onclick') || ''));
if (cand) cand.click();
@@ -1437,6 +1439,7 @@ function lmeRmkSync(tr, lmeid, v){
if(typeof RV_CACHE !== 'undefined')
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
if(typeof rvCachePut === 'function') rvCachePut();
if(CUR && CURTYPE === 'lme' && String(CUR.id) === String(lmeid)) CUR_ADOPT = v; // 决策 250:判定源同步
}
/* 规格 2026-10-16 ③:定额子行点选=纯视觉选中(.subsel 与清单行 tr.sel 同配色整套)。
@@ -1765,6 +1768,7 @@ async function openDlg(){
$('omask').classList.add('on'); // 规格 打开工程BUG2:先显示弹框再清值——清值派发的 input 事件在隐藏态测量会出错
if(IOPEN) impExcelToggle(); // 决策 233:每次打开先收回导入面板,回默认打开模式
$('ofile').value=''; $('oname').value=''; $('oname').dataset.auto=''; $('omsg').textContent='';
dupScanFile($('ofile'),'wb','obtnGo','omsg'); // 决策 243 补记五:弹框每开必清预检状态——上一文件的命中结论绝不带给新文件
// 决策 50 补漏(2026-11-01 主人拍板):期次连 dataset.pf/pt 一起清——PVAL 读 dataset,只清 .value
// 是「假清空」:重开看着空、点打开仍带旧期次提交;地区清 select 后补 comboSyncAll 刷新镜像框显示
setPeriod($('oper'),'',''); $('oprov').value=''; $('ocity').value=''; $('odist').value='';
@@ -1809,7 +1813,9 @@ async function doOpen(){
if(!r.ok){
let m=r.msg||'打开失败';
if(/无法识别|不是计价文件|不再支持 xml|文件头/.test(m)) m='本文件暂不支持,请与软件商联系';
$('omsg').textContent=m; return;
$('omsg').textContent=m;
if(/同一份文件|重复导入|必须先删除/.test(m)) alert(m); // 决策 243 补记五:重复类失败弹框兜底(预检漏网时)
return;
}
SID=r.session_id;
setManualMode(false);
@@ -2112,7 +2118,7 @@ rawPick = async function(k, id, el){
RVTAB=rec.rvtab; _rvStateSave(); rawTabs(); await rawDraw(); // 决策 219 修:等**真实渲染**完成(原 rawTab+盲等600ms 与 _apPick 250ms 抢跑)
tr=find();
}
if(tr){
if(tr && !(rec && rec.normsel)){ // 决策 252:最后点的是定额→切回只恢复定额(sel 由 guard 清,不在此恢复清单)
document.querySelectorAll('#rawbody tr.sel').forEach(x=>x.classList.remove('sel')); // 决策 219 修:清后加,与 pick() 同单选语义(原直接 add 造成双选中)
tr.classList.add('sel');
const sp=_scrollAncestor(document.querySelector('#rawbody'));
@@ -2218,6 +2224,9 @@ async function pick(type,id,tr){
const ptd=window.__lastPickedTd;
if(ptd && tr.contains(ptd)) ptd.classList.add('cellhit');
CURTYPE=type; CUR={id};
// 决策 250:随手取本行备注格(工料机/清单/原数据行都渲染 td.rmk)——已采纳标记的判定源
const _rmk = tr.querySelector ? tr.querySelector('td.rmk') : null;
CUR_ADOPT = _rmk ? ((_rmk.getAttribute('title') || _rmk.textContent || '') + '').trim() : '';
histCtxUI(); // 决策 208:行类型变了,工具栏上下文差异(来源置灰/单位框提示)即时跟随
// 搜索框/屏蔽词框**非粘性**(2026-10-11 主人定):所在行换了 → 必须清除上一次遗留的
// **所有**信息(关键字模式/检索结果状态/屏蔽词/框内文字),再带入本行名称——每行都从
@@ -2284,34 +2293,9 @@ function curPrice(){
结果里定位——在就提到第一条;不在(关键词过滤/检索分页)就把快照取回来放在第一条;
第二条起仍按正常搜索逻辑排序。取消采纳同步删除记忆;再采纳=覆盖(连续采纳认最后一次)。
开发阶段不做存量兼容。 */
const ADOPT_SRC_KEY='wb_adopt_src_v1';
function adoptSrcMap(){
try{ return JSON.parse(localStorage.getItem(ADOPT_SRC_KEY))||{}; }catch(e){ return {}; }
}
function adoptSrcStore(map){
try{ localStorage.setItem(ADOPT_SRC_KEY, JSON.stringify(map)); }catch(e){}
}
function rowSig(x){
return [x.name,x.attr,x.unit,x.price,x.proj,x.period_m].map(v=>(v==null?'':String(v))).join('|');
}
function adoptSrcSave(row){
if(!SID||!CUR||!CUR.id||!row) return;
const m=adoptSrcMap();
m[SID+':'+(CURTYPE==='lme'?'L':'B')+CUR.id]={
id:(CURTYPE==='lme'?null:row.bill_id), sig:rowSig(row), row:row};
adoptSrcStore(m);
}
function adoptSrcDrop(rowId){
if(!SID||rowId==null) return;
const m=adoptSrcMap();
delete m[SID+':'+(CURTYPE==='lme'?'L':'B')+rowId];
adoptSrcStore(m);
}
function curAdoptSrc(){
if(!SID||!CUR||!CUR.id) return null;
const e=adoptSrcMap()[SID+':'+(CURTYPE==='lme'?'L':'B')+CUR.id];
return (e&&e.row)?e:null;
}
/* 决策 250(2026-11-01 主人定):已采纳标记的判定源=**后端采纳备注**(CUR_ADOPT,随 pick 取自
行备注格、随采纳/取消/手工编辑同步)——原 adoptSrc localStorage 记忆机制(决策 138/139 的
id/签名定位)整组退役:换浏览器/清缓存记忆即丢,「已采纳」显示成「采纳」,与库分叉。 */
/* 采纳备注格式(决策 138,2026-10-20 主人定):采纳:名称+(项目名称)——有加号和中文括号,
价格不再写进备注。已采纳定位/置顶以 adoptSrc 的 id/签名为准,不再按备注文本反推。 */
function adoptTxtFor(x,isLme,old){
@@ -2372,15 +2356,17 @@ function renderHist(){
// 第二条起仍按正常搜索逻辑的顺序展示。取消采纳 = 记忆删除 → 复原为「采纳」。
// ⚠️ 引用 isLme —— 必须在其 const 声明之后(TDZ),故放表头渲染之后。
const adoptedBadge='<span class="tg tg-lo" title="已采纳——取消请点上方该行的「取消采纳」">已采纳</span>';
// 决策 250(2026-11-01 主人定):已采纳标记/置顶按后端采纳备注反推——备注以
// 「采纳:行名+行项目+」开头(adoptTxtFor 格式)即命中;同键多行取排序首条(精确档在前)。
// 当前结果没有匹配行(关键词过滤/翻页)就不置顶不标记——不再凭本地记忆凭空插行。
let adoptedIdx=-1;
const asrc=curAdoptSrc();
if(asrc){
const want=asrc.id!=null ? (x=>x.bill_id===asrc.id) : (x=>rowSig(x)===asrc.sig);
const pi=rows.findIndex(want);
if(pi>0) rows=[rows[pi]].concat(rows.slice(0,pi), rows.slice(pi+1));
else if(pi<0) rows=[Object.assign({},asrc.row)].concat(rows);
VISIBLE_ROWS=rows;
adoptedIdx=0;
if(/^采纳:/.test(CUR_ADOPT||'')){
const pi=rows.findIndex(x=>CUR_ADOPT.indexOf('采纳:'+(x.name||'')+'+'+(x.proj||'')+'+')===0);
if(pi>=0){
if(pi>0) rows=[rows[pi]].concat(rows.slice(0,pi), rows.slice(pi+1));
VISIBLE_ROWS=rows;
adoptedIdx=0;
}
}
const selfMode=$('fself') && $('fself').value==='yes';
const emptyMsg=selfMode
@@ -2625,8 +2611,7 @@ 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; }
adoptSrcSave(x); // 决策 139:记住采纳来源(id/签名+行快照),永远置顶
// ③ 刷新当前视图(9.1 清单行字段被覆盖、9.3 追加定额带临删——重拉才是真状态)
CUR_ADOPT=txt; // 决策 250:判定源同步(已采纳标记立即点亮)
// keepView:采纳后停在原组原行(规格 2026-10-16:点采纳跳至第一组 = bug,修复)
const cur=document.querySelector('.tab.on');
const p=cur?cur.dataset.p:'p2';
@@ -2655,7 +2640,7 @@ 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; }
adoptSrcDrop(billId); // 决策 139:取消采纳=删除来源记忆
if(CUR && String(CUR.id)===String(billId)) CUR_ADOPT=''; // 决策 250:判定源同步(标记立即复原)
// ③ 刷新当前视图(原数据/组表都可能是取消来源;撤缓存重拉即真状态;keepView 停在原地)
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
const cur=document.querySelector('.tab.on');
@@ -2704,19 +2689,19 @@ async function adoptLme(i){
if(prow){ prow[6]=rp.ntp; prow[7]=rp.taxrate; prow[8]=rp.taxp; }
const trp=document.querySelector(`#tb0 tr[data-id="${CUR.id}"]`);
if(trp){
if(trp.children[6]) trp.children[6].textContent=rm(rp.ntp);
if(trp.children[7]) trp.children[7].textContent=rm(rp.taxrate);
if(trp.children[8]) trp.children[8].textContent=rm(rp.taxp);
if(trp.children[7]) trp.children[7].textContent=rm(rp.ntp); // 决策 243 源列后:7=除税 8=税率 9=含税
if(trp.children[8]) trp.children[8].textContent=rm(rp.taxrate);
if(trp.children[9]) trp.children[9].textContent=rm(rp.taxp);
}
const trR0=document.querySelector(`#rawbody tr.lmerow[data-id="${CUR.id}"]`);
if(trR0){
const d6=trR0.children[6], d7=trR0.children[7], d8=trR0.children[8];
if(d6) d6.textContent=rm(rp.ntp);
if(d7) d7.textContent=rm(rp.taxrate);
if(d8) d8.textContent=rm(rp.taxp);
const d7=trR0.children[7], d8=trR0.children[8], d9=trR0.children[9]; // 决策 243 源列后同款
if(d7) d7.textContent=rm(rp.ntp);
if(d8) d8.textContent=rm(rp.taxrate);
if(d9) d9.textContent=rm(rp.taxp);
}
}
const txt=adoptTxtFor(x,true,_lmeAnchor||_oldLme); // 决策 219:旧价优先锚(第一次计算/合并后首次三价),无锚退改前现值
const txt=adoptTxtFor(x,true,_lmeAnchor||_oldLme); // 决策 251:旧价=导入时项目级原件三价(锚),锚空退改前现值
let r=null;
try{
r=await J('/api/session/remark',{method:'POST',headers:{'Content-Type':'application/json'},
@@ -2726,20 +2711,21 @@ async function adoptLme(i){
// 决策 172:采纳改价+备注落库后撤原数据取数缓存——否则切到原数据页命中旧缓存
//(价格/备注旧值,实测报障「项目级工料机汇总没同步更新」;与定额采纳/取消采纳同口径)
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
adoptSrcSave(x); // 决策 139:记住采纳来源(签名+行快照),永远置顶
CUR_ADOPT=txt; // 决策 250:判定源同步(已采纳标记立即点亮)
const row=(LME_ROWS||[]).find(y=>y[0]===CUR.id); // 数据先行:排序/重画后备注与取消采纳不丢
if(row){ row[10]=txt;
// 就地更新两格(不整表重画——重画会丢 tr.sel 选中态);取消采纳格口径=备注以「采纳:」开头(lmeAdoptCellHTML)
// 决策 243 源列后行 12 格:10=取消采纳 11=备注(原 9/10 顺延一位)
const tr0=document.querySelector(`#tb0 tr[data-id="${CUR.id}"]`);
const c9=tr0&&tr0.children[9], c10=tr0&&tr0.children[10];
if(c10){ c10.textContent=txt; c10.title=txt; }
if(c9) c9.innerHTML=`<a class="lk" onclick="cancelAdopt(${CUR.id})">取消采纳</a>`;
const c10=tr0&&tr0.children[10], c11=tr0&&tr0.children[11];
if(c11){ c11.textContent=txt; c11.title=txt; }
if(c10) c10.innerHTML=`<a class="lk" onclick="cancelAdopt(${CUR.id})">取消采纳</a>`;
// 决策 147/149:原数据·项目级卡同款两格原位同步(两表一体,改一处=改两处)
const trR=document.querySelector(`#rawbody tr.lmerow[data-id="${CUR.id}"]`);
if(trR){
const d9=trR.children[9], d10=trR.children[10];
if(d10){ d10.textContent=txt; d10.title=txt; }
if(d9) d9.innerHTML=`<a class="lk" onclick="cancelAdopt(${CUR.id})">取消采纳</a>`;
const d10=trR.children[10], d11=trR.children[11];
if(d11){ d11.textContent=txt; d11.title=txt; }
if(d10) d10.innerHTML=`<a class="lk" onclick="cancelAdopt(${CUR.id})">取消采纳</a>`;
}
}
renderHist(); // 已采纳灰标记:传递到本行
@@ -2757,20 +2743,20 @@ async function cancelAdopt(lmeId){
body:JSON.stringify({session_id:SID,lme_id:lmeId})});
}catch(e){ r=null; }
if(!r || !r.ok){ dlMsg('取消采纳失败:'+(r&&r.msg?r.msg:'服务未响应'),'err'); return; }
adoptSrcDrop(lmeId); // 决策 139:取消采纳=删除来源记忆
if(CUR && String(CUR.id)===String(lmeId)) CUR_ADOPT=''; // 决策 250:判定源同步(标记立即复原)
const row=(LME_ROWS||[]).find(y=>y[0]===lmeId);
if(row) row[10]='';
const tr0=document.querySelector(`#tb0 tr[data-id="${lmeId}"]`);
if(tr0){
const c9=tr0.children[9], c10=tr0.children[10];
if(c10){ c10.textContent=''; c10.title=''; }
if(c9) c9.innerHTML='<span style="color:#b9c4d2">—</span>';
const c10=tr0.children[10], c11=tr0.children[11]; // 决策 243 源列后:10=取消采纳 11=备注
if(c11){ c11.textContent=''; c11.title=''; }
if(c10) c10.innerHTML='<span style="color:#b9c4d2">—</span>';
}
const trR=document.querySelector(`#rawbody tr.lmerow[data-id="${lmeId}"]`); // 决策 147:原数据卡同款两格原位刷新
if(trR){
const c9=trR.children[9], c10=trR.children[10];
if(c10){ c10.textContent=''; c10.title=''; }
if(c9) c9.innerHTML='<span style="color:#b9c4d2">—</span>';
const c10=trR.children[10], c11=trR.children[11]; // 决策 243 源列后同款
if(c11){ c11.textContent=''; c11.title=''; }
if(c10) c10.innerHTML='<span style="color:#b9c4d2">—</span>';
}
loadAdopt();
renderHist();
@@ -2833,8 +2819,10 @@ function lmeSort(i){
lmeRenderRows();
}
function lmeRenderRows(){
// 显示位→数据位:取消采纳列(显示 9)不可排序;备注显示 10 = 数据 r[10],其余显示位与数据位同下标
const view=sortRows(LME_ROWS, LME_SORT.k, LME_SORT.dir, LME_NUM);
// 显示位→数据位:决策 243 加「源」列(显示 1)后整体错一位——2编码..9含税=数据1..8,
// 11备注=数据10;0序号/1源/10取消采纳无数据位=不排序(LME_VIEW_DS 见 common.js,与 COLS.lme 同步改)
const _dk=LME_VIEW_DS[LME_SORT.k];
const view=sortRows(LME_ROWS, _dk==null?-1:_dk, LME_SORT.dir, LME_NUM);
LME_VIEW=view;
// 决策 209:0 量行整行不显示后,全临删场景=0 行是**新口径常态**——提示语与「未打开工程」分开
$('tb0').innerHTML=renderLme(view,WB_OPTS)