From 7b84d499a9baba1778e2c9529a71a3357c95fddf Mon Sep 17 00:00:00 2001 From: zhaichao Date: Sun, 20 Sep 2026 17:22:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E8=AF=BE=E7=AA=97=E5=8F=A3=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=A0=BC=E5=8D=95=E5=87=BB=E5=8F=8C=E9=80=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TeachingPlanServiceImpl.java | 49 ++++++++++++++----- frontend/src/api/schedule/teachingPlan.js | 4 +- .../src/views/schedule/planImport/index.vue | 15 +++++- .../teachBusiness/schedulingWindow/index.vue | 25 ++++++++-- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/backend/roomroot-jwgl/src/main/java/com/roomroot/jwgl/service/impl/TeachingPlanServiceImpl.java b/backend/roomroot-jwgl/src/main/java/com/roomroot/jwgl/service/impl/TeachingPlanServiceImpl.java index 5f8fe1b5a..4e8ec4c14 100644 --- a/backend/roomroot-jwgl/src/main/java/com/roomroot/jwgl/service/impl/TeachingPlanServiceImpl.java +++ b/backend/roomroot-jwgl/src/main/java/com/roomroot/jwgl/service/impl/TeachingPlanServiceImpl.java @@ -117,32 +117,59 @@ public class TeachingPlanServiceImpl implements TeachingPlanService { "责任单位", "授课教员", "教学场地", "教学内容", "教学方法", "教员备注", "教务备注", "检查结果", "课程表编号" }; - String[] example = { - "1", "2026", "", "2026-03-02 08:00:00", "", "1", "高等数学", "1班", - "基础教研室", "张三", "教学楼A-101", "函数与极限", "讲授", - "", "", "", "" + String[][] examples = { + {"1", "2026", "", "2026-03-02 08:00:00", "", "1", "高等数学(测试)", "1班", + "基础教研室", "张三", "教学楼A-101", "函数与极限", "讲授", + "导入测试样例1", "", "通过", ""}, + {"2", "2026", "", "2026-03-02 10:00:00", "", "3", "大学物理(测试)", "2班", + "物理教研室", "李四", "实验楼B-203", "牛顿定律", "实验", + "导入测试样例2", "", "", ""}, + {"3", "2026", "", "2026-03-03 14:00:00", "", "5", "军事理论(测试)", "3班", + "指挥教研室", "王五", "阶梯教室C-1", "战役概论", "研讨", + "导入测试样例3", "联教联训", "", ""} }; try (Workbook wb = new XSSFWorkbook(); ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + org.apache.poi.ss.usermodel.Font headerFont = wb.createFont(); + headerFont.setFontName("宋体"); + headerFont.setBold(true); + headerFont.setFontHeightInPoints((short) 11); + org.apache.poi.ss.usermodel.CellStyle headerStyle = wb.createCellStyle(); + headerStyle.setFont(headerFont); + org.apache.poi.ss.usermodel.Font dataFont = wb.createFont(); + dataFont.setFontName("宋体"); + dataFont.setFontHeightInPoints((short) 11); + org.apache.poi.ss.usermodel.CellStyle dataStyle = wb.createCellStyle(); + dataStyle.setFont(dataFont); + Sheet sheet = wb.createSheet("教学实施计划"); Row header = sheet.createRow(0); for (int i = 0; i < headers.length; i++) { - header.createCell(i).setCellValue(headers[i]); - sheet.setColumnWidth(i, 14 * 256); + org.apache.poi.ss.usermodel.Cell cell = header.createCell(i); + cell.setCellValue(headers[i]); + cell.setCellStyle(headerStyle); + sheet.setColumnWidth(i, 16 * 256); } - Row row = sheet.createRow(1); - for (int i = 0; i < example.length; i++) { - row.createCell(i).setCellValue(example[i]); + for (int r = 0; r < examples.length; r++) { + Row row = sheet.createRow(r + 1); + for (int i = 0; i < examples[r].length; i++) { + org.apache.poi.ss.usermodel.Cell cell = row.createCell(i); + cell.setCellValue(examples[r][i]); + cell.setCellStyle(dataStyle); + } } Sheet help = wb.createSheet("填写说明"); String[] notes = { "1. 数据从第2行开始填写,第1行表头请勿修改,列顺序固定不可调整。", "2. 「课程名称」必填,课程名称为空的行将被跳过;其余列可留空。", "3. 「序号」「年度」「节次」为整数;「日期」支持 yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss。", - "4. 第2行为示例数据,导入前请删除。", + "4. 第2至4行为测试样例,可直接导入验证。", "5. 标识号、登录编号由系统自动生成,无需填写。" }; for (int i = 0; i < notes.length; i++) { - help.createRow(i).createCell(0).setCellValue(notes[i]); + org.apache.poi.ss.usermodel.Row noteRow = help.createRow(i); + org.apache.poi.ss.usermodel.Cell noteCell = noteRow.createCell(0); + noteCell.setCellValue(notes[i]); + noteCell.setCellStyle(dataStyle); } help.setColumnWidth(0, 100 * 256); wb.write(bos); diff --git a/frontend/src/api/schedule/teachingPlan.js b/frontend/src/api/schedule/teachingPlan.js index ca90ff233..b2c013a6f 100644 --- a/frontend/src/api/schedule/teachingPlan.js +++ b/frontend/src/api/schedule/teachingPlan.js @@ -20,7 +20,9 @@ export function importTeachingPlan(file) { return request({ url: '/teachingPlan/import', method: 'post', - data: formData + data: formData, + headers: { 'Content-Type': 'multipart/form-data' }, + timeout: 60000 }) } diff --git a/frontend/src/views/schedule/planImport/index.vue b/frontend/src/views/schedule/planImport/index.vue index 76358040e..d5cd64a3b 100644 --- a/frontend/src/views/schedule/planImport/index.vue +++ b/frontend/src/views/schedule/planImport/index.vue @@ -76,6 +76,7 @@
+ 【教学实施计划模板】下载 选择文件 {{ selectedFileName }} @@ -144,7 +145,8 @@