forum status

This commit is contained in:
zhao 2020-02-27 14:14:09 +08:00
parent e5edb85b91
commit f4c0fd4054
3 changed files with 29 additions and 26 deletions

View File

@ -22,14 +22,10 @@ class Forum extends AdminController
if(Request::isAjax()){ if(Request::isAjax()){
$data = Request::only(['id','name','title','sec']); $data = Request::only(['id','name','title','sec']);
$where =array(); $where =array();
//var_dump($data);
if (!empty($data['sec'])) { if (!empty($data['sec'])) {
switch ($data['sec']) { switch ($data['sec']) {
case '0':
$data['status'] = $data['sec'];
break;
case '1': case '1':
$data['status'] = $data['sec']; $data['a.status'] = 1;
break; break;
case '2': case '2':
$data['is_top'] = 1; $data['is_top'] = 1;
@ -38,32 +34,32 @@ class Forum extends AdminController
$data['is_hot'] = 1; $data['is_hot'] = 1;
break; break;
case '4': case '4':
$data['is_replay'] = 0; $data['is_reply'] = 0;
break; break;
case '5':
$data['a.status'] = 0;
break;
}
} }
unset($data['sec']); unset($data['sec']);
} unset($data['status']);
if(!empty($data['id'])){ if(!empty($data['id'])){
$data['a.id'] = $data['id']; $data['a.id'] = $data['id'];
unset($data['id']); unset($data['id']);
} }
if(!empty($data['status'])){
$data['a.status'] = $data['status'];
unset($data['status']);
}
if(!empty($data['title'])){ if(!empty($data['title'])){
$where[] = ['title', 'like', '%'.$data['title'].'%']; $where[] = ['title', 'like', '%'.$data['title'].'%'];
//var_dump($map);
unset($data['title']); unset($data['title']);
} }
$map = array_filter($data); $map = array_filter($data,[$this,"filtr"]);
$forumList = Db::name('article') $forumList = Db::name('article')
->alias('a') ->alias('a')
->join('user u','a.user_id = u.id') ->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('a.delete_time',0)
->where($map) ->where($map)
->where($where) ->where($where)
@ -76,7 +72,7 @@ class Forum extends AdminController
$res['msg'] = ''; $res['msg'] = '';
$res['count'] = $count; $res['count'] = $count;
foreach($forumList as $k=>$v){ 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 { } else {
$res = ['code'=>-1,'msg'=>'没有查询结果!']; $res = ['code'=>-1,'msg'=>'没有查询结果!'];

View File

@ -19,13 +19,14 @@ layui.define(['table', 'form'], function(exports){
,url: '/admin/Forum/list' //帖子数据接口 ,url: '/admin/Forum/list' //帖子数据接口
,cols: [[ ,cols: [[
{type: 'checkbox', fixed: 'left'} {type: 'checkbox', fixed: 'left'}
,{field: 'id', width: 100, title: 'ID', sort: true} ,{field: 'id', width: 55, title: 'ID', sort: true}
,{field: 'poster', title: '发帖人'} ,{field: 'poster', title: '贴主'}
,{field: 'avatar', title: '头像', width: 100, templet: '#imgTpl'} ,{field: 'avatar', title: '头像', width: 100, templet: '#imgTpl', align: 'center'}
,{field: 'content', title: '发帖内容',templet: '#title'} ,{field: 'content', title: '标题', width: 200,templet: '#title'}
,{field: 'posttime', title: '发帖时间', sort: true} ,{field: 'posttime', title: '时间', sort: true}
,{field: 'top', title: '置顶', templet: '#buttonTpl', minWidth: 80, align: 'center'} ,{field: 'top', title: '置顶', templet: '#buttonTpl', minWidth: 80, align: 'center'}
,{field: 'hot', title: '精贴', templet: '#buttonHot', 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'} ,{field: 'check', title: '审帖', templet: '#buttonCheck', minWidth: 80, align: 'center'}
,{title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#table-forum-list'} ,{title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#table-forum-list'}
]] ]]

View File

@ -31,9 +31,8 @@
<option value="1">正常</option> <option value="1">正常</option>
<option value="2">置顶</option> <option value="2">置顶</option>
<option value="3">热门</option> <option value="3">热门</option>
<option value="4">禁回</option> <option value="4">禁评</option>
<option value="0">封禁</option> <option value="5">封禁</option>
</select> </select>
</div> </div>
</div> </div>
@ -69,7 +68,14 @@
{{# } else { }} {{# } else { }}
<button class="layui-btn layui-btn-primary layui-btn-xs">正常</button> <button class="layui-btn layui-btn-primary layui-btn-xs">正常</button>
{{# } }} {{# } }}
</script> </script>
<script type="text/html" id="buttonReply">
{{# if(d.reply == 1){ }}
<button class="layui-btn layui-btn-primary layui-btn-xs">正常</button>
{{# } else { }}
<button class="layui-btn layui-btn-xs">禁评</button>
{{# } }}
</script>
<script type="text/html" id="buttonCheck"> <script type="text/html" id="buttonCheck">
{if condition="checkRuleButton('admin/forum/check')"}<input type="checkbox" name="check" lay-skin="switch" lay-filter="forumcheck" lay-text="正常|封禁" {{# if(d.check == 1){ }} checked {{# } }} id="{{d.id}}" >{else}<button class="layui-btn layui-btn-xs layui-btn-radius layui-btn-disabled">无审核权</button>{/if} {if condition="checkRuleButton('admin/forum/check')"}<input type="checkbox" name="check" lay-skin="switch" lay-filter="forumcheck" lay-text="正常|封禁" {{# if(d.check == 1){ }} checked {{# } }} id="{{d.id}}" >{else}<button class="layui-btn layui-btn-xs layui-btn-radius layui-btn-disabled">无审核权</button>{/if}
</script> </script>