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

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

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