diff --git a/app/common/model/Student.php b/app/common/model/Student.php index 95fe00d..7b056c9 100644 --- a/app/common/model/Student.php +++ b/app/common/model/Student.php @@ -23,6 +23,9 @@ use support\Model; */ class Student extends BaseModel { - - + public function parent() + { + return $this->hasOne(StudentParent::class, 'id', 'parent_id')->bind(['parent_name']); + } + } diff --git a/app/common/service/TeacherScheduleTimeService.php b/app/common/service/TeacherScheduleTimeService.php index 29aaad1..6018069 100644 --- a/app/common/service/TeacherScheduleTimeService.php +++ b/app/common/service/TeacherScheduleTimeService.php @@ -74,6 +74,11 @@ class TeacherScheduleTimeService } } + /** + * @desc 获取排课列表 + * @param $request + * @return array + */ public function getScheduleTime($request) { try { @@ -87,8 +92,17 @@ class TeacherScheduleTimeService } $data = $request->get(); - $schedule = TeacherScheduleTime::where(['teacher_id'=>$teacher->id, 'date'=>$data['schedule_date']])->select(); + $schedule = TeacherScheduleTime::where(['teacher_id'=>$teacher->id, 'month'=>$data['month']]) + ->field('id,teacher_id,date,time,hour,month,subject_id,is_publish') + ->with(['subject']) + ->select(); +// foreach ($schedule as &$item){ +// if(!$item->is_publish){ +// $item->subject_name = ''; +// $item->english_name = ''; +// } +// } return [ 'code' => ResponseCode::SUCCESS, diff --git a/plugin/admin/app/controller/StudentController.php b/plugin/admin/app/controller/StudentController.php index 1d9368a..94dac3e 100644 --- a/plugin/admin/app/controller/StudentController.php +++ b/plugin/admin/app/controller/StudentController.php @@ -2,6 +2,7 @@ namespace plugin\admin\app\controller; +use app\common\model\StudentParent; use app\constant\ResponseCode; use support\Request; use support\Response; @@ -39,6 +40,39 @@ class StudentController extends Crud return view('student/index'); } + public function select(Request $request): Response + { + try { + + $data = $request->get(); + + $student = \app\common\model\Student::order('id asc'); + if (isset($data['id']) && $data['id']) { + $student->where(['id' => $data['id']]); + } + + $limit = (int)$request->get('limit', 10); + $limit = $limit <= 0 ? 10 : $limit; + $page = (int)$request->get('page'); + $page = $page > 0 ? $page : 1; + + $total = $student->count(); + $list = $student->page($page, $limit)->with(['parent'])->select(); + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'count' => $total, + 'data' => $list, + 'msg' => 'success' + ]); + } catch (Exception $e) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } + } + /** * 插入 * @param Request $request @@ -64,7 +98,7 @@ class StudentController extends Crud 'password' => $password, 'salt' => $salt, 'avatar' => $request_data['avatar'], - 'parent_id' => 0, + 'parent_id' => $request_data['parent_id'], ]); return json([ @@ -73,7 +107,9 @@ class StudentController extends Crud ]); // return parent::insert($request); } - return view('student/insert'); + + $parent = StudentParent::order('id asc')->field('id,parent_name,account')->select()->toArray(); + return view('student/insert', ['parent' => $parent]); } /** @@ -98,7 +134,7 @@ class StudentController extends Crud 'student_name' => $request_data['student_name'], 'account' => $request_data['account'], 'avatar' => $request_data['avatar'], - 'parent_id' => 0, + 'parent_id' => $request_data['parent_id'], ]; } else { $salt = random_str(16); @@ -109,7 +145,7 @@ class StudentController extends Crud 'password' => $password, 'salt' => $salt, 'avatar' => $request_data['avatar'], - 'parent_id' => 0, + 'parent_id' => $request_data['parent_id'], ]; } @@ -128,7 +164,9 @@ class StudentController extends Crud // return parent::update($request); } - return view('student/update'); + + $parent = StudentParent::order('id asc')->field('id,parent_name,account')->select()->toArray(); + return view('student/update', ['parent' => $parent]); } @@ -150,7 +188,7 @@ class StudentController extends Crud 'salt' => $salt, 'password' => $password ]); - if(!$res){ + if (!$res) { throw new Exception('重置失败'); } diff --git a/plugin/admin/app/view/student/index.html b/plugin/admin/app/view/student/index.html index 4d4a635..e6e2240 100644 --- a/plugin/admin/app/view/student/index.html +++ b/plugin/admin/app/view/student/index.html @@ -102,7 +102,7 @@ hide: true }, { title: "家长", align: "center", - field: "parent_id", + field: "parent_name", }, { title: "创建时间", align: "center", field: "created_at", @@ -213,7 +213,7 @@ title: "新增", shade: 0.1, maxmin: true, - area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"], + area: [common.isModile() ? "100%" : "750px", common.isModile() ? "100%" : "700px"], content: INSERT_URL }); } @@ -226,7 +226,7 @@ title: "修改", shade: 0.1, maxmin: true, - area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"], + area: [common.isModile() ? "100%" : "650px", common.isModile() ? "100%" : "700px"], content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value }); } diff --git a/plugin/admin/app/view/student/insert.html b/plugin/admin/app/view/student/insert.html index 208142c..a117041 100644 --- a/plugin/admin/app/view/student/insert.html +++ b/plugin/admin/app/view/student/insert.html @@ -66,7 +66,12 @@