diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 6be698cd..97d7779f 100755 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -452,6 +452,7 @@ class Index extends AdminBase } + // 表格有效性 private function youxiaoxing($obj, $cell, $value) { $yxx = $obj->getCell($cell) diff --git a/app/kaoshi/view/luru_fengong/create.html b/app/kaoshi/view/luru_fengong/create.html index 6fca0f3f..e7f0164a 100644 --- a/app/kaoshi/view/luru_fengong/create.html +++ b/app/kaoshi/view/luru_fengong/create.html @@ -1,32 +1,6 @@ {extend name=".././view/create.html" /} {block name="jscss"} - {/block} {block name="form"}
diff --git a/app/teach/controller/FenGong.php b/app/teach/controller/FenGong.php index a5b584c9..eddabbb4 100644 --- a/app/teach/controller/FenGong.php +++ b/app/teach/controller/FenGong.php @@ -21,6 +21,10 @@ class FenGong extends AdminBase $list['dataurl'] = 'fengong/data'; $list['status'] = '/teach/fengong/status'; $list['kaoshi'] = '/teach/fengong/kaoshi'; + $list['nianji'] = \app\facade\Tools::nianJiNameList(); + + $fg = new FG(); + $qx = $fg->teacherFengong(67); // 模板赋值 $this->view->assign('list', $list); @@ -43,22 +47,29 @@ class FenGong extends AdminBase ,'status' => '' ,'delete_time' => '' ,'searchval' => '' - ,'student_id' => '' + ,'subject_id' => '' + ,'ruxuenian' => '' ],'POST'); + if (strlen($src['ruxuenian']) > 0) { + $bj = new \app\teach\model\Banji; + $src['banji_id'] = $bj ->where('ruxuenian', $src['ruxuenian']) + ->where('status', true) + ->column('id'); + } + // 按条件查询数据 $fg = new FG; $data = $fg->search($src) ->visible([ 'id' - ,'title' - ,'jiancheng' - ,'lieming' - ,'sbjCategory' => ['title'] - ,'status' - ,'kaoshi' - ,'paixu' - ,'update_time' + ,'teacher_id' + ,'subject_id' + ,'xueqi_id' + ,'fgTeacher' => ['id', 'xingming'] + ,'fgSubject' => ['id', 'title'] + ,'fgXueqi' => ['id', 'title'] + ,'bfdate' ]); $src['all'] = true; @@ -79,6 +90,7 @@ class FenGong extends AdminBase ,'formpost' => 'POST' ,'url' => 'save' ); + $list['data']['nianji'] = \app\facade\Tools::nianJiNameList(); // 模板赋值 $this->view->assign('list', $list); @@ -92,24 +104,39 @@ class FenGong extends AdminBase { // 获取表单数据 $list = request()->only([ - 'title' - ,'jiancheng' - ,'category_id' - ,'kaoshi' - ,'paixu' - ,'lieming' + 'teacher_id' + ,'subject_id' + ,'banji_id' + ,'xueqi_id' + ,'bfdate' ], 'post'); // 验证表单数据 $validate = new \app\teach\validate\FenGong; + $result = $validate->scene('create')->check($list); $msg = $validate->getError(); if(!$result){ return json(['msg' => $msg, 'val' => 0]); } + + $data = array(); + foreach ($list['banji_id'] as $key => $value) { + foreach ($list['subject_id'] as $k => $val) { + $data[] = [ + 'teacher_id' => $list['teacher_id'] + ,'banji_id' => $value + ,'subject_id' => $val + ,'bfdate' => $list['bfdate'] + ,'xueqi_id' => $list['xueqi_id'] + ]; + } + } + // 保存数据 - $data = FG::create($list); + $fg = new FG(); + $data = $fg->saveAll($data); // 根据更新结果设置返回提示信息 $data ? $data = ['msg' => '添加成功', 'val' => 1] diff --git a/app/teach/controller/Xueqi.php b/app/teach/controller/Xueqi.php index 016cadc0..120a86c9 100755 --- a/app/teach/controller/Xueqi.php +++ b/app/teach/controller/Xueqi.php @@ -220,4 +220,5 @@ class Xueqi extends AdminBase return json($data); } + } diff --git a/app/teach/model/FenGong.php b/app/teach/model/FenGong.php index de9f3046..7522be6d 100644 --- a/app/teach/model/FenGong.php +++ b/app/teach/model/FenGong.php @@ -14,6 +14,7 @@ class FenGong extends BaseModel ,'banji_id' => 'int' ,'subject_id' => 'int' ,'teacher_id' => 'int' + ,'xueqi_id' => 'int' ,'create_time' => 'int' ,'bfdate' => 'int' ,'update_time' => 'int' @@ -33,12 +34,14 @@ class FenGong extends BaseModel ,'field' => 'id' ,'order' => 'desc' ,'subject_id' => '' + ,'banji_id' => '' ,'xueqi_id' => '' ,'all' => false ]; $src = array_cover($srcfrom, $src); $src['subject_id'] = str_to_array($src['subject_id']); $src['xueqi_id'] = str_to_array($src['xueqi_id']); + $src['banji_id'] = str_to_array($src['banji_id']); // 查询数据 $data = $this @@ -51,6 +54,9 @@ class FenGong extends BaseModel ->when(count($src['xueqi_id']) > 0, function($query) use($src){ $query->where('xueqi_id', 'in', $src['xueqi_id']); }) + ->when(count($src['banji_id']) > 0, function($query) use($src){ + $query->where('banji_id', 'in', $src['banji_id']); + }) ->when($src['all'] == false, function ($query) use($src) { $query ->page($src['page'], $src['limit']); @@ -62,6 +68,13 @@ class FenGong extends BaseModel ,'fgSubject' => function ($query) { $query->field('id, title, jiancheng, lieming'); } + ,'fgTeacher' => function ($query) { + $query->field('id, xingming'); + } + ,'fgBanji' => function ($query) { + $query->field('id, ruxuenian, paixu') + ->append(['banjiTitle']); + } ]) ->order([$src['field'] => $src['order']]) ->select(); @@ -69,6 +82,62 @@ class FenGong extends BaseModel } + // 查教师现任务分工 + public function teacherFengong($teacher_id = 0, $time = 0) + { + $time == 0 ? $time = time() : $time; + + // 查询学期 + $xq = new \app\teach\model\Xueqi; + $xueqi_id = $xq->timeSrcXueqi($time); + $xueqi_id ? $xueqi_id = $xueqi_id->id : $xueqi_id = 0; + + // 查询任务分工情况 + $data = $this + ->where('teacher_id', $teacher_id) + ->where('xueqi_id', $xueqi_id) + ->where('bfdate', '<', $time) + ->field('any_value(id) as id + ,any_value(xueqi_id) as xueqi_id + ,any_value(banji_id) as banji_id + ,any_value(subject_id) as subject_id + ,any_value(teacher_id) as teacher_id + ,any_value(bfdate) as bfdate') + ->group('xueqi_id,banji_id,subject_id') + ->select(); + + return $data; + } + + + // 查询班级现任课教师 + public function banjiSubjectFengong($banji_id=0, $time=0) + { + $time == 0 ? $time = time() : $time; + + // 查询学期 + $xq = new \app\teach\model\Xueqi; + $xueqi_id = $xq->timeSrcXueqi($time); + $xueqi_id ? $xueqi_id = $xueqi_id->id : $xueqi_id = 0; + + // 查询任务分工情况 + $data = $this + ->where('banji_id', $banji_id) + ->where('xueqi_id', $xueqi_id) + ->where('bfdate', '<', $time) + ->field('any_value(id) as id + ,any_value(xueqi_id) as xueqi_id + ,any_value(banji_id) as banji_id + ,any_value(subject_id) as subject_id + ,any_value(teacher_id) as teacher_id + ,any_value(bfdate) as bfdate') + ->group('subject_id') + ->select(); + + return $data; + } + + // 学期关联 public function fgXueqi() { @@ -76,10 +145,39 @@ class FenGong extends BaseModel } - // 学期关联 + // 学科关联 public function fgSubject() { - return $this->belongsTo(\app\teach\model\Subject::class, 'xueqi_id', 'id'); + return $this->belongsTo(\app\teach\model\Subject::class, 'subject_id', 'id'); + } + + + // 教师关联 + public function fgTeacher() + { + return $this->belongsTo(\app\admin\model\Admin::class, 'teacher_id', 'id') + ->visible(['id', 'xingming']); + } + + + // 教师关联 + public function fgBanji() + { + return $this->belongsTo(\app\teach\model\Banji::class, 'banji_id', 'id'); + } + + + // 接任时间获取器 + public function getBfdateAttr($value) + { + return date('Y-m-d', $value); + } + + + // 接任时间修改器 + public function setBfdateAttr($value) + { + return strtotime($value); } diff --git a/app/teach/model/Xueqi.php b/app/teach/model/Xueqi.php index ab3f3c75..2018a1d7 100755 --- a/app/teach/model/Xueqi.php +++ b/app/teach/model/Xueqi.php @@ -111,4 +111,21 @@ class Xueqi extends BaseModel ->select(); return $list; } + + + // 根据时间查询学期 + public function timeSrcXueqi($time = 0) + { + if($time == 0) + { + $time = time(); + } + + $data = $this + ->where('bfdate', '<', $time) + ->where('enddate', '>', $time) + ->cache(true) + ->find(); + return $data; + } } diff --git a/app/teach/route/teach.php b/app/teach/route/teach.php index 4a7dc1cb..27fa162e 100755 --- a/app/teach/route/teach.php +++ b/app/teach/route/teach.php @@ -110,13 +110,13 @@ Route::group('zuzhang', function () { // 任务分工 Route::group('fengong', function () { - Route::rule('','fengong/index','get'); # 信息列表 - Route::rule('data','fengong/ajaxdata','post'); # 获取数据 - Route::rule('create','fengong/create','get'); # 添加信息 - Route::rule('save','fengong/save','post'); # 保存信息 - Route::rule('edit/','fengong/edit','get'); # 修改信息 - Route::rule('update/','fengong/update','put'); # 更新信息 - Route::rule('delete','fengong/delete','delete'); # 删除信息 - Route::rule('status','fengong/setStatus','post'); # 删除信息 + Route::rule('','FenGong/index','get'); # 信息列表 + Route::rule('data','FenGong/ajaxdata','post'); # 获取数据 + Route::rule('create','FenGong/create','get'); # 添加信息 + Route::rule('save','FenGong/save','post'); # 保存信息 + Route::rule('edit/','FenGong/edit','get'); # 修改信息 + Route::rule('update/','FenGong/update','put'); # 更新信息 + Route::rule('delete','FenGong/delete','delete'); # 删除信息 + Route::rule('status','FenGong/setStatus','post'); # 删除信息 }); diff --git a/app/teach/validate/FenGong.php b/app/teach/validate/FenGong.php index 6e23eda0..87c7dfd2 100644 --- a/app/teach/validate/FenGong.php +++ b/app/teach/validate/FenGong.php @@ -13,7 +13,14 @@ class FenGong extends Validate * * @var array */ - protected $rule = []; + protected $rule = [ + 'id|ID' => 'require|number', + 'teacher_id|教师' => 'require|number', + 'subject_id|学科' => 'require|array', + 'banji_id|班级' => 'require|array', + 'xueqi_id|学期' => 'require|number', + 'bfdate|上任时间' => 'require|date', + ]; /** * 定义错误信息 @@ -21,5 +28,13 @@ class FenGong extends Validate * * @var array */ - protected $message = []; + protected $scene = [ + 'create' => [ + 'teacher_id' + ,'subject_id' + ,'banji_id' + ,'xueqi_id' + ,'bfdate' + ] + ]; } diff --git a/app/teach/view/fen_gong/create.html b/app/teach/view/fen_gong/create.html new file mode 100644 index 00000000..79ae7d62 --- /dev/null +++ b/app/teach/view/fen_gong/create.html @@ -0,0 +1,99 @@ +{extend name=".././view/create.html" /} +{block name="jscss"} + +{/block} +{block name="form"} + +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +{/block} +{block name="myjs"} + +{/block} diff --git a/app/teach/view/fengong/index.html b/app/teach/view/fen_gong/index.html similarity index 61% rename from app/teach/view/fengong/index.html rename to app/teach/view/fen_gong/index.html index b6d8871f..d790d3fa 100644 --- a/app/teach/view/fengong/index.html +++ b/app/teach/view/fen_gong/index.html @@ -17,13 +17,22 @@ -
- +
+
- - + +
+
+
+ +
+
@@ -49,7 +58,6 @@ diff --git a/app/teach/view/fengong/create.html b/app/teach/view/fengong/create.html deleted file mode 100644 index c34707af..00000000 --- a/app/teach/view/fengong/create.html +++ /dev/null @@ -1,96 +0,0 @@ -{extend name=".././view/create.html" /} -{block name="form"} -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- -
- -
-
-
- -
-
-{/block} -{block name="myjs"} - -{/block}