gaoluyang
9 天以前 68efd64847fe918d0d206aa89e21c971a3321fec
陕西昭德型煤:
1.现场巡检上传附件查看附件修改联调
已修改1个文件
28 ■■■■■ 文件已修改
src/views/inspectionManagement/components/viewQrCodeFiles.vue 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/inspectionManagement/components/viewQrCodeFiles.vue
@@ -95,15 +95,39 @@
const cancel = () => {
  dialogVisitable.value = false;
};
// 基础预览URL
const BASE_PREVIEW_URL = 'https://nj477vg8876.vicp.fun';
// 处理每一类数据:分离图片和视频
function processItems(items) {
  const images = [];
  const videos = [];
  if (!items || !Array.isArray(items)) {
    return { images, videos };
  }
  items.forEach(item => {
    // 使用 fileUrl 字段,如果不存在则使用 url 字段作为兼容
    const fileUrl = item.fileUrl || item.url;
    if (!fileUrl) return;
    // 构建完整的预览URL
    let fullUrl = fileUrl;
    // 如果 fileUrl 不是完整URL,则拼接基础URL
    if (!fileUrl.startsWith('http://') && !fileUrl.startsWith('https://')) {
      // 确保路径以 / 开头
      const path = fileUrl.startsWith('/') ? fileUrl : `/${fileUrl}`;
      fullUrl = `${BASE_PREVIEW_URL}${path}`;
    }
    // 输出最终路径,方便调试
    console.log('原始 fileUrl:', fileUrl);
    console.log('最终预览路径:', fullUrl);
    console.log('文件类型:', item.contentType);
    if (item.contentType?.startsWith('image/')) {
      images.push(item.url);
      images.push(fullUrl);
    } else if (item.contentType?.startsWith('video/')) {
      videos.push(item.url);
      videos.push(fullUrl);
    }
  });
  return { images, videos };