diff --git a/application/rongyu/controller/DwRongyu.php b/application/rongyu/controller/DwRongyu.php index 9b49d66c..1beb1caf 100644 --- a/application/rongyu/controller/DwRongyu.php +++ b/application/rongyu/controller/DwRongyu.php @@ -17,9 +17,9 @@ class DwRongyu extends Base public function index() { // 设置数据总数 - $list['count'] = Teacher::count(); + $list['count'] = dwry::count(); // 设置页面标题 - $list['title'] = '教师列表'; + $list['title'] = '单位荣誉'; // 模板赋值 $this->assign('list', $list); @@ -28,6 +28,62 @@ class DwRongyu extends Base return $this->fetch(); } + /** + * 显示单位荣誉列表 + * + * @return \think\Response + */ + public function ajaxData() + { + // 获取DT的传值 + $getdt = request()->param(); + + //得到排序的方式 + $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 = [ + 'hjschool'=>$getdt['hjschool'], + 'fzschool'=>$getdt['fzschool'], + 'category'=>$getdt['category'], + 'search'=>$getdt['search']['value'], + 'order'=>$order, + 'order_field'=>$order_field + ]; + + // 实例化 + $dwry = new dwry(); + + // 获取荣誉总数 + $datacnt = $dwry->select()->count(); + + // 查询数据 + $data = $dwry->search($search); + + $cnt = $data->count(); + + // 重组返回内容 + $data = [ + 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 + 'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量) + 'recordsFiltered'=>$datacnt, // 符合条件的总数据量 + 'data'=>$data, //获取到的数据结果 + ]; + + return json($data); + } + /** * 显示创建资源表单页. * diff --git a/application/rongyu/model/DwRongyu.php b/application/rongyu/model/DwRongyu.php index 3a337f7d..6e8028b2 100644 --- a/application/rongyu/model/DwRongyu.php +++ b/application/rongyu/model/DwRongyu.php @@ -7,5 +7,33 @@ use app\common\model\Base; class DwRongyu extends Base { - // + //搜索单位获奖荣誉 + public function search($search) + { + // 获取参数 + $hjschool = $search['hjschool']; + $fzschool = $search['fzschool']; + $category = $search['category']; + $order_field = $search['order_field']; + $order = $search['order']; + $category = $search['category']; + $search = $search['search']; + + $data = $this->order([$order_field =>$order]) + ->when(!empty($hjschool),function($query) use($hjschool){ + $query->where('hjschool','in',$hjschool); + }) + ->when(!empty($fzschool),function($query) use($fzschool){ + $query->where('fzschool','in',$fzschool); + }) + ->when(!empty($category),function($query) use($category){ + $query->where('category','in',$category); + }) + ->when(!empty($search),function($query) use($search){ + $query->where('title','like',$search); + }) + ->select(); + + return $data; + } } diff --git a/application/rongyu/model/DwRongyuCanyu.php b/application/rongyu/model/DwRongyuCanyu.php new file mode 100644 index 00000000..7ef51aaf --- /dev/null +++ b/application/rongyu/model/DwRongyuCanyu.php @@ -0,0 +1,11 @@ + {foreach $school as $key=>$vo } {/foreach} @@ -112,9 +112,9 @@ url: "{:url('ajaxdata')}", type: "post", data: { - school:function(){ + hjschool:function(){ var chk = []; - $('input[name="school"]:checked').each(function(){ + $('input[name="hjschool"]:checked').each(function(){ if(typeof($(this).val()) != "undefined") { chk.push($(this).val()); @@ -122,9 +122,9 @@ }); return chk; }, - ruxuenian:function(){ + fzschool:function(){ var chk = []; - $('input[name="nianji"]:checked').each(function(){ + $('input[name="fzschool"]:checked').each(function(){ if(typeof($(this).val()) != "undefined") { chk.push($(this).val()); @@ -132,9 +132,9 @@ }); return chk; }, - banji:function(){ + category:function(){ var chk = []; - $('input[name="banji"]:checked').each(function(){ + $('input[name="category"]:checked').each(function(){ if(typeof($(this).val()) != "undefined") { chk.push($(this).val()); diff --git a/application/system/model/Category.php b/application/system/model/Category.php index 85a8a731..97cc7311 100644 --- a/application/system/model/Category.php +++ b/application/system/model/Category.php @@ -6,7 +6,7 @@ use app\common\model\Base; class Category extends Base { - // 开启全局自动时间戳 + // 关闭全局自动时间戳 protected $autoWriteTimestamp = false; // 父级类别获取器 diff --git a/database/migrations/20181218041034_dw_rongyu.php b/database/migrations/20181218041034_dw_rongyu.php index 211a65dc..62191e3b 100644 --- a/database/migrations/20181218041034_dw_rongyu.php +++ b/database/migrations/20181218041034_dw_rongyu.php @@ -34,10 +34,11 @@ class DwRongyu extends Migrator // 添加当前表字段 $table ->addColumn('title','string',['limit'=>30,'null'=>false,'comment'=>'单位荣誉名称']) - ->addColumn('hjzhengdw','integer',['limit'=>11,'null'=>false,'comment'=>'获奖单位']) - ->addColumn('fazhengdw','integer',['limit'=>11,'null'=>false,'comment'=>'发证单位']) - ->addColumn('fazhengsj','integer',['limit'=>11,'null'=>false,'comment'=>'发证时间']) - ->addColumn('leixing','integer',['limit'=>15,'null'=>false,'comment'=>'荣誉类型']) + ->addColumn('hjschool','integer',['limit'=>11,'null'=>false,'comment'=>'获奖单位']) + ->addColumn('fzschool','integer',['limit'=>11,'null'=>false,'comment'=>'发证单位']) + ->addColumn('fzshijian','integer',['limit'=>11,'null'=>false,'comment'=>'发证时间']) + ->addColumn('category','string',['limit'=>100,'null'=>false,'comment'=>'荣誉图片']) + ->addColumn('pic','integer',['limit'=>15,'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'=>'更新时间']) diff --git a/database/migrations/20181227061353_dw_rongyu_canyu.php b/database/migrations/20181227061353_dw_rongyu_canyu.php new file mode 100644 index 00000000..e4165a9a --- /dev/null +++ b/database/migrations/20181227061353_dw_rongyu_canyu.php @@ -0,0 +1,41 @@ +table('dw_rongyu_canyu'); + + // 添加当前表字段 + $table + ->addColumn('rongyuid','string',['limit'=>30,'null'=>false,'comment'=>'单位荣誉名称']) + ->addColumn('teacherid','integer',['limit'=>11,'null'=>false,'comment'=>'获奖单位']) + ->create(); + + } +}