提交 e558ce66 authored 作者: 龙菲's avatar 龙菲

修复角色新增和编辑的数据冲突

上级 729c5f86
...@@ -12,7 +12,12 @@ ...@@ -12,7 +12,12 @@
<div class="label">{{ title }}</div> <div class="label">{{ title }}</div>
</div> </div>
<div class="dialog-content"> <div class="dialog-content">
<el-form :model="dialogForm" class="basic-info" :rules="rules"> <el-form
:model="dialogForm"
class="basic-info"
:rules="rules"
ref="dialogForm"
>
<el-form-item <el-form-item
label="角色名称" label="角色名称"
:label-width="formLabelWidth" :label-width="formLabelWidth"
...@@ -138,9 +143,7 @@ export default { ...@@ -138,9 +143,7 @@ export default {
dialogForm: {}, dialogForm: {},
formLabelWidth: "100px", formLabelWidth: "100px",
status: true, status: true,
files: [], //文献文件
dialogVisible: false, dialogVisible: false,
// permissionTree: [],
props: { props: {
value: "id", value: "id",
label: "title", label: "title",
...@@ -171,55 +174,66 @@ export default { ...@@ -171,55 +174,66 @@ export default {
// 取消编辑 // 取消编辑
cancelForm() { cancelForm() {
this.$emit("handleClose"); this.$emit("handleClose");
this.reload();
}, },
async handleSubmit() { handleSubmit() {
const { name, remark } = this.dialogForm; this.$refs.dialogForm.validate(async (valid) => {
let status = this.status ? 1 : 0; if (valid) {
let permissions = this.$refs.tree.getCheckedKeys(); const { name, remark } = this.dialogForm;
let status = this.status ? 1 : 0;
let permissions = this.$refs.tree.getCheckedKeys();
const params = { const params = {
name, name,
status, status,
permissions, permissions,
remark, remark,
}; };
let parentIdArr = this.$refs.roleParentTree.getCheckedKeys(); let parentIdArr = this.$refs.roleParentTree.getCheckedKeys();
if (parentIdArr.length > 0) { if (parentIdArr.length > 0) {
let pid = parentIdArr.toString(); let pid = parentIdArr.toString();
params.pid = pid; params.pid = pid;
} }
if (this.dialogForm.id) { if (this.dialogForm.id) {
params.id = this.dialogForm.id; params.id = this.dialogForm.id;
let res = await upadateRole(params); let res = await upadateRole(params);
if (res.code == 0) { if (res.code == 0) {
this.$message.success("修改成功!"); this.$message.success("修改成功!");
this.reload(); this.reload();
} }
} else { } else {
params.dataScope = "5"; //默认数据权限为自己 params.dataScope = "5"; //默认数据权限为自己
// return // return
let res = await addRole(params); let res = await addRole(params);
if (res.code == 0) { if (res.code == 0) {
this.$message.success("添加成功!"); this.$message.success("添加成功!");
this.reload(); this.reload();
}
}
} }
} });
}, },
reload() { reload() {
this.$emit("refresh");
this.$emit("handleClose"); this.$emit("handleClose");
this.$refs.dialogForm.resetFields();
this.$emit("refresh");
this.$nextTick(() => {
this.$refs.tree.setCheckedKeys([]);
});
this.allRole = [];
}, },
handleClose(done) { handleClose(done) {
this.$confirm("确认关闭?") this.$confirm("确认关闭?")
.then((_) => { .then((_) => {
done(); done();
this.$emit("handleClose"); this.$emit("handleClose");
this.reload();
}) })
.catch((_) => {}); .catch((_) => {});
}, },
setPer() { setPer() {
let checkedIds = []; let checkedIds = [];
getCheckedIds(this.dialogForm.permissionRespNodes); getCheckedIds(this.dialogForm.permissionRespNodes);
...@@ -236,7 +250,7 @@ export default { ...@@ -236,7 +250,7 @@ export default {
} }
setTimeout(() => { setTimeout(() => {
if (checkedIds.length > 0) { if (checkedIds.length > 0) {
this.$refs["tree"].setCheckedKeys(checkedIds); this.$refs.tree.setCheckedKeys(checkedIds);
} }
}, 100); }, 100);
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论