77 >
88 <div v-resize =" resizeStepContainer" >
99 <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% ;" >
1411 <component
1512 :is =" iconComponent(`${nodeModel.type}-icon`)"
1613 class =" mr-8"
1714 :size =" 24"
1815 :item =" nodeModel?.properties.node_data"
1916 />
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 >
3218 </div >
3319
3420 <div @mousemove.stop @mousedown.stop @keydown.stop @click.stop >
7056 </el-button >
7157 <template #dropdown >
7258 <el-dropdown-menu style =" min-width : 80px " >
59+ <el-dropdown-item @click =" renameNode" class =" p-8" >{{
60+ $t('common.rename')
61+ }}</el-dropdown-item >
7362 <el-dropdown-item @click =" copyNode" class =" p-8" >{{
7463 $t('common.copy')
7564 }}</el-dropdown-item >
138127 @clickNodes =" clickNodes"
139128 />
140129 </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 >
141164 </div >
142165</template >
143166<script setup lang="ts">
@@ -149,6 +172,7 @@ import { iconComponent } from '../icons/utils'
149172import { copyClick } from ' @/utils/clipboard'
150173import { WorkflowType } from ' @/enums/workflow'
151174import { MsgError , MsgConfirm } from ' @/utils/message'
175+ import type { FormInstance } from ' element-plus'
152176import { t } from ' @/locales'
153177const {
154178 params : { id }
@@ -165,6 +189,11 @@ const height = ref<{
165189})
166190const showAnchor = ref <boolean >(false )
167191const anchorData = ref <any >()
192+ const titleFormRef = ref ()
193+ const nodeNameDialogVisible = ref <boolean >(false )
194+ const form = ref <any >({
195+ title: ' '
196+ })
168197
169198const condition = computed ({
170199 set : (v ) => {
@@ -190,6 +219,7 @@ const showNode = computed({
190219 return true
191220 }
192221})
222+
193223const handleWheel = (event : any ) => {
194224 const isCombinationKeyPressed = event .ctrlKey || event .metaKey
195225 if (! isCombinationKeyPressed ) {
@@ -202,19 +232,30 @@ const node_status = computed(() => {
202232 }
203233 return 200
204234})
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+ }
215255 }
216- }
256+ })
217257}
258+
218259const mousedown = () => {
219260 props .nodeModel .graphModel .clearSelectElements ()
220261 set (props .nodeModel , ' isSelected' , true )
0 commit comments