diff --git a/application/keti/controller/Index.php b/application/keti/controller/Index.php index f3b262d1..a22dc209 100644 --- a/application/keti/controller/Index.php +++ b/application/keti/controller/Index.php @@ -36,54 +36,40 @@ class Index extends Base */ public function ajaxData() { - // 获取DT的传值 - $getdt = request()->param(); + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'field'=>'update_time', + 'order'=>'desc', + 'lxdanweiid'=>array(), + 'category'=>array(), + 'searchval'=>'' + ],'POST'); - //得到排序的方式 - $order = $getdt['order'][0]['dir']; - //得到排序字段的下标 - $order_column = $getdt['order'][0]['column']; - //根据排序字段的下标得到排序字段 - $order_field = $getdt['columns'][$order_column]['name']; - if($order_field=='') - { - $order_field = $getdt['columns'][$order_column]['data']; - } - //得到limit参数 - $limit_start = $getdt['start']; - $limit_length = $getdt['length']; - - //得到搜索的关键词 - $search = [ - 'lxdanweiid'=>$getdt['lxdanweiid'], - 'category'=>$getdt['category'], - 'search'=>$getdt['search']['value'], - 'order'=>$order, - 'order_field'=>$order_field - ]; // 实例化 $keti = new keti; - // 获取荣誉总数 - $cnt = $keti->select()->count(); - - // 查询数据 - $data = $keti->search($search); - $datacnt = $data->count(); - + // 查询要显示的数据 + $data = $keti->search($src); + // 获取符合条件记录总数 + $cnt = $data->count(); // 获取当前页数据 + $limit_start = $src['page'] * $src['limit'] - $src['limit']; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); - - + // 重组返回内容 $data = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$datacnt, // 符合条件的总数据量 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; + return json($data); } @@ -97,13 +83,17 @@ class Index extends Base public function create() { // 设置页面标题 - $list['title'] = '添加课题册'; + $list['set'] = array( + 'webtitle'=>'添加课题册', + 'butname'=>'添加', + 'formpost'=>'POST', + 'url'=>'/kt', + ); // 模板赋值 $this->assign('list',$list); - // 渲染 - return $this->fetch(); + return $this->fetch('create'); } /** @@ -157,14 +147,22 @@ class Index extends Base public function edit($id) { // 获取荣誉册信息 - $list = keti::where('id',$id) + $list['data'] = keti::where('id',$id) ->field('id,title,category,lxshijian,lxdanweiid') ->find(); + // 设置页面标题 + $list['set'] = array( + 'webtitle'=>'编辑课题册', + 'butname'=>'修改', + 'formpost'=>'PUT', + 'url'=>'/kt/'.$id, + ); + // 模板赋值 $this->assign('list',$list); - - return $this->fetch(); + // 渲染 + return $this->fetch('create'); } /** diff --git a/application/keti/controller/KetiInfo.php b/application/keti/controller/KetiInfo.php index 3eb27955..c22471b5 100644 --- a/application/keti/controller/KetiInfo.php +++ b/application/keti/controller/KetiInfo.php @@ -18,7 +18,7 @@ class KetiInfo extends Base public function index() { // 设置要给模板赋值的信息 - $list['webtitle'] = '课题信息列表'; + $list['webtitle'] = '课题列表'; // 模板赋值 $this->assign('list',$list); @@ -34,20 +34,18 @@ class KetiInfo extends Base * @param int $id * @return \think\Response */ - public function ketiList($id) + public function ketiList($id,$title) { - - // 获取变量 + + // 设置要给模板赋值的信息 + $list['webtitle'] = $title.' 列表'; $list['id'] = $id; - // 设置页面标题 - $list['title'] = '课题信息'; - // 设置数据总数 - $list['count'] = ktinfo::where('ketice',$id)->count(); // 模板赋值 $this->assign('list',$list); - return $this->fetch(''); + // 渲染模板 + return $this->fetch(); } @@ -59,59 +57,44 @@ class KetiInfo extends Base */ public function ajaxData() { - // 获取DT的传值 - $getdt = request()->param(); + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'field'=>'update_time', + 'order'=>'desc', + 'lxdanweiid'=>array(), + 'lxcategory'=>array(), + 'fzdanweiid'=>array(), + 'subject'=>array(), + 'category'=>array(), + 'jddengji'=>array(), + 'searchval'=>'' + ],'POST'); - //得到排序的方式 - $order = $getdt['order'][0]['dir']; - //得到排序字段的下标 - $order_column = $getdt['order'][0]['column']; - //根据排序字段的下标得到排序字段 - $order_field = $getdt['columns'][$order_column]['name']; - if($order_field=='') - { - $order_field = $getdt['columns'][$order_column]['data']; - } - //得到limit参数 - $limit_start = $getdt['start']; - $limit_length = $getdt['length']; - - //得到搜索的关键词 - $search = [ - 'lxdanweiid'=>$getdt['lxdanweiid'], - 'lxcategory'=>$getdt['lxcategory'], - 'fzdanweiid'=>$getdt['fzdanweiid'], - 'subject'=>$getdt['subject'], - 'category'=>$getdt['category'], - 'jddengji'=>$getdt['jddengji'], - 'ketice'=>$getdt['ketice'], - 'search'=>$getdt['search']['value'], - 'order'=>$order, - 'order_field'=>$order_field - ]; // 实例化 - $keti = new ktinfo; - - // 获取荣誉总数 - $cnt = $keti->select()->count(); - - // 查询数据 - $data = $keti->search($search); - $datacnt = $data->count(); + $ktinfo = new ktinfo; + // 查询要显示的数据 + $data = $ktinfo->search($src); + // 获取符合条件记录总数 + $cnt = $data->count(); // 获取当前页数据 + $limit_start = $src['page'] * $src['limit'] - $src['limit']; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); - - + // 重组返回内容 $data = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$datacnt, // 符合条件的总数据量 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; + return json($data); } @@ -126,14 +109,18 @@ class KetiInfo extends Base public function create($id=0) { // 设置页面标题 - $list['title'] = '添加课题信息'; - $list['ketice'] = $id; + $list['set'] = array( + 'webtitle'=>'添加课题册', + 'butname'=>'添加', + 'formpost'=>'POST', + 'url'=>'/ktinfo', + 'ketice'=>$id + ); // 模板赋值 $this->assign('list',$list); - // 渲染 - return $this->fetch(); + return $this->fetch('create'); } /** @@ -266,7 +253,7 @@ class KetiInfo extends Base public function edit($id) { // 获取课题信息 - $list = ktinfo::where('id',$id) + $list['id'] = ktinfo::where('id',$id) ->field('id,title,fzdanweiid,bianhao,subject,category,jhjtshijian,lxpic') ->with([ 'ktZcr'=>function($query){ @@ -279,11 +266,18 @@ class KetiInfo extends Base ->find(); + // 设置页面标题 + $list['set'] = array( + 'webtitle'=>'编辑课题', + 'butname'=>'修改', + 'formpost'=>'PUT', + 'url'=>'/ktinfo/'.$id, + ); + // 模板赋值 $this->assign('list',$list); - - // 渲染模板 - return $this->fetch(); + // 渲染 + return $this->fetch('create'); } /** @@ -386,7 +380,7 @@ class KetiInfo extends Base public function jieTi($id) { // 获取课题信息 - $list = ktinfo::where('id',$id) + $list['data'] = ktinfo::where('id',$id) ->field('id,title,jddengji,jtshijian,jtpic') ->with([ 'ktCy'=>function($query){ @@ -398,11 +392,18 @@ class KetiInfo extends Base ]) ->find(); + // 设置页面标题 + $list['set'] = array( + 'webtitle'=>'编辑结题', + 'butname'=>'修改', + 'formpost'=>'PUT', + 'url'=>'/ktjt/'.$id, + ); + // 模板赋值 $this->assign('list',$list); - - // 渲染模板 - return $this->fetch(); + // 渲染 + return $this->fetch('create'); } diff --git a/application/keti/model/Keti.php b/application/keti/model/Keti.php index 63fa88a3..400421a5 100644 --- a/application/keti/model/Keti.php +++ b/application/keti/model/Keti.php @@ -9,25 +9,23 @@ use app\common\model\Base; class Keti extends Base { //搜索课题册 - public function search($search) + public function search($src) { - // 获取参数 - $lxdanweiid = $search['lxdanweiid']; - $category = $search['category']; - $order_field = $search['order_field']; - $order = $search['order']; - $category = $search['category']; - $search = $search['search']; + // 整理参数 + $lxdanweiid = $src['lxdanweiid']; + $category = $src['category']; + $searchval = $src['searchval']; - $data = $this->order([$order_field =>$order]) - ->when(strlen($lxdanweiid)>0,function($query) use($lxdanweiid){ + $data = $this + ->order([$src['field'] =>$src['order']]) + ->when(count($lxdanweiid)>0,function($query) use($lxdanweiid){ $query->where('lxdanweiid','in',$lxdanweiid); }) - ->when(strlen($category)>0,function($query) use($category){ + ->when(count($category)>0,function($query) use($category){ $query->where('category','in',$category); }) - ->when(strlen($search)>0,function($query) use($search){ - $query->where('title','like',$search); + ->when(strlen( $searchval)>0,function($query) use( $searchval){ + $query->where('title','like', $searchval); }) ->with( [ @@ -39,7 +37,10 @@ class Keti extends Base }, ] ) - ->append(['ktcnt','jtcnt']) + ->withCount(['ktInfo'=>'lxcount'],'id') + ->withCount(['ktInfo'=>function($query){ + $query->where('id','between',[1,1000]); + }]) ->select(); diff --git a/application/keti/model/KetiInfo.php b/application/keti/model/KetiInfo.php index 08cc2ee8..5d5b05fc 100644 --- a/application/keti/model/KetiInfo.php +++ b/application/keti/model/KetiInfo.php @@ -8,48 +8,43 @@ use app\common\model\Base; class KetiInfo extends Base { //搜索课题册 - public function search($search) + public function search($src) { // 获取参数 - $lxdanweiid = $search['lxdanweiid']; - $lxcategory = $search['lxcategory']; - $fzdanweiid = $search['fzdanweiid']; - $subject = $search['subject']; - $category = $search['category']; - $jddengji = $search['jddengji']; - $ketice = $search['ketice']; - $order_field = $search['order_field']; - $order = $search['order']; - $search = $search['search']; + $lxdanweiid = $src['lxdanweiid']; + $lxcategory = $src['lxcategory']; + $fzdanweiid = $src['fzdanweiid']; + $subject = $src['subject']; + $category = $src['category']; + $jddengji = $src['jddengji']; + $searchval = $src['searchval']; - $data = $this->order([$order_field =>$order]) - ->when(strlen($lxdanweiid)>0,function($query) use($lxdanweiid){ + $data = $this + ->order([$src['field'] =>$src['order']]) + ->when(count($lxdanweiid)>0,function($query) use($lxdanweiid){ $query->where('ketice','in',function ($q) use($lxdanweiid){ $q->name('keti')->where('lxdanweiid','in',$lxdanweiid)->field('id'); }); }) - ->when(strlen($lxcategory)>0,function($query) use($lxcategory){ + ->when(count($lxcategory)>0,function($query) use($lxcategory){ $query->where('ketice','in',function($q) use($lxcategory){ $q->name('keti')->where('category','in',$lxcategory)->field('id'); }); }) - ->when(strlen($fzdanweiid)>0,function($query) use($fzdanweiid){ + ->when(count($fzdanweiid)>0,function($query) use($fzdanweiid){ $query->where('fzdanweiid','in',$fzdanweiid); }) - ->when(strlen($subject)>0,function($query) use($subject){ + ->when(count($subject)>0,function($query) use($subject){ $query->where('subject','in',$subject); }) - ->when(strlen($category)>0,function($query) use($category){ + ->when(count($category)>0,function($query) use($category){ $query->where('category','in',$category); }) - ->when(strlen($ketice)>0,function($query) use($ketice){ - $query->where('ketice','in',$ketice); - }) - ->when(strlen($jddengji)>0,function($query) use($jddengji){ + ->when(count($jddengji)>0,function($query) use($jddengji){ $query->where('jddengji','in',$jddengji); }) - ->when(strlen($search)>0,function($query) use($search){ - $query->where('title','like',$search); + ->when(strlen($searchval)>0,function($query) use($searchval){ + $query->where('title','like',$searchval); }) ->with( [ diff --git a/application/keti/view/index/create.html b/application/keti/view/index/create.html index b4c30cdc..f00f31e8 100644 --- a/application/keti/view/index/create.html +++ b/application/keti/view/index/create.html @@ -1,78 +1,84 @@ {extend name="common@create" /} -{block name="mycss"} +{block name="jscss"} {/block} -{block name="formaa"} -
+{block name="form"} + {/block} -{block name="yanzheng"} - +{/block} - - -{/block} \ No newline at end of file diff --git a/application/keti/view/index/edit.html b/application/keti/view/index/edit.html deleted file mode 100644 index c7c09184..00000000 --- a/application/keti/view/index/edit.html +++ /dev/null @@ -1,78 +0,0 @@ -{extend name="common@create" /} -{block name="mycss"} -{/block} -{block name="formaa"} - -{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/keti/view/index/index.html b/application/keti/view/index/index.html index 724c0d3b..1a53ae74 100644 --- a/application/keti/view/index/index.html +++ b/application/keti/view/index/index.html @@ -1,206 +1,180 @@ + {extend name="common@list" /} -{block name="topnav"} - +{block name="jsset"} + {/block} -{block name="bouttons"} -| - | 课题册名称 | -立项单位 | -课题类别 | -课题数量 | -结题数量 | -立项时间 | -状态 | -操作 | -
|---|
+ {/if}
+ {/eq}
+ 或将照片拖到这里,单次最多可选300张
-| - | 主持人 | -课题名称 | -课题编号 | -立项单位 | -负责单位 | -立项类型 | -鉴定结果 | -立项时间 | -状态 | -操作 | -
|---|