diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 23a2026d..feed0efa 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -164,8 +164,11 @@ class Index extends Base // 成绩列表 public function Chengjilist($id) { - // 设置数据总数 - $list['count'] = Chengji::where('kaoshi',$id)->count(); + // 实例化成绩数据模型 + $cj = new Chengji(); + + // 查询成绩数量 + $list['count'] = $cj->searchAll($id)->count(); // 设置页面标题 $list['title'] = '成绩列表'; $list['kaoshi'] = $id; @@ -184,59 +187,22 @@ class Index extends Base // 获取DT的传值 $getdt = request()->param(); - //得到排序的方式 - $order = $getdt['order'][0]['dir']; - //得到排序字段的下标 - $order_column = $getdt['order'][0]['column']; - //根据排序字段的下标得到排序字段 - $order_field = $getdt['columns'][$order_column]['data']; - //得到limit参数 - $limit_start = $getdt['start']; - $limit_length = $getdt['length']; - //得到搜索的关键词 - $search = $getdt['search']['value']; + // 实例化成绩数据模型 + $cj = new Chengji(); + // 查询成绩数量 + $cnt = $cj->searchAll($getdt['kaoshi'])->count(); - // 获取记录集总数 - $cnt = Chengji::where('kaoshi',$getdt['kaoshi'])->count(); - //查询数据 - $data =Chengji::field('id,kaoshi,school,banji,student,nianji,yuwen,shuxue,waiyu,stuSum,stuAvg,status') - ->where('kaoshi',$getdt['kaoshi']) - ->append(['cj_school.jiancheng','cj_banji.title','cj_student.xingming']) - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->select(); - - - // 如果需要查询 - if($search){ - $data =Chengji::where('kaoshi',$getdt['kaoshi']) - ->where(function ($query) use($search){ - $query->whereOr('student','in',function ($query) use($search){ - $query->name('student')->where('xingming','like','%'.$search.'%')->field('id'); - }) - ->whereOr('school','in',function ($query) use($search){ - $query->name('school')->where('title|jiancheng','like','%'.$search.'%')->field('id'); - }); - }) - - ->append(['cj_school.jiancheng','cj_banji.title','cj_student.xingming']) - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->select(); - } - // $data = $data->visible(['cj_school.jiancheng','cj_banji.title']); - + // 分页查询成绩 + $data = $cj->searchAjax($getdt['kaoshi'],$getdt); + // 获取分页成绩数量 $datacnt = $data->count(); - // $data = $data->append(['stuAvg','stuSum']); - - - + // 重组返回内容 $data = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'draw'=> $getdt["draw"] + 1 , // ajax请求次数,作为标识符 + 'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量) + 'recordsFiltered'=>$datacnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; diff --git a/application/chengji/model/Chengji.php b/application/chengji/model/Chengji.php index 42128a16..ca723817 100644 --- a/application/chengji/model/Chengji.php +++ b/application/chengji/model/Chengji.php @@ -118,5 +118,70 @@ class Chengji extends Base return $val; } + + // 查询根据考试ID查询考试成绩 + public function searchAjax($kaoshiid,$getdt) + { + //得到排序的方式 + $order = $getdt['order'][0]['dir']; + //得到排序字段的下标 + $order_column = $getdt['order'][0]['column']; + //根据排序字段的下标得到排序字段 + $order_field = $getdt['columns'][$order_column]['data']; + //得到limit参数 + $limit_start = $getdt['start']; + $limit_length = $getdt['length']; + //得到搜索的关键词 + $search = $getdt['search']['value']; + $school = $getdt['school']; + $nianji = $getdt['nianji']; + + if(trim($search)!='' || $school!='' || $nianji!='') + { + $data = $this->scope('kaoshi',$kaoshiid) + ->where(function ($query) use($search){ + $query->whereOr('student','in',function ($query) use($search){ + $query->name('student')->where('xingming','like','%'.$search.'%')->field('id'); + }) + ->whereOr('school','in',function ($query) use($search){ + $query->name('school')->where('title|jiancheng','like','%'.$search.'%')->field('id'); + }); + }) + ->when($school!='',function($query) use($school){ + $query->where('school','in',$school); + }) + ->when($nianji!='',function($query) use($nianji){ + $query->where('nianji','in',$nianji); + }) + ->order([$order_field=>$order]) + ->limit($limit_start,$limit_length) + ->select(); + }else{ + $data = $this->scope('kaoshi',$kaoshiid) + ->order([$order_field=>$order]) + ->limit($limit_start,$limit_length) + ->select(); + } + + $data = $data->append(['cj_school.jiancheng','cj_banji.title','cj_student.xingming']); + + return $data; + } + + + + // 根据考试ID查询所有考试成绩 + public function searchAll($kaoshiid) + { + return $this::scope('kaoshi',$kaoshiid) + // ->cache('key',180) + ->select(); + } + + // 考试项目查询范围 + public function scopeKaoshi($query,$kaoshiid) + { + $query->where('kaoshi',$kaoshiid); + } } diff --git a/application/chengji/view/index/chengjilist.html b/application/chengji/view/index/chengjilist.html index 28477b35..e3f338b0 100644 --- a/application/chengji/view/index/chengjilist.html +++ b/application/chengji/view/index/chengjilist.html @@ -25,20 +25,52 @@ 共有数据:{$list.count} 条 +
+
筛选成绩
+
+
+ {php} + $school = new app\system\model\School; + $school = $school->searchMany('校级','校级'); + {/php} +
+
{foreach $school as $key=>$vo } + + {/foreach} +
+ +
+
+ +
+
+ + + + + + +
+ +
+
+
-
- - {php} - $njlist = nianjiList(); - {/php} - - -
{/block} {block name="tables"} @@ -72,6 +104,26 @@ type: "post", data: { kaoshi:"{$list.kaoshi}", + school:function(){ + var chk = []; + $('input[name="school"]:checked').each(function(){ + if(typeof($(this).val()) != "undefined") + { + chk.push($(this).val()); + } + }); + return chk; + }, + nianji:function(){ + var chk = []; + $('input[name="nianji"]:checked').each(function(){ + if(typeof($(this).val()) != "undefined") + { + chk.push($(this).val()); + } + }); + return chk; + }, }, }; @@ -145,7 +197,6 @@ }, ]; - // 删除成绩 function delcj(obj,url){ layer.confirm('确认要成绩删除吗?',function(index){ @@ -175,5 +226,18 @@ }); }); } + + // 筛选成绩面板折叠 + $('#shaixuan').click(function(){ + $(this).next().toggle(); + }); + + // 重载数据 + function dtreload() + { + $('#table1').DataTable().ajax.reload(); + } + + {/block} \ No newline at end of file diff --git a/application/common/view/list.html b/application/common/view/list.html index ee638621..e27d8114 100644 --- a/application/common/view/list.html +++ b/application/common/view/list.html @@ -99,6 +99,7 @@ order: [ [ 0, 'desc' ] ], + destroy: true, //option显示数量 aLengthMenu: [[20, 50, 100, 500], [20, 50, 100, 500]], iDisplayLength: 20, //默认显示20条 diff --git a/application/kaoshi/view/more_action/index.html b/application/kaoshi/view/more_action/index.html index bc4de2f6..3041b921 100644 --- a/application/kaoshi/view/more_action/index.html +++ b/application/kaoshi/view/more_action/index.html @@ -91,16 +91,6 @@ fontSize:'50px', }); }); - - $('h1').mouseleave(function(){ - $(this).animate({ - fontSize:'36px', - }); - }); - - - - {/block} \ No newline at end of file diff --git a/application/system/controller/School.php b/application/system/controller/School.php index 308a5204..f14b8ce2 100644 --- a/application/system/controller/School.php +++ b/application/system/controller/School.php @@ -12,7 +12,10 @@ class School extends Base // 单位列表 public function index() { - $count = sch::count(); + // 实例化单位模型 + $sch = new sch(); + // 获取记录集总数 + $count = $sch->searchAll()->count(); // 设置要给模板赋值的信息 $list['title'] = '单位列表'; @@ -32,43 +35,17 @@ class School extends Base // 获取DT的传值 $getdt = request()->param(); - //得到排序的方式 - $order = $getdt['order'][0]['dir']; - //得到排序字段的下标 - $order_column = $getdt['order'][0]['column']; - //根据排序字段的下标得到排序字段 - $order_field = $getdt['columns'][$order_column]['data']; - //得到limit参数 - $limit_start = $getdt['start']; - $limit_length = $getdt['length']; - //得到搜索的关键词 - $search = $getdt['search']['value']; - - - // 获取记录集总数 - $cnt = sch::count(); - //查询数据 - $data =sch::field('id,title,jiancheng,biaoshi,xingzhi,jibie,status,xueduan,paixu') - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->all(); - - // 如果需要查询 - if($search){ - $data =sch::field('id,title,jiancheng,biaoshi,xingzhi,jibie,status,xueduan,paixu') - ->whereOr('title','like','%'.$search.'%') - ->whereOr('pid','in',function($query) use ($search){ - $query->name('category')->where('title','like','%'.$search.'%')->field('id'); - }) - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->all(); - } + // 实例化单位模型 + $sch = new sch(); + // 获取记录集总数 + $cnt = $sch->searchAll()->count(); + //查询数据 + $data =$sch->searchAjax($getdt); $datacnt = $data->count(); - + // 组合返回数据 $data = [ 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) diff --git a/application/system/model/School.php b/application/system/model/School.php index 968bb403..c123ef51 100644 --- a/application/system/model/School.php +++ b/application/system/model/School.php @@ -6,6 +6,7 @@ use app\common\model\Base; class School extends Base { + // 单位性质获取器 public function getXingzhiAttr($value) { @@ -27,10 +28,74 @@ class School extends Base // 获取类别名 public function getcategory($id) { - return db('category') + $ct = new \app\system\model\Category; + return $ct ->where('id',$id) ->value('title'); } + // 查询所有单位 + public function searchAjax($getdt) + { + //得到排序的方式 + $order = $getdt['order'][0]['dir']; + //得到排序字段的下标 + $order_column = $getdt['order'][0]['column']; + //根据排序字段的下标得到排序字段 + $order_field = $getdt['columns'][$order_column]['data']; + //得到limit参数 + $limit_start = $getdt['start']; + $limit_length = $getdt['length']; + //得到搜索的关键词 + $search = $getdt['search']['value']; + + + // 如果需要查询 + if(trim($search)){ + $data =sch::field('id,title,jiancheng,biaoshi,xingzhi,jibie,status,xueduan,paixu') + ->whereOr('title','like','%'.$search.'%') + ->whereOr('pid','in',function($query) use ($search){ + $query->name('category')->where('title','like','%'.$search.'%')->field('id'); + }) + ->order([$order_field=>$order]) + ->limit($limit_start,$limit_length) + ->select(); + }else{ + $data =$this->field('id,title,jiancheng,biaoshi,xingzhi,jibie,status,xueduan,paixu') + ->order([$order_field=>$order]) + ->limit($limit_start,$limit_length) + ->select(); + } + + return $data; + } + + // 查询所有数据 + public function searchAll() + { + return $this->cache('key',180)->select(); + } + + // 查询范围内数据 + public function searchMany($jibie1,$jibie2) + { + $jb = new \app\system\model\Category; + $jibie1 = $jb->wherePid(102) + ->whereTitle($jibie1) + ->value('id'); + $jibie2 = $jb->wherePid(102) + ->whereTitle($jibie2) + ->value('id'); + + $schlist = $this->where('jibie','between',[$jibie1,$jibie2])->select(); + return $schlist; + } + + + + + + + }