| | |
| | | |
| | | return data; |
| | | }, |
| | | convertToTreeData(data, parent,index,parentId) { |
| | | const tempJson = data.find(f => |
| | | f.index_no === index |
| | | ) |
| | | parent.children = { |
| | | "id": tempJson.id, |
| | | "parentId": parentId, |
| | | "name": "审批人", |
| | | "type": "APPROVAL", |
| | | "children":{},//必须要 不然选中的值无法传递 |
| | | "props": |
| | | { |
| | | "assignedType": "ASSIGN_USER", |
| | | "nobody": { |
| | | "handler": "TO_PASS", |
| | | "assignedUser": [] |
| | | }, |
| | | "refuse": { |
| | | "type": "TO_END", |
| | | "target": "" |
| | | }, |
| | | "assignedUser": [{"id": tempJson.board_id||tempJson.rule_code, "name": tempJson.name,"type":tempJson.board_id!=null?"group":"staff"}], |
| | | "approvalGroup":tempJson.board_id!=null?{"id":tempJson.board_id,"name":tempJson.name}:"", |
| | | "staffGroup":tempJson.board_id!=null?"":{"id":tempJson.rule_code,"name":tempJson.name}, |
| | | } |
| | | } |
| | | //节点数组的大小 大于当前循环的 说明还有子项 继续循环 |
| | | if (data.length >index) { |
| | | let getChildren = this.convertToTreeData(data, parent.children, index+1,parent.children.id) |
| | | parent.children=getChildren |
| | | } |
| | | return parent; |
| | | }, |
| | | //审批流树形结构转换为json |
| | | dataTree(data, index, parentId) { |
| | | let result = [];//存放结果 |
| | | let names = [];//存放审批人 |
| | | let ruleCode = [];//架构组 |
| | | data.props.assignedUser.forEach(org => names.push(org.name)); |
| | | let ids = [] |
| | | data.props.assignedUser.forEach(org => ids.push(org.id)); |
| | | // 修改的时候 根据选中类型是架构还是审批组 渲染数据 |
| | | if(data.props.assignedUser[0].type==='staff'){ |
| | | ids = []; |
| | | data.props.assignedUser.forEach(org => ruleCode.push(org.id)); |
| | | }else{ |
| | | //判断选中的数据类型是架构还是审批组 如果是架构 将审批组清空 board_id置为空 |
| | | if (data.props.staffGroup!=undefined&& Object.keys(data.props.staffGroup).length!==0) { |
| | | ids = []; |
| | | data.props.assignedUser.forEach(org => ruleCode.push(org.id)); |
| | | } |
| | | } |
| | | |
| | | //插入流程数组项 |
| | | result.push( |
| | | { |
| | | name: String(names).replaceAll(',', '、'), |
| | | id: data.id||'', |
| | | parent_id: parentId||'', |
| | | index_no: index, |
| | | board_id: ids.length > 0 ? String(ids).replaceAll(',', '、') : null, |
| | | rule_code: ruleCode.length > 0 ? String(ruleCode).replaceAll(',', '、') : null |
| | | } |
| | | ) // 只取当前节点的信息,不包括 children |
| | | //如果下面还有子项 继续往下读数据 |
| | | if (data.children!==undefined&&Object.keys(data.children).length !== 0) { |
| | | let getChildren = this.dataTree(data.children, index + 1, parentId) |
| | | result = result.concat(getChildren) |
| | | } |
| | | |
| | | return result |
| | | }, |
| | | |
| | | }; |
| | |
| | | |
| | | }, |
| | | methods: { |
| | | convertToTreeData(data, parent,index,parentId) { |
| | | //index从1开始 从index_no=1的节点开始往下一个个找 |
| | | const tempJson = data.find(f => |
| | | f.index_no === index |
| | | ) |
| | | //解析子审批节点 |
| | | parent.children = { |
| | | "id": tempJson.id, |
| | | "parentId": parentId, |
| | | "name": "审批人", |
| | | "type": "APPROVAL", |
| | | "children":{},//必须要 不然选中的值无法传递 |
| | | "props": |
| | | { |
| | | "assignedType": "ASSIGN_USER", |
| | | "nobody": { |
| | | "handler": "TO_PASS", |
| | | "assignedUser": [] |
| | | }, |
| | | "refuse": { |
| | | "type": "TO_END", |
| | | "target": "" |
| | | }, |
| | | "assignedUser": [{"id": tempJson.board_id||tempJson.rule_code, "name": tempJson.name,"type":tempJson.board_id!=null?"group":"staff"}], |
| | | "approvalGroup":tempJson.board_id!=null?{"id":tempJson.board_id,"name":tempJson.name}:"", |
| | | "staffGroup":tempJson.board_id!=null?"":{"id":tempJson.rule_code,"name":tempJson.name}, |
| | | } |
| | | } |
| | | //如果传过来的审批节点数组大于当前索引 说明下面还有 |
| | | if (data.length >index) { |
| | | let getChildren = this.convertToTreeData(data, parent.children, index+1,parent.children.id) |
| | | parent.children=getChildren |
| | | } |
| | | return parent; |
| | | }, |
| | | |
| | | loadFormInfo(formId) { |
| | | let param = {"id": formId} |
| | | |
| | |
| | | let form = rsp.data.data; |
| | | form.logo = "" |
| | | form.formItems = [] |
| | | form.process =this.convertToTreeData(form.steps, { |
| | | form.process =this.$Utils.convertToTreeData(form.steps, { |
| | | "id": form.id, "parentId": null, |
| | | "type": "ROOT", |
| | | "name": "发起人", |
| | |
| | | publishProcess() { |
| | | this.validateDesign() |
| | | }, |
| | | //审批流树形结构转换为json |
| | | dataTree(data, index, parentId) { |
| | | let result = [];//存放结果 |
| | | let names = [];//存放审批人 |
| | | let ruleCode = [];//架构组 |
| | | data.props.assignedUser.forEach(org => names.push(org.name)); |
| | | let ids = [] |
| | | data.props.assignedUser.forEach(org => ids.push(org.id)); |
| | | // 修改的时候 根据选中类型是架构还是审批组 渲染数据 |
| | | if(data.props.assignedUser[0].type==='staff'){ |
| | | ids = []; |
| | | data.props.assignedUser.forEach(org => ruleCode.push(org.id)); |
| | | }else{ |
| | | //判断选中的数据类型是架构还是审批组 如果是架构 将审批组清空 board_id置为空 |
| | | if (data.props.staffGroup!=undefined&& Object.keys(data.props.staffGroup).length!==0) { |
| | | ids = []; |
| | | data.props.assignedUser.forEach(org => ruleCode.push(org.id)); |
| | | } |
| | | } |
| | | |
| | | //插入流程数组项 |
| | | result.push( |
| | | { |
| | | name: String(names).replaceAll(',', '、'), |
| | | id: data.id||'', |
| | | parent_id: parentId||'', |
| | | index_no: index, |
| | | board_id: ids.length > 0 ? String(ids).replaceAll(',', '、') : null, |
| | | rule_code: ruleCode.length > 0 ? String(ruleCode).replaceAll(',', '、') : null |
| | | } |
| | | ) // 只取当前节点的信息,不包括 children |
| | | //如果下面还有子项 继续往下读数据 |
| | | if (data.children!==undefined&&Object.keys(data.children).length !== 0) { |
| | | let getChildren = this.dataTree(data.children, index + 1, parentId) |
| | | result = result.concat(getChildren) |
| | | } |
| | | |
| | | return result |
| | | }, |
| | | doPublish() { |
| | | this.$confirm('确认发布后流程立即生效,是否继续?', '提示', { |
| | | confirmButtonText: '发布', |
| | |
| | | data.id = processNew.id||'' |
| | | let i = 1; |
| | | //转数据结构 |
| | | data.steps = this.dataTree(processNew.children, i, processNew.id); |
| | | data.steps = this.$Utils.dataTree(processNew.children, i, processNew.id); |
| | | let template = {data} |
| | | createFlow(template).then(rsp => { |
| | | this.$message.success("创建流程成功") |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | convertToTreeData(data, parent,index,parentId) { |
| | | const tempJson = data.find(f => |
| | | f.index_no === index |
| | | ) |
| | | this.$store.state.noTakeList .push(tempJson.id) |
| | | parent.children = { |
| | | "id": tempJson.id, |
| | | "parentId": parentId, |
| | | "name": "审批人", |
| | | "type": "APPROVAL", |
| | | "props": |
| | | { |
| | | "assignedType": "ASSIGN_USER", |
| | | "nobody": { |
| | | "handler": "TO_PASS", |
| | | "assignedUser": [] |
| | | }, |
| | | "refuse": { |
| | | "type": "TO_END", |
| | | "target": "" |
| | | }, |
| | | "assignedUser": [{"id": tempJson.board_id||tempJson.rule_code, "name": tempJson.name,"type":tempJson.board_id!=null?"group":"staff"}], |
| | | "approvalGroup":tempJson.board_id!=null?{"id":tempJson.board_id,"name":tempJson.name}:"", |
| | | "staffGroup":tempJson.board_id!=null?"":{"id":tempJson.rule_code,"name":tempJson.name}, |
| | | } |
| | | } |
| | | //节点数组的大小 大于当前循环的 说明还有子项 继续循环 |
| | | if (data.length >index) { |
| | | let getChildren = this.convertToTreeData(data, parent.children, index+1,parent.children.id) |
| | | parent.children=getChildren |
| | | } |
| | | return parent; |
| | | }, |
| | | |
| | | getProcessInfo() { |
| | | this.loading = true; |
| | | let param = {"id": this.processInstanceId} |
| | |
| | | getFlowDetail(param){ |
| | | getFlowDetail(param).then(rsp => { |
| | | let form = rsp.data.data; |
| | | form.process =this.convertToTreeData(form.steps, { |
| | | form.process =this.$Utils.convertToTreeData(form.steps, { |
| | | "id": form.id, "parentId": null, |
| | | "type": "ROOT", |
| | | "name": "发起人", |