| | |
| | | <div class="layout-body"> |
| | | <process-design ref="processDesign" v-show="activeSelect === 'processDesign'"/> |
| | | </div> |
| | | <w-dialog :showFooter="false" v-model="validVisible" title="设置项检查"> |
| | | <flow-dialog :showFooter="false" v-model="validVisible" title="设置项检查"> |
| | | <el-result :icon="validIcon" :title="errTitle" :subTitle="validResult.desc"> |
| | | <i slot="icon" style="font-size: 30px" v-if="!validResult.finished" class="el-icon-loading"></i> |
| | | <div slot="subTitle" class="err-info" v-if="validResult.errs.length > 0"> |
| | |
| | | </el-form> |
| | | </template> |
| | | </el-result> |
| | | </w-dialog> |
| | | </flow-dialog> |
| | | </el-container> |
| | | |
| | | </template> |
| | | |
| | | <script> |
| | | import LayoutHeader from './LayoutHeader' |
| | | import {getFormDetail, createForm, updateFormDetail, createFlow, getFlowDetail} from '@/api/design' |
| | | import {createFlow, getFlowDetail} from '@/api/design' |
| | | |
| | | import ProcessDesign from '@/views/admin/layout/ProcessDesign' |
| | | |
| | |
| | | |
| | | }, |
| | | methods: { |
| | | convertToTreeData(data, parent,index,parentId) { |
| | | //index从1开始 从index_no=1的节点开始往下一个个找 |
| | | const tempJson = data.find(f => |
| | | f.index_no === index |
| | | ) |
| | | console.log("tempJson",tempJson); |
| | | //解析子审批节点 |
| | | 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; |
| | | }, |
| | | |
| | | loadFormInfo(formId) { |
| | | let param = {"id": formId} |
| | | |
| | | //获取流程详情 |
| | | getFlowDetail(param).then(rsp => { |
| | | let form = rsp.data.data; |
| | | console.log("getFlowDetail-form", form) |
| | | 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": "发起人", |
| | |
| | | form.templateName = form.name |
| | | form.groupId = null; |
| | | |
| | | console.log("输出转换后的form,",form) |
| | | |
| | | this.$store.commit('loadForm', form) |
| | | }).catch(err => { |
| | | this.$message.error(err) |
| | |
| | | }) |
| | | }, |
| | | validateDesign() { |
| | | console.log('000') |
| | | this.validVisible = true |
| | | this.validStep = 0 |
| | | this.showValiding() |
| | |
| | | publishProcess() { |
| | | this.validateDesign() |
| | | }, |
| | | //审批流树形结构转换为json |
| | | dataTree(data, index, parentId) { |
| | | let result = []; |
| | | let names = []; |
| | | let ruleCode = []; |
| | | console.log("data》》》",data) |
| | | 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 |
| | | console.log("result>>>",result) |
| | | //如果下面还有子项 继续往下读数据 |
| | | 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('确认发布后流程立即生效,是否继续?', '提示', { |
| | |
| | | type: 'warning' |
| | | }).then(() => { |
| | | let processNew = JSON.parse(JSON.stringify(this.setup.process)); |
| | | console.log("processNew", processNew) |
| | | //判断条件分支 |
| | | this.conditionRecursion(processNew); |
| | | let data = {}; |
| | | data.name = this.form.name; |
| | | data.id = processNew.id||'' |
| | | var i = 1; |
| | | 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} |
| | | console.log("新数组结构-template", template); |
| | | createFlow(template).then(rsp => { |
| | | this.$message.success("创建流程成功") |
| | | this.$router.push("/formsPanel") |