Sfoglia il codice sorgente

fix(cockpit): 实体详情工单附件链接补统一图片基址

维修前/后附件与处置流水图片在实体详情面板里是 <a href> 直接打开原串,
后端给对象存储相对路径时会打不开。改为走 resolveDeviceImageUrl,
与设备图片、设备详情附件同一口径;timelineAttachments 同时收 attachImages。
ChenJZ 3 ore fa
parent
commit
f53a22f126

+ 4 - 1
src/modules/cockpit/components/EntityDetailSections.vue

@@ -25,7 +25,7 @@
         <section v-if="showPeople && view.people.length" class="entity-sections__group"><h3>相关人员</h3><ul><li v-for="item in view.people" :key="item.role"><span>{{ item.role }}</span><b>{{ item.name }}</b></li></ul></section>
         <section v-if="showDevices && view.devices.length" class="entity-sections__group"><h3>设备信息</h3><ul><li v-for="item in view.devices" :key="item.code || item.name"><b>{{ item.name }}</b><span>{{ item.code }} · {{ item.status }}</span><small>{{ item.type || item.location }}</small><button v-if="item.code" type="button" class="entity-sections__locate" :data-locate-device="item.code" @click.stop="locateDevice(item.code)">定位 {{ item.code }}</button></li></ul></section>
         <section v-if="showRecords && view.records.length" class="entity-sections__group"><h3>处置记录</h3><ol class="entity-sections__records"><li v-for="(item,index) in view.records" :key="index"><b>{{ item.title }}</b><time>{{ item.time }}</time><span>{{ item.operator }}</span><p>{{ item.description }}</p></li></ol></section>
-        <section v-if="showAttachments" class="entity-sections__group"><h3>附件</h3><p v-if="!view.attachments.length">暂无附件</p><ul v-else><li v-for="(item,index) in view.attachments" :key="index"><a v-if="item.url" :href="item.url" target="_blank" rel="noopener">{{ item.name }}</a><span v-else>{{ item.name }}</span></li></ul></section>
+        <section v-if="showAttachments" class="entity-sections__group"><h3>附件</h3><p v-if="!view.attachments.length">暂无附件</p><ul v-else><li v-for="(item,index) in view.attachments" :key="index"><a v-if="item.url" :href="attachmentUrl(item.url)" target="_blank" rel="noopener">{{ item.name }}</a><span v-else>{{ item.name }}</span></li></ul></section>
         <section v-if="showRelated" class="entity-sections__group"><h3>关联信息</h3><p v-if="!view.devices.length">暂无关联设备数据</p><ul v-else><li v-for="item in view.devices" :key="item.code || item.name"><b>{{ item.name }}</b><span>{{ item.code }} · {{ item.status }}</span><small>{{ item.type || item.location }}</small><button v-if="item.code" type="button" class="entity-sections__locate" :data-locate-device="item.code" @click.stop="locateDevice(item.code)">定位 {{ item.code }}</button></li></ul></section>
         <section v-if="showAlarms" class="entity-sections__group"><h3>关联报警</h3><p v-if="!view.relatedAlarms.length">暂无关联报警</p><ul v-else><li v-for="item in view.relatedAlarms" :key="item.code"><b>{{ item.name }}</b><span>{{ item.code }} · {{ item.status }}</span></li></ul></section>
         <section v-if="showFlow && view.track" class="entity-sections__group"><h3>处置轨迹</h3><WorkOrderTimeline :track="view.track" /></section>
@@ -35,9 +35,12 @@
 import { computed, ref, watch } from 'vue'
 import { entityDetailView } from '../domain/entityDetail.js'
 import WorkOrderTimeline from './WorkOrderTimeline.vue'
+import { resolveDeviceImageUrl } from '../services/deviceImage.js'
 const props = defineProps({ detail: { type: Object, default: null }, presentation: { type: String, default: 'entity' } })
 const emit = defineEmits(['locate-device'])
 const view = computed(() => entityDetailView(props.detail))
+// 维修附件可能是对象存储相对路径,走统一前缀拼接才能点开看(与设备图片同口径)。
+function attachmentUrl(url) { return resolveDeviceImageUrl(url) || url }
 const activeTab = ref('')
 const tabs = computed(() => view.value.tabs || [])
 watch(() => props.detail && (props.detail.kind + '|' + props.detail.id), () => { activeTab.value = (tabs.value[0] && tabs.value[0].key) || '' }, { immediate: true })

+ 2 - 1
src/modules/cockpit/domain/entityDetail.js

@@ -765,7 +765,8 @@ function workOrderStage(code) {
     const n = Number(code); const active = n === 6 ? 3 : n === 7 ? 0 : Number.isInteger(n) ? Math.max(0, Math.min(n, 5)) : 0
     return labels.map((label,index) => ({ label, state: index < active ? 'done' : index === active ? 'active' : 'pending' }))
 }
-function timelineAttachments(records) { return (Array.isArray(records) ? records : []).flatMap((item) => item.attachList || item.attachments || []) }
+// 维修过程图片:后端既有 attachList 也有新暴露的 attachImages,两条都收进附件清单。
+function timelineAttachments(records) { return (Array.isArray(records) ? records : []).flatMap((item) => item.attachList || item.attachments || item.attachImages || []) }
 
 /**
  * 缺值剔除:always 行例外 —— 业务上"这个设施没有该属性"时要显式显示占位符