spring
2025-03-07 e5bdee63dd988a12883fb5bcb760a91d77a455d0
文件导出封装优化
已修改23个文件
144 ■■■■■ 文件已修改
src/plugins/download.js 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/ensureResults/ensureResultsValidity/components/ViewRecord.vue 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/method/methodVerification/components/ViewTestRecord.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/method/methodVerification/components/calibrationsFileDia.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/method/methodVerification/components/viewWorkPermitDia.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/reportResults/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/sampleDisposal/sampleDisposal.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/sampleDisposal/sampleRegistration.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/uncertainty/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/correctiveAction/components/ViewTestRecord.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/customerManagement/customerSatisfaction.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/systemManagement/documentControl/components/FileList.vue 4 ●●● 补丁 | 查看 | 原始文档 | 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 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/structural/capabilityAndLaboratory/laboratory/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/plugins/download.js
@@ -80,11 +80,30 @@
        downloadLoadingInstance.close();
      });
  },
  saveAs(text, name, opts) {
  async saveAs(text, name, opts) {
    if (typeof text === "string") {
      // 路径下载
      saveAs(text, name, opts);
      try {
        let state = /\.(jpg|jpeg|png|gif)$/i.test(text); // 判断是否为图片
        let url1 = "";
        if (state) {
          url1 = Vue.prototype.javaApi + "/img/" + text;
        } else {
          url1 = Vue.prototype.javaApi + "/word/" + text;
        }
        // 使用 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);
      }
    } else {
      // 流下载
      blobToText(text)
src/views/CNAS/process/ensureResults/ensureResultsValidity/components/ViewRecord.vue
@@ -107,15 +107,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.fileUrlrow.fileName;
        link.click();
        this.$download.saveAs(url, row.fileName)
      }
      this.$download.saveAs(row.fileUrl, row.fileName)
    },
    // 删除
    delete(row) {
src/views/CNAS/process/method/methodVerification/components/ViewTestRecord.vue
@@ -106,14 +106,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.saveAs(row.fileUrl, row.fileName)
    },
    // 删除
    delete(row) {
src/views/CNAS/process/method/methodVerification/components/calibrationsFileDia.vue
@@ -93,14 +93,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.saveAs(row.fileUrl, row.fileName)
    },
  }
};
src/views/CNAS/process/method/methodVerification/components/viewWorkPermitDia.vue
@@ -89,14 +89,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.saveAs(row.fileUrl, row.fileName)
    },
  },
};
src/views/CNAS/process/reportResults/index.vue
@@ -223,8 +223,7 @@
      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.saveAs(res.data, "报告结果")
      })
    },
    openAdd() {
src/views/CNAS/process/sampleDisposal/sampleDisposal.vue
@@ -506,8 +506,7 @@
    // 导出详情
    handleDown0(row) {
      // 后端下载
      let url = this.javaApi + '/word/' + row.url
      this.$download.saveAs(url, row.month + ' 样品处理申请表');
      this.$download.saveAs(row.url, row.month + ' 样品处理申请表')
    },
    handleDelete(row) {
      this.$confirm("是否删除该条数据?", "提示", {
src/views/CNAS/process/sampleDisposal/sampleRegistration.vue
@@ -535,8 +535,7 @@
    // 导出详情
    handleDown0(row) {
      // 后端下载
      let url = this.javaApi + '/word/' + row.url
      this.$download.saveAs(url, row.month + ' 样品接收表')
      this.$download.saveAs(row.url, row.month + ' 样品接收表')
    },
    // 删除
    handleDelete(row) {
src/views/CNAS/process/uncertainty/index.vue
@@ -183,8 +183,7 @@
      })
    },
    handleDown(row) {
      let url = this.javaApi + '/word/' + row.reportUrl
      this.$download.saveAs(url, row.reportName);
      this.$download.saveAs(row.reportUrl, row.reportName)
    },
    beforeUpload(file) {
      if (file.size > 1024 * 1024 * 10) {
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.saveAs(row.fileUrl, row.fileUrl)
    },
    // 删除
    delete(row) {
src/views/CNAS/systemManagement/customerManagement/customerSatisfaction.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.saveAs(row.fileUrl, row.fileName)
    },
    // 删除客户分析附件
    delFile(row) {
src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue
@@ -460,9 +460,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.saveAs(row.url, row.url)
    },
    async uploadPDF(pdfBlob) {
      const formData = new FormData();
src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue
@@ -567,9 +567,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.saveAs(row.alterAfterUrl, row.alterAfterUrl)
    },
    // 打开审核弹框
    handleCheck(row) {
src/views/CNAS/systemManagement/documentControl/components/FileList.vue
@@ -251,9 +251,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.saveAs(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.saveAs(row.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.saveAs(row.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.saveAs(row.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.saveAs(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.saveAs(row.data, '文件定期审查记录')
      })
    },
    getList() {
@@ -543,8 +541,7 @@
      }
    },
    handleDown0(row) {
      let url = this.javaApi + '/word/' + row.url
      this.$download.saveAs(url, "所有文件定期检查记录");
      this.$download.saveAs(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.saveAs(row.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.saveAs(row.fileUrl, row.fileName)
    },
    // 删除
    delete(row) {
src/views/CNAS/systemManagement/managementReview/components/managementReviewPlan.vue
@@ -281,9 +281,7 @@
      this.lookDialogVisible = true
    },
    handleDown0(url, name) {
      if (!url) return this.$message.warning('文件未上传')
      let url0 = this.javaApi + '/word/' + url
      this.$download.saveAs(url0, name);
      this.$download.saveAs(url, name)
    }
  }
};
src/views/structural/capabilityAndLaboratory/laboratory/index.vue
@@ -328,8 +328,7 @@
    },
    // 资质明细附件下载
    handleDownLoad(row) {
      const url = process.env.VUE_APP_BASE_API + "/img/" + row.fileUrl;
      this.$download.saveAs(url, row.fileUrl);
      this.$download.saveAs(row.fileUrl, row.fileUrl)
    },
    openAdd() {
      this.qualificationsConnectVisible = true;