diff --git a/app/admin/view/index/create.html b/app/admin/view/index/create.html index de8ac218..286ef692 100755 --- a/app/admin/view/index/create.html +++ b/app/admin/view/index/create.html @@ -246,7 +246,7 @@ 备注
- +
diff --git a/app/kaoshi/controller/Index.php b/app/kaoshi/controller/Index.php index e1c89986..03975f11 100755 --- a/app/kaoshi/controller/Index.php +++ b/app/kaoshi/controller/Index.php @@ -122,6 +122,29 @@ class Index extends AdminBase $this->view->assign('list', $list); // 渲染 return $this->view->fetch(); + } + + + // 修改考试信息 + public function editSetp1($id) + { + // 获取考试信息 + $list['data'] = KS::where('id', $id) + ->field('id, title, xueqi_id, category_id, bfdate, enddate, zuzhi_id, fanwei_id') + ->find(); + + // 设置页面标题 + $list['set'] = array( + 'webtitle' => '编辑考试' + ,'butname' => '修改' + ,'formpost' => 'PUT' + ,'url' => '/kaoshi/index/update/' . $id + ); + + // 模板赋值 + $this->view->assign('list', $list); + // 渲染 + return $this->view->fetch('create_setp1'); } @@ -298,7 +321,7 @@ class Index extends AdminBase // 更新数据 $ks = new KS(); $ksdata = $ks::update($list); - $ksdata ? $data = ['msg' => '更新成功', 'val' => 1] + $ksdata ? $data = ['msg' => '更新成功', 'val' => 1, 'kaoshi_id'=> $ksdata->id] : $data = ['msg' => '数据处理错误', 'val' => 0]; // 返回信息 diff --git a/app/kaoshi/controller/KaoshiSet.php b/app/kaoshi/controller/KaoshiSet.php index dea784bb..81038dbc 100755 --- a/app/kaoshi/controller/KaoshiSet.php +++ b/app/kaoshi/controller/KaoshiSet.php @@ -28,6 +28,7 @@ class KaoshiSet extends AdminBase $src['kaoshi_id'] = $kaoshi_id; $list['subject'] = $ksset->srcSubject($src); $nj = $ksset->srcGrade($kaoshi_id); + $list['nj'] = $nj; $kaoshi = new \app\kaoshi\model\Kaoshi; $list['sj'] = $kaoshi::where('id', $kaoshi_id)->value('bfdate'); diff --git a/app/kaoshi/controller/LuruFengong.php b/app/kaoshi/controller/LuruFengong.php new file mode 100644 index 00000000..dc5f8294 --- /dev/null +++ b/app/kaoshi/controller/LuruFengong.php @@ -0,0 +1,183 @@ +srcSubject($src); + $nj = $ksset->srcGrade($kaoshi_id); + $list['nj'] = $nj; + $kaoshi = new \app\kaoshi\model\Kaoshi; + $list['sj'] = $kaoshi::where('id', $kaoshi_id)->value('bfdate'); + + // 模板赋值 + $this->view->assign('list', $list); + + // 渲染模板 + return $this->view->fetch(); + } + + // 获取考试信息列表 + public function ajaxData() + { + + // 获取参数 + $src = $this->request + ->only([ + 'kaoshi_id' => 0 + ,'banji_id' => array() + ,'subject_id' => array() + ,'ruxuenian' => '' + ,'page' => '1' + ,'limit' => '10' + ,'field' => 'update_id' + ,'order' => 'asc' + ,'searchval' => '' + ], 'POST'); + + // 根据条件查询数据 + $lrfgsbj = new lrfg; + $data = $lrfgsbj->search($src); + $data = reSetObject($data, $src); + + return json($data); + } + + + /** + * 显示创建资源表单页. + * + * @return \think\Response + */ + public function create($kaoshi_id) + { + + // 设置页面标题 + $list['set'] = array( + 'webtitle' => '录入成绩分工' + ,'butname' => '分工' + ,'formpost' => 'POST' + ,'url' => '/kaoshi/lrfg/save' + ,'kaoshi_id' => $kaoshi_id + ); + + // 获取考试时间 + $ks = new \app\kaoshi\model\Kaoshi; + $enddate = $ks->kaoshiInfo($kaoshi_id); + $enddate = $enddate->getData('enddate'); + $list['set']['nianji'] = nianJiNameList('str', $enddate); + + // 模板赋值 + $this->view->assign('list', $list); + // 渲染 + return $this->view->fetch(); + } + + + /** + * 保存新建的资源 + * + * @param \think\Request $request + * @return \think\Response + */ + public function save() + { + // 获取参数 + $src = $this->request + ->only([ + 'kaoshi_id' + ,'admin_id' => array() + ,'subject_id' => array() + ,'banji_id' => array() + ], 'POST'); + + event('kslu', $src['kaoshi_id']); + + // 验证表单数据 + $validate = new \app\kaoshi\validate\LuruFengong; + $result = $validate->scene('create')->check($src); + $msg = $validate->getError(); + // 如果验证不通过则停止保存 + if(!$result){ + return json(['msg' => $msg,'val' => 0]);; + } + + // 整理参数 + $list = array(); + foreach ($src['admin_id'] as $admin_k => $admin_v) { + foreach ($src["banji_id"] as $banji_k => $banji_v) { + foreach ($src["subject_id"] as $sbj_k => $sbj_v) { + $list[] = [ + 'kaoshi_id' => $src['kaoshi_id'] + ,'banji_id' => $banji_v + ,'subject_id' => $sbj_v + ,'admin_id' => $admin_v + ]; + } + } + } + + // 查询已经存在数据删除并添加新数据 + $lrfg = new lrfg; + + $data = $lrfg->saveAll($list); + + // 根据更新结果设置返回提示信息 + $data ? $data = ['msg' => '设置成功', 'val' => 1] + : $data = ['msg' => '数据处理错误', 'val' => 0]; + + // 返回信息 + return json($data); + + } + + /** + * 删除指定资源 + * + * @param int $id + * @return \think\Response + */ + // 删除考号 + public function delete($id) + { + + // 整理数据 + $id = request()->delete('id'); + $id = explode(',', $id); + + // 判断考试结束时间是否已过 + $lrfg = new lrfg; + $ksid = $lrfg::where('id', $id[0])->value('kaoshi_id'); + event('kslu', $ksid); + + $data = lrfg::destroy($id, true); + // 根据更新结果设置返回提示信息 + $data ? $data = ['msg' => '删除成功','val' => 1] + : $data = ['msg' => '数据处理错误','val' => 0]; + // 返回信息 + return json($data); + } +} diff --git a/app/kaoshi/model/LuruFengong.php b/app/kaoshi/model/LuruFengong.php new file mode 100644 index 00000000..11abf494 --- /dev/null +++ b/app/kaoshi/model/LuruFengong.php @@ -0,0 +1,118 @@ + '' + ,'banji_id' => '' + ,'subject_id' => '' + ,'ruxuenian' => '' + ,'searchval' => '' + ]; + $src = array_cover($srcfrom, $src) ; + $src['kaoshi_id'] = strToarray($src['kaoshi_id']); + $src['banji_id'] = strToarray($src['banji_id']); + + $logList = self::where('kaoshi_id', 'in', $src['kaoshi_id']) + ->when(count($src['banji_id']) > 0, function($query) use($src){ + $query->where('banji_id', 'in', $src['banji_id']); + }) + ->when(count($src['subject_id']) > 0, function($query) use($src){ + $query->where('subject_id', 'in', $src['subject_id']); + }) + ->when(strlen($src['searchval']) > 0, function($query) use($src){ + $query->where('admin_id', 'in', function ($q) use($src) { + $q->name('admin') + ->where('xingming', 'like', '%'. $src['searchval'] . '%') + ->field('id'); + }); + }) + ->when(strlen($src['ruxuenian']) > 0, function($query) use($src){ + $query->where('banji_id', 'in', function ($q) use($src) { + $q->name('banji') + ->where('ruxuenian', $src['ruxuenian']) + ->field('id'); + }); + }) + ->with([ + 'fgKaoshi' => function ($query) { + $query->field('id, title'); + } + ,'fgBanji' => function ($query) { + $query->field('id, ruxuenian, paixu, school_id') + ->with([ + 'glSchool' => function($q){ + $q->field('id, title, jiancheng'); + }, + ]) + ->append(['banjiTitle']); + } + ,'fgSubject' => function ($query) { + $query->field('id, title, jiancheng'); + } + ,'fgAdmin' => function ($query) { + $query->field('id, xingming'); + } + ]) + ->select(); + + return $logList; + } + + + // 根据教师ID查询可以录入成绩的班级 + public function srcMyLuruBanji($srcfrom) + { + $src = [ + 'kaoshi_id' => '' + ]; + $src = array_cover($srcfrom, $src) ; + $admin_id = session('user_id'); + $data = $this->where('user_id', $admin_id) + ->where('kaoshi_id', $src['kaoshi_id']) + ->->group('banji_id') + ->column(['banji_id']); + return $data; + } + + + // 考试关联表 + public function fgKaoshi() + { + return $this->belongsTo('\app\kaoshi\model\Kaoshi', 'kaoshi_id', 'id'); + } + + + // 班级关联表 + public function fgBanji() + { + return $this->belongsTo('\app\teach\model\Banji', 'banji_id', 'id'); + } + + + // 学科关联表 + public function fgSubject() + { + return $this->belongsTo('\app\teach\model\Subject', 'subject_id', 'id'); + } + + + // 考试关联表 + public function fgAdmin() + { + return $this->belongsTo('\app\admin\model\Admin', 'admin_id', 'id'); + } + + +} diff --git a/app/kaoshi/route/kaoshi.php b/app/kaoshi/route/kaoshi.php index 5201c44e..ae115ae8 100755 --- a/app/kaoshi/route/kaoshi.php +++ b/app/kaoshi/route/kaoshi.php @@ -28,6 +28,8 @@ Route::group('index', function () { Route::rule('setp3/','Index/createSetp3','get'); # 添加信息 Route::rule('tongji/','Index/tongji','get'); # 添加信息 Route::rule('chengji/','Index/chengji','get'); # 添加信息 + Route::rule('editsetp1/','Index/editSetp1','get'); # 更新信息 + Route::rule('updatesetp1/','Index/updateSetp1','put'); # 更新信息 }); @@ -65,7 +67,14 @@ Route::group('tjxm', function () { }); - +// 考试设置 +Route::group('lrfg', function () { + Route::rule('index/','LuruFengong/index','get'); # 信息列表 + Route::rule('data','LuruFengong/ajaxdata','post'); # 获取数据 + Route::rule('create/','LuruFengong/create','get'); # 添加信息 + Route::rule('save','LuruFengong/save','post'); # 保存信息 + Route::rule('delete/','LuruFengong/delete','delete'); # 删除信息 +}); diff --git a/app/kaoshi/validate/LuruFengong.php b/app/kaoshi/validate/LuruFengong.php new file mode 100644 index 00000000..68dc52d1 --- /dev/null +++ b/app/kaoshi/validate/LuruFengong.php @@ -0,0 +1,39 @@ + ['规则1','规则2'...] + * + * @var array + */ + protected $rule = [ + 'kaoshi_id|考试' => 'require|length:1,25', + 'admin_id|教师' => 'require|array', + 'banji_id|班级' => 'require|array', + 'subject_id|学科' => 'require|array', + ]; + + /** + * 定义错误信息 + * 格式:'字段名.规则名' => '错误信息' + * + * @var array + */ + protected $message = []; + + protected $scene = [ + 'create' => [ + 'kaoshi_id' + ,'admin_id' + ,'subject_id' + ,'banji_id' + ], + ]; +} diff --git a/app/kaoshi/view/index/create_setp1.html b/app/kaoshi/view/index/create_setp1.html index fbb3fd4a..bb917342 100644 --- a/app/kaoshi/view/index/create_setp1.html +++ b/app/kaoshi/view/index/create_setp1.html @@ -40,7 +40,12 @@ {volist name="xueqilist" id="vo"} - {/volist} @@ -84,7 +94,12 @@ +
- +
@@ -111,13 +126,19 @@ +
+ 上一步 @@ -172,6 +173,13 @@ } + function preSet() + { + $(location).attr('href', '/kaoshi/index/editsetp1/' + "{$list['set']['kaoshi_id']}"); + return false; + } + + // 下层按钮 function btmOnclick(id,ischecked) { diff --git a/app/kaoshi/view/index/create_setp3.html b/app/kaoshi/view/index/create_setp3.html index d505463a..067a6637 100644 --- a/app/kaoshi/view/index/create_setp3.html +++ b/app/kaoshi/view/index/create_setp3.html @@ -58,6 +58,7 @@
+ 上一步 @@ -142,6 +143,13 @@ return false; } + + function preSet() + { + $(location).attr('href', '/kaoshi/index/setp2/' + "{$list['set']['kaoshi_id']}"); + return false; + } + {/block} diff --git a/app/kaoshi/view/index/index.html b/app/kaoshi/view/index/index.html index 7e3e8b0f..91a57ba6 100755 --- a/app/kaoshi/view/index/index.html +++ b/app/kaoshi/view/index/index.html @@ -63,6 +63,7 @@ + @@ -154,6 +155,9 @@ case 'renke':// 查询成绩 cjgl.addTab(obj.data.title + ' 任课教师设置', '/chengji/bjtj/renke/' + obj.data.id, true); break; + case 'lurufengong':// 查询成绩 + cjgl.addTab(obj.data.title + ' 录入成绩分工', '/kaoshi/lrfg/index/' + obj.data.id, true); + break; }; }); }); diff --git a/app/kaoshi/view/kaoshi_set/index.html b/app/kaoshi/view/kaoshi_set/index.html index 364eb273..20a6ad33 100755 --- a/app/kaoshi/view/kaoshi_set/index.html +++ b/app/kaoshi/view/kaoshi_set/index.html @@ -12,14 +12,13 @@ {block name="search"}
- -
- - {php} $njlist = nianJiNameList('str',$list['sj']);{/php} - {foreach $njlist as $key=>$vo} - - {/foreach} -
+ +
+ + {volist name="list.nj" id="vo"} + + {/volist} +
diff --git a/app/kaoshi/view/luru_fengong/create.html b/app/kaoshi/view/luru_fengong/create.html new file mode 100644 index 00000000..0132b2ca --- /dev/null +++ b/app/kaoshi/view/luru_fengong/create.html @@ -0,0 +1,157 @@ +{extend name=".././view/create.html" /} +{block name="jscss"} + +{/block} +{block name="form"} +
+ +
+ +
+
+ +
+ {present name="$list.data.kt_zcr"} + {volist name="$list.data.kt_zcr" id="vo"} +
+
+ {$vo.admin.xingming} +
+
+ {/volist} + {/present} +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+{/block} + +{block name="myjs"} + +{/block} + diff --git a/app/kaoshi/view/luru_fengong/edit.html b/app/kaoshi/view/luru_fengong/edit.html new file mode 100644 index 00000000..126fee1a --- /dev/null +++ b/app/kaoshi/view/luru_fengong/edit.html @@ -0,0 +1,76 @@ +{extend name=".././view/create.html" /} + +{block name="form"} +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+ +
+
+{/block} + +{block name="myjs"} + +{/block} + diff --git a/app/kaoshi/view/luru_fengong/index.html b/app/kaoshi/view/luru_fengong/index.html new file mode 100644 index 00000000..d51b5bbf --- /dev/null +++ b/app/kaoshi/view/luru_fengong/index.html @@ -0,0 +1,165 @@ + +{extend name=".././view/list.html" /} +{block name="jsset"} + +{/block} +{block name="nav"} + + 考试管理 + 考试设置 + +{/block} +{block name="search"} + +
+ +
+ +
+
+
+ +
+ + {volist name="list.nj" id="vo"} + + {/volist} +
+
+
+ +
+ +
+
+{/block} +{block name="table"} +
+{/block} +{block name="myjs"} + + + + + + +{/block} diff --git a/app/kaoshi/view/tongji_log/index.html b/app/kaoshi/view/tongji_log/index.html index 41a1ec83..8e8e0512 100755 --- a/app/kaoshi/view/tongji_log/index.html +++ b/app/kaoshi/view/tongji_log/index.html @@ -74,9 +74,6 @@ break; }; }); - - - }); diff --git a/database/migrations/20210302070154_luru_fengong.php b/database/migrations/20210302070154_luru_fengong.php index b6db932e..46aff45a 100644 --- a/database/migrations/20210302070154_luru_fengong.php +++ b/database/migrations/20210302070154_luru_fengong.php @@ -34,7 +34,7 @@ class LuRuFenGong extends Migrator // 添加当前表字段 $table ->addColumn('kaoshi_id','integer',['limit'=>11,'null'=>false,'comment'=>'考试id']) - ->addColumn('user_id','integer',['limit'=>11,'null'=>false,'comment'=>'用户id']) + ->addColumn('admin_id','integer',['limit'=>11,'null'=>false,'comment'=>'用户id']) ->addColumn('banji_id','integer',['limit'=>11,'null'=>false,'comment'=>'班级id']) ->addColumn('subject_id','integer',['limit'=>11,'null'=>false,'comment'=>'学科id']) ->addColumn('create_time','integer',['limit'=>11,'default'=>1539158918,'null'=>false,'comment'=>'创建时间'])