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

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

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

Loading…
Cancel
Save