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); + } } }); };