提交 84de88b7 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

资源权限前端功能

上级 26ee865c
......@@ -44,4 +44,19 @@ export const createAuthority = (data) => {
method: 'post',
data
})
}
// @Summary 设置角色资源权限
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body sysModel.SysAuthority true "设置角色资源权限"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
// @Router /authority/setDataAuthority [post]
export const setDataAuthority = (data) => {
return service({
url: "/authority/setDataAuthority",
method: 'post',
data
})
}
\ No newline at end of file
......@@ -49,6 +49,9 @@
<el-tab-pane label="角色api">
<apis :row="activeRow" />
</el-tab-pane>
<el-tab-pane label="资源权限">
<Datas :row="activeRow" :authority="tableData" />
</el-tab-pane>
</el-tabs>
</el-drawer>
</div>
......@@ -65,6 +68,7 @@ import {
import Menus from '@/view/superAdmin/authority/components/menus'
import Apis from '@/view/superAdmin/authority/components/apis'
import Datas from '@/view/superAdmin/authority/components/datas'
import infoList from '@/components/mixins/infoList'
export default {
......@@ -88,7 +92,8 @@ export default {
},
components: {
Menus,
Apis
Apis,
Datas
},
methods: {
opdendrawer(row) {
......
......@@ -61,14 +61,6 @@ export default {
}
return apiTree
},
// 关联用户api关系
async addAuthApi(row) {
const res = await getPolicyPathByAuthorityId({
authorityId: this.row.authorityId
})
this.activeUserId = this.row.authorityId
this.apiTreeIds = res.data.paths || []
},
// 关联关系确定
async authApiEnter() {
const checkArr = this.$refs.apiTree.getCheckedKeys(true)
......
<template>
<div>
<div class="clearflex">
<el-button @click="authDataEnter" class="fl-right" size="small" type="primary">确 定</el-button>
</div>
<el-checkbox-group v-model="dataAuthorityId" @change="selectAuthority">
<el-checkbox v-for="(item,key) in authoritys" :label="item" :key="key">{{item.authorityName}}</el-checkbox>
</el-checkbox-group>
</div>
</template>
<script>
import {setDataAuthority} from '@/api/authority'
export default {
name: 'Datas',
data() {
return {
authoritys:[],
dataAuthorityId:[]
}
},
props: {
row: {
default: function() {
return {}
},
type: Object
},
authority: {
default: function() {
return {}
},
type: Array
}
},
methods:{
// 提交
async authDataEnter(){
const res = await setDataAuthority(this.row)
if(res.success){
this.$message({ type: 'success', message: res.msg })
}
},
// 平铺角色
roundAuthority(authoritys){
authoritys&&authoritys.map(item=>{
const obj = {}
obj.ID = item.ID
obj.authorityName = item.authorityName
this.authoritys.push(obj)
if(item.children.length){
this.roundAuthority(item.children)
}
})
},
// 选择
selectAuthority(){
this.row.dataAuthorityId = this.dataAuthorityId
}
},
created() {
this.authoritys = []
this.dataAuthorityId = []
this.roundAuthority(this.authority)
this.row.dataAuthorityId&&this.row.dataAuthorityId.map(item=>{
const obj = this.authoritys&&this.authoritys.filter(au=>au.ID === item.ID)&&this.authoritys.filter(au=>au.ID === item.ID)[0]
this.dataAuthorityId.push(obj)
})
}
}
</script>
<style lang="less">
</style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册