feat:创建数据表字段,支持拖拽
This commit is contained in:
parent
898ce1305d
commit
d995a8ce0d
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-table :data="structures" class="draggable">
|
<VueDraggable v-model="structures" target=".el-table__body tbody" animation="150" @end="onEnd">
|
||||||
|
<el-table :data="structures" class="draggable" :lazy="false">
|
||||||
<el-table-column prop="field" :label="$t('generate.schema.structure.field_name.name')" />
|
<el-table-column prop="field" :label="$t('generate.schema.structure.field_name.name')" />
|
||||||
<el-table-column prop="type" :label="$t('generate.schema.structure.type.name')">
|
<el-table-column prop="type" :label="$t('generate.schema.structure.type.name')">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@ -22,6 +23,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
</VueDraggable>
|
||||||
|
|
||||||
<div class="flex justify-end mt-4">
|
<div class="flex justify-end mt-4">
|
||||||
<el-button type="success" :icon="Plus" @click="addField">{{ $t('system.add') }}</el-button>
|
<el-button type="success" :icon="Plus" @click="addField">{{ $t('system.add') }}</el-button>
|
||||||
@ -95,14 +97,14 @@ import type { FormInstance } from 'element-plus'
|
|||||||
import Message from '/admin/support/message'
|
import Message from '/admin/support/message'
|
||||||
import http from '/admin/support/http'
|
import http from '/admin/support/http'
|
||||||
import { Code } from '/admin/enum/app'
|
import { Code } from '/admin/enum/app'
|
||||||
|
import { VueDraggable } from 'vue-draggable-plus'
|
||||||
|
|
||||||
const schemaStore = useSchemaStore()
|
const schemaStore = useSchemaStore()
|
||||||
const emits = defineEmits(['prev', 'next'])
|
const emits = defineEmits(['prev', 'next'])
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
|
|
||||||
const structures = computed(() => {
|
// 初始化
|
||||||
return schemaStore.getStructures
|
const structures = ref(schemaStore.getStructures)
|
||||||
})
|
|
||||||
|
|
||||||
const structure: Ref<Structure> = ref(schemaStore.initStructure())
|
const structure: Ref<Structure> = ref(schemaStore.initStructure())
|
||||||
// structure
|
// structure
|
||||||
@ -149,7 +151,11 @@ const next = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 调整数据结构
|
||||||
|
const onEnd = () => {
|
||||||
|
console.log(structures.value)
|
||||||
|
schemaStore.setStructures(structures.value)
|
||||||
|
}
|
||||||
const types: string[] = [
|
const types: string[] = [
|
||||||
'id',
|
'id',
|
||||||
'smallIncrements',
|
'smallIncrements',
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"terser": "^5.29.2",
|
"terser": "^5.29.2",
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.4.21",
|
||||||
|
"vue-draggable-plus": "^0.4.0",
|
||||||
"vue-i18n": "9",
|
"vue-i18n": "9",
|
||||||
"vue-router": "4.3.0",
|
"vue-router": "4.3.0",
|
||||||
"vuedraggable": "^2.24.3"
|
"vuedraggable": "^2.24.3"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user