Skip to content

Commit a726d81

Browse files
authored
Merge pull request #203 from zhanglc0618/featrue/message-and-signal-standard-id
feat: 流程设计器:优化 消息和信号 的新增,自动生成符合BPMN规范的id
2 parents cee91dd + 258240b commit a726d81

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/components/bpmnProcessDesigner/package/penal/signal-message/SignalAndMessage.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
link
2020
size="small"
2121
style="color: #ff4d4f"
22-
@click="removeObject('message', scope.row, scope.$index)"
22+
@click="removeObject('message', scope.row)"
2323
>
2424
移除
2525
</el-button>
@@ -47,7 +47,7 @@
4747
link
4848
size="small"
4949
style="color: #ff4d4f"
50-
@click="removeObject('signal', scope.row, scope.$index)"
50+
@click="removeObject('signal', scope.row)"
5151
>
5252
移除
5353
</el-button>
@@ -110,6 +110,14 @@ const modelConfig = computed(() => {
110110
})
111111
const bpmnInstances = () => (window as any)?.bpmnInstances
112112
113+
// 生成规范化的ID
114+
const generateStandardId = (type: string): string => {
115+
const prefix = type === 'message' ? 'Message_' : 'Signal_'
116+
const timestamp = Date.now()
117+
const random = Math.random().toString(36).substring(2, 6).toUpperCase()
118+
return `${prefix}${timestamp}_${random}`
119+
}
120+
113121
const initDataList = () => {
114122
console.log(window, 'window')
115123
rootElements.value = bpmnInstances().modeler.getDefinitions().rootElements
@@ -131,7 +139,10 @@ const initDataList = () => {
131139
const openModel = (type) => {
132140
modelType.value = type
133141
editingIndex.value = -1
134-
modelObjectForm.value = {}
142+
modelObjectForm.value = {
143+
id: generateStandardId(type),
144+
name: ''
145+
}
135146
dialogVisible.value = true
136147
}
137148
@@ -189,7 +200,7 @@ const addNewObject = () => {
189200
initDataList()
190201
}
191202
192-
const removeObject = (type, row, index) => {
203+
const removeObject = (type, row) => {
193204
ElMessageBox.confirm(`确认移除该${type === 'message' ? '消息' : '信号'}吗?`, '提示', {
194205
confirmButtonText: '确 认',
195206
cancelButtonText: '取 消'

0 commit comments

Comments
 (0)