|
|
@@ -468,7 +468,7 @@ onLoad((opts) => {
|
|
|
const batchId = fullPath.split('/').filter(Boolean).pop()
|
|
|
|
|
|
// 优先使用路由参数中的 id,其次使用 URL 路径中的 id
|
|
|
- const finalId = batchId || 1
|
|
|
+ const finalId = batchId
|
|
|
loadData(finalId)
|
|
|
|
|
|
routeOptions.value = opts || {}
|
|
|
@@ -544,13 +544,35 @@ const traceDetail = computed(() => {
|
|
|
emptyMessage: '检测报告待补充,上传完成后可查看大图。',
|
|
|
items: (data.reports || []).map(report => {
|
|
|
let images = []
|
|
|
- try {
|
|
|
- if (report.reportFiles) {
|
|
|
- const files = JSON.parse(report.reportFiles)
|
|
|
- images = files.map(f => f.url)
|
|
|
+
|
|
|
+ // 处理 reportFiles:可能是字符串 URL、JSON 字符串数组、或已解析的数组
|
|
|
+ if (report.reportFiles) {
|
|
|
+ if (typeof report.reportFiles === 'string') {
|
|
|
+ // 尝试解析 JSON 字符串
|
|
|
+ try {
|
|
|
+ const parsed = JSON.parse(report.reportFiles)
|
|
|
+ // 如果解析成功且是数组,提取 url 字段
|
|
|
+ if (Array.isArray(parsed)) {
|
|
|
+ images = parsed.map(item =>
|
|
|
+ typeof item === 'string' ? item : (item.url || item)
|
|
|
+ ).filter(Boolean)
|
|
|
+ } else {
|
|
|
+ // 解析后不是数组,可能是单个对象
|
|
|
+ images = [parsed.url || parsed].filter(Boolean)
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ // 解析失败,当作普通 URL 字符串处理
|
|
|
+ images = [report.reportFiles]
|
|
|
+ }
|
|
|
+ } else if (Array.isArray(report.reportFiles)) {
|
|
|
+ // 已经是数组,提取 url 字段
|
|
|
+ images = report.reportFiles.map(item =>
|
|
|
+ typeof item === 'string' ? item : (item.url || item)
|
|
|
+ ).filter(Boolean)
|
|
|
+ } else if (typeof report.reportFiles === 'object') {
|
|
|
+ // 单个对象
|
|
|
+ images = [report.reportFiles.url || report.reportFiles].filter(Boolean)
|
|
|
}
|
|
|
- } catch (e) {
|
|
|
- console.error('解析 reportFiles 失败', e)
|
|
|
}
|
|
|
|
|
|
return {
|