@@ -721,59 +762,272 @@ function rowPrice(r){ // 信息价 / 市场价:序号/纳入/名称/发布单
`;
}
-// 价格明细:左侧目录(一级:批次名 → 分类),右侧只显示当前选中的分类
-let PORDER=[], PGROUP={}, PATT={has:false}, PTITLE='', CURSEC=-1;
-// 左侧目录树的根(批次名)折叠状态:这两个必须定义,否则 renderPrice() 里引用会抛 ReferenceError,
-// 整个「价格明细」(表头 + 表体 + 统计)都会渲染不出来(2026-09-29 修)
-let TREE_FOLD=false;
-function toggleTree(){
- TREE_FOLD=!TREE_FOLD;
- const r=document.getElementById('treeRoot');
- if(r) r.classList.toggle('collapsed', TREE_FOLD);
+/* =========================================================================
+ 价格明细(2026-10-12 重做,主人定):
+ 左 = 本批次自己的多级目录树(单根=批次名;行内增删改名/上下移,↑↓✕ 两段式确认);
+ 右 = 选中目录的价格行(行内编辑/新增;**只有最底层目录可新增行**)。
+ 接口:GET /api/admin/batch/{id}/dirs 树 + 子树行数
+ GET /api/admin/batch/{id}/prices?dir_id&subtree 行(dict,subtree=1 含子孙)
+ POST /api/admin/batch/{id}/dirs {op:add|rename|move|seq|del, ...}
+ POST /api/admin/batch/{id}/prices {op:add|edit|del, ...}
+ 行编辑改 名称/规格/单位 后,服务端按导入同款口径重算比对键,工作台比对即刻生效。
+ ========================================================================= */
+const COL_PRICE=[
+ {t:'材料编码',a:'c',w:100},
+ {t:'材料名称',a:'l',w:180},
+ {t:'规格型号',a:'l',w:150},
+ {t:'单位',a:'c',w:56},
+ {t:'不含税单价',a:'r',w:96,num:1},
+ {t:'税率',a:'r',w:64,num:1},
+ {t:'含税单价',a:'r',w:96,num:1},
+ {t:'备注',a:'l',w:180},
+ {t:'操作',a:'c',w:100}
+];
+// 树 + 行的全部界面状态(换批次/换标签在 loadTab 价格分支复位)
+let PD={tree:[],counts:{},nUncat:0,cur:0,curName:'',curPath:'',curLeaf:true,picked:false,
+ rows:[],total:0,att:{has:false},
+ ren:0, // 正在改名的目录 id(0=无)
+ adding:null, // 新建目录:{parent, mode:'child'|'sib', sib}(sib=-1=插同级末尾)
+ cfm:null, // 待二次确认:{id, op:'up'|'down'|'del'}
+ cfmRow:0, // 待确认删除的行 id
+ editId:0, // 正在行内编辑的行 id(0=无)
+ addingRow:false}; // 底部新增行
+let PDMAP={}; // 目录 id → {name, leaf, parent, path}(渲染/取值用,renderTree 时重建)
+function pdClear(){ PD.ren=0; PD.adding=null; PD.cfm=null; PD.cfmRow=0; }
+
+async function loadPrice(){
+ $('ptool').style.display='flex';
+ const [d,a]=await Promise.all([J(`/api/admin/batch/${DID}/dirs`),
+ J(`/api/admin/batch/${DID}/attach`)]);
+ PD.tree=d.tree||[]; PD.counts=d.counts||{}; PD.nUncat=d.n_uncat||0; PD.att=a;
+ renderTree(); // 先建 PDMAP(名称/路径/叶子都从它取)
+ // 没选过(首次打开/换批次)→ 默认选第一个一级目录;选过的目录被删了 → 也落回第一个
+ if((!PD.picked || (PD.cur!==0 && !PDMAP[PD.cur])))
+ PD.cur = PD.tree.length ? PD.tree[0].id : 0;
+ const m=PDMAP[PD.cur];
+ PD.curName=m?m.name:'(未分类)';
+ PD.curPath=m?m.path:'';
+ PD.curLeaf=PD.cur===0?true:!!m.leaf;
+ await loadPriceRows();
}
-function renderPrice(){
- const cg=document.getElementById('dcg'), th=document.getElementById('dth'), tb=document.getElementById('dtbd');
- const head=document.getElementById('dsecH');
- // 三级:根(批次名) → 块 → 分类
- const byBlock={}, blocks=[];
- PORDER.forEach((s,i)=>{
- if(!(s.block in byBlock)){ byBlock[s.block]=[]; blocks.push(s.block); }
- byBlock[s.block].push({cls:s.cls, i:i, n:(PGROUP[s.key]||[]).length});
- });
- const kids = blocks.map(b=>{
- const secs = byBlock[b].map(x=>
- `
${esc(x.cls||'(未分类)')}
`
- ).join('');
- return `
- ▾${esc(b||'(未分块)')}
${secs}
`;
- }).join('');
- dside.innerHTML = PORDER.length
- ? `
-
▾${esc(PTITLE)}
- (${blocks.length} 块 · ${PORDER.length} 分类)
-
${kids}
-
`
- : '
(没有数据)
';
- cg.innerHTML=COL_PRICE.map(c=>`
`).join('');
- sumw($('dtb')); colwApply($('dtb'));
- th.innerHTML=headHTML(COL_PRICE);
- const cur=PORDER[CURSEC];
- const rows = cur ? (PGROUP[cur.key]||[]) : [];
- head.textContent = (cur ? (cur.block?cur.block+' / ':'') + (cur.cls||'(未分类)') : '(未分类)')
- + (rows.length?` 共 ${rows.length} 条`:'');
- tb.innerHTML = rows.map(r=>'
'+COL_PRICE.map(c=>cellHTML(c, r[c.k])).join('')+'
').join('')
- || `
| 没有数据 |
`;
- dcnt.innerHTML = `价格 ${PORDER.reduce((s,x)=>s+(PGROUP[x.key]||[]).length,0)} 条 · ${PORDER.length} 个分类` +
- (PATT.has ? ` · 原件:
${esc(PATT.name)}` : ' · 未挂附件');
+function dirExists(id){
+ return id===0 || !!PDMAP[id];
}
-function pickSec(i){
- CURSEC=i;
- dside.querySelectorAll('.secT').forEach((el,j)=>el.classList.toggle('on', j===i));
- renderPrice();
+async function loadPriceRows(){
+ renderTree();
+ const d=await J(`/api/admin/batch/${DID}/prices?page=1&page_size=5000&dir_id=${PD.cur}&subtree=1`);
+ PD.rows=d.rows||[]; PD.total=d.total||0;
+ renderRows();
document.getElementById('dright').scrollTop=0;
}
+async function pickDir(id){
+ PD.cur=id; PD.picked=true; PD.editId=0; PD.addingRow=false; pdClear();
+ const m=PDMAP[id];
+ PD.curName=m?m.name:'(未分类)';
+ PD.curPath=m?m.path:'';
+ PD.curLeaf=id===0?true:!!m.leaf;
+ await loadPriceRows();
+}
+function buildMap(ns,parent,path){
+ ns.forEach(n=>{
+ const p=path?path+' / '+n.name:n.name;
+ PDMAP[n.id]={name:n.name,leaf:!!n.leaf,parent:parent,path:p};
+ if(n.children&&n.children.length) buildMap(n.children,n.id,p);
+ });
+}
+function leavesHTML(sel){
+ const out=[];
+ (function walk(ns,p){ ns.forEach(n=>{
+ if(n.leaf) out.push({id:n.id,name:p?p+' / '+n.name:n.name});
+ if(n.children&&n.children.length) walk(n.children,p?p+' / '+n.name:n.name);
+ });})(PD.tree,'');
+ return '
'
+ + out.map(o=>`
`).join('');
+}
+/* ---- 树渲染:编辑态(改名/新建)与确认态(↑↓✕)都整树重画,状态在 PD ---- */
+function renderTree(){
+ PDMAP={}; buildMap(PD.tree,0,'');
+ const grand = PD.tree.length
+ ? PD.tree.reduce((s,n)=>s+(PD.counts[n.id]||0),0)+PD.nUncat
+ : PD.nUncat;
+ dside.innerHTML=`
+
+
▾${esc(dt.textContent)}
+ (${grand} 条)
+ +子目录
+
+
${renderNodes(PD.tree,0,0)}
+
+ (未分类)${PD.nUncat}
+
+
+ `;
+}
+function renderNodes(ns,parent,depth){
+ let h='';
+ ns.forEach(n=>{
+ h+=nodeHTML(n);
+ if(PD.adding&&PD.adding.mode==='sib'&&PD.adding.sib===n.id) h+=newNodeHTML(parent);
+ if(n.children&&n.children.length){
+ h+=`
${renderNodes(n.children,n.id,depth+1)}
`;
+ if(PD.adding&&PD.adding.mode==='child'&&PD.adding.parent===n.id) h+=`
${newNodeHTML(n.id)}
`;
+ }
+ });
+ if(PD.adding&&PD.adding.mode==='sib'&&PD.adding.sib===-1&&PD.adding.parent===parent) h+=newNodeHTML(parent);
+ return h;
+}
+function nodeHTML(n){
+ const cnt=PD.counts[n.id]||0, cur=PD.cur===n.id;
+ const stop='event.stopPropagation();';
+ let mid;
+ if(PD.ren===n.id){
+ mid=`
+
✓
+ ✕`;
+ } else if(PD.cfm&&PD.cfm.id===n.id){
+ const lbl=PD.cfm.op==='del'?'确认删除?':(PD.cfm.op==='up'?'确认上移?':'确认下移?');
+ mid=`
${esc(n.name)}${cnt}
+
${lbl}确认
+ 取消`;
+ } else {
+ mid=`
${esc(n.name)}${cnt}
+
+ +子
+ +平级
+ ✎
+ ↑
+ ↓
+ ✕
+ `;
+ }
+ return `
${mid}
`;
+}
+function newNodeHTML(parent){
+ const stop='event.stopPropagation();';
+ return `
+
+ ✓
+ ✕
`;
+}
+/* ---- 目录操作(全部走 POST /dirs;成功后刷新树 + 当前行表)---- */
+async function dirPost(body){
+ const r=await J(`/api/admin/batch/${DID}/dirs`,{method:'POST',headers:{'Content-Type':'application/json'},
+ body:JSON.stringify(body)});
+ if(!r.ok){ alert(r.msg); return false; }
+ pdClear();
+ const d=await J(`/api/admin/batch/${DID}/dirs`);
+ PD.tree=d.tree||[]; PD.counts=d.counts||{}; PD.nUncat=d.n_uncat||0;
+ if(!dirExists(PD.cur)) PD.cur = PD.tree.length ? PD.tree[0].id : 0;
+ const m=PDMAP[PD.cur];
+ PD.curName=m?m.name:'(未分类)'; PD.curPath=m?m.path:''; PD.curLeaf=PD.cur===0?true:!!m.leaf;
+ await loadPriceRows();
+ return true;
+}
+function dirAddRoot(){ PD.ren=0; PD.cfm=null; PD.adding={parent:0,mode:'sib',sib:-1}; renderTree(); const i=$('pnew'); if(i) i.focus(); }
+function dirAddChild(id){ PD.ren=0; PD.cfm=null; PD.adding={parent:id,mode:'child',sib:0}; renderTree(); const i=$('pnew'); if(i) i.focus(); }
+function dirAddSib(id){ PD.ren=0; PD.cfm=null; const p=PDMAP[id].parent; PD.adding={parent:p,mode:'sib',sib:id}; renderTree(); const i=$('pnew'); if(i) i.focus(); }
+function dirRen(id){ PD.adding=null; PD.cfm=null; PD.ren=id; renderTree(); const i=$('pren'); if(i){ i.focus(); i.select(); } }
+function dirCfm(id,op){ PD.ren=0; PD.adding=null; PD.cfm={id:id,op:op}; renderTree(); }
+function dirRenSave(id){
+ const i=$('pren'); if(!i||!i.value.trim()){ alert('目录名称不能为空'); return; }
+ dirPost({op:'rename',id:id,name:i.value.trim()});
+}
+function dirAddSave(parent){
+ const i=$('pnew'); if(!i||!i.value.trim()){ alert('目录名称不能为空'); return; }
+ dirPost({op:'add',parent:parent,name:i.value.trim()}).then(ok=>{ if(ok) pickDir(PD.cur); });
+}
+async function dirGo(id,op){
+ // ↑↓ 在服务端是同一个 op=seq(dir=up/down),rename/add/move/del 同名同参
+ const body = (op==='up'||op==='down') ? {op:'seq', id:id, dir:op} : {op:op, id:id};
+ return dirPost(body);
+}
+/* ---- 右侧行表 ---- */
+function renderRows(){
+ const cg=$('dcg'), th=$('dth'), tb=$('dtbd');
+ cg.innerHTML=COL_PRICE.map(c=>`
`).join('');
+ th.innerHTML='
'+COL_PRICE.map(c=>`| ${c.t} | `).join('')+'
';
+ // 工具行状态:新增行只在最底层目录可用;编辑/新增时显示「所属目录」下拉
+ const b=$('padd');
+ if(PD.curLeaf){ b.classList.remove('dis'); b.disabled=false; b.title=''; }
+ else { b.classList.add('dis'); b.disabled=true; b.title='请选择最底层目录(没有子目录的目录)再新增行'; }
+ const editing=PD.editId||PD.addingRow;
+ $('ptool').classList.toggle('editing', !!editing);
+ if(editing) $('pdirsel').innerHTML=leavesHTML(PD.editId?curEditDir():PD.cur);
+ $('pwhere').textContent = PD.curLeaf ? `当前:${PD.curName}(最底层目录,可挂价格行)`
+ : `当前:${PD.curName}(含子目录,仅查看)`;
+ $('dsecH').style.display='block';
+ $('dsecH').innerHTML = esc(PD.curPath || PD.curName)
+ + `
${PD.curLeaf?'':'(含子目录汇总) '}共 ${PD.total} 条`;
+ tb.innerHTML=PD.rows.map(rowHTML).join('')
+ + (PD.addingRow?newRowHTML():'');
+ if(!PD.rows.length&&!PD.addingRow)
+ tb.innerHTML=`
| 没有数据 |
`;
+ // 底部统计(.pager 的 #dcnt):批次总条数 + 原件
+ const grand=PD.tree.reduce((s,n)=>s+(PD.counts[n.id]||0),0)+PD.nUncat;
+ dcnt.innerHTML=`价格 ${grand} 条` +
+ (PD.att.has ? ` · 原件:
${esc(PD.att.name)}` : ' · 未挂附件');
+}
+function curEditDir(){
+ const r=PD.rows.find(x=>x.id===PD.editId);
+ return r?(r.dir_id||0):PD.cur;
+}
+function cellOut(v,cls){
+ return `
${(v===null||v===undefined||v==='')?'—':esc(v)} | `;
+}
+function rowHTML(r){
+ if(PD.editId===r.id){
+ const v=['Code','Name','Specification','Unit','NoTaxPrice','TaxRate','TaxPrice','Note'].map(k=>r[k]==null?'':r[k]);
+ return `
${['编码(选填)','名称(必填)','规格','单位','不含税价','税率','含税价','备注'].map((ph,i)=>
+ ` | `).join('')}
+ ✓ 保存
+ ✕ 取消 |
`;
+ }
+ const del = PD.cfmRow===r.id
+ ? `
确认删除?取消`
+ : `
编辑删除`;
+ return `
${cellOut(r.Code,'c')}${cellOut(r.Name,'l')}${cellOut(r.Specification,'l')}${cellOut(r.Unit,'c')}
+ ${cellOut(r.NoTaxPrice,'r')}${cellOut(r.TaxRate,'r')}${cellOut(r.TaxPrice,'r')}${cellOut(r.Note,'l')}
+ | ${del} |
`;
+}
+function newRowHTML(){
+ const ph=['编码(选填)','名称(必填)','规格','单位','不含税价','税率','含税价','备注'];
+ return `
${ph.map((p,i)=>` | `).join('')}
+ ✓ 保存
+ ✕ 取消 |
`;
+}
+function rowNew(){
+ if(!PD.curLeaf){ alert('只有最底层目录才可以挂价格行。请先选择(或新建)最底层目录。'); return; }
+ PD.editId=0; PD.addingRow=true; PD.cfmRow=0; renderRows();
+ const i=$('pe1'); if(i) i.focus();
+}
+function rowEdit(id){ PD.editId=id; PD.addingRow=false; PD.cfmRow=0; renderRows(); }
+function rowCancel(){ PD.editId=0; PD.addingRow=false; renderRows(); }
+function rowDel(id){ PD.cfmRow=id; PD.editId=0; PD.addingRow=false; renderRows(); }
+async function rowDelGo(id){
+ const r=await J(`/api/admin/batch/${DID}/prices`,{method:'POST',headers:{'Content-Type':'application/json'},
+ body:JSON.stringify({op:'del',id:id})});
+ if(!r.ok){ alert(r.msg); return; }
+ PD.cfmRow=0; await loadPrice();
+}
+async function rowSave(){
+ const g=i=>{ const e=$('pe'+i); return e?e.value.trim():''; };
+ const body={ op: PD.editId?'edit':'add',
+ id: PD.editId||undefined,
+ code:g(0),name:g(1),spec:g(2),unit:g(3),
+ notax:g(4),taxrate:g(5),taxprice:g(6),note:g(7),
+ dir_id: parseInt(($('pdirsel')&&$('pdirsel').value)||PD.cur||0,10) };
+ const r=await J(`/api/admin/batch/${DID}/prices`,{method:'POST',headers:{'Content-Type':'application/json'},
+ body:JSON.stringify(body)});
+ if(!r.ok){ alert(r.msg); return; }
+ PD.editId=0; PD.addingRow=false;
+ await loadPrice();
+}
+function pdExport(){ saveAs(`/api/admin/batch/${DID}/export`, (dt.textContent||'价格批次')+'.zip'); }
async function tog(id,cur){
await J(`/api/admin/batch/${id}/enabled`,{method:'POST',headers:{'Content-Type':'application/json'},
@@ -812,31 +1066,11 @@ function almeRender(){
document.getElementById('dtbd').innerHTML=renderLme(view, WB_OPTS)
||`
| 没有数据 |
`;
}
-// 价格明细:**与上传的 HTML 一模一样**——按分类分组(分类标题=目录),列为 HTML 那 8 列
-const COL_PRICE=[
- {t:'材料编码',a:'c',w:110,k:0},
- {t:'材料名称',a:'l',w:210,k:1},
- {t:'规格型号',a:'l',w:200,k:2},
- {t:'单位',a:'c',w:64,k:3},
- {t:'不含税单价',a:'r',w:106,num:1,k:4},
- {t:'税率',a:'r',w:76,num:1,k:5},
- {t:'含税单价',a:'r',w:106,num:1,k:6},
- {t:'备注',a:'l',w:230,k:8} // k = 接口返回行里的下标(0..6 前七列,8=备注;7=目录,用作分组标题)
-];
-// 定额(挂在清单下):定额编码 / 定额名称 / 单位 / 单价
+// 定额(挂在清单下):定额编码 / 定额名称 / 单位 / 单价(COL_PRICE 已上移进价格明细模块,2026-10-12)
const COL_NORM=[{t:'定额编码',a:'c',w:130},{t:'定额名称',a:'l',w:300},
{t:'单位',a:'c',w:64},{t:'单价',a:'r',w:110,num:1}];
// headHTML / colgHTML 由 common.js 提供(数组式与对象式列定义都支持)
-// cellHTML 仅价格明细(对象式 k 下标映射)用到,保留在本页
-function cellHTML(c,v){
- if(c.a==='tg') return '
| ';
- if(c.dash) return '
— | ';
- if(c.a==='attr') return `
${esc(fmtAttr(v))} | `;
- if(c.num) return `
${num(v)} | `;
- if(c.a==='c') return `
${esc(v)} | `;
- return `
${esc(v)} | `;
-}
// 4 个标签:与工作台同一份(common.js TABS),默认停在「原数据」
document.addEventListener('DOMContentLoaded', function(){ $('dtabs').innerHTML = tabsHTML(); });
@@ -867,7 +1101,6 @@ async function det(id,name){
dbody.classList.toggle('fx', isPrice);
dside.style.display = isPrice?'block':'none';
document.getElementById('dsecH').style.display = isPrice?'block':'none';
- CURSEC = isPrice ? 0 : -1;
// 注:后台类似清单已固定走「系统默认(按名称聚类)」分组,不再读专业 / 不再显示专业下拉
// (2026-10-01 主人定:后台是历史检索口,统一自动聚类比让操作者选专业更稳)
mask.classList.add('on');
@@ -901,22 +1134,12 @@ async function loadTab(pid){
document.querySelectorAll('#mask .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'){
- // 面板复位(兜底,见 det() 里的注释):价格明细只有左目录 + 右一张表,
+ // 面板复位(兜底,见 det() 里的注释):价格明细只有左目录树 + 右一张表,
// 「原数据」的写树 / 四个标签卡必须关掉,否则会和价格表抢同一个 dright 的高度。
$('drawbox').style.display='none';
$('dtb').style.display='';
- const [d,a]=await Promise.all([J(`/api/admin/batch/${DID}/prices?page=1&page_size=5000`),
- J(`/api/admin/batch/${DID}/attach`)]);
- document.getElementById('n0').textContent=d.total+' 条';
- // 按「目录(=分类标题)」分组,保持入库顺序
- const order=[], g={};
- d.rows.forEach(r=>{
- const blk=(r[9]||'').trim(), cls=(r[7]||'').trim(), key=blk+'||'+cls;
- if(!(key in g)){ g[key]=[]; order.push({block:blk, cls:cls, key:key}); }
- g[key].push(r);
- });
- PORDER=order; PGROUP=g; PATT=a; PTITLE=dt.textContent;
- renderPrice();
+ PD.editId=0; PD.addingRow=false; pdClear(); // PD.cur 不复位:换批次由 loadPrice 自愈落首个一级目录
+ await loadPrice(); // 2026-10-12 重做:多级目录树 + 行内编辑(见 loadPrice/renderTree/renderRows)
return;
}
// ---- 原数据(p3):与工作台同一套结构 + 同一份 RawView 渲染,只换接口 ----
@@ -984,19 +1207,17 @@ async function openImp(){
document.getElementById('irowNote').style.display = isPrice?'flex':'none';
document.getElementById('irowPub').style.display = isPrice?'flex':'none';
document.getElementById('irowPdf').style.display = isPrice?'flex':'none';
- ipdf.value=
+ ipdf.value='';
// 每次只能导入一个文件:从你自己电脑的任意位置选,选完会传进软件目录
ifile.value=''; UPF=null;
iname.value=''; iname.dataset.auto=''; // 每次重新带出文件名
- // 价格类三种都收:HTML 原件 + Excel(.xlsx 新格式 / .xls 老格式)
- // 工程类只认计价文件 **.cos4 / .cos**(主人 2026-10-06):原来的 .xml 一并去掉,
- // 因为服务端 EXT_OK 里也没有 .xml,收进来同样是"打不开",等于给用户一个假选项。
- ifile.accept = isPrice ? '.html,.htm,.xlsx,.xls' : '.cos4,.cos';
+ // 2026-10-12 重设计(主人定):价格类**只收标准模板 .xlsx**(HTML 导入退役);
+ // 工程类只认计价文件 **.cos4 / .cos**(主人 2026-10-06)。
+ ifile.accept = isPrice ? '.xlsx' : '.cos4,.cos';
document.getElementById('ifileInfo').textContent='';
document.getElementById('irowTip').textContent = isPrice
- ? '信息价/市场价:HTML 原件 或 Excel(.xlsx / .xls,每次一个)+ 附件(任意格式,选填)。'
- + '名称 / 地区 必填;期次留空时会自动从块名或文件名里认(如「珠海信息价_2026年7月」→ 2026-07)。'
- + '一个文件含多个市场(多个 sheet / 多个块)时会拆成多个批次,各带各的期次。'
+ ? '信息价/市场价:只收「标准模板」Excel(.xlsx,每次一个)+ 附件原件(任意格式,选填)。'
+ + '名称留空或点文件后自动带出文件名(可改);期次留空时自动从文件名里认(如「珠海信息价_2026年7月」→ 2026-07)。'
: '工程:选择一个 .cos4 或 .cos 文件(可从电脑任意位置选,每次只能一个)。全部必填。';
imsg.textContent='';
await loadImpFilters();
@@ -1009,14 +1230,12 @@ async function pickFile(inp){
const r = await uploadFile('/api/admin/upload', f);
if(!r.ok){ info.textContent='× '+r.msg; UPF=null; return; }
UPF=r;
- // 价格类三种都收:HTML 原件 + Excel(.xlsx 新格式 / .xls 老格式)
- // ⚠️ 之前这里只认 price_html,Excel 选完直接被判「不是信息价 HTML」——导入功能等于没有。
- const ok = (KIND!=='project')
- ? (r.state==='price_html' || r.state==='price_xlsx')
- : (r.state==='zip'||r.state==='xml');
+ // 2026-10-12 重设计:价格类只认标准模板 Excel;工程类只认 .cos4/.cos
+ const ok = (KIND!=='project') ? (r.state==='price_xlsx')
+ : (r.state==='zip'||r.state==='xml');
info.textContent = ok
? `已选:${r.name}(${(r.size/1048576).toFixed(2)} MB)· 已存进软件目录`
- : `已选:${r.name},但这不是${KIND!=='project'?'信息价/市场价文件(HTML 或 Excel)':'计价工程文件'},无法导入`;
+ : `已选:${r.name},但这不是${KIND!=='project'?'标准模板 Excel(请点「标准模板」按钮下载后填写)':'计价工程文件'},无法导入`;
// 名称默认 = 文件名(去掉扩展名),与工作台「打开工程」一致;手动改过就不再覆盖
const stem = f.name.replace(/\.[^.]+$/,'');
if(!iname.value.trim() || iname.dataset.auto==='1') iname.value = stem;
@@ -1055,7 +1274,7 @@ function kindOptions(kinds, cur){
async function doImport(){
const isPrice = (KIND!=='project');
const miss=[];
- if(!UPF) miss.push(isPrice?'HTML 文件(每次只能一个)':'文件(每次只能一个)');
+ if(!UPF) miss.push(isPrice?'标准模板 Excel 文件(每次只能一个)':'文件(每次只能一个)');
if(!iname.value.trim()) miss.push('名称');
if(!iprov.value||!icity.value||!idist.value) miss.push('地区(省/市/区)');
const pv=PVAL($('iper'));
diff --git a/CostReview/app/ui/sessions.html b/CostReview/app/ui/sessions.html
index a894c27..b10bc02 100644
--- a/CostReview/app/ui/sessions.html
+++ b/CostReview/app/ui/sessions.html
@@ -39,7 +39,8 @@ a:hover{text-decoration:underline}
@@ -144,7 +145,7 @@ function delSel(){
del(ITEMS.filter(x=>rep.includes(x.id)).flatMap(x=>(x.all||[]).map(a=>a.id)));
}
-function go(id){ location.href='/workbench.html?sid='+id; }
+function go(id){ location.href='/workbench.html?sid='+id+'&t='+Date.now(); }
/* 2026-09-30 主人定:落地页每行**只留「打开」+「删除」**,去掉「重新解析」按钮。
它只在解析器更新后才需要,不该占日常位置。
⚠️ 去掉之后的替代路径:**删掉这个会话 → 重新打开工程**(走一遍全新解析,数据就是新的),
diff --git a/CostReview/app/ui/workbench.html b/CostReview/app/ui/workbench.html
index 28fef59..a035583 100644
--- a/CostReview/app/ui/workbench.html
+++ b/CostReview/app/ui/workbench.html
@@ -261,7 +261,8 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
-
后台管理
+
+
后台管理
diff --git a/测试计划.md b/测试计划.md
index 3bdcae5..0a71b74 100644
--- a/测试计划.md
+++ b/测试计划.md
@@ -180,3 +180,28 @@ L1 单元测试(pytest,内存 SQLite) ← 解析/归一化/匹配/分
- 分层策略参考测试金字塔与"测服务不测壳"思路:[Test Guild 桌面自动化工具对比](https://testguild.com/Blog/Automation%20Testing)、[sqa.stackexchange 社区讨论](https://sqa.stackexchange.com/questions)
- 测试管理工具/资源索引:[hanzhichao/awesome-testing](https://github.com/hanzhichao/awesome-testing)(TestLink/禅道等,若后续要管用例库可选用;当前规模用本 md + pytest 足够)
- 测试计划制定步骤参考:[Hanlen520/Software-Testing](https://github.com/Hanlen520/Software-Testing)
+
+---
+
+## 8. 执行进度(2026-10-12 第二轮更新)
+
+**自动化测试 143 条全绿(14.5s)**,生产库零接触(夹具把 app 拷进临时目录起独立服务)。跑法:`cmd /c ".venv\Scripts\python.cmd -m pytest CostReview\app\tests -q"`
+
+| 文件 | 层 | 条数 | 覆盖 |
+|---|---|---|---|
+| `tests/test_license_*` + `test_wipe.py`(原有) | L1 | 96 | 验签/租约/心跳/加固/清场 |
+| `tests/test_unit_core.py`(新) | L1 | 14 | norm/md5/clean_attr(含小数点护栏)/sniff/期次识别/字集键/lme_list_where 的 CAST 坑/parse_std 结构/价格 HTML+Excel 解析 |
+| `tests/test_match_tiers.py`(新) | L1 | 6 | 四档匹配逐档验证:精确、次精确+名称护栏、字集等价、模糊 0.60、x_enabled 排除、自过滤、期次距离排序与窗口 |
+| `tests/test_api_p0.py`(新) | L2 | 13 | 导入(含加密/乱码/xml/越权拒绝、重复确认)、会话原地续用(**防翻倍回归**)+备注双写回填、比对自排除、工料机比对、检索、删除级联、行内编辑白名单 |
+| `tests/test_api_p1.py`(新) | L2 | 10 | 上传去重、价格原件挂接、询价附件全生命周期、采纳收集、批次纳入排除、清空模拟数据、字典 CRUD、信息价 HTML+Excel 导入(块期次识别、Excel/HTML 同口径互命中) |
+| `tests/test_api_group.py`(新) | L2 | 3 | 分组 v2 条数守恒(不多不少不重复)、名称层字集并组、关键词层规则(首匹配+排除词)、组价不一致、组排序 |
+| `tests/test_api_upgrade.py`(新) | L2 | 3 | 旧口径批次自动升级:后台手动升级、打开即升级(须走 uploads 流程,护栏核对内容哈希)、价格批次拒绝升级 |
+
+### 本轮测试抓到并已修复的缺陷
+
+1. **【已修复】同名工程二次打开清单翻倍**:`/api/audit` 原地续用路径漏了 wipe(注释声称"wipe 后重写"但代码没做),二次打开会在旧清单上叠加,分组/检索/比对全部失真。修复:api_server.py 续用分支补 `sess.wipe(con, sid)`(同一事务,解析失败自动回滚不丢旧数据)。回归用例:test_api_p0 防翻倍断言。
+ **存量数据**:生产会话库 3 号会话《南屏水库项目(二期)》有 24 对历史重复清单(14,966 条中)——**用修复后的版本重新打开一次该工程即自愈**(备注按 rkey 自动回填,不丢)。
+2. **【待处理】多块价格文件重复导入不触发确认**:`find_dup` 按弹框名比对,多块文件落库名是块名,同文件重导静默产生重复批次(单块正常)。建议查重改按块名或 `x_src_hash`。
+3. **【观察】Excel 解析 str(None) 陷阱**:openpyxl 只读模式整行空单元格返回 None,`str(None)` 被当非空保留空行——无害(to_records 跳过空名行),但解析层值得留意。
+
+**下一步**(按优先级):L3 Playwright 前端冒烟(三页面主流程)→ 专项A 性能(testdata 大库)→ 专项B 安全(origin/路径穿越/280MB 上限)→ 迁移链混合口径库用例。