feat: User input parameters and interface parameters support adjusting the order(#2103)
* feat: table support sort(#2103) * feat: User input parameters and interface parameters support adjusting the order(#2103) * feat: User input parameters and interface parameters support adjusting the order(#2103)
This commit is contained in:
parent
df940686e9
commit
a2e5180236
@ -18,6 +18,7 @@
|
|||||||
"@ctrl/tinycolor": "^4.1.0",
|
"@ctrl/tinycolor": "^4.1.0",
|
||||||
"@logicflow/core": "^1.2.27",
|
"@logicflow/core": "^1.2.27",
|
||||||
"@logicflow/extension": "^1.2.27",
|
"@logicflow/extension": "^1.2.27",
|
||||||
|
"@types/sortablejs": "^1.15.8",
|
||||||
"@vavt/cm-extension": "^1.6.0",
|
"@vavt/cm-extension": "^1.6.0",
|
||||||
"@vueuse/core": "^10.9.0",
|
"@vueuse/core": "^10.9.0",
|
||||||
"@wecom/jssdk": "^2.1.0",
|
"@wecom/jssdk": "^2.1.0",
|
||||||
@ -42,6 +43,7 @@
|
|||||||
"pinyin-pro": "^3.18.2",
|
"pinyin-pro": "^3.18.2",
|
||||||
"recorder-core": "^1.3.24040900",
|
"recorder-core": "^1.3.24040900",
|
||||||
"screenfull": "^6.0.2",
|
"screenfull": "^6.0.2",
|
||||||
|
"sortablejs": "^1.15.6",
|
||||||
"use-element-plus-theme": "^0.0.5",
|
"use-element-plus-theme": "^0.0.5",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-clipboard3": "^2.0.0",
|
"vue-clipboard3": "^2.0.0",
|
||||||
|
|||||||
@ -5,13 +5,15 @@
|
|||||||
<el-icon class="mr-4">
|
<el-icon class="mr-4">
|
||||||
<Plus />
|
<Plus />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
{{$t('common.add')}}
|
{{ $t('common.add') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-table
|
<el-table
|
||||||
v-if="props.nodeModel.properties.api_input_field_list?.length > 0"
|
v-if="props.nodeModel.properties.api_input_field_list?.length > 0"
|
||||||
:data="props.nodeModel.properties.api_input_field_list"
|
:data="props.nodeModel.properties.api_input_field_list"
|
||||||
class="mb-16"
|
class="mb-16"
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="field"
|
||||||
>
|
>
|
||||||
<el-table-column prop="variable" :label="$t('dynamicsForm.paramForm.field.label')" />
|
<el-table-column prop="variable" :label="$t('dynamicsForm.paramForm.field.label')" />
|
||||||
<el-table-column prop="default_value" :label="$t('dynamicsForm.default.label')" />
|
<el-table-column prop="default_value" :label="$t('dynamicsForm.default.label')" />
|
||||||
@ -48,11 +50,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { set } from 'lodash'
|
import { set } from 'lodash'
|
||||||
|
import Sortable from 'sortablejs'
|
||||||
import ApiFieldFormDialog from './ApiFieldFormDialog.vue'
|
import ApiFieldFormDialog from './ApiFieldFormDialog.vue'
|
||||||
import { MsgError } from '@/utils/message'
|
import { MsgError } from '@/utils/message'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
const props = defineProps<{ nodeModel: any }>()
|
|
||||||
|
|
||||||
|
const props = defineProps<{ nodeModel: any }>()
|
||||||
|
const tableRef = ref()
|
||||||
const currentIndex = ref(null)
|
const currentIndex = ref(null)
|
||||||
const ApiFieldFormDialogRef = ref()
|
const ApiFieldFormDialogRef = ref()
|
||||||
const inputFieldList = ref<any[]>([])
|
const inputFieldList = ref<any[]>([])
|
||||||
@ -67,6 +71,7 @@ function openAddDialog(data?: any, index?: any) {
|
|||||||
function deleteField(index: any) {
|
function deleteField(index: any) {
|
||||||
inputFieldList.value.splice(index, 1)
|
inputFieldList.value.splice(index, 1)
|
||||||
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
||||||
|
onDragHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshFieldList(data: any) {
|
function refreshFieldList(data: any) {
|
||||||
@ -92,6 +97,30 @@ function refreshFieldList(data: any) {
|
|||||||
currentIndex.value = null
|
currentIndex.value = null
|
||||||
ApiFieldFormDialogRef.value.close()
|
ApiFieldFormDialogRef.value.close()
|
||||||
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
||||||
|
onDragHandle()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDragHandle() {
|
||||||
|
if (!tableRef.value) return
|
||||||
|
|
||||||
|
// 获取表格的 tbody DOM 元素
|
||||||
|
const wrapper = tableRef.value.$el as HTMLElement
|
||||||
|
const tbody = wrapper.querySelector('.el-table__body-wrapper tbody')
|
||||||
|
if (!tbody) return
|
||||||
|
// 初始化 Sortable
|
||||||
|
Sortable.create(tbody, {
|
||||||
|
animation: 150,
|
||||||
|
ghostClass: 'ghost-row',
|
||||||
|
onEnd: (evt) => {
|
||||||
|
if (evt.oldIndex === undefined || evt.newIndex === undefined) return
|
||||||
|
// 更新数据顺序
|
||||||
|
const items = [...inputFieldList.value]
|
||||||
|
const [movedItem] = items.splice(evt.oldIndex, 1)
|
||||||
|
items.splice(evt.newIndex, 0, movedItem)
|
||||||
|
inputFieldList.value = items
|
||||||
|
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@ -21,6 +21,8 @@
|
|||||||
v-if="props.nodeModel.properties.user_input_field_list?.length > 0"
|
v-if="props.nodeModel.properties.user_input_field_list?.length > 0"
|
||||||
:data="props.nodeModel.properties.user_input_field_list"
|
:data="props.nodeModel.properties.user_input_field_list"
|
||||||
class="mb-16"
|
class="mb-16"
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="field"
|
||||||
>
|
>
|
||||||
<el-table-column prop="field" :label="$t('dynamicsForm.paramForm.field.label')" width="95">
|
<el-table-column prop="field" :label="$t('dynamicsForm.paramForm.field.label')" width="95">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@ -107,12 +109,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { set } from 'lodash'
|
import { set } from 'lodash'
|
||||||
|
import Sortable from 'sortablejs'
|
||||||
import UserFieldFormDialog from './UserFieldFormDialog.vue'
|
import UserFieldFormDialog from './UserFieldFormDialog.vue'
|
||||||
import { MsgError } from '@/utils/message'
|
import { MsgError } from '@/utils/message'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
import UserInputTitleDialog from '@/workflow/nodes/base-node/component/UserInputTitleDialog.vue'
|
import UserInputTitleDialog from '@/workflow/nodes/base-node/component/UserInputTitleDialog.vue'
|
||||||
const props = defineProps<{ nodeModel: any }>()
|
const props = defineProps<{ nodeModel: any }>()
|
||||||
|
|
||||||
|
const tableRef = ref()
|
||||||
const UserFieldFormDialogRef = ref()
|
const UserFieldFormDialogRef = ref()
|
||||||
const UserInputTitleDialogRef = ref()
|
const UserInputTitleDialogRef = ref()
|
||||||
const inputFieldList = ref<any[]>([])
|
const inputFieldList = ref<any[]>([])
|
||||||
@ -129,6 +133,7 @@ function openChangeTitleDialog() {
|
|||||||
function deleteField(index: any) {
|
function deleteField(index: any) {
|
||||||
inputFieldList.value.splice(index, 1)
|
inputFieldList.value.splice(index, 1)
|
||||||
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
||||||
|
onDragHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshFieldList(data: any, index: any) {
|
function refreshFieldList(data: any, index: any) {
|
||||||
@ -153,6 +158,7 @@ function refreshFieldList(data: any, index: any) {
|
|||||||
}
|
}
|
||||||
UserFieldFormDialogRef.value.close()
|
UserFieldFormDialogRef.value.close()
|
||||||
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
||||||
|
onDragHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshFieldTitle(data: any) {
|
function refreshFieldTitle(data: any) {
|
||||||
@ -178,6 +184,29 @@ const getDefaultValue = (row: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDragHandle() {
|
||||||
|
if (!tableRef.value) return
|
||||||
|
|
||||||
|
// 获取表格的 tbody DOM 元素
|
||||||
|
const wrapper = tableRef.value.$el as HTMLElement
|
||||||
|
const tbody = wrapper.querySelector('.el-table__body-wrapper tbody')
|
||||||
|
if (!tbody) return
|
||||||
|
// 初始化 Sortable
|
||||||
|
Sortable.create(tbody, {
|
||||||
|
animation: 150,
|
||||||
|
ghostClass: 'ghost-row',
|
||||||
|
onEnd: (evt) => {
|
||||||
|
if (evt.oldIndex === undefined || evt.newIndex === undefined) return
|
||||||
|
// 更新数据顺序
|
||||||
|
const items = [...inputFieldList.value]
|
||||||
|
const [movedItem] = items.splice(evt.oldIndex, 1)
|
||||||
|
items.splice(evt.newIndex, 0, movedItem)
|
||||||
|
inputFieldList.value = items
|
||||||
|
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!props.nodeModel.properties.user_input_field_list) {
|
if (!props.nodeModel.properties.user_input_field_list) {
|
||||||
if (props.nodeModel.properties.input_field_list) {
|
if (props.nodeModel.properties.input_field_list) {
|
||||||
@ -211,6 +240,7 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
set(props.nodeModel.properties, 'user_input_field_list', inputFieldList)
|
set(props.nodeModel.properties, 'user_input_field_list', inputFieldList)
|
||||||
set(props.nodeModel.properties, 'user_input_config', inputFieldConfig)
|
set(props.nodeModel.properties, 'user_input_config', inputFieldConfig)
|
||||||
|
onDragHandle()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user