本文摘要
在泛微 Ecology 二次开发中,利用 ecodeSDK 覆盖 WeaBrowser 组件,当页面处于流程请求地址且流程 ID 在允许列表内时,为“多流程”浏览按钮的跳转链接添加监控标识参数,并把按钮文字改为“点击查看流程”,从而实现跳转至监控流程。适用于需对指定流程启用监控浏览的场景,需注意开关和流程 ID 白名单配置。
let enable = true;const allowedWorkflowIds = [148,56,143]; // 允许的流程ID列表
//判断条件const checkConditions = () => { // console.log("开始检查"); const { hash } = window.location; if (!hash.startsWith('#/main/workflow/req')) return false; // 判断页面地址 if (!WfForm) return false; // 表单sdk加载完成 const baseInfo = WfForm.getBaseInfo(); const { workflowid } = baseInfo; return allowedWorkflowIds.includes(workflowid); // 判断流程id是否在允许的列表中};
ecodeSDK.overwritePropsFnQueueMapSet('WeaBrowser', { fn: (newProps) => { //newProps 代表组件参数 if (!enable || !checkConditions()) return; // 开关打开、条件不满足
//筛选newProps.title:"多流程" if (newProps.title == "多流程") { const linkUrlWithMonitor = newProps.linkUrl.replace(/(requestid=)/, '&ismonitor=1&$1'); newProps.linkUrl = linkUrlWithMonitor; console.log(newProps); if (!newProps.replaceDatas || !newProps.replaceDatas.length || !newProps.replaceDatas[0].name) { // 如果 replaceDatas 不存在、为空数组或第一个元素的 name 属性不存在或为空,则不执行后续操作 return; } newProps.replaceDatas[0].name = "点击查看流程"; }
},});