cxmo 1 жил өмнө
parent
commit
689a030d75

+ 34 - 4
src/views/system_manage/authManage.vue

@@ -2,6 +2,7 @@
     import { ref, onMounted, watch } from 'vue'
     import { ref, onMounted, watch } from 'vue'
     import { useRoute } from 'vue-router'
     import { useRoute } from 'vue-router'
     import { departInterence } from '@/api/api.js'
     import { departInterence } from '@/api/api.js'
+    import { ElMessage } from 'element-plus'
 
 
     const route = useRoute()
     const route = useRoute()
 
 
@@ -112,16 +113,45 @@
         })
         })
     }
     }
     //菜单权限 全选
     //菜单权限 全选
-    function handleCheckAll(){
-
+    function handleCheckAll(item){
+        // 取到所有的子菜单id
+        let ids = item.Child.map(item =>{
+            return item.MenuId
+        })
+        item.CheckList = item.checkAll ? ids : [];	
+        item.isIndeterminate = false;
     }
     }
     //菜单权限 复选框
     //菜单权限 复选框
-    function handleChecked(){}
+    function handleChecked(item){
+        let len = item.CheckList.length;
+        item.checkAll = len === item.Child.length;
+        item.isIndeterminate = len > 0 && len < item.Child.length;
+    }
     //功能复选框 (原项目里这个函数就是空的...)
     //功能复选框 (原项目里这个函数就是空的...)
     function handleChecked2(){}
     function handleChecked2(){}
 
 
     //保存权限
     //保存权限
-    function saveAuth(){}
+    function saveAuth(){
+        let checkArr = [];
+        authList.value.forEach(item => {
+            if(item.CheckList.length) {
+                checkArr.push(item.MenuId)
+                checkArr.push(item.CheckList)
+            }
+        })
+        let MenuButtonIdStr = Array.from(new Set(btnCheck.value));//去重
+        let params = {
+            MenuIdStr:checkArr.flat(2).join(','),
+            RoleId:Number(role.value),
+            MenuButtonIdStr:MenuButtonIdStr.join(',')
+        }
+        departInterence.saveAuth(params).then(res => {
+            if(res.Ret === 200) {
+                ElMessage.success(res.Msg);
+                getBtnList();
+            }
+        })
+    }
 
 
     onMounted(() => {
     onMounted(() => {
         getRoles()
         getRoles()