mirror of https://github.com/1099438829/apeblog
修正留言和增加文件留言审理
This commit is contained in:
parent
b763d9f8c3
commit
3f385526a1
|
|
@ -5,6 +5,7 @@ namespace app\admin\controller;
|
|||
use app\common\model\Document as aModel;
|
||||
use app\common\model\DocumentCategory as cModel;
|
||||
use app\common\model\DocumentArticle;
|
||||
use app\common\model\Comment as CommentModel;
|
||||
use app\Request;
|
||||
use app\admin\service\UtilService as Util;
|
||||
use think\Exception;
|
||||
|
|
@ -203,4 +204,56 @@ class Article extends AuthController
|
|||
$this->assign("info",$info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章管理主页
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function comment($article_id ='')
|
||||
{
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章评论列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 李玉坤
|
||||
* @date 2021-11-03 23:28
|
||||
*/
|
||||
public function commentList()
|
||||
{
|
||||
$where = Util::postMore([
|
||||
['document_id',''],
|
||||
['name',''],
|
||||
['tel',''],
|
||||
['email',''],
|
||||
['start_time',''],
|
||||
['end_time',''],
|
||||
['page',1],
|
||||
['limit',20],
|
||||
]);
|
||||
if ($where['document_id'] == "") return app("json")->fail("参数错误");
|
||||
return app("json")->layui(CommentModel::systemPage($where));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改字段
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @author 李玉坤
|
||||
* @date 2021-02-16 23:12
|
||||
*/
|
||||
public function commentField($id)
|
||||
{
|
||||
if (!$id) return app("json")->fail("参数有误,Id为空!");
|
||||
$where = Util::postMore([['field',''],['value','']]);
|
||||
if ($where['field'] == '' || $where['value'] =='') return app("json")->fail("参数有误!");
|
||||
return CommentModel::update([$where['field']=>$where['value']],['id'=>$id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ class Message extends AuthController
|
|||
public function lst(Request $request)
|
||||
{
|
||||
$where = Util::postMore([
|
||||
['name',''],
|
||||
['author',''],
|
||||
['tel',''],
|
||||
['email',''],
|
||||
['start_time',''],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,267 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>文章评论管理 - {:system_config("title")}后台管理系统</title>
|
||||
{include file="public/header" /}
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid p-t-15">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header"><h4>搜索</h4></div>
|
||||
<div class="card-body">
|
||||
<form class="form-inline searchForm" onsubmit="return false;">
|
||||
<div class="form-group">
|
||||
<label for="author">姓名</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="author" name="author" placeholder="请输入姓名">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">邮箱</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="email" name="email" placeholder="邮箱">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="url">网址</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="url" name="url" placeholder="网址">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="start_time">操作时间</label>
|
||||
<div class="input-group">
|
||||
<input class="form-control js-datetimepicker" type="text" id="start_time" name="start_time" autocomplete="off" data-side-by-side="true" data-locale="zh-cn" data-format="YYYY-MM-DD" placeholder="开始时间">
|
||||
<span class="input-group-addon">~</span>
|
||||
<input class="form-control js-datetimepicker" type="text" id="end_time" name="end_time" autocomplete="off" data-side-by-side="true" data-locale="zh-cn" data-format="YYYY-MM-DD" placeholder="结束时间">
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success" style="margin: -10px 0 0 10px;" id="search">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-toolbar clearfix">
|
||||
<div class="toolbar-btn-action">
|
||||
<a class="btn btn-warning" href="#!" onclick="delSelect()"><i class="mdi mdi-window-close"></i> 删除</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table id="tb_departments"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="public/footer"/}
|
||||
<script type="text/javascript">
|
||||
var id = GetQueryString("id");
|
||||
$('#tb_departments').bootstrapTable({
|
||||
classes: 'table table-bordered table-hover table-striped',
|
||||
url: '/admin/article/commentList?id='+id,
|
||||
method: 'post',
|
||||
dataType : 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
|
||||
uniqueId: 'id',
|
||||
idField: 'id', // 每行的唯一标识字段
|
||||
toolbar: '#toolbar', // 工具按钮容器
|
||||
showColumns: false, // 是否显示所有的列
|
||||
showRefresh: false, // 是否显示刷新按钮
|
||||
responseHandler: function (res) {
|
||||
return {
|
||||
"total": res.count,
|
||||
"rows": res.data,
|
||||
};
|
||||
},
|
||||
pagination: true,
|
||||
queryParams: function(params) {
|
||||
let temp = toArrayList($(".searchForm").serializeArray());
|
||||
temp['document_id'] = id;
|
||||
temp['limit'] = params.limit;
|
||||
temp['page'] = (params.offset / params.limit) + 1;
|
||||
return temp;
|
||||
},
|
||||
sidePagination: "server",
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
pageList: [10, 20, 50, 100],
|
||||
columns: [{
|
||||
checkbox: true, // 是否显示复选框
|
||||
},{
|
||||
field: 'id',
|
||||
title: 'ID'
|
||||
},{
|
||||
field: 'author',
|
||||
title: '姓名'
|
||||
}, {
|
||||
field: 'email',
|
||||
title: '邮箱',
|
||||
}, {
|
||||
field: 'url',
|
||||
title: '网址',
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
formatter: function (value, row, index) {
|
||||
if (value == 0) {
|
||||
is_checked = '';
|
||||
} else if (value == 1){
|
||||
is_checked = 'checked="checked"';
|
||||
}
|
||||
var field = "display";
|
||||
result = '<label class="lyear-switch switch-primary switch-solid lyear-status"><input type="checkbox" '+ is_checked +'><span onClick="updateStatus('+ row.id +', '+ value +', \''+ field +'\')"></span></label>';
|
||||
return result;
|
||||
},
|
||||
},{
|
||||
field: 'create_time',
|
||||
title: '留言时间',
|
||||
}, {
|
||||
field: 'operate',
|
||||
title: '操作',
|
||||
formatter:function (value,row,index) {
|
||||
let html = '<a href="#!" class="btn btn-xs btn-default m-r-5 btn-detail" title="详情" data-toggle="tooltip" data-trigger="hover"><i class="mdi mdi-eye-outline"></i></a> \n' +
|
||||
'<a class="btn btn-xs btn-default btn-del" href="#!" title="删除" data-toggle="tooltip" onclick="delOne('+row.id+')"><i class="mdi mdi-window-close"></i></a>';
|
||||
return html;
|
||||
},
|
||||
events: {
|
||||
'click .btn-detail': function (event, value, row, index) {
|
||||
//职位描述+任职要求
|
||||
let content = ' <div class="p-lr-15">\n' +
|
||||
' <div class="row show-grid">\n' +
|
||||
' <div class="col-xs-12 col-md-4">姓名:</div>\n' +
|
||||
' <div class="col-xs-12 col-md-8">'+row.author+'</div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="row show-grid">\n' +
|
||||
' <div class="col-xs-12 col-md-4">网址:</div>\n' +
|
||||
' <div class="col-xs-12 col-md-8">'+row.url+'</div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="row show-grid">\n' +
|
||||
' <div class="col-xs-12 col-md-4">邮箱:</div>\n' +
|
||||
' <div class="col-xs-12 col-md-8">'+row.email+'</div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="row show-grid">\n' +
|
||||
' <div class="col-xs-12 col-md-4">评论内容:</div>\n' +
|
||||
' <div class="col-xs-12 col-md-8" style="white-space: pre-wrap;">'+row.content+'</div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>';
|
||||
$.alert({
|
||||
title: '详情',
|
||||
content: content,
|
||||
boxWidth: '50%', //定义弹窗宽度
|
||||
useBootstrap: false, //定义宽度必须设置
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: '关闭',
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}],
|
||||
onLoadSuccess: function(data){
|
||||
$("[data-toggle='tooltip']").tooltip();
|
||||
}
|
||||
});
|
||||
|
||||
//搜索
|
||||
$("#search").click(function () {
|
||||
let start_time = $('#start_time').val();
|
||||
let end_time = $('#end_time').val();
|
||||
if(start_time && end_time && start_time > end_time ){
|
||||
alert('开始时间不能大于结束时间');
|
||||
return false;
|
||||
}
|
||||
$("#tb_departments").bootstrapTable('refresh',{query:{page:1},pageNumber:1});
|
||||
});
|
||||
|
||||
function updateStatus(id, value,field) {
|
||||
var newstate = (value == 1) ? 0 : 1; // 发送参数值跟当前参数值相反
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/admin/article/commentField?id="+id,
|
||||
data: {field: field, value: newstate},
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
if (res.status == 200) {parent.lightyear.notify('修改成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');$(".tree-table").bootstrapTable('refresh');}
|
||||
else parent.lightyear.notify('修改失败', 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
},
|
||||
error: function () {
|
||||
parent.lightyear.notify('修改失败', 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delOne(id) {
|
||||
$.confirm({
|
||||
title: '重要提醒!',
|
||||
content: '删除后将不可恢复,请谨慎操作!',
|
||||
backgroundDismiss: true,
|
||||
buttons: {
|
||||
ok: {
|
||||
text: '确认',
|
||||
btnClass: 'btn-danger',
|
||||
action: function () {
|
||||
$.post("/admin/message/del",data={id:id},function (res) {
|
||||
if (res.status == 200 || res.code == 200) lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
|
||||
location.reload();
|
||||
})
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: '取消',
|
||||
btnClass: 'btn-primary'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delSelect() {
|
||||
var checkID = "";
|
||||
var selectedItem = $('#tb_departments').bootstrapTable('getSelections');
|
||||
if (selectedItem=="") return lightyear.notify("没有选中项", 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
|
||||
for (var i = 0 ; i< selectedItem.length; i++)
|
||||
{
|
||||
checkID += selectedItem[i]['id']+",";
|
||||
}
|
||||
if (checkID=="") return lightyear.notify("没有选中项", 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
|
||||
$.confirm({
|
||||
title: '重要提醒!',
|
||||
content: '选中项删除后将不可恢复,请谨慎操作!',
|
||||
backgroundDismiss: true,
|
||||
buttons: {
|
||||
ok: {
|
||||
text: '确认',
|
||||
btnClass: 'btn-danger',
|
||||
action: function () {
|
||||
$.post("/admin/message/del",data={id:checkID},function (res) {
|
||||
if (res.status == 200 || res.code == 200) { lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');location.reload();}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
|
||||
})
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: '取消',
|
||||
btnClass: 'btn-primary'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function GetQueryString(name)
|
||||
{
|
||||
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if(r!=null)return unescape(r[2]); return null;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -124,7 +124,8 @@
|
|||
title: '操作',
|
||||
formatter:function (value,row,index) {
|
||||
let html ='<a class="btn btn-xs btn-default btn-del" href="#!" title="删除" data-toggle="tooltip" onclick="delOne('+row.id+')"><i class="mdi mdi-window-close"></i></a>\n' +
|
||||
'<a type="button" class="btn-edit btn btn-xs btn-default m-r-5" href="/admin/article/edit?id='+row.id+'" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>';
|
||||
'<a type="button" class="btn-edit btn btn-xs btn-default m-r-5" href="/admin/article/edit?id='+row.id+'" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>\n'+
|
||||
'<a type="button" class="btn-edit btn btn-xs btn-default m-r-5" href="/admin/article/comment?id='+row.id+'" title="查看评论" data-toggle="tooltip"><i class="mdi mdi-message-text"></i></a>\n';
|
||||
return html;
|
||||
},
|
||||
events : {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
<div class="card-body">
|
||||
<form class="form-inline searchForm" onsubmit="return false;">
|
||||
<div class="form-group">
|
||||
<label for="name">姓名</label>
|
||||
<label for="author">姓名</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="请输入姓名">
|
||||
<input type="text" class="form-control" id="author" name="author" placeholder="请输入姓名">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
field: 'id',
|
||||
title: 'ID'
|
||||
},{
|
||||
field: 'name',
|
||||
field: 'author',
|
||||
title: '姓名'
|
||||
}, {
|
||||
field: 'tel',
|
||||
|
|
@ -123,7 +123,7 @@
|
|||
let content = ' <div class="p-lr-15">\n' +
|
||||
' <div class="row show-grid">\n' +
|
||||
' <div class="col-xs-12 col-md-4">姓名:</div>\n' +
|
||||
' <div class="col-xs-12 col-md-8">'+row.name+'</div>\n' +
|
||||
' <div class="col-xs-12 col-md-8">'+row.author+'</div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="row show-grid">\n' +
|
||||
' <div class="col-xs-12 col-md-4">联系方式:</div>\n' +
|
||||
|
|
|
|||
|
|
@ -11,5 +11,29 @@ namespace app\common\model;
|
|||
*/
|
||||
class Comment extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 李玉坤
|
||||
* @date 2021-02-15 23:24
|
||||
*/
|
||||
public static function systemPage($where): array
|
||||
{
|
||||
$model = new self;
|
||||
$model = $model->order('create_time','desc');
|
||||
if (isset($where['name']) && $where['name'] !== '') $model->where('name', "like", "%$where[name]%");
|
||||
if (isset($where['email']) && $where['email'] !== '') $model->where('email', "like", "%$where[email]%");
|
||||
if (isset($where['tel']) && $where['tel'] !== '') $model->where('tel', "like", "%$where[tel]%");
|
||||
if (isset($where['start_time']) && $where['start_time'] != '') $model = $model->where("m.created_at", ">", strtotime($where['start_time'] . " 00:00:00"));
|
||||
if (isset($where['end_time']) && $where['end_time'] != '') $model = $model->where("m.created_at", "<", strtotime($where['end_time'] . " 23:59:59"));
|
||||
$count = self::counts($model);
|
||||
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'],(int)$where['limit']);
|
||||
$data = $model->select();
|
||||
if ($data) $data = $data->toArray();
|
||||
return compact('data','count');
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ class MessageForm extends BaseModel
|
|||
{
|
||||
$model = new self;
|
||||
$model = $model->order('create_time','desc');
|
||||
if (isset($where['name']) && $where['name'] !== '') $model->where('name', "like", "%$where[name]%");
|
||||
if (isset($where['author']) && $where['author'] !== '') $model->where('author', "like", "%$where[name]%");
|
||||
if (isset($where['email']) && $where['email'] !== '') $model->where('email', "like", "%$where[email]%");
|
||||
if (isset($where['tel']) && $where['tel'] !== '') $model->where('tel', "like", "%$where[tel]%");
|
||||
if (isset($where['start_time']) && $where['start_time'] != '') $model = $model->where("m.created_at", ">", strtotime($where['start_time'] . " 00:00:00"));
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Index extends Base
|
|||
{
|
||||
if(request()->isPost()){
|
||||
$data = Util::postMore([
|
||||
['name',''],
|
||||
['author',''],
|
||||
['tel',''],
|
||||
['email',''],
|
||||
['content',''],
|
||||
|
|
|
|||
Loading…
Reference in New Issue