diff --git a/CostReview/app/core/match.py b/CostReview/app/core/match.py index d2174f9..980f500 100644 --- a/CostReview/app/core/match.py +++ b/CostReview/app/core/match.py @@ -384,11 +384,21 @@ 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, projs=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, pmin=None, pmax=None, att="all"): 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, projs=projs) # classes 只对价格库有意义,清单比对不筛目录 + # 决策 208(2026-10-26 主人定):价格范围/附件筛选清单侧同样生效(工具栏恒显最大集)—— + # 价格=b.Price(NULL 自然不落区间);附件=bill_attach 绑定的询价资料(与 api_search 回填 file 同一来源)。 + if pmin is not None: + w += " AND b.Price>=?"; args = args + [pmin] + if pmax is not None: + w += " AND b.Price<=?"; args = args + [pmax] + if att == "yes": + w += " AND EXISTS(SELECT 1 FROM bill_attach ba WHERE ba.bill_id=b.id)" + elif att == "no": + w += " AND NOT EXISTS(SELECT 1 FROM bill_attach ba WHERE ba.bill_id=b.id)" out, seen_ids, qn = [], set(), norm_match(row["Name"]) # L0 精确:编码+名称+单位(b.id 带回 → 前端展开定额 / 右栏「定额编码·名称」用)。 # 2026-10-10 决策 27:哈希里的编码只取前 9 位(后 3 位是项目内顺序码,没有对比意义), @@ -470,7 +480,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, projs=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, pmin=None, pmax=None, att="all"): """独立检索(2026-10-08 主人定第 4 轮 B 方案):跨**全部入库项目**(kind='project')按 条件+关键词 直查清单库,与工作台选中的行无关(主人:"搜索条件高于点选清单")。 行结构与 match_bill() 完全一致 —— 前端 renderHist / 右栏 / ± 展开零改动复用,差异只有: @@ -480,10 +490,19 @@ def hist_search(hist, kinds, units, area, pfrom, pto, kw, limit=200, self_name=N self_name/self_src:被审工程自己(若它也入库了)**排除**(2026-10-08 主人定), 判定与 match_bill/match_lme 同一套(_self_filter 口径):同一份文件(x_src_hash 相同) 或项目名相同。 - page:分页(2026-10-08 主人定,每页=limit 条,第 N 页 OFFSET (N-1)×limit)。""" + page:分页(2026-10-08 主人定,每页=limit 条,第 N 页 OFFSET (N-1)×limit)。 + pmin/pmax/att:决策 208(2026-10-26 主人定)清单侧同生效——价格=b.Price,附件=bill_attach。""" c = hist.cursor() cond, args = _filters(kinds, units, [], prefix="bt", projs=projs) # 批次级条件(拼好的 SQL 串 + 参数) extra = [] + if pmin is not None: + extra.append("b.Price>=?"); args = args + [pmin] + if pmax is not None: + extra.append("b.Price<=?"); args = args + [pmax] + if att == "yes": + extra.append("EXISTS(SELECT 1 FROM bill_attach ba WHERE ba.bill_id=b.id)") + elif att == "no": + extra.append("NOT EXISTS(SELECT 1 FROM bill_attach ba WHERE ba.bill_id=b.id)") nm = (self_name or "").strip() src = (self_src or "").strip() if src or nm: diff --git a/CostReview/app/server/api_server.py b/CostReview/app/server/api_server.py index aca87dd..ce9480b 100644 --- a/CostReview/app/server/api_server.py +++ b/CostReview/app/server/api_server.py @@ -5184,7 +5184,10 @@ def api_search(body): body.get("classes") or [], limit, srcs, pf, pt, None if scope_self else self_name, None if scope_self else self_src, - area, projs=body.get("projs") or []) + area, projs=body.get("projs") or [], + pmin=_num_or_none(body.get("pmin")), + pmax=_num_or_none(body.get("pmax")), + att=body.get("att") or "all") # 决策 208:价格范围/附件清单侧同生效 # 规格 20:本组其他清单的批次记录(bill_id 集合)——组价不一致对比按它过滤 allowed = None if scope_self and members is not None: @@ -5445,7 +5448,10 @@ def api_hist_search(body): 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"))) + stop=match.stop_words(body.get("stop")), + pmin=_num_or_none(body.get("pmin")), + pmax=_num_or_none(body.get("pmax")), + att=body.get("att") or "all") # 决策 208:价格范围/附件清单侧同生效) finally: hist.close() for r in res: # 单价类型码 → 名称(0/空=未标注 → 前端显示 —) diff --git a/CostReview/app/ui/workbench.html b/CostReview/app/ui/workbench.html index bff4b7a..98b9f5d 100644 --- a/CostReview/app/ui/workbench.html +++ b/CostReview/app/ui/workbench.html @@ -108,6 +108,7 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none} #histbar .hbl{font-size:12px;color:#456;white-space:nowrap} #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 .hb:disabled,#histbar select:disabled{opacity:.45;cursor:not-allowed} /* 决策 208:清单上下文来源置灰 */ #histbar > *{flex:0 0 auto} /* 决策 143:子项禁收缩——按钮不被压到换行;余量由搜索/屏蔽词弹性吸收 */ #histbar > .combo{flex:1 1 90px;min-width:0} /* 决策 143:搜索/屏蔽词的小叉壳层在顶层,弹性吸收余量(单位/项目名称的壳在 .fld 里不受此限) */ #histbar > .combo[data-for="fstop"]{flex:0 0 150px} /* 决策 167:屏蔽词定宽 150px(主人定;165 为 60px)且禁压缩 */ @@ -398,8 +399,9 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none} 搜索框无值:点上方清单行→清单匹配搜索,左侧条件即改即查(原方式),查询按钮置灰无效; 搜索框有值:条件改动只记录,点「查询」按 条件+关键词 出结果;清空关键词→自动重查回比对方式。 折叠入口只剩上沿分隔条正中的小把手(#hgrip .hbtn)。 --> - -