From 493b04538fe3a156018c92e6ff22eaa55ea7954e Mon Sep 17 00:00:00 2001 From: IMaster Date: Mon, 4 Nov 2024 10:15:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Web/src/views/system/codeG?= =?UTF-8?q?en/component/genConfigDialog.vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化排序,并修复无法保存修改后数据的的bug。 --- .../codeGen/component/genConfigDialog.vue | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/Web/src/views/system/codeGen/component/genConfigDialog.vue b/Web/src/views/system/codeGen/component/genConfigDialog.vue index 32078965..4715a6db 100644 --- a/Web/src/views/system/codeGen/component/genConfigDialog.vue +++ b/Web/src/views/system/codeGen/component/genConfigDialog.vue @@ -231,29 +231,13 @@ const rowDrop = () => { const fullData = xGrid.value?.getTableData().fullData || []; const newIndex = sortableEvent.newIndex as number; const oldIndex = sortableEvent.oldIndex as number; - // 往前移动 - if (oldIndex > newIndex) { - const moveRow = fullData?.find((e) => e.orderNo == oldIndex + 1); - for (let i = oldIndex; i > newIndex; i--) { - const row = fullData?.find((e) => e.orderNo == i); - if (row) { - row.orderNo += 1; - } - } - moveRow.orderNo = newIndex + 1; - } else { - // 往后移动 - const moveRow = fullData?.find((e) => e.orderNo == oldIndex + 1); - for (let i = oldIndex; i < newIndex; i++) { - const row = fullData?.find((e) => e.orderNo == i + 2); - if (row) { - row.orderNo -= 1; - } - } - moveRow.orderNo = newIndex + 1; - } + var orderNo = fullData[newIndex - 1].orderNo; + fullData[newIndex].orderNo = orderNo! + 10; + const currentRow = fullData.splice(oldIndex, 1)[0]; + fullData.splice(newIndex, 0, currentRow); + fullData.forEach((u, i) => (u.orderNo = 100 + i * 10)); // 更新表格数据 - xGrid.value?.updateData(); + xGrid.value?.loadData(fullData); }, }); };