feat(lme): 决策185-190落地——动态工料机现算、并集视野重组、同码异价拆行、子级改价收严
This commit is contained in:
@@ -285,6 +285,12 @@ tr.xtdel > td:not(.tgc), tr.xtdel > td:not(.tgc) span { text-decoration: line-th
|
||||
td.editing{position:relative}
|
||||
td.editing .cellin, td.editing textarea.cellin { position: absolute; inset: 0; width: 100%; height: 100%;
|
||||
box-sizing: border-box; border: 1px solid #7aa7d9; border-radius: 0; font: inherit; padding: 0 4px; outline: none; margin: 0; }
|
||||
/* 决策 189 通用要求(2026-10-24 主人定):任何单元格编辑框——含耗浮层/弹框内——
|
||||
一律动态填满所在单元格、四边与单元格边线重合(±2px 内):同一铺满规则覆盖所有容器。
|
||||
宿主 td 由 JS 加 td.editing(cellEditFill 锁行高);非 td 宿主由 resk/hao 编辑函数处理。 */
|
||||
.haopop td.editing .cellin, .haopop td.editing textarea.cellin,
|
||||
.kvtb td.editing .cellin { position: absolute; inset: 0; width: 100%; height: 100%;
|
||||
box-sizing: border-box; border: 1px solid #7aa7d9; border-radius: 0; font: inherit; padding: 0 4px; outline: none; margin: 0; }
|
||||
|
||||
/* ---- 规格 2026-10-17 ⑮:字段编辑历史——右下红三角 + 批注浮层(序号/时间/内容,最近在上)---- */
|
||||
td.eh{position:relative}
|
||||
|
||||
@@ -881,7 +881,7 @@ function renderLme(rows, opts) {
|
||||
const subT = (opts.subSet && opts.subSet.size)
|
||||
? (code => (opts.subSet.has(code) ? ' title="' + RAW_LME_SUB_TIP + '"' : '')) : null;
|
||||
return (rows || []).map((r, i) =>
|
||||
'<tr class="' + (opts.rowClass || '') + '"' + 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-code="' + esc(r[1] || '') + '" 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>'
|
||||
@@ -1045,8 +1045,9 @@ function rawKV(rows, tip) {
|
||||
/* 工料机汇总表:后端 _raw_proj(lme) 与 _raw_uw(lme) 的行序一致
|
||||
0=编码 1=名称 2=规格 3=单位 4=类别 5=消耗量 6=除税编制价 7=税率 8=含税编制价
|
||||
(2026-10-16 主人口径:税率插在下标 7,前后端一次同改 —— 按下标取列是 BILLROW 铁律)
|
||||
数量列标签按层不同:项目级=「总数量」(源文件项目级汇总的 Quantity 原样,2026-10-11 主人定),
|
||||
单位工程级=「消耗量」(清单→定额→消耗量归集计算值)。
|
||||
数量列头三层统一为「数量」(决策 148 统一项目级卡/项目工料机;决策 190 补齐单位工程级卡,
|
||||
原「总数量/消耗量」双轨列头撤除)。数据语义不变:项目级=源文件 Quantity 原样;
|
||||
单位级 summary=源文件汇总节点原样,其余=清单→定额归集现算值。
|
||||
RAW_LME_KIND=0 时把「类别」整列拿掉 —— 数据仍然取,只是不显示。 */
|
||||
/* 工料机汇总表的列排序(2026-10-07 主人要求):
|
||||
点列名按该列排序、再点反向;空值恒排最后(与方向无关);消耗量/价格/税率按数值比,
|
||||
@@ -1073,6 +1074,7 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
rows = rows || [];
|
||||
RV_LME_ROWS = rows; RV_LME_TIP = tip || ''; RV_LME_QL = qtyLabel || '';
|
||||
const subSet = new Set((extra && extra.sub) || []); // 带子级组成的编码集 → 三格挂 title 提示
|
||||
RV_LME_SUBS = subSet; // 决策 188:点击编辑拦截用(带子级三价不可改)
|
||||
/* 决策 170(2026-10-22 修):项目级/单位级分支判据。原为 `!RAW_LME_KIND`——RAW_LME_KIND
|
||||
是常量 0,条件恒真 → 单位级调用也进了项目级分支,行首被当 id、整行左移一位
|
||||
(编码列显示名称、单位列显示类别数字,主人实测报障)。
|
||||
@@ -1083,7 +1085,7 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
/* 决策 147(2026-10-21 主人定):项目级卡与「项目工料机」**同码同形** —— renderLme 唯一渲染、
|
||||
COLS.lme 同列宽(数量135/备注160)、同排序同点击同双击改价,改一处=改两处;
|
||||
数据集差异按主人原文保留:项目工料机走单位过滤,此处全量(含台班/配合比)。
|
||||
列头数量名沿用决策 40 的「总数量」(qtyLabel 传入);单位工程级卡走下方原路径不动。 */
|
||||
列头恒=COLS.lme(决策 148 统一「数量」);单位工程级卡走下方原路径,列头亦统一「数量」(决策 190)。 */
|
||||
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);
|
||||
@@ -1097,7 +1099,7 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
{ 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),
|
||||
// 而编辑/排序映射都以视图下标为键 —— 两套键系差一位(类别列隐藏时),先翻译再查。
|
||||
@@ -1133,7 +1135,7 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
// 两列严格等宽、随容器自适应;其余列宽不变。表头统一居中见 common.css。
|
||||
const cols = RAW_LME_KIND ? [40, 110, '', '', 60, 52, 90, 90, 70, 100] : [40, 110, '', '', 0, 52, 90, 90, 70, 100];
|
||||
const head = [['序号', 'c'], ['编码', 'c'], ['名称', 'l'], ['规格', 'l'], ['类别', 'c'], ['单位', 'c'],
|
||||
[qtyLabel || '消耗量', 'r'], ['除税编制价', 'r'], ['税率', 'r'], ['含税编制价', 'r']];
|
||||
[qtyLabel || '数量', 'r'], ['除税编制价', 'r'], ['税率', 'r'], ['含税编制价', 'r']]; // 决策 190:默认列头「数量」(原「消耗量」)
|
||||
return (tip ? '<div class="hint">' + esc(tip) + '</div>' : '')
|
||||
+ rawTbl(cols, head, body || '<tr><td class="empty">没有工料机数据</td></tr>', null,
|
||||
{ cur: RV_LME_SORT.k, dir: RV_LME_SORT.dir, fn: 'rawLmeSort' });
|
||||
@@ -1339,7 +1341,7 @@ async function rawDraw() {
|
||||
else if (RVTAB === 'lme') html = rawLmeTbl(d.rows,
|
||||
d.src === 'summary' ? '' // 2026-10-13 主人定:读 xml 原样口径取消说明行
|
||||
: '单位工程级 · 工料机汇总(按本单位工程的清单→定额→消耗量归集;点列名可排序)',
|
||||
d.src === 'summary' ? '总数量' : '消耗量');
|
||||
'数量'); // 决策 190(2026-10-24 主人定):列头统一「数量」,原 总数量/消耗量 双轨撤除
|
||||
else html = rawUw('cost', d.rows);
|
||||
}
|
||||
b.innerHTML = html;
|
||||
@@ -1654,7 +1656,11 @@ function haoPop(btn, nid) {
|
||||
function haoRow(x, i) {
|
||||
const has = x[8] === 1 || x[8] === '1';
|
||||
// ± 挂在序号格里(浮层不再单列把手):台班/配合比可展开下一级组成
|
||||
return '<tr><td class="c">' + (has ? '<span class="haosub" title="展开/收起下一级组成" data-code="'
|
||||
// 决策 188 补:主行挂 data-code/data-sub——工作台侧单击 含量(消耗量)/除税/税率/含税 可编辑
|
||||
//(带子级行单价锁死,只能含量+子数据;单条行三价+含量全可编辑)
|
||||
return '<tr class="haorow" data-code="' + esc(x[0] || '') + '"' + (has ? ' data-sub="1"' : '')
|
||||
+ ' title="单击 ' + (has ? '含量(消耗量)' : '含量/除税价/税率/含税价')
|
||||
+ ' 可编辑(汇总实时联动)"><td class="c">' + (has ? '<span class="haosub" title="展开/收起下一级组成" data-code="'
|
||||
+ esc(x[0] || '') + '" onclick="haoRes(this)">+</span>' : '') + (i + 1) + '</td>'
|
||||
+ '<td class="c">' + ell(x[0], '—') + '</td>'
|
||||
+ '<td class="l">' + ell(x[1], '—') + '</td>'
|
||||
@@ -1679,12 +1685,16 @@ function haoRes(tg) {
|
||||
const rows = (d && d.rows) || [];
|
||||
tr.dataset.open = '1'; tg.textContent = '−';
|
||||
const frag = document.createElement('tbody');
|
||||
// 决策 188:子级行挂 data-pcode/data-ccode + 标题提示(工作台侧单击可编辑 含量/除税/含税)
|
||||
frag.innerHTML = rows.length
|
||||
? rows.map(x => '<tr class="resk"><td class="c"></td><td class="c">' + ell(x[0], '—') + '</td>'
|
||||
? rows.map(x => '<tr class="resk" data-pcode="' + esc(tg.dataset.code) + '" data-ccode="' + esc(x[0]) + '"'
|
||||
+ ' title="单击 含量/除税价/含税价 可编辑(母行单价=Σ子级自动联动)">'
|
||||
+ '<td class="c"></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="c">—</td><td class="r">' + rm(x[7]) + '</td></tr>').join('')
|
||||
+ '<td class="r">' + (x[8] == null ? '—' : num(x[8], 2)) + '</td>'
|
||||
+ '<td class="r">' + rm(x[7]) + '</td></tr>').join('')
|
||||
: '<tr class="resk"><td colspan="9" style="text-align:left">(没有下一级组成)</td></tr>';
|
||||
let nx = tr.nextElementSibling;
|
||||
while (nx && nx.classList.contains('resk')) nx = nx.nextElementSibling;
|
||||
|
||||
@@ -959,28 +959,27 @@ function mTog(tr){
|
||||
if (box) Array.from(box.querySelectorAll('tr.mrow')).forEach(r => { r.style.display = open ? 'none' : ''; });
|
||||
}
|
||||
function renderMergeTree(){
|
||||
// 决策 171(2026-10-22 主人定):视野=单位工程×n+项目级——组内行含 项目级行(lvl=proj)
|
||||
// 与 单位级按码聚合行(lvl=uw,标注 N 个单位工程);**编码只读**(主人定「合并工料机里面的
|
||||
// 编码就不可编辑」,原编码输入框撤除);价格仍可编辑(仅项目级行)。
|
||||
// 列=勾选/序号/编码/来源/名称/规格型号/单位/数量/除税编制价/税率/含税编制价;固定顶部表头;
|
||||
// 不过滤带子数据的工料机(决策78 废止口径不变)。
|
||||
// 决策 186 v3(2026-10-23 主人定「合并逻辑1」):视野=**各单位工程品类并集**——项目级行
|
||||
// 不再显示(并集由单位级聚合呈现,不依赖项目级层);「来源」列去掉(全部来自单位工程汇总,
|
||||
// 标注 N 个单位工程);**编码只读**;全部字段只读(决策 184:改价在外面·行级改价/原数据)。
|
||||
// 列=勾选/序号/编码/名称/规格型号/单位/数量/除税编制价/税率/含税编制价;固定顶部表头。
|
||||
// 决策 173(2026-10-22 主人定):弹框加宽(1120px)+ 列宽可拖(公共 .rs 拖列逻辑)——
|
||||
// 名称 200 / 规格 150,其余列宽不变;全 px 列 → data-sumw(表宽=列宽和),拖完 colwSave 记忆。
|
||||
let h = '<table class="mtbl" data-sumw="1" style="width:1062px"><colgroup>'
|
||||
+ '<col style="width:34px"><col style="width:36px"><col style="width:44px"><col style="width:104px"><col style="width:92px"><col style="width:200px"><col style="width:150px">'
|
||||
+ '<col style="width:48px"><col style="width:86px"><col style="width:104px"><col style="width:60px"><col style="width:104px">'
|
||||
let h = '<table class="mtbl" data-sumw="1" style="width:1018px"><colgroup>'
|
||||
+ '<col style="width:34px"><col style="width:36px"><col style="width:44px"><col style="width:150px"><col style="width:200px"><col style="width:150px">'
|
||||
+ '<col style="width:48px"><col style="width:96px"><col style="width:100px"><col style="width:60px"><col style="width:100px">'
|
||||
+ '</colgroup><thead><tr><th></th><th title="单选:合并后按此行的编码与三价替换全组">✓<span class="rs"></span></th><th>序号<span class="rs"></span></th><th>编码<span class="rs"></span></th>'
|
||||
+ '<th>来源<span class="rs"></span></th><th>名称<span class="rs"></span></th><th>规格型号<span class="rs"></span></th><th>单位<span class="rs"></span></th><th>数量<span class="rs"></span></th><th>除税编制价<span class="rs"></span></th><th>税率<span class="rs"></span></th><th>含税编制价<span class="rs"></span></th></tr></thead>';
|
||||
+ '<th>名称<span class="rs"></span></th><th>规格型号<span class="rs"></span></th><th>单位<span class="rs"></span></th><th>数量<span class="rs"></span></th><th>除税编制价<span class="rs"></span></th><th>税率<span class="rs"></span></th><th>含税编制价<span class="rs"></span></th></tr></thead>';
|
||||
let no = 0;
|
||||
MDATA.groups.forEach((g, gi) => {
|
||||
const qty = g.rows.reduce((s, r) => s + (Number(r.qty) || 0), 0);
|
||||
h += '<tbody class="mgrp" data-gi="' + gi + '">'
|
||||
+ '<tr class="mhead2" onclick="mTog(this)"><td><span class="tog" data-open="1">−</span></td>'
|
||||
+ '<td></td><td></td>'
|
||||
+ '<td class="gtitle" colspan="6" title="名称|规格|单位">' + esc(g.name || '—') + ' | ' + esc(g.spec || '—') + ' | ' + esc(g.unit || '—')
|
||||
+ '<td class="gtitle" colspan="7" title="名称|规格|单位">' + esc(g.name || '—') + ' | ' + esc(g.spec || '—') + ' | ' + esc(g.unit || '—')
|
||||
+ ' <span style="color:#8a97a8;font-weight:400">' + g.rows.length + ' 条</span></td>'
|
||||
+ '<td class="r"><b>' + num(qty, 3) + '</b></td>'
|
||||
+ '<td></td><td></td><td></td></tr>';
|
||||
+ '<td></td><td></td></tr>';
|
||||
g.rows.forEach(r => {
|
||||
no++;
|
||||
const isUw = r.lvl === 'uw';
|
||||
@@ -996,7 +995,6 @@ function renderMergeTree(){
|
||||
+ (r.def ? ' checked' : '') + ' title="单选:合并后全组按此行归并(数值=行现值;改价在外面·行级改价/原数据)"></td>'
|
||||
+ '<td class="c">' + no + '</td>'
|
||||
+ '<td class="c">' + esc(r.code || '—') + '</td>'
|
||||
+ '<td class="c" style="color:#6b7a8d">' + (isUw ? (r.units + '个单位工程') : '项目级') + '</td>'
|
||||
+ '<td class="l" title="' + esc(g.name || '') + '">' + esc(g.name || '—') + (r.sub
|
||||
? ' <span class="subtag" title="带子级组成(台班/配合比):合并后各单位工程的子级以保留行为准,原软件按子级重算母价">子级</span>' : '') + '</td>'
|
||||
+ '<td class="l" title="' + esc(g.spec || '') + '">' + esc(g.spec || '—') + '</td>'
|
||||
@@ -1152,7 +1150,7 @@ function pageSearchGo(key, val){
|
||||
格位对应 rawTreeHTML:0把手 1序号 2编码 3类型 4名称 5特征 6单位 7工程量 8单价 9合价 10取消采纳 11备注 */
|
||||
document.addEventListener('click', function(e){
|
||||
if(!SID) return;
|
||||
const td = e.target.closest && e.target.closest('#rawbody td, #tb0 td');
|
||||
const td = e.target.closest && e.target.closest('#rawbody td, #tb0 td, .haopop td');
|
||||
if(!td || td.querySelector('input')) return;
|
||||
const tr = td.closest('tr'); if(!tr) return;
|
||||
const idx = Array.prototype.indexOf.call(tr.children, td);
|
||||
@@ -1163,12 +1161,30 @@ document.addEventListener('click', 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('haorow') && tr.dataset.code && SID){
|
||||
// 决策 188 补:浮层主行(定额下的工料机)——单条行 含量(消耗量)/除税/税率/含税 可编辑;
|
||||
// 带子级行单价锁死(只能改含量/去改子数据)
|
||||
const _sub = tr.dataset.sub === '1';
|
||||
if(idx === 5){ haoEdit(td, tr, 'content'); }
|
||||
else if(!_sub && (idx === 6 || idx === 7 || idx === 8)){ haoEdit(td, tr, ({6:'ntp',7:'taxrate',8:'taxp'})[idx]); }
|
||||
else if(_sub){ $('msg').textContent = '带子级的单价不可编辑:请修改它的子数据(单价=Σ子级联动)'; }
|
||||
} else if(tr.classList.contains('resk') && tr.dataset.ccode && SID){
|
||||
// 决策 188(2026-10-24 主人定):子级组成行——含量/除税价/含税价 单击可编辑(母行Σ联动)
|
||||
const F = {5:'content', 6:'ntp', 7:'taxrate', 8:'taxp'};
|
||||
if(F[idx]){ reskEdit(td, tr, F[idx]); }
|
||||
} else if((tr.classList.contains('lmerow') || tr.closest('#tb0')) && (tr.dataset.lmeid || tr.dataset.id)){
|
||||
// 2026-10-16 主人口径:项目级工料机汇总 除税编制价|税率|含税编制价 三格可改(单位级行无 data-lmeid=只读)。
|
||||
// 决策 147 补落实(2026-10-21):「项目工料机」页签同码同形——单击改价同卡;两处布局同构,
|
||||
// 视图下标=数据下标(6=除税编制价 7=税率 8=含税编制价),卡侧走 RV_LME_DS(恒等映射)兜底。
|
||||
const dk = tr.closest('#tb0') ? idx : (RV_LME_DS ? RV_LME_DS[idx] : null);
|
||||
if(dk===6 || dk===7 || dk===8){ api='lme'; field=({6:'ntp',7:'taxrate',8:'taxp'})[dk]; }
|
||||
if(dk===6 || dk===7 || dk===8){
|
||||
// 决策 188 收严(2026-10-24 主人定):带子级的工料机单价不可编辑,只能通过子数据修改
|
||||
if((typeof LME_SUB!=='undefined'&&LME_SUB.has(tr.dataset.code))||
|
||||
(typeof RV_LME_SUBS!=='undefined'&&RV_LME_SUBS&&RV_LME_SUBS.has(tr.dataset.code))){
|
||||
$('msg').textContent='带子级的单价不可编辑:请修改它的子数据(单价=Σ子级联动)'; return;
|
||||
}
|
||||
api='lme'; field=({6:'ntp',7:'taxrate',8:'taxp'})[dk];
|
||||
}
|
||||
// 2026-10-22 主人定:名称/规格/单位行内编辑(数据下标 2/3/4;编码=1 永不可改;
|
||||
// 两处同码同形同此入口,单位级行无 data-lmeid 进不来=只读)
|
||||
else if(dk===2 || dk===3 || dk===4){ api='lmefield'; field=({2:'name',3:'spec',4:'unit'})[dk]; }
|
||||
@@ -1207,6 +1223,7 @@ function editCell(td, api, id, field, cur){
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
const v = inp.value.trim();
|
||||
td.classList.remove('editing'); td.style.height = '';
|
||||
if(!save || v === cur){ td.textContent = cur; return; }
|
||||
const body = {session_id:SID, fields:{}};
|
||||
body.fields[field] = v;
|
||||
@@ -1255,6 +1272,7 @@ function grpBillQtyEdit(td, tr, cur0){
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
const v = inp.value.trim();
|
||||
td.classList.remove('editing'); td.style.height = '';
|
||||
if(!save || v === cur0.replace(/,/g, '')){ td.textContent = cur0; return; }
|
||||
if(!/^-?\d+(\.\d+)?$/.test(v)){ $('msg').textContent = '清单工程量只能输入数字'; td.textContent = cur0; return; }
|
||||
const r = await J('/api/session/bill/op',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
@@ -1287,6 +1305,7 @@ function grpNormQtyEdit(td, tr, cur0){
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
const v = inp.value.trim();
|
||||
td.classList.remove('editing'); td.style.height = '';
|
||||
if(!save || v === pre){ td.textContent = cur0; return; }
|
||||
const r = await J('/api/session/norm/op',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID, norm_id:nid, fields:{Quantity:v}})});
|
||||
@@ -1328,6 +1347,154 @@ document.addEventListener('click', function(e){
|
||||
交互沿用 editCell 口径(失焦/Enter 提交、Esc 取消、无防抖);提交成功后本地行原位
|
||||
同步三个格(序号/排序不动),RV_LME_ROWS 同步改,本会话其余视图缓存撤掉(单位级
|
||||
汇总按编码同步过,不能读旧值),当前视图 DOM 写回缓存。 */
|
||||
/* 决策 188 补:浮层主行编辑——content=定额消耗量(/norm/content);三价=按码(/lme/price)。
|
||||
保存后浮层整层重开(值全部刷新,含 Σ 母行价)。 */
|
||||
async function haoEdit(td, tr, field){
|
||||
if(td.querySelector('input')) return;
|
||||
const cur = td.textContent.trim();
|
||||
const inp = document.createElement('input');
|
||||
inp.className = 'cellin'; inp.value = (cur==='—'||cur==='' ? '' : cur); inp.spellcheck = false;
|
||||
inp.addEventListener('input', function(){
|
||||
const f = this.value.replace(/[^\d.]/g, ''), pp = f.split('.');
|
||||
this.value = pp.length > 2 ? pp[0] + '.' + pp.slice(1).join('') : f;
|
||||
});
|
||||
cellEditFill(td);
|
||||
td.textContent = ''; td.appendChild(inp); inp.focus(); inp.select();
|
||||
let done = false;
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
td.classList.remove('editing'); td.style.height = '';
|
||||
const v = inp.value.trim();
|
||||
if(!save || v === cur || v === ''){ td.textContent = cur; return; }
|
||||
const nv = Number(v.replace(/,/g, ''));
|
||||
if(!isFinite(nv) || nv < 0){ $('msg').textContent = '请输入非负数字'; td.textContent = cur; return; }
|
||||
const pop = tr.closest('.haopop');
|
||||
const nid = pop ? Number(pop.dataset.nid) : 0;
|
||||
let url, body;
|
||||
if(field === 'content'){ url = '/api/session/norm/content'; body = { session_id: SID, norm_id: nid, res_code: tr.dataset.code, qty: nv }; }
|
||||
else { url = '/api/session/lme/price'; body = { session_id: SID, code: tr.dataset.code }; body[field] = nv; }
|
||||
const r = await J(url, { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) });
|
||||
if(!r || !r.ok){ $('msg').textContent = (r && r.msg) || '保存失败'; td.textContent = cur; return; }
|
||||
$('msg').textContent = '已保存(各级汇总已实时联动)';
|
||||
// 浮层整层重开=全部行刷新(Σ 母行价/兄弟行联动可见)——延后一拍;
|
||||
// 先调 haoPopClose() 清模块级引用(let 不挂 window)——否则 haoPop 对同 nid 走「收起」分支(实测根因);
|
||||
// 重开后自动钉住,免回车引发的滚动/blur 误关(钉住浮层仍可点空白关闭)。
|
||||
try{
|
||||
const _nid = Number(pop.dataset.nid), _btn = HAO_BTN;
|
||||
if(typeof haoPopClose === 'function') haoPopClose();
|
||||
setTimeout(() => {
|
||||
try{
|
||||
const _b2 = document.querySelector('#tb1 .haobtn') || _btn;
|
||||
if(_b2) haoPop(_b2, _nid);
|
||||
if(typeof HAO_POP !== 'undefined' && HAO_POP){ HAO_POP.dataset.pinned = '1'; }
|
||||
}catch(e){}
|
||||
}, 250);
|
||||
}catch(e){}
|
||||
};
|
||||
inp.addEventListener('keydown', ev => {
|
||||
if(ev.key === 'Enter'){ ev.preventDefault(); fin(true); }
|
||||
else if(ev.key === 'Escape'){ fin(false); }
|
||||
});
|
||||
inp.addEventListener('blur', () => fin(true));
|
||||
}
|
||||
|
||||
/* 决策 188:子级组成行内编辑(含量→/lme/content;除税/含税→/lme/price 按码定位)。
|
||||
保存后重拉该母行子级列表原位重画,并把母行除税/含税两格更新为 Σ(含量×价)——联动立即可见。 */
|
||||
async function reskEdit(td, tr, field){
|
||||
if(td.querySelector('input')) return;
|
||||
const cur = td.textContent.trim();
|
||||
const inp = document.createElement('input');
|
||||
inp.className = 'cellin'; inp.value = (cur==='—'?'':cur); inp.spellcheck = false;
|
||||
inp.addEventListener('input', function(){
|
||||
const f = this.value.replace(/[^\d.]/g, ''), pp = f.split('.');
|
||||
this.value = pp.length > 2 ? pp[0] + '.' + pp.slice(1).join('') : f;
|
||||
});
|
||||
cellEditFill(td);
|
||||
td.textContent = ''; td.appendChild(inp); inp.focus(); inp.select();
|
||||
let done = false;
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
td.classList.remove('editing'); td.style.height = '';
|
||||
const v = inp.value.trim();
|
||||
if(!save || v === cur || v === ''){ td.textContent = cur; return; }
|
||||
const nv = Number(v.replace(/,/g, ''));
|
||||
if(!isFinite(nv) || nv < 0){ $('msg').textContent = '请输入非负数字'; td.textContent = cur; return; }
|
||||
const body = { session_id: SID, p_code: tr.dataset.pcode, res_code: tr.dataset.ccode };
|
||||
if(field === 'content'){ body.qty = nv; }
|
||||
else { body.code = tr.dataset.ccode; body[field] = nv; } // 价格接口按 code 定位(2026-10-24 修:此前漏带 code→行不存在)
|
||||
const r = await J('/api/session/lme/' + (field === 'content' ? 'content' : 'price'),
|
||||
{ method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) });
|
||||
if(!r || !r.ok){ $('msg').textContent = (r && r.msg) || '保存失败'; td.textContent = cur; return; }
|
||||
td.textContent = String(nv);
|
||||
$('msg').textContent = '已保存(母行单价已按 Σ 子级联动)';
|
||||
await reskRefresh(tr);
|
||||
};
|
||||
inp.addEventListener('keydown', ev => {
|
||||
if(ev.key === 'Enter'){ ev.preventDefault(); fin(true); }
|
||||
else if(ev.key === 'Escape'){ fin(false); }
|
||||
});
|
||||
inp.addEventListener('blur', () => fin(true));
|
||||
}
|
||||
/* 重拉某母行的子级并原位重画 + 母行两价格更新为 Σ */
|
||||
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;
|
||||
const pcode = tr.dataset.pcode;
|
||||
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));
|
||||
const rows = (d && d.rows) || [];
|
||||
let snt = 0, stx = 0;
|
||||
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>'
|
||||
+ '<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">' + 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; }
|
||||
if(m && m.parentNode){
|
||||
let ref = m.nextElementSibling;
|
||||
while(tmp.firstChild) m.parentNode.insertBefore(tmp.firstChild, ref);
|
||||
}
|
||||
// 母行两价格 = Σ(视图格位 6=除税 8=含税;税率格保持 —)
|
||||
if(m){
|
||||
const inPop = !!tr.closest('.haopop'); // 浮层布局=直下标;原数据卡走 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);
|
||||
}
|
||||
if(typeof RV_LME_ROWS !== 'undefined' && RV_LME_ROWS && m){
|
||||
// 同步缓存里的母行值(防排序回显旧值)
|
||||
const key = m.dataset.lmeid != null ? Number(m.dataset.lmeid) : null;
|
||||
if(key != null){ const ri = (RV_LME_IDS||[]).indexOf(key);
|
||||
if(ri >= 0 && RV_LME_ROWS[ri]){ RV_LME_ROWS[ri][6] = Math.round((snt + Number.EPSILON) * 100) / 100;
|
||||
RV_LME_ROWS[ri][8] = Math.round((stx + Number.EPSILON) * 100) / 100; } }
|
||||
if(typeof rvCachePut === 'function') rvCachePut();
|
||||
}
|
||||
// 同步「项目工料机」页签内存(LME_ROWS)里的同码行
|
||||
if(typeof LME_ROWS !== 'undefined' && LME_ROWS){
|
||||
const li = LME_ROWS.findIndex(x => x[1] === pcode);
|
||||
if(li >= 0){ LME_ROWS[li][6] = Math.round((snt + Number.EPSILON) * 100) / 100;
|
||||
LME_ROWS[li][8] = Math.round((stx + Number.EPSILON) * 100) / 100; }
|
||||
}
|
||||
}catch(e){ /* 重拉失败不挡保存 */ }
|
||||
}
|
||||
|
||||
const LME_FIELDS = { ntp: 6, taxrate: 7, taxp: 8 }; // 字段 → 数据 r[] 下标
|
||||
function lmePriceCells(tr){
|
||||
const out = {};
|
||||
@@ -1360,6 +1527,7 @@ function lmeEditCell(td, tr, field, cur){
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
const v = inp.value.trim();
|
||||
td.classList.remove('editing'); td.style.height = '';
|
||||
if(!save || v === cur){ td.textContent = cur; return; }
|
||||
const nv = lmeParseNum(v);
|
||||
if(nv !== null && Number.isNaN(nv)){ $('msg').textContent = '请输入数字'; td.textContent = cur; return; }
|
||||
@@ -1421,6 +1589,7 @@ function lmeEditField(td, tr, field){
|
||||
const fin = async save => {
|
||||
if(done) return; done = true;
|
||||
const v = inp.value.trim();
|
||||
td.classList.remove('editing'); td.style.height = '';
|
||||
if(!save || v === cur){ td.textContent = cur; return; }
|
||||
if(field === 'name' && !v){ $('msg').textContent = '名称不能为空'; td.textContent = cur; return; }
|
||||
const body = {session_id: SID, id: Number(tr.dataset.lmeid || tr.dataset.id)};
|
||||
@@ -1626,6 +1795,7 @@ async function inqBatchDl(){
|
||||
async function loadLme(){
|
||||
const d=await J(`/api/session/rows?session_id=${SID}&type=lme`);
|
||||
LME_ROWS=d.rows||[]; LME_SORT={k:-1,dir:1}; // 新数据:排序复位
|
||||
LME_SUB=new Set(d.sub||[]); // 决策 188 收严:带子级集——三价格前端先拦(服务端同款拒)
|
||||
colg('cg0',C_LME_WB); $('th0').innerHTML=lmeHeadHTML();
|
||||
lmeRenderRows();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user