diff --git a/application/admin/view/auth_rule/index.html b/application/admin/view/auth_rule/index.html index 18d91e85..d10c6449 100644 --- a/application/admin/view/auth_rule/index.html +++ b/application/admin/view/auth_rule/index.html @@ -122,7 +122,7 @@ layui.use(['table','laypage','form','cjgl'], function(){ cjgl.delAll(checkStatus,'/authrule','mytable'); break; case 'add': - cjgl.add('添加权限','/authrule/create','650','500'); + cjgl.add('添加权限','/authrule/create','','',true); break; }; }); @@ -142,7 +142,7 @@ layui.use(['table','laypage','form','cjgl'], function(){ cjgl.del(obj,"/authrule"); break; case 'edit':// 编辑 - cjgl.add('编辑权限','/authrule/'+obj.data.id+'/edit','650','500'); + cjgl.add('编辑权限','/authrule/'+obj.data.id+'/edit','','',true); break; case 'status':// 状态 cjgl.status(obj,"{:url('setstatus')}"); diff --git a/application/teach/controller/Banji.php b/application/teach/controller/Banji.php index 3c291a0a..bdfb3f71 100644 --- a/application/teach/controller/Banji.php +++ b/application/teach/controller/Banji.php @@ -27,7 +27,6 @@ class Banji extends Base // 获取班级信息列表 public function ajaxData() { - // 获取参数 $src = $this->request ->only([ @@ -61,7 +60,6 @@ class Banji extends Base 'data'=>$data, //获取到的数据结果 ]; - return json($data); } diff --git a/application/teach/controller/Xueqi.php b/application/teach/controller/Xueqi.php index 07bb6724..d9c12b8f 100644 --- a/application/teach/controller/Xueqi.php +++ b/application/teach/controller/Xueqi.php @@ -27,55 +27,34 @@ class Xueqi extends Base public function ajaxData() { - // 获取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']; + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'field'=>'id', + 'order'=>'desc', + 'searchval'=>'' + ],'POST'); - // 获取记录集总数 - $cnt = XQ::count(); - //查询数据 - $data =XQ::field('id,title,xuenian,category,bfdate,enddate,status') - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->all(); - - - // 如果需要查询 - if($search){ - $data = XQ::field('id,title,xuenian,category,bfdate,enddate,status') - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->whereOr('title|xuenian','like','%'.$search.'%') - ->whereOr('category','in',function($query) use($search) - { - $query->table('catagory') - ->where('title','like','%'.$search.'%') - ->field('id'); - }) - ->all(); - } - - $datacnt = $data->count(); - - - + // 实例化 + $xq = new XQ; + // 查询要显示的数据 + $data = $xq->search($src); + // 获取符合条件记录总数 + $cnt = $data->count(); + // 获取当前页数据 + $limit_start = $src['page'] * $src['limit'] - $src['limit']; + $limit_length = $src['limit']-1; + $data = $data->slice($limit_start,$limit_length); + + // 重组返回内容 $data = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; @@ -88,13 +67,17 @@ class Xueqi extends Base public function create() { // 设置页面标题 - $list['title'] = '添加学期'; + $list['set'] = array( + 'webtitle'=>'添加学期', + 'butname'=>'添加', + 'formpost'=>'POST', + 'url'=>'/xueqi', + ); // 模板赋值 $this->assign('list',$list); - // 渲染 - return $this->fetch(); + return $this->fetch('create'); } diff --git a/application/teach/model/Xueqi.php b/application/teach/model/Xueqi.php index 67eb5de4..476e3d4d 100644 --- a/application/teach/model/Xueqi.php +++ b/application/teach/model/Xueqi.php @@ -31,19 +31,16 @@ class Xueqi extends Base return date('Y-m-d',$value); } - // 分类获取器 - public function getcategoryAttr($value) + // 分类关联 + public function glCategory() { - return db('category') - ->where('id',$value) - ->value('title'); + return $this->belongsTo('\app\system\model\Category','category','id'); } // 查询所有单位 public function search($src) { // 整理变量 - $xingzhi = $src['xingzhi']; $searchval = $src['searchval']; // 查询数据 @@ -54,13 +51,7 @@ class Xueqi extends Base }) ->with( [ - 'dwXingzhi'=>function($query){ - $query->field('id,title'); - }, - 'dwJibie'=>function($query){ - $query->field('id,title'); - }, - 'dwXueduan'=>function($query){ + 'glCategory'=>function($query){ $query->field('id,title'); }, ] diff --git a/application/teach/view/xueqi/create.html b/application/teach/view/xueqi/create.html index c309e56f..c41c9e1d 100644 --- a/application/teach/view/xueqi/create.html +++ b/application/teach/view/xueqi/create.html @@ -4,7 +4,7 @@
-
- -
- -
-
-
- +
- {php} $category = getCategory(101);{/php} - {volist name="category" id="vo"}
-
- -
- {php} $category = getCategory(102);{/php} - -
-
-
- -
- {php} $category = getCategory(103);{/php} - -
-
-
- -
- -
-
+ +