|
|
@ -4,61 +4,36 @@
|
|
|
|
<!-- 角色列表 -->
|
|
|
|
<!-- 角色列表 -->
|
|
|
|
<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
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<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 roleList"
|
|
|
|
:key="index"
|
|
|
|
:key="index"
|
|
|
|
:header="item.name"
|
|
|
|
:header="item.name"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<a-button
|
|
|
|
|
|
|
|
type="link"
|
|
|
|
|
|
|
|
icon="form"
|
|
|
|
|
|
|
|
slot="extra"
|
|
|
|
|
|
|
|
@click.stop="editRole(item.id)"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
|
|
type="link"
|
|
|
|
|
|
|
|
slot="extra"
|
|
|
|
|
|
|
|
style="color: #ff4d4f"
|
|
|
|
|
|
|
|
icon="delete"
|
|
|
|
|
|
|
|
@click.stop="delRole(item.id)"
|
|
|
|
|
|
|
|
></a-button>
|
|
|
|
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
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)"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<span class="role-li">
|
|
|
|
<span class="role-li">
|
|
|
|
<span>{{ rolechild.name || "无" }}</span>
|
|
|
|
<span>{{ rolechild.name || "无" }}</span>
|
|
|
|
<span v-show="rolechild.name"
|
|
|
|
<span v-show="rolechild.name"> </span>
|
|
|
|
><a-button type="link" icon="form" @click="editRole(rolechild.id)">
|
|
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
|
|
type="link"
|
|
|
|
|
|
|
|
style="color: #ff4d4f"
|
|
|
|
|
|
|
|
icon="delete"
|
|
|
|
|
|
|
|
@click="delRole(rolechild.id)"
|
|
|
|
|
|
|
|
></a-button
|
|
|
|
|
|
|
|
></span>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a-collapse-panel>
|
|
|
|
</a-collapse-panel>
|
|
|
|
</a-collapse>
|
|
|
|
</a-collapse>
|
|
|
|
</a-col>
|
|
|
|
</a-col>
|
|
|
|
<!-- 人员表格 -->
|
|
|
|
<!-- 功能表格 -->
|
|
|
|
<a-col :span="19">
|
|
|
|
<a-col :span="19">
|
|
|
|
<div class="treebox">
|
|
|
|
<div class="treebox">
|
|
|
|
<a-tree
|
|
|
|
<a-tree
|
|
|
|
class="tree"
|
|
|
|
class="tree"
|
|
|
|
v-model="checkedKeys"
|
|
|
|
v-model="checkedKeys"
|
|
|
|
checkable
|
|
|
|
checkable
|
|
|
|
|
|
|
|
checkStrictly
|
|
|
|
:replace-fields="replaceFields"
|
|
|
|
:replace-fields="replaceFields"
|
|
|
|
:expanded-keys="expandedKeys"
|
|
|
|
:expanded-keys="expandedKeys"
|
|
|
|
:auto-expand-parent="autoExpandParent"
|
|
|
|
|
|
|
|
:selected-keys="selectedKeys"
|
|
|
|
:selected-keys="selectedKeys"
|
|
|
|
:tree-data="menus"
|
|
|
|
:tree-data="menus"
|
|
|
|
@expand="onExpand"
|
|
|
|
@expand="onExpand"
|
|
|
@ -68,31 +43,40 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a-col>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</a-row>
|
|
|
|
<add-form
|
|
|
|
<a-drawer
|
|
|
|
:show="add.show"
|
|
|
|
title="操作"
|
|
|
|
:title="add.title"
|
|
|
|
placement="right"
|
|
|
|
:list="roleList"
|
|
|
|
:closable="false"
|
|
|
|
@close="addClose"
|
|
|
|
:visible="actions.show"
|
|
|
|
@success='success'
|
|
|
|
@close="onClose"
|
|
|
|
:id='add.editId'
|
|
|
|
>
|
|
|
|
></add-form>
|
|
|
|
<div class="content">
|
|
|
|
|
|
|
|
<div v-if="actionsList.length === 0">无可配置操作</div>
|
|
|
|
|
|
|
|
<a-checkbox
|
|
|
|
|
|
|
|
v-for="action in actionsList"
|
|
|
|
|
|
|
|
:checked="action.isCheck"
|
|
|
|
|
|
|
|
:key="action.id"
|
|
|
|
|
|
|
|
@change="onChange($event, action.id)"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{{ action.name }}</a-checkbox
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</a-drawer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import { getrolelist, FindAllMenus, roleDel } from "@/api/basic/role";
|
|
|
|
import {
|
|
|
|
import addForm from "./form.vue";
|
|
|
|
getrolelist,
|
|
|
|
|
|
|
|
FindAllMenus,
|
|
|
|
|
|
|
|
changeMenuShow,
|
|
|
|
|
|
|
|
getActions,
|
|
|
|
|
|
|
|
changeActions,
|
|
|
|
|
|
|
|
} from "@/api/basic/role";
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
|
|
|
|
addForm,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
add: {
|
|
|
|
roleId: null,
|
|
|
|
show: false,
|
|
|
|
|
|
|
|
title: "新增角色",
|
|
|
|
|
|
|
|
editId:null
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
roleList: [],
|
|
|
|
roleList: [],
|
|
|
|
expandedKeys: [],
|
|
|
|
expandedKeys: [],
|
|
|
|
replaceFields: {
|
|
|
|
replaceFields: {
|
|
|
@ -100,11 +84,13 @@ export default {
|
|
|
|
title: "name",
|
|
|
|
title: "name",
|
|
|
|
key: "id",
|
|
|
|
key: "id",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
autoExpandParent: true,
|
|
|
|
|
|
|
|
checkedKeys: [],
|
|
|
|
checkedKeys: [],
|
|
|
|
selectedKeys: [],
|
|
|
|
selectedKeys: [],
|
|
|
|
ActionsList: [],
|
|
|
|
menus: [], //页面菜单
|
|
|
|
menus: [],
|
|
|
|
actionsList: [], //操作
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
@ -116,60 +102,86 @@ export default {
|
|
|
|
this.roleList = res.data;
|
|
|
|
this.roleList = res.data;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
rolechoose(data) {
|
|
|
|
|
|
|
|
this.checkedKeys = [];
|
|
|
|
|
|
|
|
if (data !== undefined) {
|
|
|
|
|
|
|
|
this.roleId = data;
|
|
|
|
|
|
|
|
FindAllMenus({ roleId: this.roleId }).then((res) => {
|
|
|
|
|
|
|
|
this.menus = res.data;
|
|
|
|
|
|
|
|
this.defaultCheck(this.menus);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (data === undefined) {
|
|
|
|
|
|
|
|
this.roleId = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
rolechange(data) {
|
|
|
|
rolechange(data) {
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
this.searchForm.roleId = this.roleList[data].id;
|
|
|
|
this.checkedKeys = [];
|
|
|
|
FindAllMenus({ roleId: this.searchForm.roleId }).then((res) => {
|
|
|
|
this.roleId = this.roleList[data].id;
|
|
|
|
|
|
|
|
FindAllMenus({ roleId: this.roleId }).then((res) => {
|
|
|
|
this.menus = res.data;
|
|
|
|
this.menus = res.data;
|
|
|
|
|
|
|
|
this.defaultCheck(this.menus);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.searchForm.roleId = null;
|
|
|
|
this.roleId = null;
|
|
|
|
|
|
|
|
this.menus = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
success(){
|
|
|
|
defaultCheck(arr) {
|
|
|
|
this.getData()
|
|
|
|
for (let item of arr) {
|
|
|
|
},
|
|
|
|
if (item.isShow === true && item.childrenList !== null) {
|
|
|
|
addClose() {
|
|
|
|
this.checkedKeys.push(item.id);
|
|
|
|
this.add.show = false;
|
|
|
|
this.defaultCheck(item.childrenList);
|
|
|
|
this.add.editId = undefined;
|
|
|
|
} else if (item.isShow === true) {
|
|
|
|
},
|
|
|
|
this.checkedKeys.push(item.id);
|
|
|
|
// 编辑角色
|
|
|
|
|
|
|
|
editRole(id){
|
|
|
|
|
|
|
|
this.add.editId = id
|
|
|
|
|
|
|
|
this.add.title = '修改角色'
|
|
|
|
|
|
|
|
this.add.show= true;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// 删除角色
|
|
|
|
|
|
|
|
delRole(id) {
|
|
|
|
|
|
|
|
var vm = this;
|
|
|
|
|
|
|
|
this.$confirm({
|
|
|
|
|
|
|
|
title: "是否删除",
|
|
|
|
|
|
|
|
// okText:'删除',
|
|
|
|
|
|
|
|
// cancelText:'取消',
|
|
|
|
|
|
|
|
icon: "delete",
|
|
|
|
|
|
|
|
onOk:()=> {
|
|
|
|
|
|
|
|
roleDel({roleId:id}).then(res=>{
|
|
|
|
|
|
|
|
if(res.code === 200){
|
|
|
|
|
|
|
|
this.$message.success(res.msg)
|
|
|
|
|
|
|
|
this.getData()
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onExpand(expandedKeys) {
|
|
|
|
onExpand(expandedKeys) {
|
|
|
|
this.expandedKeys = expandedKeys;
|
|
|
|
this.expandedKeys = expandedKeys;
|
|
|
|
this.autoExpandParent = false;
|
|
|
|
this.autoExpandParent = false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onCheck(checkedKeys) {
|
|
|
|
onCheck(checkedKeys, e) {
|
|
|
|
// console.log('onCheck', checkedKeys);
|
|
|
|
|
|
|
|
this.checkedKeys = checkedKeys;
|
|
|
|
this.checkedKeys = checkedKeys;
|
|
|
|
|
|
|
|
// console.log(e.node.eventKey);
|
|
|
|
|
|
|
|
changeMenuShow({
|
|
|
|
|
|
|
|
roleId: this.roleId,
|
|
|
|
|
|
|
|
showMenusId: e.node.eventKey,
|
|
|
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
|
|
this.$message.success(res.msg);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onSelect(selectedKeys, info) {
|
|
|
|
onSelect(selectedKeys, info) {
|
|
|
|
// console.log('onSelect', info);
|
|
|
|
// console.log('onSelect', info);
|
|
|
|
this.selectedKeys = selectedKeys;
|
|
|
|
this.selectedKeys = selectedKeys;
|
|
|
|
|
|
|
|
// console.log(selectedKeys);
|
|
|
|
|
|
|
|
getActions({ roleId: this.roleId, menusId: this.selectedKeys[0] }).then(
|
|
|
|
|
|
|
|
(res) => {
|
|
|
|
|
|
|
|
this.actionsList = res.data;
|
|
|
|
|
|
|
|
this.actions.show = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onChange(e, id) {
|
|
|
|
|
|
|
|
changeActions({
|
|
|
|
|
|
|
|
roleId: this.roleId,
|
|
|
|
|
|
|
|
menusId: this.selectedKeys[0],
|
|
|
|
|
|
|
|
operationId: id,
|
|
|
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
|
|
this.$message.success(res.msg);
|
|
|
|
|
|
|
|
this.onSelect(this.selectedKeys)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onClose() {
|
|
|
|
|
|
|
|
this.actions.show = false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
@ -200,12 +212,11 @@ export default {
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/deep/.ant-tree ul {
|
|
|
|
.treebox {
|
|
|
|
width: 200px;
|
|
|
|
padding-left: 30px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.tree {
|
|
|
|
.tree {
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
margin-left: 20px;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.role-card {
|
|
|
|
.role-card {
|
|
|
|
line-height: 30px;
|
|
|
|
line-height: 30px;
|
|
|
@ -221,4 +232,7 @@ export default {
|
|
|
|
justify-content: space-between;
|
|
|
|
justify-content: space-between;
|
|
|
|
width: 100%;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/deep/.ant-checkbox-wrapper + .ant-checkbox-wrapper {
|
|
|
|
|
|
|
|
margin: 0px;
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|