From eb4a73bd0b7c96af113b171060de019c515e3fd4 Mon Sep 17 00:00:00 2001 From: Dai Date: Sun, 4 Aug 2024 19:20:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=AC=E5=9C=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E3=80=81=E6=95=99=E5=B8=88=E5=88=86=E9=85=8D=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/TeacherFreeTime.php | 9 +- app/common/model/TeacherScheduleTime.php | 3 +- app/common/service/StudentHomeworkService.php | 3 + app/common/service/SubjectHomeworkService.php | 3 + app/common/service/TeacherFreeTimeService.php | 4 + .../controller/StudentScheduleController.php | 3 + .../controller/TeacherFreeTimeController.php | 2 +- .../TeacherScheduleTimeController.php | 13 +- .../app/view/student-homework/index.html | 5 +- .../app/view/student-schedule/index.html | 5 +- .../app/view/subject-homework/index.html | 5 +- .../app/view/teacher-schedule-time/index.html | 5 +- .../app/view/teacher/check_free_time.html | 26 +-- .../app/view/teacher/free_time_setting.html | 168 +++++++++++++----- plugin/admin/app/view/teacher/index.html | 4 +- 15 files changed, 188 insertions(+), 70 deletions(-) diff --git a/app/common/model/TeacherFreeTime.php b/app/common/model/TeacherFreeTime.php index 3bc9688..99a1820 100644 --- a/app/common/model/TeacherFreeTime.php +++ b/app/common/model/TeacherFreeTime.php @@ -27,7 +27,12 @@ class TeacherFreeTime extends BaseModel public function teacher() { - return $this->hasOne(Teacher::class,'id','teacher_id')->bind(['teacher_name','teacher_account'=>"account"]); + return $this->hasOne(Teacher::class, 'id', 'teacher_id')->bind([ + 'teacher_name', + 'teacher_account' => "account", + 'time_zone_name', + 'time_zone_offset' + ]); } /** @@ -36,7 +41,7 @@ class TeacherFreeTime extends BaseModel */ public function teacherScheduleTime() { - return $this->hasMany(TeacherScheduleTime::class,'free_time_id','id'); + return $this->hasMany(TeacherScheduleTime::class, 'free_time_id', 'id'); } } diff --git a/app/common/model/TeacherScheduleTime.php b/app/common/model/TeacherScheduleTime.php index 839752b..0886ff4 100644 --- a/app/common/model/TeacherScheduleTime.php +++ b/app/common/model/TeacherScheduleTime.php @@ -24,7 +24,8 @@ class TeacherScheduleTime extends BaseModel return $this->hasOne(Teacher::class, 'id', 'teacher_id')->bind([ 'teacher_account' => 'account', 'teacher_name', - 'time_zone_name' + 'time_zone_name', + 'time_zone_offset' ]); } diff --git a/app/common/service/StudentHomeworkService.php b/app/common/service/StudentHomeworkService.php index 83bb63d..73ee06f 100644 --- a/app/common/service/StudentHomeworkService.php +++ b/app/common/service/StudentHomeworkService.php @@ -64,9 +64,12 @@ class StudentHomeworkService 'subject_id' => $subject_homework->subject_id, 'date'=> $subject_homework->date, 'time'=> $subject_homework->time, + 'en_time'=> $subject_homework->en_time, 'hour'=> $subject_homework->hour, 'start_time'=> $subject_homework->start_time, 'end_time'=> $subject_homework->end_time, + 'en_start_time'=> $subject_homework->start_time, + 'en_end_time'=> $subject_homework->end_time, 'month'=> $subject_homework->month, 'feedback_file_url' => $feedback_file_url, ]); diff --git a/app/common/service/SubjectHomeworkService.php b/app/common/service/SubjectHomeworkService.php index 22e0084..e8c8daf 100644 --- a/app/common/service/SubjectHomeworkService.php +++ b/app/common/service/SubjectHomeworkService.php @@ -79,9 +79,12 @@ class SubjectHomeworkService 'teacher_schedule_time_id' => $data['teacher_schedule_time_id'], 'date' => $teacher_schedule_time->date, 'time' => $teacher_schedule_time->time, + 'en_time' => $teacher_schedule_time->en_time, 'hour' => $teacher_schedule_time->hour, 'start_time' => $teacher_schedule_time->start_time, 'end_time' => $teacher_schedule_time->end_time, + 'en_start_time' => $teacher_schedule_time->en_start_time, + 'en_end_time' => $teacher_schedule_time->en_end_time, 'month' => $teacher_schedule_time->month, 'subject_id' => $teacher_schedule_time->subject_id, 'content' => isset($data['content']) ? $data['content'] : '', diff --git a/app/common/service/TeacherFreeTimeService.php b/app/common/service/TeacherFreeTimeService.php index f1ad4b7..23fa31b 100644 --- a/app/common/service/TeacherFreeTimeService.php +++ b/app/common/service/TeacherFreeTimeService.php @@ -52,6 +52,8 @@ class TeacherFreeTimeService $en_time_period = explode('-', $en_time); $firstDate = new DateTime($free_date . ' ' . trim($time_period[0])); $secondDate = new DateTime($free_date . ' ' . trim($time_period[1])); + $enFirstDate = new DateTime($free_date . ' ' . trim($en_time_period[0])); + $enSecondDate = new DateTime($free_date . ' ' . trim($en_time_period[1])); $diff = $secondDate->diff($firstDate); $h = $diff->h; $m = round($diff->i / 60, 2); @@ -65,6 +67,8 @@ class TeacherFreeTimeService 'hour' => $hour, 'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()), 'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()), + 'en_start_time' => date('Y-m-d H:i:s', $enFirstDate->getTimestamp()), + 'en_end_time' => date('Y-m-d H:i:s', $enSecondDate->getTimestamp()), 'month' => date('Y-m', strtotime($free_date)), ]; diff --git a/plugin/admin/app/controller/StudentScheduleController.php b/plugin/admin/app/controller/StudentScheduleController.php index 4212b9c..b937d9f 100644 --- a/plugin/admin/app/controller/StudentScheduleController.php +++ b/plugin/admin/app/controller/StudentScheduleController.php @@ -200,9 +200,12 @@ class StudentScheduleController extends Crud 'subject_id' => $teacher_schedule_time->subject_id, 'date' => $teacher_schedule_time->date, 'time' => $teacher_schedule_time->time, + 'en_time' => $teacher_schedule_time->en_time, 'hour' => $teacher_schedule_time->hour, 'start_time' => $teacher_schedule_time->start_time, 'end_time' => $teacher_schedule_time->end_time, + 'en_start_time' => $teacher_schedule_time->en_start_time, + 'en_end_time' => $teacher_schedule_time->en_end_time, 'month' => $teacher_schedule_time->month, ]); if (!$res) { diff --git a/plugin/admin/app/controller/TeacherFreeTimeController.php b/plugin/admin/app/controller/TeacherFreeTimeController.php index 53c48c9..5c25e44 100644 --- a/plugin/admin/app/controller/TeacherFreeTimeController.php +++ b/plugin/admin/app/controller/TeacherFreeTimeController.php @@ -246,7 +246,7 @@ class TeacherFreeTimeController extends Crud //所有学生 $student = Student::order('id asc')->field('id,account,student_name')->select()->toArray(); - $time_period = explode(' - ', $free_time['time']); + $time_period = explode(' - ', $free_time['en_time']); $limit_time = [ 'start_time' => date('H:i', strtotime($time_period[0])), 'end_time' => date('H:i', strtotime($time_period[1])), diff --git a/plugin/admin/app/controller/TeacherScheduleTimeController.php b/plugin/admin/app/controller/TeacherScheduleTimeController.php index 14ba804..fd1838f 100644 --- a/plugin/admin/app/controller/TeacherScheduleTimeController.php +++ b/plugin/admin/app/controller/TeacherScheduleTimeController.php @@ -123,20 +123,24 @@ class TeacherScheduleTimeController extends Crud throw new Exception('教师空闲时间不存在'); } - foreach ($data['schedule_time'] as $item) { + foreach ($data['schedule_en_time'] as $item) { $time_period = explode(' - ', $item); $start_time = strtotime($free_time->date . ' ' . trim($time_period[0])); $end_time = strtotime($free_time->date . ' ' . trim($time_period[1])); - if (!(strtotime($free_time->start_time) <= $start_time && strtotime($free_time->end_time) >= $end_time)) { + + if (!(strtotime($free_time->en_start_time) <= $start_time && strtotime($free_time->en_end_time) >= $end_time)) { throw new Exception('时间' . $item . '不在老师空闲范围内'); } } \app\common\model\TeacherScheduleTime::where(['free_time_id' => $free_time->id])->select()->delete(); - foreach ($data['schedule_time'] as $item) { + foreach ($data['schedule_time'] as $index => $item) { $time_period = explode(' - ', $item); + $en_time_period = explode(' - ', $data['schedule_en_time'][$index]); $start_time = $free_time->date . ' ' . trim($time_period[0]); $end_time = $free_time->date . ' ' . trim($time_period[1]); + $en_start_time = $free_time->date . ' ' . trim($en_time_period[0]); + $en_end_time = $free_time->date . ' ' . trim($en_time_period[1]); $firstDate = new DateTime($start_time); $secondDate = new DateTime($end_time); @@ -150,9 +154,12 @@ class TeacherScheduleTimeController extends Crud 'teacher_id' => $free_time->teacher_id, 'date' => $free_time->date, 'time' => $time, + 'en_time' => $data['schedule_en_time'][$index], 'hour' => $hour, 'start_time' => $start_time, 'end_time' => $end_time, + 'en_start_time' => $en_start_time, + 'en_end_time' => $en_end_time, 'month' => $free_time->month, 'free_time_id' => $free_time->id, ]); diff --git a/plugin/admin/app/view/student-homework/index.html b/plugin/admin/app/view/student-homework/index.html index ebe34fc..608e053 100644 --- a/plugin/admin/app/view/student-homework/index.html +++ b/plugin/admin/app/view/student-homework/index.html @@ -159,7 +159,10 @@ title: "日期",align: "center", field: "date", },{ - title: "时间",align: "center", + title: "本地时间",align: "center", + field: "en_time", + },{ + title: "中国时间",align: "center", field: "time", },{ title: "课程",align: "center", diff --git a/plugin/admin/app/view/student-schedule/index.html b/plugin/admin/app/view/student-schedule/index.html index 1430f6e..0eca91d 100644 --- a/plugin/admin/app/view/student-schedule/index.html +++ b/plugin/admin/app/view/student-schedule/index.html @@ -215,7 +215,10 @@ title: "日期", align: "center", field: "date", }, { - title: "时间段", align: "center", + title: "本地时间", align: "center", + field: "en_time", + }, { + title: "中国时间", align: "center", field: "time", }, { title: "课时", align: "center", diff --git a/plugin/admin/app/view/subject-homework/index.html b/plugin/admin/app/view/subject-homework/index.html index 8c9a76a..48e9b28 100644 --- a/plugin/admin/app/view/subject-homework/index.html +++ b/plugin/admin/app/view/subject-homework/index.html @@ -218,7 +218,10 @@ title: "日期", align: "center", field: "date", }, { - title: "时间", align: "center", + title: "本地时间", align: "center", + field: "en_time", + }, { + title: "中国时间", align: "center", field: "time", }, { title: "开始时间", align: "center", diff --git a/plugin/admin/app/view/teacher-schedule-time/index.html b/plugin/admin/app/view/teacher-schedule-time/index.html index bf7ff13..128ac42 100644 --- a/plugin/admin/app/view/teacher-schedule-time/index.html +++ b/plugin/admin/app/view/teacher-schedule-time/index.html @@ -194,7 +194,10 @@ title: "日期", align: "center", field: "date", }, { - title: "时间", align: "center", + title: "本地时间", align: "center", + field: "en_time", + }, { + title: "中国时间", align: "center", field: "time", }, { title: "课时", align: "center", diff --git a/plugin/admin/app/view/teacher/check_free_time.html b/plugin/admin/app/view/teacher/check_free_time.html index e10b906..08b3fbc 100644 --- a/plugin/admin/app/view/teacher/check_free_time.html +++ b/plugin/admin/app/view/teacher/check_free_time.html @@ -17,21 +17,21 @@ - + + + + + + + + @@ -209,7 +209,7 @@ let month = obj.data['month']; let index = layer.open({ type: 2, - title: "修改", + title: "空闲时间日历", shade: 0.1, maxmin: true, area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"], diff --git a/plugin/admin/app/view/teacher/free_time_setting.html b/plugin/admin/app/view/teacher/free_time_setting.html index b4b8030..3109f45 100644 --- a/plugin/admin/app/view/teacher/free_time_setting.html +++ b/plugin/admin/app/view/teacher/free_time_setting.html @@ -17,11 +17,26 @@
- +
+
+ +
+ +
+
+
+ +
+ +
+
@@ -37,7 +52,13 @@
- + +
+ +
+
+
+
@@ -49,39 +70,65 @@
- - - - - - - + + + + + + +
排课时间
{if (empty($teacher_schedule_time))} -
-
- +
+ +
+
-
- - + +
+ +
+
+ +
{else /} - {foreach $teacher_schedule_time as $index=>$item} -
-
- -
-
- - -
-
- {/foreach} + {foreach $teacher_schedule_time as $index=>$item} +
+ +
+ +
+ +
+ +
+
+ + +
+
+ {/foreach} {/if}
@@ -116,8 +163,6 @@ const UPDATE_API = "/app/admin/teacher-schedule-time/update"; - - // 获取数据库记录 layui.use(["form", "util", "popup", 'laydate'], function () { let $ = layui.$; @@ -130,34 +175,63 @@ elem: ".time", type: "time", format: 'HH:mm', - btns:['clear','confirm'], + btns: ['clear', 'confirm'], min: "{$limit_time['start_time']}:00", max: "{$limit_time['end_time']}:59", range: '-', - ready: function(date){ + ready: function (date) { var layKey = layui.$(this.elem).attr('lay-key'); layui.$('#layui-laydate' + layKey).children().eq(0).find('.layui-laydate-list>li').width('50%').last('li').hide(); layui.$('#layui-laydate' + layKey).children().eq(1).find('.layui-laydate-list>li').width('50%').last('li').hide(); + }, + done: function (value, date, endDate) { + let start_date_time = new Date(date.year, date.month, date.date, parseInt(date.hours + parseInt("{$free_time['time_zone_offset']}")), date.minutes, date.seconds) + let start_time = start_date_time.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"}) + let end_date_time = new Date(endDate.year, endDate.month, endDate.date, parseInt(endDate.hours + parseInt("{$free_time['time_zone_offset']}")), endDate.minutes, endDate.seconds) + let end_time = end_date_time.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"}) + $(this.elem).parent().parent().children().find('.schedule_time').val(start_time + ' - ' + end_time) } }); // 添加时间 $('#schedule_free_time').on('click', '.add-schedule-time', function () { - console.log('add'); var html = $(this).parent().parent().parent().clone(); var maxNum = $('#schedule_free_time').find('.time:last').attr('curNum'); maxNum = Number(maxNum) + 1; - var htmlStr ='
\n' + - '
\n' + - ' \n' + - '
\n' + - '
\n' + - ' \n' + - ' \n' + - '
\n' + - '
'; + // var htmlStr = '
\n' + + // '
\n' + + // ' \n' + + // '
\n' + + // '
\n' + + // ' \n' + + // ' \n' + + // '
\n' + + // '
'; + + var htmlStr = '
\n' + + ' \n' + + '
\n' + + ' \n' + + '
\n' + + ' \n' + + '
\n' + + ' \n' + + '
\n' + + '
\n' + + ' \n' + + ' \n' + + '
\n' + + '
'; $('#schedule_free_time').find('.layui-form-item:last').after(htmlStr); $('#schedule_free_time').find('.layui-form-item:last').find('input').val(''); @@ -166,21 +240,28 @@ elem: ".time", type: "time", format: 'HH:mm', - btns:['clear','confirm'], + btns: ['clear', 'confirm'], min: "{$limit_time['start_time']}:00", max: "{$limit_time['end_time']}:59", range: '-', - ready: function(date){ + ready: function (date) { var layKey = layui.$(this.elem).attr('lay-key'); layui.$('#layui-laydate' + layKey).children().eq(0).find('.layui-laydate-list>li').width('50%').last('li').hide(); layui.$('#layui-laydate' + layKey).children().eq(1).find('.layui-laydate-list>li').width('50%').last('li').hide(); + }, + done: function (value, date, endDate) { + let start_date_time = new Date(date.year, date.month, date.date, parseInt(date.hours + parseInt("{$free_time['time_zone_offset']}")), date.minutes, date.seconds) + let start_time = start_date_time.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"}) + let end_date_time = new Date(endDate.year, endDate.month, endDate.date, parseInt(endDate.hours + parseInt("{$free_time['time_zone_offset']}")), endDate.minutes, endDate.seconds) + let end_time = end_date_time.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"}) + $(this.elem).parent().parent().children().find('.schedule_time').val(start_time + ' - ' + end_time) } }); }) // 删除时间 $('#schedule_free_time').on('click', '.remove-schedule-time', function () { - if($('#schedule_free_time').find('.layui-form-item').length > 1){ + if ($('#schedule_free_time').find('.layui-form-item').length > 1) { var that = this; $(this).parent().parent().remove(); } @@ -220,7 +301,6 @@ }); - //提交事件 layui.use(["form", "popup"], function () { // 字段验证允许为空 diff --git a/plugin/admin/app/view/teacher/index.html b/plugin/admin/app/view/teacher/index.html index 2873e85..3fd3650 100644 --- a/plugin/admin/app/view/teacher/index.html +++ b/plugin/admin/app/view/teacher/index.html @@ -172,8 +172,8 @@ title: "时区名称",align: "center", field: "time_zone_name", },{ - title: "时差",align: "center", - field: "time_zone", + title: "时差/h",align: "center", + field: "time_zone_offset", },{ title: "创建时间",align: "center", field: "created_at",