diff --git a/app/chengji/controller/Luru.php b/app/chengji/controller/Luru.php index 81286639..4c0f3048 100644 --- a/app/chengji/controller/Luru.php +++ b/app/chengji/controller/Luru.php @@ -56,22 +56,21 @@ class Luru extends BaseController { // 获取参数 $src = $this->request - ->only(['page','limit','field','type','kaoshi','school','ruxuenian','paixu','searchval' + ->only([ + 'page' + ,'limit' + ,'field'=>'update_time' + ,'type'=>'desc' + ,'searchval' ],'POST'); - $src['school'] = strToarray($src['school']); - - // 获取参与考试的班级 - $kh = new \app\kaoshi\model\Kaohao; - $src['banji']= array_column($kh->cyBanji($src), 'id'); - - // 实例化 $cj = new Chengji; // 查询要显示的数据 $data = $cj->searchLuru($src); + // 获取符合条件记录总数 $cnt = count($data); // 获取当前页数据 diff --git a/app/chengji/model/Chengji.php b/app/chengji/model/Chengji.php index 69c2cf92..0a1f486c 100644 --- a/app/chengji/model/Chengji.php +++ b/app/chengji/model/Chengji.php @@ -9,11 +9,6 @@ use app\common\model\Base; class Chengji extends Base { - // 成绩和学科关联 - public function cjSubject() - { - return $this->belongsTo('\app\teach\model\Subject'); - } // 学科关联 public function subjectName() @@ -27,6 +22,12 @@ class Chengji extends Base return $this->belongsTo('\app\admin\model\Admin','user_id','id'); } + // 考号关联 + public function cjKaohao() + { + return $this->belongsTo('\app\kaoshi\model\Kaohao','kaohao_id','id'); + } + // 列出已录成绩列表 @@ -40,7 +41,7 @@ class Chengji extends Base 'banji'=>array(), 'subject_id'=>array(), 'searchval'=>array(), - 'user_id'=>session('userid'); + 'user_id'=>session('userid'), ); // 用新值替换初始值 @@ -50,47 +51,36 @@ class Chengji extends Base $kaoshi = $src['kaoshi']; $searchval = $src['searchval']; - // 获取参加考试时间 - $ks = new app\kaoshi\model\Kaoshi; - $enddate = $ks->where('id',$kaoshiid)->value('enddate'); - - $nianji = nianjiList($enddate); - - + $nianji = nianjiList(); $cjList = $this - ->where('user_id'=>$src['user_id']) + ->where('user_id',$src['user_id']) ->when(count($subject_id)>0,function($query)use($subject_id){ $query->where('subjectid','in',$subject_id); }) - ->where('kaohao_id','in',function($query)use($banji,$kaoshi,$searchval,$nianji){ - $query->name('kaohao') - ->where('kaoshi',$kaoshi) - ->where(count($banji)>0,function($q)use($banji){ - $q->where('banji','in',$banji); - }) - ->when(strlen($searchval>0),function($w)use($searchval,$nianji){ - $w->name('student') - ->where('banji','in',function($x)use($nianji){ - $x->name('banji') - ->where('ruxuenian','in',$nianji) - ->field('id'); - }) - ->where('xingminng','like','%'.$searchval.'%') - ->field('id'); - }); - }) - ->select(); - halt($cjList->toArray()); - - - return true; - - - - - + ->with([ + 'subjectName'=>function($query){ + $query->field('id,title,lieming'); + } + ,'cjKaohao'=>function($query){ + $query->field('id,kaoshi,school,ruxuenian,nianji,banji,paixu,student') + ->append(['banjiTitle']) + ->with([ + 'cjSchool'=>function($query){ + $query->field('id,jiancheng,paixu'); + } + ,'cjStudent'=>function($query){ + $query->field('id,xingming,sex'); + } + ]); + } + ]) + ->order([$src['field']=>$src['type']]) + ->limit(200) + ->select() + ->toArray(); + return $cjList; } diff --git a/app/chengji/view/index/index.html b/app/chengji/view/index/index.html index 2c73665d..bba25d6d 100644 --- a/app/chengji/view/index/index.html +++ b/app/chengji/view/index/index.html @@ -174,7 +174,7 @@ // 修改服务器数据 $.ajax({ - url:"/chengji/index/update/"+rowdata.id, + url:"/chengji/luru/update/"+rowdata.id, type:'PUT', data:{ "colname":colname, diff --git a/app/chengji/view/luru/index.html b/app/chengji/view/luru/index.html index 1fc391d5..c20e53f0 100644 --- a/app/chengji/view/luru/index.html +++ b/app/chengji/view/luru/index.html @@ -65,69 +65,114 @@ {/block} \ No newline at end of file diff --git a/app/kaoshi/model/Kaohao.php b/app/kaoshi/model/Kaohao.php index f28de4e2..eb960575 100644 --- a/app/kaoshi/model/Kaohao.php +++ b/app/kaoshi/model/Kaohao.php @@ -104,7 +104,7 @@ class Kaohao extends Base // 查询成绩 $khlist = $this->where('kaoshi',$src['kaoshi']) - ->field('id,school,student,ruxuenian,paixu,kaoshi') + ->field('id,school,student,ruxuenian,paixu,kaoshi,nianji') ->when(count($school)>0,function($query) use($school){ $query->where('school','in',$school); }) @@ -410,22 +410,20 @@ class Kaohao extends Base */ public function getBanjiTitleAttr() { - $ks = $this->where('id',$this->id) - ->with([ - 'cjKaoshi'=>function($query){ - $query->field('id,bfdate'); - } - ]) - ->find(); - $bfdate = $ks->cjKaoshi->getData('bfdate'); + // $ks = $this->where('id',$this->id) + // ->with([ + // 'cjKaoshi'=>function($query){ + // $query->field('id,bfdate'); + // } + // ]) + // ->find(); + // $bfdate = $ks->cjKaoshi->getData('bfdate'); - $nj = nianjiList($bfdate); + // $nj = nianjiList($bfdate); $bj = banjinamelist(); - - - $title = $nj[$this->getAttr('ruxuenian')] . $bj[$this->getAttr('paixu')]; - + // $title = $nj[$this->getAttr('nianji')] . $bj[$this->getAttr('paixu')]; + $title = $this->getAttr('nianji') . $bj[$this->getAttr('paixu')]; return $title; }