diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 3b00864b..951d912b 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -16,48 +16,5 @@ class Index extends Base return $this->fetch(); } - // 生成考号 - public function kaohao() - { - return $this->fetch(); - } - - // 保存考号 - public function kaohaosave() - { - // 获取表单数据 - $list = request()->only(['kaoshi','banjiids'],'post'); - // 获取参加考试班级 - $list['banjiids'] = implode(',',$list['banjiids']); - - // 获取参加考试学生名单 - $stulist = Student::where('status',1) - ->where('banji','in',$list['banjiids']) - ->field('id,school,banji') - ->append(['nianji']) - ->select(); - - // 组合参加考试学生信息 - $stus = array(); - foreach ($stulist as $key => $value) { - $stus[] = [ - 'kaoshi' => $list['kaoshi'], - 'school' => $value->school, - 'ruxuenian' => $value->nianji, - 'banji' => $value->banji, - 'student' => $value->id - ]; - } - - // 声明成绩数据模型类 - $cj = new Chengji(); - $data = $cj->saveAll($stus); - - - // 根据更新结果设置返回提示信息 - $data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; - - // 返回信息 - return json($data); - } + } diff --git a/application/teach/controller/Kaoshi.php b/application/teach/controller/Kaoshi.php index c67ea2ae..4c5bb7ce 100644 --- a/application/teach/controller/Kaoshi.php +++ b/application/teach/controller/Kaoshi.php @@ -6,6 +6,10 @@ namespace app\teach\controller; use app\common\controller\Base; // 引用学期数据模型类 use app\teach\model\Kaoshi as KS; +// 引用学生类 +use app\renshi\model\Student; +// 引用成绩类 +use app\chengji\model\Chengji; class Kaoshi extends Base { @@ -298,4 +302,49 @@ class Kaoshi extends Base // 返回信息 return json($data); } + + // 生成考号 + public function kaohao() + { + return $this->fetch(); + } + + // 保存考号 + public function kaohaosave() + { + // 获取表单数据 + $list = request()->only(['kaoshi','banjiids'],'post'); + // 获取参加考试班级 + $list['banjiids'] = implode(',',$list['banjiids']); + + // 获取参加考试学生名单 + $stulist = Student::where('status',1) + ->where('banji','in',$list['banjiids']) + ->field('id,school,banji') + ->append(['nianji']) + ->select(); + + // 组合参加考试学生信息 + $stus = array(); + foreach ($stulist as $key => $value) { + $stus[] = [ + 'kaoshi' => $list['kaoshi'], + 'school' => $value->school, + 'ruxuenian' => $value->nianji, + 'banji' => $value->banji, + 'student' => $value->id + ]; + } + + // 声明成绩数据模型类 + $cj = new Chengji(); + $data = $cj->saveAll($stus); + + + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); + } } diff --git a/application/teach/view/kaoshi/index.html b/application/teach/view/kaoshi/index.html index 7b9a40cf..22590634 100644 --- a/application/teach/view/kaoshi/index.html +++ b/application/teach/view/kaoshi/index.html @@ -96,12 +96,15 @@ startbut = ''; // 编辑按钮 editbut = ''; + // 生成考号 + kaohaobut = ''; + // 删除按钮 delbut = ''; if(row.status == '已停用') { - buts = startbut + editbut + delbut; + buts = startbut + editbut + kaohaobut + delbut; }else{ - buts = stopbut + editbut + delbut; + buts = stopbut + editbut + kaohaobut + delbut; } return buts; diff --git a/application/chengji/view/index/kaohao.html b/application/teach/view/kaoshi/kaohao.html similarity index 97% rename from application/chengji/view/index/kaohao.html rename to application/teach/view/kaoshi/kaohao.html index 16a15f48..8211f46c 100644 --- a/application/chengji/view/index/kaohao.html +++ b/application/teach/view/kaoshi/kaohao.html @@ -1,6 +1,6 @@ {extend name="common@create" /} {block name="formaa"} -