diff --git a/src/views/medal/MedalInfo.vue b/src/views/medal/MedalInfo.vue
index 8e19faa..a92fe89 100644
--- a/src/views/medal/MedalInfo.vue
+++ b/src/views/medal/MedalInfo.vue
@@ -29,33 +29,33 @@
}}
- {{ JSON.parse(scope.row.name).zh }}
+ {{ getJsonField(scope.row.name, 'zh') }}
- {{ JSON.parse(scope.row.name).en }}
+ {{ getJsonField(scope.row.name, 'en') }}
- {{ JSON.parse(scope.row.name).ar }}
+ {{ getJsonField(scope.row.name, 'ar') }}
- {{ JSON.parse(scope.row.name).tr }}
+ {{ getJsonField(scope.row.name, 'tr') }}
- {{ JSON.parse(scope.row?.medalDesc)?.zh || ''}}
+ {{ getJsonField(scope.row.medalDesc, 'zh')}}
- {{ JSON.parse(scope.row?.medalDesc)?.en || ''}}
+ {{ getJsonField(scope.row.medalDesc, 'en')}}
- {{ JSON.parse(scope.row?.medalDesc)?.ar || ''}}
+ {{ getJsonField(scope.row.medalDesc, 'ar')}}
- {{ JSON.parse(scope.row?.medalDesc)?.tr || ''}}
+ {{ getJsonField(scope.row.medalDesc, 'tr')}}
@@ -560,6 +560,17 @@ export default {
return false;
}
},
+ // 解析json字段
+ getJsonField(jsonStr, field) {
+ try {
+ if (!jsonStr) return '';
+ const obj = JSON.parse(jsonStr);
+ return obj?.[field] || '';
+ } catch (e) {
+ console.error('JSON 解析失败:', jsonStr);
+ return '';
+ }
+ },
// 分页导航
handleSizeChange() {
this.getData();
diff --git a/src/views/medal/MedalLevelManagement.vue b/src/views/medal/MedalLevelManagement.vue
index 77667f6..a0c4d45 100644
--- a/src/views/medal/MedalLevelManagement.vue
+++ b/src/views/medal/MedalLevelManagement.vue
@@ -27,16 +27,16 @@
@selection-change="handleSelectionChange" border style="width: 100%; margin-top: 25px">
- {{ JSON.parse(scope.row.seriesName).zh }}
+ {{ getJsonField(scope.row.seriesName, 'zh') }}
- {{ JSON.parse(scope.row.seriesName).en }}
+ {{ getJsonField(scope.row.seriesName, 'en') }}
- {{ JSON.parse(scope.row.seriesName).ar }}
+ {{ getJsonField(scope.row.seriesName, 'ar') }}
- {{ JSON.parse(scope.row.seriesName).tr }}
+ {{ getJsonField(scope.row.seriesName, 'tr') }}
{{
@@ -382,6 +382,17 @@ export default {
addFormData.partitionInfosList = JSON.parse(JSON.stringify(e));
addFormData.partitionInfosList.shift();
};
+ // 解析json字段
+ const getJsonField =(jsonStr, field) =>{
+ try {
+ if (!jsonStr) return '';
+ const obj = JSON.parse(jsonStr);
+ return obj?.[field] || '';
+ } catch (e) {
+ console.error('JSON 解析失败:', jsonStr);
+ return '';
+ }
+ };
const handleSizeChange = (val) => {
formData.pageSize = val;
getData();
@@ -408,7 +419,8 @@ export default {
getpartitionInfosList,
resetAddFormData,
detailPageFun,
- Dialogtitle
+ Dialogtitle,
+ getJsonField
}
}
}