2020-01-01 13:17:19 +08:00
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
@Name:layuiAdmin 社区系统
|
|
|
|
|
@Author:star1029
|
|
|
|
|
@Site:http://www.layui.com/admin/
|
|
|
|
|
@License:LPPL
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layui.define(['table', 'form'], function(exports){
|
|
|
|
|
var $ = layui.$
|
|
|
|
|
,table = layui.table
|
|
|
|
|
,form = layui.form;
|
|
|
|
|
|
|
|
|
|
//帖子管理
|
|
|
|
|
table.render({
|
|
|
|
|
elem: '#LAY-app-forum-list'
|
2020-01-14 15:47:11 +08:00
|
|
|
|
,url: '/admin/Forum/list' //帖子数据接口
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,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: 'top', title: '置顶', templet: '#buttonTpl', minWidth: 80, align: 'center'}
|
2020-01-14 15:47:11 +08:00
|
|
|
|
,{field: 'hot', title: '精贴', templet: '#buttonHot', minWidth: 80, align: 'center'}
|
|
|
|
|
,{field: 'check', title: '审帖', templet: '#buttonCheck', minWidth: 80, align: 'center'}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,{title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#table-forum-list'}
|
|
|
|
|
]]
|
|
|
|
|
,page: true
|
|
|
|
|
,limit: 15
|
|
|
|
|
,limits: [10, 15, 20, 25, 30]
|
|
|
|
|
,text: '对不起,加载出现异常!'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//监听工具条
|
|
|
|
|
table.on('tool(LAY-app-forum-list)', function(obj){
|
|
|
|
|
var data = obj.data;
|
|
|
|
|
if(obj.event === 'del'){
|
|
|
|
|
layer.confirm('确定删除此条帖子?', function(index){
|
2020-01-14 15:47:11 +08:00
|
|
|
|
//obj.del();
|
|
|
|
|
$.ajax({
|
|
|
|
|
type:'post',
|
|
|
|
|
url:"/admin/Forum/listdel",
|
|
|
|
|
data:{id:data.id},
|
|
|
|
|
dataType:'json',
|
|
|
|
|
success:function(data){
|
|
|
|
|
if(data.code == 0){
|
|
|
|
|
layer.msg(data.msg,{
|
|
|
|
|
icon:6,
|
|
|
|
|
time:2000
|
|
|
|
|
},function(){
|
|
|
|
|
location.reload();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
layer.open({
|
|
|
|
|
title:'删除失败',
|
|
|
|
|
content:data.msg,
|
|
|
|
|
icon:5,
|
|
|
|
|
adim:6
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-01-01 13:17:19 +08:00
|
|
|
|
layer.close(index);
|
|
|
|
|
});
|
|
|
|
|
} else if(obj.event === 'edit'){
|
|
|
|
|
var tr = $(obj.tr);
|
|
|
|
|
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2
|
|
|
|
|
,title: '编辑帖子'
|
2020-01-14 15:47:11 +08:00
|
|
|
|
,content: '/admin/Forum/listform?id='+ data.id
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,area: ['550px', '400px']
|
|
|
|
|
,btn: ['确定', '取消']
|
|
|
|
|
,resize: false
|
|
|
|
|
,yes: function(index, layero){
|
|
|
|
|
var iframeWindow = window['layui-layer-iframe'+ index]
|
|
|
|
|
,submitID = 'LAY-app-forum-submit'
|
|
|
|
|
,submit = layero.find('iframe').contents().find("#layuiadmin-form-list")
|
|
|
|
|
,poster = submit.find('input[name="poster"]').val()
|
|
|
|
|
,content = submit.find('input[name="content"]').val()
|
|
|
|
|
,avatar = submit.find('input[name="avatar"]').val();
|
|
|
|
|
|
|
|
|
|
//监听提交
|
|
|
|
|
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
|
|
|
|
|
var field = data.field; //获取提交的字段
|
|
|
|
|
|
|
|
|
|
//提交 Ajax 成功后,静态更新表格中的数据
|
|
|
|
|
//$.ajax({});
|
|
|
|
|
$.ajax({
|
|
|
|
|
type:"post",
|
2020-01-14 15:47:11 +08:00
|
|
|
|
url:"/admin/Forum/listform",
|
2020-01-01 13:17:19 +08:00
|
|
|
|
data:{"id":data.id,"poster":name,"sort":sort,"ename":ename},
|
|
|
|
|
daType:"json",
|
|
|
|
|
success:function (data){
|
|
|
|
|
if (data.code == 0) {
|
|
|
|
|
layer.msg(data.msg,{
|
|
|
|
|
icon:6,
|
|
|
|
|
time:2000
|
|
|
|
|
}, function(){
|
|
|
|
|
location.reload();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
layer.open({
|
|
|
|
|
tiele:'修改失败',
|
|
|
|
|
content:data.msg,
|
|
|
|
|
icon:5,
|
|
|
|
|
anim:6
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table.reload('LAY-app-forum-list'); //数据刷新
|
|
|
|
|
layer.close(index); //关闭弹层
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
submit.trigger('click');
|
|
|
|
|
}
|
|
|
|
|
,success: function(layero, index){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-14 15:47:11 +08:00
|
|
|
|
//评论管理
|
2020-01-01 13:17:19 +08:00
|
|
|
|
table.render({
|
|
|
|
|
elem: '#LAY-app-forumreply-list'
|
2020-01-14 15:47:11 +08:00
|
|
|
|
,url: '/admin/Forum/replys'
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,cols: [[
|
|
|
|
|
{type: 'checkbox', fixed: 'left'}
|
|
|
|
|
,{field: 'id', width: 100, title: 'ID', sort: true}
|
|
|
|
|
,{field: 'replyer', title: '回帖人'}
|
2020-01-14 15:47:11 +08:00
|
|
|
|
,{field: 'cardid', title: '回帖ID',templet: '#title'}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,{field: 'avatar', title: '头像', width: 100, templet: '#imgTpl'}
|
|
|
|
|
,{field: 'content', title: '回帖内容', width: 200}
|
|
|
|
|
,{field: 'replytime', title: '回帖时间', sort: true}
|
2020-01-14 15:47:11 +08:00
|
|
|
|
,{field: 'check', title: '审核', templet: '#buttonCheck'}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,{title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#table-forum-replys'}
|
|
|
|
|
]]
|
|
|
|
|
,page: true
|
2020-01-14 15:47:11 +08:00
|
|
|
|
,limit: 15
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,limits: [10, 15, 20, 25, 30]
|
|
|
|
|
,text: '对不起,加载出现异常!'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//监听工具条
|
|
|
|
|
table.on('tool(LAY-app-forumreply-list)', function(obj){
|
|
|
|
|
var data = obj.data;
|
|
|
|
|
if(obj.event === 'del'){
|
|
|
|
|
layer.confirm('确定删除此条评论?', function(index){
|
2020-01-14 15:47:11 +08:00
|
|
|
|
//obj.del();
|
|
|
|
|
$.ajax({
|
|
|
|
|
type:'post',
|
|
|
|
|
url:"/admin/Forum/redel",
|
|
|
|
|
data:{id:data.id},
|
|
|
|
|
dataType:'json',
|
|
|
|
|
success:function(data){
|
|
|
|
|
if(data.code == 0){
|
|
|
|
|
layer.msg(data.msg,{
|
|
|
|
|
icon:6,
|
|
|
|
|
time:2000
|
|
|
|
|
},function(){
|
|
|
|
|
location.reload();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
layer.open({
|
|
|
|
|
title:'删除失败',
|
|
|
|
|
content:data.msg,
|
|
|
|
|
icon:5,
|
|
|
|
|
adim:6
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-01-01 13:17:19 +08:00
|
|
|
|
layer.close(index);
|
|
|
|
|
});
|
|
|
|
|
} else if(obj.event === 'edit'){
|
|
|
|
|
var tr = $(obj.tr);
|
|
|
|
|
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2
|
|
|
|
|
,title: '编辑评论'
|
2020-01-14 15:47:11 +08:00
|
|
|
|
,content: '/admin/Forum/replysform.html'
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,area: ['550px', '350px']
|
|
|
|
|
,btn: ['确定', '取消']
|
|
|
|
|
,resize: false
|
|
|
|
|
,yes: function(index, layero){
|
|
|
|
|
//获取iframe元素的值
|
|
|
|
|
var othis = layero.find('iframe').contents().find("#layuiadmin-form-replys");
|
|
|
|
|
var content = othis.find('textarea[name="content"]').val();
|
|
|
|
|
|
|
|
|
|
//数据更新
|
|
|
|
|
obj.update({
|
|
|
|
|
content: content
|
|
|
|
|
});
|
|
|
|
|
layer.close(index);
|
|
|
|
|
}
|
|
|
|
|
,success: function(layero, index){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
exports('forum', {})
|
|
|
|
|
});
|