From 12cb42c0c5d6c1a9dc17e923dad2338fd6ba6d55 Mon Sep 17 00:00:00 2001 From: wanglihui <1769794040@qq.com> Date: Sun, 14 Jan 2024 15:37:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=88=86=E7=BB=84=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/components/Banner.vue | 11 +++++++++-- .../configuration/components/CustomGroup.vue | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/pages/workplace/configuration/components/Banner.vue b/src/pages/workplace/configuration/components/Banner.vue index 7eb4695..0c11773 100644 --- a/src/pages/workplace/configuration/components/Banner.vue +++ b/src/pages/workplace/configuration/components/Banner.vue @@ -235,11 +235,18 @@ const tableDrop = () => { Sortable.create(document.querySelector('.el-table__body-wrapper tbody') as HTMLElement, { handle: '.bd-drag', animation: 300, - onEnd({ newIndex, oldIndex }: any) { + onEnd(evt: any) { + const { newIndex, oldIndex } = evt; const tablesList = [...tableData.value]; const currRow = tablesList.splice(oldIndex as number, 1)[0]; tablesList.splice(newIndex as number, 0, currRow); - bannerReorder(tablesList[newIndex].banner_no, tablesList[oldIndex].banner_no); + if (oldIndex > newIndex) { + // 向上排序 + bannerReorder(tablesList[newIndex].banner_no, tablesList[oldIndex].banner_no); + } else { + // 向下排序 + bannerReorder(tablesList[oldIndex].banner_no, tablesList[newIndex].banner_no); + } } }); }; diff --git a/src/pages/workplace/configuration/components/CustomGroup.vue b/src/pages/workplace/configuration/components/CustomGroup.vue index 96a170b..8539a6b 100644 --- a/src/pages/workplace/configuration/components/CustomGroup.vue +++ b/src/pages/workplace/configuration/components/CustomGroup.vue @@ -170,7 +170,13 @@ const treesDrop = () => { const treesList = [...dataTree.value]; const currRow = treesList.splice(oldIndex as number, 1)[0]; treesList.splice(newIndex as number, 0, currRow); - categoryReorder(treesList[newIndex].category_no, treesList[oldIndex].category_no); + if (oldIndex > newIndex) { + // 向上排序 + categoryReorder(treesList[newIndex].category_no, treesList[oldIndex].category_no); + } else { + // 向下排序 + categoryReorder(treesList[oldIndex].category_no, treesList[newIndex].category_no); + } } }); }; @@ -378,7 +384,13 @@ const tableDrop = () => { const currRow = tablesList.splice(oldIndex as number, 1)[0]; tablesList.splice(newIndex as number, 0, currRow); tableData.value = tablesList; - categorysAppsReorder(tablesList[newIndex].app_id, tablesList[oldIndex].app_id); + if (oldIndex > newIndex) { + // 向上排序 + categorysAppsReorder(tablesList[newIndex].app_id, tablesList[oldIndex].app_id); + } else { + // 向下排序 + categorysAppsReorder(tablesList[oldIndex].app_id, tablesList[newIndex].app_id); + } } }); };