提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<div class="panel-tab__content"> |
9259c2
|
3 |
<el-radio-group v-model="approveMethod" @change="onApproveMethodChange"> |
H |
4 |
<div class="flex-col"> |
|
5 |
<div v-for="(item, index) in APPROVE_METHODS" :key="index"> |
|
6 |
<el-radio :value="item.value" :label="item.value"> |
|
7 |
{{ item.label }} |
|
8 |
</el-radio> |
|
9 |
<el-form-item prop="approveRatio"> |
|
10 |
<el-input-number |
|
11 |
v-model="approveRatio" |
|
12 |
:min="10" |
|
13 |
:max="100" |
|
14 |
:step="10" |
|
15 |
size="small" |
|
16 |
v-if=" |
|
17 |
item.value === ApproveMethodType.APPROVE_BY_RATIO && |
|
18 |
approveMethod === ApproveMethodType.APPROVE_BY_RATIO |
|
19 |
" |
|
20 |
@change="onApproveRatioChange" |
|
21 |
/> |
|
22 |
</el-form-item> |
|
23 |
</div> |
|
24 |
</div> |
|
25 |
</el-radio-group> |
|
26 |
<!-- 与Simple设计器配置合并,保留以前的代码 --> |
|
27 |
<el-form label-width="90px" style="display: none"> |
820397
|
28 |
<el-form-item label="快捷配置"> |
H |
29 |
<el-button size="small" @click="changeConfig('依次审批')">依次审批</el-button> |
|
30 |
<el-button size="small" @click="changeConfig('会签')">会签</el-button> |
|
31 |
<el-button size="small" @click="changeConfig('或签')">或签</el-button> |
|
32 |
</el-form-item> |
|
33 |
<el-form-item label="会签类型"> |
|
34 |
<el-select v-model="loopCharacteristics" @change="changeLoopCharacteristicsType"> |
|
35 |
<el-option label="并行多重事件" value="ParallelMultiInstance" /> |
|
36 |
<el-option label="时序多重事件" value="SequentialMultiInstance" /> |
|
37 |
<el-option label="无" value="Null" /> |
|
38 |
</el-select> |
|
39 |
</el-form-item> |
|
40 |
<template |
|
41 |
v-if=" |
|
42 |
loopCharacteristics === 'ParallelMultiInstance' || |
|
43 |
loopCharacteristics === 'SequentialMultiInstance' |
|
44 |
" |
|
45 |
> |
|
46 |
<el-form-item label="循环数量" key="loopCardinality"> |
|
47 |
<el-input |
|
48 |
v-model="loopInstanceForm.loopCardinality" |
|
49 |
clearable |
|
50 |
@change="updateLoopCardinality" |
|
51 |
/> |
|
52 |
</el-form-item> |
|
53 |
<el-form-item label="集合" key="collection" v-show="false"> |
|
54 |
<el-input v-model="loopInstanceForm.collection" clearable @change="updateLoopBase" /> |
|
55 |
</el-form-item> |
|
56 |
<!-- add by 芋艿:由于「元素变量」暂时用不到,所以这里 display 为 none --> |
|
57 |
<el-form-item label="元素变量" key="elementVariable" style="display: none"> |
|
58 |
<el-input v-model="loopInstanceForm.elementVariable" clearable @change="updateLoopBase" /> |
|
59 |
</el-form-item> |
|
60 |
<el-form-item label="完成条件" key="completionCondition"> |
|
61 |
<el-input |
|
62 |
v-model="loopInstanceForm.completionCondition" |
|
63 |
clearable |
|
64 |
@change="updateLoopCondition" |
|
65 |
/> |
|
66 |
</el-form-item> |
|
67 |
<!-- add by 芋艿:由于「异步状态」暂时用不到,所以这里 display 为 none --> |
|
68 |
<el-form-item label="异步状态" key="async" style="display: none"> |
|
69 |
<el-checkbox |
|
70 |
v-model="loopInstanceForm.asyncBefore" |
|
71 |
label="异步前" |
3e359e
|
72 |
value="异步前" |
820397
|
73 |
@change="updateLoopAsync('asyncBefore')" |
H |
74 |
/> |
|
75 |
<el-checkbox |
|
76 |
v-model="loopInstanceForm.asyncAfter" |
|
77 |
label="异步后" |
3e359e
|
78 |
value="异步后" |
820397
|
79 |
@change="updateLoopAsync('asyncAfter')" |
H |
80 |
/> |
|
81 |
<el-checkbox |
|
82 |
v-model="loopInstanceForm.exclusive" |
|
83 |
v-if="loopInstanceForm.asyncAfter || loopInstanceForm.asyncBefore" |
|
84 |
label="排除" |
3e359e
|
85 |
value="排除" |
820397
|
86 |
@change="updateLoopAsync('exclusive')" |
H |
87 |
/> |
|
88 |
</el-form-item> |
|
89 |
<el-form-item |
|
90 |
label="重试周期" |
|
91 |
prop="timeCycle" |
|
92 |
v-if="loopInstanceForm.asyncAfter || loopInstanceForm.asyncBefore" |
|
93 |
key="timeCycle" |
|
94 |
> |
|
95 |
<el-input v-model="loopInstanceForm.timeCycle" clearable @change="updateLoopTimeCycle" /> |
|
96 |
</el-form-item> |
|
97 |
</template> |
|
98 |
</el-form> |
|
99 |
</div> |
|
100 |
</template> |
|
101 |
|
|
102 |
<script lang="ts" setup> |
9259c2
|
103 |
import { ApproveMethodType, APPROVE_METHODS } from '@/components/SimpleProcessDesignerV2/src/consts' |
H |
104 |
|
820397
|
105 |
defineOptions({ name: 'ElementMultiInstance' }) |
H |
106 |
|
|
107 |
const props = defineProps({ |
|
108 |
businessObject: Object, |
9259c2
|
109 |
type: String, |
H |
110 |
id: String |
820397
|
111 |
}) |
H |
112 |
const prefix = inject('prefix') |
|
113 |
const loopCharacteristics = ref('') |
|
114 |
//默认配置,用来覆盖原始不存在的选项,避免报错 |
|
115 |
const defaultLoopInstanceForm = ref({ |
|
116 |
completionCondition: '', |
|
117 |
loopCardinality: '', |
|
118 |
extensionElements: [], |
|
119 |
asyncAfter: false, |
|
120 |
asyncBefore: false, |
|
121 |
exclusive: false |
|
122 |
}) |
|
123 |
const loopInstanceForm = ref<any>({}) |
|
124 |
const bpmnElement = ref(null) |
|
125 |
const multiLoopInstance = ref(null) |
|
126 |
const bpmnInstances = () => (window as any)?.bpmnInstances |
|
127 |
|
|
128 |
const getElementLoop = (businessObject) => { |
|
129 |
if (!businessObject.loopCharacteristics) { |
|
130 |
loopCharacteristics.value = 'Null' |
|
131 |
loopInstanceForm.value = {} |
|
132 |
return |
|
133 |
} |
|
134 |
if (businessObject.loopCharacteristics.$type === 'bpmn:StandardLoopCharacteristics') { |
|
135 |
loopCharacteristics.value = 'StandardLoop' |
|
136 |
loopInstanceForm.value = {} |
|
137 |
return |
|
138 |
} |
|
139 |
if (businessObject.loopCharacteristics.isSequential) { |
|
140 |
loopCharacteristics.value = 'SequentialMultiInstance' |
|
141 |
} else { |
|
142 |
loopCharacteristics.value = 'ParallelMultiInstance' |
|
143 |
} |
|
144 |
// 合并配置 |
|
145 |
loopInstanceForm.value = { |
|
146 |
...defaultLoopInstanceForm.value, |
|
147 |
...businessObject.loopCharacteristics, |
|
148 |
completionCondition: businessObject.loopCharacteristics?.completionCondition?.body ?? '', |
|
149 |
loopCardinality: businessObject.loopCharacteristics?.loopCardinality?.body ?? '' |
|
150 |
} |
|
151 |
// 保留当前元素 businessObject 上的 loopCharacteristics 实例 |
|
152 |
multiLoopInstance.value = bpmnInstances().bpmnElement.businessObject.loopCharacteristics |
|
153 |
// 更新表单 |
|
154 |
if ( |
|
155 |
businessObject.loopCharacteristics.extensionElements && |
|
156 |
businessObject.loopCharacteristics.extensionElements.values && |
|
157 |
businessObject.loopCharacteristics.extensionElements.values.length |
|
158 |
) { |
|
159 |
loopInstanceForm.value['timeCycle'] = |
|
160 |
businessObject.loopCharacteristics.extensionElements.values[0].body |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
const changeLoopCharacteristicsType = (type) => { |
|
165 |
// this.loopInstanceForm = { ...this.defaultLoopInstanceForm }; // 切换类型取消原表单配置 |
|
166 |
// 取消多实例配置 |
|
167 |
if (type === 'Null') { |
|
168 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
169 |
loopCharacteristics: null |
|
170 |
}) |
|
171 |
return |
|
172 |
} |
|
173 |
// 配置循环 |
|
174 |
if (type === 'StandardLoop') { |
|
175 |
const loopCharacteristicsObject = bpmnInstances().moddle.create( |
|
176 |
'bpmn:StandardLoopCharacteristics' |
|
177 |
) |
|
178 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
179 |
loopCharacteristics: loopCharacteristicsObject |
|
180 |
}) |
|
181 |
multiLoopInstance.value = null |
|
182 |
return |
|
183 |
} |
|
184 |
// 时序 |
|
185 |
if (type === 'SequentialMultiInstance') { |
|
186 |
multiLoopInstance.value = bpmnInstances().moddle.create( |
|
187 |
'bpmn:MultiInstanceLoopCharacteristics', |
|
188 |
{ isSequential: true } |
|
189 |
) |
|
190 |
} else { |
|
191 |
multiLoopInstance.value = bpmnInstances().moddle.create( |
|
192 |
'bpmn:MultiInstanceLoopCharacteristics', |
|
193 |
{ collection: '${coll_userList}' } |
|
194 |
) |
|
195 |
} |
|
196 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
197 |
loopCharacteristics: toRaw(multiLoopInstance.value) |
|
198 |
}) |
|
199 |
} |
|
200 |
|
|
201 |
// 循环基数 |
|
202 |
const updateLoopCardinality = (cardinality) => { |
|
203 |
let loopCardinality = null |
|
204 |
if (cardinality && cardinality.length) { |
|
205 |
loopCardinality = bpmnInstances().moddle.create('bpmn:FormalExpression', { |
|
206 |
body: cardinality |
|
207 |
}) |
|
208 |
} |
|
209 |
bpmnInstances().modeling.updateModdleProperties( |
|
210 |
toRaw(bpmnElement.value), |
|
211 |
multiLoopInstance.value, |
|
212 |
{ |
|
213 |
loopCardinality |
|
214 |
} |
|
215 |
) |
|
216 |
} |
|
217 |
|
|
218 |
// 完成条件 |
|
219 |
const updateLoopCondition = (condition) => { |
|
220 |
let completionCondition = null |
|
221 |
if (condition && condition.length) { |
|
222 |
completionCondition = bpmnInstances().moddle.create('bpmn:FormalExpression', { |
|
223 |
body: condition |
|
224 |
}) |
|
225 |
} |
|
226 |
bpmnInstances().modeling.updateModdleProperties( |
|
227 |
toRaw(bpmnElement.value), |
|
228 |
multiLoopInstance.value, |
|
229 |
{ |
|
230 |
completionCondition |
|
231 |
} |
|
232 |
) |
|
233 |
} |
|
234 |
|
|
235 |
// 重试周期 |
|
236 |
const updateLoopTimeCycle = (timeCycle) => { |
|
237 |
const extensionElements = bpmnInstances().moddle.create('bpmn:ExtensionElements', { |
|
238 |
values: [ |
|
239 |
bpmnInstances().moddle.create(`${prefix}:FailedJobRetryTimeCycle`, { |
|
240 |
body: timeCycle |
|
241 |
}) |
|
242 |
] |
|
243 |
}) |
|
244 |
bpmnInstances().modeling.updateModdleProperties( |
|
245 |
toRaw(bpmnElement.value), |
|
246 |
multiLoopInstance.value, |
|
247 |
{ |
|
248 |
extensionElements |
|
249 |
} |
|
250 |
) |
|
251 |
} |
|
252 |
|
|
253 |
// 直接更新的基础信息 |
|
254 |
const updateLoopBase = () => { |
|
255 |
bpmnInstances().modeling.updateModdleProperties( |
|
256 |
toRaw(bpmnElement.value), |
|
257 |
multiLoopInstance.value, |
|
258 |
{ |
|
259 |
collection: loopInstanceForm.value.collection || null, |
|
260 |
elementVariable: loopInstanceForm.value.elementVariable || null |
|
261 |
} |
|
262 |
) |
|
263 |
} |
|
264 |
|
|
265 |
// 各异步状态 |
|
266 |
const updateLoopAsync = (key) => { |
|
267 |
const { asyncBefore, asyncAfter } = loopInstanceForm.value |
|
268 |
let asyncAttr = Object.create(null) |
|
269 |
if (!asyncBefore && !asyncAfter) { |
|
270 |
// this.$set(this.loopInstanceForm, "exclusive", false); |
|
271 |
loopInstanceForm.value['exclusive'] = false |
|
272 |
asyncAttr = { asyncBefore: false, asyncAfter: false, exclusive: false, extensionElements: null } |
|
273 |
} else { |
|
274 |
asyncAttr[key] = loopInstanceForm.value[key] |
|
275 |
} |
|
276 |
bpmnInstances().modeling.updateModdleProperties( |
|
277 |
toRaw(bpmnElement.value), |
|
278 |
multiLoopInstance.value, |
|
279 |
asyncAttr |
|
280 |
) |
|
281 |
} |
|
282 |
|
|
283 |
const changeConfig = (config) => { |
|
284 |
if (config === '依次审批') { |
|
285 |
changeLoopCharacteristicsType('SequentialMultiInstance') |
|
286 |
updateLoopCardinality('1') |
|
287 |
updateLoopCondition('${ nrOfCompletedInstances >= nrOfInstances }') |
|
288 |
} else if (config === '会签') { |
|
289 |
changeLoopCharacteristicsType('ParallelMultiInstance') |
|
290 |
updateLoopCondition('${ nrOfCompletedInstances >= nrOfInstances }') |
|
291 |
} else if (config === '或签') { |
|
292 |
changeLoopCharacteristicsType('ParallelMultiInstance') |
|
293 |
updateLoopCondition('${ nrOfCompletedInstances > 0 }') |
|
294 |
} |
|
295 |
} |
|
296 |
|
9259c2
|
297 |
/** |
H |
298 |
* -----新版本多实例----- |
|
299 |
*/ |
|
300 |
const approveMethod = ref() |
|
301 |
const approveRatio = ref(100) |
|
302 |
const otherExtensions = ref() |
|
303 |
const getElementLoopNew = () => { |
|
304 |
const extensionElements = |
|
305 |
bpmnElement.value.businessObject?.extensionElements ?? |
|
306 |
bpmnInstances().moddle.create('bpmn:ExtensionElements', { values: [] }) |
|
307 |
approveMethod.value = extensionElements.values.filter( |
|
308 |
(ex) => ex.$type === `${prefix}:ApproveMethod` |
|
309 |
)?.[0]?.value |
|
310 |
|
|
311 |
otherExtensions.value = |
|
312 |
extensionElements.values.filter((ex) => ex.$type !== `${prefix}:ApproveMethod`) ?? [] |
|
313 |
|
|
314 |
if (!approveMethod.value) { |
|
315 |
approveMethod.value = ApproveMethodType.SEQUENTIAL_APPROVE |
|
316 |
updateLoopCharacteristics() |
|
317 |
} |
|
318 |
} |
|
319 |
const onApproveMethodChange = () => { |
|
320 |
approveRatio.value = 100 |
|
321 |
updateLoopCharacteristics() |
|
322 |
} |
|
323 |
const onApproveRatioChange = () => { |
|
324 |
updateLoopCharacteristics() |
|
325 |
} |
|
326 |
const updateLoopCharacteristics = () => { |
|
327 |
// 根据ApproveMethod生成multiInstanceLoopCharacteristics节点 |
|
328 |
if (approveMethod.value === ApproveMethodType.RANDOM_SELECT_ONE_APPROVE) { |
|
329 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
330 |
loopCharacteristics: null |
|
331 |
}) |
|
332 |
} else { |
|
333 |
if (approveMethod.value === ApproveMethodType.APPROVE_BY_RATIO) { |
|
334 |
multiLoopInstance.value = bpmnInstances().moddle.create( |
|
335 |
'bpmn:MultiInstanceLoopCharacteristics', |
|
336 |
{ isSequential: false, collection: '${coll_userList}' } |
|
337 |
) |
|
338 |
multiLoopInstance.value.completionCondition = bpmnInstances().moddle.create( |
|
339 |
'bpmn:FormalExpression', |
|
340 |
{ |
|
341 |
body: '${ nrOfCompletedInstances/nrOfInstances >= ' + approveRatio.value / 100 + '}' |
|
342 |
} |
|
343 |
) |
|
344 |
} |
|
345 |
if (approveMethod.value === ApproveMethodType.ANY_APPROVE) { |
|
346 |
multiLoopInstance.value = bpmnInstances().moddle.create( |
|
347 |
'bpmn:MultiInstanceLoopCharacteristics', |
|
348 |
{ isSequential: false, collection: '${coll_userList}' } |
|
349 |
) |
|
350 |
multiLoopInstance.value.completionCondition = bpmnInstances().moddle.create( |
|
351 |
'bpmn:FormalExpression', |
|
352 |
{ |
|
353 |
body: '${ nrOfCompletedInstances > 0 }' |
|
354 |
} |
|
355 |
) |
|
356 |
} |
|
357 |
if (approveMethod.value === ApproveMethodType.SEQUENTIAL_APPROVE) { |
|
358 |
multiLoopInstance.value = bpmnInstances().moddle.create( |
|
359 |
'bpmn:MultiInstanceLoopCharacteristics', |
|
360 |
{ isSequential: true, collection: '${coll_userList}' } |
|
361 |
) |
|
362 |
multiLoopInstance.value.loopCardinality = bpmnInstances().moddle.create( |
|
363 |
'bpmn:FormalExpression', |
|
364 |
{ |
|
365 |
body: '1' |
|
366 |
} |
|
367 |
) |
|
368 |
multiLoopInstance.value.completionCondition = bpmnInstances().moddle.create( |
|
369 |
'bpmn:FormalExpression', |
|
370 |
{ |
|
371 |
body: '${ nrOfCompletedInstances >= nrOfInstances }' |
|
372 |
} |
|
373 |
) |
|
374 |
} |
|
375 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
376 |
loopCharacteristics: toRaw(multiLoopInstance.value) |
|
377 |
}) |
|
378 |
} |
|
379 |
|
|
380 |
// 添加ApproveMethod到ExtensionElements |
|
381 |
const extensions = bpmnInstances().moddle.create('bpmn:ExtensionElements', { |
|
382 |
values: [ |
|
383 |
...otherExtensions.value, |
|
384 |
bpmnInstances().moddle.create(`${prefix}:ApproveMethod`, { |
|
385 |
value: approveMethod.value |
|
386 |
}) |
|
387 |
] |
|
388 |
}) |
|
389 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { |
|
390 |
extensionElements: extensions |
|
391 |
}) |
|
392 |
} |
|
393 |
|
820397
|
394 |
onBeforeUnmount(() => { |
H |
395 |
multiLoopInstance.value = null |
|
396 |
bpmnElement.value = null |
|
397 |
}) |
|
398 |
|
|
399 |
watch( |
9259c2
|
400 |
() => props.id, |
820397
|
401 |
(val) => { |
9259c2
|
402 |
if (val) { |
H |
403 |
nextTick(() => { |
|
404 |
bpmnElement.value = bpmnInstances().bpmnElement |
|
405 |
// getElementLoop(val) |
|
406 |
getElementLoopNew() |
|
407 |
}) |
|
408 |
} |
820397
|
409 |
}, |
H |
410 |
{ immediate: true } |
|
411 |
) |
|
412 |
</script> |