From e747323f265bc50fd41626c962e95e10e8b4bdb4 Mon Sep 17 00:00:00 2001 From: Dai Date: Wed, 9 Oct 2024 22:06:41 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E6=8E=92=E8=AF=BE?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TeacherScheduleTimeController.php | 17 ++++++---- .../export_schedule_index.html | 34 +++++++++++++++++-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/plugin/admin/app/controller/TeacherScheduleTimeController.php b/plugin/admin/app/controller/TeacherScheduleTimeController.php index df6b4f4..468e275 100644 --- a/plugin/admin/app/controller/TeacherScheduleTimeController.php +++ b/plugin/admin/app/controller/TeacherScheduleTimeController.php @@ -441,11 +441,12 @@ class TeacherScheduleTimeController extends Crud { try { $month = $request->get('month'); + $is_publish = $request->get('is_publish'); $summary = \app\common\model\TeacherScheduleTime::order('ts.start_time asc')->alias('ts') ->leftJoin('teacher t', 'ts.teacher_id = t.id') ->leftJoin('student_schedule ss', 'ts.id = ss.teacher_schedule_time_id and t.id = ss.teacher_id') ->leftJoin('subject sb', 'ts.subject_id = sb.id') - ->where(['ts.is_publish' => 1, 'ts.month' => $month]) + ->where(['ts.is_publish' => $is_publish, 'ts.month' => $month]) ->field(' t.teacher_name, ts.time, @@ -477,9 +478,10 @@ class TeacherScheduleTimeController extends Crud $worksheet->setCellValue('D1', 'UK Time'); $worksheet->setCellValue('E1', 'Subject'); $worksheet->setCellValue('F1', 'Tutor'); - $worksheet->setCellValue('G1', 'Duration'); - $worksheet->setCellValue('H1', 'Note'); - $worksheet->getStyle('A1:H1')->getFill() + $worksheet->setCellValue('G1', 'Student'); + $worksheet->setCellValue('H1', 'Duration'); + $worksheet->setCellValue('I1', 'Note'); + $worksheet->getStyle('A1:I1')->getFill() ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID) ->getStartColor()->setRGB('4f81bd'); @@ -504,6 +506,7 @@ class TeacherScheduleTimeController extends Crud $en_time = ''; $subject_name = ''; $teacher_name = ''; + $student_name = ''; $hour = ''; if (isset($export_data[$date])) { $merge_count = count($export_data[$date]); @@ -513,6 +516,7 @@ class TeacherScheduleTimeController extends Crud $en_time = $schedule_time['en_time']; $subject_name = $schedule_time['english_name']; $teacher_name = $schedule_time['teacher_name']; + $student_name = $schedule_time['student_name']; $hour = $schedule_time['hour']; } @@ -530,8 +534,9 @@ class TeacherScheduleTimeController extends Crud $worksheet->setCellValue('D' . $row, $en_time); $worksheet->setCellValue('E' . $row, $subject_name); $worksheet->setCellValue('F' . $row, $teacher_name); - $worksheet->setCellValue('G' . $row, $hour); - $worksheet->setCellValue('H' . $row, ''); + $worksheet->setCellValue('G' . $row, $student_name); + $worksheet->setCellValue('H' . $row, $hour); + $worksheet->setCellValue('I' . $row, ''); } $writer = new Xlsx($spreadsheet); diff --git a/plugin/admin/app/view/teacher-schedule-time/export_schedule_index.html b/plugin/admin/app/view/teacher-schedule-time/export_schedule_index.html index e3fbd9f..64d0e40 100644 --- a/plugin/admin/app/view/teacher-schedule-time/export_schedule_index.html +++ b/plugin/admin/app/view/teacher-schedule-time/export_schedule_index.html @@ -29,7 +29,8 @@ @@ -169,6 +170,8 @@ edit(obj); }else if (obj.event === "export_schedule") { export_schedule(obj); + }else if (obj.event === "export_unpublish_schedule") { + export_unpublish_schedule(obj); } else if (obj.event === "rest_password") { rest_password(obj); } @@ -253,7 +256,34 @@ let export_schedule = function(obj) { let month = obj.data['month']; layui.$.ajax({ - url: '/app/admin/teacherScheduleTime/exportSummary?month=' + month, + url: '/app/admin/teacherScheduleTime/exportSummary?is_publish=1&month=' + month, + type: "POST", + dateType: "json", + success: function (res) { + if (res.code) { + return layui.popup.failure(res.msg); + } + console.log(111,res.data) + const link = document.createElement('a'); + link.style.display = 'none'; + // 设置下载地址 + link.setAttribute('href', res.data.file_url); + // 设置文件名 + link.setAttribute('download', res.data.file_name); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + return layui.popup.success("操作成功", function () { + parent.refreshTable(); + parent.layer.close(parent.layer.getFrameIndex(window.name)); + }); + } + }); + }// 老师课程安排 + let export_unpublish_schedule = function(obj) { + let month = obj.data['month']; + layui.$.ajax({ + url: '/app/admin/teacherScheduleTime/exportSummary?is_publish=0&month=' + month, type: "POST", dateType: "json", success: function (res) {