Просмотр исходного кода

库表管理时,新增表的时候,上移或下移列出现索引越界问题

轻风2016 1 год назад
Родитель
Сommit
464f2a8d3b
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      Web/src/views/system/database/component/addTable.vue

+ 7 - 0
Web/src/views/system/database/component/addTable.vue

@@ -300,6 +300,13 @@ function handleColDown(record: EditRecordRow, index: number) {
 }
 
 function ChangeExForArray(index1: number, index2: number, array: Array<EditRecordRow>) {
+	let maxIndex = state.tableData.length - 1;//最大索引
+    if (index2 > maxIndex) {
+        index2 = 0;
+    };
+    if (index2 < 0) {
+        index2 = maxIndex;
+    }
 	let temp = array[index1];
 	array[index1] = array[index2];
 	array[index2] = temp;