提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<div class="panel-tab__content"> |
|
3 |
<el-form label-width="90px"> |
|
4 |
<el-form-item label="快捷配置"> |
|
5 |
<el-button size="small" @click="changeConfig('依次审批')">依次审批</el-button> |
|
6 |
<el-button size="small" @click="changeConfig('会签')">会签</el-button> |
|
7 |
<el-button size="small" @click="changeConfig('或签')">或签</el-button> |
|
8 |
</el-form-item> |
|
9 |
<el-form-item label="会签类型"> |
|
10 |
<el-select v-model="loopCharacteristics" @change="changeLoopCharacteristicsType"> |
|
11 |
<el-option label="并行多重事件" value="ParallelMultiInstance" /> |
|
12 |
<el-option label="时序多重事件" value="SequentialMultiInstance" /> |
|
13 |
<el-option label="无" value="Null" /> |
|
14 |
</el-select> |
|
15 |
</el-form-item> |
|
16 |
<template |
|
17 |
v-if=" |
|
18 |
loopCharacteristics === 'ParallelMultiInstance' || |
|
19 |
loopCharacteristics === 'SequentialMultiInstance' |
|
20 |
" |
|
21 |
> |
|
22 |
<el-form-item label="循环数量" key="loopCardinality"> |
|
23 |
<el-input |
|
24 |
v-model="loopInstanceForm.loopCardinality" |
|
25 |
clearable |
|
26 |
@change="updateLoopCardinality" |
|
27 |
/> |
|
28 |
</el-form-item> |
|
29 |
<el-form-item label="集合" key="collection" v-show="false"> |
|
30 |
<el-input v-model="loopInstanceForm.collection" clearable @change="updateLoopBase" /> |
|
31 |
</el-form-item> |
|
32 |
<!-- add by 芋艿:由于「元素变量」暂时用不到,所以这里 display 为 none --> |
|
33 |
<el-form-item label="元素变量" key="elementVariable" style="display: none"> |
|
34 |
<el-input v-model="loopInstanceForm.elementVariable" clearable @change="updateLoopBase" /> |
|
35 |
</el-form-item> |
|
36 |
<el-form-item label="完成条件" key="completionCondition"> |
|
37 |
<el-input |
|
38 |
v-model="loopInstanceForm.completionCondition" |
|
39 |
clearable |
|
40 |
@change="updateLoopCondition" |
|
41 |
/> |
|
42 |
</el-form-item> |
|
43 |
<!-- add by 芋艿:由于「异步状态」暂时用不到,所以这里 display 为 none --> |
|
44 |
<el-form-item label="异步状态" key="async" style="display: none"> |
|
45 |
<el-checkbox |
|
46 |
v-model="loopInstanceForm.asyncBefore" |
|
47 |
label="异步前" |
3e359e
|
48 |
value="异步前" |
820397
|
49 |
@change="updateLoopAsync('asyncBefore')" |
H |
50 |
/> |
|
51 |
<el-checkbox |
|
52 |
v-model="loopInstanceForm.asyncAfter" |
|
53 |
label="异步后" |
3e359e
|
54 |
value="异步后" |
820397
|
55 |
@change="updateLoopAsync('asyncAfter')" |
H |
56 |
/> |
|
57 |
<el-checkbox |
|
58 |
v-model="loopInstanceForm.exclusive" |
|
59 |
v-if="loopInstanceForm.asyncAfter || loopInstanceForm.asyncBefore" |
|
60 |
label="排除" |
3e359e
|
61 |
value="排除" |
820397
|
62 |
@change="updateLoopAsync('exclusive')" |
H |
63 |
/> |
|
64 |
</el-form-item> |
|
65 |
<el-form-item |
|
66 |
label="重试周期" |
|
67 |
prop="timeCycle" |
|
68 |
v-if="loopInstanceForm.asyncAfter || loopInstanceForm.asyncBefore" |
|
69 |
key="timeCycle" |
|
70 |
> |
|
71 |
<el-input v-model="loopInstanceForm.timeCycle" clearable @change="updateLoopTimeCycle" /> |
|
72 |
</el-form-item> |
|
73 |
</template> |
|
74 |
</el-form> |
|
75 |
</div> |
|
76 |
</template> |
|
77 |
|
|
78 |
<script lang="ts" setup> |
|
79 |
defineOptions({ name: 'ElementMultiInstance' }) |
|
80 |
|
|
81 |
const props = defineProps({ |
|
82 |
businessObject: Object, |
|
83 |
type: String |
|
84 |
}) |
|
85 |
const prefix = inject('prefix') |
|
86 |
const loopCharacteristics = ref('') |
|
87 |
//默认配置,用来覆盖原始不存在的选项,避免报错 |
|
88 |
const defaultLoopInstanceForm = ref({ |
|
89 |
completionCondition: '', |
|
90 |
loopCardinality: '', |
|
91 |
extensionElements: [], |
|
92 |
asyncAfter: false, |
|
93 |
asyncBefore: false, |
|
94 |
exclusive: false |
|
95 |
}) |
|
96 |
const loopInstanceForm = ref<any>({}) |
|
97 |
const bpmnElement = ref(null) |
|
98 |
const multiLoopInstance = ref(null) |
|
99 |
const bpmnInstances = () => (window as any)?.bpmnInstances |
|
100 |
|
|
101 |
const getElementLoop = (businessObject) => { |
|
102 |
if (!businessObject.loopCharacteristics) { |
|
103 |
loopCharacteristics.value = 'Null' |
|
104 |
loopInstanceForm.value = {} |
|
105 |
return |
|
106 |
} |
|
107 |
if (businessObject.loopCharacteristics.$type === 'bpmn:StandardLoopCharacteristics') { |
|
108 |
loopCharacteristics.value = 'StandardLoop' |
|
109 |
loopInstanceForm.value = {} |
|
110 |
return |
|
111 |
} |
|
112 |
if (businessObject.loopCharacteristics.isSequential) { |
|
113 |
loopCharacteristics.value = 'SequentialMultiInstance' |
|
114 |
} else { |
|
115 |
loopCharacteristics.value = 'ParallelMultiInstance' |
|
116 |
} |
|
117 |
// 合并配置 |
|
118 |
loopInstanceForm.value = { |
|
119 |
...defaultLoopInstanceForm.value, |
|
120 |
...businessObject.loopCharacteristics, |
|
121 |
completionCondition: businessObject.loopCharacteristics?.completionCondition?.body ?? '', |
|
122 |
loopCardinality: businessObject.loopCharacteristics?.loopCardinality?.body ?? '' |
|
123 |
} |
|
124 |
// 保留当前元素 businessObject 上的 loopCharacteristics 实例 |
|
125 |
multiLoopInstance.value = bpmnInstances().bpmnElement.businessObject.loopCharacteristics |
|
126 |
// 更新表单 |
|
127 |
if ( |
|
128 |
businessObject.loopCharacteristics.extensionElements && |
|
129 |
businessObject.loopCharacteristics.extensionElements.values && |
|
130 |
businessObject.loopCharacteristics.extensionElements.values.length |
|
131 |
) { |
|
132 |
loopInstanceForm.value['timeCycle'] = |
|
133 |
businessObject.loopCharacteristics.extensionElements.values[0].body |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
const changeLoopCharacteristicsType = (type) => { |
|
138 |
// this.loopInstanceForm = { ...this.defaultLoopInstanceForm }; // 切换类型取消原表单配置 |
|
139 |
// 取消多实例配置 |
|
140 |
if (type === 'Null') { |
|
141 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
142 |
loopCharacteristics: null |
|
143 |
}) |
|
144 |
return |
|
145 |
} |
|
146 |
// 配置循环 |
|
147 |
if (type === 'StandardLoop') { |
|
148 |
const loopCharacteristicsObject = bpmnInstances().moddle.create( |
|
149 |
'bpmn:StandardLoopCharacteristics' |
|
150 |
) |
|
151 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
152 |
loopCharacteristics: loopCharacteristicsObject |
|
153 |
}) |
|
154 |
multiLoopInstance.value = null |
|
155 |
return |
|
156 |
} |
|
157 |
// 时序 |
|
158 |
if (type === 'SequentialMultiInstance') { |
|
159 |
multiLoopInstance.value = bpmnInstances().moddle.create( |
|
160 |
'bpmn:MultiInstanceLoopCharacteristics', |
|
161 |
{ isSequential: true } |
|
162 |
) |
|
163 |
} else { |
|
164 |
multiLoopInstance.value = bpmnInstances().moddle.create( |
|
165 |
'bpmn:MultiInstanceLoopCharacteristics', |
|
166 |
{ collection: '${coll_userList}' } |
|
167 |
) |
|
168 |
} |
|
169 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
170 |
loopCharacteristics: toRaw(multiLoopInstance.value) |
|
171 |
}) |
|
172 |
} |
|
173 |
|
|
174 |
// 循环基数 |
|
175 |
const updateLoopCardinality = (cardinality) => { |
|
176 |
let loopCardinality = null |
|
177 |
if (cardinality && cardinality.length) { |
|
178 |
loopCardinality = bpmnInstances().moddle.create('bpmn:FormalExpression', { |
|
179 |
body: cardinality |
|
180 |
}) |
|
181 |
} |
|
182 |
bpmnInstances().modeling.updateModdleProperties( |
|
183 |
toRaw(bpmnElement.value), |
|
184 |
multiLoopInstance.value, |
|
185 |
{ |
|
186 |
loopCardinality |
|
187 |
} |
|
188 |
) |
|
189 |
} |
|
190 |
|
|
191 |
// 完成条件 |
|
192 |
const updateLoopCondition = (condition) => { |
|
193 |
let completionCondition = null |
|
194 |
if (condition && condition.length) { |
|
195 |
completionCondition = bpmnInstances().moddle.create('bpmn:FormalExpression', { |
|
196 |
body: condition |
|
197 |
}) |
|
198 |
} |
|
199 |
bpmnInstances().modeling.updateModdleProperties( |
|
200 |
toRaw(bpmnElement.value), |
|
201 |
multiLoopInstance.value, |
|
202 |
{ |
|
203 |
completionCondition |
|
204 |
} |
|
205 |
) |
|
206 |
} |
|
207 |
|
|
208 |
// 重试周期 |
|
209 |
const updateLoopTimeCycle = (timeCycle) => { |
|
210 |
const extensionElements = bpmnInstances().moddle.create('bpmn:ExtensionElements', { |
|
211 |
values: [ |
|
212 |
bpmnInstances().moddle.create(`${prefix}:FailedJobRetryTimeCycle`, { |
|
213 |
body: timeCycle |
|
214 |
}) |
|
215 |
] |
|
216 |
}) |
|
217 |
bpmnInstances().modeling.updateModdleProperties( |
|
218 |
toRaw(bpmnElement.value), |
|
219 |
multiLoopInstance.value, |
|
220 |
{ |
|
221 |
extensionElements |
|
222 |
} |
|
223 |
) |
|
224 |
} |
|
225 |
|
|
226 |
// 直接更新的基础信息 |
|
227 |
const updateLoopBase = () => { |
|
228 |
bpmnInstances().modeling.updateModdleProperties( |
|
229 |
toRaw(bpmnElement.value), |
|
230 |
multiLoopInstance.value, |
|
231 |
{ |
|
232 |
collection: loopInstanceForm.value.collection || null, |
|
233 |
elementVariable: loopInstanceForm.value.elementVariable || null |
|
234 |
} |
|
235 |
) |
|
236 |
} |
|
237 |
|
|
238 |
// 各异步状态 |
|
239 |
const updateLoopAsync = (key) => { |
|
240 |
const { asyncBefore, asyncAfter } = loopInstanceForm.value |
|
241 |
let asyncAttr = Object.create(null) |
|
242 |
if (!asyncBefore && !asyncAfter) { |
|
243 |
// this.$set(this.loopInstanceForm, "exclusive", false); |
|
244 |
loopInstanceForm.value['exclusive'] = false |
|
245 |
asyncAttr = { asyncBefore: false, asyncAfter: false, exclusive: false, extensionElements: null } |
|
246 |
} else { |
|
247 |
asyncAttr[key] = loopInstanceForm.value[key] |
|
248 |
} |
|
249 |
bpmnInstances().modeling.updateModdleProperties( |
|
250 |
toRaw(bpmnElement.value), |
|
251 |
multiLoopInstance.value, |
|
252 |
asyncAttr |
|
253 |
) |
|
254 |
} |
|
255 |
|
|
256 |
const changeConfig = (config) => { |
|
257 |
if (config === '依次审批') { |
|
258 |
changeLoopCharacteristicsType('SequentialMultiInstance') |
|
259 |
updateLoopCardinality('1') |
|
260 |
updateLoopCondition('${ nrOfCompletedInstances >= nrOfInstances }') |
|
261 |
} else if (config === '会签') { |
|
262 |
changeLoopCharacteristicsType('ParallelMultiInstance') |
|
263 |
updateLoopCondition('${ nrOfCompletedInstances >= nrOfInstances }') |
|
264 |
} else if (config === '或签') { |
|
265 |
changeLoopCharacteristicsType('ParallelMultiInstance') |
|
266 |
updateLoopCondition('${ nrOfCompletedInstances > 0 }') |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 |
onBeforeUnmount(() => { |
|
271 |
multiLoopInstance.value = null |
|
272 |
bpmnElement.value = null |
|
273 |
}) |
|
274 |
|
|
275 |
watch( |
|
276 |
() => props.businessObject, |
|
277 |
(val) => { |
|
278 |
bpmnElement.value = bpmnInstances().bpmnElement |
|
279 |
getElementLoop(val) |
|
280 |
}, |
|
281 |
{ immediate: true } |
|
282 |
) |
|
283 |
</script> |