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-04-28 18:44:40 +08:00
|
|
|
|
,url: forumList //帖子数据接口
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,cols: [[
|
2021-06-09 14:48:38 +08:00
|
|
|
|
{type: 'checkbox'}
|
|
|
|
|
,{field: 'id', width: 60, title: 'ID', sort: true}
|
2021-06-17 14:25:48 +08:00
|
|
|
|
,{field: 'poster', title: '贴主',width: 100}
|
2021-06-09 14:48:38 +08:00
|
|
|
|
,{field: 'avatar', title: '头像', width: 80, templet: '#imgTpl'}
|
2021-06-17 14:25:48 +08:00
|
|
|
|
,{field: 'content', title: '标题', mWidth: 200,templet: '#title'}
|
2021-06-09 14:48:38 +08:00
|
|
|
|
,{field: 'posttime', title: '时间',width: 120, sort: true}
|
|
|
|
|
,{field: 'top', title: '置顶', templet: '#buttonTpl', width: 80, align: 'center'}
|
|
|
|
|
,{field: 'hot', title: '精贴', templet: '#buttonHot', width: 80, align: 'center'}
|
|
|
|
|
,{field: 'reply', title: '评论状态', templet: '#buttonReply', width: 80, align: 'center'}
|
|
|
|
|
,{field: 'check', title: '审帖', templet: '#buttonCheck', width: 100, align: 'center'}
|
2021-06-17 14:25:48 +08:00
|
|
|
|
,{title: '操作', width: 60, align: 'center', toolbar: '#table-forum-list'}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
]]
|
|
|
|
|
,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',
|
2020-04-28 18:44:40 +08:00
|
|
|
|
url:forumListdel,
|
2020-01-14 15:47:11 +08:00
|
|
|
|
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-04-28 18:44:40 +08:00
|
|
|
|
,url: forumReplys
|
2020-01-01 13:17:19 +08:00
|
|
|
|
,cols: [[
|
2021-06-09 14:48:38 +08:00
|
|
|
|
{type: 'checkbox'}
|
|
|
|
|
,{field: 'id', width: 80, title: 'ID', sort: true}
|
|
|
|
|
,{field: 'replyer', title: '回帖人', width: 80}
|
|
|
|
|
,{field: 'cardid', title: '帖ID',templet: '#title'}
|
|
|
|
|
,{field: 'avatar', title: '头像', width: 80, templet: '#imgTpl'}
|
|
|
|
|
,{field: 'content', title: '评论', minWidth: 200}
|
|
|
|
|
,{field: 'replytime', title: '回复时间', width: 120, sort: true}
|
|
|
|
|
,{field: 'check', title: '审核', templet: '#buttonCheck', width: 100}
|
|
|
|
|
,{title: '操作', width: 85, align: 'center', toolbar: '#table-forum-replys'}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
]]
|
|
|
|
|
,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',
|
2020-04-28 18:44:40 +08:00
|
|
|
|
url:forumRedel,
|
2020-01-14 15:47:11 +08:00
|
|
|
|
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){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-04-28 18:44:40 +08:00
|
|
|
|
|
|
|
|
|
//帖子分类管理
|
|
|
|
|
table.render({
|
|
|
|
|
elem: '#LAY-app-content-tags'
|
|
|
|
|
,url: forumTags //帖子分类接口
|
|
|
|
|
,cols: [[
|
|
|
|
|
{type: 'numbers', fixed: 'left'}
|
|
|
|
|
,{field: 'sort', title: '排序', width: 80, sort: true}
|
|
|
|
|
,{field: 'id', title: 'ID',width: 60}
|
|
|
|
|
,{field: 'tags', title: '分类名', minWidth: 100}
|
|
|
|
|
,{field: 'ename', title: 'EN别名', minWidth: 100}
|
2021-07-22 10:50:56 +08:00
|
|
|
|
,{
|
|
|
|
|
title: '图标', align: 'center',
|
|
|
|
|
templet: '<p><i class="layui-icon {{d.icon}}"></i></p>'
|
|
|
|
|
}
|
2020-04-28 18:44:40 +08:00
|
|
|
|
,{field: 'is_hot', title: '热门', templet: '#buttonHot'}
|
|
|
|
|
,{field: 'desc', title: '描述', minWidth: 100}
|
2021-07-22 10:50:56 +08:00
|
|
|
|
,{title: '操作', width: 100, align: 'center', toolbar: '#layuiadmin-app-cont-tagsbar'}
|
2020-04-28 18:44:40 +08:00
|
|
|
|
]]
|
|
|
|
|
,text: '对不起,加载出现异常!'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//监听工具条
|
|
|
|
|
table.on('tool(LAY-app-content-tags)', function(obj){
|
|
|
|
|
var data = obj.data;
|
|
|
|
|
if(obj.event === 'del'){
|
|
|
|
|
layer.confirm('确定删除此分类?', function(index){
|
|
|
|
|
$.ajax({
|
|
|
|
|
type:'post',
|
|
|
|
|
url:forumTagsDelete,
|
|
|
|
|
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
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//obj.del();
|
|
|
|
|
layer.close(index);
|
|
|
|
|
});
|
|
|
|
|
} else if(obj.event === 'edit'){
|
|
|
|
|
var tr = $(obj.tr);
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2
|
|
|
|
|
,title: '编辑分类'
|
|
|
|
|
,content: forumTagsForm + '?id='+ data.id
|
2021-07-22 10:50:56 +08:00
|
|
|
|
,area: ['400px', '450px']
|
2020-04-28 18:44:40 +08:00
|
|
|
|
,btn: ['确定', '取消']
|
|
|
|
|
,yes: function(index, layero){
|
|
|
|
|
//获取iframe元素的值
|
|
|
|
|
var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags")
|
|
|
|
|
,sort = othis.find('input[name="sort"]').val()
|
|
|
|
|
,tags = othis.find('input[name="tags"]').val()
|
|
|
|
|
,ename = othis.find('input[name="ename"]').val()
|
2021-07-22 10:50:56 +08:00
|
|
|
|
,icon = othis.find('input[name="icon"]').val()
|
2020-04-28 18:44:40 +08:00
|
|
|
|
,desc = othis.find('input[name="desc"]').val();
|
|
|
|
|
|
|
|
|
|
if(!tags.replace(/\s/g, '')) return;
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type:"post",
|
|
|
|
|
url:forumTagsForm,
|
2021-07-22 10:50:56 +08:00
|
|
|
|
data:{"id":data.id,"sort":sort,"catename":tags,"ename":ename,"icon":icon,"desc":desc},
|
2020-04-28 18:44:40 +08:00
|
|
|
|
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
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
/*
|
|
|
|
|
obj.update({
|
|
|
|
|
tags: tags
|
|
|
|
|
,ename: ename
|
|
|
|
|
,sort: sort
|
|
|
|
|
});
|
|
|
|
|
*/
|
|
|
|
|
layer.close(index);
|
|
|
|
|
}
|
|
|
|
|
,success: function(layero, index){
|
|
|
|
|
//给iframe元素赋值
|
|
|
|
|
var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags").click();
|
|
|
|
|
othis.find('input[name="sort"]').val(data.sort)
|
|
|
|
|
,othis.find('input[name="tags"]').val(data.tags)
|
|
|
|
|
,othis.find('input[name="ename"]').val(data.ename)
|
2021-07-22 10:50:56 +08:00
|
|
|
|
,othis.find('input[name="icon"]').val(data.icon)
|
2020-04-28 18:44:40 +08:00
|
|
|
|
,othis.find('input[name="desc"]').val(data.desc);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
|
|
|
|
exports('forum', {})
|
|
|
|
|
});
|