From 50387c6b29136e2eb3c7e145997dd567265ed4e2 Mon Sep 17 00:00:00 2001 From: Dai Date: Sun, 17 Nov 2024 22:03:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=95=99=E5=B8=88=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=8F=91=E5=B8=83=E6=8E=92=E8=AF=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TeacherScheduleTimeController.php | 49 +++++++++++++++++ .../app/view/teacher-schedule-time/index.html | 53 ++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/plugin/admin/app/controller/TeacherScheduleTimeController.php b/plugin/admin/app/controller/TeacherScheduleTimeController.php index fac5707..a902a94 100644 --- a/plugin/admin/app/controller/TeacherScheduleTimeController.php +++ b/plugin/admin/app/controller/TeacherScheduleTimeController.php @@ -357,6 +357,7 @@ class TeacherScheduleTimeController extends Crud } + /** * @desc 时间列表 * @param Request $request @@ -504,6 +505,54 @@ class TeacherScheduleTimeController extends Crud } } + /** + * @desc 更改教师排课状态 + * @param Request $request + * @return Response + */ + public function changePublishStatus(Request $request) + { + try { + $data = $request->post(); + $list = \app\common\model\TeacherScheduleTime::where(['id' => $data['ids']])->select(); + + if($data['status']){ + foreach ($list as $item) { + if (empty($item->subject_id)) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => '请先选择课程再发布-ID' . $item->id + ]); + } + $student_schedule = StudentSchedule::where(['teacher_schedule_time_id' => $item->id])->select(); + if ($student_schedule->isEmpty()) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => '请先安排学生后再发布-ID' . $item->id + ]); + } + } + } + + foreach ($list as $item) { + $item->save(['is_publish' => $data['status']]); + if($data['status']){ + (new SendMsgCronJobService())->teacherScheduleTimePublishMsgToTeacher($item->id); + } + } + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'msg' => 'success' + ]); + } catch (Exception $e) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } + } + /** * @desc 导出排课页面 diff --git a/plugin/admin/app/view/teacher-schedule-time/index.html b/plugin/admin/app/view/teacher-schedule-time/index.html index 847e1e4..a72f791 100644 --- a/plugin/admin/app/view/teacher-schedule-time/index.html +++ b/plugin/admin/app/view/teacher-schedule-time/index.html @@ -117,7 +117,14 @@