process.js
2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @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 }