更新 Web/src/views/system/codeGen/component/genConfigDialog.vue

优化排序,并修复无法保存修改后数据的的bug。
This commit is contained in:
IMaster 2024-11-04 10:15:26 +08:00
parent ce5673b1fc
commit 493b04538f

View File

@ -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);
},
});
};