Files
order-notification-automation/src/modules/order-rules/field-sources.cjs
T

11 lines
804 B
JavaScript

'use strict';
const BUSINESS_FIELDS=['orderNo','brief','appDate','customer','productLine','quantity','changeReason','changeContent','totalAmount'];
const METADATA_FIELDS=['processName','processVersion','nodeName','receivedAt','serialNum'];
function sourcesFor(adapter){return adapter?.sources||Object.fromEntries(Object.entries(adapter?.fields||{}).map(([key,path])=>[key,{type:'form',path}]));}
function readSource(source,sample){
if(source?.type==='form')return {path:source.path,value:Object.hasOwn(sample.fields||{},source.path)?sample.fields[source.path]:null};
if(source?.type==='metadata'&&METADATA_FIELDS.includes(source.key))return {path:'待办 · '+source.key,value:sample[source.key]};
return {path:'',value:null};
}
module.exports={BUSINESS_FIELDS,METADATA_FIELDS,sourcesFor,readSource};