Ver Fonte

fix(FormTable): Invert select bug (#3412)

bowen há 1 ano atrás
pai
commit
595b1ce680
1 ficheiros alterados com 6 adições e 4 exclusões
  1. 6 4
      src/views/demo/table/FormTable.vue

+ 6 - 4
src/views/demo/table/FormTable.vue

@@ -61,10 +61,12 @@
   function onSelect(record, selected) {
     if (selected) {
       state.selectedRowKeys.push(record.id);
-    } else {
-      state.selectedRowKeys
-        .splice(0)
-        .push(...state.selectedRowKeys.filter((id) => id !== record.id));
+      return;
+    }
+    const delIdx = state.selectedRowKeys.indexOf(record.id);
+
+    if (delIdx !== -1) {
+      state.selectedRowKeys.splice(delIdx, 1);
     }
   }