gaoluyang
2025-11-07 d8eee22dbe6a44acdd8c35a65261759747d9a8c7
src/views/personnelManagement/contractManagement/index.vue
@@ -74,7 +74,7 @@
import { onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick } from "vue";
import FormDia from "@/views/personnelManagement/contractManagement/components/formDia.vue";
import { ElMessageBox } from "element-plus";
import { staffOnJobListPage } from "@/api/personnelManagement/employeeRecord.js";
import { staffOnJobListPage, staffOnJobExportCopy } from "@/api/personnelManagement/employeeRecord.js";
import dayjs from "dayjs";
import { getToken } from "@/utils/auth.js";
import FilesDia from "./filesDia.vue";
@@ -287,8 +287,30 @@
};
// 下载合同
const handleDownloadContract = (row) => {
  const fileName = `${row.staffName}劳动合同.xlsx`;
  proxy.download("/staff/staffOnJob/exportCopy", { ...row }, fileName);
  const fileName = `${row.staffName || "合同"}劳动合同.docx`;
  proxy.$modal?.loading?.("正在生成合同,请稍候...");
  staffOnJobExportCopy({ ...row })
    .then((res) => {
      proxy.$modal?.closeLoading?.();
      if (res?.code === 200 && res?.msg) {
        const javaApi = proxy.javaApi || import.meta.env.VITE_JAVA_API || "";
        const downloadPath = res.msg.startsWith("/") ? res.msg : `/${res.msg}`;
        const downloadUrl = `${javaApi}${downloadPath}`;
        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 || "合同生成失败");
      }
    })
    .catch(() => {
      proxy.$modal?.closeLoading?.();
      proxy.$modal.msgError("合同生成失败,请稍后重试");
    });
};
const upload = reactive({
  // 是否显示弹出层(合同导入)