李志伟 3 år sedan
förälder
incheckning
5d196f0e27
1 ändrade filer med 32 tillägg och 32 borttagningar
  1. 32
    32
      src/pages/SystemManagement/UserRights/index.jsx

+ 32
- 32
src/pages/SystemManagement/UserRights/index.jsx Visa fil

@@ -126,24 +126,24 @@ export default (props) => {
126 126
   // 选择左侧的菜单多选框
127 127
   const onCheck = (checkedKeys, info) => {
128 128
     //当前选中数组
129
-    let list2;
130
-    let list3 = [...rolePermissionList];
129
+    let list;
130
+    let list2 = [...rolePermissionList];
131 131
     //权限数据
132
-    var list4 = list3.filter((item) => item.split(':').length == 2);
132
+    var list3 = list2.filter((item) => item.split(':').length == 2);
133 133
     if (info.checked) {
134 134
       if (info.node.children) {
135
-        list2 = treeToArray(info.node).map((item) => {
135
+        list = treeToArray(info.node).map((item) => {
136 136
           return item.key;
137 137
         });
138
-        list2.forEach((item) => {
139
-          if (list3.indexOf(item) === -1) {
140
-            list3.push(item);
138
+        list.forEach((item) => {
139
+          if (list2.indexOf(item) === -1) {
140
+            list2.push(item);
141 141
           }
142 142
         });
143 143
       } else {
144
-        list2 = info.node.key;
145
-        if (list3.indexOf(list2) === -1) {
146
-          list3.push(list2);
144
+        list = info.node.key;
145
+        if (list2.indexOf(list) === -1) {
146
+          list2.push(list);
147 147
         }
148 148
       }
149 149
     } else {
@@ -151,47 +151,47 @@ export default (props) => {
151 151
       setCurrentList([]);
152 152
       //取消菜单
153 153
       if (info.node.children) {
154
-        list2 = treeToArray(info.node).map((item) => {
154
+        list = treeToArray(info.node).map((item) => {
155 155
           return item.key;
156 156
         });
157
-        list2.forEach((item) => {
158
-          if (list3.indexOf(item) !== -1) {
159
-            list3.splice(list3.indexOf(item), 1);
160
-            list4.map((v) => {
157
+        list.forEach((item) => {
158
+          if (list2.indexOf(item) !== -1) {
159
+            list2.splice(list2.indexOf(item), 1);
160
+            list3.map((v) => {
161 161
               if (v.split(':')[0] == item) {
162
-                list3.splice(list3.indexOf(v), 1);
162
+                list2.splice(list2.indexOf(v), 1);
163 163
               }
164 164
             });
165 165
           }
166 166
         });
167 167
       } else {
168
-        list2 = info.node.key;
169
-        if (list3.indexOf(list2) !== -1) {
170
-          list3.splice(list3.indexOf(list2), 1);
171
-          list4.map((v) => {
172
-            if (v.split(':')[0] == list2) {
173
-              list3.splice(list3.indexOf(list2), 1);
168
+        list = info.node.key;
169
+        if (list2.indexOf(list) !== -1) {
170
+          list2.splice(list2.indexOf(list), 1);
171
+          list3.map((v) => {
172
+            if (v.split(':')[0] == list) {
173
+              list2.splice(list2.indexOf(list), 1);
174 174
             }
175 175
           });
176 176
         }
177 177
       }
178 178
     }
179
-    if (list3.length < checkedKeys.length + list4.length) {
179
+    if (list2.length < checkedKeys.length + list3.length) {
180 180
       // 说明父节点是因为子节点全部选中才选中实际上菜单数组中没有父节点的数据
181 181
       checkedKeys.forEach((item) => {
182
-        if (list3.indexOf(item) === -1) {
183
-          list3.push(item);
182
+        if (list2.indexOf(item) === -1) {
183
+          list2.push(item);
184 184
         }
185 185
       });
186
-    } else if (list3.length > checkedKeys.length + list4.length) {
186
+    } else if (list2.length > checkedKeys.length + list3.length) {
187 187
       // 说明父节点是因为子节点全部取消才取消实际上菜单数组中多了父节点的数据
188
-      list3.forEach((item) => {
189
-        if (checkedKeys.indexOf(item) === -1 && list4.indexOf(item) === -1) {
190
-          list3.splice(list3.indexOf(item), 1);
188
+      list2.forEach((item) => {
189
+        if (checkedKeys.indexOf(item) === -1 && list3.indexOf(item) === -1) {
190
+          list2.splice(list2.indexOf(item), 1);
191 191
         }
192 192
       });
193 193
     }
194
-    setRolePermissionList(list3);
194
+    setRolePermissionList(list2);
195 195
   };
196 196
   // 选择左侧菜单文字
197 197
   const onSelect = (checkedKeys, info) => {
@@ -219,8 +219,8 @@ export default (props) => {
219 219
     }
220 220
     setPLoading(true);
221 221
     //菜单数据
222
-    var list4 = rolePermissionList.filter((item) => item.split(':').length !== 2);
223
-    list4.forEach((item) => {
222
+    var list2 = rolePermissionList.filter((item) => item.split(':').length !== 2);
223
+    list2.forEach((item) => {
224 224
       setParnentList(item);
225 225
     });
226 226