//申请流程按钮 /** * @param {*} that 主页this * @param {*} label 特殊label名称更改 示例:{submitRequest:'确认提交'} * @param {*} initHide 自定义返回是否隐藏函数 {submitRequest:() => {return false)} * @param {*} noShow 不显示的按钮 示例:['submitRequest'] * 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,'submitRequest')?changeLabelText(label,'submitRequest'):'提交', name: "submitRequest", hide: () => { return hideButtonRequest(that, [1], initHide, noShow , 'submitRequest') }, size: 'mini' }, { type: 'primary', icon: 'el-icon-circle-check', // label: label==undefined?'审批':label, label: changeLabelText(label,'agreeRequest')?changeLabelText(label,'agreeRequest'):'审批', name: "agreeRequest", hide: () => { return hideButtonRequest(that, [2], initHide, noShow , 'agreeRequest') }, size: 'mini' }, { type: 'primary', icon: 'el-icon-circle-check', // label: label==undefined?'处理':label, label: changeLabelText(label,'handleRequest')?changeLabelText(label,'handleRequest'):'处理', name: "handleRequest", hide: () => { return hideButtonRequest(that, [4], initHide, noShow , 'handleRequest') }, size: 'mini' }, { type: 'primary', icon: 'el-icon-circle-check', // label: '执行', label: changeLabelText(label,'againHandleRequest')?changeLabelText(label,'againHandleRequest'):'执行', name: "againHandleRequest", hide: () => { return hideButtonRequest(that, [9], initHide, noShow , 'againHandleRequest') }, size: 'mini' }, { type: 'danger', icon: 'el-icon-delete-solid', // label: '中止', label: changeLabelText(label,'abortRequest')?changeLabelText(label,'abortRequest'):'中止', name: "abortRequest", hide: () => { return hideButtonRequest(that, [5], initHide, noShow , 'abortRequest') }, size: 'mini' }, { type: 'danger', icon: 'el-icon-circle-check', // label: '驳回', label: changeLabelText(label,'refuseRequest')?changeLabelText(label,'refuseRequest'):'驳回', name: "refuseRequest", hide: () => { return hideButtonRequest(that, [2], initHide, noShow , 'refuseRequest') }, size: 'mini' }, { type: 'danger', icon: 'el-icon-delete-solid', // label: '取消', label: changeLabelText(label,'cancelRequest')?changeLabelText(label,'cancelRequest'):'取消', name: "cancelRequest", hide: () => { return hideButtonRequest(that, [1,2,4], initHide, noShow , 'cancelRequest') }, 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 }