feat(records): move sync settings and preserve paginated navigation

This commit is contained in:
abaishu0730 committed 2026-10-20 18:35:41 +08:00
1 parent de30cb5706
commit c215e6ec6c
26 files changed
+201 -34

No files matched your search

+3
View File
@@ -9,10 +9,13 @@ function createAssets(){
'/page-lifecycle.js':{path:path.join(webRoot,'modules/navigation/lifecycle.js'),type:'text/javascript'},
'/navigation.js':{path:path.join(webRoot,'modules/navigation/view.js'),type:'text/javascript'},
'/workspace.js':{path:path.join(webRoot,'modules/workspace/view.js'),type:'text/javascript'},
'/bpm-sync-settings.js':{path:path.join(webRoot,'modules/bpm/sync-settings.js'),type:'text/javascript'},
'/bpm.js':{path:path.join(webRoot,'modules/bpm/view.js'),type:'text/javascript'},
'/mail.js':{path:path.join(webRoot,'modules/mail/view.js'),type:'text/javascript'},
'/mail-history.js':{path:path.join(webRoot,'modules/mail/history.js'),type:'text/javascript'},
'/orders.js':{path:path.join(webRoot,'modules/bpm/arrivals.js'),type:'text/javascript'},
'/record-state.js':{path:path.join(webRoot,'modules/records/state.js'),type:'text/javascript'},
'/record-table.js':{path:path.join(webRoot,'modules/records/controller.js'),type:'text/javascript'},
'/record-ui.js':{path:path.join(webRoot,'modules/records/shared.js'),type:'text/javascript'},
'/pdf-records.js':{path:path.join(webRoot,'modules/records/pdf.js'),type:'text/javascript'},
'/storage.js':{path:path.join(webRoot,'modules/storage/view.js'),type:'text/javascript'},
+1
View File
@@ -41,6 +41,7 @@ class BpmScanStore{
if(q){conditions.push("value LIKE ? ESCAPE '\\'");args.push('%'+q.replace(/[\\%_]/g,'\\$&')+'%');}
if(from){conditions.push('day>=?');args.push(from);}if(to){conditions.push('day<=?');args.push(to);}
const where=conditions.length?' WHERE '+conditions.join(' AND '):'',total=this.db.prepare('SELECT COUNT(*) n FROM arrivals'+where).get(...args).n;
page=Math.min(page,Math.max(1,Math.ceil(total/pageSize)));
const items=this.db.prepare("SELECT connection_id AS connectionId,source,task_id AS storageKey,value,first_seen AS firstSeenAt,last_seen AS lastSeenAt FROM arrivals"+where+" ORDER BY json_extract(value,'$.arrivedAt') DESC,connection_id,source,task_id LIMIT ? OFFSET ?").all(...args,pageSize,(page-1)*pageSize).map(({value,storageKey,...rest})=>({...JSON.parse(value),...rest,recordId:JSON.stringify([rest.connectionId,rest.source,storageKey])}));
return {items,total,page,pageSize};
}
+2 -1
View File
@@ -17,6 +17,7 @@ async function queryJobs({jobs,outputDir,archiveStore},input={}){
const {q='',status='',page=1,pageSize=25}=input;
if(typeof q!=='string'||q.length>200||!['','success','running','error','interrupted'].includes(status)||!Number.isSafeInteger(page)||page<1||page>1000000||!Number.isInteger(pageSize)||pageSize<1||pageSize>100)throw fail('导出记录查询条件无效。');
const needle=q.trim().toLowerCase(),filtered=jobs.filter(j=>(!status||j.status===status)&&(!needle||[j.metadata?.order,j.metadata?.project,j.metadata?.model,j.metadata?.serial,j.filename].join(' ').toLowerCase().includes(needle))).sort((a,b)=>String(b.updatedAt||'').localeCompare(String(a.updatedAt||''))||String(a.jobId).localeCompare(String(b.jobId)));
return {jobs:await publicJobs(filtered.slice((page-1)*pageSize,page*pageSize),outputDir,archiveStore),total:filtered.length,page,pageSize};
const actualPage=Math.min(page,Math.max(1,Math.ceil(filtered.length/pageSize)));
return {jobs:await publicJobs(filtered.slice((actualPage-1)*pageSize,actualPage*pageSize),outputDir,archiveStore),total:filtered.length,page:actualPage,pageSize};
}
module.exports={queryJobs,publicJobs,jobFile};