|
|
@@ -28,7 +28,12 @@
|
|
|
</el-row>
|
|
|
|
|
|
<!-- 列表 -->
|
|
|
- <el-table :data="tableData" v-loading="loading" stripe style="width: 100%">
|
|
|
+ <el-table
|
|
|
+ :data="tableData"
|
|
|
+ v-loading="loading"
|
|
|
+ stripe
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
<el-table-column prop="ind" label="序号" width="280"></el-table-column>
|
|
|
<el-table-column prop="role_name" label="角色名称" width="380">
|
|
|
</el-table-column>
|
|
|
@@ -145,17 +150,17 @@ export default {
|
|
|
addrUserVisible: false,
|
|
|
form: {
|
|
|
name: "",
|
|
|
- describe: "",
|
|
|
+ describe: ""
|
|
|
},
|
|
|
rules: {
|
|
|
name: [
|
|
|
- { required: true, message: "请输入角色名称", trigger: "blur" },
|
|
|
+ { required: true, message: "请输入角色名称", trigger: "blur" }
|
|
|
// { min: 3, max: 5, message: "长度在 1 到 15 个字符", trigger: "blur" },
|
|
|
],
|
|
|
describe: [
|
|
|
- { required: true, message: "请输入角色描述", trigger: "blur" },
|
|
|
+ { required: true, message: "请输入角色描述", trigger: "blur" }
|
|
|
// { min: 3, max: 5, message: "长度在 1 到 30 个字符", trigger: "blur" },
|
|
|
- ],
|
|
|
+ ]
|
|
|
},
|
|
|
|
|
|
// 分配权限
|
|
|
@@ -167,8 +172,10 @@ export default {
|
|
|
// 树形控件的属性绑定对象
|
|
|
treeProps: {
|
|
|
label: "purview_name",
|
|
|
- children: "children",
|
|
|
+ children: "children"
|
|
|
},
|
|
|
+
|
|
|
+ isClick: true // 防止重复弹框
|
|
|
};
|
|
|
},
|
|
|
//监听属性 类似于data概念
|
|
|
@@ -189,7 +196,7 @@ export default {
|
|
|
this.fullHeight = val;
|
|
|
this.timer = true;
|
|
|
let that = this;
|
|
|
- setTimeout(function () {
|
|
|
+ setTimeout(function() {
|
|
|
//防止过度调用监测事件,导致卡顿
|
|
|
that.timer = false;
|
|
|
}, 400);
|
|
|
@@ -198,9 +205,9 @@ export default {
|
|
|
|
|
|
setRightDialogVisible(val) {
|
|
|
if (val == false) {
|
|
|
- this.defKeys = []
|
|
|
+ this.defKeys = [];
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
//方法集合
|
|
|
methods: {
|
|
|
@@ -222,10 +229,10 @@ export default {
|
|
|
data: this.qs.stringify({
|
|
|
page: this.page,
|
|
|
page_item: "10",
|
|
|
- role_name: this.input,
|
|
|
- }),
|
|
|
+ role_name: this.input
|
|
|
+ })
|
|
|
})
|
|
|
- .then((res) => {
|
|
|
+ .then(res => {
|
|
|
if (res.data.data.total_item !== 0) {
|
|
|
var data = res.data.data.page_list;
|
|
|
this.pagesum = res.data.data.total_item;
|
|
|
@@ -239,10 +246,10 @@ export default {
|
|
|
this.tableData = [];
|
|
|
this.pagesum = 0;
|
|
|
}
|
|
|
- this.loading = false
|
|
|
+ this.loading = false;
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- this.loading = false
|
|
|
+ .catch(err => {
|
|
|
+ this.loading = false;
|
|
|
});
|
|
|
},
|
|
|
|
|
|
@@ -264,7 +271,6 @@ export default {
|
|
|
},
|
|
|
// 编辑角色
|
|
|
actionFunc(data) {
|
|
|
- // console.log(data);
|
|
|
this.describeData = data;
|
|
|
this.tltData = "编辑角色";
|
|
|
this.form.name = data.role_name; // 角色名称
|
|
|
@@ -273,7 +279,7 @@ export default {
|
|
|
},
|
|
|
// 添加、编辑角色确定
|
|
|
submitForm() {
|
|
|
- this.$refs["form"].validate((valid) => {
|
|
|
+ this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
if (this.tltData == "添加角色") {
|
|
|
// 添加
|
|
|
@@ -283,43 +289,44 @@ export default {
|
|
|
this.editRoleAxios(); // 编辑
|
|
|
}
|
|
|
} else {
|
|
|
- // console.log("error submit!!");
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
// 添加 - 确定
|
|
|
addrRoleAxios() {
|
|
|
- this.$axios({
|
|
|
- method: "POST",
|
|
|
- url: "/api/api_gateway?method=sysmenage.usermanager.role_add",
|
|
|
- data: this.qs.stringify({
|
|
|
- role_name: this.form.name,
|
|
|
- role_message: this.form.describe,
|
|
|
- }),
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res.data.data == true) {
|
|
|
- this.$message({
|
|
|
- message: "成功!",
|
|
|
- type: "success",
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- this.addrUserVisible = false;
|
|
|
- this.tabListData();
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- message: "失败!",
|
|
|
- type: "error",
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- }
|
|
|
- // console.log(res);
|
|
|
- this.addrUserVisible = false;
|
|
|
+ var that = this;
|
|
|
+ if (this.isClick == true) {
|
|
|
+ this.isClick = false;
|
|
|
+ this.$axios({
|
|
|
+ method: "POST",
|
|
|
+ url: "/api/api_gateway?method=sysmenage.usermanager.role_add",
|
|
|
+ data: this.qs.stringify({
|
|
|
+ role_name: this.form.name,
|
|
|
+ role_message: this.form.describe
|
|
|
+ })
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- // console.log(err);
|
|
|
- });
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.data == true) {
|
|
|
+ this.$message({
|
|
|
+ message: "成功!",
|
|
|
+ type: "success",
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+ this.addrUserVisible = false;
|
|
|
+ this.tabListData();
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ that.isClick = true;
|
|
|
+ }, 2500);
|
|
|
+ // this.addrUserVisible = false;
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ setTimeout(() => {
|
|
|
+ that.isClick = true;
|
|
|
+ }, 2500);
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
// 编辑 - 确定
|
|
|
editRoleAxios() {
|
|
|
@@ -329,15 +336,15 @@ export default {
|
|
|
data: this.qs.stringify({
|
|
|
role_id: this.describeData.id,
|
|
|
role_name: this.form.name,
|
|
|
- role_message: this.form.describe,
|
|
|
- }),
|
|
|
+ role_message: this.form.describe
|
|
|
+ })
|
|
|
})
|
|
|
- .then((res) => {
|
|
|
+ .then(res => {
|
|
|
if (res.data.data == true) {
|
|
|
this.$message({
|
|
|
message: "成功!",
|
|
|
type: "success",
|
|
|
- duration: 1500,
|
|
|
+ duration: 1500
|
|
|
});
|
|
|
this.addrUserVisible = false;
|
|
|
this.tabListData();
|
|
|
@@ -345,15 +352,12 @@ export default {
|
|
|
this.$message({
|
|
|
message: "失败!",
|
|
|
type: "error",
|
|
|
- duration: 1500,
|
|
|
+ duration: 1500
|
|
|
});
|
|
|
}
|
|
|
- // console.log(res);
|
|
|
this.addrUserVisible = false;
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- // console.log(err);
|
|
|
- });
|
|
|
+ .catch(err => {});
|
|
|
},
|
|
|
|
|
|
// 分配权限
|
|
|
@@ -361,22 +365,20 @@ export default {
|
|
|
this.describeData = val;
|
|
|
this.$axios({
|
|
|
method: "POST",
|
|
|
- url: "/api/api_gateway?method=sysmenage.usermanager.user_info",
|
|
|
+ url: "/api/api_gateway?method=sysmenage.usermanager.user_info"
|
|
|
})
|
|
|
- .then((res) => {
|
|
|
+ .then(res => {
|
|
|
if (res.data.message == "") {
|
|
|
var data = res.data.data.children;
|
|
|
- this.rightsList = []
|
|
|
+ this.rightsList = [];
|
|
|
this.rightsList = data;
|
|
|
this.limitsList(); //获取当前角色的权限
|
|
|
} else {
|
|
|
- this.rightsList = []
|
|
|
+ this.rightsList = [];
|
|
|
this.$message.error("获取权限列表失败!");
|
|
|
}
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- // console.log(err)
|
|
|
- });
|
|
|
+ .catch(err => {});
|
|
|
},
|
|
|
// 当前角色权限
|
|
|
limitsList() {
|
|
|
@@ -384,10 +386,10 @@ export default {
|
|
|
method: "POST",
|
|
|
url: "/api/api_gateway?method=sysmenage.usermanager.role_info",
|
|
|
data: this.qs.stringify({
|
|
|
- role_id: this.describeData.id, //角色ID
|
|
|
- }),
|
|
|
+ role_id: this.describeData.id //角色ID
|
|
|
+ })
|
|
|
})
|
|
|
- .then((res) => {
|
|
|
+ .then(res => {
|
|
|
if (res.data.data) {
|
|
|
this.setRightDialogVisible = true;
|
|
|
var list = this.tableData;
|
|
|
@@ -400,54 +402,58 @@ export default {
|
|
|
}
|
|
|
this.tableData = list;
|
|
|
} else {
|
|
|
- this.tableData = []
|
|
|
+ this.tableData = [];
|
|
|
}
|
|
|
- // this.tabListData = list;
|
|
|
+ // this.tabListData = list;
|
|
|
// this.tableData = list;
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ .catch(err => {});
|
|
|
},
|
|
|
|
|
|
getLeafkeys(node, arr) {
|
|
|
if (!node.children) {
|
|
|
return arr.push(node.pur_id);
|
|
|
}
|
|
|
- node.children.forEach((item) => this.getLeafkeys(item, arr));
|
|
|
+ node.children.forEach(item => this.getLeafkeys(item, arr));
|
|
|
},
|
|
|
setRightDialogClosed() {
|
|
|
this.rightsList = [];
|
|
|
},
|
|
|
// 确定 - 分配权限
|
|
|
allotRights() {
|
|
|
- var that = this
|
|
|
+ var that = this;
|
|
|
// 获得当前选中的Id
|
|
|
const keys = [
|
|
|
...this.$refs.treeRef.getCheckedKeys(),
|
|
|
- ...this.$refs.treeRef.getHalfCheckedKeys(),
|
|
|
+ ...this.$refs.treeRef.getHalfCheckedKeys()
|
|
|
];
|
|
|
const idStr = keys.join(",");
|
|
|
- console.log(idStr);
|
|
|
- this.$axios({
|
|
|
- method: "POST",
|
|
|
- url: "/api/api_gateway?method=sysmenage.usermanager.role_perm",
|
|
|
- data: this.qs.stringify({
|
|
|
- pur_id: idStr, // 权限id
|
|
|
- role_id: this.describeData.id, // 角色id
|
|
|
- }),
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- console.log(res);
|
|
|
- if (res.data.message == "") {
|
|
|
- this.$message.success("分配权限成功!");
|
|
|
- that.setRightDialogVisible = false;
|
|
|
- that.tabListData();
|
|
|
- }
|
|
|
+ if (this.isClick == true) {
|
|
|
+ this.isClick = false;
|
|
|
+ this.$axios({
|
|
|
+ method: "POST",
|
|
|
+ url: "/api/api_gateway?method=sysmenage.usermanager.role_perm",
|
|
|
+ data: this.qs.stringify({
|
|
|
+ pur_id: idStr, // 权限id
|
|
|
+ role_id: this.describeData.id // 角色id
|
|
|
+ })
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.message == "") {
|
|
|
+ this.$message.success("分配权限成功!");
|
|
|
+ that.setRightDialogVisible = false;
|
|
|
+ that.tabListData();
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ that.isClick = true;
|
|
|
+ }, 2500);
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ setTimeout(() => {
|
|
|
+ that.isClick = true;
|
|
|
+ }, 2500);
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 删除
|
|
|
@@ -455,43 +461,41 @@ export default {
|
|
|
this.$confirm("此操作将永久删除, 是否继续?", "提示", {
|
|
|
confirmButtonText: "确定",
|
|
|
cancelButtonText: "取消",
|
|
|
- type: "warning",
|
|
|
+ type: "warning"
|
|
|
})
|
|
|
.then(() => {
|
|
|
this.$axios({
|
|
|
method: "POST",
|
|
|
url: "/api/api_gateway?method=sysmenage.usermanager.role_delete",
|
|
|
data: this.qs.stringify({
|
|
|
- role_id: data.id,
|
|
|
- }),
|
|
|
+ role_id: data.id
|
|
|
+ })
|
|
|
})
|
|
|
- .then((res) => {
|
|
|
+ .then(res => {
|
|
|
if (res.data.message == "") {
|
|
|
this.$message({
|
|
|
type: "success",
|
|
|
message: "删除成功!",
|
|
|
- duration: 1500,
|
|
|
+ duration: 1500
|
|
|
});
|
|
|
}
|
|
|
this.tabListData();
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ .catch(err => {});
|
|
|
})
|
|
|
.catch(() => {
|
|
|
this.$message({
|
|
|
type: "info",
|
|
|
- message: "已取消删除",
|
|
|
+ message: "已取消删除"
|
|
|
});
|
|
|
});
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
|
created() {},
|
|
|
//生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
mounted() {
|
|
|
- this.loading = true
|
|
|
+ this.loading = true;
|
|
|
this.tabListData(); // 表格数据
|
|
|
},
|
|
|
beforeCreate() {}, //生命周期 - 创建之前
|
|
|
@@ -500,10 +504,10 @@ export default {
|
|
|
updated() {}, //生命周期 - 更新之后
|
|
|
beforeDestroy() {}, //生命周期 - 销毁之前
|
|
|
destroyed() {}, //生命周期 - 销毁完成
|
|
|
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
+ activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
};
|
|
|
</script>
|
|
|
-<style lang='less' scoped>
|
|
|
+<style lang="less" scoped>
|
|
|
.role_box {
|
|
|
.search_box {
|
|
|
display: flex;
|
|
|
@@ -535,4 +539,4 @@ export default {
|
|
|
height: 14px;
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|