feat: 决策59-63--类似清单对比区右栏/价格目录树改版/导入整份拒绝/数据目录拍平 + det类型传参修复

This commit is contained in:
lianjianwei2024
2026-10-14 18:07:54 +08:00
parent ab2ec78045
commit 9464f74e17
6 changed files with 210 additions and 44 deletions

View File

@@ -21,9 +21,9 @@ ROOT = os.path.join(APP_DIR, "ui") # 前端页面目录
CORE = os.path.join(APP_DIR, "core") # 解析器
DATA_DIR = os.path.join(PRJ_DIR, "data")
SRC_DIR = os.path.join(os.path.dirname(PRJ_DIR), "后台需要导入的项目") # 批量导入参考目录
UPLOAD_DIR = os.path.join(DATA_DIR, "uploads") # 导入的文件副本(存在软件内)
ATTACH_DIR = os.path.join(DATA_DIR, "attachments") # 价格批次原件 PDF(存在软件内)
INQ_DIR = os.path.join(DATA_DIR, "inquiry") # 项目询价附件 pdf/zip/rar(2026-10-06)
UPLOAD_DIR = os.path.join(DATA_DIR, "source_files") # 工作台原文件(原数据页数据源同这份;2026-10-14 拍平不分桶)
ATTACH_DIR = os.path.join(DATA_DIR, "price_attachments") # 市场价信息价附件(价格批次原件;2026-10-14 拍平不分桶)
INQ_DIR = os.path.join(DATA_DIR, "inquiry_attachments") # 询价附件(采购公告/厂商回复等;2026-10-14 拍平不分桶)
# 注:会话库的路径由 session_job 自己管(sess.connect()),这里不再重复定义常量
for _d in (UPLOAD_DIR, ATTACH_DIR, INQ_DIR):
os.makedirs(_d, exist_ok=True)
@@ -462,9 +462,9 @@ def _allowed_source_path(p):
def _save_to(dirpath, sha, safe_name, raw):
sub = os.path.join(dirpath, sha[:2])
os.makedirs(sub, exist_ok=True)
fp = os.path.join(sub, sha + "_" + safe_name)
# 2026-10-14 主人定:三个附件目录全部拍平,不再分 sha 前两位的桶子目录
os.makedirs(dirpath, exist_ok=True)
fp = os.path.join(dirpath, sha + "_" + safe_name)
if not os.path.exists(fp):
with open(fp, "wb") as f:
f.write(raw)
@@ -1297,10 +1297,10 @@ SESSION_KEEP_DAYS = 0
def _src_path(src_name):
"""会话的源文件还在不在软件里?src_name 形如「<sha256>_<原文件名>」,落在 uploads/<sha[:2]>/ 下"""
"""会话的源文件还在不在软件里?src_name 形如「<sha256>_<原文件名>」,落在 source_files/ 下(2026-10-14 拍平)"""
if not src_name:
return None
p = os.path.join(UPLOAD_DIR, src_name[:2], src_name)
p = os.path.join(UPLOAD_DIR, src_name)
if os.path.exists(p):
return p
# 老会话可能是别的名字:按文件名尾部兜底找一遍
@@ -1338,7 +1338,7 @@ def _purge_upload_files(names):
nm = os.path.basename((raw or "").strip())
if not nm or "_" not in nm:
continue # 老格式(无 sha 前缀)没有对应的 uploads 文件
fp = os.path.join(UPLOAD_DIR, nm[:2], nm)
fp = os.path.join(UPLOAD_DIR, nm) # 2026-10-14 拍平:不再有桶层
if not os.path.isfile(fp):
continue
try:
@@ -1368,18 +1368,73 @@ def _purge_orphan_uploads():
2026-10-11 起因:删除路径只清被删会话当时引用的文件,模拟数据工具等渠道留下的
孤儿会一直积压(实测 1799 个)。引用口径与 _purge_upload_files 完全一致
(sessions.src_name 分段 + batches.x_src_hash),复用它逐个判+删,返回删除个数。"""
(sessions.src_name 分段 + batches.x_src_hash),复用它逐个判+删,返回删除个数。
2026-10-14 拍平:不再分桶,直接扫目录,只认 <sha256>_<原名> 规矩文件。"""
if not os.path.isdir(UPLOAD_DIR):
return 0
gone = 0
for sub in os.listdir(UPLOAD_DIR):
d = os.path.join(UPLOAD_DIR, sub)
if not os.path.isdir(d) or len(sub) != 2:
for f in os.listdir(UPLOAD_DIR):
if not os.path.isfile(os.path.join(UPLOAD_DIR, f)) or "_" not in f:
continue
for f in os.listdir(d):
# 只认 <sha256>_<原名> 且桶号=sha 前两位的规矩文件,别的一律不碰
if f.startswith(sub) and "_" in f and os.path.isfile(os.path.join(d, f)):
gone += _purge_upload_files([f])
head = f.split("_", 1)[0].lower()
if len(head) < 8 or any(ch not in "0123456789abcdef" for ch in head):
continue # 只认 <sha256>_<原名> 规矩文件,别的一律不碰
gone += _purge_upload_files([f])
return gone
def _purge_orphan_inq():
"""启动自愈:询价附件目录里 inquiry_files 表不再引用的物理文件回收(幂等,2026-10-14 拍平同款)。"""
if not os.path.isdir(INQ_DIR):
return 0
c = conn()
try:
ref = {r[0] for r in c.execute(
"SELECT DISTINCT sha256 FROM inquiry_files WHERE sha256 IS NOT NULL")}
finally:
c.close()
gone = 0
for f in os.listdir(INQ_DIR):
fp = os.path.join(INQ_DIR, f)
if not os.path.isfile(fp) or "_" not in f:
continue
head = f.split("_", 1)[0].lower()
if len(head) < 8 or any(ch not in "0123456789abcdef" for ch in head) or head in ref:
continue
try:
os.remove(fp)
gone += 1
except OSError:
pass
return gone
def _purge_orphan_attach():
"""启动自愈:价格附件目录里未被 attachments 表引用的物理文件回收(幂等,2026-10-14 拍平同款)。
之前 _sweep_orphan_attach 只挂在删除流程上;现在启动也对账一遍,stored_path 里旧桶层
路径不影响——按文件名 sha 前缀对账,不依赖路径。"""
if not os.path.isdir(ATTACH_DIR):
return 0
c = conn()
try:
ref = {r[0] for r in c.execute(
"SELECT DISTINCT sha256 FROM attachments WHERE sha256 IS NOT NULL")}
finally:
c.close()
gone = 0
for f in os.listdir(ATTACH_DIR):
fp = os.path.join(ATTACH_DIR, f)
if not os.path.isfile(fp) or "_" not in f:
continue
head = f.split("_", 1)[0].lower()
if len(head) < 8 or any(ch not in "0123456789abcdef" for ch in head) or head in ref:
continue
try:
os.remove(fp)
gone += 1
except OSError:
pass
return gone
@@ -3023,10 +3078,15 @@ def api_import_price(con, body):
return {"ok": False, "msg": "导入失败:%s" % e}
fname = os.path.splitext(os.path.basename(path))[0]
fp1, fp2 = price.guess_period(fname)
# 2026-10-14 主人定:整份校验——空块/空记录/无目录数据一律整份拒绝,不再静默跳过
if not blocks:
return {"ok": False, "msg": "与模板数据结构不一致,请按模板数据结构录入"}
for b in blocks:
recs = price_xlsx.to_records([b])
if not recs:
continue
return {"ok": False, "msg": "与模板数据结构不一致,请按模板数据结构录入"}
if any(not (r.get("Class") or "").strip() for r in recs):
return {"ok": False, "msg": "与模板数据结构不一致,请按模板数据结构录入"}
s1 = b.get("period_start_m") if b.get("period_start_m") is not None else (fp1 if fp1 is not None else p1)
s2 = b.get("period_end_m") if b.get("period_end_m") is not None else (fp2 if fp2 is not None else p2)
if s1 is None:
@@ -4529,6 +4589,12 @@ def run():
_g = _purge_orphan_uploads() # 2026-10-11:uploads 零引用源文件副本对账回收(幂等)
if _g:
print("[启动自愈] 回收零引用源文件副本 %d 个" % _g)
_gi = _purge_orphan_inq() # 2026-10-14:询价附件零引用对账回收(拍平后同款自愈)
if _gi:
print("[启动自愈] 回收零引用询价附件 %d 个" % _gi)
_ga = _purge_orphan_attach() # 2026-10-14:价格附件零引用对账回收(启动也扫,不只挂在删除流程)
if _ga:
print("[启动自愈] 回收零引用价格附件 %d 个" % _ga)
# 2026-10-11:启动「数据过期」打印已取消(主人定)——打开即自动升级(决策 34)后「需重导」口径不再成立;
# stale_batches() 保留:/api/admin/summary 的 stale 字段仍返回,供后续一键批量升级(方案 B)复用。
srv = ThreadingHTTPServer(("127.0.0.1", PORT), Handler)

View File

@@ -552,7 +552,7 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
</div>
</div>
<script src="common.js?v=20261013m"></script>
<script src="common.js?v=20261013p"></script>
<script src="period.js"></script>
<script>
const $=id=>document.getElementById(id);
@@ -773,7 +773,7 @@ function rowProj(r){ // 工程(序号倒序:第一行是总数,往下递
<td class="r">${r.rows_lme??0}</td>
<td class="c">${inqCell(r)}</td>
<td class="c">${ell(r.imported_at||'')}</td>
<td class="c"><a href="javascript:det(${r.id},'${esc(r.name).replace(/'/g,"")}')">明细</a>
<td class="c"><a href="javascript:det(${r.id},'${esc(r.name).replace(/'/g,"")}','${r.kind||'project'}')">明细</a>
<a href="javascript:edit(${r.id})">编辑</a>
<a href="javascript:delBatch(${r.id},'${esc(r.name).replace(/'/g,"")}','清单 ${r.rows_bill??0} 条、工料机 ${r.rows_lme??0} 条')">删除</a></td>
</tr>`;
@@ -797,7 +797,7 @@ function rowPrice(r){ // 信息价 / 市场价:序号/纳入/名称/发布单
<td class="c">${ell(r.imported_at||'')}</td>
<td class="l">${att}</td>
<td class="l">${ell(r.note||'—')}</td>
<td class="c"><a href="javascript:det(${r.id},'${nm}')">明细</a>
<td class="c"><a href="javascript:det(${r.id},'${nm}','${r.kind||'info'}')">明细</a>
<a href="javascript:edit(${r.id})">编辑</a>
<a href="javascript:delBatch(${r.id},'${nm}','价格 ${r.rows_price??0} 条${r.attach_name?'、附件 '+r.attach_name:''}')">删除</a></td>
</tr>`;
@@ -882,8 +882,7 @@ function leavesHTML(sel){
if(n.leaf) out.push({id:n.id,name:p?p+' / '+n.name:n.name});
if(n.children&&n.children.length) walk(n.children,p?p+' / '+n.name:n.name);
});})(PD.tree,'');
return '<option value="0">(未分类)</option>'
+ out.map(o=>`<option value="${o.id}"${o.id===sel?' selected':''}>${esc(o.name)}</option>`).join('');
return out.map(o=>`<option value="${o.id}"${o.id===sel?' selected':''}>${esc(o.name)}</option>`).join('');
}
/* ---- 树渲染:编辑态(改名/新建)与确认态(↑↓✕)都整树重画,状态在 PD ---- */
function renderTree(){
@@ -897,14 +896,8 @@ function renderTree(){
<span style="font-weight:400;color:#6b7280;font-size:11.5px">(${grand} 条)</span></div>
${rootBarHTML()}
<div class="children">${renderNodes(PD.tree,0,0)}
<div class="pnode${PD.cur===0?' on':''}" style="${PD.cur===0?'':'color:#9aa4b2'}" onclick="pickDir(0)">
<span class="pnar em"></span><span class="nm">(未分类)</span><span class="cnt">${PD.nUncat}</span></div>
</div>
</div>
<div class="treefoot"><div class="tipp">
先点选目录,再用上方根目录按钮:+子目录 +平级 ✎ ↑ ↓ ✕(↑↓✕ 均需二次确认)。<br>
只有最底层目录(没有子目录)可以挂价格行、新增行。拖右侧分隔条调目录栏宽度(会记住),正中小把手可收起/展开。
</div></div>`;
</div>`;
}
/* ---- 根目录工具排(2026-10-13 决策 48 主人定:行内按钮全部收编到这里)----
六个按钮作用于「当前选中的目录」(PD.cur);(未分类)是虚拟节点不可改删移 ——
@@ -956,7 +949,7 @@ function nodeHTML(n){
// 展开 / 折叠把手:有子级可点,叶子放透明占位保持同级对齐(2026-10-13 主人定)
const hasKids=n.children&&n.children.length;
const ar=hasKids
? `<span class="pnar" title="展开 / 折叠" onclick="${stop}pdFold(${n.id})">${PD.fold[n.id]?'▸':'▾'}</span>`
? `<span class="pnar" title="展开 / 折叠" onclick="${stop}pdFold(${n.id})">${PD.fold[n.id]?'+':'−'}</span>`
: '<span class="pnar em"></span>';
let mid;
if(PD.ren===n.id){
@@ -1193,8 +1186,10 @@ function detLayout(mode){
$('dsecH').style.display = price?'block':'none';
$('ptool').style.display = price?'flex':'none';
}
async function det(id,name){
async function det(id,name,kind){
DID=id; dt.textContent=name;
if(kind) KIND=kind; // 2026-10-14 修:类型随批次传入——此前用全局 KIND(上一次/页签遗留)判断布局,
// 从「入库项目」页签直接开信息价明细会走错分支、目录树空白
const isPrice=(KIND!=='project');
// 价格类(信息价/市场价)只有一张价格明细表 → 不显示 4 个标签
$('dtabs').style.display = isPrice?'none':'flex';

View File

@@ -244,3 +244,9 @@ body.rawrow-dragging .rawnorm{pointer-events:none} /* 拖过面板表面时不
仅覆盖 .attr 单元格内的 ell,恢复换行、关闭省略号。 */
.attr .ell{white-space:pre-wrap;text-overflow:clip;cursor:auto}
/* 组表右键菜单(2026-10-13 主人定:暂时只做弹框,无功能) */
.grpctx{position:fixed;z-index:9999;background:#fff;border:1px solid #c9d4e2;border-radius:6px;
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}

View File

@@ -331,6 +331,37 @@ function billSortDOM(tb) {
});
})();
/* ================= 组表右键菜单(2026-10-13 主人定:暂时只做弹框,功能后加)=================
右键类似清单组表(data-grp 以 b 开头 = 工作台/后台的 similar 组表行)弹四项菜单:
上方插入清单 / 下方插入清单 / 删除 / 临时删除。点菜单项或任意处收起,均暂无功能。 */
(function () {
let menu = null;
function close() { if (menu) { menu.remove(); menu = null; } }
function show(x, y) {
close();
menu = document.createElement('div');
menu.className = 'grpctx';
menu.innerHTML = ['上方插入清单', '下方插入清单', '删除', '临时删除']
.map(t => '<div class="gi">' + t + '</div>').join('');
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"]');
if (!tr) return;
e.preventDefault();
show(e.clientX, e.clientY);
});
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(); // 菜单项暂无功能:点了只收起
});
})();
/* ---- 列宽持久化(2026-10-07,主人批准)----
此前拖完列宽,切个标签/重画就还原(列定义重建),是高频操作里的真实摩擦。
按**表头文字指纹**为每张表存一份列宽到 localStorage,重建后自动套用。
@@ -628,12 +659,18 @@ function billRemarkCell(r) {
return (r && r[10]) ? esc(r[10]) : '';
}
function grpTR(cls, key, title, sum, open) {
// 2026-10-13 主人定:组汇总金额对齐「合价」列——原来固定放倒数第 2 格,
// 工作台落在「取消采纳」列、后台落在「单价」列。现按列名找 合价 下标动态排版。
const cols = billCols();
const si = cols.findIndex(c => c[0] === '合价');
const gt = si > 2 ? si - 2 : cols.length - 4; // 标题从第 3 格跨到合价前一列
const tail = Math.max(0, cols.length - si - 1); // 合价之后的列(取消采纳/备注)留空
return '<tr class="' + cls + '" data-grp="' + key + '" onclick="tgGrp(\'' + key + '\',this)">'
+ '<td class="tg"><span class="tog' + (open ? ' g' : '') + '" data-open="' + (open ? 1 : 0) + '" id="gt_' + key + '">' + (open ? '−' : '+') + '</span></td>'
+ '<td class="c"></td>'
+ '<td class="gtitle" colspan="' + (CB_TOTAL() - 2) + '">' + title + '</td>'
+ '<td class="gtitle" colspan="' + gt + '">' + title + '</td>'
+ '<td class="r"><b>' + num(sum) + '</b></td>'
+ '<td></td></tr>';
+ '<td></td>'.repeat(tail) + '</tr>';
}
function tgGrp(key, tr) {
const tg = document.getElementById('gt_' + key);
@@ -721,7 +758,8 @@ function grpTreeRender(box, d, pick) {
h += '<div class="rn lv1" data-pk="bg' + i + '"><span class="nm">' + nm + '</span></div>';
});
extra.forEach((g, i) => {
h += '<div class="rn lv1" style="color:#8a97a8" data-pk="bx' + i + '"><span class="nm">'
// 2026-10-13 主人定:落单组标题颜色与其他组一致(原灰色 #8a97a8 内联取消)
h += '<div class="rn lv1" data-pk="bx' + i + '"><span class="nm">'
+ '第 ' + (groups.length + i + 1) + ' 组 · ' + ((g.rows || []).length) + ' 条</span></div>';
});
h += '</div>';
@@ -914,7 +952,7 @@ function rawKV(rows, tip) {
if (!rows || !rows.length) return '<div class="empty">没有数据</div>';
return (tip ? '<div class="hint">' + esc(tip) + '</div>' : '')
+ '<table class="kvtb"><colgroup><col style="width:220px"><col></colgroup>'
+ '<thead><tr><th>名称</th><th>值</th></tr></thead><tbody>' // 2026-10-13 主人定:字段→名称
+ '<thead><tr><th>名称</th><th>造价</th></tr></thead><tbody>' // 2026-10-13 主人定:字段→名称;2026-10-14:值→造价
+ rows.map(r => '<tr><td>' + esc(r[0]) + '</td><td>' + esc(r[1] == null || r[1] === '' ? '—' : r[1]) + '</td></tr>').join('')
+ '</tbody></table>';
}
@@ -982,6 +1020,12 @@ function rawTabs() {
const mount = document.getElementById('rawLvMount');
if (mount) mount.innerHTML = lv;
else h += lv;
// 2026-10-14 主人定:项目级标签行右侧加「导出」「合并工料机」占位按钮(功能后加)
if (RVSEL.k === 'proj') {
h += '<div style="margin-left:auto;display:flex;gap:4px;align-items:center">'
+ '<div class="lvbtn" title="功能即将上线">导出</div>'
+ '<div class="lvbtn" title="功能即将上线">合并工料机</div></div>';
}
st.innerHTML = h;
}
function rawTab(t) { RVTAB = t; rawTabs(); rawDraw(); }

View File

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

View File

@@ -71,6 +71,13 @@ body.histdrag{user-select:none}
.grpbox.treeclosed .grpsplit{width:14px;margin-left:0}
.grpmain{flex:1;min-width:0;overflow:auto}
body.grptree-dragging{cursor:col-resize !important;user-select:none}
/* 类似清单 ⟳ 重载行钉在滚动容器顶(34px),表头接在其下(2026-10-13 主人定) */
#t2 th{top:34px}
/* 下边对比区右栏(项目特征/定额):左线拖宽、中线拖高(均有记忆);收起态(2026-10-13 主人定) */
#hattrvsplit{flex:none;width:6px;cursor:col-resize}
#hattrvsplit:hover,#hattrhsplit:hover{background:#dbe7f6}
#hattrhsplit{flex:none;height:6px;cursor:row-resize}
#histwrap.attrfold #hattr,#histwrap.attrfold #hattrvsplit{display:none}
/* ---- 底部历史容器 ---- */
#histwrap{flex:0 0 auto;min-height:0;display:flex;flex-direction:column;background:#fff;border-top:1px solid var(--line)}
/* flex-shrink 归零(2026-10-08 主人报拖动不跟手):容器高度只听把手的,空间不够时
@@ -296,9 +303,8 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
<div class="grpsplit" id="grpsplit"><span class="gsplitbtn" title="收起/展开目录树">◀</span></div>
<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">
<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>
<span style="font-size:11.5px;color:var(--muted)">分组结果已缓存(改分组规则后自动按新规则重算)</span>
<!-- 原数据单位工程级的层级按钮挂点(2026-10-13 决策 58:分组/清单/定额/默认列宽 迁到这里最右) -->
<span id="rawLvMount" style="margin-left:auto;display:inline-flex;gap:4px;align-items:center"></span>
</div>
@@ -384,6 +390,8 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
<!-- 9 查询(仅关键字模式可用)/ 10 重置 / 11 分页(仅检索模式显示,置最右) -->
<button class="hb" id="btnQuery" onclick="doQuery()" disabled>查询</button>
<button class="hb" onclick="resetF()" data-page-node-id="Evol61yGTGBTDRv9YB3eiD">重置</button>
<!-- 收/展右栏(2026-10-13 主人定,仅类似清单标签显示):项目特征 + 定额(编码/名称)面板 -->
<button class="hb" id="fattrBtn" onclick="toggleHattr()" style="display:none">收项目特征</button>
<span class="hpg" id="hpg" style="display:none">
<button class="hb" id="hpgPrev" onclick="histPage(-1)">上一页</button>
<span id="hpgNo">第 1 页</span>
@@ -397,9 +405,11 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
<div id="histtblwrap" data-page-node-id="sB1ovGovBUXmqk4FshQgJU"><table id="ht" data-page-node-id="MJQFDMJgym6ECUMTzOdbf3"><colgroup id="hcg" data-page-node-id="jAFNXguH6nCvHUS1DHTrhI"></colgroup><thead id="hth" data-page-node-id="zPhbbuDHd1SRc0h6JBRQbb"></thead><tbody id="htb" data-page-node-id="uwNDVJZ7TLutkE4sPZuTKc"></tbody></table></div>
<div id="hmfoot" data-page-node-id="pHyW3yoVd6lJ4HizgoXkiG"></div>
</div>
<div id="hattrvsplit" title="拖动调整面板宽度"></div>
<div id="hattr">
<div class="hattr-hd">项目特征</div>
<div id="hattrTxt"></div>
<div id="hattrhsplit" title="拖动调整定额区高度"></div>
<div class="hattr-hd" style="border-top:1px solid var(--line)">定额(编码 / 名称)</div>
<div id="hattrNorms"><div class="empty">—</div></div>
</div>
@@ -462,7 +472,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
</div>
</div>
<script src="common.js?v=20261013m"></script>
<script src="common.js?v=20261013p"></script>
<script src="period.js"></script>
<script>
let SID=0, CUR=null, CURTYPE='lme', HROWS=[];
@@ -543,8 +553,10 @@ function syncHist(p){
// 单价类型两标签都显示(2026-10-08 主人定:工料机标签放来源右边)
if($('funitLbl')) $('funitLbl').textContent = isLme ? '单位' : '建设单位';
if($('funit')) $('funit').placeholder = isLme ? '输入单位(建设单位 / 发行单位)' : '输入建设单位';
// 工料机对比不用右栏(项目特征/定额面板)——结果表占满整行(2026-10-08 主人定)
if($('hattr')) $('hattr').style.display = isLme ? 'none' : '';
// 工料机对比不用右栏(项目特征/定额面板)——结果表占满整行(2026-10-08 主人定);
// 类似清单可手动收起右栏(2026-10-13 主人定「收项目特征」按钮)
if($('fattrBtn')) $('fattrBtn').style.display = (p==='p2') ? '' : 'none';
if($('hattr')) $('hattr').style.display = (isLme || HATTR_FOLD) ? 'none' : '';
// 精确度按标签取默认(工料机=全部含模糊;各自记住手动选择)
if($('htier') && FLT.tierByTab[p]) $('htier').value = FLT.tierByTab[p];
// 切标签=换对比上下文:结果表按新标签的列头重置(旧结果属于上一个标签,留着必然错位)
@@ -782,8 +794,7 @@ async function loadGroups(kind, fresh){
/* ⟳ 重载(决策 46):跳过服务端缓存,按当前数据与分组规则强制重新分组 */
function reloadSim(){
ldWrap('', '正在重新分组(不用缓存,工程大要稍等)…', ()=>loadGroups('similar', true))
.then(()=>{ $('msg').textContent='已按当前数据与分组规则重新分组'; });
ldWrap('', '正在重新分组(不用缓存,工程大要稍等)…', ()=>loadGroups('similar', true)); // 完成提示语已取消(2026-10-14 主人定)
}
// 清单首列「+」→ 展开其下定额:由 common.js 提供(读全局 WB_OPTS.normApi)。
@@ -1656,6 +1667,50 @@ async function initFromUrl(){
}
initFromUrl();
/* ---------- 下边对比区右栏(2026-10-13 主人定):收/展按钮 + 左线拖宽 + 中线拖高,均有记忆 ---------- */
let HATTR_FOLD = false;
try { HATTR_FOLD = localStorage.getItem('hattrFold') === '1'; } catch (e) {}
function applyHattrFold() {
document.getElementById('histwrap').classList.toggle('attrfold', HATTR_FOLD);
const b = document.getElementById('fattrBtn');
if (b) b.textContent = HATTR_FOLD ? '展开项目特征' : '收项目特征';
}
function toggleHattr() {
HATTR_FOLD = !HATTR_FOLD;
try { localStorage.setItem('hattrFold', HATTR_FOLD ? '1' : '0'); } catch (e) {}
applyHattrFold();
}
function hattrSplitInit() {
const body = document.getElementById('histbody');
const hattr = document.getElementById('hattr');
const vs = document.getElementById('hattrvsplit');
if (!body || !hattr || !vs || vs.dataset.ready) return;
vs.dataset.ready = '1';
{ const mw = panelMemLoad('hattrw', 160, 100000); if (mw) hattr.style.width = mw + 'px'; }
let dv = null;
vs.addEventListener('mousedown', e => { dv = { x0: e.clientX, w0: hattr.getBoundingClientRect().width }; e.preventDefault(); });
document.addEventListener('mousemove', e => {
if (!dv) return;
hattr.style.width = Math.max(160, Math.round(dv.w0 - (e.clientX - dv.x0))) + 'px';
});
document.addEventListener('mouseup', () => { if (!dv) return; dv = null; panelMemSave('hattrw', parseFloat(hattr.style.width) || 0); });
const hs = document.getElementById('hattrhsplit');
const norms = document.getElementById('hattrNorms');
if (!hs || hs.dataset.ready) return;
hs.dataset.ready = '1';
{ const nh = panelMemLoad('hattrnh', 70, 100000); if (nh) norms.style.height = nh + 'px'; }
let dh = null;
hs.addEventListener('mousedown', e => { dh = { y0: e.clientY, h0: norms.getBoundingClientRect().height }; e.preventDefault(); });
document.addEventListener('mousemove', e => {
if (!dh) return;
const maxH = Math.max(70, Math.round(hattr.clientHeight * 0.75));
norms.style.height = Math.min(Math.max(70, Math.round(dh.h0 - (e.clientY - dh.y0))), maxH) + 'px';
});
document.addEventListener('mouseup', () => { if (!dh) return; dh = null; panelMemSave('hattrnh', parseFloat(norms.style.height) || 0); });
}
applyHattrFold();
hattrSplitInit();
/* ================= 分组/匹配 设置(决策 32,2026-10-10 重做:分组规则表格 + 全局过滤词) ================= */
let RULES = []; // 规则行 [{_uid, seq, name, keywords, exclude, _hits}]
let RULE_EDIT = new Set(); // 处于编辑态的行 _uid