Commit 753cdc8b authored by “yiyousong”'s avatar “yiyousong”

fix: 修复新增\编辑用户时不能选择角色的问题

parent 4208bd84
......@@ -46,10 +46,10 @@
<a-form-model-item label="用户角色" prop="roleId">
<a-select v-model="form.roleId" placeholder="请选择角色">
<a-select-option
v-for="v in userDict"
:key="v.key"
:value="v.key"
>{{ v.value }}</a-select-option
v-for="(v, key) in userDict"
:key="key"
:value="key"
>{{ v }}</a-select-option
>
</a-select>
</a-form-model-item>
......@@ -105,9 +105,9 @@ export default {
},
props: {
userDict: {
type: Array,
type: Object,
default: () => {
return [];
return {};
},
},
visibleUserEdit: {
......@@ -153,12 +153,22 @@ export default {
// 编辑
onEdit(row) {
this.form = { ...row };
this.form.areaNames = JSON.parse(this.form.areaNames);
if (this.form.areaNames.length) {
this.selectAreaList = this.form.areaNames.map((v) => v.label);
try {
this.form.areaNames = JSON.parse(this.form.areaNames);
} catch (err) {
this.form.areaNames = this.form.areaNames;
console.log(typeof this.form.areaNames);
}
if (typeof this.form.areaNames == "string") {
this.selectAreaList = [this.form.areaNames];
} else {
this.selectAreaList = [];
if (this.form.areaNames.length) {
this.selectAreaList = this.form.areaNames.map((v) => v.label);
} else {
this.selectAreaList = [];
}
}
// this.form.areaCodes = this.form.areaCodes.split(",");
this.form.loginPwd && this.$delete(this.form, "loginPwd");
},
......@@ -216,5 +226,4 @@ export default {
};
</script>
<style>
</style>
\ No newline at end of file
<style></style>
......@@ -70,10 +70,10 @@
<a-form-model-item label="用户角色" prop="roleId">
<a-select v-model="form.roleId" placeholder="请选择角色">
<a-select-option
v-for="v in userDict"
:key="v.key"
:value="v.key"
>{{ v.value }}</a-select-option
v-for="(v, key) in userDict"
:key="key"
:value="key"
>{{ v }}</a-select-option
>
</a-select>
</a-form-model-item>
......@@ -135,9 +135,9 @@ export default {
},
props: {
userDict: {
type: Array,
type: Object,
default: () => {
return [];
return {};
},
},
visibleUser: {
......@@ -229,5 +229,4 @@ export default {
};
</script>
<style>
</style>
\ No newline at end of file
<style></style>
......@@ -170,7 +170,7 @@ export default {
},
formTitle: undefined, //表单title
sourceInfoForm: {},
userDict: [], // 角色数据
userDict: {}, // 角色数据
userform: {
roleId: undefined,
searchVal: undefined,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment