소스 검색

1、权限管理-角色视图-资源列表递归

赖云浩 4 년 전
부모
커밋
49ab1953c3
3개의 변경된 파일77개의 추가작업 그리고 13개의 파일을 삭제
  1. 9 0
      src/api/application.js
  2. 32 1
      src/pages/application-manage/app-manage/index.vue
  3. 36 12
      src/pages/authorization-manage/author-role-manage.vue

+ 9 - 0
src/api/application.js

@@ -17,3 +17,12 @@ export function detail(id) {
 export function select(data) {
     return axios.post(`/appsvr/app/factorRadio`, data);
 }
+
+// 获取资源
+export function getRemoteRource(data) {
+    return axios.post(`/applicationManagement/resource/getResourceRemote`, data)
+}
+// 同步资源
+export function syncRource() {
+    return axios.get(`/applicationManagement/resource/sync`)
+}

+ 32 - 1
src/pages/application-manage/app-manage/index.vue

@@ -92,6 +92,8 @@
                     <dg-button type="primary" icon="el-icon-circle-plus-outline" @click="handleAddDialog"
                         >新增</dg-button
                     >
+                    <dg-button type="primary" @click="handleRemoteRource">资源获取</dg-button>
+                    <dg-button type="primary" @click="handleSyncRource">资源同步</dg-button>
                 </div>
                 <Table ref="myTable" :url="tableUrl" :headerData="titleData" :condition="formData" :lazyLoad="true">
                     <dg-table-column fixed="right" label="操作" width="120" align="center">
@@ -118,13 +120,21 @@
 <script>
 import Tree from "@/pages/common/tree";
 import Table from "@/pages/common/table";
-import { appRestApi, select } from "@/api/application";
+import { appRestApi, select,getRemoteRource,syncRource } from "@/api/application";
 import Editor from "./editor";
 import Detail from "./detail";
 const editorArea = ["960px", "680px"];
+
+import {mapGetters} from "vuex";
+
 export default {
     name: "appMSG",
     components: { Tree, Table },
+    computed:{
+        ...mapGetters(['user'])
+    },
+    mounted(){
+    },
     data() {
         const that = this;
         return {
@@ -295,6 +305,27 @@ export default {
                         that.fail(error); // 直接提示后端错误信息
                     });
             });
+        },
+
+        // 获取资源
+        handleRemoteRource(){
+            const that = this;
+            const queryParams = {
+                listingAll:true
+            }
+            getRemoteRource(queryParams).then(res => {
+                that.$message.success("资源获取成功!");
+            }).catch(err => {
+                that.$message.error(err);
+            })
+        },
+        handleSyncRource(){
+            const that = this;
+            syncRource().then(res => {
+                 that.$message.success("资源同步成功!");
+            }).catch(err => {
+                that.$message.error(err);
+            })
         }
     },
     created() {

+ 36 - 12
src/pages/authorization-manage/author-role-manage.vue

@@ -298,25 +298,38 @@ export default {
                 });
         },
         select(selection, row) {
+            const that = this;
             if (
                 selection.some(el => {
                     return row.id === el.id;
                 })
             ) {
                 if (row.children) {
-                    row.children.map(j => {
-                        this.toggleSelection(j, true);
-                    });
+                    loopRowChild(row.children,true);
+                    // row.children.map(j => {
+                    //     this.toggleSelection(j, true);
+                    // });
                 }
             } else {
                 if (row.children) {
-                    row.children.map(j => {
-                        this.toggleSelection(j, false);
-                    });
+                    // row.children.map(j => {
+                    //     this.toggleSelection(j, false);
+                    // });
+                    loopRowChild(row.children,false);
                 }
             }
+
+            function loopRowChild(rows,flag){
+                rows.map(item => {
+                    if(item.children){
+                        loopRowChild(item.children,flag)
+                    }
+                    that.toggleSelection(item, flag);
+                })
+            }
         },
         selectAll(selection) {
+            const that = this;
             // tabledata第一层只要有在selection里面就是全选
             const isSelect = selection.some(el => {
                 const tableDataIds = this.tableData.map(j => j.id);
@@ -327,21 +340,32 @@ export default {
                 const selectIds = selection.map(j => j.id);
                 return selectIds.includes(el.id);
             });
+
+            function loopRowChild(rows,flag){
+                rows.map(item => {
+                    if(item.children){
+                        loopRowChild(item.children,flag)
+                    }
+                    that.toggleSelection(item, flag);
+                })
+            }
             if (isSelect) {
                 selection.map(el => {
                     if (el.children) {
-                        el.children.map(j => {
-                            this.toggleSelection(j, true);
-                        });
+                        // el.children.map(j => {
+                        //     this.toggleSelection(j, true);
+                        // });
+                        loopRowChild(el.children,true)
                     }
                 });
             }
             if (isCancel) {
                 this.tableData.map(el => {
                     if (el.children) {
-                        el.children.map(j => {
-                            this.toggleSelection(j, false);
-                        });
+                        // el.children.map(j => {
+                        //     this.toggleSelection(j, false);
+                        // });
+                        loopRowChild(el.children,false)
                     }
                 });
             }