role1.0
fanluyan 1 year ago
parent c71cfda1d8
commit 2c2d771878

@ -761,6 +761,9 @@ export function getPermission(data) {
url: "/xymanager/role/getPermission", url: "/xymanager/role/getPermission",
method: "get", method: "get",
params: data, params: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
},
}); });
} }

@ -1,13 +1,23 @@
<template> <template>
<el-dialog <el-dialog
class="addUserDialog" class="blindDialog"
title="权限绑定" title="权限绑定"
:visible.sync="isShow" :visible.sync="isShow"
:close-on-click-modal="false" :close-on-click-modal="false"
width="470px" width="470px"
@close="handleclose" @close="handleclose"
> >
绑定权限 <div class="treeBoxList" v-loading="treeLoading">
<el-tree
:data="treeData"
show-checkbox
node-key="id"
ref="tree"
highlight-current
:props="defaultProps"
>
</el-tree>
</div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="isShow = false"> </el-button> <el-button @click="isShow = false"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button> <el-button type="primary" @click="submitForm()"> </el-button>
@ -15,15 +25,27 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { addRole, updateRole } from "@/utils/api/index"; import {
getPermissionTree,
getPermission,
changePermission,
} from "@/utils/api/index";
export default { export default {
props: {}, props: {},
data() { data() {
return { return {
roleUser: "", roleUser: "",
isShow: false, isShow: false,
treeData: [],
formdata: {}, defaultProps: {
//
children: "list",
label: "name",
},
treeLoading: false,
rowData: "",
premissData: [],
selectTreeNode: [],
rules: { rules: {
name: [{ required: true, message: "请输入用户名", trigger: "blur" }], name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
}, },
@ -35,67 +57,75 @@ export default {
methods: { methods: {
// //
getdataform(val) { getdataform(val) {
this.formdata = JSON.parse(JSON.stringify(val)); this.rowData = JSON.parse(JSON.stringify(val));
this.getPermissionRole();
}, },
// //
submitForm() { getPermissionList() {
this.$refs.formInfo.validate((valid) => { this.treeLoading = true;
if (valid) { getPermissionTree()
if (this.title == "新增") { .then((res) => {
addRole(this.formdata) if (res.code == 200) {
.then((res) => { console.log(res);
if (res.code == 200) { this.treeLoading = false;
this.$message({ this.treeData = res.data.list;
duration: 1500, } else {
showClose: true, this.$message.error(res.msg);
message: "添加成功", }
type: "success", })
}); .catch((err) => {});
this.isShow = false; },
} else { //
this.$message.error(res.msg); getPermissionRole() {
} console.log(this.rowData);
}) getPermission({ id: this.rowData.id })
.catch((err) => {}); .then((res) => {
if (res.code == 200) {
console.log(res);
this.premissData = res.data;
} else { } else {
updateRole(this.formdata) this.$message.error(res.msg);
.then((res) => {
if (res.code == 200) {
this.$message.success("修改成功");
this.isShow = false;
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {});
} }
} else { })
console.log("error submit!!"); .catch((err) => {});
return false; },
}
}); //
submitForm() {
console.log(this.$refs.tree.getCheckedNodes());
this.selectTreeNode = this.$refs.tree.getCheckedNodes();
console.log(this.selectTreeNode);
// changePermission()
// .then((res) => {
// if (res.code == 200) {
// console.log(res);
// } else {
// this.$message.error(res.msg);
// }
// })
// .catch((err) => {});
}, },
display() { display() {
this.isShow = true; this.isShow = true;
this.roleUser = localStorage.getItem("role"); this.getPermissionList();
}, },
hide() { hide() {
this.isShow = false; this.isShow = false;
}, },
handleclose() { handleclose() {
this.$parent.roleListAll(); this.treeData = [];
}, },
}, },
mounted() {}, mounted() {},
}; };
</script> </script>
<style lang="less"> <style lang="less">
.addUserDialog { .blindDialog {
.el-form-item { .treeBoxList {
.el-input, height: 600px;
.el-select, overflow: auto;
.el-input-number { .el-dialog__body {
width: 100%; overflow: auto;
} }
} }
} }

Loading…
Cancel
Save