|
@@ -91,7 +91,7 @@
|
|
<el-form-item>
|
|
<el-form-item>
|
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
|
- <el-button
|
|
|
|
|
|
+ <!-- <el-button
|
|
type="success"
|
|
type="success"
|
|
plain
|
|
plain
|
|
@click="handleExport"
|
|
@click="handleExport"
|
|
@@ -99,7 +99,7 @@
|
|
v-hasPermi="['system:student-select-supervisor-record:export']"
|
|
v-hasPermi="['system:student-select-supervisor-record:export']"
|
|
>
|
|
>
|
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
|
- </el-button>
|
|
|
|
|
|
+ </el-button> -->
|
|
<el-button type="primary" @click="exportWordTemplate" :loading="exportLoading">批量导出互选表</el-button>
|
|
<el-button type="primary" @click="exportWordTemplate" :loading="exportLoading">批量导出互选表</el-button>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
@@ -210,6 +210,8 @@ 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 { exportDocx } from '@/utils/doc.js';
|
|
|
|
+import { selectionBookApi } from '@/api/system/studentSelectSupervisorRecord/selectionBook';
|
|
|
|
+
|
|
// import docxtemplater from "docxtemplater"
|
|
// import docxtemplater from "docxtemplater"
|
|
// import PizZip from "pizzip"
|
|
// import PizZip from "pizzip"
|
|
// import JSZipUtils from "jszip-utils"
|
|
// import JSZipUtils from "jszip-utils"
|
|
@@ -294,32 +296,41 @@ watch(selectedRows, (newSelection) => {
|
|
});
|
|
});
|
|
|
|
|
|
/** 导出按钮操作 */
|
|
/** 导出按钮操作 */
|
|
-const ibj = ref({
|
|
|
|
- name: '示例名称',
|
|
|
|
- conditionCons: [
|
|
|
|
- {
|
|
|
|
- groupName: '条件组 1',
|
|
|
|
- cont: '条件内容 1'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- groupName: '条件组 2',
|
|
|
|
- cont: '条件内容 2'
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
-});
|
|
|
|
const exportWordTemplate = async () => {
|
|
const exportWordTemplate = async () => {
|
|
- const fileName = '导出文档.docx';
|
|
|
|
- try {
|
|
|
|
- const response = await axios.get('/templates/templete.docx', {
|
|
|
|
- responseType: 'blob' // 确保以 blob 形式获取文件
|
|
|
|
- });
|
|
|
|
|
|
+ if (selectedRows.value.length === 0) {
|
|
|
|
+ message.error('请先选择需要导出的数据!');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const dataList = await Promise.all(selectedRows.value.map(async (row) => {
|
|
|
|
+ // 获取每一行的详细信息
|
|
|
|
+ const selectionBook = await selectionBookApi.getSelectionBook(row.id);
|
|
|
|
+ console.log(selectionBook);
|
|
|
|
+ return {
|
|
|
|
+ studentName: selectionBook.studentName,
|
|
|
|
+ userNumber: selectionBook.studentNumber,
|
|
|
|
+ major: selectionBook.major,
|
|
|
|
+ mobile: selectionBook.studentMobile,
|
|
|
|
+ nickname: selectionBook.supervisor,
|
|
|
|
+ // title: selectionBook.title,
|
|
|
|
+ title: selectionBook.supervisor,
|
|
|
|
+ studentAchievementRequirement: selectionBook.studentAchievementRequirement,
|
|
|
|
+ studentSignDate: new Date(selectionBook.studentSignDate).toLocaleDateString(),
|
|
|
|
+ supervisorSignDate: new Date(selectionBook.supervisorSignDate).toLocaleDateString(),
|
|
|
|
+ // studentSignature: selectionBook.studentSignature,
|
|
|
|
+ supervisorSignature: selectionBook.supervisorSignature,
|
|
|
|
+ studentSignature: "/logo.png"
|
|
|
|
+ };
|
|
|
|
+ }));
|
|
|
|
+ console.log("导出的数据对象:", dataList);
|
|
|
|
|
|
- // 使用你之前的 exportDocx 方法处理文件
|
|
|
|
- exportDocx(URL.createObjectURL(response.data), ibj.value, fileName);
|
|
|
|
|
|
+ const zipFileName = '师生互选表.zip';
|
|
|
|
+ try {
|
|
|
|
+ exportDocx("/templates/ceshi.docx", dataList, zipFileName);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error('导出文档失败:', error);
|
|
console.error('导出文档失败:', error);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+
|
|
// const exportWordTemplate = async () => {
|
|
// const exportWordTemplate = async () => {
|
|
// if (selectedRows.value.length === 0) {
|
|
// if (selectedRows.value.length === 0) {
|
|
// message.error('请先选择需要导出的数据!');
|
|
// message.error('请先选择需要导出的数据!');
|