From 939c2c993060bfae2344579fd5fd994ea4143878 Mon Sep 17 00:00:00 2001 From: Dai Date: Tue, 16 Jul 2024 22:52:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8E=92=E8=AF=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/StudentSchedule.php | 16 +- .../controller/StudentScheduleController.php | 98 ++- .../app/controller/TeacherController.php | 77 +- .../TeacherScheduleTimeController.php | 27 +- plugin/admin/app/model/StudentSchedule.php | 10 +- .../app/view/student-schedule/index.html | 778 +++++++++++------- .../app/view/student-schedule/insert.html | 70 +- .../app/view/student-schedule/update.html | 70 +- plugin/admin/app/view/student/index.html | 609 +++++++------- .../schedule_time_setting.html | 17 +- .../view/teacher/schedule_time_setting.html | 188 +++++ .../view/teacher/teacher_schedule_time.html | 26 +- 12 files changed, 1251 insertions(+), 735 deletions(-) create mode 100644 plugin/admin/app/view/teacher/schedule_time_setting.html diff --git a/app/common/model/StudentSchedule.php b/app/common/model/StudentSchedule.php index 9bf7f79..f0f12dc 100644 --- a/app/common/model/StudentSchedule.php +++ b/app/common/model/StudentSchedule.php @@ -23,5 +23,19 @@ use support\Model; class StudentSchedule extends BaseModel { - + public function teacher() + { + return $this->hasOne(Teacher::class, 'id', 'teacher_id')->bind(['teacher_account'=>'account', 'teacher_name']); + } + + public function subject() + { + return $this->hasOne(Subject::class, 'id', 'subject_id')->bind(['subject_name', 'english_name']); + } + + public function student() + { + return $this->hasOne(Student::class, 'id', 'student_id')->bind(['student_name', 'student_account'=>'account']); + } + } diff --git a/plugin/admin/app/controller/StudentScheduleController.php b/plugin/admin/app/controller/StudentScheduleController.php index e16567e..fe2f42f 100644 --- a/plugin/admin/app/controller/StudentScheduleController.php +++ b/plugin/admin/app/controller/StudentScheduleController.php @@ -2,6 +2,9 @@ namespace plugin\admin\app\controller; +use app\common\model\Student; +use app\common\model\Subject; +use app\common\model\Teacher; use app\common\model\TeacherScheduleTime; use app\constant\ResponseCode; use support\Request; @@ -37,7 +40,92 @@ class StudentScheduleController extends Crud */ public function index(): Response { - return view('student-schedule/index'); + //获取所有老师 + $teacher = Teacher::order('id asc')->field('id,teacher_name,account')->select()->toArray(); + //所有课程 + $subject = Subject::order('sort desc,id asc')->field('id,subject_name,english_name')->select()->toArray(); + $student = Student::order('id asc')->field('id,student_name,account')->select()->toArray(); + + return view('student-schedule/index', ['teacher' => $teacher, 'subject' => $subject, 'student' => $student]); + } + + + public function select(Request $request): Response + { + try { + $data = $request->get(); + $student_schedule = \app\common\model\StudentSchedule::order('id desc'); + + if (isset($data['student_id']) && $data['student_id']) { + $student_schedule->where(['student_id' => $data['student_id']]); + } + if (isset($data['teacher_id']) && $data['teacher_id']) { + $student_schedule->where(['teacher_id' => $data['teacher_id']]); + } + if (isset($data['subject_id']) && $data['subject_id']) { + $student_schedule->where(['subject_id' => $data['subject_id']]); + } + if (isset($data['date']) && $data['date']) { + if ($data['date'][0] && $data['date'][1]) { + $student_schedule->whereBetweenTime('date', $data['date'][0], $data['date'][1]); + } + } + if (isset($data['month']) && $data['month']) { + $student_schedule->where(['month' => $data['month']]); + } + if (isset($data['is_publish']) && $data['is_publish'] !== '') { + $student_schedule->where(['is_publish' => $data['is_publish']]); + } + + + $limit = (int)$request->get('limit', 10); + $limit = $limit <= 0 ? 10 : $limit; + $page = (int)$request->get('page'); + $page = $page > 0 ? $page : 1; + + $total = $student_schedule->count(); + $list = $student_schedule->with(['teacher', 'student', 'subject'])->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 + * @return Response + */ + public function changePublishStatus(Request $request) + { + try { + $data = $request->post(); + $res = \app\common\model\StudentSchedule::where(['id' => $data['ids']])->save([ + 'is_publish' => $data['status'] + ]); + if (!$res) { + throw new Exception('操作失败'); + } + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'msg' => 'success' + ]); + } catch (Exception $e) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } } /** @@ -84,7 +172,7 @@ class StudentScheduleController extends Crud throw new Exception('未找到教师排课,添加失败'); } - if($data['type'] == 'add'){ + if ($data['type'] == 'add') { if (empty($teacher_schedule_time->subject_id)) { throw new Exception('请先排课再添加学生'); } @@ -96,10 +184,10 @@ class StudentScheduleController extends Crud ", [$teacher_schedule_time->start_time, $teacher_schedule_time->start_time, $teacher_schedule_time->end_time, $teacher_schedule_time->end_time, $teacher_schedule_time->start_time, $teacher_schedule_time->end_time, - ])->findOrEmpty(); + ])->with(['teacher', 'subject'])->findOrEmpty(); if (!$conflict->isEmpty()) { - throw new Exception('该学生课程和其他课程有冲突'); + throw new Exception("该学生课程和【{$conflict->teacher_name}】的【{$conflict->subject_name} {$conflict->date} {$conflict->time} 】有冲突"); } $res = \app\common\model\StudentSchedule::create([ @@ -119,7 +207,7 @@ class StudentScheduleController extends Crud throw new Exception('添加失败'); } - }else{ + } else { $student_schedule = \app\common\model\StudentSchedule::where(['student_id' => $data['student_id'], 'teacher_schedule_time_id' => $teacher_schedule_time->id])->findOrEmpty(); $student_schedule->delete(); diff --git a/plugin/admin/app/controller/TeacherController.php b/plugin/admin/app/controller/TeacherController.php index 1ff8e42..226a480 100644 --- a/plugin/admin/app/controller/TeacherController.php +++ b/plugin/admin/app/controller/TeacherController.php @@ -2,6 +2,9 @@ namespace plugin\admin\app\controller; +use app\common\model\Student; +use app\common\model\StudentSchedule; +use app\common\model\Subject; use app\common\model\TeacherScheduleTime; use app\constant\ResponseCode; use support\Request; @@ -162,23 +165,6 @@ class TeacherController extends Crud } - /** - * @desc 教师月份课程安排 - * @param Request $request - * @return Response - */ - public function teacherScheduleTime(Request $request) - { - - $data = $request->get(); - $teacher_id = $data['teacher_id']; - $month = $data['month']; - $teacher = \app\common\model\Teacher::where(['id'=>$teacher_id])->findOrEmpty(); - - return view('teacher/teacher_schedule_time', ['teacher' => $teacher, 'month' => $month]); - } - - /** * @desc 获取教师课程安排统计 * @param Request $request @@ -229,6 +215,63 @@ class TeacherController extends Crud } } + + /** + * @desc 教师月份课程安排日历 + * @param Request $request + * @return Response + */ + public function teacherScheduleTime(Request $request) + { + + $data = $request->get(); + $teacher_id = $data['teacher_id']; + $month = $data['month']; + $teacher = \app\common\model\Teacher::where(['id'=>$teacher_id])->findOrEmpty(); + //获取该老师当前分配学生 +// $student_schedule = StudentSchedule::where(['']) + + return view('teacher/teacher_schedule_time', ['teacher' => $teacher, 'month' => $month]); + } + + + /** + * 更新 + * @param Request $request + * @return Response + * @throws BusinessException + */ + public function scheduleTimeSet(Request $request): Response + { + if ($request->method() === 'POST') { + + if ($request->post('is_publish')) { + $request->post('is_publish', 0); + } +// parent::update($request); + + return parent::update($request); + } + $free_time_id = $request->get('free_time_id'); + $schedule_time = \app\common\model\TeacherScheduleTime::where(['id' => $free_time_id])->with(['teacher'])->findOrEmpty()->toArray(); + //课程 + $project = Subject::order('sort desc, id asc')->select()->toArray(); + //所有学生 + $student = Student::order('id asc')->field('id,account,student_name')->select()->toArray(); + $student_schedule = StudentSchedule::where(['teacher_schedule_time_id' => $free_time_id])->select()->toArray(); + $student_schedule_id = []; + if ($student_schedule) { + $student_schedule_id = array_column($student_schedule, 'student_id'); + } + + + return view('teacher/schedule_time_setting', [ + 'schedule_time' => $schedule_time, + 'project' => $project, + 'student' => $student, + 'student_schedule_id' => $student_schedule_id]); + } + /** * @desc 重置密码 * @param Request $request diff --git a/plugin/admin/app/controller/TeacherScheduleTimeController.php b/plugin/admin/app/controller/TeacherScheduleTimeController.php index bfb7622..f678d2a 100644 --- a/plugin/admin/app/controller/TeacherScheduleTimeController.php +++ b/plugin/admin/app/controller/TeacherScheduleTimeController.php @@ -3,6 +3,7 @@ namespace plugin\admin\app\controller; use app\common\model\Student; +use app\common\model\StudentSchedule; use app\common\model\Subject; use app\common\model\Teacher; use app\constant\ResponseCode; @@ -123,32 +124,6 @@ class TeacherScheduleTimeController extends Crud return view('teacher-schedule-time/update', ['teacher' => $teacher]); } - /** - * 更新 - * @param Request $request - * @return Response - * @throws BusinessException - */ - public function scheduleTimeSet(Request $request): Response - { - if ($request->method() === 'POST') { - - if ($request->post('is_publish')) { - $request->post('is_publish', 0); - } -// parent::update($request); - - return parent::update($request); - } - $free_time_id = $request->get('free_time_id'); - $schedule_time = \app\common\model\TeacherScheduleTime::where(['id' => $free_time_id])->with(['teacher'])->findOrEmpty()->toArray(); - //课程 - $project = Subject::order('sort desc, id asc')->select()->toArray(); - //学生 - $student = Student::order('id asc')->field('id,account,student_name')->select()->toArray(); - - return view('teacher-schedule-time/schedule_time_setting', ['schedule_time' => $schedule_time, 'project' => $project, 'student' => $student]); - } /** * @desc 时间列表 diff --git a/plugin/admin/app/model/StudentSchedule.php b/plugin/admin/app/model/StudentSchedule.php index 91b94cf..46c5593 100644 --- a/plugin/admin/app/model/StudentSchedule.php +++ b/plugin/admin/app/model/StudentSchedule.php @@ -11,9 +11,13 @@ use plugin\admin\app\model\Base; * @property mixed $teacher_schedule_time_detail 排课详情 * @property integer $teacher_id 教师 * @property integer $subject_id 学科 - * @property string $date_time 课程时间 - * @property string $date_start_time 课程开始时间 - * @property string $date_end_time 课程结束时间 + * @property string $date 日期 + * @property string $time 时间段 + * @property mixed $hour 课时 + * @property string $start_time 课程开始时间 + * @property string $end_time 课程结束时间 + * @property string $month 月份 + * @property integer $is_public 是否发布0:未发布 1:已发布 * @property mixed $created_at 创建时间 * @property string $updated_at 更新时间 * @property string $deleted_at diff --git a/plugin/admin/app/view/student-schedule/index.html b/plugin/admin/app/view/student-schedule/index.html index 851c6dc..7e58be7 100644 --- a/plugin/admin/app/view/student-schedule/index.html +++ b/plugin/admin/app/view/student-schedule/index.html @@ -1,341 +1,487 @@ - - - - 浏览页面 - - - - - - -
-
-
- -
- -
-
- - -
-
+ + + 浏览页面 + + + + + + +
+
+ + +
+ +
+
+
- -
- -
-
- - -
-
-
- -
- -
- -
-
- -
- -
- -
-
- -
- - - -
-
- 展开 - 收起 -
- +
-
- - -
-
-
+ +
+ +
+ +
-
- - +
+ +
+ +
+
- - +
+ +
+
+ + - + +
+
+
- - - - - - - // 表格新增数据 - let add = function() { - layer.open({ - type: 2, - title: "新增", - shade: 0.1, - maxmin: true, - area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"], - content: INSERT_URL - }); - } + + - // 表格编辑数据 - let edit = function(obj) { - let value = obj.data[PRIMARY_KEY]; - layer.open({ - type: 2, - title: "修改", - shade: 0.1, - maxmin: true, - area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"], - content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value - }); - } + + + + - // 删除一行 - let remove = function(obj) { - return doRemove(obj.data[PRIMARY_KEY]); - } + - + // 表格顶部搜索重置事件 + form.on("submit(table-reset)", function (data) { + table.reload("data-table", { + where: [] + }) + }); + + // 字段允许为空 + form.verify({ + phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"], + email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"], + url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"], + number: [/(^$)|^\d+$/, '只能填写数字'], + date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"], + identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"] + }); + + // 表格排序事件 + table.on("sort(data-table)", function (obj) { + table.reload("data-table", { + initSort: obj, + scrollPos: "fixed", + where: { + field: obj.field, + order: obj.type + } + }); + }); + + // 表格新增数据 + let add = function () { + layer.open({ + type: 2, + title: "新增", + shade: 0.1, + maxmin: true, + area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"], + content: INSERT_URL + }); + } + + // 表格编辑数据 + let edit = function (obj) { + let value = obj.data[PRIMARY_KEY]; + layer.open({ + type: 2, + title: "修改", + shade: 0.1, + maxmin: true, + area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"], + content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value + }); + } + + // 删除多行 + let publish = function (obj, status) { + let checkIds = common.checkField(obj, PRIMARY_KEY); + if (checkIds === "") { + layui.popup.warning("未选中数据"); + return false; + } + let ids = checkIds; + // doRemove(checkIds.split(",")); + let data = {ids: checkIds.split(","), status: status}; + let msg = ''; + if (status) { + msg = '确定批量【发布】学生课表?'; + } else { + msg = '确定批量【取消发布】学生课表?'; + } + layer.confirm(msg, { + icon: 3, + title: "提示" + }, function (index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: '/app/admin/studentSchedule/changePublishStatus', + data: data, + dataType: "json", + type: "post", + success: function (res) { + layer.close(loading); + if (res.code) { + return layui.popup.failure(res.msg); + } + return layui.popup.success("操作成功", refreshTable); + } + }) + }); + } + + // 删除一行 + let remove = function (obj) { + return doRemove(obj.data[PRIMARY_KEY]); + } + + // 删除多行 + let batchRemove = function (obj) { + let checkIds = common.checkField(obj, PRIMARY_KEY); + if (checkIds === "") { + layui.popup.warning("未选中数据"); + return false; + } + doRemove(checkIds.split(",")); + } + + // 执行删除 + let doRemove = function (ids) { + let data = {}; + data[PRIMARY_KEY] = ids; + layer.confirm("确定删除?", { + icon: 3, + title: "提示" + }, function (index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: DELETE_API, + data: data, + dataType: "json", + type: "post", + success: function (res) { + layer.close(loading); + if (res.code) { + return layui.popup.failure(res.msg); + } + return layui.popup.success("操作成功", refreshTable); + } + }) + }); + } + + // 刷新表格数据 + window.refreshTable = function () { + table.reloadData("data-table", { + scrollPos: "fixed", + done: function (res, curr) { + if (curr > 1 && res.data && !res.data.length) { + curr = curr - 1; + table.reloadData("data-table", { + page: { + curr: curr + }, + }) + } + } + }); + } + }) + + + diff --git a/plugin/admin/app/view/student-schedule/insert.html b/plugin/admin/app/view/student-schedule/insert.html index f5de6b0..5a9fad5 100644 --- a/plugin/admin/app/view/student-schedule/insert.html +++ b/plugin/admin/app/view/student-schedule/insert.html @@ -50,23 +50,52 @@
- +
- + +
+
+ +
+ +
+ +
+
+ +
+ +
+
- +
- + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
@@ -97,30 +126,39 @@ // 相关接口 const INSERT_API = "/app/admin/student-schedule/insert"; - // 字段 课程时间 date_time + // 字段 日期 date layui.use(["laydate"], function() { layui.laydate.render({ - elem: "#date_time", - - }); - }) - - // 字段 课程开始时间 date_start_time - layui.use(["laydate"], function() { - layui.laydate.render({ - elem: "#date_start_time", + elem: "#date", type: "datetime", }); }) - // 字段 课程结束时间 date_end_time + // 字段 课程开始时间 start_time layui.use(["laydate"], function() { layui.laydate.render({ - elem: "#date_end_time", + elem: "#start_time", type: "datetime", }); }) + // 字段 课程结束时间 end_time + layui.use(["laydate"], function() { + layui.laydate.render({ + elem: "#end_time", + type: "datetime", + }); + }) + + // 字段 是否发布0:未发布 1:已发布 is_public + layui.use(["form"], function() { + layui.$("#is_public").attr("checked", layui.$('input[name="is_public"]').val() != 0); + layui.form.render(); + layui.form.on("switch(is_public)", function(data) { + layui.$('input[name="is_public"]').val(this.checked ? 1 : 0); + }); + }) + //提交事件 layui.use(["form", "popup"], function () { // 字段验证允许为空 diff --git a/plugin/admin/app/view/student-schedule/update.html b/plugin/admin/app/view/student-schedule/update.html index 1ba7441..0eb6e10 100644 --- a/plugin/admin/app/view/student-schedule/update.html +++ b/plugin/admin/app/view/student-schedule/update.html @@ -51,23 +51,52 @@
- +
- + +
+
+ +
+ +
+ +
+
+ +
+ +
+
- +
- + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
@@ -123,30 +152,39 @@ } }); - // 字段 课程时间 date_time + // 字段 日期 date layui.use(["laydate"], function() { layui.laydate.render({ - elem: "#date_time", - - }); - }) - - // 字段 课程开始时间 date_start_time - layui.use(["laydate"], function() { - layui.laydate.render({ - elem: "#date_start_time", + elem: "#date", type: "datetime", }); }) - // 字段 课程结束时间 date_end_time + // 字段 课程开始时间 start_time layui.use(["laydate"], function() { layui.laydate.render({ - elem: "#date_end_time", + elem: "#start_time", type: "datetime", }); }) + // 字段 课程结束时间 end_time + layui.use(["laydate"], function() { + layui.laydate.render({ + elem: "#end_time", + type: "datetime", + }); + }) + + // 字段 是否发布0:未发布 1:已发布 is_public + layui.use(["form"], function() { + layui.$("#is_public").attr("checked", layui.$('input[name="is_public"]').val() != 0); + layui.form.render(); + layui.form.on("switch(is_public)", function(data) { + layui.$('input[name="is_public"]').val(this.checked ? 1 : 0); + }); + }) + // ajax返回失败 if (res.code) { diff --git a/plugin/admin/app/view/student/index.html b/plugin/admin/app/view/student/index.html index 3c8f81e..4d4a635 100644 --- a/plugin/admin/app/view/student/index.html +++ b/plugin/admin/app/view/student/index.html @@ -1,323 +1,324 @@ - - - - 浏览页面 - - - - - - - - - -
-
-
-
-
+ + + 浏览页面 + + + + - - + - - - - - - - - - // 表格顶部工具栏事件 - table.on("toolbar(data-table)", function(obj) { - if (obj.event === "add") { - add(); - } else if (obj.event === "refresh") { - refreshTable(); - } else if (obj.event === "batchRemove") { - batchRemove(obj); - } - }); + + - // 表格顶部搜索事件 - form.on("submit(table-query)", function(data) { - table.reload("data-table", { - page: { - curr: 1 - }, - where: data.field - }) - return false; - }); - - // 表格顶部搜索重置事件 - form.on("submit(table-reset)", function(data) { - table.reload("data-table", { - where: [] - }) - }); - - // 字段允许为空 - form.verify({ - phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"], - email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"], - url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"], - number: [/(^$)|^\d+$/,'只能填写数字'], - date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"], - identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"] - }); + + + + - // 表格排序事件 - table.on("sort(data-table)", function(obj){ - table.reload("data-table", { - initSort: obj, - scrollPos: "fixed", - where: { - field: obj.field, - order: obj.type - } - }); - }); + - + // 表格顶部搜索重置事件 + form.on("submit(table-reset)", function (data) { + table.reload("data-table", { + where: [] + }) + }); + + // 字段允许为空 + form.verify({ + phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"], + email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"], + url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"], + number: [/(^$)|^\d+$/, '只能填写数字'], + date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"], + identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"] + }); + + // 表格排序事件 + table.on("sort(data-table)", function (obj) { + table.reload("data-table", { + initSort: obj, + scrollPos: "fixed", + where: { + field: obj.field, + order: obj.type + } + }); + }); + + // 表格新增数据 + let add = function () { + layer.open({ + type: 2, + title: "新增", + shade: 0.1, + maxmin: true, + area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"], + content: INSERT_URL + }); + } + + // 表格编辑数据 + let edit = function (obj) { + let value = obj.data[PRIMARY_KEY]; + layer.open({ + type: 2, + title: "修改", + shade: 0.1, + maxmin: true, + area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"], + content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value + }); + } + + let rest_password = function (obj) { + console.log() + let data = {}; + data[PRIMARY_KEY] = obj.data[PRIMARY_KEY]; + let first_name = obj.data['account'].split(' '); + console.log(first_name) + let new_password = first_name[0].trim() + '001'; + layer.confirm("确定充值密码?重置后新密码为【" + new_password + "】", { + icon: 3, + title: "提示" + }, function (index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: '/app/admin/student/resetPassword', + data: data, + dataType: "json", + type: "post", + success: function (res) { + layer.close(loading); + if (res.code) { + return layui.popup.failure(res.msg); + } + return layui.popup.success("操作成功", refreshTable); + } + }) + }); + } + + // 删除一行 + let remove = function (obj) { + return doRemove(obj.data[PRIMARY_KEY]); + } + + // 删除多行 + let batchRemove = function (obj) { + let checkIds = common.checkField(obj, PRIMARY_KEY); + if (checkIds === "") { + layui.popup.warning("未选中数据"); + return false; + } + doRemove(checkIds.split(",")); + } + + // 执行删除 + let doRemove = function (ids) { + let data = {}; + data[PRIMARY_KEY] = ids; + layer.confirm("确定删除?", { + icon: 3, + title: "提示" + }, function (index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: DELETE_API, + data: data, + dataType: "json", + type: "post", + success: function (res) { + layer.close(loading); + if (res.code) { + return layui.popup.failure(res.msg); + } + return layui.popup.success("操作成功", refreshTable); + } + }) + }); + } + + // 刷新表格数据 + window.refreshTable = function () { + table.reloadData("data-table", { + scrollPos: "fixed", + done: function (res, curr) { + if (curr > 1 && res.data && !res.data.length) { + curr = curr - 1; + table.reloadData("data-table", { + page: { + curr: curr + }, + }) + } + } + }); + } + }) + + + diff --git a/plugin/admin/app/view/teacher-schedule-time/schedule_time_setting.html b/plugin/admin/app/view/teacher-schedule-time/schedule_time_setting.html index b5f8d11..83f8c9b 100644 --- a/plugin/admin/app/view/teacher-schedule-time/schedule_time_setting.html +++ b/plugin/admin/app/view/teacher-schedule-time/schedule_time_setting.html @@ -14,7 +14,6 @@
-
@@ -76,12 +75,10 @@
{foreach $student as $item} - + {/foreach}
- -
@@ -114,14 +111,15 @@ layui.use(["form", "util", "popup"], function () { let $ = layui.$; let form = layui.form; - + form.render() form.on('checkbox(check_student)', function(data){ - var elem = data.elem; // 获得 checkbox 原始 DOM 对象 + var othis = data.othis; var type = elem.checked ? 'add' : 'remove'; // 获得 checkbox 选中状态 var student_id = elem.value; // 获得 checkbox 值 let teacher_schedule_time_id = "{$schedule_time['id']}"; + var that = this; layui.$.ajax({ url: '/app/admin/studentSchedule/addStudentSchedule', @@ -129,8 +127,13 @@ dateType: "json", data: {student_id: student_id, type: type, teacher_schedule_time_id: teacher_schedule_time_id}, success: function (res) { + + console.log(111,othis.prop('checked')) if (res.code) { - return layui.popup.failure(res.msg); + $(that).prop("checked", false) + form.render() + return layui.popup.failure(res.msg, function () { + }); } return layui.popup.success("操作成功", function () { // parent.refreshTable(); diff --git a/plugin/admin/app/view/teacher/schedule_time_setting.html b/plugin/admin/app/view/teacher/schedule_time_setting.html new file mode 100644 index 0000000..904bbc9 --- /dev/null +++ b/plugin/admin/app/view/teacher/schedule_time_setting.html @@ -0,0 +1,188 @@ + + + + + 更新页面 + + + + + + + +
+ +
+
+
+ +
+ + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ {foreach $student as $item} + + {/foreach} +
+
+
+
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + diff --git a/plugin/admin/app/view/teacher/teacher_schedule_time.html b/plugin/admin/app/view/teacher/teacher_schedule_time.html index 7a0fa4b..8a8352d 100644 --- a/plugin/admin/app/view/teacher/teacher_schedule_time.html +++ b/plugin/admin/app/view/teacher/teacher_schedule_time.html @@ -90,30 +90,8 @@
- - - - - - - - - - - - - - - - - -
- - - -
@@ -205,11 +183,11 @@ layer.open({ type: 2, fix: false, - title: "排课", + title: "学生排课", shade: 0.1, maxmin: true, area: ["750px", "700px"], - content: "/app/admin/teacherScheduleTime/scheduleTimeSet?free_time_id=" + free_time_id + content: "/app/admin/teacher/scheduleTimeSet?free_time_id=" + free_time_id }); // if (confirm('您确定要删除此事件吗?')) { // arg.event.remove()