gongchunyi
20 小时以前 9231ff57ac22c083986aa6b3823ad43acde9fa2f
src/views/salesManagement/deliveryLedger/index.vue
@@ -193,10 +193,12 @@
        <div class="detail-images" v-if="detailImages.length">
          <div class="detail-images-title">发货图片</div>
          <ImagePreview
            :src="detailImages.map(i => i.url).join(',')"
            width="120px"
            height="120px"
          <el-image
            v-for="img in detailImages"
            :key="img.url"
            :src="img.url"
            :preview-src-list="detailImages.map(i => i.url)"
            fit="cover"
            class="detail-image"
          />
        </div>
@@ -243,30 +245,44 @@
const detailRow = ref(null);
const detailImages = ref([]);
const getFileAccessUrl = (file = {}) => {
  if (file?.link) {
    if (String(file.link).startsWith('http')) return file.link;
    return normalizeFileUrl(file.link);
  }
  return normalizeFileUrl(file?.url || '');
};
const normalizeFileUrl = (rawUrl = '') => {
  let fileUrl = rawUrl || '';
  if (fileUrl && fileUrl.indexOf('\\') > -1) {
    const lowerPath = fileUrl.toLowerCase();
    const uploadPathIndex = lowerPath.indexOf('uploadpath');
    if (uploadPathIndex > -1) {
      fileUrl = fileUrl
        .substring(uploadPathIndex)
        .replace(/\\/g, '/');
    } else {
      fileUrl = fileUrl.replace(/\\/g, '/');
    }
    fileUrl = fileUrl.replace(/\\/g, '/');
  }
  fileUrl = fileUrl.replace(/^\/?uploadPath/, '/profile');
  if (!fileUrl.startsWith('http')) {
  const lowerPath = fileUrl.toLowerCase();
  const uploadPathIndex = lowerPath.indexOf('/uploadpath/');
  if (uploadPathIndex > -1) {
    fileUrl = '/profile' + fileUrl.substring(uploadPathIndex + '/uploadpath'.length);
  }
  const fileRootIndex = fileUrl.toLowerCase().indexOf('/file/');
  if (!fileUrl.startsWith('/profile/') && fileRootIndex > -1) {
    fileUrl = '/profile' + fileUrl.substring(fileRootIndex + '/file'.length);
  }
  if (!fileUrl.startsWith('http') && fileUrl.toLowerCase().startsWith('profile/')) {
    fileUrl = '/' + fileUrl;
  }
  if (fileUrl && !fileUrl.startsWith('http')) {
    if (!fileUrl.startsWith('/')) fileUrl = '/' + fileUrl;
    fileUrl = javaApi + fileUrl;
  }
  return fileUrl;
};
// 上传配置
const upload = reactive({
  // 上传的地址
@@ -379,7 +395,7 @@
    // 如果有图片,将 commonFileList 转换为文件列表格式
    if (row.commonFileList && Array.isArray(row.commonFileList) && row.commonFileList.length > 0) {
      deliveryFileList.value = row.commonFileList.map((file, index) => {
        const fileUrl = normalizeFileUrl(file.url || '');
        const fileUrl = getFileAccessUrl(file);
        
        return {
          uid: file.id || Date.now() + index,
@@ -421,7 +437,7 @@
  detailRow.value = row || null;
  const list = Array.isArray(row?.commonFileList) ? row.commonFileList : [];
  detailImages.value = list
    .map((f) => ({ url: normalizeFileUrl(f?.url || '') }))
    .map((f) => ({ url: getFileAccessUrl(f) }))
    .filter((i) => !!i.url);
  detailDialogVisible.value = true;
};