feat(export): 恢复旧导出引擎并加固换行与舍入、新增采纳来源溯源与项目目录排序
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<style>
|
||||
:root{--c1:#123a6b;--c2:#1f5fae;--line:#c9d4e2;--head:#eef3fa;--bg:#f5f7fa;--txt:#1c2733;--muted:#5a6b7f}
|
||||
*{box-sizing:border-box}
|
||||
body{font-family:"Source Han Sans SC","Noto Sans SC","Source Han Sans CN","MiSans","HarmonyOS Sans SC","Microsoft YaHei",sans-serif;margin:0;background:var(--bg);color:var(--txt);font-size:13px}
|
||||
body{font-family:"Noto Sans SC","Source Han Sans SC","Source Han Sans CN","MiSans","HarmonyOS Sans SC","Microsoft YaHei",sans-serif;margin:0;background:var(--bg);color:var(--txt);font-size:13px}
|
||||
.wrap{margin:0 auto;padding:10px 16px 14px} /* 2026-10-07 去 1760 上限:面板吃满窗口(主人定) */
|
||||
/* h1 标题行与 .sub 统计行已于 2026-10-06 去掉(主人定),对应样式一并删除,不留死代码。 */
|
||||
/* 数据过期提示条已于 2026-10-11 取消(主人定):打开即自动升级(决策 34)后「需重导」口径不再成立。 */
|
||||
@@ -2082,6 +2082,8 @@ function resetF(){fq.value='';fp.value='';fc.value='';fd.value='';setPeriod($('f
|
||||
load(1)}
|
||||
|
||||
document.querySelectorAll('.tab[data-kind]').forEach(t=>t.onclick=()=>{
|
||||
const fromQ=(KIND==='qlist');
|
||||
if(fromQ && t.dataset.kind!=='qlist') qlSnap(); // 离开清单页:抓拍选中/展开/滚动(2026-11-05 记忆口径)
|
||||
document.querySelectorAll('.tab[data-kind]').forEach(x=>x.classList.remove('on'));
|
||||
t.classList.add('on'); KIND=t.dataset.kind; SORT={key:'',dir:'DESC'}; syncBtns();
|
||||
XLAST=KIND;
|
||||
@@ -2091,6 +2093,7 @@ document.querySelectorAll('.tab[data-kind]').forEach(t=>t.onclick=()=>{
|
||||
showPage('qlist'); qlLoad(); return;
|
||||
}
|
||||
if(XACT>=0){ XACT=-1; renderXTabs(); showDetail(false); xsave(); } // 从明细标签切回列表区(动态标签保留)
|
||||
else if(fromQ) showPage('list'); // 从清单页切回列表区:showPage 藏掉 klpage(否则穿帮挂在列表下面,2026-11-05 实测修)
|
||||
ldWrap('','正在加载列表…',()=>{ load(1); loadFilters(); }); // 列表取数期间挂进度条(快则不闪);loadFilters=过滤文案随页签刷新(2026-11-02 询价单位/发布单位)
|
||||
});
|
||||
// 2026-10-13 主人定:切标签没出全数据前要有进度条 —— 走共享层 ldWrap(det() 进来的路径
|
||||
@@ -3025,7 +3028,7 @@ dmask.onclick = e => { if(e.target===dmask) closeDict() };
|
||||
两棵树探索器式 +/- 把手 + 连线;目录可编辑(+子目录/✎/↑/↓/✕,错误提示走 alert,同价格目录)。
|
||||
后端:GET /api/admin/qlist/tree、/api/admin/qlist/items?dir_id=;
|
||||
POST /api/admin/qlist/save(目录)、/api/admin/qlist/items(条目)。 */
|
||||
const QL={tree:[],root:0,sel1:0,sel2:0,open1:{},open2:{},rows:[],ren:0,newp:0,edit:0};
|
||||
const QL={tree:[],root:0,sel1:0,sel2:0,open1:{},open2:{},rows:[],ren:0,newp:0,edit:0,loaded:false,_mem:null};
|
||||
function qlNode(id,list){ // 按 id 找节点(QL.tree 顶层=省列表;根是虚拟节点)
|
||||
list=list||QL.tree;
|
||||
for(const n of list){ if(n.id===id) return n; const h=qlNode(id,n.children); if(h) return h; }
|
||||
@@ -3103,7 +3106,10 @@ function qlHtml2(){
|
||||
return '<ul class="ktree">'+qlNewRow(n.id,2)+'</ul>';
|
||||
return '<div class="khint">「'+esc(n.name)+'」还没有章节目录 ——<br>点上面「+子目录」建第一个</div>';
|
||||
}
|
||||
return '<ul class="ktree">'+n.children.map(c=>qlLi2(c)).join('')+'</ul>';
|
||||
return '<ul class="ktree">'+n.children.map(c=>qlLi2(c)).join('')
|
||||
// 顶层新增行:+子目录没选中章节时挂在清单名称下(与已有章节同列,连线连续)——2026-11-05 实测补
|
||||
+((QL.newp && QL.newp.region===2 && QL.newp.parent===n.id)?qlNewRow(n.id,2):'')
|
||||
+'</ul>';
|
||||
}
|
||||
function qlLi2(n){
|
||||
const kids=n.children||[], open=QL.open2[n.id]!==false;
|
||||
@@ -3194,7 +3200,7 @@ async function qlNewGo(){
|
||||
if(!name){ qlRender1(); qlRender2(); return; }
|
||||
const r=await qlDirPost({op:'add',parent_id:parent,name});
|
||||
if(!r){ qlRender1(); qlRender2(); return; }
|
||||
await qlLoad();
|
||||
await qlLoad(true);
|
||||
if(r.id){ // 新清单名称=自动选中(区域2立即可用);新章节=自动选中出条目表
|
||||
if(r.depth===2) qlSel1(r.id);
|
||||
else if(r.depth>=3 && qlNode(QL.sel1) && qlParent(r.id)===QL.sel1) qlSel2(r.id);
|
||||
@@ -3219,12 +3225,12 @@ async function qlRenGo(){
|
||||
if(!name){ qlRender1(); qlRender2(); return; }
|
||||
const r=await qlDirPost({op:'rename',id:did,name});
|
||||
if(!r){ qlRender1(); qlRender2(); return; }
|
||||
await qlLoad();
|
||||
await qlLoad(true);
|
||||
}
|
||||
async function qlSeq(d,region){
|
||||
const id=(region===1)?QL.sel1:QL.sel2; if(!id) return;
|
||||
const r=await qlDirPost({op:'seq',id:id,dir:d>0?'down':'up'});
|
||||
if(!r) return; await qlLoad();
|
||||
if(!r) return; await qlLoad(true);
|
||||
}
|
||||
function qlSeq1(d){ qlSeq(d,1); } function qlSeq2(d){ qlSeq(d,2); }
|
||||
async function qlDel1(){
|
||||
@@ -3234,7 +3240,7 @@ async function qlDel1(){
|
||||
(n.children&&n.children.length)?'它下面还有子目录,要先删光子目录才能删它。':'删除后不可恢复。'))) return;
|
||||
const r=await qlDirPost({op:'del',id:id}); if(!r) return;
|
||||
if(QL.sel1===id){ QL.sel1=0; QL.sel2=0; QL.rows=[]; }
|
||||
await qlLoad();
|
||||
await qlLoad(true);
|
||||
}
|
||||
async function qlDel2(){
|
||||
const id=QL.sel2; if(!id) return;
|
||||
@@ -3245,16 +3251,52 @@ async function qlDel2(){
|
||||
if(!(await uiConfirm('删除章节目录「'+n.name+'」?', warn.length?warn.join(';'):'删除后不可恢复。'))) return;
|
||||
const r=await qlDirPost({op:'del',id:id}); if(!r) return;
|
||||
if(QL.sel2===id){ QL.sel2=0; QL.rows=[]; }
|
||||
await qlLoad();
|
||||
await qlLoad(true);
|
||||
}
|
||||
/* ---- 加载 ---- */
|
||||
async function qlLoad(){
|
||||
/* ---- 无感 + 记忆(2026-11-05 主人定):切走抓拍 / 切回恢复 ----
|
||||
记忆=选中目录 + 树展开 + 三区滚动(同工作台决策 214 页签状态记忆口径);
|
||||
切回时内存已有树先按现态立即渲染(不闪不重置=无感),再后台重拉保证新鲜;
|
||||
抓拍入 sessionStorage(同后台明细标签决策 150 口径)——跳工作台再回来、刷新页面都还在。
|
||||
正在编辑的行内输入/条目编辑不进记忆(切回=已保存状态,与决策 214 同口径)。 */
|
||||
const QLSNAP='admin_qlist';
|
||||
function qlSnap(){ try{
|
||||
sessionStorage.setItem(QLSNAP, JSON.stringify({
|
||||
sel1:QL.sel1, sel2:QL.sel2, open1:QL.open1, open2:QL.open2,
|
||||
sc1:$('ktree1')?$('ktree1').scrollTop:0, sc2:$('ktree2')?$('ktree2').scrollTop:0,
|
||||
sc3:$('kbody3')?$('kbody3').scrollTop:0}));
|
||||
}catch(e){} }
|
||||
function qlUnsnap(){ try{
|
||||
const s=sessionStorage.getItem(QLSNAP); return s?JSON.parse(s):null;
|
||||
}catch(e){ return null; } }
|
||||
function qlApplyScroll(mem){ // innerHTML 重渲染会重置 scrollTop,渲染后重挂
|
||||
if(!mem) return;
|
||||
const a=$('ktree1'), b=$('ktree2'), c=$('kbody3');
|
||||
if(a) a.scrollTop=mem.sc1||0;
|
||||
if(b) b.scrollTop=mem.sc2||0;
|
||||
if(c) c.scrollTop=mem.sc3||0;
|
||||
}
|
||||
async function qlLoad(noMem){
|
||||
// noMem=true=本页操作后的刷新(新增/改名/上下移/删除/存条目):内存 QL 态就是最新事实,
|
||||
// 绝不回读记忆(旧抓拍会把切走前的选中盖回来)。记忆只在「从别的标签/页面切回」时恢复一次。
|
||||
const mem=noMem?null:qlUnsnap();
|
||||
if(mem){ // 记忆先落 QL(选中/展开立即恢复,含跨刷新)
|
||||
if(Number.isInteger(mem.sel1)) QL.sel1=mem.sel1;
|
||||
if(Number.isInteger(mem.sel2)) QL.sel2=mem.sel2;
|
||||
QL.open1=mem.open1||{}; QL.open2=mem.open2||{};
|
||||
}
|
||||
QL._mem=mem;
|
||||
if(QL.loaded){ // 内存已有树:现态立即上屏(切回瞬间出画面,无感),随后再刷新
|
||||
qlRender1(); qlRender2(); qlLoadItems();
|
||||
qlApplyScroll(QL._mem);
|
||||
}
|
||||
const d=await J('/api/admin/qlist/tree');
|
||||
if(d.ok===false){ alert(d.msg||'清单库加载失败'); return; }
|
||||
QL.tree=d.tree||[]; QL.root=d.root||0;
|
||||
QL.tree=d.tree||[]; QL.root=d.root||0; QL.loaded=true;
|
||||
if(QL.sel1 && QL.sel1!==QL.root && !qlNode(QL.sel1)){ QL.sel1=0; QL.sel2=0; QL.rows=[]; }
|
||||
if(QL.sel2 && !qlNode(QL.sel2)){ QL.sel2=0; QL.rows=[]; }
|
||||
qlRender1(); qlRender2(); qlLoadItems();
|
||||
qlApplyScroll(QL._mem);
|
||||
}
|
||||
/* ---- 区域3:真正的清单条目(编码/名称/项目特征/单位/工程量)---- */
|
||||
async function qlLoadItems(){
|
||||
@@ -3271,6 +3313,7 @@ async function qlLoadItems(){
|
||||
QL.rows=d.rows||[];
|
||||
tb.innerHTML=QL.rows.length?QL.rows.map(qlItemRow).join('')
|
||||
:'<tr><td colspan="6" class="kempty">这个章节还没有条目 —— 点「+条目」录第一条(工程量默认 1.000)</td></tr>';
|
||||
qlApplyScroll(QL._mem); // 条目表内容到位后再挂一次滚动记忆
|
||||
}
|
||||
function qlItemRow(r){
|
||||
if(QL.edit===r.id){
|
||||
@@ -3310,7 +3353,7 @@ async function qlItemSave(id){
|
||||
const r=await J('/api/admin/qlist/items',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify(body)});
|
||||
if(!r.ok){ alert(r.msg); return; }
|
||||
QL.edit=0; await qlLoad(); // 整树重拉:区域1/2 的条数徽章同步刷新
|
||||
QL.edit=0; await qlLoad(true); // 整树重拉:区域1/2 的条数徽章同步刷新(操作后刷新不走记忆)
|
||||
}
|
||||
async function qlItemDel(id){
|
||||
const r0=QL.rows.find(x=>x.id===id);
|
||||
@@ -3318,8 +3361,10 @@ async function qlItemDel(id){
|
||||
const r=await J('/api/admin/qlist/items',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({op:'del',id:id})});
|
||||
if(!r.ok){ alert(r.msg); return; }
|
||||
await qlLoad();
|
||||
await qlLoad(true);
|
||||
}
|
||||
// 页面卸载前也抓拍一次:没点标签直接跳工作台/关页,记忆不丢(sessionStorage 跨跳转保留)
|
||||
window.addEventListener('beforeunload', ()=>{ if(KIND==='qlist') qlSnap(); });
|
||||
// 页面初载(2026-10-13 主人定:进页面要等待时挂进度条——从工作台切过来时首屏不再是空白静默)
|
||||
(async function(){
|
||||
await ldWrap('','正在加载后台数据(项目/筛选/汇总)…', async ()=>{
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
依赖变量:--c1 主色 / --c2 次色 / --line 分隔线 / --muted 次要文字 / --head 表头底色
|
||||
============================================================ */
|
||||
|
||||
/* ---- 打包字体(2026-11-05 字体加固,主人拍板)----
|
||||
Noto Sans SC,SIL OFL 1.1,免费商用、可随软件分发(许可正文:ui/fonts/LICENSE-OFL.txt)。
|
||||
woff2 为子集(GB2312 全集+界面字符,共 7749 字),由 test/字体加固/生成字体.py 生成;
|
||||
子集未覆盖的生僻字由微软雅黑兜底(仅名字引用,用户系统自带,不随软件分发)。 */
|
||||
@font-face{font-family:"Noto Sans SC";src:url("fonts/NotoSansSC-Regular.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap}
|
||||
@font-face{font-family:"Noto Sans SC";src:url("fonts/NotoSansSC-Bold.woff2") format("woff2");font-weight:700;font-style:normal;font-display:swap}
|
||||
body{font-family:"Noto Sans SC","Microsoft YaHei",system-ui,sans-serif}
|
||||
|
||||
#tabbar .tab, #dtabs .tab{height:24px;min-height:24px;max-height:24px;flex-shrink:0;align-self:flex-end}
|
||||
|
||||
/* ---- 原数据:左侧目录树 + 右侧标签卡 ---- */
|
||||
|
||||
93
CostReview/app/ui/fonts/LICENSE-OFL.txt
Normal file
93
CostReview/app/ui/fonts/LICENSE-OFL.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -7,7 +7,7 @@
|
||||
:root{--c1:#123a6b;--c2:#1f5fae;--line:#c9d4e2;--head:#eef3fa;--bg:#f5f7fa;--txt:#1c2733;--muted:#5a6b7f}
|
||||
*{box-sizing:border-box}
|
||||
html,body{height:100%}
|
||||
body{font-family:"Microsoft YaHei",system-ui,sans-serif;margin:0;background:var(--bg);color:var(--txt);font-size:13px}
|
||||
body{font-family:"Noto Sans SC","Microsoft YaHei",system-ui,sans-serif;margin:0;background:var(--bg);color:var(--txt);font-size:13px}
|
||||
/* 2026-10-22 主人定:显示区按最大行撑满(去掉原 max-height:100vh-230px 的底部留白);
|
||||
行数超过可视范围走前端分页(只改显示,接口/数据逻辑不动)。 */
|
||||
.wrap{margin:0 auto;padding:10px 16px 14px;height:100%;display:flex;flex-direction:column}
|
||||
@@ -48,6 +48,13 @@ tr:hover td{background:#f6f9fd}
|
||||
.manualtag{color:#1f5fae;font-weight:600;white-space:nowrap}
|
||||
a{color:var(--c2);text-decoration:none;cursor:pointer}
|
||||
a:hover{text-decoration:underline}
|
||||
/* 目录分组折叠(2026-11-05 主人定):列表按目录聚组,组头行最左 ± 把手收/放该目录的项目 */
|
||||
tr.pfh td{background:var(--head);padding:3px 8px;font-size:12px;white-space:nowrap;border-left:none;border-right:none}
|
||||
tr.pfh .pfh-b{display:inline-flex;width:16px;height:16px;align-items:center;justify-content:center;cursor:pointer;color:#52708f;font-family:Consolas,monospace;font-weight:700;user-select:none;border:1px solid #b8c4d4;border-radius:4px;background:#fff;line-height:1}
|
||||
tr.pfh .pfh-b:hover{color:var(--c2);border-color:var(--c2)}
|
||||
tr.pfh .pfh-n{font-weight:600;color:var(--c1);cursor:pointer}
|
||||
tr.pfh .pfh-n:hover{text-decoration:underline}
|
||||
tr.pfh .pfh-c{color:var(--muted);font-size:11px;margin-left:5px}
|
||||
/* 统一弹框体系(2026-10-19 主人定:删除确认按「风格预览」里打开项目的弹框样式) */
|
||||
.mask{position:fixed;inset:0;background:rgba(20,30,45,.45);display:none;align-items:center;justify-content:center;z-index:99}
|
||||
.mask.on{display:flex}
|
||||
@@ -70,9 +77,19 @@ a:hover{text-decoration:underline}
|
||||
.pdrow .tw{width:16px;flex:none;text-align:center;cursor:pointer;color:#52708f;font-family:Consolas,monospace;font-weight:700;user-select:none;font-size:14px}
|
||||
.pdrow .tw:hover{color:var(--c2)}
|
||||
.pdrow .tw.off{visibility:hidden;cursor:default}
|
||||
/* 树形连接虚线(2026-11-05 主人定:节点间虚线连接,每层把手错一个把手位 16px;
|
||||
祖先还有后续兄弟→整行竖虚线;末支→肘形「└」竖勾(上半行)+横虚线接入把手) */
|
||||
.pdrow .ln{flex:none;position:relative}
|
||||
.pdrow .ln.v{width:16px;align-self:stretch}
|
||||
.pdrow .ln.v::before{content:'';position:absolute;left:8px;top:0;bottom:0;border-right:1px dashed #9fb2c6}
|
||||
.pdrow .ln.s{width:16px}
|
||||
.pdrow .ln.h{width:16px;align-self:stretch}
|
||||
.pdrow .ln.h::before{content:'';position:absolute;left:8px;top:0;height:50%;border-right:1px dashed #9fb2c6}
|
||||
.pdrow .ln.h::after{content:'';position:absolute;left:8px;right:0;top:50%;border-top:1px dashed #9fb2c6}
|
||||
.pdrow .dn{font-weight:600;color:var(--c1);overflow:hidden;text-overflow:ellipsis}
|
||||
.pdrow .cnt{color:var(--muted);font-size:11px}
|
||||
.pdrow .pn{color:#26405e;overflow:hidden;text-overflow:ellipsis}
|
||||
.pdrow.pj{cursor:pointer} /* 项目行可点选(2026-11-05:选中后 ↑↓ 同级移动) */
|
||||
.pdrow .ic{color:#b8860b;font-size:12px;flex:none}
|
||||
.pdrow select{max-width:280px;height:24px;font:inherit;font-size:12px;border:1px solid #b8c4d4;border-radius:5px;background:#fff;color:#26405e;padding:0 4px}
|
||||
.pdrow select:focus{outline:2px solid #9cc3ec}
|
||||
@@ -136,7 +153,7 @@ a:hover{text-decoration:underline}
|
||||
<div style="display:flex;flex-direction:column;min-height:0;flex:1">
|
||||
<div class="rtbar" id="pdrt"></div>
|
||||
<div class="pdtree" id="pdtree"></div>
|
||||
<div class="pdnote">提示:点项目行的「所属目录」下拉直接改归属;目录按钮作用于选中的目录(未选中时只有「+子目录」=新增一级根目录);删除目录=其子目录一并删除,目录内项目回「未归类」。</div>
|
||||
<div class="pdnote">提示:点项目行的「所属目录」下拉改归属;点选目录或项目行后用 ↑/↓ 在<strong>同级内</strong>移动(不可跨级、不改归属);未归类不算目录、不能建子级;目录最多 3 层;删除目录=其子目录一并删除,目录内项目回「未归类」。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -243,7 +260,19 @@ function render(){
|
||||
rowsToShow=view.slice(st,st+size);
|
||||
}else PAG.p=1;
|
||||
let h='';
|
||||
/* 目录分组折叠(2026-11-05 主人定):同目录项目聚组,组头行最左 ± 把手收/放该组项目;
|
||||
组序=组内首行在当前排序里的位置(组内保持现有排序相对序);折叠的组只留组头。 */
|
||||
const gmap=new Map();
|
||||
rowsToShow.forEach(r=>{
|
||||
const g=r[2]||'未归类';
|
||||
if(!gmap.has(g)) gmap.set(g,[]);
|
||||
gmap.get(g).push(r);
|
||||
});
|
||||
gmap.forEach((grs,gname)=>{
|
||||
const folded=!!PFCOL[gname];
|
||||
h+=`<tr class="pfh"><td class="c"><span class="pfh-b" data-g="${esc(gname)}" title="${folded?'展开':'折叠'}「${esc(gname)}」下的项目" onclick="pfToggle(this.dataset.g)">${folded?'+':'−'}</span></td>`
|
||||
+`<td colspan="${SCOLS.length-1}"><span class="pfh-n" data-g="${esc(gname)}" title="${folded?'展开':'折叠'}" onclick="pfToggle(this.dataset.g)">📁 ${esc(gname)}</span><span class="pfh-c">(${grs.length})</span></td></tr>`;
|
||||
if(!folded) grs.forEach(r=>{
|
||||
const srcCell = r[10]
|
||||
? `<span class="manualtag" title="手工工程:没有源文件,不能按原格式导出/重新解析;要上源文件数据请先删除本工程,再按源文件重新导入(同名导入会被拒,决策 242)">手工创建</span>`
|
||||
: (r[9]
|
||||
@@ -261,10 +290,12 @@ function render(){
|
||||
<a onclick="go(${r[0]})" title="打开最近一次审核,接着上次的活干">打开</a>
|
||||
<a onclick="del([${(r[7]||[]).join(',')}])" style="margin-left:8px;color:#c0392b">删除</a>
|
||||
</td></tr>`;
|
||||
});
|
||||
});
|
||||
$('tbody').innerHTML=h||`<tr><td colspan="${SCOLS.length}" class="empty">没有匹配的会话</td></tr>`;
|
||||
/* 行高实测回填(行高变了且正在分页 → 重算一次;rowH 稳定后不再二次渲染) */
|
||||
const fr=$('tbody').firstElementChild;
|
||||
/* 行高实测回填(行高变了且正在分页 → 重算一次;rowH 稳定后不再二次渲染);
|
||||
首行可能是目录组头行(高度不同),量行高要用项目行 */
|
||||
const fr=$('tbody').querySelector('tr:not(.pfh)');
|
||||
if(fr && !fr.classList.contains('empty')){
|
||||
const rh=fr.getBoundingClientRect().height;
|
||||
if(rh && Math.abs(rh-(PAG.rowH||0))>0.5){ PAG.rowH=rh; if(view.length>PAG.size){ render(); return; } }
|
||||
@@ -281,6 +312,12 @@ function render(){
|
||||
/* 分页翻页(前端切片,不动数据) */
|
||||
const PAG={p:1,size:0,rowH:0};
|
||||
function pgGo(d){ PAG.p+=d; render(); }
|
||||
/* 目录分组折叠状态(2026-11-05 主人定):跨刷新记忆进 localStorage(存折叠中的目录名数组) */
|
||||
let PFCOL={};
|
||||
function pfFoldLoad(){ try{ const a=JSON.parse(localStorage.getItem('sess_dir_fold_v1')||'[]');
|
||||
(Array.isArray(a)?a:[]).forEach(n=>{ PFCOL[n]=1; }); }catch(e){} }
|
||||
function pfFoldSave(){ try{ localStorage.setItem('sess_dir_fold_v1', JSON.stringify(Object.keys(PFCOL))); }catch(e){} }
|
||||
function pfToggle(g){ if(PFCOL[g]) delete PFCOL[g]; else PFCOL[g]=1; pfFoldSave(); render(); }
|
||||
function selAll(el){ document.querySelectorAll('.f-sel').forEach(x=>x.checked=el.checked); updDel(); }
|
||||
function updDel(){
|
||||
const n=document.querySelectorAll('.f-sel:checked').length;
|
||||
@@ -327,18 +364,18 @@ document.addEventListener('keydown',function(e){
|
||||
· 项目行「所属目录」下拉直接改归属(归属键=项目名称,删工程/重导入不丢);
|
||||
· 目录 增/改名/删/上下移 收编根工具排,作用于选中目录(决策 48 同款:
|
||||
未选中时只有「+子目录」=新增一级根目录;↑↓✕ 两段式确认)。 */
|
||||
let PDIRS=[], PASG={}, PDSEL=0, PDCOL={_n:1}, PDNEW=null, PDREN=0, PDBUSY=false;
|
||||
let PDIRS=[], PASG={}, PORD={}, PDSEL=0, PDSELP='', PDCOL={_n:1}, PDNEW=null, PDREN=0, PDBUSY=false;
|
||||
|
||||
async function pdOpen(){
|
||||
PDSEL=0; PDNEW=null; PDREN=0; PDCOL={};
|
||||
PDSEL=0; PDSELP=''; PDNEW=null; PDREN=0; PDCOL={};
|
||||
$('pdmask').classList.add('on');
|
||||
try{ await pdReload(); }
|
||||
catch(e){ PDIRS=[]; PASG={}; pdDraw(); toast('目录读取失败:'+e.message); }
|
||||
catch(e){ PDIRS=[]; PASG={}; PORD={}; pdDraw(); toast('目录读取失败:'+e.message); }
|
||||
}
|
||||
function pdClose(){ $('pdmask').classList.remove('on'); }
|
||||
async function pdReload(){
|
||||
const d=await J('/api/projdirs');
|
||||
PDIRS=d.dirs||[]; PASG=d.map||{};
|
||||
PDIRS=d.dirs||[]; PASG=d.map||{}; PORD=d.porder||{};
|
||||
syncListDirs(); pdDraw();
|
||||
}
|
||||
async function pdSave(body){
|
||||
@@ -366,10 +403,16 @@ function pdName(id){ const d=PDIRS.find(x=>x.id===id); return d?d.name:''; }
|
||||
function pdPath(id){ const p=[]; let d=PDIRS.find(x=>x.id===id); const seen=new Set();
|
||||
while(d && !seen.has(d.id)){ seen.add(d.id); p.unshift(d.name); d=PDIRS.find(x=>x.id===(+d.parent|0)); }
|
||||
return p.join('/'); }
|
||||
/* 组内项目排序(2026-11-05 主人定:同级可 ↑↓ 移动):porder 里排过的按序在前,没排过的按列表原序在后 */
|
||||
function _pdOrdIdx(pid, nm){ const o=PORD[String(pid|0)]||[]; const k=o.indexOf(nm); return k<0?99999:k; }
|
||||
function pdItemsIn(pid){ return ITEMS.filter(x=>{ const n=(x.name||'').trim();
|
||||
return n && (+PASG[n]||0)===(pid|0); }); }
|
||||
return n && (+PASG[n]||0)===(pid|0); })
|
||||
.sort((a,b)=>_pdOrdIdx(pid,(a.name||'').trim())-_pdOrdIdx(pid,(b.name||'').trim())); }
|
||||
function pdItemsNone(){ return ITEMS.filter(x=>{ const n=(x.name||'').trim();
|
||||
return !n || !(+PASG[n]||0); }); }
|
||||
return !n || !(+PASG[n]||0); })
|
||||
.sort((a,b)=>{ const na=(a.name||'').trim(), nb=(b.name||'').trim();
|
||||
if(!na && nb) return -1; if(na && !nb) return 1; // 无名项目排最上(不可选不可移)
|
||||
return _pdOrdIdx(0,na)-_pdOrdIdx(0,nb); }); }
|
||||
function pdDepth(id){ // 目录层号:根=1,子=2,孙=3(2026-11-04 主人定:目录最多 3 层)
|
||||
let lvl=0, cur=id; const seen=new Set();
|
||||
while(cur && !seen.has(cur)){ seen.add(cur); lvl++;
|
||||
@@ -384,18 +427,28 @@ function pdDirOpts(cur){
|
||||
walk(0);
|
||||
return h;
|
||||
}
|
||||
function pdProjRow(x, depth){
|
||||
/* 树形连接线段(2026-11-05 主人定):prefix=祖先层列表(true=该层还有后续兄弟→竖虚线;
|
||||
false=末支→空白占位)。每层占 16px=一个把手位;非根级再补一条横虚线接入本节点把手。 */
|
||||
function pdLines(prefix){
|
||||
let h='';
|
||||
(prefix||[]).forEach(k=>{ h+= k?'<span class="ln v"></span>':'<span class="ln s"></span>'; });
|
||||
if(prefix && prefix.length) h+='<span class="ln h"></span>';
|
||||
return h;
|
||||
}
|
||||
function pdProjRow(x, prefix){
|
||||
const nm=(x.name||'').trim();
|
||||
const cur=nm?(+PASG[nm]||0):0;
|
||||
return `<div class="pdrow pj" style="padding-left:${depth*18+4}px">
|
||||
<span class="tw off"></span><span class="ic">📄</span>
|
||||
const sel=nm && PDSELP===nm;
|
||||
return `<div class="pdrow pj${sel?' sel':''}"${nm?` data-pn="${esc(nm)}" title="点选后可用上方 ↑/↓ 在同级内移动(不改归属、不可跨级)" onclick="pdSelProj(this.dataset.pn,event)"`:''} style="padding-left:4px;${nm?'cursor:pointer':''}">
|
||||
${pdLines(prefix)}<span class="tw off"></span><span class="ic">📄</span>
|
||||
<span class="pn" style="max-width:360px" title="${esc(nm||'(无名)')}">${esc(nm||'(无名)')}</span>
|
||||
<select ${nm?'':'disabled title="无名项目不能归类"'} title="改所属目录" onclick="event.stopPropagation()"
|
||||
onchange="pdAssign(${x.id},this)">${pdDirOpts(cur)}</select></div>`;
|
||||
}
|
||||
function pdDirRow(d, depth){
|
||||
function pdDirRow(d, prefix){
|
||||
const kd=pdKids(d.id).length, pj=pdItemsIn(d.id).length;
|
||||
let h=`<div class="pdrow${PDSEL===d.id?' sel':''}" onclick="pdSel(${d.id},event)" style="padding-left:${depth*18+4}px">`;
|
||||
let h=`<div class="pdrow${PDSEL===d.id?' sel':''}" onclick="pdSel(${d.id},event)" style="padding-left:4px">`;
|
||||
h+=pdLines(prefix);
|
||||
h+= (kd+pj)>0
|
||||
? `<span class="tw" title="${PDCOL[d.id]?'展开':'收起'}" onclick="pdToggle(event,${d.id})">${PDCOL[d.id]?'+':'−'}</span>`
|
||||
: '<span class="tw off"></span>';
|
||||
@@ -409,24 +462,27 @@ function pdDirRow(d, depth){
|
||||
h+=`<span class="cnt">(${kd+pj})</span></div>`;
|
||||
return h;
|
||||
}
|
||||
function pdNewRow(depth){
|
||||
function pdNewRow(prefix){
|
||||
const ph=(PDNEW && (+PDNEW.parent|0)===0)?'根目录名称:回车确认 / ESC 取消':'子目录名称:回车确认 / ESC 取消';
|
||||
return `<div class="pdrow" style="padding-left:${depth*18+4}px"><span class="tw off"></span><span class="ic">📁</span>
|
||||
return `<div class="pdrow" style="padding-left:4px">${pdLines(prefix)}<span class="tw off"></span><span class="ic">📁</span>
|
||||
<input class="ren" id="pdnewin" placeholder="${ph}"
|
||||
onkeydown="pdNewKey(event)" onblur="pdNewBlur()"></div>`;
|
||||
}
|
||||
function pdDirRows(pid, depth){
|
||||
function pdDirRows(pid, depth, prefix){
|
||||
let h='';
|
||||
pdKids(pid).forEach(d=>{
|
||||
h+=pdDirRow(d, depth);
|
||||
if(PDNEW && PDNEW.mode==='sib' && PDNEW.sib===d.id) h+=pdNewRow(depth); // +平级:插在它后面
|
||||
if(PDNEW && PDNEW.mode==='child' && (+PDNEW.parent|0)===d.id) h+=pdNewRow(depth+1); // +子目录:输入框紧跟父行
|
||||
const kids=pdKids(pid);
|
||||
kids.forEach((d,i)=>{
|
||||
const isLast=i===kids.length-1;
|
||||
const kidPrefix=(prefix||[]).concat(!isLast); // 本目录还有后续兄弟→子级行在此层画竖虚线
|
||||
h+=pdDirRow(d, prefix);
|
||||
if(PDNEW && PDNEW.mode==='sib' && PDNEW.sib===d.id) h+=pdNewRow(prefix); // +平级:与本目录同级
|
||||
if(PDNEW && PDNEW.mode==='child' && (+PDNEW.parent|0)===d.id) h+=pdNewRow(kidPrefix); // +子目录:子级位
|
||||
if(!PDCOL[d.id]){
|
||||
h+=pdDirRows(d.id, depth+1);
|
||||
pdItemsIn(d.id).forEach(x=>{ h+=pdProjRow(x, depth+1); }); // 项目挂目录下一级
|
||||
h+=pdDirRows(d.id, depth+1, kidPrefix);
|
||||
pdItemsIn(d.id).forEach(x=>{ h+=pdProjRow(x, kidPrefix); }); // 项目挂目录下一级
|
||||
}
|
||||
});
|
||||
if(PDNEW && PDNEW.mode==='child' && (+PDNEW.parent|0)===0 && pid===0) h+=pdNewRow(depth); // 新增一级根目录:排在根级末尾
|
||||
if(PDNEW && PDNEW.mode==='child' && (+PDNEW.parent|0)===0 && pid===0) h+=pdNewRow([]); // 新增一级根目录:排在根级末尾
|
||||
return h;
|
||||
}
|
||||
function pdNoneRow(){
|
||||
@@ -436,39 +492,47 @@ function pdNoneRow(){
|
||||
:'<span class="tw off"></span>')
|
||||
+'<span class="ic">📂</span><span class="dn">未归类</span>'
|
||||
+`<span class="cnt">(${none.length})</span></div>`;
|
||||
if(open) none.forEach(x=>{ h+=pdProjRow(x, 1); });
|
||||
if(open) none.forEach(x=>{ h+=pdProjRow(x, [false]); }); // 未归类固定节点:一层空白占位+肘线
|
||||
return h;
|
||||
}
|
||||
function pdDrawBar(){
|
||||
const d=PDIRS.find(x=>x.id===PDSEL);
|
||||
const p=PDSELP || ''; // 选中的项目名(与目录选择互斥)
|
||||
const pg=p?(+PASG[p]||0):0; // 项目所在组(0=未归类)
|
||||
const tgt=d || PDIRS.find(x=>x.id===pg); // +子目录 的目标目录(项目在未归类时=无,即建根)
|
||||
const B=(t,tt,fn,dis,disT)=>dis
|
||||
? `<button class="btn" disabled title="${disT||'请先点选一个目录'}">${t}</button>`
|
||||
: `<button class="btn" title="${tt}" onclick="${fn}">${t}</button>`;
|
||||
const full=d && pdDepth(d.id)>=3; // 目录最多 3 层(2026-11-04 主人定)
|
||||
const full=tgt && pdDepth(tgt.id)>=3; // 目录最多 3 层(2026-11-04 主人定)
|
||||
const who = d ? ('当前选中:目录 '+esc(pdPath(d.id)))
|
||||
: p ? ('当前选中:项目「'+esc(p)+'」('+esc(pg?pdPath(pg):'未归类')+')')
|
||||
: '未选中目录';
|
||||
$('pdrt').innerHTML =
|
||||
B(d?'+子目录':'+根目录',
|
||||
full?'目录最多 3 层:「'+d.name+'」已是第 3 层,不能再建子级'
|
||||
:(d?('在「'+d.name+'」下新增子目录'):'新增一级根目录(未归类不算目录,不能在它下面建子级)'),
|
||||
B(tgt?'+子目录':'+根目录',
|
||||
full?'目录最多 3 层:「'+tgt.name+'」已是第 3 层,不能再建子级'
|
||||
:(tgt?('在「'+tgt.name+'」下新增子目录'):'新增一级根目录(未归类不算目录,不能在它下面建子级)'),
|
||||
'pdAdd()', !!full, '目录最多 3 层:不能再建子级')
|
||||
+ B('+平级','在选中目录后面插入平级目录','pdAddSib()',!d)
|
||||
+ B('✎','重命名选中目录','pdRen()',!d)
|
||||
+ B('↑','上移选中目录(需确认)','pdMove(-1)',!d)
|
||||
+ B('↓','下移选中目录(需确认)','pdMove(1)',!d)
|
||||
+ B('✕','删除选中目录(需确认)','pdDel()',!d)
|
||||
+ `<span class="who">${d?('当前选中:'+esc(pdPath(d.id))):'未选中目录'}</span>`;
|
||||
+ B('✎','重命名选中目录','pdRen()',!d,'重命名只对目录有效,请点选一个目录')
|
||||
+ B('↑', p?('上移选中项目(同级内移动,不改归属;需确认)'):'上移选中目录(需确认)','pdMove(-1)',!d&&!p)
|
||||
+ B('↓', p?('下移选中项目(同级内移动,不改归属;需确认)'):'下移选中目录(需确认)','pdMove(1)',!d&&!p)
|
||||
+ B('✕','删除选中目录(需确认)','pdDel()',!d,'项目不在这里删除;改归属请用「所属目录」下拉')
|
||||
+ `<span class="who">${who}</span>`;
|
||||
}
|
||||
function pdDraw(){
|
||||
pdDrawBar();
|
||||
$('pdtree').innerHTML=pdNoneRow()+pdDirRows(0,0);
|
||||
$('pdtree').innerHTML=pdNoneRow()+pdDirRows(0,0,[]);
|
||||
const ni=$('pdnewin'); if(ni) ni.focus();
|
||||
const ri=$('pdrenin'); if(ri){ ri.focus(); ri.select(); }
|
||||
if(ni || ri) pdArmOutsideCommit(); // 输入态挂「点别处提交」保底
|
||||
}
|
||||
|
||||
/* ---- 交互 ---- */
|
||||
function pdSel(id, e){ if(e) e.stopPropagation(); PDSEL=id; PDREN=0; pdDraw(); }
|
||||
function pdSel(id, e){ if(e) e.stopPropagation(); PDSEL=id; PDSELP=''; PDREN=0; pdDraw(); }
|
||||
function pdSelProj(nm, e){ if(e) e.stopPropagation(); if(!nm) return; PDSELP=nm; PDSEL=0; PDREN=0; pdDraw(); }
|
||||
function pdToggle(e, key){ if(e) e.stopPropagation(); if(PDCOL[key]) delete PDCOL[key]; else PDCOL[key]=1; pdDraw(); }
|
||||
function pdAdd(){ const d=PDIRS.find(x=>x.id===PDSEL);
|
||||
function pdAdd(){ let d=PDIRS.find(x=>x.id===PDSEL);
|
||||
if(!d && PDSELP) d=PDIRS.find(x=>x.id===(+PASG[PDSELP]||0)); // 选中项目时,+子目录落在它所在目录下
|
||||
if(d && pdDepth(d.id)>=3) return; // 目录最多 3 层(双保险,按钮已禁用)
|
||||
const p=(d?d.id:0); delete PDCOL[p]; // 给折叠目录加子目录时自动展开,否则提交后看不见
|
||||
PDNEW={parent:p, mode:'child'}; PDREN=0; pdDraw(); }
|
||||
@@ -523,6 +587,14 @@ async function pdRenGo(){
|
||||
else if(r){ dlgNotice(r.msg||'改名失败'); PDREN=did; pdDraw(); }
|
||||
}
|
||||
function pdMove(d){
|
||||
if(PDSELP){ // 项目同级移动(2026-11-05 主人定):只换位、不改归属、不可跨级
|
||||
const nm=PDSELP;
|
||||
dlgShow('确定把「'+nm+'」'+(d<0?'上移':'下移')+'一位?(同级内移动,不改归属)','确定',async ()=>{
|
||||
const r=await pdSave({op:'move_proj', name:nm, d});
|
||||
if(r && r.ok){ await pdReload(); if(PDSELP!==nm){ PDSELP=nm; pdDraw(); } } else if(r){ dlgNotice(r.msg||'移动失败'); }
|
||||
},'确认',false);
|
||||
return;
|
||||
}
|
||||
const dsel=PDIRS.find(x=>x.id===PDSEL); if(!dsel) return;
|
||||
dlgShow('确定把「'+dsel.name+'」'+(d<0?'上移':'下移')+'一位?','确定',async ()=>{
|
||||
const r=await pdSave({op:'move', id:PDSEL, d});
|
||||
@@ -556,6 +628,7 @@ document.addEventListener('keydown',function(e){
|
||||
if(e.key!=='Escape' || !$('pdmask').classList.contains('on')) return;
|
||||
if($('dlgmask').classList.contains('on')) return; // 确认弹框优先,交给它自己的 ESC 处理
|
||||
if(PDNEW || PDREN){ PDNEW=null; PDREN=0; pdDraw(); return; }
|
||||
if(PDSELP){ PDSELP=''; pdDraw(); return; } // 先退项目选中,再关弹框
|
||||
pdClose();
|
||||
});
|
||||
|
||||
@@ -587,6 +660,7 @@ async function del(ids){
|
||||
|
||||
|
||||
head();
|
||||
pfFoldLoad(); // 折叠记忆先于首帧渲染恢复(2026-11-05 目录分组折叠)
|
||||
sumw($('tb')); // 表宽=列宽和(先按基础宽出表)
|
||||
colwApply($('tb')); // 套用上次拖动记忆(伸缩列只记基础宽)
|
||||
attrFillBind($('tb'), NAME_IDX, 260); // 项目名称列吃掉全部余宽 → 表格撑满屏幕(RO 盯缩放)
|
||||
|
||||
@@ -688,6 +688,10 @@ body.histdrag{user-select:none}
|
||||
let SID=0, CUR=null, CURTYPE='lme', HROWS=[];
|
||||
let CUR_ADOPT=''; // 决策 250(2026-11-01 主人定):当前选中行的采纳备注(pick 时从行备注格取,
|
||||
// 采纳/取消/手工编辑同步)——对比框「已采纳」标记按它反推,与库同源不漂
|
||||
/* 决策 256(2026-11-06 主人定「乙 后端溯源」):本行已采纳来源行的快照缓存——
|
||||
比对/检索结果里没有来源行时插回第一条+徽章;快照由后端 adopt_src 表溯源(跨重开/换浏览器有效)。
|
||||
{key:'bill:214', row:{渲染行}, busy, done} —— 采纳/取消时即时维护,行切换按 key 失效。 */
|
||||
let _ADOPT_SRC={};
|
||||
let MANUAL=false; // 2026-10-19:当前是手工工程(无源文件)→ 禁止原格式导出/重新解析
|
||||
/* 当前渲染进历史表的那份(已按精确度过滤 + 按时间/价格排序)。
|
||||
「采纳」必须从这里取值,不能用 HROWS —— HROWS 未过滤未排序,下标对不上会采纳错历史价。 */
|
||||
@@ -2425,13 +2429,36 @@ function renderHist(){
|
||||
// 「采纳:行名+行项目+」开头(adoptTxtFor 格式)即命中;同键多行取排序首条(精确档在前)。
|
||||
// 当前结果没有匹配行(关键词过滤/翻页)就不置顶不标记——不再凭本地记忆凭空插行。
|
||||
let adoptedIdx=-1;
|
||||
const ak=(CUR && (CURTYPE==='bill'||CURTYPE==='lme') && CUR.id) ? (CURTYPE+':'+CUR.id) : null;
|
||||
if(/^采纳:/.test(CUR_ADOPT||'')){
|
||||
const pi=rows.findIndex(x=>CUR_ADOPT.indexOf('采纳:'+(x.name||'')+'+'+(x.proj||'')+'+')===0);
|
||||
if(pi>=0){
|
||||
if(pi>0) rows=[rows[pi]].concat(rows.slice(0,pi), rows.slice(pi+1));
|
||||
VISIBLE_ROWS=rows;
|
||||
adoptedIdx=0;
|
||||
} else if(ak){
|
||||
// 决策 256(乙 后端溯源):来源行不在当前结果里 → 取快照插到第一条+徽章(跨重开定位)。
|
||||
// 会话内存缓存优先;无缓存异步向后端 adopt_src 表取(一次,防串台:回调核对 ak 未变)。
|
||||
if(_ADOPT_SRC.key===ak && _ADOPT_SRC.row){
|
||||
rows=[_ADOPT_SRC.row].concat(rows.filter(r=>r!==_ADOPT_SRC.row));
|
||||
VISIBLE_ROWS=rows;
|
||||
adoptedIdx=0;
|
||||
} else if(!_ADOPT_SRC.busy && _ADOPT_SRC.done!==ak){
|
||||
_ADOPT_SRC.busy=true;
|
||||
J('/api/session/adopt/src?session_id='+SID+'&type='+CURTYPE+'&row_id='+CUR.id)
|
||||
.then(r=>{
|
||||
_ADOPT_SRC.busy=false;
|
||||
const nowKey=(CUR && CUR.id)?(CURTYPE+':'+CUR.id):null;
|
||||
if(nowKey!==ak) return; // 期间已切行:丢弃
|
||||
_ADOPT_SRC={key:ak, row:(r&&r.ok&&r.row)?r.row:null, done:ak};
|
||||
if(_ADOPT_SRC.row) renderHist(); // 拿到快照 → 重渲染插行
|
||||
})
|
||||
.catch(()=>{ _ADOPT_SRC.busy=false; _ADOPT_SRC.done=ak; });
|
||||
}
|
||||
}
|
||||
} else if(_ADOPT_SRC.key===ak){
|
||||
// 行没采纳备注了(取消/手工改备注):清本行缓存。别的行缓存保留(切回来还用得上)。
|
||||
_ADOPT_SRC={};
|
||||
}
|
||||
const selfMode=$('fself') && $('fself').value==='yes';
|
||||
const emptyMsg=selfMode
|
||||
@@ -2677,6 +2704,15 @@ async function adopt(i){
|
||||
}catch(e){ r=null; }
|
||||
if(!r || !r.ok){ dlMsg('备注写入失败:'+(r&&r.msg?r.msg:'服务未响应'),'err'); return; }
|
||||
CUR_ADOPT=txt; // 决策 250:判定源同步(已采纳标记立即点亮)
|
||||
// 决策 256(乙 后端溯源):来源行快照落库(跨重开定位)+ 会话内存缓存(当场插行零等待)
|
||||
try{
|
||||
const src=VISIBLE_ROWS[i] || {};
|
||||
_ADOPT_SRC={key:CURTYPE+':'+CUR.id, row:src};
|
||||
J('/api/session/adopt/src',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({act:'record',type:'bill',row_id:CUR.id,
|
||||
src:{src:src.src||'project', src_id:src.src_id||src.bill_id, name:src.name,
|
||||
attr:src.attr, unit:src.unit, price:src.price, proj:src.proj, period:src.period}})});
|
||||
}catch(e){}
|
||||
// keepView:采纳后停在原组原行(规格 2026-10-16:点采纳跳至第一组 = bug,修复)
|
||||
const cur=document.querySelector('.tab.on');
|
||||
const p=cur?cur.dataset.p:'p2';
|
||||
@@ -2706,6 +2742,7 @@ async function cancelBillAdopt(billId, el){
|
||||
}catch(e){ r2=null; }
|
||||
if(!r2 || !r2.ok){ dlMsg('取消采纳失败:'+(r2&&r2.msg?r2.msg:'备注清空未响应'),'err'); return; }
|
||||
if(CUR && String(CUR.id)===String(billId)) CUR_ADOPT=''; // 决策 250:判定源同步(标记立即复原)
|
||||
if(CUR && String(CUR.id)===String(billId)) _ADOPT_SRC={}; // 决策 256:来源快照缓存同步清(后端 unadopt 已删表行)
|
||||
// ③ 刷新当前视图(原数据/组表都可能是取消来源;撤缓存重拉即真状态;keepView 停在原地)
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
const cur=document.querySelector('.tab.on');
|
||||
@@ -2777,6 +2814,16 @@ async function adoptLme(i){
|
||||
//(价格/备注旧值,实测报障「项目级工料机汇总没同步更新」;与定额采纳/取消采纳同口径)
|
||||
Object.keys(RV_CACHE).forEach(k=>{ if(String(k).indexOf(SID+'|')===0) delete RV_CACHE[k]; });
|
||||
CUR_ADOPT=txt; // 决策 250:判定源同步(已采纳标记立即点亮)
|
||||
// 决策 256(乙 后端溯源):来源行快照落库(跨重开定位)+ 会话内存缓存
|
||||
try{
|
||||
const src=VISIBLE_ROWS[i] || {};
|
||||
_ADOPT_SRC={key:CURTYPE+':'+CUR.id, 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,
|
||||
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)
|
||||
@@ -2809,6 +2856,7 @@ async function cancelAdopt(lmeId){
|
||||
}catch(e){ r=null; }
|
||||
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 row=(LME_ROWS||[]).find(y=>y[0]===lmeId);
|
||||
if(row) row[10]='';
|
||||
const tr0=document.querySelector(`#tb0 tr[data-id="${lmeId}"]`);
|
||||
|
||||
Reference in New Issue
Block a user