修复勋章记录管理页面 勋章等级管理 报错问题

This commit is contained in:
chenruiye
2025-06-10 14:02:26 +08:00
parent 90da1d4674
commit 7e381e1155
2 changed files with 37 additions and 14 deletions

View File

@@ -29,33 +29,33 @@
}}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="勋章名称-华语区">
<template v-slot="scope">{{ JSON.parse(scope.row.name).zh }}</template>
<template v-slot="scope">{{ getJsonField(scope.row.name, 'zh') }}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="勋章名称-英语区">
<template v-slot="scope">{{ JSON.parse(scope.row.name).en }}</template>
<template v-slot="scope">{{ getJsonField(scope.row.name, 'en') }}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="勋章名称-阿语区">
<template v-slot="scope">{{ JSON.parse(scope.row.name).ar }}</template>
<template v-slot="scope">{{ getJsonField(scope.row.name, 'ar') }}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="勋章名称-土耳其区">
<template v-slot="scope">{{ JSON.parse(scope.row.name).tr }}</template>
<template v-slot="scope">{{ getJsonField(scope.row.name, 'tr') }}</template>
</el-table-column>
<el-table-column prop="medalDesc" align="center" label="勋章获得方式-华语区">
<template v-slot="scope">{{ JSON.parse(scope.row?.medalDesc)?.zh || ''}}</template>
<template v-slot="scope">{{ getJsonField(scope.row.medalDesc, 'zh')}}</template>
</el-table-column>
<el-table-column prop="medalDesc" align="center" label="勋章获得方式-英语区">
<template v-slot="scope">{{ JSON.parse(scope.row?.medalDesc)?.en || ''}}</template>
<template v-slot="scope">{{ getJsonField(scope.row.medalDesc, 'en')}}</template>
</el-table-column>
<el-table-column prop="medalDesc" align="center" label="勋章获得方式-阿语区">
<template v-slot="scope">{{ JSON.parse(scope.row?.medalDesc)?.ar || ''}}</template>
<template v-slot="scope">{{ getJsonField(scope.row.medalDesc, 'ar')}}</template>
</el-table-column>
<el-table-column prop="medalDesc" align="center" label="勋章获得方式-土耳其区">
<template v-slot="scope">{{ JSON.parse(scope.row?.medalDesc)?.tr || ''}}</template>
<template v-slot="scope">{{ getJsonField(scope.row.medalDesc, 'tr')}}</template>
</el-table-column>
<el-table-column align="center" prop="picUrl" label="勋章图片" width="120">
<template v-slot="scope">
<el-image style="width: 100px; height: 100px" :src="scope.row.picUrl" :zoom-rate="1.1"
:preview-src-list="scope.row.picUrl" fit="scale-down" preview-teleported="true"
:preview-src-list="[scope.row.picUrl ?? '']" fit="scale-down" preview-teleported="true"
hide-on-click-modal="true" />
</template>
</el-table-column>
@@ -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();

View File

@@ -27,16 +27,16 @@
@selection-change="handleSelectionChange" border style="width: 100%; margin-top: 25px">
<el-table-column prop="seriesId" align="center" label="ID" />
<el-table-column prop="name" align="center" label="勋章等级名称-华语区">
<template v-slot="scope">{{ JSON.parse(scope.row.seriesName).zh }}</template>
<template v-slot="scope">{{ getJsonField(scope.row.seriesName, 'zh') }}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="勋章等级名称-英语区">
<template v-slot="scope">{{ JSON.parse(scope.row.seriesName).en }}</template>
<template v-slot="scope">{{ getJsonField(scope.row.seriesName, 'en') }}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="勋章等级名称-阿语区">
<template v-slot="scope">{{ JSON.parse(scope.row.seriesName).ar }}</template>
<template v-slot="scope">{{ getJsonField(scope.row.seriesName, 'ar') }}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="勋章等级名称-土耳其区">
<template v-slot="scope">{{ JSON.parse(scope.row.seriesName).tr }}</template>
<template v-slot="scope">{{ getJsonField(scope.row.seriesName, 'tr') }}</template>
</el-table-column>
<el-table-column prop="partitionDesc" align="center" label="分区">
<template v-slot="scope">{{
@@ -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
}
}
}