Explorar o código

修改显示问题

lex hai 1 ano
pai
achega
e4f49a0035
Modificáronse 1 ficheiros con 25 adicións e 15 borrados
  1. 25 15
      src/views/courseware-config/add-teacher.vue

+ 25 - 15
src/views/courseware-config/add-teacher.vue

@@ -166,7 +166,7 @@ export default {
       this.$refs.searchForm.resetFields();
       this.search();
     },
-    onFormatSelectData(arr) {
+    onFormatSelectData(arr, row) {
       try {
         let currentPageList = [];
         const otherPageList = [];
@@ -179,18 +179,28 @@ export default {
         });
 
         const lastPage = [];
-        if (arr.length > 0) {
-          arr.forEach(item => {
-            const index = currentPageList.findIndex(
-              child => child.id === item.id
-            );
-            if (index === -1) {
-              lastPage.push(item);
-            }
-          });
+        if (row?.id) {
+          const index = currentPageList.findIndex(child => child.id === row.id);
+          if (index === -1) {
+            lastPage.push(row);
+          } else {
+            currentPageList.splice(index, 1);
+          }
         } else {
-          currentPageList = [];
+          if (arr.length > 0) {
+            arr.forEach(item => {
+              const index = currentPageList.findIndex(
+                child => child.id === item.id
+              );
+              if (index === -1) {
+                lastPage.push(item);
+              }
+            });
+          } else {
+            currentPageList = [];
+          }
         }
+
         this.activeChiose = [
           ...lastPage,
           ...otherPageList,
@@ -198,12 +208,12 @@ export default {
         ].sort((a, b) => a.id - b.id);
       } catch (e) {}
     },
-    onTableSelect(arr) {
-      // console.log(arr, "onTableSelect");
-      this.onFormatSelectData(arr);
+    onTableSelect(arr, row) {
+      console.log(arr, "onTableSelect", row);
+      this.onFormatSelectData(arr, row);
     },
     handleSelectionChange(arr) {
-      // console.log(arr, "val");
+      console.log(arr, "val");
       this.onFormatSelectData(arr);
     },
     async getList() {