// 申请流程按钮name值统一封装 const requestDataNames = { submit:'submitRequest',//提交 agree:'agreeRequest',//审批 handle:'handleRequest',//处理 againHandle:"againHandleRequest",//执行 abort:'abortRequest',//中止 refuse:'refuseRequest',//驳回 cancel:'cancelRequest',//取消 } export default requestDataNames; //申请流程按钮 /** * @param {*} that 主页this * @param {*} label 特殊label名称更改 示例:{againHandleRequest:'确认提交'} * @param {*} initHide 自定义返回是否隐藏函数 {againHandleRequest:() => {return false)} * @param {*} noShow 不显示的按钮 示例:['againHandleRequest'] * initHide优先级大于noShow 如果initHide和noShow中都有对应数据,则noShow无效 * vue调用文件参考示例: * 1、使用 label 更改按钮名称 DrawerButtonData: [ ...requestData(this,{againHandleRequest:'新按钮名称'}), ] * 2、使用 initHide 函数处理是否隐藏 againHandleRequestInit为业务线判断隐藏函数,返回值为false/true DrawerButtonData: [ ...requestData(this,false,{ againHandleRequest:() => {return this.againHandleRequestInit([9])} }), ] * 3、使用 noShow 隐藏按钮 DrawerButtonData: [ ...requestData(this,false,false,['againHandleRequest']), ] * @returns */ export function requestData(that,label,initHide,noShow){ return [ { type: 'primary', icon: 'el-icon-circle-check', // label: label==undefined?'提交':label, label: changeLabelText(label,requestDataNames.submit)?changeLabelText(label,requestDataNames.submit):'提交', name: requestDataNames.submit, hide: () => { return hideButtonRequest(that, [1], initHide, noShow , requestDataNames.submit) }, size: 'mini' }, { type: 'primary', icon: 'el-icon-circle-check', // label: label==undefined?'审批':label, label: changeLabelText(label,requestDataNames.agree)?changeLabelText(label,requestDataNames.agree):'审批', name: requestDataNames.agree, hide: () => { return hideButtonRequest(that, [2], initHide, noShow , requestDataNames.agree) }, size: 'mini' }, { type: 'primary', icon: 'el-icon-circle-check', // label: label==undefined?'处理':label, label: changeLabelText(label,requestDataNames.handle)?changeLabelText(label,requestDataNames.handle):'处理', name: requestDataNames.handle, hide: () => { return hideButtonRequest(that, [4], initHide, noShow , requestDataNames.handle) }, size: 'mini' }, { type: 'primary', icon: 'el-icon-circle-check', // label: '执行', label: changeLabelText(label,requestDataNames.againHandle)?changeLabelText(label,requestDataNames.againHandle):'执行', name: requestDataNames.againHandle, hide: () => { return hideButtonRequest(that, [9], initHide, noShow , requestDataNames.againHandle) }, size: 'mini' }, { type: 'danger', icon: 'el-icon-delete-solid', // label: '中止', label: changeLabelText(label,requestDataNames.abort)?changeLabelText(label,requestDataNames.abort):'中止', name: requestDataNames.abort, hide: () => { return hideButtonRequest(that, [5], initHide, noShow , requestDataNames.abort) }, size: 'mini' }, { type: 'danger', icon: 'el-icon-circle-check', // label: '驳回', label: changeLabelText(label,requestDataNames.refuse)?changeLabelText(label,requestDataNames.refuse):'驳回', name: requestDataNames.refuse, hide: () => { return hideButtonRequest(that, [2], initHide, noShow , requestDataNames.refuse) }, size: 'mini' }, { type: 'danger', icon: 'el-icon-delete-solid', // label: '取消', label: changeLabelText(label,requestDataNames.cancel)?changeLabelText(label,requestDataNames.cancel):'取消', name: requestDataNames.cancel, hide: () => { return hideButtonRequest(that, [1,2,4], initHide, noShow , requestDataNames.cancel) }, size: 'mini' }, // { // type: 'primary', // icon: 'el-icon-circle-check', // label: '执行完成', // name: "completeRequest", // hide: () => { return hideButtonRequest(that, [5]) }, // size: 'mini' // }, ] } //任务流程按钮 /** * @param {*} that 主页this * @returns */ export function jobData(that){ return [ { type: 'primary', icon: 'el-icon-circle-check', label: '接受', name: "acceptJob", hide: () => { return hideButtonJob(that, [1]) }, size: 'mini' }, { type: 'primary', icon: 'el-icon-circle-check', label: '执行', name: "handleJob", hide: () => { return hideButtonJob(that, [2]) }, size: 'mini' }, { type: 'primary', icon: 'el-icon-circle-check', label: '打开', name: "openJob", hide: () => { return hideButtonJob(that, [4]) }, size: 'mini' }, { type: 'danger', icon: 'el-icon-circle-close', label: '关闭', name: "closeJob", hide: () => { return hideButtonJob(that, [1]) }, size: 'mini' }, { type: 'danger', icon: 'el-icon-delete-solid', label: '作废', name: "invalidJob", hide: () => { return hideButtonJob(that, [1, 4]) }, size: 'mini' }, { type: 'danger', icon: 'el-icon-circle-close', label: '取消', name: "cancelAcceptJob", hide: () => { return hideButtonJob(that, [2]) }, size: 'mini' }, ] } function hideButtonRequest(that, val, initHide, noShow, name) { let data = true // 走自定义是否隐藏事件 if(initHide && initHide[name]){ data = initHide[name]() }else{ // 隐藏按钮中是否有此按钮 if(noShow && noShow.indexOf(name) >= 0){ data = true }else{ val.forEach(key => { if (that.propsData.requestStatus == key) { data = false } }) } } return data } function hideButtonJob(that, val) { let data = true val.forEach(key => { if (that.propsData.jobStatus == key) { data = false } }) return data } // 更改按钮自定义特殊名称 function changeLabelText(labels,name){ if(labels && labels[name]){ return labels[name] } return false }