AlarmAttachments.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div v-if="images.length" class="alarm-attachments">
  3. <div class="attachment-images">
  4. <el-image
  5. v-for="(file, index) in images"
  6. :key="file.url"
  7. class="attachment-thumbnail"
  8. :src="file.url"
  9. :alt="file.name"
  10. :title="`点击查看大图:${file.name}`"
  11. :preview-src-list="previewUrls"
  12. :initial-index="index"
  13. preview-teleported
  14. fit="cover"
  15. lazy
  16. >
  17. <template #placeholder><span class="image-placeholder">加载中…</span></template>
  18. <template #error><span class="image-placeholder">图片加载失败</span></template>
  19. </el-image>
  20. </div>
  21. </div>
  22. </template>
  23. <script setup>
  24. import { computed } from 'vue'
  25. import { imageAttachments } from './common/utils/alarmReviewModel'
  26. const props = defineProps({
  27. value: { type: String, default: '' },
  28. baseUrl: { type: String, default: '' }
  29. })
  30. const images = computed(() => imageAttachments(props.value, props.baseUrl))
  31. const previewUrls = computed(() => images.value.map(file => file.url))
  32. </script>
  33. <style scoped>
  34. .alarm-attachments { margin-top: 12px; }
  35. .attachment-images { display: flex; flex-wrap: wrap; gap: 10px; }
  36. .attachment-thumbnail { width: 96px; height: 72px; flex: 0 0 96px; border: 1px solid #e4e7ed; border-radius: 4px; background: #fff; cursor: zoom-in; }
  37. .attachment-thumbnail:hover { border-color: var(--el-color-primary); }
  38. .image-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: #909399; font-size: 12px; }
  39. </style>