feat(costreview): 询价附件支持清单绑定并新增项目筛选、动态明细标签与行结构统一
This commit is contained in:
@@ -172,7 +172,7 @@ def sim_weighted(qname, hname, qattr, hattr):
|
||||
return 0.7 * jaccard(qname, hname) + 0.3 * a
|
||||
|
||||
|
||||
def _filters(kinds, units, classes, prefix="bt", self_src=None, area=None, orgs=None):
|
||||
def _filters(kinds, units, classes, prefix="bt", self_src=None, area=None, orgs=None, projs=None):
|
||||
"""生成批次级筛选 SQL(默认全选=不筛)
|
||||
self_src:被审工程的源文件名 —— 同一个文件若也在历史库里,排除掉(避免自己跟自己比)
|
||||
area:地区前缀列表 [(省, 市, 区/县), ...](2026-09-29 树形多选后改成这样)
|
||||
@@ -182,6 +182,8 @@ def _filters(kinds, units, classes, prefix="bt", self_src=None, area=None, orgs=
|
||||
orgs:单位(2026-10-08 主人定,工料机比对专用):建设单位 ∪ 发布单位 **跨来源联查**,
|
||||
一批名字同时匹配 BulidUnit(工程批次)OR x_publisher(价格批次);
|
||||
工程批次 x_publisher 恒空、价格批次 BulidUnit 恒空,OR 起来天然各走各的。
|
||||
projs:项目名称(决策 141,2026-10-20,主人定):按批次项目名 bt.Name 精确匹配(IN),
|
||||
与 units 同款;比对/检索两条路径、清单/工料机两侧全部透传。
|
||||
"""
|
||||
w, args = ["%s.x_enabled=1" % prefix], []
|
||||
if area:
|
||||
@@ -212,6 +214,9 @@ def _filters(kinds, units, classes, prefix="bt", self_src=None, area=None, orgs=
|
||||
w.append("(%s.BulidUnit IN (%s) OR %s.x_publisher IN (%s))"
|
||||
% (prefix, ",".join("?" * len(orgs)), prefix, ",".join("?" * len(orgs))))
|
||||
args += list(orgs) + list(orgs)
|
||||
if projs:
|
||||
w.append("%s.Name IN (%s)" % (prefix, ",".join("?" * len(projs))))
|
||||
args += list(projs)
|
||||
if classes:
|
||||
w.append("p.Class IN (%s)" % ",".join("?" * len(classes)))
|
||||
args += list(classes)
|
||||
@@ -379,11 +384,11 @@ def _region3(p, c, d3):
|
||||
return "/".join(x for x in (p, c, d3) if x) or None
|
||||
|
||||
|
||||
def match_bill(hist, row, base, kinds, units, classes, limit=20, srcs=None, pfrom=None, pto=None, self_name=None, self_src=None, area=None):
|
||||
def match_bill(hist, row, base, kinds, units, classes, limit=20, srcs=None, pfrom=None, pto=None, self_name=None, self_src=None, area=None, projs=None):
|
||||
bf, bt = span(base) # 基准期次:单月 int 或 (起, 止) 区间
|
||||
"""row: sqlite Row of s_bills"""
|
||||
c = hist.cursor()
|
||||
w, args = _filters(kinds, units, [], self_src=self_src, area=area) # classes 只对价格库有意义,清单比对不筛目录
|
||||
w, args = _filters(kinds, units, [], self_src=self_src, area=area, projs=projs) # classes 只对价格库有意义,清单比对不筛目录
|
||||
out, seen_ids, qn = [], set(), norm_match(row["Name"])
|
||||
# L0 精确:编码+名称+单位(b.id 带回 → 前端展开定额 / 右栏「定额编码·名称」用)。
|
||||
# 2026-10-10 决策 27:哈希里的编码只取前 9 位(后 3 位是项目内顺序码,没有对比意义),
|
||||
@@ -465,7 +470,7 @@ def match_bill(hist, row, base, kinds, units, classes, limit=20, srcs=None, pfro
|
||||
return res[:limit]
|
||||
|
||||
|
||||
def hist_search(hist, kinds, units, area, pfrom, pto, kw, limit=200, self_name=None, self_src=None, page=1, stop=None):
|
||||
def hist_search(hist, kinds, units, area, pfrom, pto, kw, limit=200, self_name=None, self_src=None, page=1, stop=None, projs=None):
|
||||
"""独立检索(2026-10-08 主人定第 4 轮 B 方案):跨**全部入库项目**(kind='project')按
|
||||
条件+关键词 直查清单库,与工作台选中的行无关(主人:"搜索条件高于点选清单")。
|
||||
行结构与 match_bill() 完全一致 —— 前端 renderHist / 右栏 / ± 展开零改动复用,差异只有:
|
||||
@@ -477,7 +482,7 @@ def hist_search(hist, kinds, units, area, pfrom, pto, kw, limit=200, self_name=N
|
||||
或项目名相同。
|
||||
page:分页(2026-10-08 主人定,每页=limit 条,第 N 页 OFFSET (N-1)×limit)。"""
|
||||
c = hist.cursor()
|
||||
cond, args = _filters(kinds, units, [], prefix="bt") # 批次级条件(拼好的 SQL 串 + 参数)
|
||||
cond, args = _filters(kinds, units, [], prefix="bt", projs=projs) # 批次级条件(拼好的 SQL 串 + 参数)
|
||||
extra = []
|
||||
nm = (self_name or "").strip()
|
||||
src = (self_src or "").strip()
|
||||
@@ -535,7 +540,7 @@ def hist_search(hist, kinds, units, area, pfrom, pto, kw, limit=200, self_name=N
|
||||
|
||||
def hist_search_lme(hist, orgs=None, area=None, pfrom=None, pto=None, kw="", pmin=None, pmax=None,
|
||||
srcs=None, limit=200, self_name=None, self_src=None, page=1, att="all", kinds=None,
|
||||
stop=None):
|
||||
stop=None, projs=None):
|
||||
"""独立检索 · 工料机版(2026-10-08 主人定):跨全部入库项目的**工料机**(lmes, kind='project')
|
||||
+ 信息价/市场价明细(prices),条件+关键词直查,与工作台选中的行无关。
|
||||
工料机标签的关键字查询走这里(hist_search 查的是清单库,工料机标签不适用)。
|
||||
@@ -550,8 +555,8 @@ def hist_search_lme(hist, orgs=None, area=None, pfrom=None, pto=None, kw="", pmi
|
||||
srcs = srcs or ["project", "info", "market"]
|
||||
# kinds=单价类型,只对工程来源生效(价格批次 FileKind 恒空,一传就整片剔除)
|
||||
# → 工程/价格两个分支各拼各的 cond,cargs 分别跟各自的分支参数走
|
||||
cond, cargs = _filters(kinds or [], [], [], prefix="bt", self_src=self_src, area=area, orgs=orgs)
|
||||
condp, cargsp = _filters([], [], [], prefix="bt", self_src=self_src, area=area, orgs=orgs)
|
||||
cond, cargs = _filters(kinds or [], [], [], prefix="bt", self_src=self_src, area=area, orgs=orgs, projs=projs)
|
||||
condp, cargsp = _filters([], [], [], prefix="bt", self_src=self_src, area=area, orgs=orgs, projs=projs)
|
||||
outer, oargs = [], []
|
||||
nm = (self_name or "").strip()
|
||||
src = (self_src or "").strip()
|
||||
@@ -648,7 +653,7 @@ def hist_search_lme(hist, orgs=None, area=None, pfrom=None, pto=None, kw="", pmi
|
||||
return res
|
||||
|
||||
|
||||
def match_lme(hist, row, base, orgs=None, limit=20, srcs=None, pfrom=None, pto=None, self_name=None, self_src=None, area=None, pmin=None, pmax=None, att="all", kinds=None):
|
||||
def match_lme(hist, row, base, orgs=None, limit=20, srcs=None, pfrom=None, pto=None, self_name=None, self_src=None, area=None, pmin=None, pmax=None, att="all", kinds=None, projs=None):
|
||||
"""工料机:历史工程工料机 + 信息价/市场价(价格库)
|
||||
2026-10-08 主人定:比对按「名称+规格型号+单位」三件套;筛选 = 来源/单价类型/单位/地区/期次/价格范围/附件。
|
||||
orgs = 单位跨来源联查(建设单位 OR 发布单位,见 _filters);pmin/pmax = 价格范围(除税单价);
|
||||
@@ -662,7 +667,7 @@ def match_lme(hist, row, base, orgs=None, limit=20, srcs=None, pfrom=None, pto=N
|
||||
c = hist.cursor()
|
||||
out, seen_ids = [], set()
|
||||
# ---- 历史工程工料机 ----
|
||||
w, args = _filters(kinds or [], [], [], self_src=self_src, area=area, orgs=orgs)
|
||||
w, args = _filters(kinds or [], [], [], self_src=self_src, area=area, orgs=orgs, projs=projs)
|
||||
wpr, apr = _price_range("l.NoTaxPrice", pmin, pmax)
|
||||
w = w + " AND " + wpr; args = args + apr
|
||||
res = []
|
||||
@@ -765,7 +770,7 @@ def match_lme(hist, row, base, orgs=None, limit=20, srcs=None, pfrom=None, pto=N
|
||||
# 单位筛选走 orgs(发布单位),价格范围同样对 p.NoTaxPrice 生效。
|
||||
# ⚠️ **这里永远不加 lme_list_where**(主人 2026-10-09 明示"永远不能屏蔽信息价/市场价的
|
||||
# 任何单位")—— 刊物里的台班单价等是正常价格行;搜索对象=项目工料机(过滤后)+价格全量。
|
||||
wp, argp = _filters([], [], [], prefix="bt", self_src=self_src, area=area, orgs=orgs)
|
||||
wp, argp = _filters([], [], [], prefix="bt", self_src=self_src, area=area, orgs=orgs, projs=projs)
|
||||
wpp, app = _price_range("p.NoTaxPrice", pmin, pmax)
|
||||
wp = wp + " AND " + wpp; argp = argp + app
|
||||
if pk:
|
||||
|
||||
@@ -646,7 +646,8 @@ def api_inq_list(con, bid):
|
||||
if not ok:
|
||||
return {"ok": False, "msg": msg}
|
||||
rows = con.execute("""SELECT f.id, f.original_name, f.size, f.ext, f.uploaded_at,
|
||||
(SELECT COUNT(*) FROM lme_attach a WHERE a.file_id=f.id) AS n
|
||||
(SELECT COUNT(*) FROM lme_attach a WHERE a.file_id=f.id)
|
||||
+ (SELECT COUNT(*) FROM bill_attach a WHERE a.file_id=f.id) AS n
|
||||
FROM inquiry_files f WHERE f.batch_id=? ORDER BY f.id""", (bid,)).fetchall()
|
||||
total = con.execute("SELECT COUNT(*) FROM lme_attach WHERE batch_id=?", (bid,)).fetchone()[0]
|
||||
return {"ok": True, "total_bound": total,
|
||||
@@ -687,64 +688,114 @@ def api_inq_upload(con, bid, body):
|
||||
|
||||
|
||||
def api_inq_bind(con, bid, body):
|
||||
"""把选中的工料机绑到某个附件。
|
||||
"""把选中的工料机/清单绑到某个附件(决策 152:清单也能绑,同 lme_attach 口径)。
|
||||
|
||||
★ 允许改绑:lme_id 是主键,INSERT OR REPLACE 冲突即覆盖 —— 覆盖即改绑,
|
||||
★ 允许改绑:lme_id/bill_id 是主键,INSERT OR REPLACE 冲突即覆盖 —— 覆盖即改绑,
|
||||
不需要先解绑。返回里带着「从哪个附件改过来的、几条」,前端据此做二次确认文案。
|
||||
body: {file_id, lme_ids?: [...], bill_ids?: [...]} —— 两类至少给一类。
|
||||
"""
|
||||
ok, msg = _inq_guard(con, bid)
|
||||
if not ok:
|
||||
return {"ok": False, "msg": msg}
|
||||
fid = int(body.get("file_id") or 0)
|
||||
ids = [int(x) for x in (body.get("lme_ids") or [])]
|
||||
lme_ids = [int(x) for x in (body.get("lme_ids") or [])]
|
||||
bill_ids = [int(x) for x in (body.get("bill_ids") or [])]
|
||||
if not fid:
|
||||
return {"ok": False, "msg": "请先在左边选中一个附件"}
|
||||
if not ids:
|
||||
return {"ok": False, "msg": "还没有勾选工料机"}
|
||||
if not lme_ids and not bill_ids:
|
||||
return {"ok": False, "msg": "还没有勾选工料机/清单"}
|
||||
row = con.execute("SELECT original_name FROM inquiry_files WHERE id=? AND batch_id=?",
|
||||
(fid, bid)).fetchone()
|
||||
if not row:
|
||||
return {"ok": False, "msg": "附件不存在(可能已被删除)"}
|
||||
cur = con.cursor()
|
||||
# 只接受确实属于本项目的工料机(防越权:传别项目的 lme_id 也绑不上)
|
||||
q = "SELECT id FROM lmes WHERE batch_id=? AND id IN (%s)" % ",".join("?" * len(ids))
|
||||
valid = [r[0] for r in cur.execute(q, [bid] + ids)]
|
||||
if not valid:
|
||||
return {"ok": False, "msg": "勾选的工料机不属于这个项目"}
|
||||
# 改绑统计:这些行原本绑在哪些附件上
|
||||
moved = {}
|
||||
for lme_id, old_name in cur.execute(
|
||||
"""SELECT a.lme_id, f.original_name FROM lme_attach a
|
||||
JOIN inquiry_files f ON f.id=a.file_id
|
||||
WHERE a.lme_id IN (%s)""" % ",".join("?" * len(valid)), valid):
|
||||
moved[old_name] = moved.get(old_name, 0) + 1
|
||||
for lme_id in valid:
|
||||
cur.execute("INSERT OR REPLACE INTO lme_attach(lme_id, batch_id, file_id) VALUES(?,?,?)",
|
||||
(lme_id, bid, fid))
|
||||
con.commit()
|
||||
n = len(valid)
|
||||
n = 0
|
||||
hint = ""
|
||||
if moved:
|
||||
hint = "(其中 %s)" % "、".join(
|
||||
"%d 条从《%s》改绑过来" % (c, (k or "").strip()[:24]) for k, c in moved.items())
|
||||
return {"ok": True, "n": n, "moved": moved,
|
||||
"msg": "已把 %d 条工料机绑定到《%s》%s" % (n, (row[0] or "")[:40], hint)}
|
||||
if lme_ids:
|
||||
# 只接受确实属于本项目的工料机(防越权:传别项目的 lme_id 也绑不上)
|
||||
q = "SELECT id FROM lmes WHERE batch_id=? AND id IN (%s)" % ",".join("?" * len(lme_ids))
|
||||
valid = [r[0] for r in cur.execute(q, [bid] + lme_ids)]
|
||||
if not valid:
|
||||
return {"ok": False, "msg": "勾选的工料机不属于这个项目"}
|
||||
# 改绑统计:这些行原本绑在哪些附件上
|
||||
moved = {}
|
||||
for lme_id, old_name in cur.execute(
|
||||
"""SELECT a.lme_id, f.original_name FROM lme_attach a
|
||||
JOIN inquiry_files f ON f.id=a.file_id
|
||||
WHERE a.lme_id IN (%s)""" % ",".join("?" * len(valid)), valid):
|
||||
moved[old_name] = moved.get(old_name, 0) + 1
|
||||
for lme_id in valid:
|
||||
cur.execute("INSERT OR REPLACE INTO lme_attach(lme_id, batch_id, file_id) VALUES(?,?,?)",
|
||||
(lme_id, bid, fid))
|
||||
n += len(valid)
|
||||
if moved:
|
||||
hint = "(其中 %s)" % "、".join(
|
||||
"%d 条从《%s》改绑过来" % (c, (k or "").strip()[:24]) for k, c in moved.items())
|
||||
if bill_ids:
|
||||
q = "SELECT id FROM bills WHERE batch_id=? AND id IN (%s)" % ",".join("?" * len(bill_ids))
|
||||
valid = [r[0] for r in cur.execute(q, [bid] + bill_ids)]
|
||||
if not valid and not lme_ids:
|
||||
return {"ok": False, "msg": "勾选的清单不属于这个项目"}
|
||||
moved = {}
|
||||
for bill_id, old_name in cur.execute(
|
||||
"""SELECT a.bill_id, f.original_name FROM bill_attach a
|
||||
JOIN inquiry_files f ON f.id=a.file_id
|
||||
WHERE a.bill_id IN (%s)""" % ",".join("?" * len(valid)), valid):
|
||||
moved[old_name] = moved.get(old_name, 0) + 1
|
||||
for bill_id in valid:
|
||||
cur.execute("INSERT OR REPLACE INTO bill_attach(bill_id, batch_id, file_id) VALUES(?,?,?)",
|
||||
(bill_id, bid, fid))
|
||||
n += len(valid)
|
||||
if moved:
|
||||
hint += ("%s%s" % (";" if hint else "", "、".join(
|
||||
"%d 条清单从《%s》改绑过来" % (c, (k or "").strip()[:24]) for k, c in moved.items())))
|
||||
con.commit()
|
||||
what = "工料机" if lme_ids else "清单"
|
||||
return {"ok": True, "n": n, "msg": "已把 %d 条%s绑定到《%s》%s" % (n, what, (row[0] or "")[:40], hint)}
|
||||
|
||||
|
||||
def api_inq_unbind(con, bid, body):
|
||||
"""解绑:把选中的工料机从附件上摘下来(附件本身保留)"""
|
||||
"""解绑:把选中的工料机/清单从附件上摘下来(附件本身保留)"""
|
||||
ok, msg = _inq_guard(con, bid)
|
||||
if not ok:
|
||||
return {"ok": False, "msg": msg}
|
||||
ids = [int(x) for x in (body.get("lme_ids") or [])]
|
||||
if not ids:
|
||||
return {"ok": False, "msg": "还没有勾选工料机"}
|
||||
lme_ids = [int(x) for x in (body.get("lme_ids") or [])]
|
||||
bill_ids = [int(x) for x in (body.get("bill_ids") or [])]
|
||||
if not lme_ids and not bill_ids:
|
||||
return {"ok": False, "msg": "还没有勾选工料机/清单"}
|
||||
cur = con.cursor()
|
||||
cur.execute("DELETE FROM lme_attach WHERE batch_id=? AND lme_id IN (%s)"
|
||||
% ",".join("?" * len(ids)), [bid] + ids)
|
||||
n = cur.rowcount
|
||||
n = 0
|
||||
if lme_ids:
|
||||
cur.execute("DELETE FROM lme_attach WHERE batch_id=? AND lme_id IN (%s)"
|
||||
% ",".join("?" * len(lme_ids)), [bid] + lme_ids)
|
||||
n += cur.rowcount
|
||||
if bill_ids:
|
||||
cur.execute("DELETE FROM bill_attach WHERE batch_id=? AND bill_id IN (%s)"
|
||||
% ",".join("?" * len(bill_ids)), [bid] + bill_ids)
|
||||
n += cur.rowcount
|
||||
con.commit()
|
||||
return {"ok": True, "n": n, "msg": "已解绑 %d 条工料机" % n}
|
||||
return {"ok": True, "n": n, "msg": "已解绑 %d 条" % n}
|
||||
|
||||
|
||||
def api_inq_bills(con, bid):
|
||||
"""该项目的全部清单 + 当前绑定状态(决策 152 类似清单页签用)。
|
||||
|
||||
字段与后台「类似清单」结果行一致:编码/名称/项目特征/单位/工程量/单价/合价;
|
||||
不做相似过滤 —— 这里是**本批次自己的全部清单**,勾选绑附件用。"""
|
||||
ok, msg = _inq_guard(con, bid)
|
||||
if not ok:
|
||||
return {"ok": False, "msg": msg}
|
||||
rows = con.execute("""SELECT b.id, b.Number, b.Name, b.Attr, b.Unit, b.Quantity, b.Price, b.Total,
|
||||
a.file_id, f.original_name
|
||||
FROM bills b
|
||||
LEFT JOIN bill_attach a ON a.bill_id=b.id
|
||||
LEFT JOIN inquiry_files f ON f.id=a.file_id
|
||||
WHERE b.batch_id=? ORDER BY b.id""", (bid,)).fetchall()
|
||||
return {"ok": True, "rows": [
|
||||
{"id": r[0], "code": r[1] or "", "name": r[2] or "", "attr": r[3] or "",
|
||||
"unit": r[4] or "", "qty": r[5], "price": r[6], "total": r[7],
|
||||
"file_id": r[8], "file_name": r[9] or ""}
|
||||
for r in rows]}
|
||||
|
||||
|
||||
def api_inq_del(con, bid, body):
|
||||
@@ -759,7 +810,9 @@ def api_inq_del(con, bid, body):
|
||||
return {"ok": False, "msg": "附件不存在"}
|
||||
cur = con.cursor()
|
||||
n = cur.execute("SELECT COUNT(*) FROM lme_attach WHERE file_id=?", (fid,)).fetchone()[0]
|
||||
n += cur.execute("SELECT COUNT(*) FROM bill_attach WHERE file_id=?", (fid,)).fetchone()[0]
|
||||
cur.execute("DELETE FROM lme_attach WHERE file_id=?", (fid,))
|
||||
cur.execute("DELETE FROM bill_attach WHERE file_id=?", (fid,))
|
||||
cur.execute("DELETE FROM inquiry_files WHERE id=?", (fid,))
|
||||
con.commit()
|
||||
# 同 sha 的别处还在用就不删文件(与价格原件同一套规矩)
|
||||
@@ -1829,18 +1882,22 @@ def _raw_proj(con, T, oid, tab):
|
||||
# sub = 带子级组成的编码集(台班/配合比),前端据此挂 title 提示。
|
||||
try:
|
||||
_hide = " AND COALESCE(x_merged_hide,0)=0" if T.get("lmemerge") else ""
|
||||
rows = con.execute("""SELECT id, code, name, spec, unit, kind, qty, ntp, taxrate, taxp
|
||||
# 决策 147(2026-10-21 主人定):项目级卡与「项目工料机」同码同形 —— 返回 _lme_rows 同形
|
||||
# 11 列(id 在首位、备注位 10),前端 renderLme 唯一渲染;不再 rows/ids 分离。
|
||||
# 数据集差异保留:此处**不过** LME_LIST_WHERE(全量含台班/配合比),合并隐藏两处同滤。
|
||||
rows = con.execute("""SELECT id, code, name, spec, unit, qty, ntp, taxrate, taxp,
|
||||
kind, %(rm)s AS remark
|
||||
FROM %(lp)s WHERE %(idc)s=?%(hide)s ORDER BY id"""
|
||||
% {"lp": T["lme_proj"], "idc": T["idcol"], "hide": _hide}, (oid,)).fetchall()
|
||||
% {"lp": T["lme_proj"], "idc": T["idcol"], "hide": _hide,
|
||||
"rm": T.get("lme_remark", "NULL")}, (oid,)).fetchall()
|
||||
except Exception:
|
||||
rows = [] # 老库还没建表/没回填:退回旧口径
|
||||
if rows:
|
||||
return {"ok": True, "rows": [list(x)[1:] for x in rows],
|
||||
"ids": [x[0] for x in rows], "sub": _lme_sub_codes(con, T, oid)}
|
||||
return {"ok": True, "rows": [list(x) for x in rows], "sub": _lme_sub_codes(con, T, oid)}
|
||||
# 老库回退支:lmes 可能没有 TaxRate 列 —— 仿 _norm_res 的 PRAGMA 探测,缺列恒补 None。
|
||||
# 9 列行形与主路一致:6=除税 7=税率 8=含税(TaxRate 插在 TaxPrice 之前)。
|
||||
# 决策 147:回退支同样 11 列(id/备注补 NULL),行形与主路一致。
|
||||
has_tax = any(x[1] == "TaxRate" for x in con.execute("PRAGMA table_info(%s)" % T["lmes"]))
|
||||
rows = con.execute("""SELECT Number, Name, Specification, Unit, Kind, Quantity, NoTaxPrice, %(txr)s TaxPrice
|
||||
rows = con.execute("""SELECT NULL, Number, Name, Specification, Unit, Quantity, NoTaxPrice, %(txr)s TaxPrice, Kind, NULL
|
||||
FROM %(lm)s WHERE %(idc)s=? AND NoTaxPrice IS NOT NULL
|
||||
ORDER BY Quantity DESC LIMIT 800"""
|
||||
% {"lm": T["lmes"], "idc": T["idcol"],
|
||||
@@ -3291,17 +3348,41 @@ def api_bill_adopt(sc, hc, body):
|
||||
sid = int(body.get("session_id", 0) or 0)
|
||||
bid = int(body.get("bill_id", 0) or 0)
|
||||
src_id = int(body.get("src_bill_id", 0) or 0)
|
||||
src_self = int(body.get("src_self_bill_id", 0) or 0) # 决策 158:来源=本会话清单(范围=是)
|
||||
sb = sc.execute("SELECT id, session_id, uw_id, x_new, x_tdel FROM s_bills WHERE id=? AND session_id=?",
|
||||
(bid, sid)).fetchone()
|
||||
if not sb:
|
||||
return {"ok": False, "msg": "清单不存在(可能已被删除,请刷新)"}
|
||||
if sb["x_tdel"]:
|
||||
return {"ok": False, "msg": "临时删除状态不可以采纳(规格 9.2)——先取消临时删除"}
|
||||
bb = hc.execute("SELECT id, Number, Name, Attr, Unit, Price, Quantity FROM bills WHERE id=?", (src_id,)).fetchone()
|
||||
if not bb:
|
||||
return {"ok": False, "msg": "入库项目清单不存在(批次可能已删除)"}
|
||||
bnorms = hc.execute("""SELECT id, Number, Name, Unit, Quantity, Price, Total, x_qty_coef, x_adjust
|
||||
FROM norms WHERE bill_id=? ORDER BY id""", (src_id,)).fetchall()
|
||||
if src_self:
|
||||
if src_self == bid:
|
||||
return {"ok": False, "msg": "不能采纳清单自己"}
|
||||
bb = sc.execute("SELECT id, Number, Name, Attr, Unit, Price, Quantity FROM s_bills WHERE id=? AND session_id=?",
|
||||
(src_self, sid)).fetchone()
|
||||
if not bb:
|
||||
return {"ok": False, "msg": "本工程来源清单不存在(可能已被删除,请刷新)"}
|
||||
bnorms = sc.execute("""SELECT id, Number, Name, Unit, Quantity, Price, Total,
|
||||
NULL AS x_qty_coef, x_adjust, qty_expr
|
||||
FROM s_norms WHERE bill_id=? AND (x_tdel IS NULL OR x_tdel=0) ORDER BY id""",
|
||||
(src_self,)).fetchall()
|
||||
else:
|
||||
bb = hc.execute("SELECT id, Number, Name, Attr, Unit, Price, Quantity FROM bills WHERE id=?", (src_id,)).fetchone()
|
||||
if not bb:
|
||||
return {"ok": False, "msg": "入库项目清单不存在(批次可能已删除)"}
|
||||
bnorms = hc.execute("""SELECT id, Number, Name, Unit, Quantity, Price, Total, x_qty_coef, x_adjust
|
||||
FROM norms WHERE bill_id=? ORDER BY id""", (src_id,)).fetchall()
|
||||
|
||||
def _norm_expr(nn):
|
||||
# 批次来源:GCL×系数公式现算(规格 19);会话来源:qty_expr 原样带(公式本就按 GCL 走,
|
||||
# 换到目标清单后随目标工程量求值,语义同款)
|
||||
return nn["qty_expr"] if src_self else _gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"])
|
||||
|
||||
def _norm_res(nn_id):
|
||||
if src_self:
|
||||
return sc.execute("SELECT res_code, qty, express FROM s_norm_res WHERE norm_id=? ORDER BY id", (nn_id,))
|
||||
return hc.execute("SELECT res_code, qty, express FROM norm_res WHERE norm_id=? ORDER BY id", (nn_id,))
|
||||
|
||||
is_new = bool(sb["x_new"])
|
||||
# 规格 19(2026-10-17 主人定·采纳逻辑变化):采纳定额工程量默认公式 = **GCL×系数**,
|
||||
# 系数 = 历史定额量 ÷ 历史清单量(例:历史清单量 500、定额量 300 → GCL*0.6000)——
|
||||
@@ -3320,11 +3401,10 @@ def api_bill_adopt(sc, hc, body):
|
||||
cur = sc.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total,
|
||||
x_adopt, x_src_norm_id, qty_expr, x_adjust)
|
||||
VALUES(?,?,?,?,NULL,?,NULL,1,?,?,?)""",
|
||||
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"], nn["id"],
|
||||
_gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"]),
|
||||
nn["x_adjust"]))
|
||||
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"],
|
||||
None if src_self else nn["id"], _norm_expr(nn), nn["x_adjust"]))
|
||||
adopted_norm_ids.append(cur.lastrowid)
|
||||
for rr in hc.execute("SELECT res_code, qty, express FROM norm_res WHERE norm_id=? ORDER BY id", (nn["id"],)):
|
||||
for rr in _norm_res(nn["id"]):
|
||||
sc.execute("INSERT INTO s_norm_res(norm_id, res_code, qty, express) VALUES(?,?,?,?)",
|
||||
(cur.lastrowid, rr["res_code"], rr["qty"], rr["express"]))
|
||||
else:
|
||||
@@ -3337,18 +3417,21 @@ def api_bill_adopt(sc, hc, body):
|
||||
cur = sc.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total,
|
||||
x_adopt, x_src_norm_id, qty_expr, x_adjust)
|
||||
VALUES(?,?,?,?,NULL,?,NULL,1,?,?,?)""",
|
||||
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"], nn["id"],
|
||||
_gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"]),
|
||||
nn["x_adjust"]))
|
||||
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"],
|
||||
None if src_self else nn["id"], _norm_expr(nn), nn["x_adjust"]))
|
||||
adopted_norm_ids.append(cur.lastrowid)
|
||||
for rr in hc.execute("SELECT res_code, qty, express FROM norm_res WHERE norm_id=? ORDER BY id", (nn["id"],)):
|
||||
for rr in _norm_res(nn["id"]):
|
||||
sc.execute("INSERT INTO s_norm_res(norm_id, res_code, qty, express) VALUES(?,?,?,?)",
|
||||
(cur.lastrowid, rr["res_code"], rr["qty"], rr["express"]))
|
||||
bqty = sc.execute("SELECT Quantity FROM s_bills WHERE id=?", (bid,)).fetchone()["Quantity"]
|
||||
btotal = round((float(bqty) if bqty is not None else 0.0) * (float(new_price) if new_price is not None else 0.0), 2)
|
||||
sc.execute("UPDATE s_bills SET Price=?, Total=?, x_adopt=1 WHERE id=?", (new_price, btotal, bid))
|
||||
# 决策 108:消耗量随名称/规格/单位匹配结果改码(逐行读现值再映射,防 A→B→C 链式误改)
|
||||
n_sum, code_map = _adopt_summary_rows(sc, hc, sid, sb["uw_id"], src_id)
|
||||
# 会话来源跳过——来源消耗量的编码本就是本地码,无需重配(决策 158)
|
||||
if src_self:
|
||||
n_sum, code_map = 0, {}
|
||||
else:
|
||||
n_sum, code_map = _adopt_summary_rows(sc, hc, sid, sb["uw_id"], src_id)
|
||||
n_recode = 0
|
||||
for nid in adopted_norm_ids:
|
||||
for rr in sc.execute("SELECT id, res_code FROM s_norm_res WHERE norm_id=?", (nid,)).fetchall():
|
||||
@@ -3628,10 +3711,14 @@ def api_lme_merge(sc, body):
|
||||
rid = int(r.get("id", 0) or 0)
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
_ntp = _num_or_none(r.get("ntp"))
|
||||
_rate = _num_or_none(r.get("taxrate"))
|
||||
_taxp = _num_or_none(r.get("taxp"))
|
||||
if _ntp is not None and _rate is not None: # 决策 146:等式恒成立(除税方向复核,同 api_lme_price)
|
||||
_taxp = round(_ntp * (1 + _rate / 100.0) + 1e-9, 2)
|
||||
sc.execute("""UPDATE s_lme_proj SET code=?, ntp=?, taxrate=?, taxp=?
|
||||
WHERE session_id=? AND id=? AND COALESCE(x_merged_hide,0)=0""",
|
||||
(r.get("code"), _num_or_none(r.get("ntp")), _num_or_none(r.get("taxrate")),
|
||||
_num_or_none(r.get("taxp")), sid, rid))
|
||||
(r.get("code"), _ntp, _rate, _taxp, sid, rid))
|
||||
kept += 1
|
||||
row = sc.execute("SELECT code FROM s_lme_proj WHERE id=?", (rid,)).fetchone()
|
||||
if row and not keep_code:
|
||||
@@ -3987,14 +4074,15 @@ def api_search(body):
|
||||
pmin=_num_or_none(body.get("pmin")),
|
||||
pmax=_num_or_none(body.get("pmax")),
|
||||
att=body.get("att") or "all",
|
||||
kinds=body.get("file_kinds") or [])
|
||||
kinds=body.get("file_kinds") or [],
|
||||
projs=body.get("projs") or [])
|
||||
else:
|
||||
res = match.match_bill(hist, row, base,
|
||||
body.get("file_kinds") or [], body.get("bulid_units") or [],
|
||||
body.get("classes") or [], limit, srcs, pf, pt,
|
||||
None if scope_self else self_name,
|
||||
None if scope_self else self_src,
|
||||
area)
|
||||
area, projs=body.get("projs") or [])
|
||||
# 规格 20:本组其他清单的批次记录(bill_id 集合)——组价不一致对比按它过滤
|
||||
allowed = None
|
||||
if scope_self and members is not None:
|
||||
@@ -4021,6 +4109,23 @@ def api_search(body):
|
||||
# (第 N 组 3 条 → 只显示另外 2 条);别的项目/别的历史记录不展示。
|
||||
# 工具栏独立检索(/api/hist/search)不受限。被点清单自己的记录亦不在本组集合内。
|
||||
res = [r for r in res if r.get("bill_id") in allowed]
|
||||
if typ == "bill" and res:
|
||||
# 决策 152:清单绑定的询价附件 → 工作台历史对比框可下载(file/file_sha/file_url 同工料机行)
|
||||
c2 = conn()
|
||||
try:
|
||||
m = {}
|
||||
for bid_, fid_, nm_, sha_ in c2.execute(
|
||||
"""SELECT a.bill_id, f.id, f.original_name, f.sha256 FROM bill_attach a
|
||||
JOIN inquiry_files f ON f.id=a.file_id WHERE a.bill_id IN (%s)"""
|
||||
% ",".join("?" * len(res)), [r.get("bill_id") for r in res]):
|
||||
m[bid_] = (fid_, nm_, sha_)
|
||||
finally:
|
||||
c2.close()
|
||||
for r in res:
|
||||
hit = m.get(r.get("bill_id"))
|
||||
if hit:
|
||||
r["file"], r["file_sha"] = hit[1] or "", hit[2] or ""
|
||||
r["file_url"] = "/api/admin/inq/file/%d" % hit[0]
|
||||
return {"ok": True, "base_period": match.ym(pf) + ("~" + match.ym(pt) if pt != pf else ""),
|
||||
"rows": res, "total": len(res)}
|
||||
|
||||
@@ -4035,6 +4140,154 @@ def _num_or_none(v):
|
||||
return None
|
||||
|
||||
|
||||
def api_self_search(body):
|
||||
"""范围=是(决策 158,2026-10-21 主人定):「本项目」下拉是数据第一关——
|
||||
是=数据流走 session 库(本工程自己的行,本端点);否=走批次库(/api/search、/api/hist/search,
|
||||
排除自己,现行规则)。关键字「查询」路径同样跟随下拉。
|
||||
type='bill':本工程其他清单(跨单位工程同名/近似;scope='self_group'=组价不一致:会话内
|
||||
本组其他清单——规格 20 的组定义直读会话,不再绕批次库);type='lme':本工程自己的工料机
|
||||
(s_lmes 各单位明细行)。
|
||||
行结构与 /api/search 一致(renderHist/右栏/±/采纳零改动复用),差异:
|
||||
· src='本工程'、proj=单位工程名(工料机行无单位归属,恒『本工程』)、period=本工程基准期次;
|
||||
· 清单行带 norms=6+2 列(同 _bill_norms 形状,右栏/±/悬停直读,不走 histNorms);
|
||||
· self_bill_id=会话清单 id(采纳走 /api/session/bill/adopt 的 src_self_bill_id 分支)。
|
||||
档位与库内同一套(精确/次精确/字集/模糊,同 match_bill/match_lme 口径);
|
||||
kw/stop 同库内口径;期次/地区/单位/价格范围等库条件对本工程无意义,不参与。"""
|
||||
sid = int(body.get("session_id", 0) or 0)
|
||||
typ = body.get("type", "lme")
|
||||
rid = int(body.get("row_id", 0) or 0)
|
||||
limit = min(int(body.get("limit", 200) or 200), 500)
|
||||
sc = sess.connect()
|
||||
try:
|
||||
s = sc.execute("SELECT * FROM sessions WHERE id=?", (sid,)).fetchone()
|
||||
if not s:
|
||||
return {"ok": False, "msg": "会话不存在"}
|
||||
_k = s.keys()
|
||||
pf = (s["period_from"] if "period_from" in _k else None) or s["base_period_m"] or 0
|
||||
pt = (s["period_to"] if "period_to" in _k else None) or pf
|
||||
period = match.ym(pf) + ("~" + match.ym(pt) if pt != pf else "")
|
||||
region = match._region3(s["x_province"] if "x_province" in _k else None,
|
||||
s["x_city"] if "x_city" in _k else None,
|
||||
s["x_district"] if "x_district" in _k else None)
|
||||
bunit = (s["bulid_unit"] if "bulid_unit" in _k else None) or ""
|
||||
sw = _setting_get("global", "match_stopwords")
|
||||
try:
|
||||
match.set_stopwords(json.loads(sw)) if sw else match.set_stopwords([])
|
||||
except Exception:
|
||||
match.set_stopwords([])
|
||||
stops = match.stop_words(body.get("stop"))
|
||||
kw = match._kw_fold(body.get("kw") or "")
|
||||
|
||||
def _pass(txts):
|
||||
hay = match._kw_fold(" ".join(str(t or "") for t in txts))
|
||||
if kw and not all(t in hay for t in re.split(r"\s+", kw) if t):
|
||||
return False
|
||||
if stops and any(match._kw_fold(w) in hay for w in stops):
|
||||
return False
|
||||
return True
|
||||
|
||||
rows = []
|
||||
if typ == "bill":
|
||||
row = sc.execute("SELECT * FROM s_bills WHERE id=? AND session_id=?", (rid, sid)).fetchone() if rid else None
|
||||
if rid and not row:
|
||||
return {"ok": False, "msg": "找不到这一行"}
|
||||
uw_names = {u["id"]: (u["Name"] or "") for u in
|
||||
sc.execute("SELECT id, Name FROM s_unit_works WHERE session_id=?", (sid,))}
|
||||
grp = bool(row) and (body.get("scope") == "self_group") and row["x_name_norm"] is not None
|
||||
if row is None:
|
||||
cands = sc.execute("SELECT * FROM s_bills WHERE session_id=? ORDER BY id", (sid,)).fetchall()
|
||||
elif grp:
|
||||
cands = sc.execute("""SELECT * FROM s_bills WHERE session_id=? AND id<>?
|
||||
AND x_name_norm IS ? AND x_attr_norm IS ? ORDER BY id""",
|
||||
(sid, rid, row["x_name_norm"], row["x_attr_norm"])).fetchall()
|
||||
else:
|
||||
cands = sc.execute("SELECT * FROM s_bills WHERE session_id=? AND id<>? ORDER BY id",
|
||||
(sid, rid)).fetchall()
|
||||
qn = match.norm_match(row["Name"]) if row is not None else None
|
||||
qattr = match.norm_match(row["Attr"] or "") if row is not None else None
|
||||
setkey = match.bill_setkey(row["Name"], row["Unit"]) if row is not None else None
|
||||
pre = match.norm(row["Name"])[:6] if row is not None else None
|
||||
for b in cands:
|
||||
if row is None:
|
||||
rows.append({
|
||||
"tier": "检索", "name": b["Name"], "attr": b["Attr"], "unit": b["Unit"],
|
||||
"price": b["Price"], "period": period, "period_m": pf, "dist": 0,
|
||||
"sim": None, "src": "本工程", "proj": uw_names.get(b["uw_id"]) or "本工程",
|
||||
"bunit": bunit, "region": region, "self_bill_id": b["id"],
|
||||
"norms": [[n["Number"], n["Name"], n["Unit"], n["Quantity"], n["Price"], n["Total"], 0, 0]
|
||||
for n in sc.execute("""SELECT Number, Name, Unit, Quantity, Price, Total, x_tdel FROM s_norms WHERE bill_id=? AND (x_tdel IS NULL OR x_tdel=0) ORDER BY id""", (b["id"],)).fetchall()],
|
||||
"file": "", "file_url": ""})
|
||||
continue
|
||||
tier, sim = None, None
|
||||
j = match.jaccard(qn, match.norm_match(b["Name"]))
|
||||
if b["x_hash_exact"] and b["x_hash_exact"] == row["x_hash_exact"]:
|
||||
tier, sim = "精确", 1.0
|
||||
elif b["x_hash_semi"] and b["x_hash_semi"] == row["x_hash_semi"] and j >= match.SEMI_NAME_MIN:
|
||||
tier, sim = "次精确", 1.0
|
||||
elif match.bill_setkey(b["Name"], b["Unit"]) == setkey:
|
||||
tier, sim = "字集", 1.0
|
||||
elif (not grp and pre and match.norm(b["Name"]).startswith(pre)
|
||||
and match.norm(b["Unit"]) == match.norm(row["Unit"])):
|
||||
simv = match.sim_weighted(qn, match.norm_match(b["Name"]), qattr,
|
||||
match.norm_match(b["Attr"] or ""))
|
||||
if simv >= match.SIM_MIN:
|
||||
tier, sim = "模糊", round(simv, 2)
|
||||
if tier is None:
|
||||
continue
|
||||
norms = [[n["Number"], n["Name"], n["Unit"], n["Quantity"], n["Price"], n["Total"], 0, 0]
|
||||
for n in sc.execute("""SELECT Number, Name, Unit, Quantity, Price, Total, x_tdel
|
||||
FROM s_norms WHERE bill_id=? AND (x_tdel IS NULL OR x_tdel=0)
|
||||
ORDER BY id""", (b["id"],)).fetchall()]
|
||||
rows.append({
|
||||
"tier": tier, "name": b["Name"], "attr": b["Attr"], "unit": b["Unit"],
|
||||
"price": b["Price"], "period": period, "period_m": pf, "dist": 0,
|
||||
"sim": sim, "src": "本工程", "proj": uw_names.get(b["uw_id"]) or "本工程",
|
||||
"bunit": bunit, "region": region, "self_bill_id": b["id"], "norms": norms,
|
||||
"file": "", "file_url": ""})
|
||||
else:
|
||||
row = sc.execute("SELECT * FROM s_lme_proj WHERE id=? AND session_id=?", (rid, sid)).fetchone() if rid else None
|
||||
if rid and not row:
|
||||
return {"ok": False, "msg": "找不到这一行"}
|
||||
h_e = job.md5(row["name"], row["spec"], row["unit"]) if row is not None else None
|
||||
h_s = job.md5(row["name"], row["unit"]) if row is not None else None
|
||||
setk = match.lme_setkey(row["name"], row["spec"], row["unit"]) if row is not None else None
|
||||
qn = match.norm_match(row["name"]) if row is not None else None
|
||||
pre = match.norm(row["name"])[:6] if row is not None else None
|
||||
for l in sc.execute("SELECT * FROM s_lmes WHERE session_id=? ORDER BY id", (sid,)).fetchall():
|
||||
if row is None:
|
||||
rows.append({
|
||||
"tier": "检索", "name": l["Name"], "attr": "", "spec": l["Specification"],
|
||||
"unit": l["Unit"], "price": l["NoTaxPrice"], "tax": l["TaxRate"],
|
||||
"price_tax": l["TaxPrice"], "note": "", "period": period, "period_m": pf,
|
||||
"dist": 0, "sim": None, "src": "本工程", "proj": "本工程", "bunit": bunit,
|
||||
"region": region, "file": "", "file_url": ""})
|
||||
continue
|
||||
tier, sim = None, None
|
||||
j = match.jaccard(qn, match.norm_match(l["Name"]))
|
||||
if l["x_hash_exact"] and l["x_hash_exact"] == h_e:
|
||||
tier, sim = "精确", 1.0
|
||||
elif l["x_hash_semi"] and l["x_hash_semi"] == h_s:
|
||||
tier, sim = "次精确", 1.0
|
||||
elif match.lme_setkey(l["Name"], l["Specification"], l["Unit"]) == setk:
|
||||
tier, sim = "字集", 1.0
|
||||
elif pre and match.norm(l["Name"]).startswith(pre) and match.norm(l["Unit"]) == match.norm(row["unit"]):
|
||||
if j >= match.SIM_MIN:
|
||||
tier, sim = "模糊", round(j, 2)
|
||||
if tier is None:
|
||||
continue
|
||||
rows.append({
|
||||
"tier": tier, "name": l["Name"], "attr": "", "spec": l["Specification"],
|
||||
"unit": l["Unit"], "price": l["NoTaxPrice"], "tax": l["TaxRate"],
|
||||
"price_tax": l["TaxPrice"], "note": "", "period": period, "period_m": pf,
|
||||
"dist": 0, "sim": sim, "src": "本工程", "proj": "本工程", "bunit": bunit,
|
||||
"region": region, "file": "", "file_url": ""})
|
||||
rows = [r for r in rows
|
||||
if _pass((r.get("name"), r.get("attr"), r.get("spec"), r.get("unit")))]
|
||||
return {"ok": True, "base_period": period, "rows": rows[:limit], "total": len(rows)}
|
||||
finally:
|
||||
sc.close()
|
||||
|
||||
|
||||
def api_hist_search(body):
|
||||
"""独立检索(2026-10-08 主人定 B 方案):条件+关键词 跨全部入库项目
|
||||
target='bill'(默认)查**清单库**;target='lme'(工料机标签专用,2026-10-08 主人定)
|
||||
@@ -4077,6 +4330,7 @@ def api_hist_search(body):
|
||||
limit=min(int(body.get("limit", 200)), 500),
|
||||
self_name=self_name, self_src=self_src,
|
||||
page=int(body.get("page", 1) or 1),
|
||||
projs=body.get("projs") or [],
|
||||
stop=match.stop_words(body.get("stop")))
|
||||
else:
|
||||
res = match.hist_search(hist,
|
||||
@@ -4088,6 +4342,7 @@ def api_hist_search(body):
|
||||
min(int(body.get("limit", 200)), 500),
|
||||
self_name=self_name, self_src=self_src,
|
||||
page=int(body.get("page", 1) or 1),
|
||||
projs=body.get("projs") or [],
|
||||
stop=match.stop_words(body.get("stop")))
|
||||
finally:
|
||||
hist.close()
|
||||
@@ -4125,6 +4380,7 @@ def api_delete_batch(con, bid):
|
||||
con.execute("DELETE FROM lme_proj WHERE batch_id=?", (bid,))
|
||||
con.execute("DELETE FROM lme_uw WHERE batch_id=?", (bid,))
|
||||
con.execute("DELETE FROM lme_attach WHERE batch_id=?", (bid,))
|
||||
con.execute("DELETE FROM bill_attach WHERE batch_id=?", (bid,))
|
||||
con.execute("DELETE FROM inquiry_files WHERE batch_id=?", (bid,))
|
||||
con.execute("DELETE FROM unit_works WHERE batch_id=?", (bid,))
|
||||
con.execute("DELETE FROM sections WHERE batch_id=?", (bid,))
|
||||
@@ -4213,6 +4469,7 @@ def api_clear_mock(con):
|
||||
con.execute("DELETE FROM lme_proj WHERE batch_id IN (%s)" % ph, part)
|
||||
con.execute("DELETE FROM lme_uw WHERE batch_id IN (%s)" % ph, part)
|
||||
con.execute("DELETE FROM lme_attach WHERE batch_id IN (%s)" % ph, part)
|
||||
con.execute("DELETE FROM bill_attach WHERE batch_id IN (%s)" % ph, part)
|
||||
con.execute("DELETE FROM inquiry_files WHERE batch_id IN (%s)" % ph, part)
|
||||
con.execute("DELETE FROM unit_works WHERE batch_id IN (%s)" % ph, part)
|
||||
con.execute("DELETE FROM sections WHERE batch_id IN (%s)" % ph, part)
|
||||
@@ -5736,6 +5993,7 @@ def api_filters():
|
||||
# 2026-10-07 主人定:列表筛选补 单价类型(已有 file_kind)/建设单位/总价区间/发布单位
|
||||
"bu_rows": _distinct_rows("BulidUnit", "kind='project'"), # 历史项目里出现过的建设单位
|
||||
"pub_rows": _distinct_rows("x_publisher", "kind<>'project'"), # 信息价/市场价里出现过的发布单位
|
||||
"proj_rows": _distinct_rows("Name", "kind='project'"), # 决策 141:项目名称框选项池(历史项目名)
|
||||
}
|
||||
|
||||
|
||||
@@ -6123,6 +6381,13 @@ class Handler(SimpleHTTPRequestHandler):
|
||||
return self._json(api_inq_list(c, int(m.group(1))))
|
||||
finally:
|
||||
c.close()
|
||||
m = re.match(r"^/api/admin/batch/(\d+)/inq/bills$", p) # 决策 152:类似清单页签
|
||||
if m:
|
||||
c = conn()
|
||||
try:
|
||||
return self._json(api_inq_bills(c, int(m.group(1))))
|
||||
finally:
|
||||
c.close()
|
||||
m = re.match(r"^/api/admin/inq/file/(\d+)$", p) # 下载
|
||||
if m:
|
||||
return self._inq_file(int(m.group(1)))
|
||||
@@ -6221,6 +6486,8 @@ class Handler(SimpleHTTPRequestHandler):
|
||||
return self._json(api_session_delete(body))
|
||||
if u.path == "/api/search": # 比对:找历史相似项
|
||||
return self._json(api_search(body))
|
||||
if u.path == "/api/self/search": # 范围=是(决策 158):本会话内比对/检索
|
||||
return self._json(api_self_search(body))
|
||||
if u.path == "/api/hist/search": # 独立检索(2026-10-08 B 方案):条件+关键词 跨全部入库项目查清单
|
||||
return self._json(api_hist_search(body))
|
||||
if u.path == "/api/session/setting": # 工作台「分组/匹配」设置写入(会话库)
|
||||
|
||||
@@ -339,6 +339,16 @@ CREATE TABLE IF NOT EXISTS lme_attach(
|
||||
CREATE INDEX IF NOT EXISTS ix_lmeatt_file ON lme_attach(file_id);
|
||||
CREATE INDEX IF NOT EXISTS ix_lmeatt_batch ON lme_attach(batch_id);
|
||||
|
||||
-- 清单 ↔ 询价附件 的关联(2026-10-21 决策 152:类似清单页签也能绑附件,同 lme_attach 口径)
|
||||
-- · 一条清单 → 只一个附件(★ bill_id 作主键,数据库强制);换绑 INSERT OR REPLACE 覆盖。
|
||||
CREATE TABLE IF NOT EXISTS bill_attach(
|
||||
bill_id INTEGER PRIMARY KEY, -- bills.id
|
||||
batch_id INTEGER NOT NULL, -- 冗余,便于按项目整体清理
|
||||
file_id INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS ix_bilatt_file ON bill_attach(file_id);
|
||||
CREATE INDEX IF NOT EXISTS ix_bilatt_batch ON bill_attach(batch_id);
|
||||
|
||||
-- ===========================================================================
|
||||
-- 数据源字典(2026-10-06 新增)
|
||||
--
|
||||
|
||||
@@ -131,6 +131,16 @@ def test_inq_lifecycle(server):
|
||||
assert un["ok"] is True and un["n"] == 1
|
||||
assert get(server, "/api/admin/batch/%d/inq" % b1)["total_bound"] == 0
|
||||
post(server, "/api/admin/batch/%d/inq/bind" % b1, {"file_id": fid, "lme_ids": [lme_b1]})
|
||||
# 决策 152:清单也能绑附件(bill_attach 同口径)+ /inq/bills 列表 + 附件角标含清单数
|
||||
bill_b1 = _q(server["db"], "SELECT id FROM bills WHERE batch_id=?", (b1,))[0][0]
|
||||
bb = post(server, "/api/admin/batch/%d/inq/bind" % b1, {"file_id": fid, "bill_ids": [bill_b1]})
|
||||
assert bb["ok"] is True and bb["n"] == 1
|
||||
bl = get(server, "/api/admin/batch/%d/inq/bills" % b1)
|
||||
assert bl["ok"] is True and bl["rows"] and bl["rows"][0]["file_id"] == fid
|
||||
lst2 = get(server, "/api/admin/batch/%d/inq" % b1)
|
||||
assert lst2["files"][0]["n"] == 2 # 1 工料机 + 1 清单
|
||||
unb = post(server, "/api/admin/batch/%d/inq/unbind" % b1, {"bill_ids": [bill_b1]})
|
||||
assert unb["ok"] is True and unb["n"] == 1
|
||||
stored = _q(server["db"], "SELECT stored_path FROM inquiry_files WHERE id=?", (fid,))[0][0]
|
||||
fp = server["root"] / "CostReview" / "data" / stored
|
||||
assert fp.exists()
|
||||
|
||||
@@ -33,7 +33,7 @@ def _mk_sess():
|
||||
c.execute("""CREATE TABLE s_lme_proj(id INTEGER PRIMARY KEY, session_id INT,
|
||||
code TEXT, name TEXT, spec TEXT, unit TEXT, kind INT,
|
||||
qty REAL, ntp REAL, taxrate REAL, taxp REAL,
|
||||
x_adopt_added INTEGER DEFAULT 0, x_merged_hide INTEGER DEFAULT 0)""")
|
||||
x_adopt_added INTEGER DEFAULT 0, x_merged_hide INTEGER DEFAULT 0, x_remark TEXT)""")
|
||||
c.execute("""CREATE TABLE s_lme_uw(id INTEGER PRIMARY KEY, session_id INT, uw_id INT,
|
||||
code TEXT, name TEXT, spec TEXT, unit TEXT, kind INT,
|
||||
qty REAL, ntp REAL, taxrate REAL, taxp REAL, x_adopt_added INTEGER DEFAULT 0)""")
|
||||
@@ -175,15 +175,16 @@ def test_no_price_fields_is_noop():
|
||||
|
||||
# ---------- 行形状(前后端同改的铁律处)----------
|
||||
|
||||
def test_raw_proj_rows_are_nine_wide_with_taxrate_at_7():
|
||||
"""项目级卡:行 9 列、税率在下标 7;ids 与行一一并行;隐藏行不给 id;含税价挪到下标 8。"""
|
||||
def test_raw_proj_rows_are_eleven_wide_id_first():
|
||||
"""决策 147(2026-10-21):项目级卡与「项目工料机」同形 —— 行 11 列 id 在首位、备注位 10;
|
||||
税率在下标 7、含税在下标 8;不再 rows/ids 分离;隐藏行被过滤。"""
|
||||
sc = _mk_sess()
|
||||
d = srv._raw_proj(sc, srv.TBL["session"], SID, "lme")
|
||||
assert len(d["rows"]) == 2 # 隐藏行被过滤
|
||||
assert all(len(r) == 9 for r in d["rows"])
|
||||
assert all(len(r) == 11 for r in d["rows"])
|
||||
r0 = d["rows"][0]
|
||||
assert r0[0] == "C1" and r0[6] == 99.99 and r0[7] == 3.5 and r0[8] == 103.49
|
||||
assert d["ids"] == [1, 2] # 与行一一并行,隐藏行(id=3)不在
|
||||
assert r0[0] == 1 and r0[1] == "C1" and r0[6] == 99.99 and r0[7] == 3.5 and r0[8] == 103.49
|
||||
assert "ids" not in d
|
||||
assert d["sub"] == ["P1"]
|
||||
|
||||
|
||||
@@ -210,8 +211,8 @@ def _mk_lmes(sc, with_taxrate=True):
|
||||
Quantity REAL, NoTaxPrice REAL, TaxPrice REAL%(tx)s)""" % {"tx": tx})
|
||||
|
||||
|
||||
def test_raw_proj_fallback_nine_wide_taxrate_at_7():
|
||||
"""老会话(s_lme_proj 无数据)回退 lmes:仍 9 列、税率在下标 7、含税在下标 8;无 ids=只读。"""
|
||||
def test_raw_proj_fallback_eleven_wide_taxrate_at_7():
|
||||
"""老会话(s_lme_proj 无数据)回退 lmes:决策 147 后 11 列 id 首位、税率在下标 7、含税在下标 8;无 ids=只读。"""
|
||||
sc = _mk_sess()
|
||||
sc.execute("DELETE FROM s_lme_proj")
|
||||
_mk_lmes(sc, with_taxrate=True)
|
||||
@@ -220,8 +221,8 @@ def test_raw_proj_fallback_nine_wide_taxrate_at_7():
|
||||
[("C1", "钢筋", "", 99.99, 3.5, 103.49),
|
||||
("C2", "水泥", "", 200.0, 3.5, 207.0)])
|
||||
d = srv._raw_proj(sc, srv.TBL["session"], SID, "lme")
|
||||
assert all(len(r) == 9 for r in d["rows"])
|
||||
assert d["rows"][0][0] == "C1" and d["rows"][0][6] == 99.99
|
||||
assert all(len(r) == 11 for r in d["rows"])
|
||||
assert d["rows"][0][1] == "C1" and d["rows"][0][6] == 99.99
|
||||
assert d["rows"][0][7] == 3.5 and d["rows"][0][8] == 103.49
|
||||
assert "ids" not in d
|
||||
|
||||
@@ -235,7 +236,7 @@ def test_raw_proj_fallback_without_taxrate_column():
|
||||
Quantity, NoTaxPrice, TaxPrice) VALUES(1,'C1','钢筋','kg',2, 10, 99.99, 103.49)""")
|
||||
d = srv._raw_proj(sc, srv.TBL["session"], SID, "lme")
|
||||
r0 = d["rows"][0]
|
||||
assert len(r0) == 9 and r0[6] == 99.99 and r0[7] is None and r0[8] == 103.49
|
||||
assert len(r0) == 11 and r0[6] == 99.99 and r0[7] is None and r0[8] == 103.49
|
||||
|
||||
|
||||
def test_raw_uw_agg_fallback_nine_wide_taxrate_at_7():
|
||||
@@ -382,10 +383,10 @@ def test_http_lme_price_end_to_end(server):
|
||||
"district": "香洲区", "period_from": PERIOD_202607,
|
||||
"period_to": PERIOD_202607, "file_kind": 1, "path": p})["session_id"]
|
||||
d = get(server, "/api/session/raw/proj", session_id=sid, tab="lme")
|
||||
assert d["ok"] is True and d["rows"] and all(len(r) == 9 for r in d["rows"])
|
||||
rid = d["ids"][0]
|
||||
assert d["ids"] and len(d["ids"]) == len(d["rows"])
|
||||
code = d["rows"][0][0]
|
||||
# 决策 147:11 列 id 首位,不再 rows/ids 分离
|
||||
assert d["ok"] is True and d["rows"] and all(len(r) == 11 for r in d["rows"])
|
||||
rid = d["rows"][0][0]
|
||||
code = d["rows"][0][1]
|
||||
# 改除税 99.99 + 税率 3.5 → 含税 103.49(主人给的例,服务端复核)
|
||||
r = post(server, "/api/session/lme/price",
|
||||
{"session_id": sid, "id": rid, "ntp": 99.99, "taxrate": 3.5})
|
||||
|
||||
@@ -15,7 +15,7 @@ body{font-family:"Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSan
|
||||
align-items:flex-end —— 右侧「设置 / 工作台」两个按钮底部与标签对齐、保持自身自然高度(≈29px),
|
||||
比标签矮 3px,一眼能分清「标签」和「按钮」,不用再靠 margin-bottom 人为错开。 */
|
||||
.tabs{display:flex;align-items:flex-end;gap:4px;border-bottom:2px solid var(--c1)}
|
||||
.tab{height:32px;display:flex;align-items:center;padding:0 22px;cursor:pointer;
|
||||
.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}
|
||||
.tab:hover{background:#dbe5f2}
|
||||
@@ -26,6 +26,33 @@ body{font-family:"Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSan
|
||||
.dtab:hover{background:#dbe5f2}
|
||||
.dtab.on{background:var(--c1);color:#fff;border-color:var(--c1)}
|
||||
.tab.on{background:var(--c1);color:#fff;border-color:var(--c1)}
|
||||
/* 动态明细标签(2026-10-21 决策 150 主人定):点「明细」在此追加浏览器式标签,× 可关;
|
||||
固定三标签(入库项目/市场价/信息价 = 一个项目、一份市场价数据、一份信息价数据)不可关。
|
||||
外观同 .tab,但**不能用 .tab 类**(同 .dtab 的理由:页面标签脚本按 .tab 统一接管点击)。
|
||||
标签文字 = 类型前缀(项目·/市场价·/信息价·)+ 数据名 + 色点 —— 一眼认出点开的是哪份数据(主人补充定)。
|
||||
#xtabs 占据固定三标签与右侧按钮之间的全部宽度,标签多时横向滚动(细滚动条)。 */
|
||||
#xtabs{display:flex;align-items:flex-end;gap:4px;flex:1;min-width:0;overflow-x:auto;overflow-y:hidden;
|
||||
padding:0 2px;scrollbar-width:thin}
|
||||
#xtabs::-webkit-scrollbar{height:4px}
|
||||
.xtab{flex:none;max-width:260px;height:32px;display:flex;align-items:center;gap:6px;padding:0 8px 0 16px;
|
||||
cursor:pointer;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}
|
||||
.xtab:hover{background:#dbe5f2}
|
||||
.xtab.on{background:var(--c1);color:#fff;border-color:var(--c1)}
|
||||
.xtab .kd{flex:none;width:8px;height:8px;border-radius:2px;background:#94a3b8}
|
||||
.xtab .kd.project{background:#2563eb}.xtab .kd.market{background:#1a7f37}.xtab .kd.info{background:#d97706}
|
||||
.xtab .kd.inq{background:#0e9488} /* 决策 152:附件标签色点 */
|
||||
.xtab .xl{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.xtab .xx{flex:none;color:#8899aa;font-size:15px;line-height:1;padding:1px 5px;border-radius:4px}
|
||||
.xtab .xx:hover{background:rgba(0,0,0,.18);color:#fff}
|
||||
.xtab.on .xx{color:rgba(255,255,255,.85)}
|
||||
/* 明细标签页容器(决策 150):顶替原明细弹框——与列表 .panel 同级的页面区块,
|
||||
高度由 JS 按视口吃满(同 availHeight 口径,.wrap 底部内边距 24px),内部 .db 各自滚动 */
|
||||
#dpage{display:none;flex-direction:column;background:#fff;border:1px solid var(--line);border-top:none;min-height:420px}
|
||||
/* 附件动态标签页(决策 152):容器同 #dpage 口径;内部 qwrap 吃满剩余高度(原弹框定高取消) */
|
||||
#qpage{display:none;flex-direction:column;background:#fff;border:1px solid var(--line);border-top:none;min-height:420px}
|
||||
.qhead{display:flex;align-items:center;gap:10px;padding:9px 14px;border-bottom:1px solid var(--line);
|
||||
background:#fafcff;flex:none}
|
||||
.panel{background:#fff;border:1px solid var(--line);border-top:none}
|
||||
/* 查询栏:**强制单行**(2026-10-07 主人定:保证一行,不要 2 行)——
|
||||
可收缩控件按比例让宽,窗口放不下时查询栏内部出细横向滚动条(仍是一行)。 */
|
||||
@@ -64,11 +91,10 @@ body{font-family:"Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSan
|
||||
/* ---- 询价附件弹窗(2026-10-06)----
|
||||
左 38% 上传区 / 右 62% 工料机:右边 7 列给窄了必然横滚,等于白做。
|
||||
中间 1px 实线 + 12px 间距,不用虚线 —— 虚线在这里不承载任何信息。 */
|
||||
.qwrap{display:flex;gap:12px;height:min(560px,66vh);padding:12px}
|
||||
.qleft{width:38%;min-width:296px;display:flex;flex-direction:column;gap:8px;
|
||||
border-right:1px solid #d8e0ec;padding-right:12px}
|
||||
.qwrap{display:flex;gap:12px;flex:1;min-height:0;padding:12px}
|
||||
.qleft{width:40%;min-width:296px;display:flex;flex-direction:column;gap:8px;
|
||||
border-right:none;padding-right:0} /* 决策 153:默认 40%,分隔条拖宽后记忆 */
|
||||
.qright{flex:1;display:flex;flex-direction:column;gap:8px;min-width:0}
|
||||
.qsec{border:1px solid #c9d4e2;background:#fafcff;border-radius:6px;padding:10px}
|
||||
.qlist{flex:1;overflow:auto;border:1px solid #c9d4e2;border-radius:6px;background:#fff}
|
||||
.qitem{padding:8px 10px;border-bottom:1px solid #eef2f7;cursor:pointer;
|
||||
display:flex;gap:8px;align-items:flex-start;font-size:12.5px}
|
||||
@@ -86,6 +112,24 @@ body{font-family:"Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSan
|
||||
.qlme td{border-bottom:1px solid #f0f3f8;padding:5px 8px;vertical-align:top}
|
||||
/* 已绑:整行底色 + 名称后灰标。只靠复选框勾中态分不清「本次新勾」和「之前已绑」 */
|
||||
.qlme tr.bound{background:#f4f8ff}
|
||||
/* 决策 152:右侧工作区顶部「项目工料机 / 类似清单」页签(同操作/明细的浏览器式块状页签) */
|
||||
.qtab{padding:5px 14px;cursor:pointer;border:1px solid var(--line);border-bottom:none;
|
||||
background:#e7edf5;border-radius:8px 8px 0 0;font-size:12.5px;color:#374151;white-space:nowrap;
|
||||
user-select:none}
|
||||
.qtab:hover{background:#dbe5f2}
|
||||
.qtab.on{background:var(--c1);color:#fff;border-color:var(--c1)}
|
||||
.qtabs{display:flex;gap:4px;align-items:flex-end;border-bottom:1px solid var(--line);padding-right:8px}
|
||||
.qtree .rt{font-weight:600;padding:6px 10px;background:#f4f8ff;border-bottom:1px solid #d8e0ec;
|
||||
display:flex;align-items:center;gap:6px}
|
||||
/* 决策 153:左右分隔条拖宽(记忆)+ 工作台同款按钮 + 搜索关键词黄色高亮 */
|
||||
.qsplit{flex:none;width:6px;cursor:col-resize;border-radius:3px;background:#e3e9f2}
|
||||
.qsplit:hover{background:#c9d8ec}
|
||||
.btn.wb{display:inline-flex;align-items:center;justify-content:center;height:28px;padding:0 12px;
|
||||
border:1px solid #b8c4d4;border-radius:6px;background:#fff;cursor:pointer;font:inherit;
|
||||
font-size:12.5px;color:#26405e;line-height:1;white-space:nowrap;vertical-align:middle;
|
||||
user-select:none;flex:none}
|
||||
.btn.wb:hover{background:#eef3fa}
|
||||
mark.qhl{background:#ffe58f;color:inherit;padding:0 1px;border-radius:2px}
|
||||
.sum{color:var(--muted);font-size:12px;margin-left:auto}
|
||||
.sum b{color:#c0392b}
|
||||
/* .tw 高度由 JS 动态设(与行数自适应同源,见 autoSize/availHeight)——
|
||||
@@ -113,26 +157,26 @@ td.name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.pager{display:flex;gap:8px;align-items:center;justify-content:flex-end;padding:8px 12px;font-size:13px;color:var(--muted)}
|
||||
a{color:var(--c2);text-decoration:none}
|
||||
a:hover{text-decoration:underline}
|
||||
.dlg .tabs{border-bottom:2px solid var(--c1)}
|
||||
/* 明细子标签条已随决策 150 移出弹框、进页面标签页 #dpage(其余弹框没有 .tabs) */
|
||||
#dtabs{border-bottom:2px solid var(--c1)}
|
||||
.mask{position:fixed;inset:0;background:rgba(0,0,0,.35);display:none;align-items:center;justify-content:center;z-index:50}
|
||||
.mask.on{display:flex}
|
||||
/* 明细弹框:主人 2026-10-01 要「同软件宽度」→ 跟随窗口,只在超宽屏上封顶 */
|
||||
/* 明细弹框宽度口径(主人 2026-10-01「同软件宽度」)现为其余弹框(导入/附件/编辑/字典/询价)通用 */
|
||||
.dlg{background:#fff;border-radius:8px;width:96vw;max-width:1760px;max-height:92vh;display:flex;flex-direction:column}
|
||||
/* 2026-10-08 主人定:明细弹框高度钉死 92vh —— 各标签内容高矮差异太大,内容撑高 +
|
||||
遮罩垂直居中 = 每次加载/切标签顶边都在跳。盒子尺寸恒定后,打开第一帧就落在最终
|
||||
位置,数据加载、切标签、树展开全部零移动(内部 .db 本来就各自滚动)。 */
|
||||
#mask .dlg{height:92vh}
|
||||
/* 2026-10-08「明细弹框高度钉死 92vh」已随决策 150(2026-10-21 主人定)作废:明细不再开弹框,
|
||||
改为页面内动态标签页 #dpage——高度吃满 .wrap 剩余空间、内部 .db 各自滚动,
|
||||
「盒子尺寸恒定、零移动」的思路原样保留,只是容器从遮罩弹框换成页面标签页。 */
|
||||
.dlg .dh{display:flex;justify-content:space-between;align-items:center;padding:11px 16px;
|
||||
border-bottom:1px solid var(--line);background:var(--head);border-radius:8px 8px 0 0}
|
||||
.dlg .dh b{color:var(--c1);font-size:14px}
|
||||
.dlg .db{overflow:auto;padding:0}
|
||||
#dpage .db{overflow:auto;padding:0}
|
||||
/* 类似清单左组树(2026-10-08 主人定:后台同工作台):仅 p2 标签显示,dbody 转 flex 行、树占左列 */
|
||||
#dbody.simflex{display:flex}
|
||||
#simtree{width:230px;flex:none;border-right:1px solid var(--line);overflow:auto;padding:6px 4px;background:#fcfdfe}
|
||||
.close{cursor:pointer;color:#8899aa;font-size:20px;line-height:1}
|
||||
.tip{color:var(--muted);font-size:12px;padding:6px 0}
|
||||
/* 明细:左侧目录 + 右侧内容(照上传 HTML 的版式) */
|
||||
.dlg .db.fx{display:flex;overflow:hidden}
|
||||
#dpage .db.fx{display:flex;overflow:hidden}
|
||||
/* 原数据标签要跟工作台一样「左树 + 右卡 + 下方工料机面板」各自滚动:
|
||||
必须给 #dright / #drawbox 撑出确定高度,否则 .rawbox 的 height:100% 在弹框里算不出来、整块塌陷。 */
|
||||
#dright{flex:1;min-width:0;display:flex;flex-direction:column;min-height:0}
|
||||
@@ -236,12 +280,15 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
<div class="tab on" data-kind="project">入库项目</div>
|
||||
<div class="tab" data-kind="market">市场价</div>
|
||||
<div class="tab" data-kind="info">信息价</div>
|
||||
<!-- 动态明细标签挂点(2026-10-21 决策 150 主人定):点「明细」在此追加浏览器式标签,
|
||||
同批次重复点击=聚焦已开标签;固定三标签永不关闭、动态标签带 × 可关 -->
|
||||
<div id="xtabs"></div>
|
||||
<!-- 单位地区设置:地区 / 发布单位 / 建设单位 的唯一来源,后台与工作台共用。
|
||||
放在标签栏最右(margin-left:auto),不参与上面三个数据标签的切换。
|
||||
2026-10-10 决策 31:按钮名「设置」让位给统一的「⚙ 设置」窗口(common.js,
|
||||
授权管理入口),本按钮改回原名「数据源」——功能一点没动。
|
||||
margin-bottom:6px —— 让它比标签条矮半截,免得看起来像第四个标签。 -->
|
||||
<button class="btn" id="btnDict" style="margin-left:auto" onclick="openDict()"
|
||||
<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>
|
||||
<!-- 工作台入口(2026-10-06 主人定):从标题行右上角搬到标签栏,排在「设置」右边。
|
||||
2026-10-19 主人定:去掉 ▶ 图标,蓝底让位,尺寸样式对齐工作台顶栏按钮
|
||||
@@ -252,7 +299,7 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
title="打开工作台:导入工程、做历史比对与审核">工作台</button>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel" id="lpanel">
|
||||
<div class="bar">
|
||||
<input id="fq" placeholder="名称关键字">
|
||||
<select id="fp"><option value="">全省/市</option></select>
|
||||
@@ -296,9 +343,11 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mask" id="mask">
|
||||
<div class="dlg">
|
||||
<div class="dh"><b id="dt"></b><span class="close" onclick="closeDlg()">×</span></div>
|
||||
<!-- 明细动态标签页(2026-10-21 决策 150 主人定):明细不再开弹框——原弹框 DOM 原样搬进 #dpage,
|
||||
只去掉遮罩与弹框头:标签名即标题(带类型前缀,见 renderXTabs),关闭在标签 × 上。
|
||||
#dt 隐藏保留:价格目录树根名(pdFold 渲染)与导出文件名(pdExport)仍取它。 -->
|
||||
<div id="dpage">
|
||||
<b id="dt" style="display:none"></b>
|
||||
<!-- 4 个标签由 common.js 的 TABS 生成(与工作台同一份顺序/名称/默认页),禁止在此硬编码 -->
|
||||
<div class="tabs" id="dtabs"></div>
|
||||
<div class="db" id="dbody">
|
||||
@@ -337,7 +386,48 @@ td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb
|
||||
<!-- 原数据单位工程级的层级按钮挂点(2026-10-13 决策 58:分组/清单/定额/默认列宽 迁到这里最右) -->
|
||||
<span id="rawLvMount" class="rawLvMount" style="margin-left:auto;display:inline-flex;gap:4px;align-items:center"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 附件动态标签页(2026-10-21 决策 152 主人定):询价附件不再开弹框——原弹框 DOM 搬进 #qpage,
|
||||
从列表行「询价附件」列点开 = 顶部追加「附件 · 名称」浏览器式标签(同决策 150 明细同款机制) -->
|
||||
<div id="qpage">
|
||||
<div class="qhead"><b id="qtitle">附件</b>
|
||||
<span class="tip">左边附件目录点选一个附件 → 右边勾选 → 「绑定选中」;绑定的附件在工作台历史对比框可下载</span></div>
|
||||
<div class="qwrap">
|
||||
<!-- 左:附件目录 -->
|
||||
<div class="qleft">
|
||||
<div class="qlist qtree" id="qlist"></div>
|
||||
<div class="tip" id="qmsg" style="margin:0"></div>
|
||||
</div>
|
||||
<div class="qsplit" id="qsplit" title="左右拖动调宽(自动记忆)"></div>
|
||||
<!-- 右:双页签工作区 -->
|
||||
<div class="qright">
|
||||
<div class="qtabs">
|
||||
<div class="qtab on" data-t="lme" onclick="qTab('lme')">项目工料机</div>
|
||||
<div class="qtab" data-t="bill" onclick="qTab('bill')">类似清单</div>
|
||||
<input id="qkw" placeholder="搜索当前工作区" style="flex:1;margin-left:8px" oninput="qSearchSoon()">
|
||||
</div>
|
||||
<div class="qscroll" id="qlmew"><table class="qlme" id="qtb"><colgroup id="qcgl"></colgroup><thead id="qthl"></thead><tbody id="qtbl"></tbody></table></div>
|
||||
<!-- 类似清单页签(决策 153③):左组目录树 + 共享 renderGroups 组表(多复选框列勾选绑附件) -->
|
||||
<div class="qscroll" id="qbw" style="display:none">
|
||||
<div style="display:flex;gap:8px;align-items:flex-start;min-height:100%">
|
||||
<div id="qsimtree" style="width:210px;flex:none;overflow:auto;max-height:100%"></div>
|
||||
<div style="flex:1;min-width:0;overflow:auto">
|
||||
<table class="qlme" id="qgt" data-ck="1" data-bk="1"><colgroup id="qcgb"></colgroup><thead id="qthb"></thead><tbody id="qtbb"></tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<label class="tip" style="white-space:nowrap;cursor:pointer">
|
||||
<input type="checkbox" id="qall" onchange="qAll(this)"> 全选(当前筛选)</label>
|
||||
<span class="tip" id="qc" style="white-space:nowrap"></span>
|
||||
<span class="tip" id="qbmsg" style="flex:1;text-align:right"></span>
|
||||
<button class="btn wb" onclick="qUnbind()">解绑选中</button>
|
||||
<button class="btn wb" onclick="qBind()">绑定选中</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="file" id="qfile" style="display:none">
|
||||
</div>
|
||||
|
||||
<div class="mask" id="imask">
|
||||
@@ -508,47 +598,10 @@ 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">
|
||||
|
||||
<!-- ===== 询价附件(项目工料机专用;信息价/市场价没有工料机,不会出现) ===== -->
|
||||
<div class="mask" id="qmask">
|
||||
<div class="dlg" style="width:min(1180px,94vw)">
|
||||
<div class="dh"><b id="qtitle">询价附件</b><span class="close" onclick="closeInq()">×</span></div>
|
||||
<div class="qwrap">
|
||||
<!-- 左:上传 + 已上传列表 -->
|
||||
<div class="qleft">
|
||||
<div class="qsec">
|
||||
<div style="font-weight:600;margin-bottom:4px">上传附件</div>
|
||||
<div class="tip" style="margin-bottom:8px">格式不限(可执行文件除外),一次一个文件,大小上限见「设置 → 上传设置」。只存不解析,随时可下载回来。</div>
|
||||
<button class="btn pri" onclick="qfile.click()">选择文件…</button>
|
||||
<input type="file" id="qfile" style="display:none">
|
||||
<div class="tip" id="qmsg" style="margin-top:8px"></div>
|
||||
</div>
|
||||
<div style="display:flex;align-items:center;justify-content:space-between">
|
||||
<b>已上传 <span id="qn">0</span> 个</b>
|
||||
<button class="btn danger" style="padding:3px 9px" onclick="qDel()">删除选中</button>
|
||||
</div>
|
||||
<div class="qlist" id="qlist"></div>
|
||||
<div class="tip">① 点左边一个附件选中它 ② 右边勾选工料机 ③ 点「绑定选中」</div>
|
||||
</div>
|
||||
<!-- 右:项目工料机(带复选框;同工料机页口径 LME_LIST_WHERE,过滤在后端 api_inq_lmes) -->
|
||||
<div class="qright">
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<input id="qkw" placeholder="搜 名称 / 规格 / 编码" style="flex:1" oninput="qRender()">
|
||||
<label class="tip" style="white-space:nowrap;cursor:pointer">
|
||||
<input type="checkbox" id="qall" onchange="qAll(this)"> 全选(当前筛选)</label>
|
||||
<span class="tip" id="qc" style="white-space:nowrap"></span>
|
||||
</div>
|
||||
<div class="qscroll"><table class="qlme" id="qtb"></table></div>
|
||||
<div style="display:flex;gap:8px;align-items:center;justify-content:flex-end">
|
||||
<span class="tip" id="qbmsg" style="flex:1"></span>
|
||||
<button class="btn" onclick="qUnbind()">解绑选中</button>
|
||||
<button class="btn pri" onclick="qBind()">绑定选中</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ===== 询价附件(2026-10-21 决策 152 主人定:左=附件目录树(根目录「附件目录」,上传/删除挂根行右侧);
|
||||
右=项目工料机/类似清单 双页签 + 行最右搜索框;两类都可绑附件,工作台对比框可下载) ===== -->
|
||||
|
||||
<script src="common.js?v=20261017h"></script>
|
||||
<script src="common.js?v=20261021d"></script>
|
||||
<script src="period.js"></script>
|
||||
<script>
|
||||
const $=id=>document.getElementById(id);
|
||||
@@ -1157,7 +1210,8 @@ var WB_RAW = RawView({
|
||||
getId: function(){ return DID; },
|
||||
normApi: function(nid){ return '/api/admin/norm/' + nid + '/res'; },
|
||||
lmeApi: function(){ return '/api/admin/lme/res?batch_id=' + DID; },
|
||||
treeEl: 'drawtree', tabsEl: 'drawstabs', bodyEl: 'drawbody'
|
||||
treeEl: 'drawtree', tabsEl: 'drawstabs', bodyEl: 'drawbody',
|
||||
lmeBackend: true // 决策 147:后台原数据项目级卡=后台项目工料机列集(无取消采纳/备注列)
|
||||
});
|
||||
|
||||
/* 明细弹框布局编排(2026-10-13 收编,**单一写入点**):
|
||||
@@ -1185,9 +1239,13 @@ function detLayout(mode){
|
||||
$('ptool').style.display = price?'flex':'none';
|
||||
}
|
||||
async function det(id,name,kind){
|
||||
DID=id; dt.textContent=name;
|
||||
if(kind) KIND=kind; // 2026-10-14 修:类型随批次传入——此前用全局 KIND(上一次/页签遗留)判断布局,
|
||||
// 从「入库项目」页签直接开信息价明细会走错分支、目录树空白
|
||||
// 动态标签(决策 150):同批次已开=聚焦(定位到已有下标,不重复开),没开=追加
|
||||
let i=XTABS.findIndex(t=>t.id===id && t.kind!=='inq'); // 附件标签(inq)不参与明细查重
|
||||
if(i<0){ XTABS.push({id,name,kind:KIND}); i=XTABS.length-1; }
|
||||
else if(name){ XTABS[i].name=name; XTABS[i].kind=KIND; }
|
||||
DID=id; dt.textContent=name;
|
||||
const isPrice=(KIND!=='project');
|
||||
// 价格类(信息价/市场价)只有一张价格明细表 → 不显示 4 个标签
|
||||
$('dtabs').style.display = isPrice?'none':'flex';
|
||||
@@ -1199,9 +1257,9 @@ async function det(id,name,kind){
|
||||
// 注:类似清单分组前后台**同一种方式**(决策 32 + 2026-10-13 主人确认「只有一种」)——
|
||||
// 同一套 v2 顺序管线,关键词层读工作台「⚙ 分组&过滤」存的全局分组设置(global.grp_rules);
|
||||
// 专业体系已取消,后台无分组配置入口(配置只在工作台改,两侧同源生效)。
|
||||
mask.classList.add('on');
|
||||
// 记住打开的明细:从后台跳去工作台再回来时,原来那份还在(主人 2026-10-01)
|
||||
try{ sessionStorage.setItem('admin_det', JSON.stringify({id:id, name:name})); }catch(e){}
|
||||
// 激活并显示明细页(决策 150):不再有遮罩,标签条 .on 随动,状态入会话存储
|
||||
//(从后台跳去工作台再回来时,开着的标签还在——主人 2026-10-01 的口径,容器换了口径不变)
|
||||
XACT=i; renderXTabs(); showDetail(true); xsave();
|
||||
// 2026-10-13 主人定:打开明细全程挂进度条(共享层 ldWrap)——覆盖旧版批次「看一次升一次」
|
||||
// 的升级 POST(服务端重活,大工程要重解析)+ 首标签取数;ldWrap 150ms 内完成不闪遮罩
|
||||
//(新版批次打开只要几十 ms,不闪),慢了才显示。loadTab 内部 ldStage 分段报阶段。
|
||||
@@ -1218,23 +1276,83 @@ async function det(id,name,kind){
|
||||
await loadTab(sessionStorage.getItem('admin_tab') || TAB_DEFAULT); // 与工作台一致:默认「原数据」
|
||||
});
|
||||
}
|
||||
function closeDlg(){
|
||||
mask.classList.remove('on');
|
||||
haoPopClose(); // 明细弹框关掉 = 浮层锚点没了,一并收(公共功能4)
|
||||
try{ sessionStorage.removeItem('admin_det'); }catch(e){}
|
||||
/* ===== 动态明细标签(2026-10-21 决策 150 主人定)=====
|
||||
点「明细」= 在固定三标签右侧追加浏览器式标签;同批次重复点击 = 聚焦已开标签
|
||||
(一份数据只开一个标签);× 关闭;全关 = 回落最后待过的固定标签。
|
||||
标签文字 = 类型前缀 + 数据名 + 色点,一眼认出点开的是哪份数据文件(主人补充定)。
|
||||
明细页内容仍是原弹框那套 DOM(#dpage),容器换了、内部版式决策原样保留。 */
|
||||
const XTABS=[]; // 已打开的明细标签 {id, name, kind}
|
||||
let XACT=-1; // 当前激活的明细标签下标(-1 = 显示列表区)
|
||||
let XLAST='project'; // 明细全关后回落到的固定标签(随固定标签点击更新)
|
||||
function xkind(k){ return k==='market'?'市场价':k==='info'?'信息价':k==='inq'?'附件':'项目'; }
|
||||
function renderXTabs(){
|
||||
$('xtabs').innerHTML = XTABS.map((t,i)=>
|
||||
`<div class="xtab${i===XACT?' on':''}" title="${xkind(t.kind)} · ${esc(t.name)}" onclick="focusXT(${i})">`
|
||||
+ `<span class="kd ${t.kind||'project'}"></span>`
|
||||
+ `<span class="xl">${xkind(t.kind)} · ${esc(t.name)}</span>`
|
||||
+ `<span class="xx" title="关闭标签" onclick="event.stopPropagation();closeXT(${i})">×</span></div>`).join('');
|
||||
}
|
||||
/* 回到后台页时把上次的明细恢复出来(关掉明细=主动结束,不再恢复) */
|
||||
function showPage(which){
|
||||
// 决策 152:页面三态切换 —— 列表 / 明细(决策 150)/ 附件动态标签页
|
||||
const lp=$('lpanel'), dp=$('dpage'), qp=$('qpage');
|
||||
lp.style.display = which==='list' ? '' : 'none';
|
||||
dp.style.display = which==='detail' ? 'flex' : 'none';
|
||||
qp.style.display = which==='inq' ? 'flex' : 'none';
|
||||
if(which!=='list'){
|
||||
const el = which==='detail' ? dp : qp;
|
||||
el.style.height=Math.max(420, window.innerHeight-el.getBoundingClientRect().top-24)+'px';
|
||||
}
|
||||
}
|
||||
function showDetail(on){ showPage(on?'detail':'list'); } // 旧调用兼容:明细路径行为不变
|
||||
function xfocus(t){ // 按标签类型路由打开方式(明细=det / 附件=openInq)
|
||||
if(t.kind==='inq') openInq(t.id,t.name);
|
||||
else det(t.id,t.name,t.kind);
|
||||
}
|
||||
function focusXT(i){ if(i===XACT || !XTABS[i]) return; xfocus(XTABS[i]); }
|
||||
function closeXT(i){
|
||||
haoPopClose(); // 明细页切走 = 浮层锚点没了,一并收(原 closeDlg 逻辑,公共功能4)
|
||||
const wasOn=(i===XACT);
|
||||
XTABS.splice(i,1);
|
||||
if(XACT>i) XACT--;
|
||||
else if(wasOn) XACT=-1;
|
||||
if(wasOn && XTABS.length){ // 关掉当前 → 激活右邻,没有右邻就最右(浏览器习惯)
|
||||
const j=Math.min(i,XTABS.length-1);
|
||||
xsave();
|
||||
xfocus(XTABS[j]);
|
||||
return;
|
||||
}
|
||||
if(!XTABS.length){ backToList(); return; } // 全关 = 主动结束,不再恢复
|
||||
renderXTabs(); xsave();
|
||||
}
|
||||
function backToList(){
|
||||
XACT=-1; showDetail(false); renderXTabs(); xsave();
|
||||
const el=document.querySelector(`.tab[data-kind="${XLAST}"]`);
|
||||
if(el) el.click(); // 走固定标签点击的原路:.on/KIND/筛选显隐/列表重载一次到位
|
||||
else load(1);
|
||||
}
|
||||
function xsave(){ try{
|
||||
if(XTABS.length) sessionStorage.setItem('admin_xtabs',
|
||||
JSON.stringify({tabs:XTABS, act:XACT, last:XLAST}));
|
||||
else sessionStorage.removeItem('admin_xtabs');
|
||||
}catch(e){} }
|
||||
/* 回到后台页时把上次开着的明细标签恢复出来(全关过=主动结束,不再恢复)。
|
||||
恢复 = 重建标签条 + 重开上次激活的那份(det 幂等:升级短路、接口现取)。 */
|
||||
(async function restoreDet(){
|
||||
try{
|
||||
const s = sessionStorage.getItem('admin_det');
|
||||
if(!s || KIND !== 'project') return;
|
||||
const o = JSON.parse(s);
|
||||
await det(o.id, o.name);
|
||||
const s=sessionStorage.getItem('admin_xtabs'); if(!s) return;
|
||||
const o=JSON.parse(s); if(!o.tabs || !o.tabs.length) return;
|
||||
o.tabs.forEach(t=>XTABS.push(t));
|
||||
XLAST=o.last||'project';
|
||||
renderXTabs();
|
||||
const a=(typeof o.act==='number' && o.act>=0 && o.act<XTABS.length)?o.act:XTABS.length-1;
|
||||
xfocus(XTABS[a]);
|
||||
}catch(e){}
|
||||
})();
|
||||
window.addEventListener('resize', ()=>{ if(XACT>=0){ const t=XTABS[XACT];
|
||||
showPage(t && t.kind==='inq' ? 'inq' : 'detail'); } });
|
||||
|
||||
async function loadTab(pid, fresh){
|
||||
document.querySelectorAll('#mask .tab').forEach(x=>x.classList.toggle('on',x.dataset.p===pid));
|
||||
document.querySelectorAll('#dtabs .tab').forEach(x=>x.classList.toggle('on',x.dataset.p===pid));
|
||||
const cg=document.getElementById('dcg'), th=document.getElementById('dth'), tb=document.getElementById('dtbd');
|
||||
if(KIND!=='project'){
|
||||
// 面板复位由 detLayout 统一负责(见其注释):价格明细 = 左目录树 + 右一张表
|
||||
@@ -1529,17 +1647,18 @@ function resetF(){fq.value='';fp.value='';fc.value='';fd.value='';setPeriod($('f
|
||||
['fq','ftotal_min','ftotal_max'].forEach(id=>{ const s=$(id)._cinSync; if(s) s(); });
|
||||
load(1)}
|
||||
|
||||
document.querySelectorAll('.tab').forEach(t=>t.onclick=()=>{
|
||||
document.querySelectorAll('.tab').forEach(x=>x.classList.remove('on'));
|
||||
document.querySelectorAll('.tab[data-kind]').forEach(t=>t.onclick=()=>{
|
||||
document.querySelectorAll('.tab[data-kind]').forEach(x=>x.classList.remove('on'));
|
||||
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)); // 列表取数期间挂进度条(快则不闪)
|
||||
});
|
||||
mask.onclick=e=>{ if(e.target===mask) closeDlg() };
|
||||
// 2026-10-13 主人定:切标签没出全数据前要有进度条 —— 走共享层 ldWrap(det() 进来的路径
|
||||
// 已有即时遮罩,ldWrap 检测到就只报阶段不接管;这里兜住「直接点标签」的路径)
|
||||
const TAB_STAGE={p0:'正在加载项目工料机…',p1:'正在计算组价不一致(同名同规格比对)…',
|
||||
p2:'正在计算类似清单分组(工程大要稍等)…',p3:'正在加载原数据(目录树+汇总卡)…'};
|
||||
document.querySelectorAll('#mask .tab').forEach(t=>t.onclick=()=>{
|
||||
document.querySelectorAll('#dtabs .tab').forEach(t=>t.onclick=()=>{
|
||||
ldWrap('', TAB_STAGE[t.dataset.p]||'正在加载…', ()=>loadTab(t.dataset.p));
|
||||
});
|
||||
|
||||
@@ -1586,6 +1705,7 @@ mkPeriod($('eper')); // 编辑(只读,只用于显示)
|
||||
关系:一个附件 ↔ 多条工料机;一条工料机 ↔ 一个附件(后端 lme_id 主键强制)。
|
||||
========================================================================= */
|
||||
let QBID=0, QFID=0, QLMES=[];
|
||||
let QTAB='lme', QBILLS=null; // 决策 152:右侧双页签(lme=项目工料机 / bill=类似清单,bills 懒加载)
|
||||
const qPost=(u,b)=>J(u,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(b||{})});
|
||||
|
||||
/** 项目列表「询价附件」列:按你的选择显示个数;0 个时显示灰色「上传」 */
|
||||
@@ -1638,63 +1758,142 @@ cinAttach($('ftotal_max'), () => load(1));
|
||||
const TPL_NAME = '信息价市场价导入模板.xlsx';
|
||||
function dlTpl(){ saveAs('/api/admin/price_template', TPL_NAME); }
|
||||
|
||||
/* 决策 152(主人确认):询价附件=顶部动态标签页(同决策 150 明细机制)。
|
||||
同项目重复点击=聚焦已开标签;× 关闭;内容 = 附件目录树 + 项目工料机/类似清单双页签。 */
|
||||
async function openInq(id,name){
|
||||
QBID=id; QFID=0; QLMES=[];
|
||||
$('qtitle').textContent='询价附件 · '+name;
|
||||
let i=XTABS.findIndex(t=>t.kind==='inq' && t.id===id);
|
||||
if(i<0){ XTABS.push({id:id, name:name, kind:'inq'}); i=XTABS.length-1; }
|
||||
XACT=i; renderXTabs(); showPage('inq'); xsave();
|
||||
QBID=id; QFID=0; QLMES=[]; QB_SIM=null; QBILLS=[]; QTAB='lme';
|
||||
document.querySelectorAll('.qtab').forEach(x=>x.classList.toggle('on',x.dataset.t==='lme'));
|
||||
$('qtitle').textContent='附件 · '+name;
|
||||
$('qkw').value=''; $('qmsg').textContent=''; $('qbmsg').textContent='';
|
||||
$('qmask').classList.add('on');
|
||||
await qLoad();
|
||||
}
|
||||
function closeInq(){ $('qmask').classList.remove('on'); load(PAGE); }
|
||||
|
||||
async function qLoad(){
|
||||
const [a,b]=await Promise.all([J(`/api/admin/batch/${QBID}/inq`),
|
||||
J(`/api/admin/batch/${QBID}/inq/lmes`)]);
|
||||
if(!a.ok){ $('qmsg').textContent='× '+a.msg; return; }
|
||||
QLMES=b.rows||[];
|
||||
$('qn').textContent=a.files.length;
|
||||
$('qlist').innerHTML = a.files.length
|
||||
? a.files.map(f=>`<div class="qitem${f.id===QFID?' on':''}" onclick="qSel(${f.id})">
|
||||
if(b.ok) QLMES=b.rows||[];
|
||||
// 附件目录树:根目录行 = 名称+数量,右侧挂「上传附件 / 删除选中」(决策 152 第 2 条)
|
||||
$('qlist').innerHTML =
|
||||
'<div class="rt"><span style="flex:1">📁 附件目录('+a.files.length+')</span>'
|
||||
+ '<button class="btn pri" style="padding:2px 8px" onclick="qfile.click()">上传附件</button>'
|
||||
+ '<button class="btn danger" style="padding:2px 8px" onclick="qDel()">删除选中</button></div>'
|
||||
+ (a.files.length
|
||||
? a.files.map(f=>`<div class="qitem${f.id===QFID?' on':''}" data-fid="${f.id}" onclick="qSel(${f.id})">
|
||||
<span class="nm"><a href="/api/admin/inq/file/${f.id}" data-n="${esc(f.name)}"
|
||||
onclick="event.stopPropagation();return dlInq(${f.id}, this.getAttribute('data-n'))"
|
||||
title="另存为(自己选保存位置)">${esc(f.name)}</a><span class="qbadge">${f.n} 条</span>
|
||||
<div class="tip">${(f.size/1048576).toFixed(2)} MB · ${esc(f.uploaded_at||'')}</div></span>
|
||||
<span class="qtag">${esc((f.ext||'').replace('.','').toUpperCase())}</span></div>`).join('')
|
||||
: '<div class="tip" style="padding:12px">还没上传。点上面「选择文件…」</div>';
|
||||
qRender();
|
||||
: '<div class="tip" style="padding:12px">还没有附件。点右上「上传附件」。</div>');
|
||||
if(QTAB==='lme') qRender(); else await qRenderBill();
|
||||
}
|
||||
function qSel(fid){ QFID=fid; qLoad(); }
|
||||
|
||||
function qVisible(){
|
||||
const kw=($('qkw').value||'').trim().toLowerCase();
|
||||
return kw ? QLMES.filter(r=>(r.name+' '+r.spec+' '+r.code).toLowerCase().includes(kw)) : QLMES;
|
||||
function qSel(fid){
|
||||
// 决策 153①:本地选中(不重新拉接口)——此前每次点击都 qLoad() 重取三接口,故而卡顿
|
||||
QFID=fid;
|
||||
document.querySelectorAll('#qlist .qitem').forEach(x=>x.classList.toggle('on', +x.dataset.fid===fid));
|
||||
}
|
||||
function qChecked(){ return [...$('qtb').querySelectorAll('input[data-id]:checked')].map(x=>+x.dataset.id); }
|
||||
function qAll(cb){ $('qtb').querySelectorAll('input[data-id]').forEach(x=>{x.checked=cb.checked}); }
|
||||
|
||||
async function qTab(t){
|
||||
if(QTAB===t) return;
|
||||
QTAB=t;
|
||||
document.querySelectorAll('.qtab').forEach(x=>x.classList.toggle('on',x.dataset.t===t));
|
||||
$('qlmew').style.display = t==='lme' ? '' : 'none';
|
||||
$('qbw').style.display = t==='bill' ? '' : 'none';
|
||||
$('qkw').value='';
|
||||
if(t==='lme') qRender(); else await qRenderBill();
|
||||
}
|
||||
|
||||
/* 决策 153⑦:搜索关键词黄色底显示(对转义后的文本逐词高亮) */
|
||||
function qhl(s){
|
||||
s = esc(s==null?'':String(s));
|
||||
const kw=($('qkw').value||'').trim();
|
||||
if(!kw) return s;
|
||||
return kw.split(/\s+/).filter(Boolean).reduce((acc,t)=>{
|
||||
try{ return acc.replace(new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,'\\$&'),'gi'),
|
||||
m=>'<mark class="qhl">'+m+'</mark>'); }
|
||||
catch(e){ return acc; }
|
||||
}, s);
|
||||
}
|
||||
|
||||
/* 决策 154①:搜索输入防抖(工料机上千行逐键重建表格导致删字卡顿) */
|
||||
let _qT=null;
|
||||
function qSearchSoon(){ clearTimeout(_qT); _qT=setTimeout(()=>{ QTAB==='lme'?qRender():qFilterBill(); },160); }
|
||||
|
||||
/* 工料机页签:列定义(复选框+编码固定,名称/规格伸缩)——决策 154③ 列宽拖动同工作台项目工料机 */
|
||||
const QCOLS_LME=[['',36,'c','F'],['编码',110,'c','F'],['名称',220,'l'],['规格型号',200,'l'],
|
||||
['单位',56,'c','F'],['数量',90,'r','F'],['除税价',100,'r','F'],['含税价',100,'r','F']];
|
||||
function qRender(){
|
||||
const rows=qVisible();
|
||||
$('qtb').innerHTML = '<thead><tr>'
|
||||
+ '<th style="width:36px"></th><th style="width:104px">编码</th><th>名称</th>'
|
||||
+ '<th style="width:150px">规格型号</th><th style="width:52px">单位</th>'
|
||||
+ '<th style="width:82px">数量</th><th style="width:88px">除税价</th>'
|
||||
+ '</tr></thead><tbody>'
|
||||
+ (rows.length ? rows.map(r=>{
|
||||
const bd=!!r.file_id;
|
||||
return `<tr class="${bd?'bound':''}">
|
||||
<td><input type="checkbox" data-id="${r.id}"></td>
|
||||
<td>${esc(r.code||'—')}</td>
|
||||
<td>${esc(r.name)}${bd?`<span class="qtag" style="margin-left:6px">已绑:${esc((r.file_name||'其他').slice(0,18))}</span>`:''}</td>
|
||||
<td>${esc(r.spec||'—')}</td><td>${esc(r.unit||'—')}</td>
|
||||
<td style="text-align:right">${num(r.qty,3)}</td>
|
||||
<td style="text-align:right">${num(r.price)}</td></tr>`;
|
||||
}).join('')
|
||||
: '<tr><td colspan="7" class="tip" style="text-align:center;padding:16px">没有工料机</td></tr>')
|
||||
+ '</tbody>';
|
||||
$('qc').textContent = rows.length===QLMES.length ? `共 ${QLMES.length} 条`
|
||||
: `筛出 ${rows.length} / 共 ${QLMES.length} 条`;
|
||||
const kw=($('qkw').value||'').trim().toLowerCase();
|
||||
const rows = kw ? QLMES.filter(r=>(r.name+' '+r.spec+' '+r.code).toLowerCase().includes(kw)) : QLMES;
|
||||
$('qthl').innerHTML = '<tr>' + QCOLS_LME.map((c,i)=> i===0
|
||||
? '<th class="c"></th>'
|
||||
: '<th class="'+(c[2]||'c')+'" title="左右拖动调宽">'+esc(c[0])+'<span class="rs"></span></th>').join('') + '</tr>';
|
||||
$('qtbl').innerHTML = rows.length ? rows.map(r=>{
|
||||
const bd=!!r.file_id;
|
||||
const tag=bd?`<span class="qtag" style="margin-left:6px">已绑:${qhl((r.file_name||'其他').slice(0,18))}</span>`:'';
|
||||
return `<tr class="${bd?'bound':''}"><td class="c"><input type="checkbox" data-id="${r.id}"></td>`
|
||||
+ `<td class="c">${qhl(r.code||'—')}</td>`
|
||||
+ `<td>${qhl(r.name)}${tag}</td><td>${qhl(r.spec||'—')}</td><td class="c">${esc(r.unit||'—')}</td>`
|
||||
+ `<td style="text-align:right">${num(r.qty,3)}</td>`
|
||||
+ `<td style="text-align:right">${num(r.price)}</td><td style="text-align:right">${num(r.price_tax)}</td></tr>`;
|
||||
}).join('')
|
||||
: '<tr><td colspan="8" class="tip" style="text-align:center;padding:16px">没有工料机</td></tr>';
|
||||
$('qc').textContent = '共 ' + rows.length + ' 条' + (kw ? '(筛选自 ' + QLMES.length + ')' : '');
|
||||
$('qcgl').innerHTML = colgHTML(QCOLS_LME);
|
||||
flexFit($('qtb'), QCOLS_LME); // 公共拖动器:固定+伸缩、拖动只动被拖列、窗口缩放自动重贴
|
||||
}
|
||||
|
||||
/* 类似清单页签(决策 153③):与后台明细 p2 同一份共享代码 —— /similar 同源取数 +
|
||||
renderGroups/billHeadHTML/grpTreeBind 同源渲染(含左组目录树),只多一列复选框勾选绑附件 */
|
||||
async function qRenderBill(){
|
||||
if(!QB_SIM){
|
||||
$('qtbb').innerHTML='<tr><td class="tip" style="text-align:center;padding:16px">正在计算类似清单分组(工程大要稍等)…</td></tr>';
|
||||
const [s,bl]=await Promise.all([J(`/api/admin/batch/${QBID}/similar`),
|
||||
J(`/api/admin/batch/${QBID}/inq/bills`)]);
|
||||
// ⚠️ /similar 成功响应没有 ok 字段({total,groups,extra,group_mode}),按 groups 判成功
|
||||
QB_SIM = (s && Array.isArray(s.groups)) ? s : {groups:[],extra:[]};
|
||||
QBILLS = bl.ok ? (bl.rows||[]) : [];
|
||||
QBINDS = {};
|
||||
QBILLS.forEach(r=>{ if(r.file_id) QBINDS[r.id]=r.file_name||'附件'; });
|
||||
}
|
||||
// 绑定信息写进行数组备注位(后台 noWB 已剔除取消采纳列,备注列纯文字展示)
|
||||
const enr = JSON.parse(JSON.stringify(QB_SIM));
|
||||
(enr.groups||[]).concat(enr.extra||[]).forEach(g=>(g.rows||[]).forEach(r=>{
|
||||
if(QBINDS[r[0]]) r[10]='已绑:'+QBINDS[r[0]];
|
||||
}));
|
||||
BILL_SORT={k:-1,dir:1};
|
||||
$('qthb').innerHTML = billHeadHTML({checkbox:true, backend:true});
|
||||
$('qtbb').innerHTML = renderGroups(enr,'similar',{backend:true,checkbox:true});
|
||||
grpTreeBind($('qsimtree'),'qtbb',enr);
|
||||
$('qcgb').innerHTML = colgHTML(qBindCols()); sumw($('qgt')); colwApply($('qgt'));
|
||||
}
|
||||
/* 决策 154④:类似清单默认列宽——名称收窄(210→150)、项目特征加宽(260→330),复选框列固定 36;
|
||||
表格走 colg(colgHTML+sumw+colwApply)→ 公共拖动器,拖动效果与后台类似清单一致 */
|
||||
function qBindCols(){
|
||||
return [['',36,'c','F']].concat(noWB(COLS.bill).map(c=>{
|
||||
if(c[0]==='名称') return ['名称',150,'l'];
|
||||
if(c[0]==='项目特征') return ['项目特征',330,'l','attr'];
|
||||
return c;
|
||||
}));
|
||||
}
|
||||
/* 决策 154②:类似清单搜索 = 行级过滤(组头保留),不重建共享组表 */
|
||||
function qFilterBill(){
|
||||
const kw=($('qkw').value||'').trim().toLowerCase();
|
||||
document.querySelectorAll('#qtbb tr[data-bid]').forEach(tr=>{
|
||||
tr.style.display = (!kw || tr.textContent.toLowerCase().includes(kw)) ? '' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
function qChecked(){ return QTAB==='lme'
|
||||
? [...$('qtbl').querySelectorAll('input[data-id]:checked')].map(x=>+x.dataset.id)
|
||||
: [...$('qtbb').querySelectorAll('input.qbindck:checked')].map(x=>+x.dataset.id); }
|
||||
function qAll(cb){ (QTAB==='lme'?$('qtbl'):$('qtbb')).querySelectorAll('input[type=checkbox]')
|
||||
.forEach(x=>{x.checked=cb.checked}); }
|
||||
|
||||
$('qfile').onchange=async function(){
|
||||
const f=this.files&&this.files[0]; if(!f) return;
|
||||
const bad=overMaxMsg(f); // 同上:超限本地先挡
|
||||
@@ -1706,31 +1905,63 @@ $('qfile').onchange=async function(){
|
||||
if(r.ok){ QFID=r.id||QFID; await qLoad(); }
|
||||
};
|
||||
|
||||
/* 决策 153②:附件工作区左右拖宽(分隔条 + localStorage 记忆,默认 40%) */
|
||||
(function(){
|
||||
const sp=document.getElementById('qsplit');
|
||||
const left=document.querySelector('#qpage .qleft');
|
||||
if(!sp||!left) return;
|
||||
try{ const w=localStorage.getItem('admin_inq_split'); left.style.width = w ? (+w)+'%' : '40%'; }
|
||||
catch(e){ left.style.width='40%'; }
|
||||
let dragging=false;
|
||||
sp.addEventListener('mousedown', e=>{ dragging=true; e.preventDefault(); document.body.style.cursor='col-resize'; });
|
||||
window.addEventListener('mousemove', e=>{
|
||||
if(!dragging) return;
|
||||
const wrap=document.querySelector('#qpage .qwrap');
|
||||
const r=wrap.getBoundingClientRect();
|
||||
if(!r.width) return;
|
||||
const pct=Math.min(70, Math.max(20, (e.clientX-r.left)/r.width*100));
|
||||
left.style.width=pct+'%';
|
||||
});
|
||||
window.addEventListener('mouseup', ()=>{
|
||||
if(!dragging) return;
|
||||
dragging=false; document.body.style.cursor='';
|
||||
try{ localStorage.setItem('admin_inq_split', parseFloat(left.style.width)); }catch(e){}
|
||||
});
|
||||
})();
|
||||
|
||||
async function qBind(){
|
||||
if(!QFID){ alert('请先在左边点选一个附件。'); return; }
|
||||
const ids=qChecked();
|
||||
if(!ids.length){ alert('右边还没有勾选工料机。'); return; }
|
||||
if(!ids.length){ alert('右边还没有勾选。'); return; }
|
||||
const isLme=QTAB==='lme';
|
||||
const src=isLme?QLMES:(QBILLS||[]);
|
||||
// ★ 允许改绑,但凡涉及"从别的附件挪过来"必须二次确认,把条数说清楚
|
||||
const by={}; ids.forEach(id=>{
|
||||
const r=QLMES.find(x=>x.id===id);
|
||||
const r=src.find(x=>x.id===id);
|
||||
if(r && r.file_id && r.file_id!==QFID){ const k=r.file_name||'其他附件'; by[k]=(by[k]||0)+1; }
|
||||
});
|
||||
const mv=Object.values(by).reduce((a,b)=>a+b,0);
|
||||
if(mv && !confirm(`勾选的 ${ids.length} 条里,有 ${mv} 条已经绑在别的附件上:\n `
|
||||
+ Object.entries(by).map(([k,v])=>`${v} 条原绑《${k}》`).join('、')
|
||||
+ `\n\n继续 = 把它们改绑到当前选中的附件(一条工料机只会对应一个附件)。\n确定吗?`)) return;
|
||||
const r=await qPost(`/api/admin/batch/${QBID}/inq/bind`,{file_id:QFID,lme_ids:ids});
|
||||
+ `\n\n继续 = 把它们改绑到当前选中的附件(一行只会对应一个附件)。\n确定吗?`)) return;
|
||||
const body={file_id:QFID}; body[isLme?'lme_ids':'bill_ids']=ids;
|
||||
const r=await qPost(`/api/admin/batch/${QBID}/inq/bind`,body);
|
||||
$('qbmsg').textContent=(r.ok?'✓ ':'× ')+r.msg;
|
||||
if(r.ok) await qLoad();
|
||||
if(!r.ok) return;
|
||||
if(isLme) await qLoad();
|
||||
else { QB_SIM=null; await qRenderBill(); } // 绑定态变了:附件分组视图重取绑定刷新备注列
|
||||
}
|
||||
|
||||
async function qUnbind(){
|
||||
const ids=qChecked();
|
||||
if(!ids.length){ alert('请勾选要解绑的工料机。'); return; }
|
||||
if(!confirm(`把这 ${ids.length} 条工料机从附件上解绑?\n(附件保留、工料机保留,只是断开关系)`)) return;
|
||||
const r=await qPost(`/api/admin/batch/${QBID}/inq/unbind`,{lme_ids:ids});
|
||||
if(!ids.length){ alert('请勾选要解绑的行。'); return; }
|
||||
if(!confirm(`把这 ${ids.length} 行从附件上解绑?\n(附件保留、数据保留,只是断开关系)`)) return;
|
||||
const body={}; body[QTAB==='lme'?'lme_ids':'bill_ids']=ids;
|
||||
const r=await qPost(`/api/admin/batch/${QBID}/inq/unbind`,body);
|
||||
$('qbmsg').textContent=(r.ok?'✓ ':'× ')+r.msg;
|
||||
if(r.ok) await qLoad();
|
||||
if(!r.ok) return;
|
||||
if(QTAB==='lme') await qLoad();
|
||||
else { QB_SIM=null; await qRenderBill(); }
|
||||
}
|
||||
|
||||
async function qDel(){
|
||||
@@ -1742,7 +1973,6 @@ async function qDel(){
|
||||
$('qmsg').textContent=(r.ok?'✓ ':'× ')+r.msg;
|
||||
if(r.ok){ QFID=0; await qLoad(); }
|
||||
}
|
||||
$('qmask').onclick=e=>{ if(e.target===$('qmask')) closeInq() };
|
||||
|
||||
|
||||
/* ============ 数据源面板(地区 / 发布单位 / 建设单位)====================
|
||||
@@ -2017,6 +2247,6 @@ dmask.onclick = e => { if(e.target===dmask) closeDict() };
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script>licMount('.tabs');</script><!-- 统一设置窗口+到期预警(决策 31,实现在 common.js) -->
|
||||
<script>licMount('.tabs', {settings:false});</script><!-- 统一设置+到期预警(决策 31);决策 153⑥:后台不挂「设置」,共用工作台的;「⚙ 字典」保留 -->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -125,7 +125,7 @@ const COLS = {
|
||||
// 标记 'F' = 固定宽列;无标记 = 伸缩列(名称/规格型号),平分容器剩余宽度
|
||||
// —— 表宽始终贴合容器撑满屏幕,见 flexFit() / flexRedistribute()。
|
||||
lme: [['序号', 52, 'c', 'F'], ['编码', 120, 'c', 'F'], ['名称', 220, 'l'], ['规格型号', 200, 'l'],
|
||||
['单位', 56, 'c', 'F'], ['数量', 90, 'r', 'F'], ['除税编制价', 110, 'r', 'F'], ['税率', 70, 'r', 'F'],
|
||||
['单位', 56, 'c', 'F'], ['数量', 135, 'r', 'F'], ['除税编制价', 110, 'r', 'F'], ['税率', 70, 'r', 'F'], // 决策 145:数量列宽 ×1.5(90→135)
|
||||
['含税编制价', 110, 'r', 'F'], ['取消采纳', 76, 'c', 'F', 'ns', 'wb'], ['备注', 160, 'l', '', '', 'wb']]
|
||||
};
|
||||
/* 后台列数组 = 工作台列剔除 wb 列(派生,不另维护)。
|
||||
@@ -196,9 +196,11 @@ let BILL_SORT = { k: -1, dir: 1 };
|
||||
const BILL_ATTR_IDX = COLS.bill.findIndex(c => c[3] === 'attr'); // 项目特征列(显示下标)
|
||||
const BILL_SORT_DS = { 1: 8, 2: 1, 4: 9, 5: 2, 6: 3, 7: 4, 8: 5, 9: 6, 10: 7 };
|
||||
const BILL_SORT_NUM = new Set([8, 5, 6, 7]); // 序号/工程量/单价/合价 按数值比
|
||||
function billHeadHTML() {
|
||||
return '<tr>' + billCols().map((c, i) => {
|
||||
const can = BILL_SORT_DS[i] != null;
|
||||
function billHeadHTML(opts) {
|
||||
const cols = billColsO(opts);
|
||||
const off = (opts && opts.checkbox) ? 1 : 0;
|
||||
return '<tr>' + cols.map((c, i) => {
|
||||
const can = BILL_SORT_DS[i - off] != null;
|
||||
const mark = (can && BILL_SORT.k === i) ? (BILL_SORT.dir > 0 ? ' ▲' : ' ▼') : '';
|
||||
const click = can
|
||||
? ' onclick="if(event.target.closest(\'.rs\'))return;billSort(this,' + i + ')"'
|
||||
@@ -212,7 +214,8 @@ function billSort(th, i) {
|
||||
else { BILL_SORT.k = i; BILL_SORT.dir = 1; }
|
||||
const tb = th.closest('table');
|
||||
billSortDOM(tb);
|
||||
th.closest('thead').innerHTML = billHeadHTML(); // 重画 ▲/▼(colgroup 不动,列宽保持)
|
||||
const ck = tb && tb.dataset.ck === '1'; // 决策 153③:附件复选框表重画表头带选项
|
||||
th.closest('thead').innerHTML = billHeadHTML(ck ? { checkbox: true, backend: tb.dataset.bk === '1' } : undefined); // 重画 ▲/▼(colgroup 不动,列宽保持)
|
||||
}
|
||||
/* 组 key('bg3'/'bx0'/'ag2')→ 数据组。原先内联在 tgGrp 里,组内排序也要用,收编成一份。 */
|
||||
function _grpByKey(key) {
|
||||
@@ -225,7 +228,8 @@ function _grpByKey(key) {
|
||||
}
|
||||
function billSortDOM(tb) {
|
||||
if (!tb || BILL_SORT.k < 0) return;
|
||||
const rk = BILL_SORT_DS[BILL_SORT.k];
|
||||
const off = billCkOff(tb); // 决策 153③:复选框列偏移
|
||||
const rk = BILL_SORT_DS[BILL_SORT.k - off];
|
||||
const tbody = tb && tb.tBodies[0];
|
||||
if (rk == null || !tbody) return;
|
||||
tbody.querySelectorAll('tr.grp[data-grp],tr.grp2[data-grp]').forEach(hdr => {
|
||||
@@ -640,6 +644,20 @@ function billCols() {
|
||||
const bk = (typeof WB_OPTS !== 'undefined') && WB_OPTS && WB_OPTS.backend;
|
||||
return bk ? noWB(COLS.bill) : COLS.bill;
|
||||
}
|
||||
/* 决策 153③:按渲染选项取列数组(checkbox=前置复选框列,供附件动态标签页勾选绑附件;
|
||||
backend=批次侧剔除 wb 列)。既有调用 billHeadHTML()/billCols() 行为不变。 */
|
||||
function billColsO(opts) {
|
||||
opts = opts || {};
|
||||
const base = opts.backend ? noWB(COLS.bill) : billCols();
|
||||
return opts.checkbox ? [['', 36, 'c', 'F']].concat(base) : base.slice();
|
||||
}
|
||||
/* 复选框列导致的显示下标偏移:优先读渲染时存下的 GRP_DATA.opts,其次表上的 data-ck 标记 */
|
||||
function billCkOff(tb) {
|
||||
if (tb && tb.dataset && tb.dataset.ck === '1') return 1;
|
||||
if (typeof GRP_DATA !== 'undefined' && GRP_DATA && GRP_DATA.opts && GRP_DATA.opts.checkbox) return 1;
|
||||
if (typeof WB_OPTS !== 'undefined' && WB_OPTS && WB_OPTS.checkbox) return 1;
|
||||
return 0;
|
||||
}
|
||||
const CB_LAST = () => billCols().length - 1, CB_TOTAL = () => billCols().length - 2;
|
||||
|
||||
function grpTitle(tag, g) {
|
||||
@@ -657,6 +675,7 @@ function billTR(r, grp, hide, opts) {
|
||||
const cls = (r[12] ? ' xtdel' : '') + (r[11] ? ' xnew' : '');
|
||||
// data-bid:组内排序按它对回 GRP_DATA 里的数据行(billSortDOM);右键菜单也按它定位清单
|
||||
return '<tr class="' + cls + '" data-grp="' + grp + '" data-bid="' + r[0] + '"' + st + clk + ' data-name="' + esc(r[2] || '') + '" data-price="' + esc(pr) + '">'
|
||||
+ (opts.checkbox ? '<td class="c"><input type="checkbox" class="qbindck" data-id="' + r[0] + '" onclick="event.stopPropagation()"></td>' : '')
|
||||
+ '<td class="tg"><span class="tog" title="展开/收起该清单下的定额" onclick="event.stopPropagation();tgNorm(this,' + r[0] + ')">+</span></td>'
|
||||
+ '<td class="c">' + ((r[8] == null || r[8] === '') ? '—' : esc(r[8])) + '</td>'
|
||||
+ '<td class="c">' + ell(r[1], '—') + '</td>'
|
||||
@@ -734,9 +753,10 @@ function tgGrp(key, tr) {
|
||||
let GRP_DATA = null;
|
||||
function grpRowsHTML(g, key, opts) {
|
||||
let rows = g.rows || [];
|
||||
// 组内排序激活时,懒展开的组也按同一排序出(2026-10-10 主人定)
|
||||
// 组内排序激活时,懒展开的组也按同一排序出(2026-10-10 主人定);复选框表偏移同步(决策 153③)
|
||||
if (BILL_SORT.k >= 0) {
|
||||
const rk = BILL_SORT_DS[BILL_SORT.k];
|
||||
const off = (opts && opts.checkbox) ? 1 : billCkOff(null);
|
||||
const rk = BILL_SORT_DS[BILL_SORT.k - off];
|
||||
if (rk != null) rows = sortRows(rows, rk, BILL_SORT.dir, BILL_SORT_NUM);
|
||||
}
|
||||
return rows.map(r => billTR(r, key, false, opts)).join('');
|
||||
@@ -832,13 +852,14 @@ function grpTreeBind(box, tbId, d, opt) {
|
||||
grpTreeRender(box, d, key => {
|
||||
const tb = document.getElementById(tbId);
|
||||
if (!tb) return;
|
||||
if (key === 'all') { tb.innerHTML = renderGroups(d, kind); return; }
|
||||
const o = (typeof GRP_DATA !== 'undefined' && GRP_DATA && GRP_DATA.opts) || undefined; // 决策 153③:左树重画保留渲染选项(checkbox/backend)
|
||||
if (key === 'all') { tb.innerHTML = renderGroups(d, kind, o); return; }
|
||||
const i = +key.slice(2);
|
||||
const g = key.charAt(1) === 'g' ? (d.groups || [])[i] : (d.extra || [])[i];
|
||||
if (!g) return;
|
||||
const lbl = key.charAt(1) === 'g' ? ('第 ' + (i + 1) + ' 组')
|
||||
: ('第 ' + ((d.groups || []).length + i + 1) + ' 组');
|
||||
tb.innerHTML = renderGroups({ groups: [g], labels: [lbl] }, kind);
|
||||
tb.innerHTML = renderGroups({ groups: [g], labels: [lbl] }, kind, o);
|
||||
// 决策 90(2026-10-17):点组=只显示该组时,列宽整体缩到贴住容器——右边不再有下滑条
|
||||
if (typeof fitGroupWidth === 'function') fitGroupWidth(tbId);
|
||||
}, { kind: kind, rootName: opt.rootName });
|
||||
@@ -856,17 +877,20 @@ function renderLme(rows, opts) {
|
||||
const click = opts.rowClick
|
||||
? (id => ' onclick="' + opts.rowClick + "('lme'," + id + ',this)"')
|
||||
: (() => '');
|
||||
// 决策 147:opts.rowClass 行类(原数据卡挂 lmerow 接双击改价)、opts.subSet 台班/配合比三格 title
|
||||
const subT = (opts.subSet && opts.subSet.size)
|
||||
? (code => (opts.subSet.has(code) ? ' title="' + RAW_LME_SUB_TIP + '"' : '')) : null;
|
||||
return (rows || []).map((r, i) =>
|
||||
'<tr' + click(r[0]) + ' data-id="' + r[0] + '" data-name="' + esc(r[2] || '') + '" data-price="' + esc(r[6] == null ? '' : r[6]) + '">'
|
||||
'<tr class="' + (opts.rowClass || '') + '"' + click(r[0]) + ' data-id="' + r[0] + '" data-name="' + esc(r[2] || '') + '" data-price="' + esc(r[6] == null ? '' : r[6]) + '">'
|
||||
+ '<td class="c">' + (i + 1) + '</td>'
|
||||
+ '<td class="c">' + ell(r[1], '—') + '</td>'
|
||||
+ '<td>' + ell(r[2], '—') + '</td>'
|
||||
+ '<td>' + ell(r[3], '—') + '</td>'
|
||||
+ '<td class="c u">' + esc(r[4] || '—') + '</td>'
|
||||
+ '<td class="r">' + num(r[5], 3) + '</td>'
|
||||
+ '<td class="r">' + num(r[6]) + '</td>'
|
||||
+ '<td class="r">' + num(r[7], 2) + '</td>'
|
||||
+ '<td class="r">' + num(r[8]) + '</td>'
|
||||
+ '<td class="r"' + (subT ? subT(r[1]) : '') + '>' + num(r[6]) + '</td>'
|
||||
+ '<td class="r"' + (subT ? subT(r[1]) : '') + '>' + num(r[7], 2) + '</td>'
|
||||
+ '<td class="r"' + (subT ? subT(r[1]) : '') + '>' + num(r[8]) + '</td>'
|
||||
+ (opts.backend ? '' : '<td class="c">' + lmeAdoptCellHTML(r) + '</td>'
|
||||
+ '<td title="' + esc(r[10] || '') + '">' + esc(r[10] || '') + '</td>')
|
||||
+ '</tr>').join('');
|
||||
@@ -1048,8 +1072,25 @@ function rawLmeSort(k) {
|
||||
function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
rows = rows || [];
|
||||
RV_LME_ROWS = rows; RV_LME_TIP = tip || ''; RV_LME_QL = qtyLabel || '';
|
||||
RV_LME_IDS = (extra && extra.ids) || null; // 项目级带行 id(行级改价定位用);单位级无=只读
|
||||
const subSet = new Set((extra && extra.sub) || []); // 带子级组成的编码集 → 三格挂 title 提示
|
||||
if (!RAW_LME_KIND) {
|
||||
/* 决策 147(2026-10-21 主人定):项目级卡与「项目工料机」**同码同形** —— renderLme 唯一渲染、
|
||||
COLS.lme 同列宽(数量135/备注160)、同排序同点击同双击改价,改一处=改两处;
|
||||
数据集差异按主人原文保留:项目工料机走单位过滤,此处全量(含台班/配合比)。
|
||||
列头数量名沿用决策 40 的「总数量」(qtyLabel 传入);单位工程级卡走下方原路径不动。 */
|
||||
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);
|
||||
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,
|
||||
rowClick: (typeof window !== 'undefined' && window.rawLmePick) ? 'rawLmePick' : '',
|
||||
backend: backend });
|
||||
return rawTbl(cols.map(c => c[1]), cols.map(c => [c[0], c[2]]),
|
||||
body || '<tr><td class="empty">没有工料机数据</td></tr>', null,
|
||||
{ cur: RV_LME_SORT.k, dir: RV_LME_SORT.dir, fn: 'rawLmeSort' }); // 决策 147:表头排序由 rawTbl 统一装饰(与项目工料机同款点击)
|
||||
}
|
||||
RV_LME_IDS = (extra && extra.ids) || null; // 单位级无=只读(项目级 id 已在行首位)
|
||||
// 视图列 = [序号, 编码, 名称, 规格, 类别?, 单位, 消耗量, 除税编制价, 税率, 含税编制价];
|
||||
// DS = 各视图列对应的数据下标(序号列无;类别列在 RAW_LME_KIND=0 时既不显示也不占视图下标)。
|
||||
// O2V = 原始列下标→视图下标:rawTbl 表头 onclick 传的是 cols 原始下标(common.js rawTbl),
|
||||
@@ -1075,6 +1116,7 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
const subT = subSet.has(r[0] || '') ? ' title="' + RAW_LME_SUB_TIP + '"' : '';
|
||||
// 2026-10-13 主人定:加「序号」列(视图行号,随排序重排)
|
||||
return '<tr class="lmerow"' + (lid != null ? ' data-lmeid="' + esc(lid) + '"' : '')
|
||||
+ (lid != null && window.rawLmePick ? ' data-name="' + esc(r[1] || '') + '" data-price="' + esc(r[6] == null ? '' : r[6]) + '" onclick="rawLmePick(this)"' : '') // 决策 142:项目级行接历史对比框(后台未定义 rawLmePick 则不挂)
|
||||
+ '><td class="c">' + (i + 1) + '</td><td class="c">' + ell(r[0], '—') + '</td><td class="l">' + ell(r[1], '—') + '</td>'
|
||||
+ '<td class="l">' + ell(r[2], '—') + '</td>' + kind
|
||||
+ '<td class="c u">' + esc(r[3] || '—') + '</td><td class="r">' + r3(r[5]) + '</td>'
|
||||
@@ -2300,7 +2342,7 @@ function licEnsureStyle() {
|
||||
'.btn.lic-warn{color:#b02a2a;border-color:#e4b6b6;background:#fdf3f3;font-weight:600}';
|
||||
document.head.appendChild(st);
|
||||
}
|
||||
function licMount(sel) {
|
||||
function licMount(sel, opts) {
|
||||
const host = document.querySelector(sel);
|
||||
if (!host || document.getElementById('licWarn')) return;
|
||||
licEnsureStyle();
|
||||
@@ -2311,7 +2353,8 @@ function licMount(sel) {
|
||||
btn.className = 'btn'; btn.textContent = '设置'; btn.setAttribute('data-i18n','btn.settings');
|
||||
btn.title = '授权状态 / 激活 / 续费提示(后续设置项统一收这里)';
|
||||
btn.onclick = licDlg;
|
||||
host.appendChild(warn); host.appendChild(btn);
|
||||
host.appendChild(warn);
|
||||
if (!opts || opts.settings !== false) host.appendChild(btn); // 决策 153⑥:后台不挂「设置」,共用工作台的
|
||||
if (typeof wbApplyLang === 'function') wbApplyLang(); // 晚于首轮回填注入,补一次语言套用
|
||||
licBannerTick();
|
||||
setInterval(licBannerTick, 10 * 60 * 1000);
|
||||
@@ -2770,6 +2813,7 @@ const APP_I18N = {
|
||||
'全部': '全部', '精确 + 次精确 + 字集': '精確 + 次精確 + 字集',
|
||||
'只看精确': '只看精確', '全部(含模糊)': '全部(含模糊)', '默认': '默認',
|
||||
'低→高': '低→高', '高→低': '高→低', '有': '有', '无': '無', '工程工料机': '工程工料機',
|
||||
'本项目': '本項目',
|
||||
'项目名称 / 文件名关键字': '項目名稱 / 文件名關鍵字',
|
||||
'选文件后自动带出文件名,可改': '選文件後自動帶出文件名,可改',
|
||||
'点这里选起~止(同月就选同一个)': '點這裡選起~止(同月就選同一個)',
|
||||
@@ -2883,6 +2927,7 @@ const APP_I18N = {
|
||||
'全部': 'All', '精确 + 次精确 + 字集': 'Exact + Near + Charset',
|
||||
'只看精确': 'Exact only', '全部(含模糊)': 'All (incl. fuzzy)', '默认': 'Default',
|
||||
'低→高': 'Low→High', '高→低': 'High→Low', '有': 'Yes', '无': 'No',
|
||||
'本项目': 'This Project', '是': 'Yes', '否': 'No',
|
||||
'工程工料机': 'Project L&M',
|
||||
'项目名称 / 文件名关键字': 'Project name / file name keyword',
|
||||
'选文件后自动带出文件名,可改': 'Auto-filled from file name, editable',
|
||||
@@ -3146,19 +3191,19 @@ function appWatch() {
|
||||
const WB_I18N = {
|
||||
'zh-CN': {
|
||||
'tab.p3': '原数据', 'tab.p2': '类似清单', 'tab.p1': '组价不一致清单', 'tab.p0': '项目工料机',
|
||||
'btn.cfg': '分组&过滤', 'btn.admin': '后台管理', 'btn.export': '导出', 'btn.inq': '询价附件',
|
||||
'btn.cfg': '分组&过滤', 'btn.admin': '后台管理', 'btn.export': '导出', 'btn.inq': '附件',
|
||||
'btn.recent': '最近审核', 'btn.open': '打开项目', 'btn.settings': '设置',
|
||||
'lv.group': '分组', 'lv.bill': '清单', 'lv.det': '定额', 'lv.defw': '默认列宽', 'lk.reload': '⟳ 重载'
|
||||
},
|
||||
'zh-TW': {
|
||||
'tab.p3': '原數據', 'tab.p2': '類似清單', 'tab.p1': '組價不一致清單', 'tab.p0': '項目工料機',
|
||||
'btn.cfg': '分組&過濾', 'btn.admin': '後台管理', 'btn.export': '導出', 'btn.inq': '詢價附件',
|
||||
'btn.cfg': '分組&過濾', 'btn.admin': '後台管理', 'btn.export': '導出', 'btn.inq': '附件',
|
||||
'btn.recent': '最近審核', 'btn.open': '打開項目', 'btn.settings': '設置',
|
||||
'lv.group': '分組', 'lv.bill': '清單', 'lv.det': '定額', 'lv.defw': '默認列寬', 'lk.reload': '⟳ 重載'
|
||||
},
|
||||
'en': {
|
||||
'tab.p3': 'Raw Data', 'tab.p2': 'Similar Bills', 'tab.p1': 'Price Mismatch', 'tab.p0': 'L&M Summary',
|
||||
'btn.cfg': 'Group&Filter', 'btn.admin': 'Admin', 'btn.export': 'Export', 'btn.inq': 'Inquiry Files',
|
||||
'btn.cfg': 'Group&Filter', 'btn.admin': 'Admin', 'btn.export': 'Export', 'btn.inq': 'Attachments',
|
||||
'btn.recent': 'Recent', 'btn.open': 'Open Project', 'btn.settings': 'Settings',
|
||||
'lv.group': 'Group', 'lv.bill': 'Bill', 'lv.det': 'Norm', 'lv.defw': 'Default Width', 'lk.reload': '⟳ Reload'
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ a:hover{text-decoration:underline}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="common.js?v=20261016a"></script>
|
||||
<script src="common.js?v=20261021d"></script>
|
||||
<script>
|
||||
/* 会话管理页:照后台「项目界面」的版式,管的是**还没入库**的工作台会话。
|
||||
会话库不自动清(SESSION_KEEP_DAYS=0),要删只能在这里手动删。
|
||||
|
||||
@@ -47,6 +47,7 @@ td{padding:5px 8px;border-bottom:1px solid #eef1f6;border-right:1px solid #f4f6f
|
||||
.src-p{color:#2e7d32;background:#e8f5e9}
|
||||
.src-i{color:#1565c0;background:#e3f2fd}
|
||||
.src-m{color:#e65100;background:#fff3e0}
|
||||
.src-self{color:#6a1b9a;background:#f3e5f5} /* 决策 158:范围=是,来源徽章「本工程」(紫) */
|
||||
/* 规格型号灰字(结果表名称列第二行,工料机比价的关键区分项) */
|
||||
.spec2{display:block;color:#8a97a8;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
tbody tr:hover td{background:#f6f9fd}
|
||||
@@ -99,11 +100,15 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
/* 原数据标签=只读还原,**不与历史项目比对** → 整块历史区(含筛选栏/历史表/收起·展开/拖动把手)不显示。
|
||||
其余 3 个标签照常显示(2026-10-01)。 */
|
||||
#histwrap.rawmode{display:none}
|
||||
#histbar{display:flex;align-items:center;gap:8px;padding:5px 12px;background:#eef3fa;border-bottom:1px solid var(--line);min-height:32px;flex-wrap:wrap}
|
||||
#histbar{display:flex;align-items:center;gap:4px;padding:5px 8px;background:#eef3fa;border-bottom:1px solid var(--line);min-height:32px;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden}
|
||||
#histbar::-webkit-scrollbar{height:5px}#histbar::-webkit-scrollbar-thumb{background:#c7d2e0;border-radius:3px} /* 2026-10-21 决策 143:工具栏一行排布,极窄窗横向滚动兜底 */
|
||||
#histbar .hbl{font-size:12px;color:#456;white-space:nowrap}
|
||||
#histbar select{padding:3px 6px;border:1px solid #b8c4d4;border-radius:5px;font:inherit;font-size:12px;max-width:150px}
|
||||
#histbar .hb{border:1px solid #b8c4d4;background:#fff;border-radius:5px;padding:2px 9px;font-size:12px;cursor:pointer;color:var(--c2);font-weight:600}
|
||||
#histbar select{padding:3px 4px;border:1px solid #b8c4d4;border-radius:5px;font:inherit;font-size:12px;max-width:84px}
|
||||
#histbar .hb{border:1px solid #b8c4d4;background:#fff;border-radius:5px;padding:2px 8px;font-size:12px;cursor:pointer;color:var(--c2);font-weight:600}
|
||||
#histbar > *{flex:0 0 auto} /* 决策 143:子项禁收缩——按钮不被压到换行;余量由搜索/屏蔽词弹性吸收 */
|
||||
#histbar > .combo{flex:1 1 90px;min-width:0} /* 决策 143:搜索/屏蔽词的小叉壳层在顶层,弹性吸收余量(单位/项目名称的壳在 .fld 里不受此限) */
|
||||
#histbar .fld{display:flex;align-items:center;gap:5px}
|
||||
#histbar .hnum{width:44px;padding:3px 6px;border:1px solid #b8c4d4;border-radius:5px;font:inherit;font-size:12px;background:#fff} /* 决策 144:价格范围皮肤按单位框 */
|
||||
/* 名称悬停浮层(2026-10-08 主人定):停留即显 项目特征 + 定额(编码/名称);
|
||||
浮层挂 body 固定定位(同 combo-panel 思路),定额按 bill_id 走 histNorms 缓存。 */
|
||||
#htip{position:fixed;z-index:600;display:none;width:440px;max-width:92vw;max-height:60vh;overflow:auto;
|
||||
@@ -143,11 +148,11 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
.srcpop label input{vertical-align:-1px;margin-right:4px}
|
||||
/* 建设单位(历史比对栏):common.js comboFree 包裹(同「打开工程」那套),
|
||||
这里只定宽 + 控件皮肤;旧的关键字下拉 .clist/.citem 已随 setupUnit 一起删。 */
|
||||
#fldUnit .combo{width:170px}
|
||||
#fldUnit .combo,#fldProj .combo{width:124px} /* 决策 143/144:单位、项目名称框同款定宽 */
|
||||
#fldUnit .combo input{border:1px solid #b8c4d4;border-radius:5px;font:inherit;font-size:12px}
|
||||
/* 历史比对:结果关键字搜索(名称/项目特征/单位,2026-10-08) */
|
||||
#hkw{width:200px;padding:3px 8px;border:1px solid #b8c4d4;border-radius:5px;font:inherit;font-size:12px}
|
||||
#fstop{width:150px;padding:3px 8px;border:1px solid #b8c4d4;border-radius:5px;font:inherit;font-size:12px}
|
||||
#hkw{flex:1 1 90px;min-width:88px;width:auto;padding:3px 8px;border:1px solid #b8c4d4;border-radius:5px;font:inherit;font-size:12px}
|
||||
#fstop{flex:1 1 84px;min-width:80px;width:auto;padding:3px 8px;border:1px solid #b8c4d4;border-radius:5px;font:inherit;font-size:12px}
|
||||
/* 检索兜底行灰徽标(决策 38):关键词未连写命中、仅全拆字凑齐的宽泛行 */
|
||||
.tg-lo{background:#eef0f3;color:#7a8694}
|
||||
/* ---- 地区树弹层(2026-09-29:三联动下拉 → 树形多选,根「全国」)---- */
|
||||
@@ -231,7 +236,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
.cfgtbl th,.cfgtbl td{border-bottom:1px solid #e3e9f0;padding:6px 6px;vertical-align:top;text-align:left}
|
||||
.cfgtbl thead th{text-align:center;background:#f3f7fb;white-space:nowrap}
|
||||
.cfgtbl .rin{width:100%;box-sizing:border-box;padding:4px 6px;border:1px solid #b8c4d4;border-radius:6px;font:inherit;font-size:13px;background:#fff}
|
||||
.cfgtbl .rin-seq{width:52px;text-align:center}
|
||||
/* 决策 156:序号不可编辑(原 .rin-seq 输入框样式随 ruleSeq 一并退役) */
|
||||
.cfgtbl .rin.ta{min-height:44px;resize:vertical;line-height:1.4}
|
||||
.cfgtbl tbody tr:hover{background:#f8fafd}
|
||||
.cfgtbl button.danger{background:#fdecec;border-color:#e5484d;color:#c53030;font-weight:600}
|
||||
@@ -317,7 +322,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
<button class="btn pri" id="btnExport" onclick="exportSession()" data-i18n="btn.export"
|
||||
title="按原格式导出本工程(含全部编辑:临删已省略、新增/采纳已写入)。只能对工作台的数据进行导出">导出</button>
|
||||
<button class="btn" id="btnInq" onclick="openInq()"
|
||||
title="当前会话收进的附件目录(切会话跟着切,删会话才清);勾选后可批量下载" data-i18n="btn.inq">询价附件</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>
|
||||
@@ -397,6 +402,13 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
<button class="hb" id="fareaBtn" onclick="togglePop('areapop')">地区 全国 ▾</button>
|
||||
<div class="srcpop treepop" id="areapop"></div>
|
||||
</div>
|
||||
<!-- 3b 本项目(2026-10-21 主人定):地区右边。数据第一关,决定数据流走向——
|
||||
是=只搜本工程(session 库),否=只搜其他工程(批次库,排除自己)。默认按标签:组价不一致=是,其他=否。 -->
|
||||
<div class="fld"><span class="hbl">本项目</span>
|
||||
<select id="fself" onchange="onSelf()">
|
||||
<option value="yes">是</option><option value="no" selected>否</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- 4 精确度 -->
|
||||
<div class="fld" data-page-node-id="L7WHSCZ9g0QKYYx6MjiNLs"><span class="hbl" data-page-node-id="F4AxsY4ncv9GWEqCHbf034">精确度</span>
|
||||
<select id="htier" data-page-node-id="LbhWXpxnhw5lV82pdsfuOA">
|
||||
@@ -426,14 +438,20 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
<!-- 8 单位(2026-10-08 主人定:原「建设单位」改名,**放搜索框左边**)——
|
||||
类似清单标签=建设单位;项目工料机标签=单位跨来源联查(建设单位 OR 发行单位),同框自由输入+建议下拉。
|
||||
选项:工程来源用 __BU_OPTS,工料机标签用 __ORG_OPTS(建设单位 ∪ 发行单位)。 -->
|
||||
<div class="fld" id="fldUnit"><span class="hbl" id="funitLbl">建设单位</span>
|
||||
<!-- 决策 144(2026-10-21 主人定):去掉「单位/建设单位」名称标签,只留搜索框——单位含义由 placeholder 随标签切换带出 -->
|
||||
<div class="fld" id="fldUnit">
|
||||
<input id="funit" placeholder="输入建设单位" autocomplete="off">
|
||||
</div>
|
||||
<!-- 8c 项目名称(决策 141,2026-10-20 主人定:单位框右边,交互/功能同单位框)——
|
||||
比对/检索两路径都按历史批次项目名精确过滤;清单/工料机两侧对比框同样生效。 -->
|
||||
<div class="fld" id="fldProj">
|
||||
<input id="fproj" placeholder="输入项目名称" autocomplete="off">
|
||||
</div>
|
||||
<!-- 8b 价格范围(**仅项目工料机标签**,2026-10-08 主人定:**放搜索框左边**):对除税单价,两端留空=不限 -->
|
||||
<div class="fld" id="fldPrc" style="display:none"><span class="hbl">价格范围</span>
|
||||
<input id="fpmin" type="number" placeholder="≥" min="0" style="width:70px">
|
||||
<input id="fpmin" type="number" placeholder="≥" min="0" class="hnum">
|
||||
<span class="hbl" style="margin:0 2px">~</span>
|
||||
<input id="fpmax" type="number" placeholder="≤" min="0" style="width:70px">
|
||||
<input id="fpmax" type="number" placeholder="≤" min="0" class="hnum">
|
||||
</div>
|
||||
<!-- 9 搜索(查询按钮左侧):对命中行的 名称/项目特征/单位 按关键字过滤,回车=查询 -->
|
||||
<input id="hkw" placeholder="搜索:名称 / 项目特征 / 单位" autocomplete="off">
|
||||
@@ -562,7 +580,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="common.js?v=20261017h"></script>
|
||||
<script src="common.js?v=20261021d"></script>
|
||||
<script src="period.js"></script>
|
||||
<script>
|
||||
let SID=0, CUR=null, CURTYPE='lme', HROWS=[];
|
||||
@@ -574,8 +592,9 @@ let SEARCH_SEQ=0; // 比对请求代次:只渲染最新一次,避
|
||||
/* 筛选状态(工具条一处维护):kinds 全勾=[]=不筛;area 为空=全国=不筛;kw=关键字(查询按钮的条件)。
|
||||
2026-10-08 主人定:来源下拉删除 —— 数据本就全部来自入库项目(含其挂的信息价/市场价),
|
||||
后端 srcs 缺省=三种全要,前端不再传。无关键字时条件即改即查;有关键字时改动只记这里。 */
|
||||
const FLT={kinds:[],unit:'',area:[],kw:'',srcs:[],prcmin:'',prcmax:'',att:'all',stop:'',
|
||||
tierByTab:{p0:'all',p2:'es'}}; // 精确度按标签记默认:工料机=全部(含模糊,2026-10-08 主人定),类似清单=精确+次精确
|
||||
const FLT={kinds:[],unit:'',proj:'',area:[],kw:'',srcs:[],prcmin:'',prcmax:'',att:'all',stop:'',
|
||||
tierByTab:{p0:'all',p2:'es'}, // 精确度按标签记默认:工料机=全部(含模糊,2026-10-08 主人定),类似清单=精确+次精确
|
||||
selfByTab:{p1:'yes'}}; // 本项目按标签记默认(2026-10-21 主人定):组价不一致=是,其他=否
|
||||
/* 当前停留的标签(p0=项目工料机 / p2=类似清单…)——筛选条与结果表按它分工 */
|
||||
function curTab(){ const t=document.querySelector('.tab.on'); return t?t.dataset.p:'p3'; }
|
||||
const $=id=>document.getElementById(id);
|
||||
@@ -601,7 +620,7 @@ const C_LME_WB = COLS.lme;
|
||||
// ⑤「单价」右侧加「单价类型」、「建设单位」右侧加「地区」(fkind_name/region 由接口带出)。
|
||||
const C_H=[['',30,'c','tg'],['序号',44,'c'],['档位',62,'c'],['名称',190,'l'],['单位',52,'c'],['单价',96,'r'],
|
||||
['单价类型',92,'c'],['价差%',80,'r'],['来源',110,'l'],['建设单位',110,'l'],
|
||||
['地区',130,'l'],['期次',96,'l'],['相似度',64,'r'],['操作',150,'c']];
|
||||
['地区',130,'l'],['期次',96,'l'],['操作',150,'c']]; // 决策 141:取消相似度列
|
||||
/* 项目工料机对比框结果表(2026-10-08 主人定,16 列):
|
||||
−把手(工料机行无定额可展开) −单价类型(不参与工料机比对);
|
||||
+来源徽章(工程绿/信息价蓝/市场价橙) +规格型号独立列 +备注(刊物行备注,如价格区间)
|
||||
@@ -609,8 +628,8 @@ const C_H=[['',30,'c','tg'],['序号',44,'c'],['档位',62,'c'],['名称',190,'l
|
||||
右栏(项目特征/定额)不显示。 */
|
||||
const C_H_LME=[['序号',44,'c'],['来源',64,'c'],['档位',62,'c'],['名称',190,'l'],['规格型号',170,'l'],
|
||||
['单位',52,'c'],['单价',96,'r'],['备注',110,'l'],['价差%',80,'r'],['项目/刊物',150,'l'],
|
||||
['单位主体',110,'l'],['地区',110,'l'],['期次',96,'l'],['相似度',64,'r'],['附件',70,'c'],['操作',90,'c']];
|
||||
const SRC_CLS={'工程':'src-p','信息价':'src-i','市场价':'src-m'};
|
||||
['单位主体',110,'l'],['地区',110,'l'],['期次',96,'l'],['附件',70,'c'],['操作',90,'c']]; // 决策 141:取消相似度列
|
||||
const SRC_CLS={'工程':'src-p','信息价':'src-i','市场价':'src-m','本工程':'src-self'};
|
||||
|
||||
// 表头 / colgroup 也走 common.js(与后台同一份),不再各写一份
|
||||
function head(cols){ return headHTML(cols); }
|
||||
@@ -636,11 +655,11 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||
function syncHist(p){
|
||||
const w=$('histwrap'); if(!w) return;
|
||||
w.classList.remove('rawmode');
|
||||
if(p==='p3' && !(typeof CUR!=='undefined' && CUR && CURTYPE==='bill')) w.classList.add('folded');
|
||||
if(p==='p3' && !(typeof CUR!=='undefined' && CUR && (CURTYPE==='bill'||CURTYPE==='lme'))) w.classList.add('folded'); // 决策 142:工料机选中同样不折叠
|
||||
else w.classList.remove('folded');
|
||||
// 2026-10-08 主人定:筛选条按标签分工 —— 单价类型仅类似清单;来源/价格范围仅项目工料机;
|
||||
// 「单位」两标签共用(工料机侧 = 建设单位 OR 发行单位 联查,按钮文字/选项随标签切换)。
|
||||
const isLme = (p==='p0');
|
||||
const isLme = (p==='p0') || (p==='p3' && CURTYPE==='lme' && typeof CUR!=='undefined' && CUR); // 决策 142:p3 选中工料机=同工料机对比上下文
|
||||
if($('fldSrc')) $('fldSrc').style.display = isLme ? '' : 'none';
|
||||
if($('fldPrc')) $('fldPrc').style.display = isLme ? '' : 'none';
|
||||
if($('fldAtt')) $('fldAtt').style.display = isLme ? '' : 'none';
|
||||
@@ -653,6 +672,8 @@ function syncHist(p){
|
||||
if($('hattr')) $('hattr').style.display = (isLme || HATTR_FOLD) ? 'none' : '';
|
||||
// 精确度按标签取默认(工料机=全部含模糊;各自记住手动选择)
|
||||
if($('htier') && FLT.tierByTab[p]) $('htier').value = FLT.tierByTab[p];
|
||||
// 本项目按标签取默认(组价不一致=是,其他=否;手动选择也按标签记住,2026-10-21 主人定)
|
||||
if($('fself')) $('fself').value = (FLT.selfByTab && FLT.selfByTab[p]) || 'no';
|
||||
// 切标签=换对比上下文:结果表按新标签的列头重置(旧结果属于上一个标签,留着必然错位)
|
||||
if($('hth')){
|
||||
const cols = isLme ? C_H_LME : C_H;
|
||||
@@ -744,6 +765,16 @@ window.rawBillPick = function(tr){
|
||||
pick('bill', bid, tr);
|
||||
};
|
||||
|
||||
/* 决策 142(2026-10-20 主人定):原数据·项目级工料机汇总 选中行 → 底部历史对比框,
|
||||
与「项目工料机」标签完全同一套:pick('lme')→/api/search→renderHist 共用(改一处=改 2 个地方)。 */
|
||||
window.rawLmePick = function(type, id, tr){ // 决策 147:renderLme 统一生成 rawLmePick('lme',id,this)
|
||||
if(!SID) return;
|
||||
const lid = Number(id);
|
||||
if(!lid) return;
|
||||
$('histwrap').classList.remove('folded'); // 选中即展开对比框(与清单行同款)
|
||||
pick('lme', lid, tr);
|
||||
};
|
||||
|
||||
/* 导出回写(批次D,决策 70):按原格式导出本工程(全部编辑已体现为文件内容)。
|
||||
决策 91:另存为样式;决策 92(主人定流程):壳内点导出=①先弹原生另存为选路径(此刻还没开始
|
||||
生成,大工程不再干等)→②弹进度模态(生成逐条目% + 写盘字节%),期间软件不可操作 →③模态上
|
||||
@@ -914,6 +945,7 @@ async function mergeApply(){
|
||||
mergeClose();
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
await rawDraw();
|
||||
await loadLme(); // 决策 142:项目工料机页签同步为合并后数据(服务端 x_merged_hide 过滤、LME_LIST_WHERE 不变)
|
||||
$('msg').textContent = '合并完成:保留 ' + r.kept + ' 行(含改值)、隐藏 ' + r.hidden + ' 行';
|
||||
}
|
||||
|
||||
@@ -941,7 +973,7 @@ document.addEventListener('dblclick', function(e){
|
||||
} else if(tr.classList.contains('sub') && tr.dataset.nid){
|
||||
const F = {4:'Name',7:'Quantity'};
|
||||
if(F[idx]){ api='norm'; id=tr.dataset.nid; field=F[idx]; }
|
||||
} else if(tr.classList.contains('lmerow') && tr.dataset.lmeid && RV_LME_DS){
|
||||
} else if(tr.classList.contains('lmerow') && (tr.dataset.lmeid || tr.dataset.id) && RV_LME_DS){
|
||||
// 2026-10-16 主人口径:项目级工料机汇总 除税编制价|税率|含税编制价 三格可改(单位级行无 data-lmeid=只读)。
|
||||
// 视图下标经 RV_LME_DS 映射到数据下标:6=除税编制价 7=税率 8=含税编制价。
|
||||
const dk = RV_LME_DS[idx];
|
||||
@@ -1115,6 +1147,10 @@ function lmeEditCell(td, tr, field, cur){
|
||||
const curV = f => lmeParseNum(cells[f].textContent);
|
||||
const inp = document.createElement('input');
|
||||
inp.className = 'cellin'; inp.value = cur; inp.spellcheck = false;
|
||||
inp.addEventListener('input', function(){ // 决策 146:只能输数字(数字/一个小数点/负号,实时剥除)
|
||||
const f = this.value.replace(/[^\d.\-]/g, ''), pp = f.split('.');
|
||||
this.value = pp.length > 2 ? pp[0] + '.' + pp.slice(1).join('') : f;
|
||||
});
|
||||
td.textContent = ''; td.appendChild(inp);
|
||||
inp.focus(); inp.select();
|
||||
let done = false;
|
||||
@@ -1142,7 +1178,7 @@ function lmeEditCell(td, tr, field, cur){
|
||||
ntp = taxp == null ? null : lmeRound2(taxp / div);
|
||||
}
|
||||
const r = await J('/api/session/lme/price', {method:'POST', headers:{'Content-Type':'application/json'},
|
||||
body: JSON.stringify({session_id:SID, id:Number(tr.dataset.lmeid), ntp:ntp, taxrate:taxrate, taxp:taxp})});
|
||||
body: JSON.stringify({session_id:SID, id:Number(tr.dataset.lmeid || tr.dataset.id), ntp:ntp, taxrate:taxrate, taxp:taxp})});
|
||||
if(!r || !r.ok){ $('msg').textContent = (r && r.msg) || '保存失败'; td.textContent = cur; return; }
|
||||
// 服务端复核后的三值原位回填(本地行/排序/序号都不动)
|
||||
cells.ntp.textContent = rm(r.ntp);
|
||||
@@ -1466,13 +1502,18 @@ async function search(){
|
||||
const flt = (CURTYPE==='lme')
|
||||
? lmeFlt()
|
||||
: { file_kinds:FLT.kinds, bulid_units:FLT.unit?[FLT.unit]:[] };
|
||||
const r=await J('/api/search',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID,type:CURTYPE,row_id:CUR.id,limit:50,
|
||||
scope:(CURTYPE==='bill' && curTab()==='p1') ? 'self_group' : '', // 规格 18:组价不一致对比默认只看本项目
|
||||
...flt,
|
||||
stop:(FLT.stop||'').trim(),
|
||||
area:FLT.area.map(k=>{const a=k.split('/');return{province:a[0]||'',city:a[1]||'',district:a[2]||''}}),
|
||||
period_from:PVAL($('hperBtn')).f, period_to:PVAL($('hperBtn')).t})});
|
||||
const selfYes = $('fself') && $('fself').value==='yes'; // 本项目(决策 158):是=数据流走会话库
|
||||
const r=await J(selfYes ? '/api/self/search' : '/api/search',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify(selfYes
|
||||
? {session_id:SID,type:CURTYPE,row_id:CUR.id,limit:50,
|
||||
stop:(FLT.stop||'').trim(),
|
||||
scope:(CURTYPE==='bill' && curTab()==='p1') ? 'self_group' : ''} // 规格 18:组价不一致=会话内本组其他清单(直读会话)
|
||||
: {session_id:SID,type:CURTYPE,row_id:CUR.id,limit:50,
|
||||
...flt,
|
||||
projs: FLT.proj ? [FLT.proj] : [], // 项目名称(决策 141):清单/工料机两侧同滤
|
||||
stop:(FLT.stop||'').trim(),
|
||||
area:FLT.area.map(k=>{const a=k.split('/');return{province:a[0]||'',city:a[1]||'',district:a[2]||''}}),
|
||||
period_from:PVAL($('hperBtn')).f, period_to:PVAL($('hperBtn')).t})});
|
||||
if(seq!==SEARCH_SEQ) return; // 已有更新的请求,丢弃这次过期响应
|
||||
if(!r.ok){ $('htb').innerHTML=`<tr><td colspan="${C_H.length}" class="empty">${esc(r.msg)}</td></tr>`; return; }
|
||||
HROWS=r.rows||[];
|
||||
@@ -1491,30 +1532,47 @@ function curPrice(){
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/* 当前基准行的采纳备注(对比框「已采纳」灰徽标判定依据,2026-10-11 主人定):
|
||||
清单 = GRP_DATA 里 r[0]===CUR.id 的 r[10];工料机 = LME_ROWS 同查。无选中/无备注 = 空。 */
|
||||
function curAdoptTxt(){
|
||||
if(!CUR||!CUR.id) return '';
|
||||
if(CURTYPE==='lme'){
|
||||
const r=(LME_ROWS||[]).find(y=>y[0]===CUR.id);
|
||||
return (r&&r[10])||'';
|
||||
}
|
||||
const r=grpRowById(CUR.id);
|
||||
return (r&&r[10])||'';
|
||||
/* 采纳来源记忆(决策 139,2026-10-20 主人定「记住采纳的 id,直接按 id 定位,永远排第一」):
|
||||
采纳时把来源行(清单=bill_id;工料机检索行没有 id,用 名称|规格|单位|价格|项目|期次 签名)
|
||||
连同整行快照存 localStorage(本机软件,决策 131 同款先例)。渲染对比框时按 id/签名在当前
|
||||
结果里定位——在就提到第一条;不在(关键词过滤/检索分页)就把快照取回来放在第一条;
|
||||
第二条起仍按正常搜索逻辑排序。取消采纳同步删除记忆;再采纳=覆盖(连续采纳认最后一次)。
|
||||
开发阶段不做存量兼容。 */
|
||||
const ADOPT_SRC_KEY='wb_adopt_src_v1';
|
||||
function adoptSrcMap(){
|
||||
try{ return JSON.parse(localStorage.getItem(ADOPT_SRC_KEY))||{}; }catch(e){ return {}; }
|
||||
}
|
||||
/* 结果行 x 若被采纳,其备注应恰好等于(与 adopt/adoptLme 的写入格式**逐字一致**,
|
||||
改一侧必须同步另一侧,否则灰徽标失配)。决策 138(2026-10-20 主人定)新格式:
|
||||
采纳:名称+(项目名称)——有加号和中文括号,价格不再写进备注;存量旧格式
|
||||
(采纳:名称 单价 项目)仍能识别(adoptTxtLegacy),再采纳时才覆盖为新格式。 */
|
||||
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;
|
||||
}
|
||||
/* 采纳备注格式(决策 138,2026-10-20 主人定):采纳:名称+(项目名称)——有加号和中文括号,
|
||||
价格不再写进备注。已采纳定位/置顶以 adoptSrc 的 id/签名为准,不再按备注文本反推。 */
|
||||
function adoptTxtFor(x,isLme){
|
||||
return `采纳:${x.name||''}+(${x.proj||''})`;
|
||||
}
|
||||
function adoptTxtLegacy(x,isLme){
|
||||
return isLme ? `采纳:${x.name||''}${x.price!=null?' '+Number(x.price).toFixed(2):''} ${x.proj||''}`
|
||||
: `采纳:${x.name||''} ${Number(x.price).toFixed(2)} ${x.proj||''}`;
|
||||
}
|
||||
function isAdoptedRow(x,at,isLme){
|
||||
return at===adoptTxtFor(x,isLme) || at===adoptTxtLegacy(x,isLme);
|
||||
const p=v=>(v==null||v===''?'—':v);
|
||||
return isLme
|
||||
? `采纳:${x.name||''}+${x.proj||''}+原${p(x.price)}|${p(x.tax)}|${p(x.price_tax)}`
|
||||
: `采纳:${x.name||''}+${x.proj||''}+原${p(x.price)}`;
|
||||
}
|
||||
function renderHist(){
|
||||
const tiers = $('htier').value==='all' ? ['精确','次精确','字集','模糊']
|
||||
@@ -1554,25 +1612,31 @@ function renderHist(){
|
||||
// 项目工料机标签(含其检索模式):14 列专属表 —— 来源徽章+规格型号,无把手/单价类型(2026-10-08 主人定)
|
||||
const isLme = (CURTYPE==='lme') || (HINDEP && curTab()==='p0');
|
||||
const cols = isLme ? C_H_LME : C_H;
|
||||
if($('hattr')) $('hattr').style.display = (isLme || HATTR_FOLD) ? 'none' : ''; // 决策 142:右栏显隐在渲染处统一管(改一处=两侧生效)
|
||||
colg('hcg',cols);
|
||||
// 表头全部居中(2026-10-08 主人定,工料机对比框),内容单元格对齐不变
|
||||
$('hth').innerHTML = isLme
|
||||
? '<tr>'+cols.map(c=>`<th class="c">${esc(c[0])}<span class="rs"></span></th>`).join('')+'</tr>'
|
||||
: head(cols);
|
||||
// 已采纳标记(2026-10-11 主人定):基准行采纳备注与结果行逐一匹配(首个命中)→ 灰徽标「已采纳」;
|
||||
// 再采纳其他行 = 备注被覆盖 → 标记自动传递到新行;取消采纳 = 备注清空 → 复原为「采纳」。
|
||||
// 已采纳标记 + 来源置顶(决策 138/139,2026-10-20 主人定):按记忆的 id/签名定位采纳来源——
|
||||
// 在当前结果里就提到第一条;不在(关键词过滤/检索分页)就把记住的来源行取回来放第一条;
|
||||
// 第二条起仍按正常搜索逻辑的顺序展示。取消采纳 = 记忆删除 → 复原为「采纳」。
|
||||
// ⚠️ 引用 isLme —— 必须在其 const 声明之后(TDZ),故放表头渲染之后。
|
||||
const at=curAdoptTxt();
|
||||
const adoptedBadge='<span class="tg tg-lo" title="已采纳——取消请点上方该行的「取消采纳」">已采纳</span>';
|
||||
let adoptedIdx=-1;
|
||||
if(at) rows.forEach((x,i)=>{ if(adoptedIdx<0 && isAdoptedRow(x,at,isLme)) adoptedIdx=i; });
|
||||
// 决策 138(2026-10-20 主人定):已采纳 → 采纳来源行置顶,回显在对比框第一条;
|
||||
// 第二条起仍按正常搜索逻辑的顺序展示(其余行排序不动)。
|
||||
if(adoptedIdx>0){
|
||||
rows=[rows[adoptedIdx]].concat(rows.slice(0,adoptedIdx), rows.slice(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;
|
||||
}
|
||||
const selfMode=$('fself') && $('fself').value==='yes';
|
||||
const emptyMsg=selfMode
|
||||
? (isLme?'本工程内没有同类的工料机':'本工程内没有同名的其他清单')
|
||||
: (HINDEP?(isLme?'没有符合 条件+关键词 的入库工料机/价格':'没有符合 条件+关键词 的入库清单'):'没有命中的历史项');
|
||||
$('htb').innerHTML=rows.map((x,i)=>{
|
||||
let d='—',cls='';
|
||||
if(cur && x.price!=null){ const p=(x.price-cur)/cur*100;
|
||||
@@ -1585,6 +1649,8 @@ function renderHist(){
|
||||
// 工料机/信息价/市场价行没有下挂定额,不渲染把手列。
|
||||
const tg=(!isLme && x.bill_id)
|
||||
? `<span class="tog" title="展开/收起该历史清单下的定额" onclick="event.stopPropagation();tgHist(this,${x.bill_id})">+</span>`
|
||||
: (!isLme && x.norms)
|
||||
? `<span class="tog" title="展开/收起该清单下的定额" onclick="event.stopPropagation();tgHistSelf(this,${x.self_bill_id})">+</span>`
|
||||
: '';
|
||||
// 检索兜底行(决策 38):关键词只散字凑齐 → 灰徽标「兜底」;严格命中照常蓝徽标「检索」
|
||||
const tierBadge = x.loose
|
||||
@@ -1602,7 +1668,7 @@ function renderHist(){
|
||||
+ `<td class="r ${cls}">${d}</td><td>${ell(x.proj)}</td>`
|
||||
+ `<td>${ell(x.bunit,'—')}</td>`
|
||||
+ `<td>${ell(x.region,'—')}</td>`
|
||||
+ `<td class="l">${ell(x.period)}</td><td class="r">${num(x.sim,2)}</td>`
|
||||
+ `<td class="l">${ell(x.period)}</td>`
|
||||
+ `<td class="c">${x.file&&x.file_url?`<a class="lk" href="javascript:void(0)" onclick="return saveAsAtt(${i})">下载</a>`:'—'}</td>`
|
||||
+ `<td class="c">${i===adoptedIdx ? adoptedBadge : `<a class="lk" onclick="adoptLme(${i})">采纳</a>`}</td>`
|
||||
: `<td class="c">${seq0+i+1}</td>`
|
||||
@@ -1613,10 +1679,10 @@ function renderHist(){
|
||||
+ `<td class="r ${cls}">${d}</td><td>${ell(x.proj)}</td>`
|
||||
+ `<td>${ell(x.bunit,'—')}</td>`
|
||||
+ `<td>${ell(x.region,'—')}</td>`
|
||||
+ `<td class="l">${ell(x.period)}</td><td class="r">${num(x.sim,2)}</td>`
|
||||
+ `<td class="l">${ell(x.period)}</td>`
|
||||
+ `<td class="c">${op.join(' · ')}</td>`;
|
||||
return `<tr data-i="${i}"${isLme?' data-lme="1"':''} onclick="pickHistRow(${i},this)">${isLme?'':`<td class="tg">${tg}</td>`}${body}</tr>`;
|
||||
}).join('')||`<tr><td colspan="${cols.length}" class="empty">${HINDEP?(isLme?'没有符合 条件+关键词 的入库工料机/价格':'没有符合 条件+关键词 的入库清单'):'没有命中的历史项'}</td></tr>`;
|
||||
}).join('')||`<tr><td colspan="${cols.length}" class="empty">${emptyMsg}</td></tr>`;
|
||||
// 统计(命中数角标已按主人 10-08 要求删除)
|
||||
const vs=rows.map(x=>x.price).filter(v=>v!=null).sort((a,b)=>a-b);
|
||||
let foot='';
|
||||
@@ -1653,6 +1719,9 @@ function hattrShow(x){
|
||||
const t=$('hattrTxt'), n=$('hattrNorms');
|
||||
if(!x){ t.innerHTML=''; n.innerHTML='<div class="empty">—</div>'; return; }
|
||||
t.innerHTML = x.attr ? esc(fmtAttr(x.attr)) : '<div class="empty">(无项目特征)</div>';
|
||||
if(x.norms){ n.innerHTML = x.norms.length
|
||||
? x.norms.map(r=>`<div class="hnorm-it" title="${esc((r[0]||'')+' '+(r[1]||''))}"><span class="nc">${esc(r[0]||'—')}</span>${esc(r[1]||'—')}</div>`).join('')
|
||||
: '<div class="empty">(该清单下没有定额)</div>'; return; } // 决策 158:会话源行内联定额
|
||||
if(!x.bill_id){ n.innerHTML='<div class="empty">(此行无定额)</div>'; return; }
|
||||
n.innerHTML='<div class="empty">正在读取…</div>';
|
||||
histNorms(x.bill_id).then(rows=>{
|
||||
@@ -1661,6 +1730,27 @@ function hattrShow(x){
|
||||
: '<div class="empty">(该清单下没有定额)</div>';
|
||||
}).catch(()=>{ n.innerHTML='<div class="empty">读取失败</div>'; });
|
||||
}
|
||||
/* ± 展开一条会话源清单的定额(决策 158):norms 内联在 VISIBLE_ROWS 行上,形状同 _bill_norms 6+2 列 */
|
||||
function tgHistSelf(el,sbid){
|
||||
const tr=el.closest('tr');
|
||||
let nx=tr.nextElementSibling;
|
||||
while(nx&&nx.classList.contains('hsub')){ const n2=nx.nextElementSibling; nx.remove(); nx=n2; }
|
||||
if(el.dataset.open==='1'){ el.textContent='+'; el.dataset.open='0'; el.classList.remove('g'); return; }
|
||||
el.dataset.open='1'; el.textContent='−'; el.classList.add('g');
|
||||
const x=(VISIBLE_ROWS||[]).find(v=>v&&v.self_bill_id===sbid);
|
||||
const rows=(x&&x.norms)||[];
|
||||
const frag=document.createElement('tbody');
|
||||
frag.innerHTML = rows.length
|
||||
? rows.map(r=>`<tr class="hsub"><td class="tg"></td><td class="c"></td>
|
||||
<td class="c"><span class="kind d">定额</span></td>
|
||||
<td><span class="nc" style="color:#6b7a8c;margin-right:6px">${esc(r[0]||'')}</span><span class="ell" title="${esc((r[0]||'')+' '+(r[1]||''))}">${esc(r[1]||'—')}</span></td>
|
||||
<td class="c">${esc(r[2]||'—')}</td><td class="r">${num(r[4])}</td>
|
||||
<td class="c">—</td><td class="c">—</td><td>—</td><td>—</td><td>—</td><td class="l">—</td><td class="r">—</td><td></td></tr>`).join('')
|
||||
: `<tr class="hsub"><td class="tg"></td><td colspan="${C_H.length-1}">(该清单下没有定额)</td></tr>`;
|
||||
let n2=tr.nextElementSibling;
|
||||
while(n2&&n2.classList.contains('hsub')){ n2=n2.nextElementSibling; }
|
||||
while(frag.firstChild) tr.parentNode.insertBefore(frag.firstChild,n2);
|
||||
}
|
||||
/* ± 展开一条历史清单的定额(子行列序跟 C_H 对齐:编码并入名称列,同 tgNorm 的排法) */
|
||||
async function tgHist(el,bid){
|
||||
const tr=el.closest('tr');
|
||||
@@ -1702,6 +1792,13 @@ function showHistTip(x, td, lmeOnly){
|
||||
if(T+htip.offsetHeight>window.innerHeight-8) T=Math.max(8, r.top-htip.offsetHeight-6);
|
||||
htip.style.left=L+'px'; htip.style.top=T+'px'; htip.style.visibility='visible';
|
||||
if(lmeOnly) return;
|
||||
if(x.norms){
|
||||
const box=htip.querySelector('.htip-norms'); if(!box) return;
|
||||
box.innerHTML = x.norms.length
|
||||
? x.norms.map(r=>`<div class="hnorm-it"><span class="nc">${esc(r[0]||'—')}</span>${esc(r[1]||'—')}</div>`).join('')
|
||||
: '<div class="tip" style="padding:4px 10px">(该清单下没有定额)</div>';
|
||||
return;
|
||||
}
|
||||
if(!x.bill_id){ htip.querySelector('.htip-norms').innerHTML='<div class="tip" style="padding:4px 10px">(此行无定额)</div>'; return; }
|
||||
histNorms(x.bill_id).then(ns=>{
|
||||
const box=htip.querySelector('.htip-norms'); if(!box) return;
|
||||
@@ -1753,6 +1850,14 @@ async function adopt(i){
|
||||
if(!r0 || !r0.ok){ dlMsg('采纳失败:'+(r0&&r0.msg?r0.msg:'服务未响应'),'err'); return; }
|
||||
// 定额构成变了:撤原数据取数缓存(切页重拉即新状态,与 billCtxApply 同口径)
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
} else if(x.self_bill_id){
|
||||
// 决策 158:范围=是 的来源行来自本会话——同一采纳语义(9.1 覆盖/9.3 追加+临删),服务端读会话源
|
||||
try{
|
||||
r0=await J('/api/session/bill/adopt',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID,bill_id:CUR.id,src_self_bill_id:x.self_bill_id})});
|
||||
}catch(e){ r0=null; }
|
||||
if(!r0 || !r0.ok){ dlMsg('采纳失败:'+(r0&&r0.msg?r0.msg:'服务未响应'),'err'); return; }
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
}
|
||||
// ② 采纳备注照旧(记录采纳来源——灰「已采纳」徽标与「取消采纳」列的数据源);格式走 adoptTxtFor
|
||||
const txt=adoptTxtFor(x,false);
|
||||
@@ -1762,6 +1867,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 追加定额带临删——重拉才是真状态)
|
||||
// keepView:采纳后停在原组原行(规格 2026-10-16:点采纳跳至第一组 = bug,修复)
|
||||
const cur=document.querySelector('.tab.on');
|
||||
@@ -1790,6 +1896,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:取消采纳=删除来源记忆
|
||||
// ③ 刷新当前视图(原数据/组表都可能是取消来源;撤缓存重拉即真状态;keepView 停在原地)
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
const cur=document.querySelector('.tab.on');
|
||||
@@ -1819,6 +1926,31 @@ async function adoptAtt(x){
|
||||
async function adoptLme(i){
|
||||
const x=VISIBLE_ROWS[i]; if(!x) return;
|
||||
if(CURTYPE!=='lme' || !CUR || !CUR.id) return; // 双保险:基准必须是工料机行
|
||||
// 决策 158(2026-10-21 主人定):采纳即改价——目标行三价 = 被采纳行的 除税编制价|税率|含税编制价
|
||||
//(走行级改价端点:三价联动/编码同步单位级/merged_codes 登记 全部同款)
|
||||
if(x.price!=null){
|
||||
let rp=null;
|
||||
try{
|
||||
rp=await J('/api/session/lme/price',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID,id:CUR.id,ntp:x.price,taxrate:x.tax,taxp:x.price_tax})});
|
||||
}catch(e){ rp=null; }
|
||||
if(!rp || !rp.ok){ dlMsg('采纳改价失败:'+(rp&&rp.msg?rp.msg:'服务未响应'),'err'); return; }
|
||||
const prow=(LME_ROWS||[]).find(y=>y[0]===CUR.id);
|
||||
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);
|
||||
}
|
||||
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 txt=adoptTxtFor(x,true);
|
||||
let r=null;
|
||||
try{
|
||||
@@ -1826,6 +1958,7 @@ async function adoptLme(i){
|
||||
body:JSON.stringify({lme_id:CUR.id,remark:txt})});
|
||||
}catch(e){ r=null; }
|
||||
if(!r || !r.ok){ dlMsg('备注写入失败:'+(r&&r.msg?r.msg:'服务未响应'),'err'); return; }
|
||||
adoptSrcSave(x); // 决策 139:记住采纳来源(签名+行快照),永远置顶
|
||||
const row=(LME_ROWS||[]).find(y=>y[0]===CUR.id); // 数据先行:排序/重画后备注与取消采纳不丢
|
||||
if(row){ row[10]=txt;
|
||||
// 就地更新两格(不整表重画——重画会丢 tr.sel 选中态);取消采纳格口径=备注以「采纳:」开头(lmeAdoptCellHTML)
|
||||
@@ -1833,6 +1966,13 @@ async function adoptLme(i){
|
||||
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>`;
|
||||
// 决策 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>`;
|
||||
}
|
||||
}
|
||||
renderHist(); // 已采纳灰标记:传递到本行
|
||||
dlMsg('已采纳,写入工料机备注:'+txt+await adoptAtt(x),'ok');
|
||||
@@ -1849,6 +1989,7 @@ 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:取消采纳=删除来源记忆
|
||||
const row=(LME_ROWS||[]).find(y=>y[0]===lmeId);
|
||||
if(row) row[10]='';
|
||||
const tr0=document.querySelector(`#tb0 tr[data-id="${lmeId}"]`);
|
||||
@@ -1857,6 +1998,12 @@ async function cancelAdopt(lmeId){
|
||||
if(c10){ c10.textContent=''; c10.title=''; }
|
||||
if(c9) c9.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>';
|
||||
}
|
||||
loadAdopt();
|
||||
renderHist();
|
||||
dlMsg('已取消采纳:备注已清空'
|
||||
@@ -1865,6 +2012,15 @@ async function cancelAdopt(lmeId){
|
||||
:(r.n_hit?'(附件仍被其它采纳引用,保留)':'(该行没有收集过附件)')),'ok');
|
||||
}
|
||||
|
||||
/* 决策 146(2026-10-21 主人定):合并工料机弹框的数字框(.mi.n)只能输数字——实时剥除非法字符 */
|
||||
document.addEventListener('input', function(e){
|
||||
const t=e.target;
|
||||
if(t && t.classList && t.classList.contains('mi') && t.classList.contains('n')){
|
||||
const f=t.value.replace(/[^\d.\-]/g,''), pp=f.split('.');
|
||||
t.value = pp.length>2 ? pp[0]+'.'+pp.slice(1).join('') : f;
|
||||
}
|
||||
});
|
||||
|
||||
/* 附件「下载」= 另存为(2026-10-08 主人定):走公共层 saveAs(选位置保存,不再浏览器里打开)。
|
||||
工程行 = 绑定的询价资料(/api/admin/inq/file/{id});价格行 = 刊物上传原件(/api/admin/file/{sha})。 */
|
||||
function saveAsAtt(i){
|
||||
@@ -1896,8 +2052,26 @@ function lmeRenderRows(){
|
||||
/* 下拉弹层:来源 / 单价类型 / 地区树 共用一套开关。2026-10-13 修:来源弹层 10-08 复活时
|
||||
没挂回 POPS —— 开了就再也收不上(点按钮、点弹层外都无效,主人报「选了来源收不回去」)。 */
|
||||
const POPS=['kindpop','areapop','srcpop'];
|
||||
function closePops(except){ POPS.forEach(id=>{ if(id!==except) $(id).classList.remove('on'); }); }
|
||||
function togglePop(id){ const on=!$(id).classList.contains('on'); closePops(); if(on) $(id).classList.add('on'); }
|
||||
/* 弹层挂 body(2026-10-21 主人报「来源下拉没有置顶」):决策 143 给 #histbar 加了 overflow-y:hidden,
|
||||
srcpop 的 top:100% 弹层被滚动容器整个裁掉(z-index 救不了,裁剪与层级无关)——打开时把弹层
|
||||
搬到 body 用 fixed 坐标贴着按钮显示,关闭时搬回原位。期次日历本来就是 fixed+body,不受影响。 */
|
||||
function _popRestore(p){ if(p._pp && p.parentNode!==p._pp) p._pp.appendChild(p); p.removeAttribute('style'); }
|
||||
function closePops(except){ POPS.forEach(id=>{ const p=$(id); if(id!==except){ p.classList.remove('on'); _popRestore(p); } }); }
|
||||
function togglePop(id){
|
||||
const p=$(id); const on=!p.classList.contains('on'); closePops();
|
||||
if(on){
|
||||
if(p.closest('#histbar')){
|
||||
const anchor=p.closest('.srcwrap')||p.parentNode;
|
||||
if(!p._pp) p._pp=anchor;
|
||||
const r=anchor.getBoundingClientRect();
|
||||
document.body.appendChild(p);
|
||||
p.style.position='fixed';
|
||||
p.style.top=(r.bottom+3)+'px';
|
||||
p.style.left=r.left+'px';
|
||||
}
|
||||
p.classList.add('on');
|
||||
}
|
||||
}
|
||||
|
||||
/* ================= 最近审核(会话台账,2026-09-29 新增) =================
|
||||
会话 = 打开过、但没入库的临时审核数据(session.db),跟后台「历史项目」是两回事。
|
||||
@@ -1932,7 +2106,7 @@ async function recOpen(sid,keep){
|
||||
await loadLme(); await tab((document.querySelector('.tab.on')||{dataset:{p:'p0'}}).dataset.p);
|
||||
}
|
||||
document.addEventListener('mousedown', e=>{
|
||||
if(e.target.closest('.srcwrap')) return;
|
||||
if(e.target.closest('.srcwrap,.srcpop')) return; /* 弹层已挂 body:点弹层内部不算「点外面」(2026-10-21) */
|
||||
closePops();
|
||||
});
|
||||
/* ---------- 单价类型:多选下拉(默认全勾=不筛) ---------- */
|
||||
@@ -2055,27 +2229,44 @@ function updAreaBtn(){
|
||||
有关键字=只记入条件,等「查询」(第 4 轮口径)。
|
||||
选项与导入弹框同口径(__BU_OPTS = 库内建设单位 ∪ 数据源字典,initFilters 里建)。 */
|
||||
let _unitT=0;
|
||||
let _projT=0; // 项目名称框防抖(决策 141)
|
||||
function setUnit(v){
|
||||
FLT.unit=(v||'').trim();
|
||||
if(kwActive()) return;
|
||||
clearTimeout(_unitT); _unitT=setTimeout(search, 250);
|
||||
}
|
||||
/* 项目名称(决策 141,2026-10-20 主人定):与单位框同款——自由输入+建议下拉,
|
||||
无关键字=防抖即查;有关键字=只记条件等「查询」。比对/检索两路径共用 FLT.proj。 */
|
||||
function setProj(v){
|
||||
FLT.proj=(v||'').trim();
|
||||
if(kwActive()) return;
|
||||
clearTimeout(_projT); _projT=setTimeout(search, 250);
|
||||
}
|
||||
/* 本项目(2026-10-21 主人定):是=只搜本工程,否=只搜其他工程;按标签记值(FLT.selfByTab)。
|
||||
无关键字=改完即查;有关键字=只记条件等「查询」(与其他条件同口径)。 */
|
||||
function onSelf(){
|
||||
FLT.selfByTab[curTab()]=$('fself').value;
|
||||
if(kwActive()) return;
|
||||
search();
|
||||
}
|
||||
function selVals(g){
|
||||
const els=document.querySelectorAll(`.fchk[data-g="${g}"]`);
|
||||
const all=Array.from(els), on=all.filter(x=>x.checked);
|
||||
return on.length===all.length?[]:on.map(x=>x.value); // 全选=不筛
|
||||
}
|
||||
function resetF(){
|
||||
FLT.kinds=[]; FLT.unit=''; FLT.area=[]; FLT.kw=''; FLT.srcs=[]; FLT.prcmin=''; FLT.prcmax=''; FLT.att='all'; FLT.stop='';
|
||||
FLT.kinds=[]; FLT.unit=''; FLT.proj=''; FLT.area=[]; FLT.kw=''; FLT.srcs=[]; FLT.prcmin=''; FLT.prcmax=''; FLT.att='all'; FLT.stop='';
|
||||
document.querySelectorAll('.fchk[data-g="fkind"]').forEach(x=>x.checked=true);
|
||||
document.querySelectorAll('.fchk[data-g="fsrc"]').forEach(x=>x.checked=true);
|
||||
document.querySelectorAll('input.farea').forEach(x=>{ x.checked = (x.value===''); });
|
||||
$('funit').value='';
|
||||
$('fproj').value=''; // 项目名称(决策 141)与单位框同款:重置一并清空
|
||||
$('fpmin').value=''; $('fpmax').value='';
|
||||
if($('hatt')) $('hatt').value='all';
|
||||
$('hkw').value='';
|
||||
$('fstop').value='';
|
||||
$('htier').value = (FLT.tierByTab && FLT.tierByTab[curTab()]) || 'es';
|
||||
if($('fself')) $('fself').value = (FLT.selfByTab && FLT.selfByTab[curTab()]) || 'no'; // 本项目回本标签默认(组价不一致=是)
|
||||
$('hsort').value='time';
|
||||
setPeriod($('hperBtn'),'','');
|
||||
updKindBtn(); updSrcBtn(); calcArea(); updAreaBtn(); updQryBtn();
|
||||
@@ -2165,13 +2356,18 @@ async function histSearch(page){
|
||||
// 类似清单标签:target=bill(原行为,查清单库)。
|
||||
const onLme = curTab()==='p0';
|
||||
const flt = onLme ? lmeFlt() : { file_kinds:FLT.kinds, bulid_units:FLT.unit?[FLT.unit]:[] };
|
||||
const r=await J('/api/hist/search',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID, // 排除被审工程自己(它入库了也不出现在检索里)
|
||||
const selfYes2 = $('fself') && $('fself').value==='yes'; // 本项目(决策 158):是=检索走会话库
|
||||
const r=await J(selfYes2 ? '/api/self/search' : '/api/hist/search',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify(selfYes2
|
||||
? {session_id:SID, type:onLme?'lme':'bill', kw:FLT.kw.trim(), stop:(FLT.stop||'').trim(), limit:HLIMIT}
|
||||
: {session_id:SID, // 排除被审工程自己(它入库了也不出现在检索里)
|
||||
target: onLme?'lme':'bill',
|
||||
...flt,
|
||||
area:FLT.area.map(k=>{const a=k.split('/');return{province:a[0]||'',city:a[1]||'',district:a[2]||''}}),
|
||||
period_from:PVAL($('hperBtn')).f, period_to:PVAL($('hperBtn')).t,
|
||||
kw:FLT.kw.trim(), stop:(FLT.stop||'').trim(), limit:HLIMIT, page:HPAGE})});
|
||||
kw:FLT.kw.trim(), stop:(FLT.stop||'').trim(),
|
||||
projs: FLT.proj ? [FLT.proj] : [], // 项目名称(决策 141):检索同滤
|
||||
limit:HLIMIT, page:HPAGE})});
|
||||
if(seq!==SEARCH_SEQ) return;
|
||||
if(!r.ok){ $('htb').innerHTML=`<tr><td colspan="${C_H.length}" class="empty">${esc(r.msg)}</td></tr>`; return; }
|
||||
HINDEP=true; HROWS=r.rows||[];
|
||||
@@ -2194,6 +2390,8 @@ $('hkw').oninput=()=>setKw($('hkw').value);
|
||||
$('hkw').onkeydown=e=>{ if(e.key==='Enter'){ e.preventDefault(); doQuery(); } };
|
||||
$('fstop').addEventListener('input', setStop); // 屏蔽词:输入即查(比对方式,防抖在 setStop)
|
||||
comboFree($('funit'), ()=> (curTab()==='p0' ? window.__ORG_OPTS : window.__BU_OPTS) || [], setUnit);
|
||||
comboFree($('fproj'), () => window.__PROJ_OPTS || [], setProj); // 项目名称(决策 141):交互同单位框
|
||||
$('fproj').style.padding='3px 22px 3px 8px'; // 与单位框同款矮内边距(右缘留小叉位)
|
||||
// 单位:自由输入+建议下拉
|
||||
$('funit').style.padding='3px 22px 3px 8px'; // 工具条控件更矮(盖掉 comboFree 默认内边距)
|
||||
$('fpmin').addEventListener('input', setPrc); // 价格范围:输入即查(防抖在 setPrc)
|
||||
@@ -2286,6 +2484,8 @@ async function initFilters(){
|
||||
window.__ORG_OPTS = Array.from(new Set((f.bu_rows||[]).concat(f.pub_rows||[])
|
||||
.concat(dictOrgs('builder')).concat(dictOrgs('publisher'))))
|
||||
.sort((x,y)=>x.localeCompare(y,'zh'));
|
||||
// 项目名称选项池(决策 141):历史项目名(/api/admin/filters 的 proj_rows),输入即过滤
|
||||
window.__PROJ_OPTS = (f.proj_rows||[]).sort((x,y)=>x.localeCompare(y,'zh'));
|
||||
regFill([$('oprov'),$('ocity'),$('odist')], f.area_rows||[], []);
|
||||
['oprov','ocity','odist'].forEach(id=>comboAttach($(id)));
|
||||
comboFree($('obuid'), () => window.__BU_OPTS);
|
||||
@@ -2433,7 +2633,7 @@ function ruleRender(){
|
||||
+ ' <button onclick="ruleDel('+r._uid+',this)">删除</button>'
|
||||
+ ' <button onclick="ruleInsBelow('+r._uid+')">下方插入</button>';
|
||||
return '<tr data-uid="'+r._uid+'">'
|
||||
+ '<td class="c">' + (ed?'<input class="rin rin-seq" value="'+esc(r.seq)+'" onchange="ruleSeq(this,'+r._uid+')">':esc(r.seq)) + '</td>'
|
||||
+ '<td class="c" style="color:#5b6b7e">' + esc(r.seq) + '</td>' /* 决策 156:序号不可编辑(自动编号,↑/↓调序) */
|
||||
+ '<td>' + (ed?'<input class="rin" value="'+esc(r.name||'')+'" onchange="ruleSet(this,'+r._uid+',\'name\')">':(esc(r.name||'')||'<span style="color:#b9c4d2">(未命名)</span>')) + '</td>'
|
||||
+ '<td>' + (ed?'<textarea class="rin ta" onchange="ruleSet(this,'+r._uid+',\'keywords\')">'+esc(r.keywords||'')+'</textarea>':(esc(r.keywords||'')||'<span style="color:#b9c4d2">—</span>')) + '</td>'
|
||||
+ '<td>' + (ed?'<textarea class="rin ta" onchange="ruleSet(this,'+r._uid+',\'exclude\')">'+esc(r.exclude||'')+'</textarea>':(esc(r.exclude||'')||'<span style="color:#b9c4d2">—</span>')) + '</td>'
|
||||
@@ -2473,11 +2673,6 @@ function ruleDel(uid, btn){
|
||||
}
|
||||
function ruleEdit(uid){ RULE_EDIT.add(uid); ruleRender(); }
|
||||
function ruleDone(uid){ RULE_EDIT.delete(uid); ruleNorm(); ruleRender(); }
|
||||
function ruleSeq(inp,uid){
|
||||
const r=RULES.find(x=>x._uid===uid); if(!r) return;
|
||||
let v=parseInt(inp.value,10); if(!Number.isFinite(v)||v<1) v=r.seq;
|
||||
r.seq=v; ruleNorm(); ruleRender();
|
||||
}
|
||||
function ruleSet(inp,uid,f){
|
||||
const r=RULES.find(x=>x._uid===uid); if(!r) return;
|
||||
r[f]=inp.value.replace(/^\s+|\s+$/g,'');
|
||||
@@ -2504,6 +2699,7 @@ async function cfgOpen(){
|
||||
RULES.forEach(r=>{ r._uid=++RULE_UID; if(!Number.isFinite(+r.seq)) r.seq=0; });
|
||||
RULE_EDIT=new Set(); ruleNorm(); ruleRender();
|
||||
await refreshHits();
|
||||
cfgTab('rules'); // 决策 155:打开时按当前页签回填底部用法帮助
|
||||
$('cfgmask').classList.add('on');
|
||||
}
|
||||
function cfgClose(){ $('cfgmask').classList.remove('on'); }
|
||||
@@ -2534,11 +2730,21 @@ function addStop(){
|
||||
}
|
||||
function delStop(w){ STOP = STOP.filter(x=>x!==w); renderStop(); }
|
||||
function cfgResetStop(){ STOP=[]; renderStop(); }
|
||||
/* 决策 155:用法帮助随页签切换,固定弹框最下方(原顶部长帮助按主人要求移此并改写文案) */
|
||||
const CFG_HELP = {
|
||||
rules: '用法:按序号优先匹配,如:混凝土,会把全部带混凝土的名称+项目特征全部组成一组,'
|
||||
+ '如不想出现“蒸压加气混凝土砌块”,需要增加“屏蔽词”“砌块”。'
|
||||
+ '如果单位必须为"m3",需在"单位(必)"填入"m3"。'
|
||||
+ '空格/逗号分开的多个词任一命中即可成组或者排除。',
|
||||
stop: '全局过滤词用法:类似清单的比对中这些词在「与入库项目比对」时会被忽略(不参与相似度计算)。'
|
||||
+ '点「添加」加入,每个词一个标签,点标签上的 × 可删除;输入框支持逗号 / 空格批量添加。'
|
||||
};
|
||||
function cfgTab(name){
|
||||
$('cfgdtab-rules').classList.toggle('on', name==='rules');
|
||||
$('cfgdtab-stop').classList.toggle('on', name==='stop');
|
||||
$('cfgTabProf').style.display = name==='rules' ? 'block' : 'none';
|
||||
$('cfgTabStop').style.display = name==='stop' ? 'block' : 'none';
|
||||
$('cfgHelp').textContent = CFG_HELP[name] || CFG_HELP.rules;
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -2547,7 +2753,6 @@ function cfgTab(name){
|
||||
<div class="dlg" style="width:min(1120px,94vw)">
|
||||
<div class="dh"><b>分组&过滤</b><span class="close" onclick="cfgClose()">×</span></div>
|
||||
<div style="padding:14px 16px;display:flex;flex-direction:column;gap:10px">
|
||||
<div class="tip" style="padding:0">对清单的分组进行定义,空格/逗号分开的多个词任一命中即可成组或者排除,每个关键词格内没有空格/逗号分开的词必须100%匹配。单位(必):填写后本条规则只收「单位」命中的清单(精确匹配,多个单位任一命中),其余清单照常走后续自动分组;不填=不限单位。</div>
|
||||
<div style="display:flex;gap:4px;border-bottom:2px solid var(--c1)">
|
||||
<div class="dtab on" id="cfgdtab-rules" onclick="cfgTab('rules')">分组设置</div>
|
||||
<div class="dtab" id="cfgdtab-stop" onclick="cfgTab('stop')">全局过滤词</div>
|
||||
@@ -2566,13 +2771,15 @@ function cfgTab(name){
|
||||
|
||||
<!-- 全局过滤词 -->
|
||||
<div id="cfgTabStop" style="display:none">
|
||||
<div class="tip" style="padding:0">类似清单的比对中这些词在「与入库项目比对」时会被<b>忽略</b>(不参与相似度计算)。点「添加」加入,每个词一个标签,点标签上的 × 可删除;输入框支持逗号 / 空格批量添加。</div>
|
||||
<div id="cfgStopChips" class="chips"></div>
|
||||
<div class="chip-add">
|
||||
<input id="cfgStopInput" class="chip-input" placeholder="输入过滤词,回车或点添加(可批量:逗号/空格分隔)" onkeydown="if(event.key==='Enter'){event.preventDefault();addStop();}">
|
||||
<button class="btn" onclick="addStop()">+ 添加</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用法帮助(决策 155:随页签切换,固定弹框最下方) -->
|
||||
<div class="tip" id="cfgHelp" style="padding:8px 10px;border-top:1px solid var(--line);background:#fafcff"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user