refactor(core): 采纳后端拆分至 adopt_api 并落实决策294/295口径
- 动态汇总分组键改为界面可见字段(决策303),原价四字段与 flags 不再拆行 - 导出 COS:合并并集后按库现值重写汇总行直接子级(决策294) - api_server 大幅瘦身,采纳逻辑独立成册(决策298/299) - 采纳工料机匹配改为只看单位级、先到先占(决策295,取代决策108) - 同步更新相关测试与前端工作台/管理页
This commit is contained in:
@@ -387,7 +387,7 @@ body.histdrag{user-select:none}
|
||||
<div style="display:flex;align-items:center;gap:10px;padding:4px 10px;border-bottom:1px solid var(--line);background:#fafcff;height:30px;box-sizing:border-box">
|
||||
<span id="skelbar" style="font-size:12px;color:#5a7ca6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:62%" title=""></span>
|
||||
<!-- 决策 209(2026-10-26 主人定):合并工料机入口同款放项目工料机页(弹框与原数据卡共用 rawMergeOpen) -->
|
||||
<div class="lvbtn" style="margin-left:auto" onclick="rawMergeOpen('sub')" title="按 名称|规格|单位 归并项目级工料机(决策 293:先并子级)">合并工料机</div>
|
||||
<div class="lvbtn" style="margin-left:auto" onclick="rawMergeOpen('sub')" title="按 名称|规格|单位 归并:先并子级纯叶子,再并父码(决策 293/294)">合并工料机</div>
|
||||
<input id="pgsrch_wb" class="mi pgsrch" placeholder="搜索本页数据" title="搜索本页数据,命中黄底" oninput="pageSearchGo('wb', this.value)" onkeydown="if(event.key==='Enter')pageSearchNav('wb',1)"><button class="pgsnav" data-pg="wb" data-dir="-1" title="上一个命中" onclick="pageSearchNav('wb',-1)" disabled>上一个</button><button class="pgsnav" data-pg="wb" data-dir="1" title="下一个命中(首击=从头查找)" onclick="pageSearchNav('wb',1)" disabled>下一个</button>
|
||||
</div>
|
||||
<table id="t0" data-page-node-id="wiHjUkOHHtafQFK4AcMWUn"><colgroup id="cg0" data-page-node-id="jrukeg9ggS0DZO8eKSBXsM"></colgroup><thead id="th0" data-page-node-id="tapJmvtyFyqqAOcTTiKGJ3"></thead><tbody id="tb0" data-page-node-id="L018lJjmeSEfM31wIxkb05"></tbody></table></div>
|
||||
@@ -542,11 +542,12 @@ body.histdrag{user-select:none}
|
||||
<div class="dlg" style="width:1120px;max-width:96vw">
|
||||
<h4 style="display:flex;align-items:center;gap:10px">合并工料机
|
||||
<div class="mtabs"><!-- 决策 293:页签换位=子级在先(先并子级、后并一级;取代 241「子级=第二次」顺序) -->
|
||||
<div class="mtab on" id="mtabSub" onclick="mView('sub')" title="合并被台班/配合比子级引用的工料机(先合并)">子级工料机</div>
|
||||
<div class="mtab" id="mtabL1" onclick="mView('')" title="合并一级工料机(子级无可并组后方可合并)">一级工料机</div>
|
||||
<div class="mtab on" id="mtabSub" onclick="mView('sub')" title="只合并子级/孙级里不带子级的叶子(先合并;只换码,不动父码树)">子级工料机</div>
|
||||
<div class="mtab" id="mtabL1" onclick="mView('')" title="合并所有带子级的父码(不管它自己是不是别人的子级)+顶级叶子;子级叶子清零后可合并">一级工料机</div>
|
||||
</div>
|
||||
<span style="flex:1"></span>
|
||||
<span id="mstat" style="color:#c8412f;font-size:12px;display:none"></span>
|
||||
<span id="mident" style="color:#c8412f;font-size:12px;display:none"></span>
|
||||
<button class="btn" id="mbtnApply" onclick="mergeApply()">合并</button>
|
||||
<button class="btn" onclick="mergeClose()" style="background:#fff;color:#5b6b7e;border:1px solid #c9d4e2">取消</button>
|
||||
</h4>
|
||||
@@ -692,6 +693,7 @@ body.histdrag{user-select:none}
|
||||
let SID=0, CUR=null, CURTYPE='lme', HROWS=[];
|
||||
let CUR_ADOPT=''; // 决策 250(2026-11-01 主人定):当前选中行的采纳备注(pick 时从行备注格取,
|
||||
// 采纳/取消/手工编辑同步)——对比框「已采纳」标记按它反推,与库同源不漂
|
||||
let CUR_SUB=false; // 决策 302:当前选中工料机行是否带子级(母行)——对比框「采纳」灰锁 + adoptLme 守卫
|
||||
/* 决策 256(2026-11-06 主人定「乙 后端溯源」):本行已采纳来源行的快照缓存——
|
||||
比对/检索结果里没有来源行时插回第一条+徽章;快照由后端 adopt_src 表溯源(跨重开/换浏览器有效)。
|
||||
{key:'bill:214', row:{渲染行}, busy, done} —— 采纳/取消时即时维护,行切换按 key 失效。 */
|
||||
@@ -1117,6 +1119,13 @@ async function rawMergeOpen(view){
|
||||
const d = await J('/api/session/lme/merge/groups?session_id=' + SID + (MV ? '&view=' + MV : ''));
|
||||
if(!d || !d.ok){ $('msg').textContent = (d && d.msg) || '读取合并分组失败'; return; }
|
||||
MDATA = d;
|
||||
// 决策 297:同码异物残留红字提示(仅提示不闸;导入拆码后正常为 0)
|
||||
const _mi = document.getElementById('mident');
|
||||
if(_mi){
|
||||
const _n = d.same_code_conflict | 0;
|
||||
_mi.style.display = _n > 0 ? '' : 'none';
|
||||
_mi.textContent = _n > 0 ? ('同码异物 ' + _n + ' 组(同编码对应名称/规格/单位不同,请先核对)') : '';
|
||||
}
|
||||
const _l1 = document.getElementById('mtabL1'), _sb = document.getElementById('mtabSub');
|
||||
if(_l1) _l1.classList.toggle('on', MV !== 'sub');
|
||||
if(_sb) _sb.classList.toggle('on', MV === 'sub');
|
||||
@@ -1133,9 +1142,7 @@ async function rawMergeOpen(view){
|
||||
// 决策 241 补记(2026-10-31 实测抓到):切页签后 0 组必须**清空表格**显示空态——
|
||||
// 此前 return 时 mtree 残留上一视野渲染内容(页签已高亮、表还是旧的)=「两个页签一样」假象。
|
||||
$('mtree').innerHTML = '<div style="padding:48px 0;text-align:center;color:#8a97a8;font-size:13px">'
|
||||
+ esc(MV === 'sub'
|
||||
? '子级视野:没有可合并的组(被台班/配合比子级引用的工料机里,没有「名称|规格|单位相同但编码不同」的)'
|
||||
: '没有可合并的组(项目级+各单位工程汇总里没有「名称|规格|单位相同但编码不同」的工料机)')
|
||||
+ esc('合并完成') // 决策 294 补记(2026-11-10 主人定):两视野空态统一这句话
|
||||
+ '</div>';
|
||||
$('msg').textContent = '';
|
||||
$('mmask').classList.add('on');
|
||||
@@ -1154,11 +1161,11 @@ function mbtnGate(){ // 决策 293:一级可查看不可并——子级仍
|
||||
b.disabled = lock;
|
||||
b.style.opacity = lock ? '.45' : '';
|
||||
b.style.cursor = lock ? 'not-allowed' : '';
|
||||
b.title = lock ? '子级工料机仍有待并组,先合并子级工料机' : '';
|
||||
b.title = lock ? '请先合并子级工料机' : ''; // 决策 294 补记四(2026-11-10 主人定提示词)
|
||||
if(hint){
|
||||
hint.style.display = lock ? '' : 'none';
|
||||
hint.style.color = '#c8412f';
|
||||
hint.textContent = '先合并子级工料机:子级仍有 ' + (MSUB_N < 0 ? '?' : MSUB_N) + ' 组待并';
|
||||
hint.textContent = '请先合并子级工料机';
|
||||
}
|
||||
}
|
||||
function mTog(tr){
|
||||
@@ -1209,7 +1216,7 @@ function renderMergeTree(){
|
||||
+ '<td class="c">' + no + '</td>'
|
||||
+ '<td class="c">' + esc(r.code || '—') + '</td>'
|
||||
+ '<td class="l" title="' + esc(g.name || '') + '">' + esc(g.name || '—') + (r.sub
|
||||
? ' <span class="subtag" title="带子级组成(台班/配合比):合并后各单位工程的子级以保留行为准,原软件按子级重算母价">子级</span>' : '') + '</td>'
|
||||
? ' <span class="subtag" title="带子级组成(父码):合并只换码,子级按并集去重,不重建树">子级</span>' : '') + '</td>'
|
||||
+ '<td class="l" title="' + esc(g.spec || '') + '">' + esc(g.spec || '—') + '</td>'
|
||||
+ '<td class="c">' + esc(g.unit || '—') + '</td>'
|
||||
+ '<td class="r">' + num(r.qty, 3) + '</td>'
|
||||
@@ -1375,8 +1382,13 @@ document.addEventListener('click', function(e){
|
||||
else if(_sub){ $('msg').textContent = '带子级的单价不可编辑:请修改它的子数据(单价=Σ子级联动)'; }
|
||||
} else if(tr.classList.contains('resk') && tr.dataset.ccode && SID){
|
||||
// 决策 188(2026-10-24 主人定):子级组成行——含量/除税价/含税价 单击可编辑(母行Σ联动)
|
||||
// 决策 301(2026-11-11 主人定「凡底下有子级的,税率均不可填写,单价现算逐级汇总」):
|
||||
// 带子级的 resk 行(台班/配合比套台班)同 haorow 锁——税率/单价/含税一律不进编辑框。
|
||||
const F = {5:'content', 6:'ntp', 7:'taxrate', 8:'taxp'};
|
||||
if(F[idx]){ reskEdit(td, tr, F[idx]); }
|
||||
if(F[idx] && idx !== 5 && tr.dataset.sub === '1'){
|
||||
$('msg').textContent = '带子级的单价/税率不可编辑:请修改它的子数据(单价=Σ子级联动)';
|
||||
}
|
||||
else if(F[idx]){ reskEdit(td, tr, F[idx]); }
|
||||
} else if((tr.classList.contains('lmerow') || tr.closest('#tb0')) && (tr.dataset.lmeid || tr.dataset.id)){
|
||||
// 决策 218(方案甲,2026-10-26 主人定):**项目工料机页签(#tb0)全列只读**——三价/名称/规格/
|
||||
// 单位/备注的单击编辑撤除,编辑集中在原数据标签(原数据·项目级工料机汇总卡,决策 147 同码同形)。
|
||||
@@ -1649,13 +1661,22 @@ async function reskEdit(td, tr, field){
|
||||
}
|
||||
/* 重拉某母行的子级并原位重画 + 母行两价格更新为 Σ */
|
||||
async function reskRefresh(tr){
|
||||
const motherTr = tr.previousElementSibling && tr.previousElementSibling.classList.contains('lmerow')
|
||||
? tr.previousElementSibling : null;
|
||||
// 找母行:向上跳过连续 resk 行——浮层母行无 lmerow 类(2026-10-24 实测踩坑:按类找会落到 null)
|
||||
let m = tr.previousElementSibling;
|
||||
while(m && m.classList.contains('resk')) m = m.previousElementSibling;
|
||||
if(!m || m.tagName !== 'TR') m = null;
|
||||
// 决策 294 补记三:多层——只刷新**被编辑子行的直接父行**下的子级,不把整棵树上层拍平;
|
||||
// 父行按 data-pcode 往上找(父可能是 haorow,也可能是上一级 resk)。
|
||||
const pcode = tr.dataset.pcode;
|
||||
const _inPop = !!tr.closest('.haopop'); // 先记:后面 tr 会被移除,再 closest 就没了
|
||||
let m = tr.previousElementSibling;
|
||||
while(m){
|
||||
if(m.classList.contains('resk')){
|
||||
if((m.dataset.ccode || '') === (pcode || '')) break;
|
||||
} else if(m.classList.contains('haorow') && (m.dataset.code || '') === (pcode || '')){
|
||||
break;
|
||||
}
|
||||
m = m.previousElementSibling;
|
||||
}
|
||||
if(!m || m.tagName !== 'TR') m = null;
|
||||
const _pd = m ? (parseInt(m.dataset.depth || '0', 10) || 0) : 0;
|
||||
const _cd = _pd + 1;
|
||||
const base = (typeof RVO !== 'undefined' && RVO && (typeof RVO.lmeApi === 'function' ? RVO.lmeApi() : RVO.lmeApi)) || ('/api/session/lme/res?session_id=' + SID);
|
||||
try{
|
||||
const d = await J(base + '&code=' + encodeURIComponent(pcode));
|
||||
@@ -1664,31 +1685,76 @@ async function reskRefresh(tr){
|
||||
const html = rows.map(x => {
|
||||
const q = Number(x[5]) || 0, np = Number(x[6]) || 0, tp = Number(x[7]) || 0;
|
||||
snt += q * np; stx += q * tp;
|
||||
return '<tr class="resk" data-pcode="' + esc(pcode) + '" data-ccode="' + esc(x[0]) + '"'
|
||||
+ ' title="单击 含量/除税价/税率/含税价 可编辑(除税×(1+税率)=含税 恒成立;母行单价=Σ子级自动联动)">'
|
||||
+ '<td class="c"></td><td class="c">' + ell(x[0], '—') + '</td>'
|
||||
const _hs = (x[8] === 1 || x[8] === '1');
|
||||
// 决策 301:带子级 resk 行挂 data-sub;税率格一律「—」(税率/单价=Σ子级现算不可填写)
|
||||
return '<tr class="resk" data-depth="' + _cd + '" data-pcode="' + esc(pcode) + '" data-ccode="' + esc(x[0]) + '"'
|
||||
+ (_hs ? ' data-sub="1"' : '')
|
||||
+ ' title="' + (_hs ? '带子级:含量可编辑;单价/税率=Σ子级现算,修改请改它的子数据' : '单击 含量/除税价/税率/含税价 可编辑(除税×(1+税率)=含税 恒成立;母行单价=Σ子级自动联动)') + '">'
|
||||
+ '<td class="c">' + (_hs ? '<span class="haosub" title="展开/收起下一级组成" data-code="'
|
||||
+ esc(x[0] || '') + '" onclick="event.stopPropagation();haoRes(this)">+</span>' : '') + '</td>'
|
||||
+ '<td class="c">' + ell(x[0], '—') + '</td>'
|
||||
+ '<td class="l">' + ell(x[1], '—') + '</td>'
|
||||
+ '<td class="l">' + ell(x[2], '—') + '</td><td class="c u">' + esc(x[3] || '—') + '</td>'
|
||||
+ '<td class="r">' + r3(x[5]) + '</td><td class="r">' + rm(x[6]) + '</td>'
|
||||
+ '<td class="r">' + (x[8] == null ? '—' : num(x[8], 2)) + '</td>'
|
||||
+ '<td class="r">' + (_hs ? '—' : (x[9] == null ? '—' : num(x[9], 2))) + '</td>'
|
||||
+ '<td class="r">' + rm(x[7]) + '</td></tr>';
|
||||
}).join('') || '<tr class="resk"><td colspan="9" style="text-align:left">(没有下一级组成)</td></tr>';
|
||||
// 原位替换本母行下的旧子级行(含被编辑的 tr 自己——否则旧行残留重复,2026-10-24 实测)
|
||||
let nx = tr, cnt = 0;
|
||||
const tmp = document.createElement('tbody'); tmp.innerHTML = html;
|
||||
while(nx && nx.classList.contains('resk')){ const n2 = nx.nextElementSibling; nx.remove(); nx = n2; }
|
||||
}).join('') || '<tr class="resk" data-depth="' + _cd + '"><td colspan="9" style="text-align:left">(没有下一级组成)</td></tr>';
|
||||
// 只删父行下的后代(depth>父),同级其他分支不动
|
||||
if(m && m.parentNode){
|
||||
let ref = m.nextElementSibling;
|
||||
let nx = m.nextElementSibling;
|
||||
while(nx && nx.classList.contains('resk')
|
||||
&& (parseInt(nx.dataset.depth || '0', 10) || 0) > _pd){
|
||||
const n2 = nx.nextElementSibling; nx.remove(); nx = n2;
|
||||
}
|
||||
const tmp = document.createElement('tbody'); tmp.innerHTML = html;
|
||||
const ref = m.nextSibling;
|
||||
while(tmp.firstChild) m.parentNode.insertBefore(tmp.firstChild, ref);
|
||||
m.dataset.open = '1';
|
||||
const _hsb = m.querySelector('.haosub');
|
||||
if(_hsb) _hsb.textContent = '−';
|
||||
}
|
||||
// 母行两价格 = Σ(视图格位 6=除税 8=含税;税率格保持 —)
|
||||
if(m){
|
||||
const inPop = !!tr.closest('.haopop'); // 浮层布局=直下标;原数据卡走 RV_LME_DS 映射
|
||||
const inPop = _inPop; // 浮层布局=直下标;原数据卡走 RV_LME_DS 映射
|
||||
const tds = Array.prototype.slice.call(m.children);
|
||||
const find = want => { const vi = inPop ? want : tds.findIndex((_, i) => (typeof RV_LME_DS !== 'undefined' && RV_LME_DS ? RV_LME_DS[i] : i) === want); return vi >= 0 ? tds[vi] : null; };
|
||||
const cN = find(6), cT = find(8);
|
||||
if(cN) cN.textContent = rm(Math.round((snt + Number.EPSILON) * 100) / 100);
|
||||
if(cT) cT.textContent = rm(Math.round((stx + Number.EPSILON) * 100) / 100);
|
||||
// 决策 301:逐级上滚——祖先母行按各自显示子价重算 Σ,一路反映到最高一级(haorow 为顶)
|
||||
(function rollUp(anchor){
|
||||
let cur = anchor;
|
||||
while(cur && cur.dataset.pcode){
|
||||
let g = null, s = cur.previousElementSibling;
|
||||
const want = cur.dataset.pcode || '';
|
||||
while(s){
|
||||
if(s.classList.contains('resk') && (s.dataset.ccode || '') === want){ g = s; break; }
|
||||
if(s.classList.contains('haorow') && (s.dataset.code || '') === want){ g = s; break; }
|
||||
s = s.previousElementSibling;
|
||||
}
|
||||
if(!g) break; // 没有更上一级母行 = 已到最高一级
|
||||
const gd = parseInt(g.dataset.depth || '0', 10) || 0;
|
||||
let gu = 0, gt = 0, gh = false;
|
||||
let nx = g.nextElementSibling;
|
||||
while(nx && nx.classList.contains('resk')){
|
||||
const nd = parseInt(nx.dataset.depth || '0', 10) || 0;
|
||||
if(nd <= gd) break; // 离开 g 的直接子行区
|
||||
if(nd === gd + 1){ // 只 Σ 直接子行(孙级已滚进子行格)
|
||||
const t2 = nx.querySelectorAll('td');
|
||||
const q = Number((t2[5] ? t2[5].textContent : '').replace(/,/g, '')) || 0;
|
||||
const p = Number((t2[6] ? t2[6].textContent : '').replace(/,/g, '')) || 0;
|
||||
const t = Number((t2[8] ? t2[8].textContent : '').replace(/,/g, '')) || 0;
|
||||
gu += q * p; gt += q * t; gh = true;
|
||||
}
|
||||
nx = nx.nextElementSibling;
|
||||
}
|
||||
if(!gh) break;
|
||||
const gtds = Array.prototype.slice.call(g.children);
|
||||
if(gtds[6]) gtds[6].textContent = rm(Math.round((gu + Number.EPSILON) * 100) / 100);
|
||||
if(gtds[8]) gtds[8].textContent = rm(Math.round((gt + Number.EPSILON) * 100) / 100);
|
||||
cur = g; // 继续往上滚(haorow 无 data-pcode 自然停)
|
||||
}
|
||||
})(m);
|
||||
}
|
||||
if(typeof RV_LME_ROWS !== 'undefined' && RV_LME_ROWS && m){
|
||||
// 同步缓存里的母行值(防排序回显旧值)
|
||||
@@ -2345,7 +2411,16 @@ async function pick(type,id,tr){
|
||||
// 规格 2026-10-16 ③:鼠标点的那一格贴 .cellhit(#a8e3d2)——取捕获监听记下的最近 td
|
||||
const ptd=window.__lastPickedTd;
|
||||
if(ptd && tr.contains(ptd)) ptd.classList.add('cellhit');
|
||||
CURTYPE=type; CUR={id};
|
||||
const _pkCode=(tr.dataset&&tr.dataset.code)||'';
|
||||
// 决策 302:子级叶子行(data-leaf=1,无行 id)也是合法比对基准——CUR 带码,采纳按码落价(端点首改自动建行)
|
||||
// 决策 302 补记(2026-11-11 主人实测「点清单不匹配+采纳改价行不存在」):302 重构把 CURTYPE=type
|
||||
// 弄丢了——行型必须跟随点选,否则点清单后仍按 lme 查 s_lme_proj(检索找不到这一行、采纳改价行不存在)。
|
||||
CURTYPE = type;
|
||||
CUR = (tr.dataset && tr.dataset.leaf==='1') ? {id:null, code:_pkCode, leaf:true, name:(tr.dataset.name||''), unit:(tr.dataset.unit||'')} : {id, code:_pkCode};
|
||||
// 决策 302:带子级的母工料机不能采纳——选中行即判(p0=LME_SUB / 原数据卡=RV_LME_SUBS,同一份子级组成)
|
||||
CUR_SUB = type==='lme' && !CUR.leaf && !!_pkCode
|
||||
&& ((typeof LME_SUB!=='undefined'&&LME_SUB&&LME_SUB.has(_pkCode))
|
||||
||(typeof RV_LME_SUBS!=='undefined'&&RV_LME_SUBS&&RV_LME_SUBS.has(_pkCode)));
|
||||
// 决策 250:随手取本行备注格(工料机/清单/原数据行都渲染 td.rmk)——已采纳标记的判定源
|
||||
const _rmk = tr.querySelector ? tr.querySelector('td.rmk') : null;
|
||||
CUR_ADOPT = _rmk ? ((_rmk.getAttribute('title') || _rmk.textContent || '') + '').trim() : '';
|
||||
@@ -2387,6 +2462,7 @@ async function search(){
|
||||
stop:(FLT.stop||'').trim(),
|
||||
scope:(CURTYPE==='bill' && curTab()==='p1') ? 'self_group' : ''} // 规格 18:组价不一致=会话内本组其他清单(直读会话)
|
||||
: {session_id:SID,type:CURTYPE,row_id:CUR.id,limit:50,
|
||||
...(CUR.leaf ? {leaf:{code:CUR.code||'', name:CUR.name||'', unit:CUR.unit||''}} : {}), // 决策 302:叶子按自带属性比对(无项目级行 id)
|
||||
...flt,
|
||||
projs: FLT.proj ? [FLT.proj] : [], // 项目名称(决策 141):清单/工料机两侧同滤
|
||||
stop:(FLT.stop||'').trim(),
|
||||
@@ -2551,7 +2627,9 @@ function renderHist(){
|
||||
+ `<td>${ell(x.region,'—')}</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">${i===adoptedIdx ? adoptedBadge
|
||||
: (CUR_SUB ? `<span style="color:#b9c4d2" title="带子级的母工料机不能采纳:单价=Σ子级联动,请展开后在子级叶子行上采纳">采纳</span>`
|
||||
: `<a class="lk" onclick="adoptLme(${i})">采纳</a>`)}</td>` // 决策 302:母行灰锁,采纳落叶子
|
||||
: `<td class="c">${seq0+i+1}</td>`
|
||||
+ tdbadge
|
||||
+ `<td class="hnm"><span class="ell">${esc(x.name||'')}</span></td>`
|
||||
@@ -2837,54 +2915,86 @@ async function cancelBillAdopt(billId, el){
|
||||
写完就地更新上方主表该行(11 格:9=取消采纳 10=备注),不整表重画。
|
||||
2026-10-09 主人定:采纳的工料机行若带附件(工程行=绑定的询价资料 / 价格行=刊物原件),
|
||||
该附件同时收进顶栏「询价附件」目录(带 session_id+lme_id 记事件,取消采纳按行撤)。 */
|
||||
async function adoptAtt(x){
|
||||
async function adoptAtt(x,lmeId){
|
||||
if(!x || !x.file_url) return '';
|
||||
try{
|
||||
const r=await J('/api/adopt/record',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({url:x.file_url,name:x.file||'',proj:x.proj||'',
|
||||
session_id:SID,lme_id:CUR.id})});
|
||||
session_id:SID,lme_id:(lmeId!=null?lmeId:CUR.id)})});
|
||||
if(r&&r.ok){ loadAdopt(); return ';附件已收进「工料机附件」'; }
|
||||
}catch(e){}
|
||||
return '';
|
||||
}
|
||||
async function adoptLme(i){
|
||||
const x=VISIBLE_ROWS[i]; if(!x) return;
|
||||
if(CURTYPE!=='lme' || !CUR || !CUR.id){ dlMsg('请先在上方点选工料机行,再采纳历史价','warn'); return; } // 双保险:基准必须是工料机行(规格⑤:不静默,与清单采纳同款)
|
||||
if(CURTYPE!=='lme' || !CUR || (!CUR.id && !CUR.leaf)){ dlMsg('请先在上方点选工料机行,再采纳历史价','warn'); return; } // 双保险:基准必须是工料机行(规格⑤:不静默,与清单采纳同款)
|
||||
if(CUR_SUB){ dlMsg('带子级的母工料机不能采纳:请展开后在子级叶子行上采纳(母行单价=Σ子级联动)','warn'); return; } // 决策 302:母行锁死,采纳落叶子
|
||||
// 替换前三价先抓(决策 160):行级改价落库后所在行三价被覆盖,备注要记的就是它
|
||||
const _t0=(LME_ROWS||[]).find(y=>y[0]===CUR.id);
|
||||
const _t0=CUR.leaf?null:(LME_ROWS||[]).find(y=>y[0]===CUR.id);
|
||||
const _oldLme=_t0?{price:_t0[6],tax:_t0[7],taxp:_t0[8]}:null;
|
||||
// 决策 158(2026-10-21 主人定):采纳即改价——目标行三价 = 被采纳行的 除税编制价|税率|含税编制价
|
||||
//(走行级改价端点:三价联动/编码同步单位级/merged_codes 登记 全部同款)
|
||||
let _lmeAnchor=null; // 决策 219:备注旧价锚=第一次计算/合并后首次三价(老会话锚空退改前现值)
|
||||
let _rid=CUR.id; // 决策 302:叶子按码落价(端点首改自动建行),行 id 由端点带回供备注/附件/取消采纳定位
|
||||
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,adopt:1})});
|
||||
body:JSON.stringify(CUR.leaf
|
||||
? {session_id:SID,code:CUR.code,ntp:x.price,taxrate:x.tax,taxp:x.price_tax,adopt:1}
|
||||
: {session_id:SID,id:CUR.id,code:CUR.code,ntp:x.price,taxrate:x.tax,taxp:x.price_tax,adopt:1})}); // 决策 297 补记三:带码定位优先(行首列可能是编码而非 id)
|
||||
}catch(e){ rp=null; }
|
||||
if(!rp || !rp.ok){ dlMsg('采纳改价失败:'+(rp&&rp.msg?rp.msg:'服务未响应'),'err'); return; }
|
||||
if(rp.id!=null) _rid=rp.id;
|
||||
if(rp.ntp0!=null) _lmeAnchor={price:rp.ntp0,tax:rp.rate0,taxp:rp.taxp0}; // 决策 219:锚由改价端点带回
|
||||
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[7]) trp.children[7].textContent=rm(rp.ntp); // 决策 243 源列后:7=除税 8=税率 9=含税
|
||||
if(trp.children[8]) trp.children[8].textContent=rm(rp.taxrate);
|
||||
if(trp.children[9]) trp.children[9].textContent=rm(rp.taxp);
|
||||
}
|
||||
const trR0=document.querySelector(`#rawbody tr.lmerow[data-id="${CUR.id}"]`);
|
||||
if(trR0){
|
||||
const d7=trR0.children[7], d8=trR0.children[8], d9=trR0.children[9]; // 决策 243 源列后同款
|
||||
if(d7) d7.textContent=rm(rp.ntp);
|
||||
if(d8) d8.textContent=rm(rp.taxrate);
|
||||
if(d9) d9.textContent=rm(rp.taxp);
|
||||
if(CUR.leaf){
|
||||
// 决策 302:叶子行三价原位刷新+母行 Σ 上滚原位跟随(端点 _mothers_reprice 已落库;
|
||||
// 不整表重画——重画丢选中态且叶子行备注来自采纳写入,子级结构重绘不回显)
|
||||
const trL=document.querySelector('#rawbody tr.lmesub.sel');
|
||||
if(trL){
|
||||
if(trL.children[7]) trL.children[7].textContent=rm(rp.ntp);
|
||||
if(trL.children[8]) trL.children[8].textContent=rm(rp.taxrate);
|
||||
if(trL.children[9]) trL.children[9].textContent=rm(rp.taxp);
|
||||
trL.dataset.price=String(rp.ntp);
|
||||
}
|
||||
try{
|
||||
let trM=trL ? trL.previousElementSibling : null;
|
||||
while(trM && !trM.classList.contains('lmerow')) trM=trM.previousElementSibling;
|
||||
if(trM && trM.dataset.code){
|
||||
const d2=await J('/api/session/rows?session_id='+SID+'&type=lme');
|
||||
const mr=(((d2||{}).rows)||[]).find(y=>String(y[1])===String(trM.dataset.code));
|
||||
if(mr && trM.children[7]){
|
||||
trM.children[7].textContent=rm(mr[6]);
|
||||
trM.children[8].textContent=(mr[7]==null?'—':rm(mr[7]));
|
||||
trM.children[9].textContent=rm(mr[8]);
|
||||
}
|
||||
}
|
||||
}catch(e){}
|
||||
} else {
|
||||
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[7]) trp.children[7].textContent=rm(rp.ntp); // 决策 243 源列后:7=除税 8=税率 9=含税
|
||||
if(trp.children[8]) trp.children[8].textContent=rm(rp.taxrate);
|
||||
if(trp.children[9]) trp.children[9].textContent=rm(rp.taxp);
|
||||
}
|
||||
const trR0=document.querySelector(`#rawbody tr.lmerow[data-id="${CUR.id}"]`);
|
||||
if(trR0){
|
||||
const d7=trR0.children[7], d8=trR0.children[8], d9=trR0.children[9]; // 决策 243 源列后同款
|
||||
if(d7) d7.textContent=rm(rp.ntp);
|
||||
if(d8) d8.textContent=rm(rp.taxrate);
|
||||
if(d9) d9.textContent=rm(rp.taxp);
|
||||
}
|
||||
}
|
||||
} else if(CUR.leaf){
|
||||
dlMsg('该历史行没有价格,叶子行采纳需要带价格的行','warn'); return; // 决策 302:叶子按码落价,无价可落即拦
|
||||
}
|
||||
const txt=adoptTxtFor(x,true,_lmeAnchor||_oldLme); // 决策 251:旧价=导入时项目级原件三价(锚),锚空退改前现值
|
||||
let r=null;
|
||||
try{
|
||||
r=await J('/api/session/remark',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({lme_id:CUR.id,remark:txt})});
|
||||
body:JSON.stringify({lme_id:_rid,remark:txt})}); // 决策 302:叶子=自动建行 id(端点带回)
|
||||
}catch(e){ r=null; }
|
||||
if(!r || !r.ok){ dlMsg('备注写入失败:'+(r&&r.msg?r.msg:'服务未响应'),'err'); return; }
|
||||
// 决策 172:采纳改价+备注落库后撤原数据取数缓存——否则切到原数据页命中旧缓存
|
||||
@@ -2894,31 +3004,42 @@ async function adoptLme(i){
|
||||
// 决策 256(乙 后端溯源):来源行快照落库(跨重开定位)+ 会话内存缓存
|
||||
try{
|
||||
const src=VISIBLE_ROWS[i] || {};
|
||||
_ADOPT_SRC={key:CURTYPE+':'+CUR.id, row:src};
|
||||
_ADOPT_SRC={key:CURTYPE+':'+(_rid!=null?_rid:CUR.code), row:src};
|
||||
J('/api/session/adopt/src',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({act:'record',type:'lme',row_id:CUR.id,
|
||||
body:JSON.stringify({act:'record',type:'lme',row_id:_rid,
|
||||
src:{src:src.src||'project', src_id:src.src_id, name:src.name, spec:src.spec||'',
|
||||
attr:src.attr||'', unit:src.unit, price:src.price, tax:src.tax,
|
||||
price_tax:src.price_tax, proj:src.proj, period:src.period}})});
|
||||
}catch(e){}
|
||||
const row=(LME_ROWS||[]).find(y=>y[0]===CUR.id); // 数据先行:排序/重画后备注与取消采纳不丢
|
||||
if(row){ row[10]=txt;
|
||||
// 就地更新两格(不整表重画——重画会丢 tr.sel 选中态);取消采纳格口径=备注以「采纳:」开头(lmeAdoptCellHTML)
|
||||
// 决策 243 源列后行 12 格:10=取消采纳 11=备注(原 9/10 顺延一位)
|
||||
const tr0=document.querySelector(`#tb0 tr[data-id="${CUR.id}"]`);
|
||||
const c10=tr0&&tr0.children[10], c11=tr0&&tr0.children[11];
|
||||
if(c11){ c11.textContent=txt; c11.title=txt; }
|
||||
if(c10) c10.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 d10=trR.children[10], d11=trR.children[11];
|
||||
if(d11){ d11.textContent=txt; d11.title=txt; }
|
||||
if(d10) d10.innerHTML=`<a class="lk" onclick="cancelAdopt(${CUR.id})">取消采纳</a>`;
|
||||
if(CUR.leaf){
|
||||
// 决策 302:叶子行——原位同步被点选的 lmesub 叶子行(重画兜底:RV_CACHE 已清;rid 供取消采纳定位)
|
||||
const trL=document.querySelector('#rawbody tr.lmesub.sel');
|
||||
if(trL){
|
||||
trL.dataset.rid=String(_rid);
|
||||
const c10=trL.children[10], c11=trL.children[11];
|
||||
if(c11){ c11.textContent=txt; c11.title=txt; }
|
||||
if(c10) c10.innerHTML=`<a class="lk" onclick="cancelAdopt(${_rid})">取消采纳</a>`;
|
||||
}
|
||||
} else {
|
||||
const row=(LME_ROWS||[]).find(y=>y[0]===CUR.id); // 数据先行:排序/重画后备注与取消采纳不丢
|
||||
if(row){ row[10]=txt;
|
||||
// 就地更新两格(不整表重画——重画会丢 tr.sel 选中态);取消采纳格口径=备注以「采纳:」开头(lmeAdoptCellHTML)
|
||||
// 决策 243 源列后行 12 格:10=取消采纳 11=备注(原 9/10 顺延一位)
|
||||
const tr0=document.querySelector(`#tb0 tr[data-id="${CUR.id}"]`);
|
||||
const c10=tr0&&tr0.children[10], c11=tr0&&tr0.children[11];
|
||||
if(c11){ c11.textContent=txt; c11.title=txt; }
|
||||
if(c10) c10.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 d10=trR.children[10], d11=trR.children[11];
|
||||
if(d11){ d11.textContent=txt; d11.title=txt; }
|
||||
if(d10) d10.innerHTML=`<a class="lk" onclick="cancelAdopt(${CUR.id})">取消采纳</a>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
renderHist(); // 已采纳灰标记:传递到本行
|
||||
dlMsg('已采纳,写入工料机备注:'+txt+await adoptAtt(x),'ok');
|
||||
dlMsg('已采纳,写入工料机备注:'+txt+await adoptAtt(x,_rid),'ok');
|
||||
}
|
||||
/* 取消采纳(工料机行,2026-10-09 主人定):清该行备注 + 撤它的采纳事件;
|
||||
附件失掉最后一条事件引用才出目录(后台磁盘原件永远不动)。
|
||||
@@ -2934,6 +3055,14 @@ async function cancelAdopt(lmeId){
|
||||
if(!r || !r.ok){ dlMsg('取消采纳失败:'+(r&&r.msg?r.msg:'服务未响应'),'err'); return; }
|
||||
if(CUR && String(CUR.id)===String(lmeId)) CUR_ADOPT=''; // 决策 250:判定源同步(标记立即复原)
|
||||
if(CUR && String(CUR.id)===String(lmeId)) _ADOPT_SRC={}; // 决策 256:来源快照缓存同步清(后端 /api/adopt/cancel 已删表行)
|
||||
const _trLc=document.querySelector('#rawbody tr.lmesub.sel');
|
||||
if(CUR && CUR.leaf && _trLc && ((_trLc.dataset.rid||'')===String(lmeId))){
|
||||
CUR_ADOPT=''; _ADOPT_SRC={}; // 决策 302:叶子行取消——当前选中的就是这片叶子(rid 采纳时记上)
|
||||
const d10=_trLc.children[10], d11=_trLc.children[11];
|
||||
if(d11){ d11.textContent=''; d11.title=''; }
|
||||
if(d10) d10.innerHTML='<span style="color:#b9c4d2">—</span>';
|
||||
delete _trLc.dataset.rid;
|
||||
}
|
||||
const row=(LME_ROWS||[]).find(y=>y[0]===lmeId);
|
||||
if(row) row[10]='';
|
||||
const tr0=document.querySelector(`#tb0 tr[data-id="${lmeId}"]`);
|
||||
@@ -3012,7 +3141,12 @@ function lmeRenderRows(){
|
||||
// 显示位→数据位:决策 243 加「源」列(显示 1)后整体错一位——2编码..9含税=数据1..8,
|
||||
// 11备注=数据10;0序号/1源/10取消采纳无数据位=不排序(LME_VIEW_DS 见 common.js,与 COLS.lme 同步改)
|
||||
const _dk=LME_VIEW_DS[LME_SORT.k];
|
||||
const view=sortRows(LME_ROWS, _dk==null?-1:_dk, LME_SORT.dir, LME_NUM);
|
||||
let view=sortRows(LME_ROWS, _dk==null?-1:_dk, LME_SORT.dir, LME_NUM);
|
||||
// 决策 302:默认(未点表头排序)带子级行稳定沉底(相对序不变、序号随新序重排);点表头后按排序值混排
|
||||
if(LME_SORT.k===-1 && LME_SUB && LME_SUB.size){
|
||||
const _hs=r=>LME_SUB.has(String(r[1]||''));
|
||||
view=view.filter(r=>!_hs(r)).concat(view.filter(_hs));
|
||||
}
|
||||
LME_VIEW=view;
|
||||
// 决策 209:0 量行整行不显示后,全临删场景=0 行是**新口径常态**——提示语与「未打开工程」分开
|
||||
$('tb0').innerHTML=renderLme(view,WB_OPTS)
|
||||
|
||||
Reference in New Issue
Block a user