refactor(core): 采纳后端拆分至 adopt_api 并落实决策294/295口径
- 动态汇总分组键改为界面可见字段(决策303),原价四字段与 flags 不再拆行 - 导出 COS:合并并集后按库现值重写汇总行直接子级(决策294) - api_server 大幅瘦身,采纳逻辑独立成册(决策298/299) - 采纳工料机匹配改为只看单位级、先到先占(决策295,取代决策108) - 同步更新相关测试与前端工作台/管理页
This commit is contained in:
@@ -937,8 +937,13 @@ function renderLme(rows, opts) {
|
||||
const submap = (opts && opts.submap) || {};
|
||||
return (rows || []).map((r, i) => {
|
||||
const kids = submap[r[1]] || [];
|
||||
const btn = kids.length ? '<span class="lmesubbtn" title="展开/收起子级组成" onclick="event.stopPropagation();rawLmeSub(this)">−</span> ' : '';
|
||||
const childRows = kids.map(k => '<tr class="lmesub"><td class="c"></td><td class="c"></td>'
|
||||
// 决策 302:把手默认收起(取代 291 补一「默认展开」)——初始 + 号、子行隐藏,点击展开
|
||||
const btn = kids.length ? '<span class="lmesubbtn" data-open="0" title="展开/收起子级组成" onclick="event.stopPropagation();rawLmeSub(this)">+</span> ' : '';
|
||||
// 决策 302:子级叶子行(自己不再带子级)可点选 → 历史对比框采纳落价;带子级的中层=母行,不接
|
||||
const childRows = kids.map(k => '<tr class="lmesub"'
|
||||
+ ((opts.rowClick && !(submap[k[0]] || []).length)
|
||||
? ' data-leaf="1" data-code="' + esc(k[0] || '') + '" data-name="' + esc(k[1] || '') + '" data-unit="' + esc(k[3] || '') + '" data-price="' + esc(k[6] == null ? '' : k[6]) + '" onclick="' + opts.rowClick + "('lme',-1,this)\"" : '')
|
||||
+ ' style="display:none"><td class="c"></td><td class="c"></td>'
|
||||
+ '<td class="c">' + ell(k[0], '—') + '</td><td>' + ell(k[1], '—') + '</td><td>' + ell(k[2], '—') + '</td>'
|
||||
+ '<td class="c u">' + esc(k[3] || '—') + '</td><td class="r">' + num(k[5], 3) + '</td>'
|
||||
+ '<td class="r">' + num(k[6]) + '</td><td class="r">' + num(k[7], 2) + '</td>'
|
||||
@@ -1174,7 +1179,13 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
RV_LME_IDS = null; RV_LME_DS = {}; RV_LME_O2V = null;
|
||||
for (const k in LME_VIEW_DS) RV_LME_DS[k] = LME_VIEW_DS[k]; // 决策 243 源列后视图位→数据位(单击编辑/lmePriceCells/找格共用)
|
||||
const _sk = RV_LME_DS[RV_LME_SORT.k]; // 排序键翻译成数据位(RV_LME_SORT.k 存视图位,表头 ▲/▼ 靠它对位)
|
||||
const view = sortRows(rows, _sk == null ? -1 : _sk, RV_LME_SORT.dir, RV_LME_NUM);
|
||||
let view = sortRows(rows, _sk == null ? -1 : _sk, RV_LME_SORT.dir, RV_LME_NUM);
|
||||
// 决策 302:默认(未点表头排序)带子级把手行稳定沉底——两趟 filter 各自保序,相对序不变、序号随新序连续重排;
|
||||
// 点过表头排序后按排序值全表混排(不再沉底),换数据/复位(RV_LME_SORT={k:-1})回到默认沉底
|
||||
if (RV_LME_SORT.k === -1 && Object.keys(submap).length) {
|
||||
const _hs = r => (submap[r[1]] || []).length > 0;
|
||||
view = view.filter(r => !_hs(r)).concat(view.filter(_hs));
|
||||
}
|
||||
const backend = !!RVO.lmeBackend; // 决策 147/149:后台=后台项目工料机列集(剔除 wb 专列)
|
||||
const cols = backend ? COLS.lme.filter(c => c[5] !== 'wb') : COLS.lme; // 决策 148:列头统一「数量」,与行格严格同列
|
||||
const body = renderLme(view, { rowClass: 'lmerow', subSet: subSet, submap: submap,
|
||||
@@ -1185,6 +1196,13 @@ 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 已在行首位)
|
||||
const idOf = new Map(); // 行对象 → s_lme_proj.id(并行数组)
|
||||
(RV_LME_IDS || []).forEach((v, i) => { if (rows[i]) idOf.set(rows[i], v); }); // 决策 302:先按对象引用配对、后沉底(Map 按行对象取,重排不错位)
|
||||
// 决策 302:默认(未点表头排序)带子级把手行稳定沉底——两趟 filter 各自保序,相对序不变
|
||||
if (RV_LME_SORT.k === -1 && Object.keys(submap).length) {
|
||||
const _hs = r => (submap[r[0]] || []).length > 0;
|
||||
rows = rows.filter(r => !_hs(r)).concat(rows.filter(_hs));
|
||||
}
|
||||
// 视图列 = [序号, 编码, 名称, 规格, 类别?, 单位, 数量, 除税编制价, 税率, 含税编制价];
|
||||
// DS = 各视图列对应的数据下标(序号列无;类别列在 RAW_LME_KIND=0 时既不显示也不占视图下标)。
|
||||
// O2V = 原始列下标→视图下标:rawTbl 表头 onclick 传的是 cols 原始下标(common.js rawTbl),
|
||||
@@ -1200,8 +1218,6 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
const vk = (RV_LME_O2V && RV_LME_O2V[RV_LME_SORT.k] != null) ? RV_LME_O2V[RV_LME_SORT.k] : -1;
|
||||
const dk = (vk >= 0 && RV_LME_DS && RV_LME_DS[vk] != null) ? RV_LME_DS[vk] : -1;
|
||||
const view = sortRows(rows, dk, RV_LME_SORT.dir, RV_LME_NUM); // 共用比较器(2026-10-09 收编)
|
||||
const idOf = new Map(); // 行对象 → s_lme_proj.id(并行数组)
|
||||
(RV_LME_IDS || []).forEach((v, i) => { if (rows[i]) idOf.set(rows[i], v); });
|
||||
const body = view.map((r, i) => {
|
||||
const kind = RAW_LME_KIND
|
||||
? '<td class="c">' + esc(r[4] == null ? '—' : ({ 1: '人工', 2: '材料', 3: '机械', 4: '主材', 5: '设备' }[Number(r[4])] || r[4])) + '</td>'
|
||||
@@ -1209,10 +1225,11 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
const lid = idOf.get(r);
|
||||
const subT = subSet.has(r[0] || '') ? ' title="' + RAW_LME_SUB_TIP + '"' : '';
|
||||
const kids = submap[r[0] || ''] || [];
|
||||
const btn = kids.length ? '<span class="lmesubbtn" title="展开/收起子级组成" onclick="event.stopPropagation();rawLmeSub(this)">−</span> ' : '';
|
||||
// 决策 302:把手默认收起(取代 291 补一「默认展开」)——单位级卡只读,叶子行不接点选
|
||||
const btn = kids.length ? '<span class="lmesubbtn" data-open="0" title="展开/收起子级组成" onclick="event.stopPropagation();rawLmeSub(this)">+</span> ' : '';
|
||||
const ck = v => RAW_LME_KIND
|
||||
? '<td class="c">' + esc(v == null ? '—' : ({ 1: '人工', 2: '材料', 3: '机械', 4: '主材', 5: '设备' }[Number(v)] || v)) + '</td>' : '';
|
||||
const childRows = kids.map(k => '<tr class="lmesub"><td class="c"></td><td class="c">' + ell(k[0], '—') + '</td>'
|
||||
const childRows = kids.map(k => '<tr class="lmesub" style="display:none"><td class="c"></td><td class="c">' + ell(k[0], '—') + '</td>'
|
||||
+ '<td class="l">' + ell(k[1], '—') + '</td><td class="l">' + ell(k[2], '—') + '</td>' + ck(k[4])
|
||||
+ '<td class="c u">' + esc(k[3] || '—') + '</td><td class="r">' + r3(k[5]) + '</td>'
|
||||
+ '<td class="r">' + rm(k[6]) + '</td><td class="r">' + num(k[7], 2) + '</td>'
|
||||
@@ -1236,7 +1253,7 @@ function rawLmeTbl(rows, tip, qtyLabel, extra) {
|
||||
{ cur: RV_LME_SORT.k, dir: RV_LME_SORT.dir, fn: 'rawLmeSort' });
|
||||
}
|
||||
function rawLmeSub(tg) {
|
||||
// 决策 291:人材机汇总父行展开/收起子级(默认展开;只动紧随的 lmesub 子行)
|
||||
// 决策 291:人材机汇总父行展开/收起子级(默认收起=决策 302 取代 291 补一;只动紧随的 lmesub 子行)
|
||||
const tr = tg.closest('tr');
|
||||
if (!tr) return;
|
||||
const open = tg.dataset.open !== '0'; // 当前展开 → 收起
|
||||
@@ -2479,14 +2496,22 @@ function haoRow(x, i, noSub) {
|
||||
+ '<td class="r">' + num(x[9], 2) + '</td>'
|
||||
+ '<td class="r">' + rm(x[7]) + '</td></tr>';
|
||||
}
|
||||
/* 台班 / 配合比的下一级组成(tr.resk):_lme_res 返回 8 列(无税率,恒 —),行插在当前行之后 */
|
||||
/* 台班 / 配合比的下一级组成(tr.resk):_lme_res 返回 10 列(x[8]=has_sub、x[9]=税率),
|
||||
子行可继续 ± 展开;按 data-depth 只清自己的后代,同级兄弟不误删。 */
|
||||
function haoRes(tg) {
|
||||
const tr = tg.closest('tr');
|
||||
const _pop = tg.closest('.haopop');
|
||||
const _adm = !!(_pop && _pop.dataset.adm); // 决策 289 补三:入库浮层的子级走批次库(按浮层带出的批次号)
|
||||
if (tr.dataset.open === '1') { // 已展开 → 收起
|
||||
const _depth = parseInt(tr.dataset.depth || '0', 10) || 0;
|
||||
const _dropDesc = () => {
|
||||
let nx = tr.nextElementSibling;
|
||||
while (nx && nx.classList.contains('resk')) { const n2 = nx.nextElementSibling; nx.remove(); nx = n2; }
|
||||
while (nx && nx.classList.contains('resk')
|
||||
&& (parseInt(nx.dataset.depth || '0', 10) || 0) > _depth) {
|
||||
const n2 = nx.nextElementSibling; nx.remove(); nx = n2;
|
||||
}
|
||||
};
|
||||
if (tr.dataset.open === '1') { // 已展开 → 收起(连带所有后代)
|
||||
_dropDesc();
|
||||
tr.dataset.open = '0'; tg.textContent = '+';
|
||||
return;
|
||||
}
|
||||
@@ -2501,23 +2526,30 @@ function haoRes(tg) {
|
||||
if (tr.dataset.gen !== String(_gen) || tr.dataset.open !== '1') return; // 换代次/被收起:丢弃迟到响应
|
||||
const rows = (d && d.rows) || [];
|
||||
const frag = document.createElement('tbody');
|
||||
// 决策 294 补记三:子行也有 has_sub(x[8])与税率(x[9])——子工料机还能继续展开。
|
||||
// 决策 188:子级行挂 data-pcode/data-ccode + 标题提示(工作台侧单击可编辑 含量/除税/含税)
|
||||
// 决策 289 补三:入库浮层子级只读(编辑链写会话库,批次行不给入口)
|
||||
// 决策 301:凡底下有子级的行,税率/单价均不可填写(Σ子级现算)——resk 行同 haorow 挂
|
||||
// data-sub 供分发器锁格;税率格带子级一律显示「—」。
|
||||
frag.innerHTML = rows.length
|
||||
? rows.map(x => '<tr class="resk" data-pcode="' + esc(tg.dataset.code) + '" data-ccode="' + esc(x[0]) + '"'
|
||||
+ ' title="' + (_adm ? '入库项目子级组成(只读)' : '单击 含量/除税价/含税价 可编辑(母行单价=Σ子级自动联动)') + '">'
|
||||
+ '<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>';
|
||||
let nx = tr.nextElementSibling;
|
||||
while (nx && nx.classList.contains('resk')) { const n3 = nx.nextElementSibling; nx.remove(); nx = n3; } // 补四:插行前先清旧子级(幂等,杜绝重样)
|
||||
nx = tr.nextElementSibling;
|
||||
while (nx && nx.classList.contains('resk')) nx = nx.nextElementSibling;
|
||||
while (frag.firstChild) tr.parentNode.insertBefore(frag.firstChild, nx);
|
||||
? rows.map(x => {
|
||||
const _hs = (x[8] === 1 || x[8] === '1');
|
||||
return '<tr class="resk" data-depth="' + (_depth + 1) + '" data-pcode="' + esc(tg.dataset.code) + '" data-ccode="' + esc(x[0]) + '"'
|
||||
+ (_hs ? ' data-sub="1"' : '')
|
||||
+ ' title="' + (_adm ? '入库项目子级组成(只读)' : (_hs ? '带子级:含量可编辑;单价/税率=Σ子级现算,修改请改它的子数据' : '单击 含量/除税价/含税价 可编辑(母行单价=Σ子级自动联动)')) + '">'
|
||||
+ '<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">' + (_hs ? '—' : (x[9] == null ? '—' : num(x[9], 2))) + '</td>'
|
||||
+ '<td class="r">' + rm(x[7]) + '</td></tr>';
|
||||
}).join('')
|
||||
: '<tr class="resk" data-depth="' + (_depth + 1) + '"><td colspan="9" style="text-align:left">(没有下一级组成)</td></tr>';
|
||||
_dropDesc(); // 补四:插行前先清旧后代(幂等,杜绝重样)
|
||||
const _ref = tr.nextSibling;
|
||||
while (frag.firstChild) tr.parentNode.insertBefore(frag.firstChild, _ref); // 只搬 tr,不把 tbody 塞进 tbody
|
||||
}).catch(() => { // 取数失败:回退成未展开,别卡成假「−」
|
||||
if (tr.dataset.open === '1') { tr.dataset.open = '0'; tg.textContent = '+'; }
|
||||
});
|
||||
@@ -3319,9 +3351,12 @@ function licDlg() {
|
||||
licEnsureStyle();
|
||||
// 规格 2026-10-17「重启后永远最新」:弹框里亮出程序代码更新时间与服务启动时间——
|
||||
// 主人不用再猜现在跑的是不是最新程序(旧实例被启动器自动升级重启,见 shell.py)。
|
||||
// 决策 301:前后端分列——后端时间=运行实例加载的代码(重启生效);前端时间=ui 目录实时
|
||||
// 最新 mtime(前端无运行实例,刷新页面即取磁盘最新),改完前端文件对一眼即知要不要刷新。
|
||||
fetch('/api/version').then(r => r.json()).then(v => {
|
||||
const el = document.getElementById('licVer');
|
||||
if (el && v && v.ok) el.textContent = '程序代码更新:' + v.code_mtime + ' | 服务启动:' + (v.started_at || '—') + '(端口 ' + v.port + ')';
|
||||
if (el && v && v.ok) el.textContent = '后端代码更新:' + v.code_mtime + '(重启生效)| 前端代码更新:'
|
||||
+ (v.ui_mtime || '—') + '(刷新页面生效)| 服务启动:' + (v.started_at || '—') + '(端口 ' + v.port + ')';
|
||||
}).catch(() => {});
|
||||
// 强制更新状态(2026-10-27《企业和个人版.md》5.9):当前版本/最新/最低要求——版本卡
|
||||
fetch('/api/version_info').then(r => r.json()).then(d => {
|
||||
|
||||
Reference in New Issue
Block a user