/** * @description 流程处理 */ import { getTaskNode, getFollowedNode, getFlowKey } from '@/api/process' import { getNotice } from '@/api/flow' const state = () => ({ nodes: [], // 任务节点 checkedNodes: [], // 已跟踪的任务节点 flowKey: '', //流程key formKey: '', //当前表单key bpmTask: {}, //任务类 curNodeDef: {}, //当前节点对象 }) const getters = {} const mutations = { setTaskNode(state, nodes) { state.nodes = nodes }, setCheckedNodes(state, checkedNodes) { state.checkedNodes = checkedNodes }, setCheckedSplice(state, index) { state.checkedNodes.splice(index, 1) }, setCheckedPush(state, value) { state.checkedNodes.push(value) }, setFlowKey(state, value) { state.flowKey = value }, setTaskDetailData(state, data) { state.bpmTask = data.bpmTask state.curNodeDef = data.curNodeDef state.formKey = data.formKey }, } const actions = { setCheckedSplice({ commit }, index) { commit('setCheckedSplice', index) }, setCheckedPush({ commit }, nodeId) { commit('setCheckedPush', nodeId) }, getTaskNodeById({ commit, state }, data) { getTaskNode(data, (res) => { const nodes = res.bpmDefLayout.listLayout const nodesTemp = [] for (let i = 0; i < nodes.length; i++) { const { nodeType } = nodes[i] const types = [ 'START', 'END', 'INCLUSIVEGATEWAY', 'EXCLUSIVEGATEWAY', 'PARALLELGATEWAY', ] if (!types.includes(nodeType)) { nodesTemp.push({ ...nodes[i] }) } } commit('setTaskNode', nodesTemp) // 根据流程实例id获取已跟踪的节点 getFollowedNode(data, (res2) => { const followedNodeIds = res2.value || '' const checkedNodes = [] state.nodes.forEach((node) => { if (followedNodeIds.indexOf(node.nodeId) != -1) { checkedNodes.push(node.nodeId) } }) commit('setCheckedNodes', checkedNodes) }) }) }, //根据defId或者procInstId或者taskId获取flowKey getFlowKey({ commit }, query) { getFlowKey(query, (res) => { if (res.state) { commit('setFlowKey', res.value) } }) }, //获取任务明细根据taskId getTaskDetail({ commit }, data) { commit('setTaskDetailData', data) }, } export default { namespaced: true, state, getters, mutations, actions }