3333
This commit is contained in:
@@ -112,7 +112,7 @@
|
||||
plain
|
||||
size="small"
|
||||
icon="Download"
|
||||
@click="download(contract.generatedDocxFileId)"
|
||||
@click="download(contract.generatedDocxFileId, `${detail?.employee?.employeeName || '员工'}_${contract.contractName || '入职合同'}.docx`)"
|
||||
>
|
||||
下载合同 DOCX
|
||||
</el-button>
|
||||
@@ -159,6 +159,7 @@
|
||||
<script setup lang="ts" name="onboardingEmployee">
|
||||
import { ref } from "vue";
|
||||
import { UserFilled, Download } from "@element-plus/icons-vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import {
|
||||
onboardingTaskApi,
|
||||
type OnboardingEmployee
|
||||
@@ -243,8 +244,42 @@ async function showDetail(row: OnboardingEmployee) {
|
||||
detailVisible.value = true;
|
||||
}
|
||||
|
||||
function download(fileId: number) {
|
||||
window.open(`/api/sys/dev/file/download?id=${fileId}`, "_blank");
|
||||
function resolveDownloadFileName(response: any, fallbackFileName?: string) {
|
||||
const disposition = String(response?.headers?.["content-disposition"] || "");
|
||||
const encodedName =
|
||||
disposition.match(/filename\*=UTF-8\'\'([^;]+)/i)?.[1] ||
|
||||
disposition.match(/filename="?([^";]+)"?/i)?.[1];
|
||||
|
||||
if (encodedName) {
|
||||
try {
|
||||
return decodeURIComponent(encodedName.replace(/\+/g, "%20"));
|
||||
} catch {
|
||||
return encodedName;
|
||||
}
|
||||
}
|
||||
|
||||
return fallbackFileName || "入职合同.docx";
|
||||
}
|
||||
|
||||
async function download(fileId: number, fallbackFileName?: string) {
|
||||
try {
|
||||
const response: any = await onboardingTaskApi.downloadFile(fileId);
|
||||
const blob = response?.data;
|
||||
if (!(blob instanceof Blob)) {
|
||||
throw new Error("服务器未返回有效的文件流");
|
||||
}
|
||||
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const link = document.createElement("a");
|
||||
link.href = objectUrl;
|
||||
link.download = resolveDownloadFileName(response, fallbackFileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 0);
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.msg || error?.message || "合同文件下载失败");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
|
||||
<el-table-column prop="variableName" label="中文显示名称" min-width="160" />
|
||||
|
||||
<el-table-column prop="sortCode" label="排序" width="80" align="center" sortable />
|
||||
|
||||
<el-table-column prop="dataType" label="数据类型" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" type="info">{{ row.dataType || 'string' }}</el-tag>
|
||||
|
||||
@@ -1320,6 +1320,10 @@ async function onOnboardingTemplateChange(templateId: number) {
|
||||
const contractName = contractTemplates.value.find(item => item.id === contract.contractTemplateId)?.templateName || "合同";
|
||||
return (variableResults[index].data?.list || [])
|
||||
.filter(variable => variable.hrEditable && ["contract", "company"].includes(variable.variableType))
|
||||
.sort((left, right) => {
|
||||
const sortResult = (left.sortCode ?? 100) - (right.sortCode ?? 100);
|
||||
return sortResult || left.variableCode.localeCompare(right.variableCode);
|
||||
})
|
||||
.map(variable => ({
|
||||
contractTemplateVersionId: contract.contractTemplateVersionId,
|
||||
variableCode: variable.variableCode,
|
||||
@@ -1423,10 +1427,15 @@ async function copyOrShareTaskLink(row: OnboardingTask) {
|
||||
}
|
||||
}
|
||||
|
||||
async function showDetail(row: OnboardingTask) {
|
||||
async function showDetail(row: OnboardingTask, preserveTab: boolean = false) {
|
||||
const currentTab = activeDetailTab.value;
|
||||
const { data }: any = await onboardingTaskApi.detail({ id: row.id });
|
||||
detail.value = data;
|
||||
activeDetailTab.value = "profile";
|
||||
if (!preserveTab) {
|
||||
activeDetailTab.value = "profile";
|
||||
} else {
|
||||
activeDetailTab.value = currentTab || "profile";
|
||||
}
|
||||
detailVisible.value = true;
|
||||
void loadMaterialPreviews(data?.materials || []);
|
||||
}
|
||||
@@ -1539,7 +1548,7 @@ async function generate(taskContractId: number) {
|
||||
await onboardingTaskApi.generateContract(taskContractId);
|
||||
ElMessage.success("DOCX合同文件已生成");
|
||||
if (detail.value?.task?.id) {
|
||||
await showDetail(detail.value.task);
|
||||
await showDetail(detail.value.task, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1580,7 +1589,7 @@ async function reviewMaterial(taskMaterialId: number, reviewStatus: string) {
|
||||
ElMessage.success(reviewStatus === "passed" ? "该材料已标记为合格" : "已标记需补充");
|
||||
|
||||
if (detail.value?.task) {
|
||||
await showDetail(detail.value.task);
|
||||
await showDetail(detail.value.task, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user