|
@@ -52,7 +52,7 @@ const dataConverter = {
|
|
|
id: apiData.id,
|
|
|
title: apiData.title || '',
|
|
|
content: apiData.content || '',
|
|
|
- categoryId: apiData.categoryId || '',
|
|
|
+ categoryId: apiData.categoryId != null ? String(apiData.categoryId) : '',
|
|
|
categoryName: apiData.categoryName,
|
|
|
orgId: apiData.orgId || 0,
|
|
|
orgCode: apiData.orgCode || '',
|
|
@@ -77,7 +77,7 @@ const dataConverter = {
|
|
|
id: formModel.id,
|
|
|
title: formModel.title,
|
|
|
content: formModel.content,
|
|
|
- categoryId: formModel.categoryId,
|
|
|
+ categoryId: formModel.categoryId != null ? String(formModel.categoryId) : '',
|
|
|
categoryName: formModel.categoryName,
|
|
|
orgId: Number(formModel.orgId),
|
|
|
orgCode: formModel.orgCode,
|
|
@@ -349,7 +349,7 @@ export default {
|
|
|
id: newVal.id || '',
|
|
|
title: newVal.title || '',
|
|
|
content: newVal.content || '',
|
|
|
- categoryId: newVal.categoryId || '',
|
|
|
+ categoryId: newVal.categoryId != null ? String(newVal.categoryId) : '',
|
|
|
categoryName: newVal.categoryName,
|
|
|
orgId: Number(newVal.orgId || 0),
|
|
|
orgCode: newVal.orgCode || '',
|
|
@@ -373,14 +373,15 @@ export default {
|
|
|
*/
|
|
|
'formData.categoryId': {
|
|
|
handler(newVal) {
|
|
|
- if (newVal && this.categoryOptions && this.categoryOptions.length > 0) {
|
|
|
- const category = this.categoryOptions.find(item => item.value === newVal);
|
|
|
+ const key = newVal != null ? String(newVal) : '';
|
|
|
+ if (key && this.categoryOptions && this.categoryOptions.length > 0) {
|
|
|
+ const category = this.categoryOptions.find(item => item.id === key || item.value === key);
|
|
|
if (category) {
|
|
|
this.formData.categoryName = category.name;
|
|
|
+ return;
|
|
|
}
|
|
|
- } else {
|
|
|
- this.formData.categoryName = '';
|
|
|
}
|
|
|
+ this.formData.categoryName = '';
|
|
|
},
|
|
|
immediate: true
|
|
|
},
|
|
@@ -648,6 +649,10 @@ export default {
|
|
|
label: String(item.name),
|
|
|
value: String(item.id)
|
|
|
}));
|
|
|
+ // 选项加载后,标准化当前categoryId为字符串以保证回显
|
|
|
+ if (this.formData && this.formData.categoryId != null && this.formData.categoryId !== '') {
|
|
|
+ this.formData.categoryId = String(this.formData.categoryId);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('加载分类选项失败:', error);
|