7
7
>
8
8
<div v-resize =" resizeStepContainer" >
9
9
<div class =" flex-between" >
10
- <div
11
- class =" flex align-center"
12
- :style =" { maxWidth: node_status == 200 ? 'calc(100% - 85px)' : 'calc(100% - 85px)' }"
13
- >
10
+ <div class =" flex align-center" style =" width : 70% ;" >
14
11
<component
15
12
:is =" iconComponent(`${nodeModel.type}-icon`)"
16
13
class =" mr-8"
17
14
:size =" 24"
18
15
:item =" nodeModel?.properties.node_data"
19
16
/>
20
- <h4 v-if =" showOperate(nodeModel.type)" style =" max-width : 90% " >
21
- <ReadWrite
22
- @mousemove.stop
23
- @mousedown.stop
24
- @keydown.stop
25
- @click.stop
26
- @change =" editName"
27
- :data =" nodeModel.properties.stepName"
28
- trigger =" dblclick"
29
- />
30
- </h4 >
31
- <h4 v-else >{{ nodeModel.properties.stepName }}</h4 >
17
+ <h4 class =" ellipsis-1 break-all" >{{ nodeModel.properties.stepName }}</h4 >
32
18
</div >
33
19
34
20
<div @mousemove.stop @mousedown.stop @keydown.stop @click.stop >
70
56
</el-button >
71
57
<template #dropdown >
72
58
<el-dropdown-menu style =" min-width : 80px " >
59
+ <el-dropdown-item @click =" renameNode" class =" p-8" >{{
60
+ $t('common.rename')
61
+ }}</el-dropdown-item >
73
62
<el-dropdown-item @click =" copyNode" class =" p-8" >{{
74
63
$t('common.copy')
75
64
}}</el-dropdown-item >
138
127
@clickNodes =" clickNodes"
139
128
/>
140
129
</el-collapse-transition >
130
+
131
+ <el-dialog
132
+ :title =" $t('views.applicationWorkflow.nodeName')"
133
+ v-model =" nodeNameDialogVisible"
134
+ :close-on-click-modal =" false"
135
+ :close-on-press-escape =" false"
136
+ :destroy-on-close =" true"
137
+ append-to-body
138
+ >
139
+ <el-form label-position =" top" ref =" titleFormRef" :model =" form" >
140
+ <el-form-item
141
+ prop =" title"
142
+ :rules =" [
143
+ {
144
+ required: true,
145
+ message: $t('common.inputPlaceholder'),
146
+ trigger: 'blur'
147
+ }
148
+ ]"
149
+ >
150
+ <el-input v-model =" form.title" @blur =" form.title = form.title.trim()" />
151
+ </el-form-item >
152
+ </el-form >
153
+ <template #footer >
154
+ <span class =" dialog-footer" >
155
+ <el-button @click.prevent =" nodeNameDialogVisible = false" >
156
+ {{ $t('common.cancel') }}
157
+ </el-button >
158
+ <el-button type =" primary" @click =" editName(titleFormRef)" >
159
+ {{ $t('common.save') }}
160
+ </el-button >
161
+ </span >
162
+ </template >
163
+ </el-dialog >
141
164
</div >
142
165
</template >
143
166
<script setup lang="ts">
@@ -149,6 +172,7 @@ import { iconComponent } from '../icons/utils'
149
172
import { copyClick } from ' @/utils/clipboard'
150
173
import { WorkflowType } from ' @/enums/workflow'
151
174
import { MsgError , MsgConfirm } from ' @/utils/message'
175
+ import type { FormInstance } from ' element-plus'
152
176
import { t } from ' @/locales'
153
177
const {
154
178
params : { id }
@@ -165,6 +189,11 @@ const height = ref<{
165
189
})
166
190
const showAnchor = ref <boolean >(false )
167
191
const anchorData = ref <any >()
192
+ const titleFormRef = ref ()
193
+ const nodeNameDialogVisible = ref <boolean >(false )
194
+ const form = ref <any >({
195
+ title: ' '
196
+ })
168
197
169
198
const condition = computed ({
170
199
set : (v ) => {
@@ -190,6 +219,7 @@ const showNode = computed({
190
219
return true
191
220
}
192
221
})
222
+
193
223
const handleWheel = (event : any ) => {
194
224
const isCombinationKeyPressed = event .ctrlKey || event .metaKey
195
225
if (! isCombinationKeyPressed ) {
@@ -202,19 +232,30 @@ const node_status = computed(() => {
202
232
}
203
233
return 200
204
234
})
205
- function editName(val : string ) {
206
- if (val .trim () && val .trim () !== props .nodeModel .properties .stepName ) {
207
- if (
208
- ! props .nodeModel .graphModel .nodes ?.some (
209
- (node : any ) => node .properties .stepName === val .trim ()
210
- )
211
- ) {
212
- set (props .nodeModel .properties , ' stepName' , val .trim ())
213
- } else {
214
- MsgError (t (' views.applicationWorkflow.tip.repeatedNodeError' ))
235
+
236
+ function renameNode() {
237
+ form .value .title = props .nodeModel .properties .stepName
238
+ nodeNameDialogVisible .value = true
239
+ }
240
+ const editName = async (formEl : FormInstance | undefined ) => {
241
+ if (! formEl ) return
242
+ await formEl .validate ((valid ) => {
243
+ if (valid ) {
244
+ if (
245
+ ! props .nodeModel .graphModel .nodes ?.some (
246
+ (node : any ) => node .properties .stepName === form .value .title
247
+ )
248
+ ) {
249
+ set (props .nodeModel .properties , ' stepName' , form .value .title )
250
+ nodeNameDialogVisible .value = false
251
+ formEl .resetFields ()
252
+ } else {
253
+ MsgError (t (' views.applicationWorkflow.tip.repeatedNodeError' ))
254
+ }
215
255
}
216
- }
256
+ })
217
257
}
258
+
218
259
const mousedown = () => {
219
260
props .nodeModel .graphModel .clearSelectElements ()
220
261
set (props .nodeModel , ' isSelected' , true )
0 commit comments