| | |
| | | import dayjs from "dayjs"; |
| | | import { getToken } from "@/utils/auth.js"; |
| | | import FilesDia from "./filesDia.vue"; |
| | | import axios from "axios"; |
| | | const data = reactive({ |
| | | searchForm: { |
| | | staffName: "", |
| | |
| | | const javaApi = proxy.javaApi || import.meta.env.VITE_JAVA_API || ""; |
| | | const downloadPath = res.msg.startsWith("/") ? res.msg : `/${res.msg}`; |
| | | const downloadUrl = `${javaApi}${downloadPath}`; |
| | | axios({ |
| | | url: downloadUrl, |
| | | method: "get", |
| | | responseType: "blob", |
| | | headers: { Authorization: "Bearer " + getToken() } |
| | | }) |
| | | .then((resp) => { |
| | | const blob = new Blob([resp.data], { |
| | | type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" |
| | | }); |
| | | const url = window.URL.createObjectURL(blob); |
| | | const link = document.createElement("a"); |
| | | link.href = url; |
| | | link.download = fileName; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | window.URL.revokeObjectURL(url); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msgError("合同下载失败,请稍后重试"); |
| | | }); |
| | | const link = document.createElement("a"); |
| | | link.href = downloadUrl; |
| | | link.download = fileName; |
| | | link.target = "_blank"; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | } else { |
| | | proxy.$modal.msgError(res?.msg || "合同生成失败"); |
| | | } |