gaoluyang
2025-03-07 d2a06b827fdcf4b274c503c25b3c21fd727ccbbc
文件下载全局修改
已修改28个文件
230 ■■■■■ 文件已修改
src/api/cnas/process/reportResults.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/plugins/download.js 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/reportResults/index.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/sampleDisposal/index.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/uncertainty/index.vue 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/resourceDemand/device/component/calibration.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/resourceDemand/device/component/equipmentAcceptance.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/lightning-protection-detection.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/correctiveAction/components/ViewTestRecord.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/customerSatisfaction/index.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentControl/components/FileList.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentRecords/approvalRecord.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentRecords/cancellationRecord.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentRecords/distributionCollectionRecord.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentRecords/outDocumenRecordt.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentRecords/regularReviewsRecord.vue 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentRecords/revisionRecord.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/internalAuditManagement/components/ViewTestRecord.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/managementReview/components/managementReviewPlan.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/inspectionTask/components/InspectionWord.vue 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/inspectionTask/inspection.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/productOrder/index.vue 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/reportPreparation/index.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/unpass/components/unPassDialog.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/structural/capabilityAndLaboratory/laboratory/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/cnas/process/reportResults.js
@@ -5,7 +5,7 @@
export function exportProcessReport(data) {
  return request({
    url: "/processReport/exportProcessReport",
    method: "post",
    method: "get",
    data: data,
  });
}
src/plugins/download.js
@@ -4,6 +4,7 @@
import { getToken } from "@/utils/auth";
import errorCode from "@/utils/errorCode";
import { blobValidate } from "@/utils/ruoyi";
import Vue from "vue";
const baseURL = process.env.VUE_APP_BASE_API;
let downloadLoadingInstance;
@@ -80,22 +81,37 @@
        downloadLoadingInstance.close();
      });
  },
  async downloadFileFromUrl(url, filename) {
    try {
      let state = /\.(jpg|jpeg|png|gif)$/i.test(url) // 判断是否为图片
      let url1 = ''
      if (state) {
        url1 = Vue.prototype.javaApi + '/img/' + url;
      } else {
        url1 = Vue.prototype.javaApi + '/word/' + url
      }
      // 使用 fetch 获取文件
      const response = await fetch(url1);
      if (!response.ok) {
        throw new Error('文件下载失败: ' + response.statusText);
      }
      // 将文件转换为 Blob
      const blob = await response.blob();
      // 使用 saveAs 保存文件
      saveAs(blob, filename);
      Message.success("数据导出成功");
    } catch (error) {
      Message.error(error);
    }
  },
  saveAs(text, name, opts) {
    if (typeof text === "string") {
      // 路径下载
    // 流下载
    blobToText(text).then((result) => {
      Message.error(result.msg);
    }).catch(() => {
      saveAs(text, name, opts);
      Message.success("数据导出成功");
    } else {
      // 流下载
      blobToText(text)
        .then((result) => {
          Message.error(result.msg);
        })
        .catch(() => {
          saveAs(text, name, opts);
          Message.success("数据导出成功");
        });
    }
    });
  },
  async printErrMsg(data) {
    const resText = await data.text();
src/views/CNAS/process/reportResults/index.vue
@@ -222,9 +222,7 @@
      this.outLoading = true
      exportProcessReport({ ids: this.mutilSelect.map(m => m.id) }).then(res => {
        this.outLoading = false
        if (res.code === 201) return
        const url = this.javaApi + '/word/' + res.data;
        this.$download.saveAs(url, "报告结果");
        this.$download.downloadFileFromUrl(res.data, "报告结果");
      })
    },
    openAdd() {
src/views/CNAS/process/sampleDisposal/index.vue
@@ -1,5 +1,5 @@
<template>
  <div class="sample-disposal">
  <div class="capacity-scope">
    <el-tabs type="border-card" v-model="activeName" style="height: 100%;" @tab-click="queryParams.totaldealId = ''">
      <el-tab-pane label="填写" name="填写" style="height: 100%;" :key="1">
        <el-button size="small" type="primary" @click="handleAdd0" style="margin-left: 20px;">新增</el-button>
@@ -505,9 +505,12 @@
    },
    // 导出详情
    handleDown0(row) {
      if (!row.url) {
        this.$message.warning('暂无文件')
        return
      }
      // 后端下载
      let url = this.javaApi + '/word/' + row.url
      this.$download.saveAs(url, row.month + ' 样品处理申请表');
      this.$download.downloadFileFromUrl(row.url, row.month + ' 样品处理申请表');
    },
    handleDelete(row) {
      this.$confirm("是否删除该条数据?", "提示", {
src/views/CNAS/process/uncertainty/index.vue
@@ -183,8 +183,11 @@
      })
    },
    handleDown(row) {
      let url = this.javaApi + '/word/' + row.reportUrl
      this.$download.saveAs(url, row.reportName);
      if (!row.reportUrl) {
        this.$message.warning('暂无文件')
        return
      }
      this.$download.downloadFileFromUrl(row.reportUrl, row.reportName);
    },
    beforeUpload(file) {
      if (file.size > 1024 * 1024 * 10) {
src/views/CNAS/resourceDemand/device/component/calibration.vue
@@ -416,14 +416,7 @@
      })
    },
    handleAttachmentClick(row) {
      let state = /\.(jpg|jpeg|png|gif)$/i.test(row.systemFileName)
      if (state) {
        let url = this.javaApi + '/img/' + row.systemFileName;
        this.$download.saveAs(url, row.systemFileName)
      } else {
        const url = this.javaApi + '/word/' + row.systemFileName
        this.$download.saveAs(url, row.systemFileName)
      }
      this.$download.downloadFileFromUrl(row.systemFileName, row.systemFileName)
    },
    //导出
    handleDown() {
src/views/CNAS/resourceDemand/device/component/equipmentAcceptance.vue
@@ -197,14 +197,7 @@
    },
    // 下载
    upload(row) {
      let url = '';
      if (row.type == 1) {
        url = this.javaApi + '/img/' + row.fileUrl
        this.$download.saveAs(url, row.fileName)
      } else {
        url = this.javaApi + '/word/' + row.fileUrl
        this.$download.saveAs(url, row.fileName)
      }
      this.$download.downloadFileFromUrl(row.fileUrl, row.fileName)
    },
    // 删除
    delete(row) {
src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/lightning-protection-detection.vue
@@ -250,9 +250,11 @@
      })
    },
    download(row) {
      let url = '';
      url = this.javaApi + '/img/' + row.systemFileName
      this.$download.saveAs(url, row.fileName)
      if (!row.systemFileName) {
        this.$message.warning('暂无文件')
        return
      }
      this.$download.downloadFileFromUrl(row.systemFileName, row.fileName)
    }
  }
}
src/views/CNAS/systemManagement/correctiveAction/components/ViewTestRecord.vue
@@ -111,14 +111,7 @@
    },
    // 下载
    upload(row) {
      let url = '';
      if (row.type == 1) {
        url = this.javaApi + '/img/' + row.fileUrl
        this.$download.saveAs(url, row.fileName);
      } else {
        url = this.javaApi + '/word/' + row.fileUrl
        this.$download.saveAs(url, row.fileName);
      }
      this.$download.downloadFileFromUrl(row.fileUrl, row.fileName);
    },
    // 删除
    delete(row) {
src/views/CNAS/systemManagement/customerSatisfaction/index.vue
@@ -307,14 +307,7 @@
    },
    // 下载客户福建
    upload(row) {
      let url = '';
      if (row.type == 1) {
        url = this.javaApi + '/img/' + row.fileUrl
        this.$download.saveAs(url, row.fileName);
      } else {
        url = this.javaApi + '/word/' + row.fileUrl
        this.$download.saveAs(url, row.fileName);
      }
      this.$download.downloadFileFromUrl(row.fileUrl, row.fileName);
    },
    // 删除客户分析附件
    delFile(row) {
src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue
@@ -461,8 +461,7 @@
    },
    handleDown(row) {
      if (!row.url) return this.$message.warning('文件未上传')
      let url = this.javaApi + '/word/' + row.url
      this.$download.saveAs(url, row.url);
      this.$download.downloadFileFromUrl(row.url, row.url);
    },
    async uploadPDF(pdfBlob) {
      const formData = new FormData();
src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue
@@ -568,8 +568,7 @@
    // 下载附件
    handleDown(row) {
      if (!row.alterAfterUrl) return this.$message.warning('文件未上传')
      let url = this.javaApi + '/word/' + row.alterAfterUrl
      this.$download.saveAs(url, row.alterAfterUrl)
      this.$download.downloadFileFromUrl(row.alterAfterUrl, row.alterAfterUrl)
    },
    // 打开审核弹框
    handleCheck(row) {
src/views/CNAS/systemManagement/documentControl/components/FileList.vue
@@ -252,8 +252,7 @@
    // 下载文件
    handleDown(row) {
      if (!row.url) return this.$message.warning('文件未上传')
      let url = this.javaApi + '/word/' + row.url
      this.$download.saveAs(url, row.url);
      this.$download.downloadFileFromUrl(row.url, row.url);
    },
    // 查看文件
    handleLook(row) {
src/views/CNAS/systemManagement/documentRecords/approvalRecord.vue
@@ -283,9 +283,7 @@
      // queryParams
      exportOutManageRecordCheck(this.queryParams).then(res => {
        this.outLoading = false
        if (res.code == 201) return this.$message.error('导出失败')
        let url = this.javaApi + '/word/' + res.data
        this.$download.saveAs(url, '文件审批记录')
        this.$download.downloadFileFromUrl(res.data, '文件审批记录')
      })
    },
    getAuthorizedPerson() {
src/views/CNAS/systemManagement/documentRecords/cancellationRecord.vue
@@ -243,9 +243,7 @@
      this.outLoading = true
      exportOutManageRecordCancel(this.queryParams).then(res => {
        this.outLoading = false
        if (res.code == 201) return this.$message.error('导出失败')
        let url = this.javaApi + '/word/' + res.data
        this.$download.saveAs(url, "作废文件销毁记录");
        this.$download.downloadFileFromUrl(res.data, "作废文件销毁记录");
      })
    },
    getList() {
src/views/CNAS/systemManagement/documentRecords/distributionCollectionRecord.vue
@@ -300,9 +300,7 @@
      this.outLoading = true
      exportOutManageRecordIssueRecycle(this.queryParams).then(res => {
        this.outLoading = false
        if (res.code == 201) return this.$message.error('导出失败')
        let url = this.javaApi + '/word/' + res.data
        this.$download.saveAs(url, '文件发放与回收记录')
        this.$download.downloadFileFromUrl(res.data, '文件发放与回收记录')
      })
    },
    getList() {
src/views/CNAS/systemManagement/documentRecords/outDocumenRecordt.vue
@@ -393,8 +393,7 @@
      }).catch(err => { });
    },
    handleDown0(row) {
      let url = this.javaApi + '/word/' + row.url
      this.$download.saveAs(url, '外来文件确认记录')
      this.$download.downloadFileFromUrl(row.url, '外来文件确认记录')
    },
    // 提交
    handleSubmit(row) {
src/views/CNAS/systemManagement/documentRecords/regularReviewsRecord.vue
@@ -345,9 +345,7 @@
      this.outLoading = true
      exportOutManageRecordIntervals(this.queryParams).then(res => {
        this.outLoading = false
        if (res.code == 201) return this.$message.error('导出失败')
        let url = this.javaApi + 'word/' + res.message
        this.$download.saveAs(url, "文件定期审查记录");
        this.$download.downloadFileFromUrl(res.message, "文件定期审查记录");
      })
    },
    getList() {
@@ -543,8 +541,7 @@
      }
    },
    handleDown0(row) {
      let url = this.javaApi + '/word/' + row.url
      this.$download.saveAs(url, "所有文件定期检查记录");
      this.$download.downloadFileFromUrl(row.url, "所有文件定期检查记录");
    },
    // 提交
    handleSubmit(row) {
src/views/CNAS/systemManagement/documentRecords/revisionRecord.vue
@@ -550,9 +550,7 @@
      this.outLoading = true
      exportOutManageRecordAudit(this.queryParams).then(res => {
        this.outLoading = false
        if (res.code == 201) return this.$message.error('导出失败')
        let url = this.javaApi + '/word/' + res.data
        this.$download.saveAs(url, "文件修订表");
        this.$download.downloadFileFromUrl(res.data, "文件修订表");
      })
    },
    getList() {
src/views/CNAS/systemManagement/internalAuditManagement/components/ViewTestRecord.vue
@@ -116,14 +116,7 @@
    },
    // 下载
    upload(row) {
      let url = '';
      if (row.type == 1) {
        url = this.javaApi + '/img/' + row.fileUrl
        this.$download.saveAs(url, row.fileName)
      } else {
        url = this.javaApi + '/word/' + row.fileUrl
        this.$download.saveAs(url, row.fileName)
      }
      this.$download.downloadFileFromUrl(row.fileUrl, row.fileName)
    },
    // 删除
    delete(row) {
src/views/CNAS/systemManagement/managementReview/components/managementReviewPlan.vue
@@ -282,8 +282,7 @@
    },
    handleDown0(url, name) {
      if (!url) return this.$message.warning('文件未上传')
      let url0 = this.javaApi + '/word/' + url
      this.$download.saveAs(url0, name);
      this.$download.downloadFileFromUrl(url, name);
    }
  }
};
src/views/business/inspectionTask/components/InspectionWord.vue
@@ -247,7 +247,7 @@
import AddUnPass from "@/views/business/unpass/components/addUnPass.vue";
import {
  checkSubmitPlan,
  doInsOrder,
  doInsOrder, downFile,
  getInsProductUnqualifiedRetest,
  search, selectUserCondition,
  submitPlan,
@@ -2036,16 +2036,7 @@
      downFile({
        id: row.id,
      }).then(res => {
        if (res.code === 200) {
          let url = '';
          if (res.data.type == 1) {
            url = this.javaApi + '/img/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          } else {
            url = this.javaApi + '/word/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          }
        }
        this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName);
      }).catch(error => {
      })
src/views/business/inspectionTask/inspection.vue
@@ -2884,16 +2884,7 @@
    },
    handleDown(row) {
      downFile({ id: row.id }).then((res) => {
        if (res.code === 200) {
          let url = "";
          if (res.data.type == 1) {
            url = this.javaApi + "/img/" + res.data.fileUrl;
            this.$download.saveAs(url, row.fileName)
          } else {
            url = this.javaApi + "/word/" + res.data.fileUrl;
            this.$download.saveAs(url, row.fileName)
          }
        }
        this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName)
      })
        .catch((error) => { });
    },
src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue
@@ -154,16 +154,7 @@
    // 下载
    handleDown(row) {
      downFile({ id: row.id, }).then(res => {
        if (res.code === 200) {
          let url = '';
          if (res.data.type == 1) {
            url = this.javaApi + '/img/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          } else {
            url = this.javaApi + '/word/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          }
        }
        this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName);
      }).catch(error => {
      })
src/views/business/productOrder/index.vue
@@ -986,25 +986,16 @@
      downFile({
        id: row.id,
      }).then(res => {
        if (res.code === 200) {
          let url = '';
          if (res.data.type == 1) {
            url = this.javaApi + '/img/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          } else {
            url = this.javaApi + '/word/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          }
        }
        this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName);
      }).catch(error => {
      })
    },
    // 下载报告
    download(row) {
      let url = this.javaApi + '/word/' + row.urlS ? row.urlS : row.url;
      let url = row.urlS ? row.urlS : row.url;
      if (url) {
        this.$download.saveAs(url, this.downLoadInfo.fileName);
        this.$download.downloadFileFromUrl(url, this.downLoadInfo.fileName);
      }
    },
    // 撤销
src/views/business/reportPreparation/index.vue
@@ -547,16 +547,7 @@
      downFile({
        id: row.id,
      }).then(res => {
        if (res.code === 200) {
          let url = '';
          if (res.data.type == 1) {
            url = this.javaApi + '/img/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          } else {
            url = this.javaApi + '/word/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          }
        }
        this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName);
      }).catch(error => {
      })
src/views/business/unpass/components/unPassDialog.vue
@@ -180,16 +180,7 @@
      downFile({
        id: row.id,
      }).then(res => {
        if (res.code === 200) {
          let url = '';
          if (res.data.type == 1) {
            url = this.javaApi + '/img/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          } else {
            url = this.javaApi + '/word/' + res.data.fileUrl
            this.$download.saveAs(url, row.fileName);
          }
        }
        this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName);
      }).catch(error => {
      })
src/views/structural/capabilityAndLaboratory/laboratory/index.vue
@@ -332,8 +332,7 @@
        this.$message.warning('暂无附件')
        return;
      }
      const url = this.javaApi + "/img/" + row.fileUrl;
      this.$download.saveAs(url, row.fileUrl);
      this.$download.downloadFileFromUrl(row.fileUrl, row.fileUrl);
    },
    openAdd() {
      this.qualificationsConnectVisible = true;