浏览代码

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

轻风2016 2 年之前
父节点
当前提交
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;