4242 <el-card shadow =" never" class =" card-never" style =" --el-card-padding : 12px " >
4343 <div class =" flex-between mb-12" >
4444 <span class =" ellipsis" :title =" group.label" >{{ group.label }}</span >
45- <div class =" flex align-center" style =" margin-right : -3px ; " >
46- <el-button @click =" openAddOrEditDialog(group, gIndex)" link >
45+ <div class =" flex align-center" style =" margin-right : -3px " >
46+ <el-button @click =" openAddOrEditDialog(group, gIndex)" link >
4747 <el-icon ><EditPen /></el-icon >
4848 </el-button >
4949 <el-button
5555 </el-button >
5656 </div >
5757 </div >
58-
59- <div v-for =" (item, vIndex) in group.variable_list" :key =" item.v_id" >
60- <el-row >
61- <el-col :span =" 22" >
62- <el-form-item
63- :prop =" `group_list.${gIndex}.variable_list.${vIndex}.variable`"
64- :rules =" {
65- type: 'array',
66- required: true,
67- message: $t(
68- 'views.applicationWorkflow.variable.placeholder',
69- ),
70- trigger: 'change',
71- }"
72- >
73- <NodeCascader
74- ref =" nodeCascaderRef"
75- :nodeModel =" nodeModel"
76- class =" w-full"
77- :placeholder =" $t('views.applicationWorkflow.variable.placeholder')"
78- v-model =" item.variable"
79- />
80- </el-form-item >
81- </el-col >
82- <el-col :span =" 2" >
83- <el-button
84- link
85- class =" mt-4 ml-4"
86- :disabled =" group.variable_list.length <= 1"
87- @click =" deleteVariable(gIndex, vIndex)"
88- >
89- <AppIcon iconName =" app-delete" ></AppIcon >
90- </el-button >
91- </el-col >
92- </el-row >
93- </div >
94-
58+ <VueDraggable
59+ ref =" el"
60+ v-bind:modelValue =" group.variable_list"
61+ :disabled =" group.variable_list.length === 1"
62+ handle =" .handle"
63+ :animation =" 150"
64+ ghostClass =" ghost"
65+ @end =" onEnd($event, gIndex)"
66+ >
67+ <div v-for =" (item, vIndex) in group.variable_list" :key =" item.v_id" class =" drag-card" >
68+ <el-row class =" handle" >
69+ <el-col :span =" 22" class =" flex" >
70+ <img src =" @/assets/sort.svg" alt =" " height =" 15" class =" mr-4 mt-8" />
71+ <el-form-item
72+ :prop =" `group_list.${gIndex}.variable_list.${vIndex}.variable`"
73+ :rules =" {
74+ type: 'array',
75+ required: true,
76+ message: $t('views.applicationWorkflow.variable.placeholder'),
77+ trigger: 'change',
78+ }"
79+ >
80+ <NodeCascader
81+ ref =" nodeCascaderRef"
82+ :nodeModel =" nodeModel"
83+ style =" width : 200px "
84+ :placeholder =" $t('views.applicationWorkflow.variable.placeholder')"
85+ v-model =" item.variable"
86+ />
87+ </el-form-item >
88+ </el-col >
89+ <el-col :span =" 2" >
90+ <el-button
91+ link
92+ class =" mt-4 ml-4"
93+ :disabled =" group.variable_list.length <= 1"
94+ @click =" deleteVariable(gIndex, vIndex)"
95+ >
96+ <AppIcon iconName =" app-delete" ></AppIcon >
97+ </el-button >
98+ </el-col >
99+ </el-row >
100+ </div >
101+ </VueDraggable >
95102 <el-button @click =" addVariable(gIndex)" type =" primary" size =" large" link >
96103 <AppIcon iconName =" app-add-outlined" class =" mr-4" />
97104 {{ $t('common.add') }}
@@ -116,6 +123,7 @@ import { isLastNode } from '@/workflow/common/data'
116123import { t } from ' @/locales'
117124import { randomId } from ' @/utils/common'
118125import { MsgError } from ' @/utils/message'
126+ import { VueDraggable } from ' vue-draggable-plus'
119127
120128const props = defineProps <{ nodeModel: any }>()
121129const VariableAggregationRef = ref ()
@@ -241,6 +249,17 @@ const validate = async () => {
241249 })
242250}
243251
252+ function onEnd(event : any , gIndex : number ) {
253+ const { oldIndex, newIndex } = event
254+ if (oldIndex === undefined || newIndex === undefined ) return
255+ const list = cloneDeep (props .nodeModel .properties .node_data .group_list [gIndex ].variable_list )
256+ const newInstance = { ... list [oldIndex ] }
257+ const oldInstance = { ... list [newIndex ] }
258+ list [newIndex ] = newInstance
259+ list [oldIndex ] = oldInstance
260+ set (props .nodeModel .properties .node_data .group_list [gIndex ], ' variable_list' , list )
261+ }
262+
244263onMounted (() => {
245264 if (typeof props .nodeModel .properties .node_data ?.is_result === ' undefined' ) {
246265 if (isLastNode (props .nodeModel )) {
0 commit comments