263 lines
10 KiB
JavaScript
263 lines
10 KiB
JavaScript
let tmpArr = null
|
||
let flagNum = 0
|
||
// 目标对象
|
||
const target = {};
|
||
// 代理对象
|
||
const handler = {
|
||
get: function (target, property, receiver) {
|
||
return Reflect.get(target, property, receiver);
|
||
},
|
||
set: function (target, property, value) {
|
||
const oldValue = target[property];
|
||
const baseInfo = WfForm.getBaseInfo();
|
||
|
||
if (baseInfo.requestid && !oldValue) {
|
||
target[property] = value;
|
||
return false
|
||
}
|
||
if (!_.isEqual(oldValue, value)) {
|
||
const found = config.find(item => item.workflowId === baseInfo.workflowid && item.mainfjid === value[0].localFieId);
|
||
if (!found) return
|
||
|
||
_.difference(_.map(value, 'fileid'), _.map(oldValue, 'fileid'), tmpArr).forEach((e, i) => {
|
||
WfForm.addDetailRow(property, { [found.fjld]: { value: e }, [found.fjgs]: { value: value[i].fileExtendName } })
|
||
|
||
|
||
})
|
||
|
||
target[property] = value;
|
||
}
|
||
}
|
||
};
|
||
// 创建代理
|
||
let proxy = new Proxy(target, handler);
|
||
|
||
|
||
const config = [
|
||
{
|
||
workflowId: 93026, //资料签收
|
||
detailId: 'detail_2',
|
||
fjld: "field114944", //明细表附件id 单行文本字段
|
||
mainfjid: "field114963",//主表附件字段
|
||
mxfjid: "field114942",//明细表附件字段
|
||
nodeid: "135541", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: "field114948"//附件后缀
|
||
}, {
|
||
workflowId: 93526, //项目图片
|
||
detailId: 'detail_1',
|
||
fjld: "field114498", //明细表附件id 单行文本字段
|
||
mainfjid: "field114521",//主表附件字段
|
||
mxfjid: "field114500",//明细表附件字段
|
||
nodeid: "136041", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: "field114497"//附件后缀
|
||
}
|
||
, {
|
||
workflowId: 93527, //踏勘
|
||
detailId: 'detail_1',
|
||
fjld: "field114473", //明细表附件id 单行文本字段
|
||
mainfjid: "field114477",//主表附件字段
|
||
mxfjid: "field114644",//明细表附件字段
|
||
nodeid: "136044", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: "field114470"//附件后缀
|
||
},
|
||
{
|
||
workflowId: 108027, //日常费用报销
|
||
detailId: 'detail_4',
|
||
fjld: "field179935", //明细表附件id 单行文本字段
|
||
mainfjid: "field179944",//主表附件字段
|
||
mxfjid: "field179872",//明细表附件字段
|
||
nodeid: "153048", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
}
|
||
,
|
||
{
|
||
workflowId: 108027, //日常费用报销
|
||
detailId: 'detail_1',
|
||
fjld: "field179933", //明细表附件id 单行文本字段
|
||
mainfjid: "field179945",//主表附件字段
|
||
mxfjid: "field179871",//明细表附件字段
|
||
nodeid: "153048", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
}
|
||
,
|
||
{
|
||
workflowId: 108027, //日常费用报销
|
||
detailId: 'detail_2',
|
||
fjld: "field179934", //明细表附件id 单行文本字段
|
||
mainfjid: "field179946",//主表附件字段
|
||
mxfjid: "field179876",//明细表附件字段
|
||
nodeid: "153048", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
}
|
||
,
|
||
{
|
||
workflowId: 109026, //管理经费报销
|
||
detailId: 'detail_4',
|
||
fjld: "field180615", //明细表附件id 单行文本字段
|
||
mainfjid: "field180616",//主表附件字段
|
||
mxfjid: "field180614",//明细表附件字段
|
||
nodeid: "153548", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
},
|
||
{
|
||
workflowId: 109026, //管理经费报销
|
||
detailId: 'detail_1',
|
||
fjld: "field180605", //明细表附件id 单行文本字段
|
||
mainfjid: "field180617",//主表附件字段
|
||
mxfjid: "field180603",//明细表附件字段
|
||
nodeid: "153548", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
}, {
|
||
workflowId: 109026, //管理经费报销
|
||
detailId: 'detail_2',
|
||
fjld: "field180611", //明细表附件id 单行文本字段
|
||
mainfjid: "field180618",//主表附件字段
|
||
mxfjid: "field180609",//明细表附件字段
|
||
nodeid: "153548", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
}, {
|
||
workflowId: 109028, //管理经费报销
|
||
detailId: 'detail_4',
|
||
fjld: "field180959", //明细表附件id 单行文本字段
|
||
mainfjid: "field181053",//主表附件字段
|
||
mxfjid: "field180957",//明细表附件字段
|
||
nodeid: "153559", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
}, {
|
||
workflowId: 109028, //管理经费报销
|
||
detailId: 'detail_1',
|
||
fjld: "field180914", //明细表附件id 单行文本字段
|
||
mainfjid: "field181054",//主表附件字段
|
||
mxfjid: "field180912",//明细表附件字段
|
||
nodeid: "153559", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
}, {
|
||
workflowId: 109028, //管理经费报销
|
||
detailId: 'detail_2',
|
||
fjld: "field180937", //明细表附件id 单行文本字段
|
||
mainfjid: "field181055",//主表附件字段
|
||
mxfjid: "field180935",//明细表附件字段
|
||
nodeid: "153559", //使用WfForm.getBaseInfo()查看,nodeid为节点一的id,节点二id不允许审批删除附件
|
||
fjgs: ""//附件后缀
|
||
}
|
||
|
||
]
|
||
let firstNum = {}
|
||
ecodeSDK.overwritePropsFnQueueMapSet('WeaUpload', {
|
||
fn: (newProps) => {
|
||
if (!window.location.hash.startsWith('#/main/workflow/req')) return;
|
||
if (newProps.fuxie) return; // 控制组件只复写一次
|
||
if (!WfForm) return;
|
||
|
||
const baseInfo = WfForm.getBaseInfo();
|
||
const found = config.find(item => item.workflowId === baseInfo.workflowid && item.mainfjid === newProps.fieldName);
|
||
|
||
if (!found) return
|
||
const suffixes = config.map(obj => obj.mainfjid.match(/\d+$/)[0]);
|
||
if (!suffixes.includes(newProps.fieldid)) return;
|
||
// if (newProps.datas.length > 0) {
|
||
|
||
newProps.datas.forEach(e => e['localFieId'] = newProps.fieldName)
|
||
proxy[found.detailId] = newProps.datas
|
||
|
||
|
||
// }
|
||
let onUploading = newProps.onUploading
|
||
newProps.onUploading = (string, list, number) => {
|
||
if (string == 'uploading') {
|
||
window.ecCom.WeaLoadingGlobal.start({
|
||
tip: "上传中,请稍后..." // 自定义tip文字
|
||
})
|
||
} if (string == 'uploaded') {
|
||
window.ecCom.WeaLoadingGlobal.end(); // 停止遮罩loading
|
||
window.ecCom.WeaLoadingGlobal.destroy(); // 销毁遮罩loading
|
||
}
|
||
if (string == 'error') {
|
||
window.ecCom.WeaLoadingGlobal.end(); // 停止遮罩loading
|
||
WfForm.showMessage(`上传失败`, 2, 30);
|
||
}
|
||
}
|
||
newProps.className = 'mainfj'
|
||
|
||
return newProps
|
||
},
|
||
order: 1, //排序字段,如果存在同一个页面复写了同一个组件,控制顺序时使用
|
||
desc: '资料签收附件显示'
|
||
});
|
||
const MinXiUDowm = (props, Com) => { //此函数不允许写在复写方法内,会导致实例重复创建,也就是dimout不断执行
|
||
const acParams = {
|
||
appId: '${appId}', //appId会自动识别
|
||
name: 'MinXiUDowm', //模块名称
|
||
isPage: false, //是否是路由页面
|
||
noCss: true, //是否禁止单独加载css,通常为了减少css数量,css默认前置加载
|
||
props,
|
||
}
|
||
const NewCom = Com;
|
||
return window.ecCom ? ecodeSDK.getAsyncCom(acParams) : (<NewCom { ...props } />);
|
||
}
|
||
ecodeSDK.overwriteClassFnQueueMapSet('WeaUpload', { //组件名
|
||
fn: (Com, newProps) => {
|
||
//进行位置判断
|
||
if (!window.location.hash.startsWith('#/main/workflow/req')) return;
|
||
const baseInfo = WfForm.getBaseInfo();
|
||
|
||
const found = config.find(item => item.workflowId === baseInfo.workflowid && item.mainfjid === newProps.fieldName);
|
||
console.log(found,'1')
|
||
|
||
if (!found) return
|
||
const suffixes = config.map(obj => obj.mxfjid.match(/\d+$/)[0]);
|
||
console.log(suffixes)
|
||
console.log(newProps.fieldid)
|
||
|
||
if (!suffixes.includes(newProps.fieldid)) return;
|
||
|
||
newProps.datas.forEach(e => e['localFieId'] = newProps.fieldName)
|
||
newProps.datas = proxy[found.detailId]
|
||
newProps.info = [found]
|
||
newProps.editable = true
|
||
newProps.viewAttr = 2
|
||
newProps.showUpload = false
|
||
newProps.showUploader = true
|
||
newProps.maxUploadSize = 0
|
||
newProps.showUploadTime = true
|
||
newProps.className = 'detailFj'
|
||
return {
|
||
com: MinXiUDowm.bind(this, newProps, Com),
|
||
props: newProps
|
||
};
|
||
},
|
||
order: 10, //排序字段,如果存在同一个页面复写了同一个组件,控制顺序时使用
|
||
desc: '资料签收附件显示'
|
||
});
|
||
let fuxie = false //不允许重复触发
|
||
ecodeSDK.overwritePropsFnQueueMapSet('WeaReqTop', { //提交时把明细删除的附件在主表删除
|
||
fn: (newProps) => {
|
||
if (!window.location.hash.startsWith('#/main/workflow/req')) return;
|
||
const baseInfo = WfForm.getBaseInfo();
|
||
const found = config.find(item => item.workflowId === baseInfo.workflowid);
|
||
if (!found) return
|
||
if (!WfForm) return;
|
||
if (newProps.fuxie) return;
|
||
if (fuxie) return;
|
||
let num = found.detailId.match(/\d+$/)[0];
|
||
let del = []
|
||
WfForm.registerCheckEvent(WfForm.OPER_DELROW + num, function (callback) {
|
||
del = _.concat(del, WfForm.getDetailCheckedRowIndexStr(found.detailId).split(','))
|
||
callback();
|
||
});
|
||
WfForm.registerCheckEvent(WfForm.OPER_SAVE + "," + WfForm.OPER_SUBMIT + "," + WfForm.OPER_SUBMITCONFIRM, function (callback) {
|
||
let oldValue = WfForm.getFieldValue(found.mainfjid).split(',')
|
||
const filteredArr = oldValue.filter((item, index) => { return !del.includes(String(index)) });
|
||
WfForm.changeFieldValue(found.mainfjid, { value: filteredArr.join() });
|
||
//... 执行自定义逻辑
|
||
callback();
|
||
});
|
||
fuxie = true
|
||
newProps.fuxie = true
|
||
|
||
return newProps;
|
||
},
|
||
order: 1, //排序字段,如果存在同一个页面复写了同一个组件,控制顺序时使用
|
||
desc: '设置提交或者保存时修改附件主表数量'
|
||
});
|