feat(price): 信息价/市场价重设计——目录树+行内编辑+只收标准模板+导出一份数据(决策42)

- schema: 新增 price_dirs 目录树(批次级单根/多级/仅叶挂行),prices.dir_id;Class 冗余完整路径文本
- 导入只收标准模板 xlsx:表头严格校验(HTML/别名/多sheet拆批退役);名称默认=文件名可改;期次从文件名认
- 后台明细页重做:左树行内增删改名/上下移(↑↓✕两段式确认、选中按钮常显),右表行内新增/编辑(重算比对键即刻生效)
- 导出 zip = 价格明细.xlsx(目录路径+批次信息页签)+ 附件原件,导入可复原
- 壳/跨页跳转带版本参数根治 WebView2 旧缓存;导入弹框文件框只收 .xlsx
- 附 P0/P1 接口测试夹具与价格重设计回归(新增 test_price_redesign 等 8 件,全套 148 项绿)
This commit is contained in:
lianjianwei2024
2026-10-13 08:35:34 +08:00
parent 7fb7969a2f
commit dd6bd24018
17 changed files with 2465 additions and 324 deletions

View File

@@ -168,6 +168,38 @@ a:hover{text-decoration:underline}
#dright{flex:1;overflow:auto;min-width:0}
#dright .secH{padding:10px 14px;font-size:14px;font-weight:700;color:#111827;background:#fafbfc;
border-bottom:1px solid var(--line);position:sticky;top:0}
/* ===== 价格明细重做(2026-10-12):多级目录树 + 行内编辑 ===== */
.pnode{padding:4px 6px;margin:1px 0;cursor:pointer;border-radius:6px;color:#374151;font-size:12.5px;
display:flex;align-items:center;gap:5px;white-space:nowrap}
.pnode .nm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}
.pnode .cnt{color:#9aa4b2;font-size:11px;flex:none}
.pnode:hover{background:#f3f4f6}
.pnode.on{background:#2563eb;color:#fff}
.pnode.on .cnt{color:#dbe7ff}
.pnode .ops{display:none;flex:none;gap:2px}
.pnode:hover .ops,.pnode.ops-on .ops,.pnode.on .ops{display:inline-flex}
/* ↑ 选中目录的按钮排常显(2026-10-13 主人找不到"+子目录"入口):
悬停可见照旧,选中的那一行不用悬停也能看到全部按钮 */
.pnode .ops span{min-width:17px;height:17px;padding:0 2px;border-radius:4px;background:#fff;border:1px solid #c9d4e2;
color:#34506f;font-size:11px;line-height:15px;text-align:center;cursor:pointer;white-space:nowrap}
.pnode .ops span:hover{background:var(--c2);color:#fff;border-color:var(--c2)}
.pnode .ops span.pd:hover{background:#c0392b;border-color:#c0392b} /* 删除 / 取消:红 */
.pnode .ops span.pk:hover{background:#1a7f37;border-color:#1a7f37} /* 确认:绿 */
.pnode input.ren{width:120px;padding:1px 6px;font-size:12px;border-radius:4px;border:1px solid #9fb6d4}
.pnode .cfm{display:inline-flex;gap:3px;align-items:center;background:#fff7e6;border:1px solid #f0d9a8;
border-radius:4px;padding:1px 4px;font-size:11px;color:#8a6d1a;flex:none}
.pkids{margin-left:12px;border-left:1px dotted #cbd5e1;padding-left:4px}
#ptool{display:flex;align-items:center;gap:8px;padding:9px 14px;background:#fafcff;
border-bottom:1px solid var(--line);flex-wrap:wrap}
#ptool .where{font-size:12px;color:#34506f;background:#eef3fa;border:1px solid #d8e0ec;border-radius:4px;padding:2px 8px}
#ptool .tgt{display:none;align-items:center;gap:6px;font-size:12px;color:#8a6d1a;
background:#fff7e6;border:1px solid #f0d9a8;border-radius:4px;padding:2px 8px}
#ptool.editing .tgt{display:inline-flex}
.btn.dis{color:#9aa4b2;background:#f4f6f9;cursor:not-allowed;border-color:#d8e0ec}
tr.pedit{background:#fffbef}
td.pcell input{width:100%;padding:3px 7px;font-size:12.5px;border:1px solid #9fb6d4;border-radius:4px}
.newflag{display:inline-block;margin-left:6px;padding:0 5px;border-radius:3px;background:#fff7e6;
border:1px solid #f0d9a8;color:#8a6d1a;font-size:11px}
</style>
<link rel="stylesheet" href="common.css">
</head>
@@ -191,7 +223,8 @@ a:hover{text-decoration:underline}
<!-- 工作台入口(2026-10-06 主人定):从标题行右上角搬到标签栏,排在「设置」右边。
图标 ▶ = 进入另一个页面(⚙ = 当前页设置);两者底部对齐、圆角一致,
按钮比标签矮约 3px,只靠颜色区分主动作(蓝=进入,灰=设置)。 -->
<a class="btn pri" style="text-decoration:none" href="/workbench.html"
<!-- 时间戳参数:老 WebView2 对 no-store 不完全遵守,跨页跳转带新 URL 强制绕缓存(2026-10-12) -->
<a class="btn pri" style="text-decoration:none" href="javascript:location.href='/workbench.html?v='+Date.now()"
title="打开工作台:导入工程、做历史比对与审核">▶ 工作台</a>
</div>
@@ -249,6 +282,14 @@ a:hover{text-decoration:underline}
<!-- 类似清单(p2)的左组目录树(2026-10-08 主人定:后台同工作台;仅该标签显示) -->
<div id="simtree" style="display:none"></div>
<div id="dright">
<!-- 价格明细工具行(2026-10-12 重做):只有价格批次显示;行编辑/新增时出现「所属目录」下拉 -->
<div id="ptool" style="display:none">
<button class="btn pri" id="padd" onclick="rowNew()">+ 新增行</button>
<span class="where" id="pwhere"></span>
<span class="tgt">所属目录:<select id="pdirsel" style="max-width:260px"></select></span>
<button class="btn" onclick="pdExport()">⤓ 导出</button>
<button class="btn" onclick="att(DID)">📎 附件</button>
</div>
<div id="dsecH" class="secH" style="display:none"></div>
<!-- 原数据(p3):结构与工作台一致(左树 + 右标签卡),渲染由 common.js 的 RawView 提供 -->
<div id="drawbox" class="rawbox" style="display:none">
@@ -721,59 +762,272 @@ function rowPrice(r){ // 信息价 / 市场价:序号/纳入/名称/发布单
</tr>`;
}
// 价格明细:左侧目录(一级:批次名 → 分类),右侧只显示当前选中的分类
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=>
`<div class="secT ${x.i===CURSEC?'on':''}" onclick="pickSec(${x.i})" title="${esc(x.cls)}">${esc(x.cls||'(未分类)')}</div>`
).join('');
return `<div class="blk"><div class="blab" onclick="this.parentNode.classList.toggle('fold')">
<span class="ar">▾</span>${esc(b||'(未分块)')}</div><div class="bkids">${secs}</div></div>`;
}).join('');
dside.innerHTML = PORDER.length
? `<div class="tot${TREE_FOLD?' collapsed':''}" id="treeRoot">
<div class="lab" onclick="toggleTree()"><span class="ar">▾</span>${esc(PTITLE)}
<span style="font-weight:400;color:#6b7280">(${blocks.length} 块 · ${PORDER.length} 分类)</span></div>
<div class="children">${kids}</div>
</div>`
: '<div class="treeT">(没有数据)</div>';
cg.innerHTML=COL_PRICE.map(c=>`<col style="width:${c.w}px">`).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=>'<tr>'+COL_PRICE.map(c=>cellHTML(c, r[c.k])).join('')+'</tr>').join('')
|| `<tr><td colspan="${COL_PRICE.length}" class="tip" style="text-align:center;padding:16px">没有数据</td></tr>`;
dcnt.innerHTML = `价格 ${PORDER.reduce((s,x)=>s+(PGROUP[x.key]||[]).length,0)} 条 · ${PORDER.length} 个分类` +
(PATT.has ? ` · 原件:<a href="/api/admin/file/${PATT.sha256}" data-n="${esc(PATT.name)}"
onclick="return dlFile('${PATT.sha256}', this.getAttribute('data-n'))"
title="另存为(自己选保存位置)">${esc(PATT.name)}</a>` : ' · 未挂附件');
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 '<option value="0">(未分类)</option>'
+ out.map(o=>`<option value="${o.id}"${o.id===sel?' selected':''}>${esc(o.name)}</option>`).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=`
<div class="tot">
<div class="lab"><span class="ar">▾</span>${esc(dt.textContent)}
<span style="font-weight:400;color:#6b7280;font-size:11.5px">(${grand} 条)</span>
<span class="ops" style="display:inline-flex"><span onclick="event.stopPropagation();dirAddRoot()" title="新增一级目录">+子目录</span></span>
</div>
<div class="children">${renderNodes(PD.tree,0,0)}
<div class="pnode${PD.cur===0?' on':''}" style="${PD.cur===0?'':'color:#9aa4b2'}" onclick="pickDir(0)">
<span class="nm">(未分类)</span><span class="cnt">${PD.nUncat}</span></div>
</div>
</div>
<div class="treefoot"><div class="tipp">
悬停目录出按钮:+子 +平级 ✎ ↑ ↓ ✕(↑↓✕ 均需行内二次确认;↑↓ 子目录整枝跟动)。<br>
只有最底层目录(没有子目录)可以挂价格行、新增行。
</div></div>`;
}
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+=`<div class="pkids">${renderNodes(n.children,n.id,depth+1)}</div>`;
if(PD.adding&&PD.adding.mode==='child'&&PD.adding.parent===n.id) h+=`<div class="pkids">${newNodeHTML(n.id)}</div>`;
}
});
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=`<input class="ren" id="pren" value="${esc(n.name)}" onclick="${stop}">
<span class="ops ops-on"><span class="pk" title="保存改名" onclick="${stop}dirRenSave(${n.id})">✓</span>
<span class="pd" title="取消" onclick="${stop}pdClear();renderTree()">✕</span></span>`;
} else if(PD.cfm&&PD.cfm.id===n.id){
const lbl=PD.cfm.op==='del'?'确认删除?':(PD.cfm.op==='up'?'确认上移?':'确认下移?');
mid=`<span class="nm" title="${esc(PDMAP[n.id].path)}">${esc(n.name)}</span><span class="cnt">${cnt}</span>
<span class="cfm">${lbl}<span class="pk" onclick="${stop}dirGo(${n.id},'${PD.cfm.op}')">确认</span>
<span class="pd" onclick="${stop}pdClear();renderTree()">取消</span></span>`;
} else {
mid=`<span class="nm" title="${esc(PDMAP[n.id].path)}">${esc(n.name)}</span><span class="cnt">${cnt}</span>
<span class="ops">
<span title="新增子目录" onclick="${stop}dirAddChild(${n.id})">+子</span>
<span title="新增平级目录" onclick="${stop}dirAddSib(${n.id})">+平级</span>
<span title="改名" onclick="${stop}dirRen(${n.id})">✎</span>
<span title="上移(需确认)" onclick="${stop}dirCfm(${n.id},'up')">↑</span>
<span title="下移(需确认)" onclick="${stop}dirCfm(${n.id},'down')">↓</span>
<span class="pd" title="删除(需确认)" onclick="${stop}dirCfm(${n.id},'del')">✕</span>
</span>`;
}
return `<div class="pnode${cur?' on':''}" onclick="pickDir(${n.id})">${mid}</div>`;
}
function newNodeHTML(parent){
const stop='event.stopPropagation();';
return `<div class="pnode ops-on" onclick="${stop}">
<input class="ren" id="pnew" placeholder="目录名称">
<span class="ops ops-on"><span class="pk" title="保存" onclick="${stop}dirAddSave(${parent})">✓</span>
<span class="pd" title="取消" onclick="${stop}pdClear();renderTree()">✕</span></span></div>`;
}
/* ---- 目录操作(全部走 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=>`<col style="width:${c.w}px">`).join('');
th.innerHTML='<tr>'+COL_PRICE.map(c=>`<th>${c.t}</th>`).join('')+'</tr>';
// 工具行状态:新增行只在最底层目录可用;编辑/新增时显示「所属目录」下拉
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)
+ `<span class="crumb">${PD.curLeaf?'':'(含子目录汇总) '}共 ${PD.total} 条</span>`;
tb.innerHTML=PD.rows.map(rowHTML).join('')
+ (PD.addingRow?newRowHTML():'');
if(!PD.rows.length&&!PD.addingRow)
tb.innerHTML=`<tr><td colspan="${COL_PRICE.length}" class="tip" style="text-align:center;padding:16px">没有数据</td></tr>`;
// 底部统计(.pager 的 #dcnt):批次总条数 + 原件
const grand=PD.tree.reduce((s,n)=>s+(PD.counts[n.id]||0),0)+PD.nUncat;
dcnt.innerHTML=`价格 ${grand} 条` +
(PD.att.has ? ` · 原件:<a href="/api/admin/file/${PD.att.sha256}" data-n="${esc(PD.att.name)}"
onclick="return dlFile('${PD.att.sha256}', this.getAttribute('data-n'))"
title="另存为(自己选保存位置)">${esc(PD.att.name)}</a>` : ' · 未挂附件');
}
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 `<td class="${cls}">${(v===null||v===undefined||v==='')?'—':esc(v)}</td>`;
}
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 `<tr class="pedit">${['编码(选填)','名称(必填)','规格','单位','不含税价','税率','含税价','备注'].map((ph,i)=>
`<td class="pcell"><input id="pe${i}" value="${esc(String(v[i]))}" placeholder="${ph}"></td>`).join('')}
<td class="c"><a href="javascript:rowSave()" style="color:#1a7f37">✓ 保存</a>
<a href="javascript:rowCancel()" style="color:#c0392b">✕ 取消</a></td></tr>`;
}
const del = PD.cfmRow===r.id
? `<a href="javascript:rowDelGo(${r.id})" style="color:#c0392b">确认删除?</a><a href="javascript:pdClear();renderRows()">取消</a>`
: `<a href="javascript:rowEdit(${r.id})">编辑</a><a href="javascript:rowDel(${r.id})" style="color:#c0392b">删除</a>`;
return `<tr>${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')}
<td class="c">${del}</td></tr>`;
}
function newRowHTML(){
const ph=['编码(选填)','名称(必填)','规格','单位','不含税价','税率','含税价','备注'];
return `<tr class="pedit">${ph.map((p,i)=>`<td class="pcell"><input id="pe${i}" placeholder="${p}"></td>`).join('')}
<td class="c"><a href="javascript:rowSave()" style="color:#1a7f37">✓ 保存</a>
<a href="javascript:rowCancel()" style="color:#c0392b">✕ 取消</a></td></tr>`;
}
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)
||`<tr><td colspan="${COLS.lme.length}" class="tip" style="text-align:center;padding:16px">没有数据</td></tr>`;
}
// 价格明细:**与上传的 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 '<td class="tg"></td>';
if(c.dash) return '<td class="'+(c.a||'l')+'">—</td>';
if(c.a==='attr') return `<td class="attr">${esc(fmtAttr(v))}</td>`;
if(c.num) return `<td class="r">${num(v)}</td>`;
if(c.a==='c') return `<td class="c">${esc(v)}</td>`;
return `<td class="l">${esc(v)}</td>`;
}
// 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'));

View File

@@ -39,7 +39,8 @@ a:hover{text-decoration:underline}
<div class="wrap">
<div style="display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:6px">
<h1 style="margin:0">造价审核 · 最近审核</h1>
<a class="btn pri" style="text-decoration:none;flex:none" href="/workbench.html"
<!-- 时间戳参数:老 WebView2 对 no-store 不完全遵守,跨页跳转带新 URL 强制绕缓存(2026-10-12) -->
<a class="btn pri" style="text-decoration:none;flex:none" href="javascript:location.href='/workbench.html?v='+Date.now()"
title="打开工作台:导入工程、做历史比对与审核">▶ 工作台</a>
</div>
<div class="panel">
@@ -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 主人定:落地页每行**只留「打开」+「删除」**,去掉「重新解析」按钮。
它只在解析器更新后才需要,不该占日常位置。
⚠️ 去掉之后的替代路径:**删掉这个会话 → 重新打开工程**(走一遍全新解析,数据就是新的),

View File

@@ -261,7 +261,8 @@ body.grptree-dragging{cursor:col-resize !important;user-select:none}
<!-- 2026-10-10 主人定:右上按钮一字排开,从左到右 =
分组/匹配 → 后台管理 → 询价附件 → 最近审核 → 打开项目。 -->
<button class="btn" onclick="cfgOpen()" title="类似清单分组 / 历史匹配过滤词">⚙ 分组&amp;过滤</button>
<a class="btn" href="/admin.html" data-page-node-id="soJGFd2PWIpS6Hbp6B2s0w">后台管理</a>
<!-- 时间戳参数:老 WebView2 对 no-store 不完全遵守,跨页跳转带新 URL 强制绕缓存(2026-10-12) -->
<a class="btn" href="javascript:location.href='/admin.html?v='+Date.now()" data-page-node-id="soJGFd2PWIpS6Hbp6B2s0w">后台管理</a>
<!-- 询价附件(2026-10-09 改版;2026-10-10 决策 28 改会话级 主人定):**常驻按钮**。
数据 = 当前会话在对比框点「采纳」收进来的附件(按内容去重;切会话跟着切,删会话才清,
没打开项目=空),不再是后台绑定关系的只读展示。 -->