潘志宝
6 天以前 f6ea543b3de9a770c1bf5db2baf3e8a5dc2c867a
提交 | 用户 | 时间
820397 1 <template>
H 2   <div class="panel-tab__content">
3     <el-form size="small" label-width="90px">
4       <!-- add by 芋艿:由于「异步延续」暂时用不到,所以这里 display 为 none -->
5       <el-form-item label="异步延续" style="display: none">
6         <el-checkbox
7           v-model="taskConfigForm.asyncBefore"
8           label="异步前"
3e359e 9           value="异步前"
820397 10           @change="changeTaskAsync"
H 11         />
3e359e 12         <el-checkbox
H 13           v-model="taskConfigForm.asyncAfter"
14           label="异步后"
15           value="异步后"
16           @change="changeTaskAsync"
17         />
820397 18         <el-checkbox
H 19           v-model="taskConfigForm.exclusive"
20           v-if="taskConfigForm.asyncAfter || taskConfigForm.asyncBefore"
21           label="排除"
3e359e 22           value="排除"
820397 23           @change="changeTaskAsync"
H 24         />
25       </el-form-item>
26       <component :is="witchTaskComponent" v-bind="$props" />
27     </el-form>
28   </div>
29 </template>
30
31 <script lang="ts" setup>
9259c2 32 import { installedComponent } from './data'
820397 33
H 34 defineOptions({ name: 'ElementTaskConfig' })
35
36 const props = defineProps({
37   id: String,
38   type: String
39 })
40 const taskConfigForm = ref({
41   asyncAfter: false,
42   asyncBefore: false,
43   exclusive: false
44 })
45 const witchTaskComponent = ref()
9259c2 46
820397 47 const bpmnElement = ref()
H 48
49 const bpmnInstances = () => (window as any).bpmnInstances
50 const changeTaskAsync = () => {
51   if (!taskConfigForm.value.asyncBefore && !taskConfigForm.value.asyncAfter) {
52     taskConfigForm.value.exclusive = false
53   }
54   bpmnInstances().modeling.updateProperties(bpmnInstances().bpmnElement, {
55     ...taskConfigForm.value
56   })
57 }
58
59 watch(
60   () => props.id,
61   () => {
62     bpmnElement.value = bpmnInstances().bpmnElement
63     taskConfigForm.value.asyncBefore = bpmnElement.value?.businessObject?.asyncBefore
64     taskConfigForm.value.asyncAfter = bpmnElement.value?.businessObject?.asyncAfter
65     taskConfigForm.value.exclusive = bpmnElement.value?.businessObject?.exclusive
66   },
67   { immediate: true }
68 )
69 watch(
70   () => props.type,
71   () => {
9259c2 72     if (props.type) {
H 73       witchTaskComponent.value = installedComponent[props.type].component
820397 74     }
H 75   },
76   { immediate: true }
77 )
78 </script>