From c292eb88e4936948dd9b02ab0b19e0c974ba28f9 Mon Sep 17 00:00:00 2001 From: Dai Date: Wed, 17 Jul 2024 11:36:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=AF=BE=E8=A1=A8?= =?UTF-8?q?=E6=97=A5=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/StudentController.php | 60 ++++ .../controller/StudentScheduleController.php | 67 ++++ .../app/view/student/check_schedule.html | 319 ++++++++++++++++++ plugin/admin/app/view/student/index.html | 15 + .../app/view/student/student_schedule.html | 291 ++++++++++++++++ 5 files changed, 752 insertions(+) create mode 100644 plugin/admin/app/view/student/check_schedule.html create mode 100644 plugin/admin/app/view/student/student_schedule.html diff --git a/plugin/admin/app/controller/StudentController.php b/plugin/admin/app/controller/StudentController.php index 94dac3e..1225479 100644 --- a/plugin/admin/app/controller/StudentController.php +++ b/plugin/admin/app/controller/StudentController.php @@ -3,6 +3,7 @@ namespace plugin\admin\app\controller; use app\common\model\StudentParent; +use app\common\model\StudentSchedule; use app\constant\ResponseCode; use support\Request; use support\Response; @@ -170,6 +171,65 @@ class StudentController extends Crud } + /** + * @desc 查看课表 + * @param Request $request + * @return Response + */ + public function checkSchedule(Request $request) + { + $data = $request->get(); + $student = \app\common\model\Student::where(['id' => $data['student_id']])->findOrEmpty(); + return view('student/check_schedule', ['student_id' => $data['student_id']]); + } + + /** + * @desc 获取学生排课月份总览 + * @param Request $request + * @return Response + */ + public function getStudentScheduleMonth(Request $request) + { + try { + $data = $request->get(); + $schedule_time = StudentSchedule::where(['student_id' => $data['student_id']]) + ->field(' + student_id, + month, + COUNT(id) AS total_courses, + SUM(hour) AS total_hours, + + SUM(CASE WHEN is_publish = 1 THEN 1 ELSE 0 END) AS published_courses, + SUM(CASE WHEN is_publish = 0 THEN 1 ELSE 0 END) AS unpublished_courses + ') + ->group('month') + ->with(['student']); + + $limit = (int)$request->get('limit', 10); + $limit = $limit <= 0 ? 10 : $limit; + $page = (int)$request->get('page'); + $page = $page > 0 ? $page : 1; + + $total = $schedule_time->count(); + $list = $schedule_time->page($page, $limit)->select(); + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'data' => $list, + 'count' => $total, + 'msg' => 'success', + ]); + } catch (Exception $e) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } + } + + + + /** * @desc 重置密码 * @param Request $request diff --git a/plugin/admin/app/controller/StudentScheduleController.php b/plugin/admin/app/controller/StudentScheduleController.php index fe2f42f..c9ddb80 100644 --- a/plugin/admin/app/controller/StudentScheduleController.php +++ b/plugin/admin/app/controller/StudentScheduleController.php @@ -226,4 +226,71 @@ class StudentScheduleController extends Crud } } + + /** + * @desc 教师月份课程安排日历 + * @param Request $request + * @return Response + */ + public function studentSchedule(Request $request) + { + $data = $request->get(); + $student_id = $data['student_id']; + $month = $data['month']; + $student = \app\common\model\Student::where(['id' => $student_id])->findOrEmpty()->toArray(); + return view('student/student_schedule', ['student' => $student, 'month' => $month]); + } + + /** + * @desc 学生排课日历数据 + * @param Request $request + * @return Response + */ + public function getStudentSchedule(Request $request) + { + try { + $student_id = $request->post('id'); + $start_date = date('Y-m-d H:i:s', strtotime($request->post('start_date'))); + $end_date = date('Y-m-d 23:59:59', strtotime($request->post('end_date'))); + $list = \app\common\model\StudentSchedule::where(['student_id' => $student_id]) + ->whereBetweenTime('start_time', $start_date, $end_date) + ->with(['subject', 'teacher']) + ->select() + ->toArray(); + + $free_time = []; + foreach ($list as $item) { + $time_period = explode('-', $item['time']); + if ($item['subject_id']) { + $title = $item['time'] . PHP_EOL . $item['teacher_name'] . PHP_EOL . $item['subject_name'] . '/' . $item['english_name']; + if ($item['is_publish'] == 0) { + $color = 'orange'; + } else { + $color = 'green'; + } + } else { + $color = 'red'; + $title = $item['time']; + } + $free_time[] = [ + 'free_time_id' => $item['id'], + 'title' => $title, + 'start' => $item['date'] . ' ' . $time_period[0], + 'color' => $color, + ]; + } + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'data' => $free_time, + 'msg' => 'success' + ]); + } catch (Exception $e) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } + } + } diff --git a/plugin/admin/app/view/student/check_schedule.html b/plugin/admin/app/view/student/check_schedule.html new file mode 100644 index 0000000..0f4f3b1 --- /dev/null +++ b/plugin/admin/app/view/student/check_schedule.html @@ -0,0 +1,319 @@ + + + + + + 浏览页面 + + + + + + +
+
+
+
+
+ + + + + + + + + + + + + + + diff --git a/plugin/admin/app/view/student/index.html b/plugin/admin/app/view/student/index.html index e6e2240..ea15cd8 100644 --- a/plugin/admin/app/view/student/index.html +++ b/plugin/admin/app/view/student/index.html @@ -31,6 +31,7 @@ + + + + + + + +
+ +
+
+
+
+

学生信息

+
+
{$student['student_name']}
+
+
+ + + + +
+ + 已排课,未发布 +
+
+ + 已发布 +
+
+
+ +
+ +
+ +
+
+
+
+ +
+
+ + + + +
+
+ +
+ + + + + + + + + + + + From 3cf881c4d97f704af2b5bb6ae1f1b1740d108521 Mon Sep 17 00:00:00 2001 From: Dai Date: Wed, 17 Jul 2024 11:41:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8E=92=E8=AF=BE=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/admin/app/view/teacher-schedule-time/update.html | 1 + plugin/admin/app/view/teacher/teacher_schedule_time.html | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/admin/app/view/teacher-schedule-time/update.html b/plugin/admin/app/view/teacher-schedule-time/update.html index 855b6a9..c41c603 100644 --- a/plugin/admin/app/view/teacher-schedule-time/update.html +++ b/plugin/admin/app/view/teacher-schedule-time/update.html @@ -178,6 +178,7 @@ day: '日', list: '列表' }, + allDayText : '全天', // initialDate: '2024-07-14', eventLimit: 4, // 显示更多 navLinks: true, // can click day/week names to navigate views diff --git a/plugin/admin/app/view/teacher/teacher_schedule_time.html b/plugin/admin/app/view/teacher/teacher_schedule_time.html index 8a8352d..c5c103e 100644 --- a/plugin/admin/app/view/teacher/teacher_schedule_time.html +++ b/plugin/admin/app/view/teacher/teacher_schedule_time.html @@ -145,7 +145,8 @@ // plugins: [ 'interaction', 'dayGrid', 'timeGrid' ], locale: 'zh-cn', // 设置中文 headerToolbar: { - left: 'prev,next today', + // left: 'prev,next today', + left: 'today', center: 'title', right: 'dayGridMonth,timeGridWeek,timeGridDay' }, @@ -194,6 +195,7 @@ // } }, editable: true, + allDayText : '全天', dayMaxEvents: true, // allow "more" link when too many events events: function (info, successCallback, failureCallback) { console.log('12312313', info)