mirror of
https://github.com/yangzongzhuan/RuoYi-Vue3.git
synced 2025-09-27 14:52:40 +00:00
代码生成列支持拖动排序
This commit is contained in:
@@ -6,13 +6,8 @@
|
|||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="字段信息" name="columnInfo">
|
<el-tab-pane label="字段信息" name="columnInfo">
|
||||||
<el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
|
<el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
|
||||||
<el-table-column label="序号" type="index" min-width="5%"/>
|
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
|
||||||
<el-table-column
|
<el-table-column label="字段列名" prop="columnName" min-width="10%" :show-overflow-tooltip="true" class-name="allowDrag"/>
|
||||||
label="字段列名"
|
|
||||||
prop="columnName"
|
|
||||||
min-width="10%"
|
|
||||||
:show-overflow-tooltip="true"
|
|
||||||
/>
|
|
||||||
<el-table-column label="字段描述" min-width="10%">
|
<el-table-column label="字段描述" min-width="10%">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input v-model="scope.row.columnComment"></el-input>
|
<el-input v-model="scope.row.columnComment"></el-input>
|
||||||
@@ -131,6 +126,7 @@ import { getGenTable, updateGenTable } from "@/api/tool/gen"
|
|||||||
import { optionselect as getDictOptionselect } from "@/api/system/dict/type"
|
import { optionselect as getDictOptionselect } from "@/api/system/dict/type"
|
||||||
import basicInfoForm from "./basicInfoForm"
|
import basicInfoForm from "./basicInfoForm"
|
||||||
import genInfoForm from "./genInfoForm"
|
import genInfoForm from "./genInfoForm"
|
||||||
|
import Sortable from 'sortablejs'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
@@ -197,4 +193,19 @@ function close() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
// 拖动排序
|
||||||
|
onMounted(() => {
|
||||||
|
const element = document.querySelector('.el-table__body > tbody')
|
||||||
|
Sortable.create(element, {
|
||||||
|
handle: ".allowDrag",
|
||||||
|
onEnd: (evt) => {
|
||||||
|
const targetRow = columns.value.splice(evt.oldIndex, 1)[0]
|
||||||
|
columns.value.splice(evt.newIndex, 0, targetRow)
|
||||||
|
for (const index in columns.value) {
|
||||||
|
columns.value[index].sort = parseInt(index) + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user