UNPKG

uicore-web

Version:

web ui core

738 lines (728 loc) 34.2 kB
import CustomToolbar from './CustomToolbar'; import ContainerLayout from '../ContainerLayout'; import common from "./common"; import {getToken} from "../../utils/auth"; /** * 已正式加入框架体系应用 * marked by deleteelf 20210506 */ export default { mixins: [common],//监听外部框架的大小改变事件 props: { params: { type: Object, default: null } }, data() { return { initialized: false, fid: null, linkageTimeoutHandle: {}, selectedItem: null, view: {//布局控制配置 buttonType: 1, //1 只允许出现在一个地方,2,允许同时出现在工具栏和列表 buttonIcon: true,//控制按钮在列表中是否显示其图标的全局开关,如果已经打开,则根据每个按钮自己的配置来决定是否显示 idKey: "id", parentClass: "app-page", title: null, showTitle: false, showToolbar: true, noQuery: false, emptyText: null, oa: false,//是否激活oa对应的按钮功能 params: {},//用于本页面内置参数干预 query: {},//用于本页面查询参数干预 dialog: { title: "表单" } }, queryParams: {loading: false}, dialog: {}, defaultDialog:{ visible: false, title: "未设置标题", width: "700px", height: "300px", modalClose: false, destroyOnClose: true, component: null },defaultRule: { validate: { list: {required: false, errmsg: "请先勾选后再操作!!"}, id: {required: false, errmsg: "请先选择一条数据!!"} } },defaultTools:{ add:{name:"[toolbar.add]",type:"form",remark:"[toolbar.add_remark]",style:"icon-add success", linkageRule:{params:{fid:"{fid}",cid:"{cid}",pTodoId: "{pTodoId}"}}}, mod:{name:"[toolbar.mod]",type:"form",remark:"[toolbar.mod_remark]",style:"icon-mod", linkageRule:{params:{fid:"{fid}",cid:"{cid}",id:"{id}"},validate:{id:{required:true}}}}, del:{name:"[toolbar.del]",type:"jsonupdate",remark:"[toolbar.del_remark]",style:"icon-del danger", actionUrl:this.$store.state.api.form.delForm+"{fid}", linkageRule:{params:{list:"{list}"},validate:{list:{required:true}}, confirm:{msg:"是否删除选中数据"}}}, oa_submit:{style: "icon-oa-submit success", type: "form", code: "oa_submit", name: "提交", remark: "提交到代办流程", linkageRule: {width: "800px", height: "650px", title: "提交到代办流程", params: {proId:"{proid}",cid: "{cid}",infoId: "{id}",pTodoId:"{pTodoId}", toStepId:"{first_step}",title: "{title}",fid: "submitProcess"}, validate:{id: {required: true}, proid: {required: true, errmsg: "未设置有效的流程编号"}, status:{indexOf: ["未提交", "审批退回"], errmsg:"只能对未提交或者审批退回的内容执行提交操作!"}}}}, oa_do:{style: "icon-process-list warning", type: "form", code: "oa_do", name: "审批", remark: "执行审批操作", linkageRule: {width: "800px", height: "700px", title: "流程审批", component: "StepView", params: { proId: "{proid}", cid: "{cid}", infoId: "{id}", stepId: "{stepid}", fid: "{oa_fid}", rid: "{oa_rid}",todoId:"{todoid}"}, validate: { id: {required: true}, proid: {required: true, errmsg: "未设置有效的流程编号"}, status: {indexOf: ["已提交", "审批中"], errmsg: "只能对已提交或者审批中的内容执行审批操作!"}, stepuser: {required: true, errmsg: "只有流程步骤审批人才能执行审批操作!"}, stepid: {required: true, errmsg: "未设置有效的步骤编号"}}}}, oa_detail:{style: "icon-log", type: "form", code: "oa_detail", name: "查看详情", remark: "查看审批结果与审批记录", linkageRule: { width: "850px", height: "800px", title: "查看代办详情", component: "ProcessView", params: {proId: "{proid}", cid: "{cid}", id: "{id}", rid: "{oa_rid}"}, validate: { id: {required: true}, proid: {required: true, errmsg: "未设置有效的流程编号"}, status: {notEquals: "未提交", errmsg: "无法对未提交的内容进行查看详细操作!"}}}} }, } }, created() { }, components: { ContainerLayout, CustomToolbar, Dialog: (resolve) => require([`../Dialog`], resolve), ListView: (resolve) => require([`../editors/ListView`], resolve), FormView: (resolve) => require([`../editors/FormView`], resolve), TreeView: (resolve) => require([`../editors/TreeView`], resolve), EChartView: (resolve) => require([`../editors/EChartView`], resolve), WebView: (resolve) => require([`../WebView`], resolve), TabControl: (resolve) => require([`../tab`], resolve), SelectTreeView: (resolve) => require([`../editors/SelectTreeView`], resolve), // ProcessView: (resolve) => require([`../oa/ProcessView`], resolve),//下面按需注册 StepView: (resolve) => require([`../oa/StepView`], resolve), }, methods: { $_page_getRouter() { if (this.$route && this.$route.query) { this.$_page_updatePageParams(this.$route.query); } if (this.params) { this.$_page_updatePageParams(this.params); } }, $_page_updatePageParams(pageParams) { let keys = Object.getOwnPropertyNames(pageParams); if (keys.length > 0) { this.fid = pageParams.fid; this.websocket = pageParams.websocket if (pageParams.noQuery) this.view.noQuery = pageParams.noQuery; if (pageParams.showToolbar != null) this.view.showToolbar = !(pageParams.showToolbar === false || pageParams.showToolbar == "false"); if (pageParams.halfChecked != null) this.view.checkStrictly = !(pageParams.halfChecked === false || pageParams.halfChecked == "false") if (pageParams.expandAll != null) this.view.expandAll = (pageParams.expandAll === true || pageParams.expandAll == "true") if (pageParams.showTitle != null) this.view.showTitle = (pageParams.showTitle === true || pageParams.showTitle == "true"); if (pageParams.showFilter != null) this.view.showFilter = (pageParams.showFilter === true || pageParams.showFilter == "true") if (pageParams.checkStrictly != null) this.view.checkStrictly = (pageParams.checkStrictly === true || pageParams.checkStrictly == "true") if (pageParams.showCheckbox != null) this.view.showCheckbox = (pageParams.showCheckbox === true || pageParams.showCheckbox == "true") if (pageParams.selectEnable != null) this.view.selectEnable = (pageParams.selectEnable === true || pageParams.selectEnable == "true") if (pageParams.dataType != null) this.view.dataType = pageParams.dataType; if (pageParams.action) { this.view.action = pageParams.action } if (pageParams.oa) { this.view.oa = pageParams.oa } if (pageParams.reportname) this.view.reportname = this.$_i18n(pageParams.reportname); for (let key in pageParams) { this.$set(this.queryParams, key, this.$d.adapterData(pageParams[key])); } // this.$d.debug().log("当前界面接收菜单传递参数",this.queryParams); // if (pageParams.width) { // this.dialog.width = pageParams.width; // } // if (pageParams.height) { // this.dialog.height = pageParams.height; // } if (pageParams.showPage != null&&this.view.pageControl) this.view.pageControl.visible= (pageParams.showPage !== false && pageParams.showPage !== "false") if (pageParams.s &&this.view.pageControl&& this.view.pageControl.pageSizes) { if (!Number.isNaN(pageParams.s) && this.view.pageControl.pageSizes.indexOf(pageParams.s) < 0) { for (let i in this.view.pageControl.pageSizes) { if (pageParams.s < this.view.pageControl.pageSizes[i]) { this.view.pageControl.pageSizes.splice(i, 0, pageParams.s); break; } } } } //处理参数传递可能产生的恶性界面污染问题 delete this.queryParams.expandAll; delete this.queryParams.halfChecked; delete this.queryParams.novali; delete this.queryParams.showFilter; delete this.queryParams.checkStrictly; delete this.queryParams.showCheckbox; delete this.queryParams.selectEnable; delete this.queryParams.dataType; delete this.queryParams.showPage; delete this.queryParams.width; delete this.queryParams.height; delete this.queryParams.showToolbar; delete this.queryParams.showTitle; delete this.queryParams.oa; delete this.queryParams.action; delete this.queryParams.noQuery; // delete this.queryParams.jid;//jid因为要作为数据应用到下拉,所以不能删除 // delete this.queryParams.fid;//防止因开发未正确处理而导致的无限循环现象。 this.updatePageParams(pageParams); } }, $_page_toolbar_initComplete(params, view, toolbarItems) { this.$_page_updateView(view, toolbarItems);//从工具栏的返回参数中获取下个页面的配置,一定要在界面查询完成后进行 this.initialized = true; if (this.handleParams) this.handleParams(); this.$d.debug().log("工具栏加载结果",this.$options.name,this.items); this.$_page_updateQueryParams(params);//从工具栏收集最新的参数给列表 }, $_page_updateQueryParams(params, isOut) { //接收页面级参数 //是否是外部参数 this.updatePageParams(params);//如果涉及主报表和主表单变更,可能需要考虑更复杂的重新加载逻辑,目前,先考虑不会修改 if (isOut) { if (params.fid != null) this.$d.debug().warn("收到外部传递参数,目前没有对外部传递的影响工具栏的参数进行处理,主要是fid", params); for (let key in params) { let value = this.$d.debug().adapterData(params[key]); if (value != this.queryParams[key]) {//数据不一样才进行处理 this.$set(this.queryParams, key, value);//外部传递的参数,可能是不合法的 if (this.$refs.toolbar && this.$refs.toolbar.toolbars && this.$refs.toolbar.toolbars[key] >= 0) {//如果联动了工具栏,则需要触发事件 let toolbarItem = this.$refs.toolbar.items[this.$refs.toolbar.toolbars[key]]; if (toolbarItem && toolbarItem.triggerHandler) { toolbarItem.triggerHandler(toolbarItem, value); } } } } } else { for (let key in params) { this.$set(this.queryParams, key, params[key]); } } this.query(params); }, $_page_keepSelectedCallback(data) { let item = null; if (this.selectedItem) { for (let i in data) { if (data[i][this.view.idKey] == this.selectedItem[this.view.idKey]) { item = data[i]; break; } } delete this.selectedItem; } return item; }, query(params) {//默认查询支持 //受进入页面不查询的支持 if (this.view.noQuery) { this.view.emptyText = "页面启动了加载不查询功能,请点击查询获取数据!" } params.data = (this.view.noQuery !== true); if (this.initialized !== false && params.inited !== false) this.customQuery(params); }, showDialog(item) { let options ={params: {}}; if(item.type=="form"){ options= this.$d.merge({params: {}}, this.view.dialog,{params:this.view.formView},item.linkageRule);//克隆,防止参数污染 }else{ // if(item.type=="list"){ options= this.$d.merge({params: {}}, this.view.dialog, item.linkageRule);//克隆,防止参数污染 } switch (item.type) { case "form": case "list": let params = this.$d.extend({}, this.queryParams, this.selectedItem, this.getFormData()); if (this.$options.name == "TreeView"&&item.code=="add") { options.params.pid = this.selectedItem ? this.selectedItem[this.view.idKey] : this.queryParams.pid; } if (this.fid) params.fid = this.fid; if (typeof item.linkageRule.componentPath == "string" && typeof item.linkageRule.component == "string" && this.$options.components[item.linkageRule.component] == null) { let name = item.linkageRule.component; this.$reg(this, name, item.linkageRule.componentPath); } for (let key in options.params) { if (typeof options.params[key] == "string") { options.params[key] = options.params[key].urlFormat(params, true); } } if (options.title) { options.title = this.$_i18n( options.title); } break; default: break; } this.dialog=this.$d.merge(this.defaultDialog,options); if(item.type=="form"){ if(item.code=="add"){ this.dialog.title=this.$_i18n("[toolbar.add]")+this.dialog.title; }else if(item.code=="mod"){ this.dialog.title=this.$_i18n("[toolbar.mod]")+this.dialog.title; } } this.dialog.visible = true; }, $_page_updateLayoutSetting(view) { for (let key1 in view.layout) { //在执行某个layout属性挂载,那么visible与component必须在最后执行 if(this.view.layout[key1]) { let area = view.layout[key1]; let result = this.$d.merge(this.view.layout[key1], area); for (let key2 in area) { if (key2 != "visible" && key2 != "component") this.$set(this.view.layout[key1], key2, result[key2]);//融合不支持常量 } if (area.visible != null) this.$set(this.view.layout[key1], "visible", area.visible); if (area.component != null) { if (area.componentPath && !this.$options.components[area.component]) { this.$reg(this, area.component, area.componentPath); } this.$set(this.view.layout[key1], "component", area.component); } } } }, $_page_updateView(view, toolbarItems) { if (view) { //对于view的属性加载是有讲究的 for (let key in view) { if (key == "title") { if (this.view.title != "未设置标题") this.$set(this.view, key, view[key]); } else if (key == "layout") { this.$_page_updateLayoutSetting(view); } else if (key == "query") { this.$set(this, "queryParams", this.$d.extend(this.queryParams, view[key])); } else if (key == "params") { this.$_page_updatePageParams(view[key]); } else { if (typeof view[key] == "object" && !this.$d.isArray(view[key])) this.$set(this.view, key, this.$d.merge(this.view[key], view[key])); else this.$set(this.view, key, view[key]); } } if (view.layout) this.$nextTick(() => { this.$refs.layout.updateLayout(this.view.layout); }) } if (this.view.row && this.view.row.list.length > 0 && toolbarItems) { let buttons = []; for (let i in this.view.row.list) { let codes = this.stringArray(this.view.row.list[i]); buttons = buttons.concat(codes); } for (let i in toolbarItems) { let item = toolbarItems[i]; if (buttons.indexOf(item.code) >= 0) { this.view.row.buttons[item.code] = item; if (this.view.buttonType == 1) { this.$set(item, "visible", false); } } } } if(toolbarItems){ for (let i in toolbarItems) { let item = toolbarItems[i]; if(this.view.rowClick==item.code){ this.$set(item, "visible", false); this.rowClickHandle=item; }else if(this.view.rowDbClick==item.code) { this.$set(item, "visible", false); this.rowDbClickHandle=item; } } } if (this.resize) this.resize(); },async handleDialogClose(e) { if(this.dialog.rule&&this.$refs.form.linkageData) { let params=this.$d.extend({},this.getFormData(),e.form); await this.$refs.form.linkageData(this.dialog.rule, true, this.getFormData(), params); } if (typeof e != "function" && e.success != null) { if(e.params&&e.params.closeParent) {//如果配置了关闭父窗口,则执行关闭 this.closeDialog({success:e.success,msg:e.msg,form:this.getFormData()}) }else{ this.$nextTick(() => { this.$_page_message(e); this.customQuery(this.queryParams); }) } } },getFormData(){ if(this.$refs.form&&this.$refs.form.form){ let result=this.$d.merge({},this.$refs.form.form); for(let i in this.$refs.form.items){ switch(this.$refs.form.items[i].type){ case "editor"://保存时需要恢复成相对地址 // case "file"://保存时需要恢复成相对地址 // case "image"://保存时需要恢复成相对地址 let key= this.$refs.form.items[i].code; if(result[key]) { let reg=new RegExp(this.$store.state.api.axios.baseURL + "/","g"); result[key] = result[key].replace(reg, ""); //地址修复 result[key] = result[key].replace(/width="300"/g, 'width="100%"') ; //强制去掉播放器的宽度和高度 result[key] = result[key].replace(/height="150"/g, ""); // result[key] = result[key].replace(/width="200"/g, 'width="100%"') ; //强制去掉播放器的宽度和高度 // result[key] = result[key].replace(/height="160"/g, ""); } break; default: break; } } return result; } }, $_page_message(result) { if(result.msg) {//部分场景不需要提示时,会关闭掉提示,采用的方式是删除msg的内容 this.$notify({ title: (result.success ? "成功" : "失败"), duration: 5000, message: result.msg, type: (result.success ? "success" : "error") }); } }, $page_toolbar_clickHandler(event,item) { //工具栏点击事件一共分为两种 //1,不需要进行当前界面二次收集数据的 //2,需要当前界面二次收集数据,如选中项 //是否需要,则是由验证器来决定 //从设计上来说,目前只有查询是绝对不需要验证器的,其他一律走验证器逻辑 this.$d.merge({}, this.queryParams, this.$refs.toolbar.queryParams); this.$d.debug().log("点击了按钮", item); switch (item.type) { case "search": this.queryParams.p = 1; this.$refs.toolbar.queryParams.data=true; this.customQuery(this.$refs.toolbar.queryParams); break; default: let setting = this.$d.merge({}, this.defaultRule, item.linkageRule); if (this.validate(setting)) { if (setting.confirm && setting.confirm.msg) { this.$confirm(setting.confirm.msg).then((e) => { this.execute(item); }).catch(() => { }) } else { this.execute(item); } }else{ event.preventDefault(); // if(item.type=="linkButton"){ // // } return false; } break; } }, validate(setting) { if (setting.validate) { if (this.validateCallback) { for (let key in setting.validate) { if (setting.validate[key].required !== false){ let result=this.validateCallback(setting.validate[key], key); if(result===false) { this.$notify({title: '警告', message: setting.validate[key].errmsg || "未输入正确的提示信息", type: 'warning'}); return false; }else if(result==null){//递归的不再提示 return false; } } } } } return true; }, execute(item) { switch (item.type) { case "form": if (!item.linkageRule || !item.linkageRule.component) this.$d.merge(true, item, {linkageRule: {component: "FormView"}}); this.showDialog(item); break; case "list": if (!item.linkageRule || !item.linkageRule.component) this.$d.merge(true, item, {linkageRule: {component: "ListView"}}); this.showDialog(item); break; case "webpage": case "print": if (item.actionUrl) { item.linkageRule.component = "WebView"; let params = this.$d.extend({}, this.queryParams, this.selectedItem); if (this.$d.isExternal(item.actionUrl)) { item.linkageRule.params = {src: item.actionUrl.urlFormat(params, false, true)}; } else { item.linkageRule.params = {src: this.$store.state.api.axios.baseURL + item.actionUrl.urlFormat(params, false, true)}; } } this.showDialog(item); break; case "link": if (item.actionUrl) { let params = this.$d.extend({}, this.queryParams, this.selectedItem); if(item.actionUrl.indexOf("{token}")>-1){//对token的包装支持 params["token"] =getToken(); } let url =this.adapterUrl(item.actionUrl.urlFormat(params)); this.$set(item, "href", this.$d.replaceQueryString(url)); } break; case "jsonupdate": if (item.actionUrl) { let params = {}; if (this.checkedItems && this.checkedItems.length > 0) //优先勾选的对象 params.list = this.checkedItems.map((item,index)=>{ return item[this.view.idKey]; }); else if (this.selectedItem && this.selectedItem.id) params.list = [this.selectedItem.id]; let options = this.$d.extend({}, this.queryParams, this.selectedItem, params, this.getFormData());//获取所有的参数 params = this.$d.extend(params,this.$d.getParams(item.actionUrl));//对地址栏上的get参数进行支持 params = this.$d.extend(params,item.linkageRule.params);//对联动规则上的参数进行支持 for (let key in params) { if(typeof params[key]=="string") { params[key] = params[key].urlFormat(options, true); } } let url = this.$d.getPageAddress(item.actionUrl).urlFormat(options);//对动态地址进行支持 this.$http(url, {data: params}).then((res) => { if(item.linkageRule.saveAndClose){ if (res.success) { if(item.linkageRule.saveAndClose){ //关闭弹窗,刷新父页面 this.closeDialog({success: res.success, msg: res.msg, form: params, params: this.params}); }else{ this.$_page_message(res);//当前页提示消息 this.$parent.returnData={success: res.success,form:params, params: this.params}; } } else { this.$_page_message(res);// this.$notify({title: '失败',duration:10,message: res.msg,type: 'error'}); } }else { if (res.success) { this.$_page_message(res); this.customQuery(this.$refs.toolbar.queryParams); } else { this.$_page_message(res); } } }) } break; case "save": this.save(item, this.view.formView == null || this.view.formView.saveAndClose); break; case "saveRel": let ids= this.$refs.tree.getCheckedKeys();//选中的节点 if(!this.view.checkStrictly) ids = ids.concat(this.$refs.tree.getHalfCheckedKeys());//追加半选 let params = this.$d.extend({}, this.queryParams, {checkedIds: ids.join(",")}) this.$http({url: this.$store.state.api.form.saveRel, data: params}).then((res) => { if (res.success) { //关闭弹窗或刷新父页面 if (this.$parent && this.$parent.hide && this.$parent.$options.name == "Dialog") { this.$parent.hide({success: res.success, msg: res.msg}); } } else { this.$_page_message(res);// this.$notify({title: '失败',duration:10,message: res.msg,type: 'error'}); } }) break; case "close": this.save(item); break; case "plugin": if(item.linkageRule&&item.linkageRule.plugin) { if (this.$plugins[item.linkageRule.plugin]) this.$plugins[item.linkageRule.plugin](item, this); else this.$d.debug().warn("未找到相关插件,请检查配置", item); } break; default: break; } },getStyle(style) { if (style) return "iconfont iconfont-toolbar " + style; }, $_page_linkageLayout(layout) { if (this.$refs[layout] && this.$refs[layout].initialized !== false) { //防止某些页面没有注册这个参数 if (this.selectedItem) { let params ={p: 1}; let nextParams=this.$d.merge(this.queryParams,this.selectedItem); for (let key in this.view.layout[layout].query) { if (typeof this.view.layout[layout].query[key] == "string") { if (this.view.layout[layout].query[key] == "selected") { params[key] = nextParams[key]; } else { params[key] = this.view.layout[layout].query[key].urlFormat(nextParams, true); } } else { if (nextParams[key] != null) { params[key] = nextParams[key]; } else { params[key] = this.view.layout[layout].query[key]; } } } this.$refs[layout].$_page_updateQueryParams(params, true); } else if (this.getFormData()) { this.$refs[layout].$_page_updateQueryParams(this.$d.extend({}, this.queryParams, this.getFormData()), true); } } else { if (this.linkageTimeoutHandle[layout] != null) { clearTimeout(this.linkageTimeoutHandle[layout]); delete this.linkageTimeoutHandle[layout]; } this.linkageTimeoutHandle[layout] = setTimeout(this.$_page_linkageLayout, 50, layout); } },save(item,successClose=true){ this.$refs.form.$refs.form.validate((valid) => { if (valid) { let url = this.$store.state.api.form.saveForm+ this.fid;; if(this.view.formView&&this.view.formView.action!=null)//支持地址置空 url=this.view.formView.action; if(item.actionUrl!=null)//支持地址置空 url=item.actionUrl; let data=this.getFormData(); if(item.linkageRule){ if(item.linkageRule.saveAndClose!=null) successClose=item.linkageRule.saveAndClose; if(item.linkageRule.params){//包装扩展参数 let temp=this.$d.merge({},data); for(let key in item.linkageRule.params){ if(data[key]===undefined){ if(typeof item.linkageRule.params[key]=="string"&&item.linkageRule.params[key].indexOf("{")>=0) temp[key]=item.linkageRule.params[key].urlFormat(this.getFormData(),true); else temp[key]=item.linkageRule.params[key]; } } data=temp; } } if(url) {//如果提供了地址,则执行保存并返回 this.$http(url, {data: data}).then((res) => { if (res.success) { if(successClose){ //关闭弹窗,刷新父页面 this.closeDialog({success: res.success, msg: res.msg, form: data, params: this.params}); }else{ this.$_page_message(res);//当前页提示消息 this.$parent.returnData={success: res.success,form: data, params: this.params}; } } else { this.$_page_message(res);// this.$notify({title: '失败',duration:10,message: res.msg,type: 'error'}); } }) }else{//否则直接执行返回 this.closeDialog({form: data, params: this.params}); } } else { return false; } }); },closeDialog(returnData){ if (this.$parent && this.$parent.hide && this.$parent.$options.name == "Dialog") { this.$parent.hide(returnData); }else{ this.$_page_message(returnData);//当前页提示消息 } },async initFormConfig(){ if(this.fid){ let cache={}; if (this.$store.state.form[this.fid]) { cache = this.$d.decodeData(this.$store.state.form[this.fid], {}).data[0]; } else { await this.$async({ url: this.$store.state.api.form.loadConfig + this.fid, keymap: {}, beforeDecode: (e) => { this.$store.dispatch('form/update', {key: this.fid, value: e}); } }).then(async (res) => { cache = res.data[0]; }) } //完成工具栏数据布局 for(let i=cache.tools.length-1;i>=0;i--){ if(cache.tools[i].position=="5"){//配置停靠区域为表单的,不在列表显示 cache.tools.splice(i,1); }else { let item = cache.tools[i];//新组件 if (this.defaultTools[item.code]) { cache.tools[i] = this.$d.merge(this.defaultTools[item.code], item);//自动完善细化配置,并完成属性重写 } } } this.$nextTick(async ()=>{ if(this.$options.name=="SelectTreeView"){ cache.tools=this.tools.concat(cache.tools); for(let i=cache.tools.length-1;i>=0;i--){ switch (cache.tools[i].code) { case "add": case "mod": case "del": cache.tools.splice(i,1); break; default: break; } } } await this.$refs.toolbar.updateTools(cache.tools,cache.view); if (this.view.oa && this.queryParams.cid) {//oa的组件暂时追加在配置的最后面 this.$reg(this, "StepView", "../oa/StepView"); this.$reg(this, "ProcessView", "../oa/ProcessView"); let buttons= ["oa_submit","oa_do","oa_detail"]; for(let i in buttons) { let code=buttons[i]; if (this.$refs.toolbar.toolbars[code] == null) { let index = this.$refs.toolbar.items.length; this.$refs.toolbar.items.push(this.defaultTools[code]); this.$refs.toolbar.toolbars[code]=index; } } //除了这些功能外,还需要对修改和删除功能进行干预 this.$nextTick(() => { if (this.$refs.toolbar && this.$refs.toolbar.toolbars) { if (this.$refs.toolbar.toolbars["mod"] != null) { this.$refs.toolbar.items[this.$refs.toolbar.toolbars["mod"]].linkageRule.validate.status = { indexOf: ["未提交", "审批退回"], errmsg: "流程执行过程,不允许修改内容!" } } if (this.$refs.toolbar.toolbars["del"] != null) { this.$refs.toolbar.items[this.$refs.toolbar.toolbars["del"]].linkageRule.validate.status = { indexOf: ["未提交", "审批退回"], errmsg: "流程执行过程,不允许修改内容!" } } } }) } }) }else{ //如果没有表单干预,则默认加载当前配置的tools this.$nextTick(async ()=>{ await this.$refs.toolbar.updateTools(this.tools,{}); }) } } } }