智慧农业后台管理页面
guoshilong
2022-09-05 d89fc6089053516431b18c8c8a913ce19d63234a
角色配置系统权限,数据权限和接口权限取消
2 files modified
58 ■■■■ changed files
src/api/system/role.js 5 ●●●●● patch | view | raw | blame | history
src/views/authority/role.vue 53 ●●●● patch | view | raw | blame | history
src/api/system/role.js
@@ -18,7 +18,7 @@
  })
}
export const grant = (roleIds, menuIds, dataScopeIds, apiScopeIds) => {
export const grant = (roleIds, menuIds, dataScopeIds, apiScopeIds,systemIds) => {
  return request({
    url: '/api/blade-system/role/grant',
    method: 'post',
@@ -26,7 +26,8 @@
      roleIds,
      menuIds,
      dataScopeIds,
      apiScopeIds
      apiScopeIds,
      systemIds
    }
  })
}
src/views/authority/role.vue
@@ -38,7 +38,7 @@
            </template>
        </avue-crud>
        <el-dialog title="角色权限配置" append-to-body :visible.sync="box" width="345px">
            <el-tabs type="border-card">
            <el-tabs stretch="true" type="border-card">
                <el-tab-pane label="菜单权限">
                    <el-tree
                        :data="menuGrantList"
@@ -49,7 +49,14 @@
                        :props="props"
                    ></el-tree>
                </el-tab-pane>
                <el-tab-pane label="数据权限">
                <el-tab-pane label="系统权限">
                    <!-- <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox> -->
                    <div style="margin: 15px 0;"></div>
                    <el-checkbox-group v-model="checkedSystem" @change="handleCheckedChange">
                        <el-checkbox v-for="system in systemList" :label="system.dictKey" :key="system.dictKey" >{{system.dictValue}}</el-checkbox>
                    </el-checkbox-group>
                </el-tab-pane>
                <!-- <el-tab-pane label="数据权限">
                    <el-tree
                        :data="dataScopeGrantList"
                        show-checkbox
@@ -68,7 +75,7 @@
                        :default-checked-keys="apiScopeTreeObj"
                        :props="props"
                    ></el-tree>
                </el-tab-pane>
                </el-tab-pane> -->
            </el-tabs>
            <span slot="footer" class="dialog-footer">
@@ -81,10 +88,11 @@
<script>
import { add, getList, getRole, getRoleTreeById, grant, grantTree, remove, update } from "@/api/system/role"
import {getDictionary} from "@/api/system/dictbiz"
import { mapGetters } from "vuex"
import website from '@/config/website'
export default {
    data () {
        return {
            form: {},
@@ -204,7 +212,11 @@
                    }
                ]
            },
            data: []
            data: [],
            checkAll: false,
            checkedSystem: [],
            systemList: [],
            isIndeterminate: true
        }
    },
    computed: {
@@ -242,9 +254,12 @@
        },
        submit () {
            const menuList = this.$refs.treeMenu.getCheckedKeys()
            const dataScopeList = this.$refs.treeDataScope.getCheckedKeys()
            const apiScopeList = this.$refs.treeApiScope.getCheckedKeys()
            grant(this.idsArray, menuList, dataScopeList, apiScopeList).then(() => {
            // const dataScopeList = this.$refs.treeDataScope.getCheckedKeys()
            // const apiScopeList = this.$refs.treeApiScope.getCheckedKeys()
            const dataScopeList = []
            const apiScopeList = []
            const systemIds = this.checkedSystem.join(",")
            grant(this.idsArray, menuList, dataScopeList, apiScopeList,systemIds).then(() => {
                this.box = false
                this.$message({
                    type: "success",
@@ -252,6 +267,7 @@
                })
                this.onLoad(this.page)
            })
        },
        rowSave (row, done, loading) {
            add(row).then(() => {
@@ -333,13 +349,25 @@
                    this.menuGrantList = res.data.data.menu
                    this.dataScopeGrantList = res.data.data.dataScope
                    this.apiScopeGrantList = res.data.data.apiScope
                    getDictionary({code:"system"}).then(res=>{
                        if(res.data.code == 200){
                            this.systemList = res.data.data
                        }
                    })
                    getRole(this.ids).then(res => {
                        if(res.data.data.systemIds){
                            this.checkedSystem = res.data.data.systemIds.split(",")
                        }else{
                            this.checkedSystem = []
                        }
                        this.menuTreeObj = res.data.data.menu
                        this.dataScopeTreeObj = res.data.data.dataScope
                        this.apiScopeTreeObj = res.data.data.apiScope
                        this.box = true
                    })
                })
        },
        handleDelete () {
            if (this.selectionList.length === 0) {
@@ -379,7 +407,14 @@
                this.loading = false
                this.selectionClear()
            })
        }
        },
        handleCheckAllChange(val) {
            this.checkedSystem = val ? this.systemList : [];
            this.isIndeterminate = false;
        },
        handleCheckedChange(value) {
        },
    }
};
</script>