dengzedong
5 天以前 f9b459a3fefd5fab0ee8e19268adb9d9eadab2a7
提交 | 用户 | 时间
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>
32 import UserTask from './task-components/UserTask.vue'
33 import ScriptTask from './task-components/ScriptTask.vue'
34 import ReceiveTask from './task-components/ReceiveTask.vue'
35
36 defineOptions({ name: 'ElementTaskConfig' })
37
38 const props = defineProps({
39   id: String,
40   type: String
41 })
42 const taskConfigForm = ref({
43   asyncAfter: false,
44   asyncBefore: false,
45   exclusive: false
46 })
47 const witchTaskComponent = ref()
48 const installedComponent = ref({
49   // 手工任务与普通任务一致,不需要其他配置
50   // 接收消息任务,需要在全局下插入新的消息实例,并在该节点下的 messageRef 属性绑定该实例
51   // 发送任务、服务任务、业务规则任务共用一个相同配置
52   UserTask: 'UserTask', // 用户任务配置
53   ScriptTask: 'ScriptTask', // 脚本任务配置
54   ReceiveTask: 'ReceiveTask' // 消息接收任务
55 })
56 const bpmnElement = ref()
57
58 const bpmnInstances = () => (window as any).bpmnInstances
59 const changeTaskAsync = () => {
60   if (!taskConfigForm.value.asyncBefore && !taskConfigForm.value.asyncAfter) {
61     taskConfigForm.value.exclusive = false
62   }
63   bpmnInstances().modeling.updateProperties(bpmnInstances().bpmnElement, {
64     ...taskConfigForm.value
65   })
66 }
67
68 watch(
69   () => props.id,
70   () => {
71     bpmnElement.value = bpmnInstances().bpmnElement
72     taskConfigForm.value.asyncBefore = bpmnElement.value?.businessObject?.asyncBefore
73     taskConfigForm.value.asyncAfter = bpmnElement.value?.businessObject?.asyncAfter
74     taskConfigForm.value.exclusive = bpmnElement.value?.businessObject?.exclusive
75   },
76   { immediate: true }
77 )
78 watch(
79   () => props.type,
80   () => {
81     // witchTaskComponent.value = installedComponent.value[props.type]
82     if (props.type == installedComponent.value.UserTask) {
83       witchTaskComponent.value = UserTask
84     }
85     if (props.type == installedComponent.value.ScriptTask) {
86       witchTaskComponent.value = ScriptTask
87     }
88     if (props.type == installedComponent.value.ReceiveTask) {
89       witchTaskComponent.value = ReceiveTask
90     }
91   },
92   { immediate: true }
93 )
94 </script>