diff --git a/src/modules/order-rules/batch.cjs b/src/modules/order-rules/batch.cjs
index 4d2888d..53c2124 100644
--- a/src/modules/order-rules/batch.cjs
+++ b/src/modules/order-rules/batch.cjs
@@ -28,7 +28,6 @@ function buildBatch(rule,orders,cutoff,{maxMessageBytes=20971520,window,notifica
const start=window?Date.parse(window.start):null,end=window?Date.parse(window.end):null;
if(window&&(!Number.isFinite(start)||!Number.isFinite(end)||start>=end||end!==limit||window.startInclusive!==true||window.endInclusive!==false))fail('邮件时段窗口无效。');
if(!rule?.categoryId||!Array.isArray(orders)||!orders.length)fail('类别必须包含待发订单。');
- if(rule.attachPdf===true)fail('业务通知禁止附件,请先将类别 attachPdf 设置为 false;PDF 归档仍为前置条件。');
const to=recipients(rule.to,'收件人'),cc=recipients(rule.cc||[],'抄送人').filter(a=>!to.includes(a));
if(!to.length)fail('收件人名单不能为空。');
const orderIds=[],attachments=[];
@@ -48,15 +47,16 @@ function buildBatch(rule,orders,cutoff,{maxMessageBytes=20971520,window,notifica
if(order.archive.files.some(file=>!validFile(file)))fail(`订单 ${number} 的归档文件证据无效。`);
if(!order.archive.files.some(file=>file.kind==='pdf'&&/\.pdf$/i.test(file.name)))fail(`订单 ${number} 缺少必需 PDF,本类别已阻塞。`);
orderIds.push(order.id);
+ if(rule.attachPdf===true)for(const file of order.archive.files)if(file.kind==='pdf'&&/\.pdf$/i.test(file.name)&&!attachments.some(item=>item.path===file.path))attachments.push({name:file.name,path:file.path,sha256:file.sha256,size:file.size,kind:'pdf'});
}
- const prefix=String(rule.subjectPrefix||rule.name||'订单通知');
+ const prefix=String(rule.subjectPrefix||rule.name||'订单通知');
if(/[\r\n\x00-\x1f]/.test(prefix))fail('邮件标题无效。');
const content=mailContent(orders),orderNos=content.orderNos;
- const snapshot={categoryId:rule.categoryId,subject:`${prefix} ${orderNos.join('、')}`,to,cc,orderIds,orderNos,attachments,cutoff:new Date(limit).toISOString()};
+ const snapshot={categoryId:rule.categoryId,attachPdf:rule.attachPdf===true,subject:`${prefix} ${orderNos.join('、')}`,to,cc,orderIds,orderNos,attachments,cutoff:new Date(limit).toISOString()};
snapshot.notificationMode=notificationMode;
{
- snapshot.text=[rule.intro,content.details,notificationMode==='huizhou'?'':'存放地址:'+content.directories.join('\n'),rule.signature].filter(Boolean).join('\n\n');
- snapshot.html='
'+lines(rule.intro)+'
'+content.htmlDetails+(notificationMode==='huizhou'?'':content.htmlDirectories)+''+lines(rule.signature)+'
';
+ const detailText=rule.bodyWithoutSummary===true?'':content.details;snapshot.text=[rule.intro,detailText,notificationMode==='huizhou'?'':'存放地址:'+content.directories.join('\n'),rule.signature].filter(Boolean).join('\n\n');
+ snapshot.html=''+lines(rule.intro)+'
'+(rule.bodyWithoutSummary===true?'':content.htmlDetails)+(notificationMode==='huizhou'?'':content.htmlDirectories)+''+lines(rule.signature)+'
';
}
if(window){snapshot.window=structuredClone(window);snapshot.windowStart=new Date(start).toISOString();snapshot.windowEnd=new Date(end).toISOString();}
// MIME headers, encoded-word subjects, base64 wrapping, attachment metadata and
diff --git a/src/modules/order-rules/collecting-batches.cjs b/src/modules/order-rules/collecting-batches.cjs
index 28804da..763764d 100644
--- a/src/modules/order-rules/collecting-batches.cjs
+++ b/src/modules/order-rules/collecting-batches.cjs
@@ -33,7 +33,7 @@ function readList(store,{cutoff}={}){
return [...groups.values()].map(group=>{
const {rule,orders,...value}=group,saved=store.get('batch-content-drafts',group.id);let template,sourceError;try{template=store.templateResolver?.(rule.categoryId,rule,group.notificationMode);}catch(error){sourceError=error.message;}let base;try{base=definition(store,rule,window.end,group.notificationMode,template);}catch(error){sourceError=error.message;base={context:digest([rule,window.end,group.notificationMode]),subject:rule.subjectPrefix||rule.name,format:'text',body:'{{订单明细}}\n{{存放地址}}'};}
const row={...value,carriedOrderIds:orders.filter(o=>require('./carry-forward.cjs').windowForOrder(store,o,group.notificationMode)?.end===window.end).map(o=>o.id),version:saved?.version||0,context:base.context,editor:saved?{subject:saved.subject,format:saved.format,body:saved.body}:base,edited:!!saved,editable:!sourceError&&+store.clock()o.event?.orderNo).filter(Boolean),ruleSnapshot:rule};
- try{if(sourceError)fail(sourceError,409);const snapshot=require('./template.cjs').composeBatch(rule,require('./huizhou.cjs').ordersForMode(orders,group.notificationMode),window.end,store,{window,notificationMode:group.notificationMode});Object.assign(row,{subject:snapshot.subject,text:snapshot.text,html:snapshot.html,template:snapshot.template,signature:snapshot.signature});}
+ try{if(sourceError)fail(sourceError,409);const snapshot=require('./template.cjs').composeBatch(rule,require('./huizhou.cjs').ordersForMode(orders,group.notificationMode),window.end,store,{window,notificationMode:group.notificationMode});Object.assign(row,{subject:snapshot.subject,text:snapshot.text,html:snapshot.html,attachments:snapshot.attachments||[],template:snapshot.template,signature:snapshot.signature});}
catch(error){row.error=error.message;row.text='';row.html='';}
return row;
});
diff --git a/src/modules/order-rules/dispatcher.cjs b/src/modules/order-rules/dispatcher.cjs
index 310d169..fc8c001 100644
--- a/src/modules/order-rules/dispatcher.cjs
+++ b/src/modules/order-rules/dispatcher.cjs
@@ -6,10 +6,18 @@ const {nextSlots}=require('../../shared/schedule.cjs');
const {windowForCutoff}=require('./window.cjs');
const {fail}=require('./validation.cjs');
const {modeOf,delivery,updateDelivery}=require('./delivery.cjs');
-function assertMailPolicy(batch){
+function assertMailPolicy(batch,settings){
const blocked=message=>{throw Object.assign(new Error(message),{status:409,code:'MAIL_POLICY_BLOCKED'});};
- if(!Array.isArray(batch.to)||batch.to.length!==1||batch.to[0]!=='2639266652@qq.com'||!Array.isArray(batch.cc)||batch.cc.length)blocked('当前分类通知只允许固定 QQ 2639266652@qq.com,且不得抄送。');
- if(!Array.isArray(batch.attachments)||batch.attachments.length)blocked('当前分类通知禁止 PDF 或其他附件;旧冻结批次必须先核验处理。');
+ const domains=Array.isArray(settings?.allowedDomains)?settings.allowedDomains:[];
+ if(domains.length){
+ const recipients=(Array.isArray(batch.to)?batch.to:[]).map(address=>String(address||'').trim().toLowerCase());
+ if(!recipients.length||!recipients.every(address=>domains.some(domain=>address.endsWith('@'+domain))))blocked('收件人不在允许的公司邮箱域名内,发送已阻断。');
+ if(!Array.isArray(batch.cc)||batch.cc.length)blocked('当前策略不允许抄送。');
+ }else if(!Array.isArray(batch.to)||batch.to.length!==1||batch.to[0]!=='2639266652@qq.com'||!Array.isArray(batch.cc)||batch.cc.length)blocked('当前分类通知只允许固定 QQ 2639266652@qq.com,且不得抄送。');
+ if(Array.isArray(batch.attachments)&&batch.attachments.length){
+ if(batch.attachPdf!==true)blocked('当前分类通知禁止附件;仅附归档 PDF 的类别可以携带附件。');
+ if(batch.attachments.some(file=>!file||file.kind!=='pdf'||!/\.pdf$/i.test(String(file.name||''))))blocked('邮件附件仅允许已归档的 PDF 文件。');
+ }
}
function freeze(value){
@@ -80,7 +88,7 @@ class OrderRuleDispatcher{
if(batch.status!=='prepared')return false;
let transport,sending=false;
try{
- assertMailPolicy(batch);
+ assertMailPolicy(batch,config);
require('./restricted-test.cjs').assertBatch(this.store,batch,config);
if(batch.channelId&&batch.channelId!==config.channelId){
this.store.finishSending(batch.id,'failed','批次固定的发件邮箱与当前渠道不同,请核实邮箱设置后生成新批次。',{outcome:'not_submitted',phase:'preflight',at:this.clock().toISOString()});return;
@@ -98,7 +106,7 @@ class OrderRuleDispatcher{
if(manual?this.stopped||!this.providersReady()||!this.store.providersReady():!this.ready()||this.store.settings().channelId!==config.channelId)throw Error('发送已暂停或配置已变更。');
if(!manual&&this.clock().getTime()-Date.parse(batch.cutoff)>1800000)throw Error('冻结发送队列超过30分钟。');
this.mail.store.guard(channel.id,channel.version);
- assertMailPolicy(batch);
+ assertMailPolicy(batch,config);
require('./restricted-test.cjs').assertBatch(this.store,batch,config);
this.store.beginSending(batch.id,{manual});sending=true;
const result=await transport.sendMail({from:{address:channel.email,name:channel.name},to:[...batch.to],cc:[...batch.cc],subject:batch.subject,text:batch.text,html:batch.html,attachments,messageId:`<${batch.id}@${channel.email.split('@')[1]}>`,disableFileAccess:true,disableUrlAccess:true});
diff --git a/src/modules/order-rules/mail-content.cjs b/src/modules/order-rules/mail-content.cjs
index b15a584..a9090c3 100644
--- a/src/modules/order-rules/mail-content.cjs
+++ b/src/modules/order-rules/mail-content.cjs
@@ -12,21 +12,24 @@ function fileLink(filePath){
// Content is derived from the event and its recorded archive, never current configuration.
function mailContent(orders){
const summaries=orders.flatMap(order=>{
- const event=order.event,rows=event.titleOrders;
- if(rows?.length&&rows.every(row=>typeof row.text==='string'&&row.text.trim()))return rows.map(row=>({orderNo:row.orderNo,brief:row.text}));
+ const event=order.event,rows=event.titleOrders,verbatim=order.ruleSnapshot?.keepTitleVerbatim===true;
+ if(rows?.length&&rows.every(row=>typeof row.text==='string'&&row.text.trim())){
+ if(verbatim&&rows.length===1)return [{orderNo:rows[0].orderNo,brief:event.rawTitle||event.brief||rows[0].text,verbatim:true}];
+ return rows.map(row=>({orderNo:row.orderNo,brief:row.text,verbatim}));
+ }
// Older event snapshots may lack per-order text. Recover only the declared
// title segments, using the same deterministic title parser as ingestion.
const parsed=require('./title.cjs').extractTitle(event.brief||'');
if(rows?.length&&parsed.orders.length>1)return rows.map(row=>{
const matches=parsed.orders.filter(observed=>observed.orderNo===row.orderNo);
if(!row.text?.trim()&&matches.length!==1)fail('已识别订单段落缺少可核对的简要说明原文。',409);
- return {orderNo:row.orderNo,brief:row.text?.trim()?row.text:matches[0].text};
+ return {orderNo:row.orderNo,brief:row.text?.trim()?row.text:matches[0].text,verbatim};
});
if(rows?.length>1)fail('已识别订单段落缺少可核对的简要说明原文。',409);
- if(parsed.orders.length>1)return parsed.orders.map(row=>({orderNo:row.orderNo,brief:row.text}));
- return [{orderNo:rows?.[0]?.orderNo||event.orderNo,brief:event.brief}];
+ if(parsed.orders.length>1)return parsed.orders.map(row=>({orderNo:row.orderNo,brief:row.text,verbatim}));
+ return [{orderNo:rows?.[0]?.orderNo||event.orderNo,brief:event.brief,verbatim}];
});
- const details=summaries.map(formatOrderLine).join('\n');
+ const details=summaries.map(row=>row.verbatim?String(row.brief||'').replace(/[\r\n\u0085\u2028\u2029]+[\t ]*/g,' ').trim():formatOrderLine(row)).join('\n');
const seen=new Set(),directories=[];
for(const order of orders)for(const file of order.archive.files){
const windows=path.win32.isAbsolute(file.path),directory=(windows?path.win32:path.posix).dirname(file.path),key=windows?directory.toLowerCase():directory;
diff --git a/src/modules/order-rules/store.cjs b/src/modules/order-rules/store.cjs
index 79918dc..7e89ef2 100644
--- a/src/modules/order-rules/store.cjs
+++ b/src/modules/order-rules/store.cjs
@@ -76,11 +76,12 @@ class RuleStore{
saveSettings(input,actor){return this.transaction(()=>{
const old=this.settings();
const testing=this.restrictedTest();if(testing&&input?.channelId!==testing.channelId)fail('受限测试发件通道已固定。',409);
- if(!input||Object.keys(input).some(k=>!['version','enabled','processingEnabled','processingSince','channelId','maxMessageBytes'].includes(k))||input.version!==old.version)fail('设置已变化,请刷新。',409);
+ if(!input||Object.keys(input).some(k=>!['version','enabled','processingEnabled','processingSince','channelId','maxMessageBytes','allowedDomains'].includes(k))||input.version!==old.version)fail('设置已变化,请刷新。',409);
if(typeof input.enabled!=='boolean'||typeof input.channelId!=='string'||input.channelId.length>100||!Number.isInteger(input.maxMessageBytes)||input.maxMessageBytes<1024||input.maxMessageBytes>100*1024*1024)fail('邮箱或邮件大小限制无效。');
+ if(input.allowedDomains!==undefined){if(!Array.isArray(input.allowedDomains)||input.allowedDomains.length>10||input.allowedDomains.some(d=>typeof d!=='string'||!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?\.[a-z]{2,}$/i.test(d)))fail('收件人域名白名单无效。');input.allowedDomains=[...new Set(input.allowedDomains.map(d=>d.trim().toLowerCase()))];}
const run=this.get('restricted-test','main')?.value;
const restrictedIntent=testing?.enabled&&testing.readyCount>0&&testing.readyCount===testing.ruleCount&&testing.recipient==='2639266652@qq.com'&&run.rules.every(rule=>rule.to?.length===1&&rule.to[0]==='2639266652@qq.com'&&rule.cc?.length===0&&rule.attachPdf===false);
- if(input.enabled&&(!input.channelId||!this.providersReady()&&!restrictedIntent))fail('待办接入、PDF 导出与自动归档尚未全部联调,暂不能启用自动发送。',409);
+ if(input.enabled&&old.enabled!==true&&(!input.channelId||!this.providersReady()&&!restrictedIntent))fail('待办接入、PDF 导出与自动归档尚未全部联调,暂不能启用自动发送。',409);
if(input.processingEnabled!==undefined&&typeof input.processingEnabled!=='boolean')fail('自动处理开关无效。');
const processingEnabled=input.processingEnabled??old.processingEnabled;const processingSince=processingEnabled&&!old.processingEnabled?this.now():old.processingSince;
this.put('settings',{...input,processingEnabled,processingSince,id:'main',version:old.version+1});this.audit(actor,'保存分类通知设置',input.enabled?'已启用':'已暂停');return this.settings();
diff --git a/src/modules/order-rules/validation.cjs b/src/modules/order-rules/validation.cjs
index 429b368..f6a4263 100644
--- a/src/modules/order-rules/validation.cjs
+++ b/src/modules/order-rules/validation.cjs
@@ -1,7 +1,7 @@
'use strict';
const {normalizeScopes}=require('./scopes.cjs');
const fail=(message,status=400)=>{throw Object.assign(new Error(message),{status});};
-const fields=['id','version','name','categoryId','processNames','nodeNames','adapterIds','archiveDirectory','filenameDate','subjectPrefix','intro','signature','to','cc','attachPdf','sourceRow','bodyTemplateId','huizhouEnabled','huizhouTemplateId'];
+const fields=['id','version','name','categoryId','processNames','nodeNames','adapterIds','archiveDirectory','filenameDate','subjectPrefix','intro','signature','to','cc','attachPdf','archiveOrderFolder','keepTitleVerbatim','filenameScheme','bodyWithoutSummary','sourceRow','bodyTemplateId','huizhouEnabled','huizhouTemplateId'];
function addresses(values){
if(!Array.isArray(values)||values.length>500)fail('收件名单格式无效。');
return [...new Set(values.map(v=>{
@@ -34,6 +34,14 @@ function validateRule(input,old){
rule[key]=[...new Set(rule[key].map(v=>v.trim()))];
}
if(!['','appDate','receivedAt','archiveDate'].includes(rule.filenameDate)||typeof rule.attachPdf!=='boolean')fail('请选择有效的日期来源和附件要求。');
+ if(input.archiveOrderFolder!==undefined&&typeof input.archiveOrderFolder!=='boolean')fail('归档按订单号建子目录开关无效。');
+ rule.archiveOrderFolder=rule.archiveOrderFolder===true;
+ if(input.keepTitleVerbatim!==undefined&&typeof input.keepTitleVerbatim!=='boolean')fail('标题原文开关无效。');
+ rule.keepTitleVerbatim=rule.keepTitleVerbatim===true;
+ if(input.filenameScheme!==undefined&&!['','orderDateSeq'].includes(input.filenameScheme))fail('归档命名方案无效。');
+ rule.filenameScheme=input.filenameScheme===undefined?(old.filenameScheme||''):input.filenameScheme;
+ if(input.bodyWithoutSummary!==undefined&&typeof input.bodyWithoutSummary!=='boolean')fail('正文摘要开关无效。');
+ rule.bodyWithoutSummary=rule.bodyWithoutSummary===true;
rule.to=addresses(rule.to);rule.cc=addresses(rule.cc).filter(v=>!rule.to.includes(v));
rule.version=old.version+1;rule.status='draft';return rule;
}
diff --git a/src/modules/storage/order-archive.cjs b/src/modules/storage/order-archive.cjs
index 57b3b18..0a2432f 100644
--- a/src/modules/storage/order-archive.cjs
+++ b/src/modules/storage/order-archive.cjs
@@ -4,11 +4,18 @@ const fs=require('node:fs/promises');
const crypto=require('node:crypto');
const {segments,inside}=require('./files.cjs');
const {renderSnapshot}=require('../pdf/exporter.cjs');
-const {archiveFilename}=require('./order-filename.cjs');
+const {archiveFilename,archiveSequenceFilename}=require('./order-filename.cjs');
const restricted=require('../order-rules/restricted-test.cjs');
const canonical=value=>Array.isArray(value)?value.map(canonical):value&&typeof value==='object'?Object.fromEntries(Object.keys(value).sort().map(k=>[k,canonical(value[k])])):value;
const fingerprint=value=>crypto.createHash('sha256').update(JSON.stringify(canonical(value))).digest('hex');
const fail=message=>Object.assign(new Error(message),{status:409});
+function orderSubfolder(rule,event){
+ if(rule?.archiveOrderFolder!==true)return '';
+ // Business convention: 国内/海外订单通知书 archive into \\file.
+ const raw=event?.orderNo;
+ if(typeof raw!=='string'||!/^\d{6,7}$/.test(raw.trim()))throw fail('按订单号建子目录需要明确的 6 位或 7 位主订单号,本次不归档;请核实订单号后重试。');
+ return raw.trim();
+}
function targetFor(storage,directory){
if(typeof directory!=='string'||!directory.startsWith('\\\\'))throw fail('请在分类规则选择已配置服务器的共享目录。');
const parts=directory.slice(2).replace(/\//g,'\\').split('\\');segments(parts.slice(2).join('/'));
@@ -41,14 +48,19 @@ class OrderArchiveProvider{
let previous=this.journal?.get('archive-intents',id);
const legacy=generation===1&&!previous&&this.journal?.get('archive-intents',identity);
const event=order.event||order,chosen=previous?.chosen||legacy?.chosen||(rule.filenameDate==='appDate'?event.appDate:rule.filenameDate==='receivedAt'?event.receivedAt:this.clock());
- const filename=archiveFilename(event,rule.filenameDate,chosen);
+ const target=targetFor(this.storage,rule.archiveDirectory);
+ const subfolder=orderSubfolder(rule,event);
+ if(subfolder)target.relative=[target.relative,subfolder].filter(Boolean).join('/');
+ let filename;
+ if(previous?.filename)filename=previous.filename;
+ else if(rule.filenameScheme==='orderDateSeq'){let names=[];try{const listing=await this.storage.list(target.server.id,target.relative);names=(listing?.entries||[]).map(entry=>entry.name);}catch{}filename=archiveSequenceFilename(event,chosen,names);}
+ else filename=archiveFilename(event,rule.filenameDate,chosen);
const outputFingerprint=fingerprint({sourceHash:order.sourceHash,event,directory:rule.archiveDirectory,filenameDate:rule.filenameDate,filename,chosen:new Date(chosen).toISOString(),generation});
if(legacy){
if(legacy.sourceHash!==order.sourceHash||legacy.directory!==rule.archiveDirectory||legacy.filename!==filename)throw fail('旧归档意图与当前输出不一致,请建立新归档代次。');
previous={...legacy,id,legacyIntentId:identity,archiveGeneration:generation,outputFingerprint};this.journal.put('archive-intents',previous);
}
if(previous&&(previous.sourceHash!==order.sourceHash||previous.outputFingerprint!==outputFingerprint))throw fail('归档输出与本代持久意图不一致,请建立新归档代次。');
- const target=targetFor(this.storage,rule.archiveDirectory);
// Renderer public extension contract remains its original four-field filename.
const renderInput={...snapshot,metadata:{order:String(event.orderNo),project:'流程归档',model:'订单',serial:String(event.serialNum||event.documentNum)}};
let generated;
@@ -77,4 +89,4 @@ class OrderArchiveProvider{
const result=await this.storage.readFile(target.server.id,[target.relative,path.win32.basename(file.path)].filter(Boolean).join('/'));return Buffer.from(result.bytes);
}
}
-module.exports={OrderArchiveProvider,targetFor};
+module.exports={OrderArchiveProvider,targetFor,orderSubfolder};
diff --git a/src/modules/storage/order-filename.cjs b/src/modules/storage/order-filename.cjs
index 002af1e..9a6a5f5 100644
--- a/src/modules/storage/order-filename.cjs
+++ b/src/modules/storage/order-filename.cjs
@@ -7,4 +7,14 @@ function archiveFilename(event,filenameDate,at){
const safe=v=>String(v||'').replace(/[<>:"/\\|?*\x00-\x1f]/g,'_').replace(/[. ]+$/g,'').slice(0,65);
const filename=[event.orderNo,day,event.serialNum||event.documentNum].map(safe).join('_')+'.pdf';segments(filename);return filename;
}
-module.exports={archiveFilename};
+function archiveSequenceFilename(event,at,names){
+ const orderNo=String(event?.orderNo||'').trim();
+ if(!orderNo)throw Object.assign(Error('归档文件缺少订单号。'),{status:409});
+ if(!Number.isFinite(+new Date(at)))throw Object.assign(Error('归档日期无效。'),{status:409});
+ const day=new Intl.DateTimeFormat('en-CA',{timeZone:'Asia/Shanghai'}).format(new Date(at)).replace(/-/g,'').slice(2);
+ const prefix=orderNo+day,escaped=prefix.replace(/[.*+?^${}()|[\]\\]/g,'\\$&'),pattern=new RegExp('^'+escaped+'-(\\d+)\\.pdf$','i');
+ let max=0;
+ for(const name of names||[]){const match=pattern.exec(String(name||''));if(match)max=Math.max(max,Number(match[1]));}
+ return prefix+'-'+(max+1)+'.pdf';
+}
+module.exports={archiveFilename,archiveSequenceFilename};
diff --git a/web/modules/order-rules/editor.js b/web/modules/order-rules/editor.js
index ffb9442..499a695 100644
--- a/web/modules/order-rules/editor.js
+++ b/web/modules/order-rules/editor.js
@@ -14,8 +14,8 @@
const text=(name,label,value,extra='')=>''+label+'
';
const area=(name,label,value,rows)=>''+label+'
';
const card=(number,title,description,body)=>'';
- const notify=window.OrderRuleResources.render(rule,resources,{esc,admin,section:'template'})+''+text('subjectPrefix','邮件主题前缀',rule.subjectPrefix,'maxlength="200"')+area('to','收件人',(rule.to||[]).join('\n'),3)+area('cc','抄送人',(rule.cc||[]).join('\n'),2)+'
PDF 仅归档,邮件不附附件
标准汇总正文设置(使用邮件模板时无需填写) '+area('intro','正文引导语',rule.intro,3)+'
';
- const archive=window.OrderRuleResources.render(rule,resources,{esc,admin,section:'archive'})+'文件名日期依据 待确认 '+Object.entries(dates).map(([v,label])=>''+label+' ').join('')+'订单号_日期_流水编号.pdf
';
+ const notify=window.OrderRuleResources.render(rule,resources,{esc,admin,section:'template'})+''+text('subjectPrefix','邮件主题前缀',rule.subjectPrefix,'maxlength="200"')+area('to','收件人',(rule.to||[]).join('\n'),3)+area('cc','抄送人',(rule.cc||[]).join('\n'),2)+'
邮件附归档 PDF(仅更改/返工类)
正文不含订单摘要(仅保留引导语、目录和签名)
邮件明细使用 BPM 标题原文(不从“订单号”处截断)
标准汇总正文设置(使用邮件模板时无需填写) '+area('intro','正文引导语',rule.intro,3)+'
';
+ const archive=window.OrderRuleResources.render(rule,resources,{esc,admin,section:'archive'})+'文件名日期依据 待确认 '+Object.entries(dates).map(([v,label])=>''+label+' ').join('')+'订单号_日期_流水编号.pdf
';
return '';
}
- function read(form,rule,adapters=[]){const result={...rule};for(const name of ['name','archiveDirectory','subjectPrefix','intro','filenameDate'])result[name]=form.elements.namedItem(name).value.trim();result.scopes=window.OrderRuleScopes.read(form);result.processNames=[...new Set(result.scopes.map(r=>r.processName).filter(Boolean))];result.nodeNames=[...new Set(result.scopes.map(r=>r.nodeName).filter(Boolean))];result.adapterIds=adaptersFor(result,adapters);const productLine=form.elements.namedItem('productLine')?.value.trim();if(productLine||Object.hasOwn(rule,'productLine'))result.productLine=productLine;const template=form.elements.namedItem('bodyTemplateId').value;if(template==='__legacy__')delete result.bodyTemplateId;else result.bodyTemplateId=template;result.huizhouEnabled=form.elements.namedItem('huizhouEnabled').checked;result.huizhouTemplateId=form.elements.namedItem('huizhouTemplateId').value;for(const name of ['to','cc'])result[name]=list(form.elements.namedItem(name).value);result.attachPdf=false;return result;}
+ function read(form,rule,adapters=[]){const result={...rule};for(const name of ['name','archiveDirectory','subjectPrefix','intro','filenameDate'])result[name]=form.elements.namedItem(name).value.trim();result.scopes=window.OrderRuleScopes.read(form);result.processNames=[...new Set(result.scopes.map(r=>r.processName).filter(Boolean))];result.nodeNames=[...new Set(result.scopes.map(r=>r.nodeName).filter(Boolean))];result.adapterIds=adaptersFor(result,adapters);const productLine=form.elements.namedItem('productLine')?.value.trim();if(productLine||Object.hasOwn(rule,'productLine'))result.productLine=productLine;const template=form.elements.namedItem('bodyTemplateId').value;if(template==='__legacy__')delete result.bodyTemplateId;else result.bodyTemplateId=template;result.huizhouEnabled=form.elements.namedItem('huizhouEnabled').checked;result.huizhouTemplateId=form.elements.namedItem('huizhouTemplateId').value;for(const name of ['to','cc'])result[name]=list(form.elements.namedItem(name).value);result.attachPdf=form.elements.namedItem('attachPdf').checked;result.bodyWithoutSummary=form.elements.namedItem('bodyWithoutSummary').checked;result.keepTitleVerbatim=form.elements.namedItem('keepTitleVerbatim').checked;result.archiveOrderFolder=form.elements.namedItem('archiveOrderFolder').checked;return result;}
window.OrderRuleEditor={render,read,describe,adaptersFor};
})();
diff --git a/web/modules/order-rules/view.js b/web/modules/order-rules/view.js
index ca01a41..99f025e 100644
--- a/web/modules/order-rules/view.js
+++ b/web/modules/order-rules/view.js
@@ -84,7 +84,7 @@
if(!result||!result.id||!Number.isSafeInteger(result.version))throw Error('写入已返回,但规则状态回执不完整;请刷新核对,勿重复提交。');
const {restrictedTest,...value}=result,target=data.rules.find(item=>item.id===value.id);if(!target)throw Error('规则目录已变化,请刷新核对。');Object.assign(target,value);if(Object.hasOwn(result,'restrictedTest')){data.restrictedTest=restrictedTest;if(!restrictedTest)for(const item of data.rules){delete item.testStatus;delete item.testVersion;delete item.testHasDraft;}else if(!restrictedTest.enabled)for(const item of data.rules){item.testStatus='paused';item.testVersion=null;item.testHasDraft=true;}}
if(target===rule){
- if(normalize){for(const name of ['name','archiveDirectory','subjectPrefix','intro','filenameDate','productLine']){const input=form.elements.namedItem(name);if(input&&rule[name]!==undefined)input.value=rule[name];}for(const name of ['to','cc'])form.elements.namedItem(name).value=(rule[name]||[]).join('\n');if(JSON.stringify(window.OrderRuleScopes.read(form))!==JSON.stringify(window.OrderRuleScopes.scopesFor(rule)))scopeController.setScopes(window.OrderRuleScopes.scopesFor(rule));resourceController.setDirectory(rule.archiveDirectory);}
+ if(normalize){for(const name of ['name','archiveDirectory','subjectPrefix','intro','filenameDate','productLine']){const input=form.elements.namedItem(name);if(input&&rule[name]!==undefined)input.value=rule[name];}for(const name of ['to','cc'])form.elements.namedItem(name).value=(rule[name]||[]).join('\n');const folder=form.elements.namedItem('archiveOrderFolder');if(folder)folder.checked=rule.archiveOrderFolder===true;const attachPdf=form.elements.namedItem('attachPdf');if(attachPdf)attachPdf.checked=rule.attachPdf===true;const bodyWithoutSummary=form.elements.namedItem('bodyWithoutSummary');if(bodyWithoutSummary)bodyWithoutSummary.checked=rule.bodyWithoutSummary===true;const verbatim=form.elements.namedItem('keepTitleVerbatim');if(verbatim)verbatim.checked=rule.keepTitleVerbatim===true;if(JSON.stringify(window.OrderRuleScopes.read(form))!==JSON.stringify(window.OrderRuleScopes.scopesFor(rule)))scopeController.setScopes(window.OrderRuleScopes.scopesFor(rule));resourceController.setDirectory(rule.archiveDirectory);}
updateVersion();coverage();const issues=panel.querySelector('#rule-validation-issues');issues.innerHTML=rule.validationIssues?.length?'启用前待完善 '+rule.validationIssues.map(value=>''+esc(typeof value==='string'?value:value.message||'配置需要检查')+' ').join('')+' ':'';
}
drawList();