From d64fa93aacc7daf8be7e4bff02d8c0b76c5dbfee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Tue, 30 Apr 2019 15:43:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E8=AF=95=E9=87=8D=E6=96=B0=E6=95=B4?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/chengji/controller/Index.php | 38 ++-- application/chengji/model/Chengji.php | 129 +++++------ application/common/view/create.html | 29 ++- application/kaoshi/controller/Index.php | 17 +- .../controller/{MoreAction.php => Kaohao.php} | 209 +++++++++++------- application/kaoshi/model/Kaohao.php | 83 +++++++ application/kaoshi/model/Kaoshi.php | 40 +--- .../index.html => index/more_action.html} | 0 .../{more_action => kaohao}/biaoqian.html | 0 .../view/{more_action => kaohao}/caiji.1html | 0 .../view/{more_action => kaohao}/caiji.html | 0 .../kaohao.html => kaohao/index.html} | 3 + application/teach/controller/Banji.php | 2 + ..._chengji.php => 20181114055804_kaohao.php} | 4 +- .../migrations/20190430034853_chengji.php | 47 ++++ route/kaoshi.php | 15 +- 16 files changed, 371 insertions(+), 245 deletions(-) rename application/kaoshi/controller/{MoreAction.php => Kaohao.php} (67%) create mode 100644 application/kaoshi/model/Kaohao.php rename application/kaoshi/view/{more_action/index.html => index/more_action.html} (100%) rename application/kaoshi/view/{more_action => kaohao}/biaoqian.html (100%) rename application/kaoshi/view/{more_action => kaohao}/caiji.1html (100%) rename application/kaoshi/view/{more_action => kaohao}/caiji.html (100%) rename application/kaoshi/view/{more_action/kaohao.html => kaohao/index.html} (97%) rename database/migrations/{20181114055804_chengji.php => 20181114055804_kaohao.php} (96%) create mode 100644 database/migrations/20190430034853_chengji.php diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 7e8152d5..24ea1ac7 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -3,18 +3,11 @@ namespace app\chengji\controller; // 引用控制器基类 use app\common\controller\Base; -// 引用学生数据模型 -// use app\renshi\model\Student; // 引用成绩数据模型 use app\chengji\model\Chengji; -// 引用学科数据模型 -// use app\teach\model\Subject; -// 引用文件信息存储数据模型类 -// use app\system\model\Fields; -// 引用phpspreadsheet类 -use app\renshi\controller\Myexcel; -// 引用考试类 -// use app\kaoshi\model\Kaoshi; +// 引用考号数据模型 +use app\kaoshi\model\Kaohao; + class Index extends Base { @@ -88,27 +81,26 @@ class Index extends Base $val = input('post.val'); $val = action('system/Encrypt/decrypt',[$val,'key'=>'dlbz']); $list = explode('|',$val); + $sbj = $list[1]; - $cj = new Chengji; - $cjlist = $cj->where('id',$list[0]) - ->field('id,banji,school,student,'.$list[1]) + $kh = new Kaohao; + $cjlist = $kh->where('id',$list[0]) + ->field('id,banji,school,student') ->with([ - 'cjBanji'=>function($q){ - $q->field('id,paixu,ruxuenian')->append(['banjiTitle']); - } - ,'cjStudent'=>function($q){ - $q->field('id,xingming'); - } - ,'cjSchool'=>function($q){ - $q->field('id,jiancheng'); + 'ksChengji'=>function($q) use($sbj){ + $q->where('stubject_id',$sbj) + ->field('id,kaohao_id,stubject_id,student_id,user_id'); } ]) ->find(); + + // 获取列名 $sbj = new \app\teach\model\Subject; $cjlist->lieming = $sbj::where('lieming',$list[1])->value('title'); - $cjlist->zd = $list[1]; - $cjlist->defen = $cjlist[$list[1]]; + + + halt($cjlist); return json($cjlist); } diff --git a/application/chengji/model/Chengji.php b/application/chengji/model/Chengji.php index 0c458e51..b6e70abf 100644 --- a/application/chengji/model/Chengji.php +++ b/application/chengji/model/Chengji.php @@ -11,8 +11,8 @@ class Chengji extends Base // 定义更新成绩后计算平均分和总分 - protected static function init() - { + // protected static function init() + // { // self::afterUpdate(function ($cj) { // $cj =self::where('id',$cj->id)->find(); // // 重新组合数组 @@ -41,42 +41,15 @@ class Chengji extends Base // $cj->save(); // }); - } + // } + - // 学校信息关联表 - public function cjSchool() - { - return $this->belongsTo('\app\system\model\School','school','id'); - } - - // 班级信息关联表 - public function cjBanji() - { - return $this->belongsTo('\app\teach\model\Banji','banji','id'); - } - - // 学生信息关联 - public function cjStudent() - { - return $this->belongsTo('\app\renshi\model\Student','student','id'); - } - - // 满分 - public function cjManfen() - { - return $this->hasMany('\app\kaoshi\model\KaoshiSubject','kaoshiid','kaoshi'); - } - - // 考试关联 - public function cjKaoshi() - { - return $this->belongsTo('\app\kaoshi\model\Kaoshi','kaoshi','id'); - } + @@ -94,61 +67,61 @@ class Chengji extends Base // 查询根据考试ID查询考试成绩 - public function searchAjax($search) - { - // 获取参数 - $kaoshiid = $search['kaoshiid']; - $schoolid = $search['school']; - $nianji = $search['nianji']; - $banji = $search['banji']; - $order = $search['order']; - $order_field = $search['order_field']; - $search = $search['search']; + // public function searchAjax($search) + // { + // // 获取参数 + // $kaoshiid = $search['kaoshiid']; + // $schoolid = $search['school']; + // $nianji = $search['nianji']; + // $banji = $search['banji']; + // $order = $search['order']; + // $order_field = $search['order_field']; + // $search = $search['search']; - $data = $this->where('kaoshi',$kaoshiid) - ->when(count($schoolid)>0,function($query) use($schoolid){ - $query->where('school','in',$schoolid); - }) - ->when(count($nianji)>0,function($query) use($nianji){ - $query->where('nianji','in',$nianji); - }) - ->when(count($banji)>0,function($query) use($banji){ - $query->where('banji','in',$banji); - }) - // ->when(strlen($search)>0 && is_numeric($search), function ($query) use($search){ - // // 满足条件后执行 - // $query->where('yuwen|shuxue|waiyu',$search); - // }) - ->when(strlen($search)>0 && !is_numeric($search),function($query) use($search){ - $query->where('student','in',function ($q) use($search){ - $q->name('student') - ->where('xingming','like','%'.$search.'%') - ->field('id'); - }); - }) - ->order([$order_field=>$order]) - ->select(); + // $data = $this->where('kaoshi',$kaoshiid) + // ->when(count($schoolid)>0,function($query) use($schoolid){ + // $query->where('school','in',$schoolid); + // }) + // ->when(count($nianji)>0,function($query) use($nianji){ + // $query->where('nianji','in',$nianji); + // }) + // ->when(count($banji)>0,function($query) use($banji){ + // $query->where('banji','in',$banji); + // }) + // // ->when(strlen($search)>0 && is_numeric($search), function ($query) use($search){ + // // // 满足条件后执行 + // // $query->where('yuwen|shuxue|waiyu',$search); + // // }) + // ->when(strlen($search)>0 && !is_numeric($search),function($query) use($search){ + // $query->where('student','in',function ($q) use($search){ + // $q->name('student') + // ->where('xingming','like','%'.$search.'%') + // ->field('id'); + // }); + // }) + // ->order([$order_field=>$order]) + // ->select(); - // $data = $data->append(['cj_school.jiancheng','cj_banji.title','cj_student.xingming']); + // // $data = $data->append(['cj_school.jiancheng','cj_banji.title','cj_student.xingming']); - return $data; - } + // return $data; + // } - // 根据成绩ID查询单条成绩 - public function srcOne($id) - { - $data = $this->where('id',$id) - ->with([ - 'cjManfen' - ]) - ->find(); + // // 根据成绩ID查询单条成绩 + // public function srcOne($id) + // { + // $data = $this->where('id',$id) + // ->with([ + // 'cjManfen' + // ]) + // ->find(); - return $data; - } + // return $data; + // } diff --git a/application/common/view/create.html b/application/common/view/create.html index f70a1d49..1b144ba0 100644 --- a/application/common/view/create.html +++ b/application/common/view/create.html @@ -43,25 +43,22 @@ success:function(result){ val = result.val + // 弹出提示 layer.msg(result.msg, - { - icon:1, - time:2000, - }, - function(){ - // 关闭窗口 - if(val == 1) - { - //先得到当前iframe层的索引 - var index = parent.layer.getFrameIndex(window.name); - //再执行关闭 - parent.layui.table.reload('mytable'); - parent.layer.close(index); - } + { + icon:1, + time:2000, + },function(){ + if(val == 1) + { + //先得到当前iframe层的索引 + var index = parent.layer.getFrameIndex(window.name); + //再执行关闭 + parent.layui.table.reload('mytable'); + parent.layer.close(index); + } }); - - }, error:function(xhr,status,error) { layer.msg('数据处理错误',{ diff --git a/application/kaoshi/controller/Index.php b/application/kaoshi/controller/Index.php index ead5bd13..08af966b 100644 --- a/application/kaoshi/controller/Index.php +++ b/application/kaoshi/controller/Index.php @@ -365,8 +365,21 @@ class Index extends Base } + // 考试更多操作页面 + public function moreAction($kaoshi) + { + // 获取考试信息 + $kaoshi = KS::where('id',$kaoshi) + ->field('id,title,bfdate,enddate') + ->find(); + // 设置页面标题 + $list['webtitle'] = $kaoshi['title'] .'('. $kaoshi['bfdate'].'~'.$kaoshi['enddate'].')'; + $list['kaoshiid'] = $kaoshi['id']; - - + // 模板赋值 + $this->assign('list',$list); + // 渲染 + return $this->fetch(); + } } diff --git a/application/kaoshi/controller/MoreAction.php b/application/kaoshi/controller/Kaohao.php similarity index 67% rename from application/kaoshi/controller/MoreAction.php rename to application/kaoshi/controller/Kaohao.php index e792b84f..3c71054c 100644 --- a/application/kaoshi/controller/MoreAction.php +++ b/application/kaoshi/controller/Kaohao.php @@ -6,37 +6,19 @@ namespace app\kaoshi\controller; use app\common\controller\Base; // 引用考试数据模型类 use app\kaoshi\model\Kaoshi as KS; -// 引用学生类 -use app\renshi\model\Student; +// 引用考号数据模型类 +use app\kaoshi\model\Kaohao as KH; + // 引用成绩类 use PhpOffice\PhpSpreadsheet\Spreadsheet; // 引用二维码生成类 use \Endroid\QrCode\QrCode; -class MoreAction extends Base +class Kaohao extends Base { - // 考试更多操作页面 - public function index($id) - { - // 获取考试信息 - $kaoshi = KS::where('id',$id) - ->field('id,title,bfdate,enddate') - ->find(); - - // 设置页面标题 - $list['webtitle'] = $kaoshi['title'] .'('. $kaoshi['bfdate'].'~'.$kaoshi['enddate'].')'; - $list['kaoshiid'] = $kaoshi['id']; - - // 模板赋值 - $this->assign('list',$list); - // 渲染 - return $this->fetch(); - } - - // 生成考号 - public function kaohao($kaoshi) + public function index($kaoshi) { // 获取参考年级 @@ -45,10 +27,16 @@ class MoreAction extends Base 'ksNianji' ]) ->find(); - foreach ($kaoshilist->ks_nianji as $key => $value) { - $list['data']['nianji'][$key]['id']=$value->nianji; - $list['data']['nianji'][$key]['title']=$value->nianjiname; + if(count($kaoshilist->ks_nianji)>0) + { + foreach ($kaoshilist->ks_nianji as $key => $value) { + $list['data']['nianji'][$key]['id']=$value->nianji; + $list['data']['nianji'][$key]['title']=$value->nianjiname; + } + }else{ + $list['data']['nianji']= array(); } + // 设置页面标题 @@ -68,7 +56,7 @@ class MoreAction extends Base } // 保存考号 - public function kaohaosave() + public function save() { // 实例化验证模型 $validate = new \app\kaoshi\validate\Kaohao; @@ -90,8 +78,10 @@ class MoreAction extends Base $list['banjiids'] = implode(',',$list['banjiids']); $ksid = $list['kaoshi']; + // 获取实例化学生数据模型 + $stu = new \app\renshi\model\Student; // 获取参加考试学生名单 - $stulist = Student::where('school',$list['school']) + $stulist = $stu::where('school',$list['school']) ->where('banji','in',$list['banjiids']) ->where('status',1) ->field('id,school,banji') @@ -114,9 +104,9 @@ class MoreAction extends Base } // 保存考号 - $cj = new \app\chengji\model\Chengji; + $kh = new \app\kaoshi\model\Kaohao; - $data = $cj + $data = $kh ->allowField(['id','kaoshi','student','school','ruxuenian','nianji','banji','create_time','update_time']) ->saveAll($kaohao); @@ -245,21 +235,35 @@ class MoreAction extends Base ->with([ 'ksNianji' ,'ksSubject'=>function($query){ - $query->field('id,subjectid,kaoshiid') - ->with(['subjectName'=>function($q){ - $q->field('id,title'); - }] - ); - } + $query->field('id,subjectid,kaoshiid') + ->with(['subjectName'=>function($q){ + $q->field('id,title'); + }] + ); + } ]) ->find(); - foreach ($kaoshilist->ks_nianji as $key => $value) { - $list['data']['nianji'][$key]['id']=$value->nianji; - $list['data']['nianji'][$key]['title']=$value->nianjiname; + + + // 获取考试年级 + if(count($kaoshilist->ks_nianji)>0) + { + foreach ($kaoshilist->ks_nianji as $key => $value) { + $list['data']['nianji'][$key]['id']=$value->nianji; + $list['data']['nianji'][$key]['title']=$value->nianjiname; + } + }else{ + $list['data']['nianji']= array(); } - foreach ($kaoshilist->ks_subject as $key => $value) { - $list['data']['subject'][$key]['id']=$value->subjectid; - $list['data']['subject'][$key]['title']=$value->subject_name->title; + // 获取考试学科 + if(count($kaoshilist->ks_subject)>0) + { + foreach ($kaoshilist->ks_subject as $key => $value) { + $list['data']['subject'][$key]['id']=$value->subjectid; + $list['data']['subject'][$key]['title']=$value->subject_name->title; + } + }else{ + $list['data']['nianji']= array(); } @@ -272,7 +276,6 @@ class MoreAction extends Base 'kaoshi'=>$kaoshi ); - // 模板赋值 $this->assign('list',$list); // 渲染 @@ -305,8 +308,24 @@ class MoreAction extends Base } $ks = new KS(); + $kslist = $ks::where('id',$kaoshi) + ->field('id,title') + ->with([ + 'ksSubject'=>function($query) use($subject){ + $query->where('subjectid','in',$subject) + ->field('kaoshiid,subjectid') + ->with(['subjectName'=>function($q){ + $q->field('id,jiancheng,lieming'); + }] + ); + } + ]) + ->find(); + + $kh = new KH(); // 获取考试信息 - $chengjiinfo = $ks->srcChengji($kaoshi,$subject,$banji); + $kaohao = $kh->srcKaohao($kaoshi,$banji); + // 创建表格 $spreadsheet = new Spreadsheet(); @@ -320,24 +339,30 @@ class MoreAction extends Base $sheet->setCellValue('E1', '学科'); $sheet->setCellValue('F1', '姓名'); + // 循环写出信息 $i = 2; - foreach ($chengjiinfo->ks_subject as $key => $sbj) { - foreach ($chengjiinfo->ks_chengji as $xkkey => $cj) { - // 表格赋值 - $sheet->setCellValue('A'.$i, $i-1); - $sheet->setCellValue('B'.$i, action('system/Encrypt/encrypt',['data'=>$cj->id.'|'.$sbj->lieming,'key'=>'dlbz'])); - $sheet->setCellValue('C'.$i, $cj->cj_school->jiancheng); - $sheet->setCellValue('D'.$i, $cj->cj_banji->numTitle); - $sheet->setCellValue('E'.$i, $sbj->subject_name->title); - $sheet->setCellValue('F'.$i, $cj->cj_student->xingming); - $i++; + foreach ($kaohao as $key=>$bj) + { + foreach ($kslist->ks_subject as $ksbj => $sbj) + { + foreach ($bj->banji_kaohao as $kkh => $kh) + { + // 表格赋值 + $sheet->setCellValue('A'.$i, $i-1); + $sheet->setCellValue('B'.$i, action('system/Encrypt/encrypt',['data'=>$kh->id.'|'.$sbj->subject_name->id,'key'=>'dlbz'])); + $sheet->setCellValue('C'.$i, $bj->cj_school->jiancheng); + $sheet->setCellValue('D'.$i, $bj->cj_banji->numTitle); + $sheet->setCellValue('E'.$i, $sbj->subject_name->jiancheng); + $sheet->setCellValue('F'.$i, $kh->cj_student->xingming); + $i++; + } } } - // 保存文件 - $filename = $chengjiinfo['title'].date('ymdHis').'.xls'; + // $filename = $kslist->title.' 标签数据'.date('ymdHis').'.xls'; + $filename = 'aa.xls'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0'); @@ -366,16 +391,27 @@ class MoreAction extends Base } ]) ->find(); - foreach ($kaoshilist->ks_nianji as $key => $value) { - $list['data']['nianji'][$key]['id']=$value->nianji; - $list['data']['nianji'][$key]['title']=$value->nianjiname; + // 获取考试年级 + if(count($kaoshilist->ks_nianji)>0) + { + foreach ($kaoshilist->ks_nianji as $key => $value) { + $list['data']['nianji'][$key]['id']=$value->nianji; + $list['data']['nianji'][$key]['title']=$value->nianjiname; + } + }else{ + $list['data']['nianji']= array(); } - foreach ($kaoshilist->ks_subject as $key => $value) { - $list['data']['subject'][$key]['id']=$value->subjectid; - $list['data']['subject'][$key]['title']=$value->subject_name->title; + // 获取考试学科 + if(count($kaoshilist->ks_subject)>0) + { + foreach ($kaoshilist->ks_subject as $key => $value) { + $list['data']['subject'][$key]['id']=$value->subjectid; + $list['data']['subject'][$key]['title']=$value->subject_name->title; + } + }else{ + $list['data']['nianji']= array(); } - // 设置页面标题 $list['set'] = array( 'webtitle'=>'下载成绩采集表', @@ -385,7 +421,6 @@ class MoreAction extends Base 'kaoshi'=>$kaoshi ); - // 模板赋值 $this->assign('list',$list); // 渲染 @@ -420,8 +455,24 @@ class MoreAction extends Base } $ks = new KS(); + $kslist = $ks::where('id',$kaoshi) + ->field('id,title') + ->with([ + 'ksSubject'=>function($query) use($subject){ + $query->where('subjectid','in',$subject) + ->field('kaoshiid,subjectid') + ->with(['subjectName'=>function($q){ + $q->field('id,title,lieming'); + }] + ); + } + ]) + ->find(); + + $kh = new KH(); // 获取考试信息 - $chengjiinfo = $ks->srcChengji($kaoshi,$subject,$banji); + $kaohao = $kh->srcKaohao($kaoshi,$banji); + // 获取电子表格列名 $lieming = excelLieming(); @@ -431,21 +482,21 @@ class MoreAction extends Base $sheet = $spreadsheet->getActiveSheet(); // 设置表格标题与表头信息 - $sheet->setCellValue('A1',$chengjiinfo->title.' 成绩采集表'); + $sheet->setCellValue('A1',$kslist->title.' 成绩采集表'); $sheet->setCellValue('A3', '序号'); $sheet->setCellValue('B3', '考号'); $sheet->setCellValue('C3', '班级'); $sheet->setCellValue('D3', '姓名'); // 获取列数并合并和一行 - $col = $lieming[count($chengjiinfo->ks_subject)+3]; + $col = $lieming[count($kslist->ks_subject)+3]; $sheet->mergeCells('A1:'.$col.'1'); - // 写入列名 - foreach ($chengjiinfo->ks_subject as $key => $value) { - $sheet->setCellValue($lieming[$key + 4].'3', $value->subject_name['title']); - $sheet->setCellValue($lieming[$key + 4].'2', $value->lieming); + // 写入列名 + foreach ($kslist->ks_subject as $key => $value) { + $sheet->setCellValue($lieming[$key + 4].'3', $value->subject_name->title); + $sheet->setCellValue($lieming[$key + 4].'2', $value->subject_name->lieming); } // 隐藏第二行和第二列 $sheet->getRowDimension('2')->setRowHeight('0'); @@ -454,18 +505,20 @@ class MoreAction extends Base // 将学生信息循环写入表中 $i = 4; - foreach ($chengjiinfo->ks_chengji as $key=>$value) + foreach ($kaohao as $key=>$bj) { - $sheet->setCellValue('A'.$i, $i-3); - $sheet->setCellValue('B'.$i, $value['id']); - $sheet->setCellValue('C'.$i, '\''.$value['banjiNumname']); - $sheet->setCellValue('D'.$i, $value['cj_student']['xingming']); - $i++; + foreach ($bj->banji_kaohao as $k => $kh) { + $sheet->setCellValue('A'.$i, $i-3); + $sheet->setCellValue('B'.$i, $kh->id); + $sheet->setCellValue('C'.$i, $bj->cj_banji->banjiTitle); + $sheet->setCellValue('D'.$i, $kh->cj_student->xingming); + $i++; + } } // 保存文件 - $filename = $chengjiinfo->title.'成绩采集表'.date('ymdHis').'.xls'; + $filename = $kslist->title.'成绩采集表'.date('ymdHis').'.xls'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0'); diff --git a/application/kaoshi/model/Kaohao.php b/application/kaoshi/model/Kaohao.php new file mode 100644 index 00000000..2f032e75 --- /dev/null +++ b/application/kaoshi/model/Kaohao.php @@ -0,0 +1,83 @@ +where('kaoshi',$kaoshi) + ->where('banji','in',$banji) + ->field('id,banji,school') + ->order(['banji']) + ->group('banji') + ->with([ + 'cjBanji'=>function($q){ + $q->field('id,paixu,ruxuenian') + ->append(['numTitle','banjiTitle']); + } + ,'cjSchool'=>function($q){ + $q->field('id,jiancheng'); + } + ,'banjiKaohao'=>function($q){ + $q->field('id,banji,student,kaoshi,school') + ->order(['banji','id']) + ->with([ + 'cjStudent'=>function($qsm){ + $qsm->field('id,xingming'); + } + ]); + } + ]) + ->select(); + return $data; + } + + // 满分 + public function banjiKaohao() + { + return $this->hasMany('\app\kaoshi\model\Kaohao','banji','banji'); + } + + // 学校信息关联表 + public function cjSchool() + { + return $this->belongsTo('\app\system\model\School','school','id'); + } + + // 班级信息关联表 + public function cjBanji() + { + return $this->belongsTo('\app\teach\model\Banji','banji','id'); + } + + // 学生信息关联 + public function cjStudent() + { + return $this->belongsTo('\app\renshi\model\Student','student','id'); + } + + // 满分 + public function cjManfen() + { + return $this->hasMany('\app\kaoshi\model\KaoshiSubject','kaoshiid','kaoshi'); + } + + // 考试关联 + public function cjKaoshi() + { + return $this->belongsTo('\app\kaoshi\model\Kaoshi','kaoshi','id'); + } + + + // 考试成绩 + public function ksChengji() + { + return $this->hasMany('\app\chengji\model\Chengji','kaohao_id','id'); + } +} diff --git a/application/kaoshi/model/Kaoshi.php b/application/kaoshi/model/Kaoshi.php index 5985a8cd..47dad9e2 100644 --- a/application/kaoshi/model/Kaoshi.php +++ b/application/kaoshi/model/Kaoshi.php @@ -42,45 +42,7 @@ class Kaoshi extends Base ->select(); return $data; } - - - //查询考试成绩 - public function srcChengji($kaoshi,$subject,$banji) - { - // 获取考试信息 - $data = $this->where('id',$kaoshi) - ->field('id,title') - ->with([ - 'ksSubject'=>function($query)use($subject){ - $query->field('kaoshiid,subjectid') - ->where('subjectid','in',$subject) - ->field('kaoshiid,subjectid,lieming') - ->with([ - 'subjectName'=>function($q){ - $q->field('id,title'); - } - ]); - } - ,'ksChengji'=>function($query) use($banji){ - $query->where('banji','in',$banji) - ->field('id,banji,student,kaoshi,school') - ->order(['banji','student']) - ->with([ - 'cjBanji'=>function($q){ - $q->field('id,paixu,ruxuenian')->append(['numTitle']); - } - ,'cjStudent'=>function($q){ - $q->field('id,xingming'); - } - ,'cjSchool'=>function($q){ - $q->field('id,jiancheng'); - } - ]); - } - ]) - ->find(); - return $data; - } + // 开始时间修改器 diff --git a/application/kaoshi/view/more_action/index.html b/application/kaoshi/view/index/more_action.html similarity index 100% rename from application/kaoshi/view/more_action/index.html rename to application/kaoshi/view/index/more_action.html diff --git a/application/kaoshi/view/more_action/biaoqian.html b/application/kaoshi/view/kaohao/biaoqian.html similarity index 100% rename from application/kaoshi/view/more_action/biaoqian.html rename to application/kaoshi/view/kaohao/biaoqian.html diff --git a/application/kaoshi/view/more_action/caiji.1html b/application/kaoshi/view/kaohao/caiji.1html similarity index 100% rename from application/kaoshi/view/more_action/caiji.1html rename to application/kaoshi/view/kaohao/caiji.1html diff --git a/application/kaoshi/view/more_action/caiji.html b/application/kaoshi/view/kaohao/caiji.html similarity index 100% rename from application/kaoshi/view/more_action/caiji.html rename to application/kaoshi/view/kaohao/caiji.html diff --git a/application/kaoshi/view/more_action/kaohao.html b/application/kaoshi/view/kaohao/index.html similarity index 97% rename from application/kaoshi/view/more_action/kaohao.html rename to application/kaoshi/view/kaohao/index.html index 9d66dae2..d120c787 100644 --- a/application/kaoshi/view/more_action/kaohao.html +++ b/application/kaoshi/view/kaohao/index.html @@ -35,6 +35,9 @@ } {/php} {/volist} + {php} + if(empty($nianji)){ $nianji=''; } + {/php}
diff --git a/application/teach/controller/Banji.php b/application/teach/controller/Banji.php index 91421ac5..d53a8e23 100644 --- a/application/teach/controller/Banji.php +++ b/application/teach/controller/Banji.php @@ -299,6 +299,7 @@ class Banji extends Base ->where('ruxuenian','in',$ruxuenian) ->order('paixu') ->field('id,ruxuenian,paixu') + ->where('status',1) ->append(['banTitle']) ->select(); @@ -321,6 +322,7 @@ class Banji extends Base ->where('ruxuenian','in',$ruxuenian) ->group('ruxuenian') ->field('id,ruxuenian') + ->where('status',1) ->with([ 'njBanji'=>function($query)use($school){ $query->where('status',1) diff --git a/database/migrations/20181114055804_chengji.php b/database/migrations/20181114055804_kaohao.php similarity index 96% rename from database/migrations/20181114055804_chengji.php rename to database/migrations/20181114055804_kaohao.php index f90881ce..2301ed59 100644 --- a/database/migrations/20181114055804_chengji.php +++ b/database/migrations/20181114055804_kaohao.php @@ -3,7 +3,7 @@ use think\migration\Migrator; use think\migration\db\Column; -class Chengji extends Migrator +class Kaohao extends Migrator { /** * Change Method. @@ -29,7 +29,7 @@ class Chengji extends Migrator public function change() { // 定义数据表名称 - $table = $this->table('chengji'); + $table = $this->table('kaohao'); // 添加当前表字段 $table diff --git a/database/migrations/20190430034853_chengji.php b/database/migrations/20190430034853_chengji.php new file mode 100644 index 00000000..4655b5d9 --- /dev/null +++ b/database/migrations/20190430034853_chengji.php @@ -0,0 +1,47 @@ +table('chengji'); + + // 添加当前表字段 + $table + ->addColumn('kaohao_id','integer',['limit'=>11,'null'=>false,'comment'=>'考试']) + ->addColumn('student_id','integer',['limit'=>11,'null'=>false,'comment'=>'学校']) + ->addColumn('stubject_id','integer',['limit'=>4,'null'=>false,'comment'=>'入学年']) + ->addColumn('user_id','string',['limit'=>4,'null'=>false,'comment'=>'年级']) + ->addColumn('create_time','integer',['limit'=>11,'null'=>true,'comment'=>'创建时间']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) + ->addColumn('update_time','integer',['limit'=>11,'null'=>true,'comment'=>'更新时间']) + ->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常']) + ->addIndex(array('kaohao_id','stubject_id'), array('unique' => true)) + ->create(); + } +} diff --git a/route/kaoshi.php b/route/kaoshi.php index 0274a300..a9737d88 100644 --- a/route/kaoshi.php +++ b/route/kaoshi.php @@ -11,19 +11,20 @@ //系统设置路由 Route::resource('kaoshi','kaoshi/Index'); -Route::get('kaoshi/:id/more','kaoshi/MoreAction/index'); +// 考试更多操作 +Route::get('kaoshi/:kaoshi/more','kaoshi/Index/moreAction'); // 考试设置保存 Route::get('kaoshiset/:id','kaoshi/Index/kaoshiset'); Route::put('kaoshiset/:id','kaoshi/Index/updateset'); // 考号保存 -Route::get('kaoshi/:kaoshi/kaohao','kaoshi/MoreAction/kaohao'); -Route::post('kaoshi/kaohao','kaoshi/MoreAction/kaohaosave'); +Route::get('kaoshi/:kaoshi/kaohao','kaoshi/Kaohao/index'); +Route::post('kaoshi/kaohao','kaoshi/Kaohao/save'); // 下载成绩采集表 -Route::get('kaoshi/:kaoshi/caiji','kaoshi/MoreAction/caiji'); -Route::post('kaoshi/caiji','kaoshi/MoreAction/dwcaiji'); +Route::get('kaoshi/:kaoshi/caiji','kaoshi/Kaohao/caiji'); +Route::post('kaoshi/caiji','kaoshi/Kaohao/dwcaiji'); // 下载试卷标签 -Route::get('kaoshi/:kaoshi/biaoqian','kaoshi/MoreAction/biaoqian'); -Route::post('kaoshi/:kaoshi/biaoqianXls','kaoshi/MoreAction/biaoqianXls'); +Route::get('kaoshi/:kaoshi/biaoqian','kaoshi/Kaohao/biaoqian'); +Route::post('kaoshi/:kaoshi/biaoqianXls','kaoshi/Kaohao/biaoqianXls');