提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<div class="panel-tab__content"> |
|
3 |
<div class="panel-tab__content--title"> |
|
4 |
<span><Icon icon="ep:menu" style="margin-right: 8px; color: #555" />消息列表</span> |
|
5 |
<XButton type="primary" title="创建新消息" preIcon="ep:plus" @click="openModel('message')" /> |
|
6 |
</div> |
|
7 |
<el-table :data="messageList" border> |
|
8 |
<el-table-column type="index" label="序号" width="60px" /> |
|
9 |
<el-table-column label="消息ID" prop="id" max-width="300px" show-overflow-tooltip /> |
|
10 |
<el-table-column label="消息名称" prop="name" max-width="300px" show-overflow-tooltip /> |
|
11 |
</el-table> |
|
12 |
<div |
|
13 |
class="panel-tab__content--title" |
|
14 |
style="padding-top: 8px; margin-top: 8px; border-top: 1px solid #eee" |
|
15 |
> |
|
16 |
<span><Icon icon="ep:menu" style="margin-right: 8px; color: #555" />信号列表</span> |
|
17 |
<XButton type="primary" title="创建新信号" preIcon="ep:plus" @click="openModel('signal')" /> |
|
18 |
</div> |
|
19 |
<el-table :data="signalList" border> |
|
20 |
<el-table-column type="index" label="序号" width="60px" /> |
|
21 |
<el-table-column label="信号ID" prop="id" max-width="300px" show-overflow-tooltip /> |
|
22 |
<el-table-column label="信号名称" prop="name" max-width="300px" show-overflow-tooltip /> |
|
23 |
</el-table> |
|
24 |
|
|
25 |
<el-dialog |
|
26 |
v-model="dialogVisible" |
|
27 |
:title="modelConfig.title" |
|
28 |
:close-on-click-modal="false" |
|
29 |
width="400px" |
|
30 |
append-to-body |
|
31 |
destroy-on-close |
|
32 |
> |
|
33 |
<el-form :model="modelObjectForm" label-width="90px"> |
|
34 |
<el-form-item :label="modelConfig.idLabel"> |
|
35 |
<el-input v-model="modelObjectForm.id" clearable /> |
|
36 |
</el-form-item> |
|
37 |
<el-form-item :label="modelConfig.nameLabel"> |
|
38 |
<el-input v-model="modelObjectForm.name" clearable /> |
|
39 |
</el-form-item> |
|
40 |
</el-form> |
|
41 |
<template #footer> |
|
42 |
<el-button @click="dialogVisible = false">取 消</el-button> |
|
43 |
<el-button type="primary" @click="addNewObject">保 存</el-button> |
|
44 |
</template> |
|
45 |
</el-dialog> |
|
46 |
</div> |
|
47 |
</template> |
|
48 |
<script lang="ts" setup> |
|
49 |
defineOptions({ name: 'SignalAndMassage' }) |
|
50 |
|
|
51 |
const message = useMessage() |
|
52 |
const signalList = ref<any[]>([]) |
|
53 |
const messageList = ref<any[]>([]) |
|
54 |
const dialogVisible = ref(false) |
|
55 |
const modelType = ref('') |
|
56 |
const modelObjectForm = ref<any>({}) |
|
57 |
const rootElements = ref() |
|
58 |
const messageIdMap = ref() |
|
59 |
const signalIdMap = ref() |
|
60 |
const modelConfig = computed(() => { |
|
61 |
if (modelType.value === 'message') { |
|
62 |
return { title: '创建消息', idLabel: '消息ID', nameLabel: '消息名称' } |
|
63 |
} else { |
|
64 |
return { title: '创建信号', idLabel: '信号ID', nameLabel: '信号名称' } |
|
65 |
} |
|
66 |
}) |
|
67 |
const bpmnInstances = () => (window as any)?.bpmnInstances |
|
68 |
|
|
69 |
const initDataList = () => { |
|
70 |
console.log(window, 'window') |
|
71 |
rootElements.value = bpmnInstances().modeler.getDefinitions().rootElements |
|
72 |
messageIdMap.value = {} |
|
73 |
signalIdMap.value = {} |
|
74 |
messageList.value = [] |
|
75 |
signalList.value = [] |
|
76 |
rootElements.value.forEach((el) => { |
|
77 |
if (el.$type === 'bpmn:Message') { |
|
78 |
messageIdMap.value[el.id] = true |
|
79 |
messageList.value.push({ ...el }) |
|
80 |
} |
|
81 |
if (el.$type === 'bpmn:Signal') { |
|
82 |
signalIdMap.value[el.id] = true |
|
83 |
signalList.value.push({ ...el }) |
|
84 |
} |
|
85 |
}) |
|
86 |
} |
|
87 |
const openModel = (type) => { |
|
88 |
modelType.value = type |
|
89 |
modelObjectForm.value = {} |
|
90 |
dialogVisible.value = true |
|
91 |
} |
|
92 |
const addNewObject = () => { |
|
93 |
if (modelType.value === 'message') { |
|
94 |
if (messageIdMap.value[modelObjectForm.value.id]) { |
|
95 |
message.error('该消息已存在,请修改id后重新保存') |
|
96 |
} |
|
97 |
const messageRef = bpmnInstances().moddle.create('bpmn:Message', modelObjectForm.value) |
|
98 |
rootElements.value.push(messageRef) |
|
99 |
} else { |
|
100 |
if (signalIdMap.value[modelObjectForm.value.id]) { |
|
101 |
message.error('该信号已存在,请修改id后重新保存') |
|
102 |
} |
|
103 |
const signalRef = bpmnInstances().moddle.create('bpmn:Signal', modelObjectForm.value) |
|
104 |
rootElements.value.push(signalRef) |
|
105 |
} |
|
106 |
dialogVisible.value = false |
|
107 |
initDataList() |
|
108 |
} |
|
109 |
|
|
110 |
onMounted(() => { |
|
111 |
initDataList() |
|
112 |
}) |
|
113 |
</script> |