From 2223d228dba4acf6964d7b2ba209bab39b1f11b4 Mon Sep 17 00:00:00 2001 From: cxdbz Date: Wed, 14 Nov 2018 21:22:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E5=AD=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/AuthRule.php | 6 +-- application/admin/view/auth_rule/create.html | 6 +++ application/admin/view/auth_rule/edit.html | 6 +++ application/chengji/controller/Index.php | 43 ++++++++++++++++ application/chengji/model/Chengji.php | 3 +- application/chengji/view/index/kaohao.html | 28 +++++++++-- application/renshi/model/Student.php | 8 ++- .../migrations/20181114055804_chengji.php | 49 +++++++++++++++++++ database/seeds/Rule.php | 2 +- route/chengji.php | 1 + 10 files changed, 140 insertions(+), 12 deletions(-) create mode 100644 database/migrations/20181114055804_chengji.php diff --git a/application/admin/controller/AuthRule.php b/application/admin/controller/AuthRule.php index a8380747..deaa66ab 100644 --- a/application/admin/controller/AuthRule.php +++ b/application/admin/controller/AuthRule.php @@ -105,7 +105,7 @@ class AuthRule extends Base // 获取表单数据 - $list = request()->only(['title','name','pid','condition','paixu','ismenu','font','beizhu'],'post'); + $list = request()->only(['title','name','pid','condition','paixu','ismenu','font','beizhu','url'],'post'); // 验证表单数据 @@ -142,7 +142,7 @@ class AuthRule extends Base { // 获取权限信息 - $list = AR::field('id,title,name,condition,pid,paixu,ismenu,font') + $list = AR::field('id,title,name,condition,pid,paixu,ismenu,font,url') ->get($id); @@ -161,7 +161,7 @@ class AuthRule extends Base $validate = new \app\admin\validate\Rule; // 获取表单数据 - $list = request()->only(['title','name','pid','condition','paixu','ismenu','font','beizhu'],'put'); + $list = request()->only(['title','name','pid','condition','paixu','ismenu','font','beizhu','url'],'put'); // 验证表单数据 $result = $validate->check($list); diff --git a/application/admin/view/auth_rule/create.html b/application/admin/view/auth_rule/create.html index 2d37d9af..9f510017 100644 --- a/application/admin/view/auth_rule/create.html +++ b/application/admin/view/auth_rule/create.html @@ -62,6 +62,12 @@ +
+ +
+ +
+
diff --git a/application/admin/view/auth_rule/edit.html b/application/admin/view/auth_rule/edit.html index 2e93b6c8..ea45ceb5 100644 --- a/application/admin/view/auth_rule/edit.html +++ b/application/admin/view/auth_rule/edit.html @@ -62,6 +62,12 @@
+
+ +
+ +
+
diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 99de00eb..3b00864b 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -3,6 +3,10 @@ namespace app\chengji\controller; // 引用控制器基类 use app\common\controller\Base; +// 引用学生类 +use app\renshi\model\Student; +// 引用成绩类 +use app\chengji\model\Chengji; class Index extends Base { @@ -17,4 +21,43 @@ class Index extends Base { 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/chengji/model/Chengji.php b/application/chengji/model/Chengji.php index 108950af..6f82e278 100644 --- a/application/chengji/model/Chengji.php +++ b/application/chengji/model/Chengji.php @@ -4,8 +4,7 @@ namespace app\chengji\model; // 引用基类 use app\common\model\Base; -// 引用班级数据模型类 -use app\teach\model\Chengji; + class Chengji extends Base { diff --git a/application/chengji/view/index/kaohao.html b/application/chengji/view/index/kaohao.html index c1a75c47..16a15f48 100644 --- a/application/chengji/view/index/kaohao.html +++ b/application/chengji/view/index/kaohao.html @@ -1,6 +1,27 @@ {extend name="common@create" /} {block name="formaa"} -
+ +
+ +
+ + {php} + $kaoshi = new app\teach\model\Kaoshi; + $kaoshi = $kaoshi + ->where('status',1) + ->where('bfdate','>',time()) + ->field('id,title') + ->all(); + {/php} + + +
+
@@ -28,12 +49,11 @@
-
{/foreach} @@ -85,12 +105,10 @@ }, dataType: 'json', success: function(data){ - myJson = {"name": "phpernote", "password": "1111"}; for (var val in data) { for(var bj in data[val]['banji']) { $('#' + val).append(''; - } } diff --git a/application/renshi/model/Student.php b/application/renshi/model/Student.php index 0eeef3d4..3dddc7b5 100644 --- a/application/renshi/model/Student.php +++ b/application/renshi/model/Student.php @@ -15,7 +15,7 @@ class Student extends Base return getAgeByBirth($this->getdata('shengri'),2); } - // 班级获取器 + // 年级、班级名称获取器 public function getBanjititleAttr() { $bj = Banji::get($this->banji); @@ -48,5 +48,11 @@ class Student extends Base return $sex[$value]; } + // 获取入学年 + public function getNianjiAttr() + { + return db('banji')->where('id',$this->getData('banji'))->value('ruxuenian'); + } + } diff --git a/database/migrations/20181114055804_chengji.php b/database/migrations/20181114055804_chengji.php new file mode 100644 index 00000000..0a8f70c5 --- /dev/null +++ b/database/migrations/20181114055804_chengji.php @@ -0,0 +1,49 @@ +table('chengji'); + + // 添加当前表字段 + $table + ->addColumn('kaoshi','integer',['limit'=>11,'null'=>false,'comment'=>'考试']) + ->addColumn('school','integer',['limit'=>11,'null'=>false,'comment'=>'学校']) + ->addColumn('ruxuenian','integer',['limit'=>4,'null'=>false,'comment'=>'入学年']) + ->addColumn('banji','integer',['limit'=>11,'null'=>false,'comment'=>'班级']) + ->addColumn('student','integer',['limit'=>11,'null'=>false,'comment'=>'学生']) + ->addColumn('yuwen','integer',['limit'=>3,'null'=>false,'comment'=>'语文']) + ->addColumn('shuxue','integer',['limit'=>3,'null'=>false,'comment'=>'数学']) + ->addColumn('yingyu','integer',['limit'=>3,'null'=>false,'comment'=>'英语']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) + ->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常']) + ->addIndex(array('kaoshi','student'), array('unique' => true)) + ->create(); + } +} diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index 755a531b..9147202b 100644 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -42,7 +42,7 @@ class Rule extends Seeder // 成绩采集 ['id'=>51,'title'=>'扫码录入','name'=>'chengji/Index/malu','paixu'=>1,'ismenu' =>true,'pid' =>5,'url'=>'/chengji',], ['id'=>52,'title'=>'表格录入','name'=>'chengji/Student/biaolu','paixu'=>2,'ismenu' =>true,'pid' =>5,'url'=>'/chengji',], - ['id'=>53,'title'=>'生成二维码','name'=>'chengji/Student/erweima','paixu'=>3,'ismenu' =>true,'pid' =>5,'url'=>'/chengji/erweima',], + ['id'=>53,'title'=>'生成考号','name'=>'chengji/Index/kaohao','paixu'=>3,'ismenu' =>true,'pid' =>5,'url'=>'/chengji/kaohao',], // 教务管理 diff --git a/route/chengji.php b/route/chengji.php index 064261dd..409960f5 100644 --- a/route/chengji.php +++ b/route/chengji.php @@ -12,6 +12,7 @@ //系统设置路由 Route::get('chengji/erweima','chengji/Index/erweima'); Route::get('chengji/kaohao','chengji/Index/kaohao'); +Route::post('chengji/kaohao','chengji/Index/kaohaosave');