|
|
@ -6,12 +6,15 @@
|
|
|
|
<!-- 角色列表 -->
|
|
|
|
<!-- 角色列表 -->
|
|
|
|
<a-col :span="5">
|
|
|
|
<a-col :span="5">
|
|
|
|
<div class="cardTitle">所有角色</div>
|
|
|
|
<div class="cardTitle">所有角色</div>
|
|
|
|
<a-button class="add-btn" style="margin: 10px" @click="add.show = true"
|
|
|
|
<a-button
|
|
|
|
|
|
|
|
class="add-btn"
|
|
|
|
|
|
|
|
style="margin: 10px"
|
|
|
|
|
|
|
|
@click="add.show = true"
|
|
|
|
>新增角色</a-button
|
|
|
|
>新增角色</a-button
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<a-collapse accordion @change="rolechange">
|
|
|
|
<a-collapse accordion @change="rolechange">
|
|
|
|
<a-collapse-panel
|
|
|
|
<a-collapse-panel
|
|
|
|
v-for="(item, index) in roleList"
|
|
|
|
v-for="(item, index) in afterroleList"
|
|
|
|
:key="index"
|
|
|
|
:key="index"
|
|
|
|
:header="item.name"
|
|
|
|
:header="item.name"
|
|
|
|
>
|
|
|
|
>
|
|
|
@ -19,7 +22,7 @@
|
|
|
|
v-for="(rolechild, indexs) in item.childrenList"
|
|
|
|
v-for="(rolechild, indexs) in item.childrenList"
|
|
|
|
class="role-card"
|
|
|
|
class="role-card"
|
|
|
|
:key="indexs"
|
|
|
|
:key="indexs"
|
|
|
|
@click='rolechoose(rolechild.id)'
|
|
|
|
@click="rolechoose(rolechild.id)"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<span class="role-li">
|
|
|
|
<span class="role-li">
|
|
|
|
<span>{{ rolechild.name || "无" }}</span>
|
|
|
|
<span>{{ rolechild.name || "无" }}</span>
|
|
|
@ -77,35 +80,59 @@
|
|
|
|
<role-permissions></role-permissions>
|
|
|
|
<role-permissions></role-permissions>
|
|
|
|
</a-tab-pane>
|
|
|
|
</a-tab-pane>
|
|
|
|
</a-tabs>
|
|
|
|
</a-tabs>
|
|
|
|
<a-modal
|
|
|
|
<!-- <a-modal title="分配角色" :visible="send.show" @ok="sendSubmit" @cancel="sendClose">
|
|
|
|
|
|
|
|
请选择角色:<el-cascader :options="roleList" :show-all-levels="false" :props="{ multiple: true, checkStrictly: true,value:'id',label:'name', children:'childrenList',disabled:'disabled'}" clearable ></el-cascader></a-modal> -->
|
|
|
|
|
|
|
|
<!-- 分配角色 -->
|
|
|
|
|
|
|
|
<a-drawer
|
|
|
|
title="分配角色"
|
|
|
|
title="分配角色"
|
|
|
|
|
|
|
|
:width="720"
|
|
|
|
:visible="send.show"
|
|
|
|
:visible="send.show"
|
|
|
|
@ok="sendSubmit"
|
|
|
|
:body-style="{ paddingBottom: '80px' }"
|
|
|
|
@cancel="sendClose"
|
|
|
|
@close="sendClose"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
请选择角色:
|
|
|
|
<div class="drawer-content">
|
|
|
|
<el-cascader
|
|
|
|
<div class="cardTitle">所有角色</div>
|
|
|
|
:options="roleList"
|
|
|
|
<a-tree
|
|
|
|
:show-all-levels="false"
|
|
|
|
v-model="tree.checkedKeys"
|
|
|
|
:props="{ multiple: true, checkStrictly: true,value:'id',label:'name', children:'childrenList',disabled:'disabled'}"
|
|
|
|
checkable
|
|
|
|
clearable
|
|
|
|
:expanded-keys="tree.expandedKeys"
|
|
|
|
@change="multiRole"
|
|
|
|
:auto-expand-parent="tree.autoExpandParent"
|
|
|
|
></el-cascader>
|
|
|
|
:selected-keys="tree.selectedKeys"
|
|
|
|
</a-modal>
|
|
|
|
:tree-data="roleList"
|
|
|
|
|
|
|
|
:checkStrictly="true"
|
|
|
|
|
|
|
|
:replaceFields="{ children:'childrenList', title:'name', key:'id' }"
|
|
|
|
|
|
|
|
@expand="onExpand"
|
|
|
|
|
|
|
|
@select="onSelect"
|
|
|
|
|
|
|
|
@check="onCheck"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="drawer-footer">
|
|
|
|
|
|
|
|
<a-button :style="{ marginRight: '8px' }" @click="sendClose">
|
|
|
|
|
|
|
|
关闭
|
|
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
|
|
<a-button type="primary" @click="sendSubmit"> 提交 </a-button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</a-drawer>
|
|
|
|
|
|
|
|
<!-- 新增角色 -->
|
|
|
|
<add-form
|
|
|
|
<add-form
|
|
|
|
:show="add.show"
|
|
|
|
:show="add.show"
|
|
|
|
:title="add.title"
|
|
|
|
:title="add.title"
|
|
|
|
:list="roleList"
|
|
|
|
:list="roleList"
|
|
|
|
@close="addClose"
|
|
|
|
@close="addClose"
|
|
|
|
@success='success'
|
|
|
|
@success="success"
|
|
|
|
:id='add.editId'
|
|
|
|
:id="add.editId"
|
|
|
|
></add-form>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import { columns, pagination, searchForm } from "./depend/config.js";
|
|
|
|
import { columns, pagination, searchForm } from "./depend/config.js";
|
|
|
|
import { rolelist, listByRole, assignRoles, roleDel} from "@/api/basic/role";
|
|
|
|
import {
|
|
|
|
|
|
|
|
getrolelist,
|
|
|
|
|
|
|
|
listByRole,
|
|
|
|
|
|
|
|
assignRoles,
|
|
|
|
|
|
|
|
roleDel,
|
|
|
|
|
|
|
|
} from "@/api/basic/role";
|
|
|
|
import rolePermissions from "./depend/permissions.vue";
|
|
|
|
import rolePermissions from "./depend/permissions.vue";
|
|
|
|
import addForm from "./depend/form.vue";
|
|
|
|
import addForm from "./depend/form.vue";
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
@ -115,16 +142,23 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
|
|
|
|
tree:{
|
|
|
|
|
|
|
|
expandedKeys: [],
|
|
|
|
|
|
|
|
autoExpandParent: true,
|
|
|
|
|
|
|
|
checkedKeys: [],
|
|
|
|
|
|
|
|
selectedKeys: [],
|
|
|
|
|
|
|
|
},
|
|
|
|
pagination,
|
|
|
|
pagination,
|
|
|
|
columns,
|
|
|
|
columns,
|
|
|
|
searchForm,
|
|
|
|
searchForm,
|
|
|
|
add: {
|
|
|
|
add: {
|
|
|
|
show: false,
|
|
|
|
show: false,
|
|
|
|
title: "新增角色",
|
|
|
|
title: "新增角色",
|
|
|
|
editId:null
|
|
|
|
editId: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tableChoosed: [],
|
|
|
|
tableChoosed: [],
|
|
|
|
roleList: [],
|
|
|
|
roleList: [],
|
|
|
|
|
|
|
|
afterroleList: [],
|
|
|
|
tableData: [], // 数据
|
|
|
|
tableData: [], // 数据
|
|
|
|
ActionsList: [],
|
|
|
|
ActionsList: [],
|
|
|
|
send: {
|
|
|
|
send: {
|
|
|
@ -132,21 +166,24 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
form: {
|
|
|
|
form: {
|
|
|
|
manageUserId: undefined,
|
|
|
|
manageUserId: undefined,
|
|
|
|
roleId:''
|
|
|
|
roleId: "",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
roleList: {
|
|
|
|
afterroleList: {
|
|
|
|
handler(val) {
|
|
|
|
handler(val) {
|
|
|
|
val.forEach((ele, index) => {
|
|
|
|
val.forEach((ele, index) => {
|
|
|
|
if (ele.childrenList === undefined || ele.childrenList === null) {
|
|
|
|
if (ele.childrenList === undefined || ele.childrenList === null) {
|
|
|
|
this.roleList[index].childrenList = [{disabled:true}];
|
|
|
|
this.afterroleList[index].childrenList = [{ disabled: true }];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
deep: true,
|
|
|
|
deep: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'tree.checkedKeys'(val) {
|
|
|
|
|
|
|
|
// console.log('onCheck', val);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.getData();
|
|
|
|
this.getData();
|
|
|
@ -154,8 +191,9 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
getData() {
|
|
|
|
getData() {
|
|
|
|
rolelist().then((res) => {
|
|
|
|
getrolelist().then((res) => {
|
|
|
|
this.roleList = res.data;
|
|
|
|
this.roleList = res.data;
|
|
|
|
|
|
|
|
this.afterroleList = JSON.parse(JSON.stringify(this.roleList))
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getPeople() {
|
|
|
|
getPeople() {
|
|
|
@ -169,7 +207,7 @@ export default {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
success() {
|
|
|
|
success() {
|
|
|
|
this.getData()
|
|
|
|
this.getData();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
addClose() {
|
|
|
|
addClose() {
|
|
|
|
this.add.show = false;
|
|
|
|
this.add.show = false;
|
|
|
@ -177,8 +215,8 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 编辑角色
|
|
|
|
// 编辑角色
|
|
|
|
editRole(id) {
|
|
|
|
editRole(id) {
|
|
|
|
this.add.editId = id
|
|
|
|
this.add.editId = id;
|
|
|
|
this.add.title = '修改角色'
|
|
|
|
this.add.title = "修改角色";
|
|
|
|
this.add.show = true;
|
|
|
|
this.add.show = true;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 删除角色
|
|
|
|
// 删除角色
|
|
|
@ -189,17 +227,17 @@ export default {
|
|
|
|
// cancelText:'取消',
|
|
|
|
// cancelText:'取消',
|
|
|
|
icon: "",
|
|
|
|
icon: "",
|
|
|
|
onOk: () => {
|
|
|
|
onOk: () => {
|
|
|
|
roleDel({roleId:id}).then(res=>{
|
|
|
|
roleDel({ roleId: id }).then((res) => {
|
|
|
|
if (res.code === 200) {
|
|
|
|
if (res.code === 200) {
|
|
|
|
this.$message.success(res.msg)
|
|
|
|
this.$message.success(res.msg);
|
|
|
|
this.getData()
|
|
|
|
this.getData();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
rolechange(data) {
|
|
|
|
rolechange(data) {
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
this.searchForm.roleId = this.roleList[data].id;
|
|
|
|
this.searchForm.roleId = this.roleList[data].id;
|
|
|
@ -228,35 +266,65 @@ export default {
|
|
|
|
this.pagination = pager;
|
|
|
|
this.pagination = pager;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sendRole(data) {
|
|
|
|
sendRole(data) {
|
|
|
|
this.form.manageUserId = data.id
|
|
|
|
this.form.manageUserId = data.id;
|
|
|
|
this.send.show = true
|
|
|
|
let haveid = [];
|
|
|
|
},
|
|
|
|
for (let name of data.roleNameList) {
|
|
|
|
multiRole(data){
|
|
|
|
haveid.push(name.id);
|
|
|
|
let arr = []
|
|
|
|
|
|
|
|
for(let a of data){
|
|
|
|
|
|
|
|
if(a.length > 0){
|
|
|
|
|
|
|
|
for(let b of a){
|
|
|
|
|
|
|
|
arr.push(b);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
arr.push(a);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.tree.checkedKeys = haveid
|
|
|
|
|
|
|
|
this.send.show = true;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onExpand(expandedKeys) {
|
|
|
|
|
|
|
|
// console.log('onExpand', expandedKeys);
|
|
|
|
|
|
|
|
// if not set autoExpandParent to false, if children expanded, parent can not collapse.
|
|
|
|
|
|
|
|
// or, you can remove all expanded children keys.
|
|
|
|
|
|
|
|
this.tree.expandedKeys = expandedKeys;
|
|
|
|
|
|
|
|
this.tree.autoExpandParent = false;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onCheck(checkedKeys) {
|
|
|
|
|
|
|
|
const arr = []
|
|
|
|
|
|
|
|
this.tree.checkedKeys = checkedKeys;
|
|
|
|
|
|
|
|
for(let k of this.tree.checkedKeys.checked){
|
|
|
|
|
|
|
|
arr.push(k)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.form.roleId = arr.toString()
|
|
|
|
this.form.roleId = arr.toString()
|
|
|
|
|
|
|
|
console.log(this.form.roleId);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
onSelect(selectedKeys, info) {
|
|
|
|
|
|
|
|
console.log('onSelect', info);
|
|
|
|
|
|
|
|
this.tree.selectedKeys = selectedKeys;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// multiRole(data){
|
|
|
|
|
|
|
|
// console.log(data);
|
|
|
|
|
|
|
|
// let arr = []
|
|
|
|
|
|
|
|
// for(let a of data){
|
|
|
|
|
|
|
|
// if(a.length > 0){
|
|
|
|
|
|
|
|
// for(let b of a){
|
|
|
|
|
|
|
|
// arr.push(b);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }else{
|
|
|
|
|
|
|
|
// arr.push(a);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// this.form.roleId = arr.toString()
|
|
|
|
|
|
|
|
// },
|
|
|
|
async sendSubmit() {
|
|
|
|
async sendSubmit() {
|
|
|
|
const res = await assignRoles(this.form)
|
|
|
|
const res = await assignRoles(this.form);
|
|
|
|
if (res.code === 200) {
|
|
|
|
if (res.code === 200) {
|
|
|
|
this.$message.success(res.msg)
|
|
|
|
this.$message.success(res.msg);
|
|
|
|
this.getData()
|
|
|
|
this.getData();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sendClose() {
|
|
|
|
sendClose() {
|
|
|
|
this.form.manageUserId = undefined
|
|
|
|
this.form.manageUserId = undefined;
|
|
|
|
this.send.show = false
|
|
|
|
this.send.show = false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// sendClose(){
|
|
|
|
|
|
|
|
// this.form.manageUserId = undefined
|
|
|
|
|
|
|
|
// this.send.show = false
|
|
|
|
|
|
|
|
// },
|
|
|
|
Actions(data) {
|
|
|
|
Actions(data) {
|
|
|
|
console.log(data);
|
|
|
|
console.log(data);
|
|
|
|
},
|
|
|
|
},
|
|
|
|