116116 <el-icon class =" mr-4" ><Plus /></el-icon > {{ $t('common.add') }}
117117 </el-button >
118118 </div >
119- <el-table :data =" form.init_field_list" class =" mb-16" >
119+ <el-table ref = " initFieldTableRef " :data =" form.init_field_list" class =" mb-16" >
120120 <el-table-column prop =" field" :label =" $t('dynamicsForm.paramForm.field.label')" >
121121 <template #default =" { row } " >
122122 <span :title =" row.field" class =" ellipsis-1" >{{ row.field }}</span >
188188 </el-button >
189189 </div >
190190
191- <el-table :data =" form.input_field_list" class =" mb-16" >
191+ <el-table ref = " inputFieldTableRef " :data =" form.input_field_list" class =" mb-16" >
192192 <el-table-column
193193 prop =" name"
194194 :label =" $t('views.functionLib.functionForm.form.paramName.label')"
280280</template >
281281
282282<script setup lang="ts">
283- import { ref , reactive , watch } from ' vue'
283+ import { ref , reactive , watch , nextTick } from ' vue'
284284import FieldFormDialog from ' ./FieldFormDialog.vue'
285285import FunctionDebugDrawer from ' ./FunctionDebugDrawer.vue'
286286import type { functionLibData } from ' @/api/type/function-lib'
@@ -293,6 +293,7 @@ import { t } from '@/locales'
293293import UserFieldFormDialog from ' @/workflow/nodes/base-node/component/UserFieldFormDialog.vue'
294294import { isAppIcon } from ' @/utils/application'
295295import EditAvatarDialog from ' ./EditAvatarDialog.vue'
296+ import Sortable from ' sortablejs'
296297
297298const props = defineProps ({
298299 title: String
@@ -303,6 +304,8 @@ const FieldFormDialogRef = ref()
303304const FunctionDebugDrawerRef = ref ()
304305const UserFieldFormDialogRef = ref ()
305306const EditAvatarDialogRef = ref ()
307+ const initFieldTableRef = ref ()
308+ const inputFieldTableRef = ref ()
306309
307310const FormRef = ref ()
308311
@@ -358,6 +361,40 @@ const rules = reactive({
358361 ]
359362})
360363
364+ function onDragHandle() {
365+ // For init_field_list table
366+ if (initFieldTableRef .value ) {
367+ const el = initFieldTableRef .value .$el .querySelector (' .el-table__body-wrapper tbody' )
368+ Sortable .create (el , {
369+ animation: 150 ,
370+ ghostClass: ' sortable-ghost' ,
371+ onEnd : ({ newIndex , oldIndex }) => {
372+ if (newIndex === undefined || oldIndex === undefined ) return
373+ if (newIndex !== oldIndex ) {
374+ const item = form .value .init_field_list ?.splice (oldIndex , 1 )[0 ]
375+ form .value .init_field_list ?.splice (newIndex , 0 , item )
376+ }
377+ }
378+ })
379+ }
380+
381+ // For input_field_list table
382+ if (inputFieldTableRef .value ) {
383+ const el = inputFieldTableRef .value .$el .querySelector (' .el-table__body-wrapper tbody' )
384+ Sortable .create (el , {
385+ animation: 150 ,
386+ ghostClass: ' sortable-ghost' ,
387+ onEnd : ({ newIndex , oldIndex }) => {
388+ if (newIndex === undefined || oldIndex === undefined ) return
389+ if (newIndex !== oldIndex ) {
390+ const item = form .value .input_field_list ?.splice (oldIndex , 1 )[0 ]
391+ form .value .input_field_list ?.splice (newIndex , 0 , item )
392+ }
393+ }
394+ })
395+ }
396+ }
397+
361398function submitCodemirrorEditor(val : string ) {
362399 form .value .code = val
363400}
@@ -471,6 +508,9 @@ const open = (data: any) => {
471508 visible .value = true
472509 setTimeout (() => {
473510 showEditor .value = true
511+ nextTick (() => {
512+ onDragHandle ()
513+ })
474514 }, 100 )
475515}
476516
0 commit comments