From f4c0fd40545b15557650487afa9c5072e87b5d7f Mon Sep 17 00:00:00 2001 From: zhao Date: Thu, 27 Feb 2020 14:14:09 +0800 Subject: [PATCH] forum status --- app/admin/controller/Forum.php | 30 ++++++++++++---------------- public/static/admin/modules/forum.js | 11 +++++----- view/admin/forum/list.html | 14 +++++++++---- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/app/admin/controller/Forum.php b/app/admin/controller/Forum.php index 51ded75..88a85c9 100644 --- a/app/admin/controller/Forum.php +++ b/app/admin/controller/Forum.php @@ -22,14 +22,10 @@ class Forum extends AdminController if(Request::isAjax()){ $data = Request::only(['id','name','title','sec']); $where =array(); -//var_dump($data); if (!empty($data['sec'])) { switch ($data['sec']) { - case '0': - $data['status'] = $data['sec']; - break; case '1': - $data['status'] = $data['sec']; + $data['a.status'] = 1; break; case '2': $data['is_top'] = 1; @@ -38,32 +34,32 @@ class Forum extends AdminController $data['is_hot'] = 1; break; case '4': - $data['is_replay'] = 0; + $data['is_reply'] = 0; break; + case '5': + $data['a.status'] = 0; + break; + } } unset($data['sec']); - } - + unset($data['status']); + if(!empty($data['id'])){ $data['a.id'] = $data['id']; unset($data['id']); } - if(!empty($data['status'])){ - $data['a.status'] = $data['status']; - unset($data['status']); - } + if(!empty($data['title'])){ $where[] = ['title', 'like', '%'.$data['title'].'%']; - //var_dump($map); unset($data['title']); } - - $map = array_filter($data); + + $map = array_filter($data,[$this,"filtr"]); $forumList = Db::name('article') ->alias('a') ->join('user u','a.user_id = u.id') - ->field('a.id as aid,name,user_img,title,a.update_time as update_time,is_top,is_hot,a.status as astatus') + ->field('a.id as aid,name,user_img,title,a.update_time as update_time,is_top,is_hot,is_reply,a.status as status') ->where('a.delete_time',0) ->where($map) ->where($where) @@ -76,7 +72,7 @@ class Forum extends AdminController $res['msg'] = ''; $res['count'] = $count; foreach($forumList as $k=>$v){ - $res['data'][]= ['id'=>$v['aid'],'poster'=>$v['name'],'avatar'=>$v['user_img'],'content'=>$v['title'],'posttime'=>date("Y-m-d",$v['update_time']),'top'=>$v['is_top'],'hot'=>$v['is_hot'],'check'=>$v['astatus']]; + $res['data'][]= ['id'=>$v['aid'],'poster'=>$v['name'],'avatar'=>$v['user_img'],'content'=>$v['title'],'posttime'=>date("Y-m-d",$v['update_time']),'top'=>$v['is_top'],'hot'=>$v['is_hot'],'reply'=>$v['is_reply'],'check'=>$v['status']]; } } else { $res = ['code'=>-1,'msg'=>'没有查询结果!']; diff --git a/public/static/admin/modules/forum.js b/public/static/admin/modules/forum.js index 3c2fe5f..dc07373 100644 --- a/public/static/admin/modules/forum.js +++ b/public/static/admin/modules/forum.js @@ -19,13 +19,14 @@ layui.define(['table', 'form'], function(exports){ ,url: '/admin/Forum/list' //帖子数据接口 ,cols: [[ {type: 'checkbox', fixed: 'left'} - ,{field: 'id', width: 100, title: 'ID', sort: true} - ,{field: 'poster', title: '发帖人'} - ,{field: 'avatar', title: '头像', width: 100, templet: '#imgTpl'} - ,{field: 'content', title: '发帖内容',templet: '#title'} - ,{field: 'posttime', title: '发帖时间', sort: true} + ,{field: 'id', width: 55, title: 'ID', sort: true} + ,{field: 'poster', title: '贴主'} + ,{field: 'avatar', title: '头像', width: 100, templet: '#imgTpl', align: 'center'} + ,{field: 'content', title: '标题', width: 200,templet: '#title'} + ,{field: 'posttime', title: '时间', sort: true} ,{field: 'top', title: '置顶', templet: '#buttonTpl', minWidth: 80, align: 'center'} ,{field: 'hot', title: '精贴', templet: '#buttonHot', minWidth: 80, align: 'center'} + ,{field: 'reply', title: '评论状态', templet: '#buttonReply', minWidth: 80, align: 'center'} ,{field: 'check', title: '审帖', templet: '#buttonCheck', minWidth: 80, align: 'center'} ,{title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#table-forum-list'} ]] diff --git a/view/admin/forum/list.html b/view/admin/forum/list.html index df4d4d2..8eda653 100644 --- a/view/admin/forum/list.html +++ b/view/admin/forum/list.html @@ -31,9 +31,8 @@ - - - + + @@ -69,7 +68,14 @@ {{# } else { }} {{# } }} - + +