From 158cd02e5c106e99d02a9dd134b0066e2181143e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Tue, 26 Apr 2022 08:55:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E8=A1=A8=E6=A0=BC=E6=96=B0=E5=A2=9E=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/tool/gen/editTable.vue | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/views/tool/gen/editTable.vue b/src/views/tool/gen/editTable.vue index 25f3b90..0904a83 100644 --- a/src/views/tool/gen/editTable.vue +++ b/src/views/tool/gen/editTable.vue @@ -125,7 +125,7 @@ import { listType } from '@/api/system/dict/type' import basicInfoForm from './basicInfoForm' import genInfoForm from './genInfoForm' import { useRoute } from 'vue-router' -// import Sortable from 'sortablejs' +import Sortable from 'sortablejs' // 选中选项卡的 name const activeName = ref('cloum') @@ -240,5 +240,27 @@ function nextFocus(row, index, e) { } /*************** table column 回车代码 end *************/ +// 拖动排序 +const tableSort = () => { + const tbody = document.querySelector('.el-table__body > tbody') + + Sortable.create(tbody, { + 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 + } + nextTick(() => { + console.log(columns.value) + }) + }, + }) +} + +onMounted(() => { + tableSort() +}) + handleQuery()