|
@@ -199,25 +199,18 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
import { ref } from 'vue'
|
|
-import axios from 'axios';
|
|
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
-import download from '@/utils/download'
|
|
|
|
-import { supervisorSelectionSettingApi, supervisorSelectionSettingVO } from '@/api/system/supervisorSelectionSetting'
|
|
|
|
import * as UserApi from '@/api/system/user'
|
|
import * as UserApi from '@/api/system/user'
|
|
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
|
|
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
|
|
import {studentSelectSupervisorRecordApi, studentSelectSupervisorRecordVO} from "@/api/system/studentSelectSupervisorRecord";
|
|
import {studentSelectSupervisorRecordApi, studentSelectSupervisorRecordVO} from "@/api/system/studentSelectSupervisorRecord";
|
|
import {DICT_TYPE} from "@/utils/dict";
|
|
import {DICT_TYPE} from "@/utils/dict";
|
|
import studentSelectSupervisorRecordForm from './studentSelectSupervisorRecordForm.vue'
|
|
import studentSelectSupervisorRecordForm from './studentSelectSupervisorRecordForm.vue'
|
|
import {studentSelectionProjectApi} from "@/api/system/studentSelectionProject"
|
|
import {studentSelectionProjectApi} from "@/api/system/studentSelectionProject"
|
|
-import { exportDocx } from '@/utils/doc.js';
|
|
|
|
|
|
+import ExportWord from '@/utils/doc.ts';
|
|
import { selectionBookApi } from '@/api/system/studentSelectSupervisorRecord/selectionBook';
|
|
import { selectionBookApi } from '@/api/system/studentSelectSupervisorRecord/selectionBook';
|
|
|
|
+import { saveAs } from "file-saver";
|
|
|
|
|
|
-// import docxtemplater from "docxtemplater"
|
|
|
|
-// import PizZip from "pizzip"
|
|
|
|
-// import JSZipUtils from "jszip-utils"
|
|
|
|
-// import JSZip from "jszip"
|
|
|
|
-// import { saveAs } from 'file-saver'
|
|
|
|
-// import { htmlPdf } from "@/utils/htmlToPDF.js"
|
|
|
|
|
|
+import JSZip from "jszip"
|
|
|
|
|
|
/** 导师学硕专硕名额设置 列表 */
|
|
/** 导师学硕专硕名额设置 列表 */
|
|
defineOptions({ name: 'RecordList' })
|
|
defineOptions({ name: 'RecordList' })
|
|
@@ -311,21 +304,41 @@ const exportWordTemplate = async () => {
|
|
major: selectionBook.major,
|
|
major: selectionBook.major,
|
|
mobile: selectionBook.studentMobile,
|
|
mobile: selectionBook.studentMobile,
|
|
nickname: selectionBook.supervisor,
|
|
nickname: selectionBook.supervisor,
|
|
- // title: selectionBook.title,
|
|
|
|
title: selectionBook.supervisor,
|
|
title: selectionBook.supervisor,
|
|
studentAchievementRequirement: selectionBook.studentAchievementRequirement,
|
|
studentAchievementRequirement: selectionBook.studentAchievementRequirement,
|
|
studentSignDate: new Date(selectionBook.studentSignDate).toLocaleDateString(),
|
|
studentSignDate: new Date(selectionBook.studentSignDate).toLocaleDateString(),
|
|
supervisorSignDate: new Date(selectionBook.supervisorSignDate).toLocaleDateString(),
|
|
supervisorSignDate: new Date(selectionBook.supervisorSignDate).toLocaleDateString(),
|
|
- // studentSignature: selectionBook.studentSignature,
|
|
|
|
- supervisorSignature: selectionBook.supervisorSignature,
|
|
|
|
|
|
+ supervisorSignature: "/logo.png",
|
|
studentSignature: "/logo.png"
|
|
studentSignature: "/logo.png"
|
|
};
|
|
};
|
|
}));
|
|
}));
|
|
console.log("导出的数据对象:", dataList);
|
|
console.log("导出的数据对象:", dataList);
|
|
-
|
|
|
|
- const zipFileName = '师生互选表.zip';
|
|
|
|
|
|
+ const zip = new JSZip();
|
|
|
|
+
|
|
|
|
+ const newFileName = '我就不信了.docx';
|
|
try {
|
|
try {
|
|
- exportDocx("/templates/ceshi.docx", dataList, zipFileName);
|
|
|
|
|
|
+ // 使用 for 循环遍历 dataList 并生成多个 .docx 文件
|
|
|
|
+ for (let i = 0; i < dataList.length; i++) {
|
|
|
|
+ const data = dataList[i];
|
|
|
|
+ const _word = new ExportWord({
|
|
|
|
+ url: '/templates/newceshi.docx',
|
|
|
|
+ filename: newFileName,
|
|
|
|
+ obj: data
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 使用 await 确保每个 Word 文件生成并下载前才继续执行
|
|
|
|
+ await _word.initWord((_this) => {
|
|
|
|
+ const out = _this.addDownloadFile(); // 获取文件的 Blob
|
|
|
|
+ console.log(`document_${i + 1}.docx 文件已生成`);
|
|
|
|
+
|
|
|
|
+ // 将生成的 .docx 文件添加到 zip 压缩包中
|
|
|
|
+ zip.file(`document_${i + 1}.docx`, out);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 生成 zip 文件并保存
|
|
|
|
+ const zipBlob = await zip.generateAsync({ type: 'blob' });
|
|
|
|
+ saveAs(zipBlob, "导出文件.zip");
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error('导出文档失败:', error);
|
|
console.error('导出文档失败:', error);
|
|
}
|
|
}
|