提交 | 用户 | 时间
|
3e359e
|
1 |
<template> |
H |
2 |
<div v-loading="loading" class="process-viewer-container"> |
|
3 |
<SimpleProcessViewer |
|
4 |
:flow-node="simpleModel" |
|
5 |
:tasks="tasks" |
|
6 |
:process-instance="processInstance" |
|
7 |
class="process-viewer" |
|
8 |
/> |
|
9 |
</div> |
|
10 |
</template> |
|
11 |
<script lang="ts" setup> |
|
12 |
import { propTypes } from '@/utils/propTypes' |
|
13 |
import { TaskStatusEnum } from '@/api/bpm/task' |
|
14 |
import { SimpleFlowNode, NodeType } from '@/components/SimpleProcessDesignerV2/src/consts' |
|
15 |
import { SimpleProcessViewer } from '@/components/SimpleProcessDesignerV2/src/' |
|
16 |
defineOptions({ name: 'BpmProcessInstanceSimpleViewer' }) |
|
17 |
|
|
18 |
const props = defineProps({ |
|
19 |
loading: propTypes.bool.def(false), // 是否加载中 |
|
20 |
modelView: propTypes.object, |
|
21 |
simpleJson: propTypes.string // Simple 模型结构数据 (json 格式) |
|
22 |
}) |
|
23 |
const simpleModel = ref() |
|
24 |
// 用户任务 |
|
25 |
const tasks = ref([]) |
|
26 |
// 流程实例 |
|
27 |
const processInstance = ref() |
|
28 |
|
|
29 |
/** 监控模型视图 包括任务列表、进行中的活动节点编号等 */ |
|
30 |
watch( |
|
31 |
() => props.modelView, |
|
32 |
async (newModelView) => { |
|
33 |
if (newModelView) { |
|
34 |
tasks.value = newModelView.tasks |
|
35 |
processInstance.value = newModelView.processInstance |
|
36 |
// 已经拒绝的活动节点编号集合,只包括 UserTask |
|
37 |
const rejectedTaskActivityIds: string[] = newModelView.rejectedTaskActivityIds |
|
38 |
// 进行中的活动节点编号集合, 只包括 UserTask |
|
39 |
const unfinishedTaskActivityIds: string[] = newModelView.unfinishedTaskActivityIds |
|
40 |
// 已经完成的活动节点编号集合, 包括 UserTask、Gateway 等 |
|
41 |
const finishedActivityIds: string[] = newModelView.finishedTaskActivityIds |
|
42 |
// 已经完成的连线节点编号集合,只包括 SequenceFlow |
|
43 |
const finishedSequenceFlowActivityIds: string[] = newModelView.finishedSequenceFlowActivityIds |
|
44 |
setSimpleModelNodeTaskStatus( |
|
45 |
newModelView.simpleModel, |
|
46 |
newModelView.processInstance.status, |
|
47 |
rejectedTaskActivityIds, |
|
48 |
unfinishedTaskActivityIds, |
|
49 |
finishedActivityIds, |
|
50 |
finishedSequenceFlowActivityIds |
|
51 |
) |
|
52 |
simpleModel.value = newModelView.simpleModel |
|
53 |
} |
|
54 |
} |
|
55 |
) |
|
56 |
/** 监控模型结构数据 */ |
|
57 |
watch( |
|
58 |
() => props.simpleJson, |
|
59 |
async (value) => { |
|
60 |
if (value) { |
|
61 |
simpleModel.value = JSON.parse(value) |
|
62 |
} |
|
63 |
} |
|
64 |
) |
|
65 |
const setSimpleModelNodeTaskStatus = ( |
|
66 |
simpleModel: SimpleFlowNode | undefined, |
|
67 |
processStatus: number, |
|
68 |
rejectedTaskActivityIds: string[], |
|
69 |
unfinishedTaskActivityIds: string[], |
|
70 |
finishedActivityIds: string[], |
|
71 |
finishedSequenceFlowActivityIds: string[] |
|
72 |
) => { |
|
73 |
if (!simpleModel) { |
|
74 |
return |
|
75 |
} |
|
76 |
// 结束节点 |
|
77 |
if (simpleModel.type === NodeType.END_EVENT_NODE) { |
|
78 |
if (finishedActivityIds.includes(simpleModel.id)) { |
|
79 |
simpleModel.activityStatus = processStatus |
|
80 |
} else { |
|
81 |
simpleModel.activityStatus = TaskStatusEnum.NOT_START |
|
82 |
} |
|
83 |
return |
|
84 |
} |
|
85 |
|
|
86 |
// 审批节点 |
|
87 |
if ( |
|
88 |
simpleModel.type === NodeType.START_USER_NODE || |
|
89 |
simpleModel.type === NodeType.USER_TASK_NODE |
|
90 |
) { |
|
91 |
simpleModel.activityStatus = TaskStatusEnum.NOT_START |
|
92 |
if (rejectedTaskActivityIds.includes(simpleModel.id)) { |
|
93 |
simpleModel.activityStatus = TaskStatusEnum.REJECT |
|
94 |
} else if (unfinishedTaskActivityIds.includes(simpleModel.id)) { |
|
95 |
simpleModel.activityStatus = TaskStatusEnum.RUNNING |
|
96 |
} else if (finishedActivityIds.includes(simpleModel.id)) { |
|
97 |
simpleModel.activityStatus = TaskStatusEnum.APPROVE |
|
98 |
} |
|
99 |
// TODO 是不是还缺一个 cancel 的状态 |
|
100 |
} |
|
101 |
|
|
102 |
// 抄送节点 |
|
103 |
if (simpleModel.type === NodeType.COPY_TASK_NODE) { |
|
104 |
// 抄送节点 只有通过和未执行状态 |
|
105 |
if (finishedActivityIds.includes(simpleModel.id)) { |
|
106 |
simpleModel.activityStatus = TaskStatusEnum.APPROVE |
|
107 |
} else { |
|
108 |
simpleModel.activityStatus = TaskStatusEnum.NOT_START |
|
109 |
} |
|
110 |
} |
|
111 |
// 条件节点 对应 SequenceFlow |
|
112 |
if (simpleModel.type === NodeType.CONDITION_NODE) { |
|
113 |
// 条件节点。只有通过和未执行状态 |
|
114 |
if (finishedSequenceFlowActivityIds.includes(simpleModel.id)) { |
|
115 |
simpleModel.activityStatus = TaskStatusEnum.APPROVE |
|
116 |
} else { |
|
117 |
simpleModel.activityStatus = TaskStatusEnum.NOT_START |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
// 网关节点 |
|
122 |
if ( |
|
123 |
simpleModel.type === NodeType.CONDITION_BRANCH_NODE || |
|
124 |
simpleModel.type === NodeType.PARALLEL_BRANCH_NODE || |
|
125 |
simpleModel.type === NodeType.INCLUSIVE_BRANCH_NODE |
|
126 |
) { |
|
127 |
// 网关节点。只有通过和未执行状态 |
|
128 |
if (finishedActivityIds.includes(simpleModel.id)) { |
|
129 |
simpleModel.activityStatus = TaskStatusEnum.APPROVE |
|
130 |
} else { |
|
131 |
simpleModel.activityStatus = TaskStatusEnum.NOT_START |
|
132 |
} |
|
133 |
simpleModel.conditionNodes?.forEach((node) => { |
|
134 |
setSimpleModelNodeTaskStatus( |
|
135 |
node, |
|
136 |
processStatus, |
|
137 |
rejectedTaskActivityIds, |
|
138 |
unfinishedTaskActivityIds, |
|
139 |
finishedActivityIds, |
|
140 |
finishedSequenceFlowActivityIds |
|
141 |
) |
|
142 |
}) |
|
143 |
} |
|
144 |
|
|
145 |
setSimpleModelNodeTaskStatus( |
|
146 |
simpleModel.childNode, |
|
147 |
processStatus, |
|
148 |
rejectedTaskActivityIds, |
|
149 |
unfinishedTaskActivityIds, |
|
150 |
finishedActivityIds, |
|
151 |
finishedSequenceFlowActivityIds |
|
152 |
) |
|
153 |
} |
|
154 |
</script> |
|
155 |
|
|
156 |
<style lang="scss" scoped> |
|
157 |
.process-viewer-container { |
|
158 |
height: 100%; |
|
159 |
width: 100%; |
|
160 |
|
|
161 |
:deep(.process-viewer) { |
|
162 |
height: 100% !important; |
|
163 |
min-height: 100%; |
|
164 |
width: 100%; |
|
165 |
overflow: auto; |
|
166 |
} |
|
167 |
} |
|
168 |
</style> |