2020-01-01 13:17:19 +08:00
|
|
|
|
{extend name="public:base" /}
|
|
|
|
|
|
|
|
|
|
{block name="body"}
|
|
|
|
|
<div class="layui-fluid">
|
|
|
|
|
<div class="layui-card">
|
|
|
|
|
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
|
|
|
|
<div class="layui-form-item">
|
|
|
|
|
<div class="layui-inline">
|
2021-06-09 14:48:38 +08:00
|
|
|
|
<label class="layui-form-label">帖子ID</label>
|
2020-01-01 13:17:19 +08:00
|
|
|
|
<div class="layui-input-block">
|
|
|
|
|
<input type="text" name="id" placeholder="请输入" autocomplete="off" class="layui-input">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
<label class="layui-form-label">发帖人</label>
|
|
|
|
|
<div class="layui-input-block">
|
2020-02-24 16:49:43 +08:00
|
|
|
|
<input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
|
2020-01-01 13:17:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
2021-06-09 14:48:38 +08:00
|
|
|
|
<label class="layui-form-label">标题</label>
|
2020-01-01 13:17:19 +08:00
|
|
|
|
<div class="layui-input-block">
|
2020-02-24 16:49:43 +08:00
|
|
|
|
<input type="text" name="title" placeholder="请输入" autocomplete="off" class="layui-input">
|
2020-01-01 13:17:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
2021-06-09 14:48:38 +08:00
|
|
|
|
<label class="layui-form-label">状态</label>
|
2020-01-01 13:17:19 +08:00
|
|
|
|
<div class="layui-input-block">
|
2020-02-24 16:49:43 +08:00
|
|
|
|
<select name="sec">
|
2021-12-15 15:46:04 +08:00
|
|
|
|
<option value="">选择状态</option>
|
2020-02-24 16:49:43 +08:00
|
|
|
|
<option value="1">正常</option>
|
2021-12-15 15:46:04 +08:00
|
|
|
|
<option value="5">禁止</option>
|
|
|
|
|
<option value="6">待审</option>
|
2020-02-24 16:49:43 +08:00
|
|
|
|
<option value="2">置顶</option>
|
2021-12-15 15:46:04 +08:00
|
|
|
|
<option value="3">加精</option>
|
|
|
|
|
<option value="4">禁评</option>
|
2020-01-01 13:17:19 +08:00
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
<button class="layui-btn layuiadmin-btn-forum-list" lay-submit lay-filter="LAY-app-forumlist-search">
|
|
|
|
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="layui-card-body">
|
|
|
|
|
<div style="padding-bottom: 10px;">
|
2022-08-16 15:19:21 +08:00
|
|
|
|
<button class="layui-btn layuiadmin-btn-forum-list" data-type="add">添加</button>
|
|
|
|
|
<button class="layui-btn layuiadmin-btn-forum-list" data-type="batchdel">删除</button>
|
2020-01-01 13:17:19 +08:00
|
|
|
|
</div>
|
2022-08-02 20:48:54 +08:00
|
|
|
|
<table id="LAY-app-forum-list" lay-filter="LAY-app-forum-list" ></table>
|
|
|
|
|
<script type="text/html" id="avatarTpl">
|
|
|
|
|
<div><img style="width: 25px; height: 25px;" src= "{{ d.avatar }}"></div>
|
2021-12-15 15:46:04 +08:00
|
|
|
|
</script>
|
2020-01-01 13:17:19 +08:00
|
|
|
|
<script type="text/html" id="buttonTpl">
|
2022-08-02 20:48:54 +08:00
|
|
|
|
<input type="checkbox" name="is_top" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="isTop" {{ d.top == 1 ? 'checked' : '' }}>
|
2020-02-27 14:14:09 +08:00
|
|
|
|
</script>
|
2022-08-02 20:48:54 +08:00
|
|
|
|
<script type="text/html" id="buttonHot">
|
|
|
|
|
<input type="checkbox" name="is_hot" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="isHot" {{ d.hot == 1 ? 'checked' : '' }}>
|
2020-02-27 14:14:09 +08:00
|
|
|
|
</script>
|
2022-08-02 20:48:54 +08:00
|
|
|
|
<script type="text/html" id="buttonReply">
|
|
|
|
|
<input type="checkbox" name="is_reply" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="isReply" {{ d.reply == 0 ? 'checked' : '' }}>
|
|
|
|
|
</script>
|
|
|
|
|
<script type="text/html" id="buttonCheck">
|
|
|
|
|
<input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-filter="artStatus" lay-text="通过|{{ d.check == 0 ? '待审' : '禁止' }}" {{ d.check == 1 ? 'checked' : '' }}>
|
2020-01-14 15:47:11 +08:00
|
|
|
|
</script>
|
2020-01-01 13:17:19 +08:00
|
|
|
|
<script type="text/html" id="table-forum-list">
|
2022-08-16 15:19:21 +08:00
|
|
|
|
<a class="layui-btn layui-btn-xs" lay-event="edit" ><i class="layui-icon layui-icon-edit"></i></a>
|
2022-04-19 17:26:10 +08:00
|
|
|
|
{if condition="checkRuleButton('forum/listdel')"}
|
2021-06-17 14:25:48 +08:00
|
|
|
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i></a>
|
2021-12-15 15:46:04 +08:00
|
|
|
|
{else /}<a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled"><i class="layui-icon layui-icon-delete"></i></a>{/if}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
</script>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/block}
|
|
|
|
|
|
|
|
|
|
{block name="js"}
|
2022-08-16 15:19:21 +08:00
|
|
|
|
|
2020-04-28 18:44:40 +08:00
|
|
|
|
<script>
|
2022-08-02 20:48:54 +08:00
|
|
|
|
var forumList = "{:url('Forum/list')}",
|
|
|
|
|
forumListdel = "{:url('Forum/listdel')}",
|
|
|
|
|
forumListform = "{:url('Forum/listform')}",
|
|
|
|
|
forumReplys = "{:url('Forum/replys')}",
|
|
|
|
|
forumRedel = "{:url('Forum/redel')}",
|
2020-04-28 18:44:40 +08:00
|
|
|
|
forumReplysform = "{:url('Forum/replysform')}",
|
2022-08-02 20:48:54 +08:00
|
|
|
|
forumTags = "{:url('Forum/tags')}",
|
2020-04-28 18:44:40 +08:00
|
|
|
|
forumTagsDelete = "{:url('Forum/tagsdelete')}",
|
2022-08-02 20:48:54 +08:00
|
|
|
|
forumTagsForm = "{:url('Forum/tagsform')}";
|
2022-08-16 15:19:21 +08:00
|
|
|
|
forumEdit = "{:url('Forum/edit')}";
|
2022-08-02 20:48:54 +08:00
|
|
|
|
layui.config({
|
|
|
|
|
base: '/static/admin/' //静态资源所在路径
|
|
|
|
|
}).extend({
|
|
|
|
|
index: 'lib/index' //主入口模块
|
|
|
|
|
}).use(['index', 'forum', 'table'], function(){
|
|
|
|
|
var $ = layui.$
|
|
|
|
|
,form = layui.form
|
|
|
|
|
,table = layui.table;
|
|
|
|
|
|
|
|
|
|
// 监听搜索
|
|
|
|
|
form.on('submit(LAY-app-forumlist-search)', function(data){
|
|
|
|
|
var field = data.field;
|
|
|
|
|
$.post("{:url('Forum/list')}",field);
|
|
|
|
|
//执行重载
|
|
|
|
|
table.reload('LAY-app-forum-list', {
|
|
|
|
|
where: field
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 监听置顶
|
|
|
|
|
form.on('switch(isTop)', function(obj){
|
|
|
|
|
$.post("{:url('Forum/check')}",{id:obj.value, name:obj.elem.name,value:obj.elem.checked ? 1 : 0},function(res){
|
|
|
|
|
layer.tips(obj.value + ' ' + obj.elem.name + ':'+ obj.elem.checked, obj.othis);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 监听加精
|
|
|
|
|
form.on('switch(isHot)', function(obj){
|
|
|
|
|
$.post("{:url('Forum/check')}",{id:obj.value, name:obj.elem.name,value: obj.elem.checked ? 1 : 0},function(res){
|
|
|
|
|
layer.tips(obj.value + ' ' + obj.elem.name + ':'+ obj.elem.checked, obj.othis);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 监听回复
|
|
|
|
|
form.on('switch(isReply)', function(obj){
|
|
|
|
|
$.post("{:url('Forum/check')}",{id:obj.value, name:obj.elem.name,value: obj.elem.checked ? 0 : 1},function(res){
|
|
|
|
|
layer.tips(obj.value + ' ' + obj.elem.name + ':'+ obj.elem.checked, obj.othis);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 监听审贴
|
|
|
|
|
form.on('switch(artStatus)', function(obj){
|
|
|
|
|
//layer.tips(obj.value + ' ' + obj.elem.name + ':'+ obj.elem.checked, obj.othis);
|
|
|
|
|
$.post("{:url('Forum/check')}",{id:obj.value, name:obj.elem.name,value: obj.elem.checked ? 1 : -1},function(res){
|
|
|
|
|
if(res.code == 0){
|
|
|
|
|
layer.msg(res.msg,{icon:res.icon,time:2000})
|
|
|
|
|
} else {
|
|
|
|
|
layer.open({title:'审核失败',content:res.msg,icon:5,adim:6})
|
|
|
|
|
}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
});
|
2022-08-02 20:48:54 +08:00
|
|
|
|
});
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
2022-08-02 20:48:54 +08:00
|
|
|
|
//事件
|
|
|
|
|
var active = {
|
|
|
|
|
batchdel: function(){
|
|
|
|
|
var checkStatus = table.checkStatus('LAY-app-forum-list')
|
|
|
|
|
,checkData = checkStatus.data; //得到选中的数据
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
2022-08-02 20:48:54 +08:00
|
|
|
|
if(checkData.length === 0){
|
|
|
|
|
return layer.msg('请选择数据');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layer.confirm('确定删除吗?', function(index) {
|
|
|
|
|
//获取所选id
|
|
|
|
|
var idsArray = [];
|
|
|
|
|
for (var i = 0; i < checkData.length; i++) {
|
|
|
|
|
idsArray.push(checkData[i].id);
|
2020-01-01 13:17:19 +08:00
|
|
|
|
}
|
2022-08-02 20:48:54 +08:00
|
|
|
|
var ids = idsArray.toString();
|
|
|
|
|
|
|
|
|
|
//执行 Ajax 后重载
|
|
|
|
|
$.post("{:url('Forum/listdel')}",{"id": ids},function(res){
|
|
|
|
|
if(res.code == 0){
|
|
|
|
|
layer.msg('删除成功', {icon: 1,shade: 0});
|
2021-10-12 16:46:49 +08:00
|
|
|
|
}
|
2020-01-01 13:17:19 +08:00
|
|
|
|
});
|
2022-08-02 20:48:54 +08:00
|
|
|
|
|
|
|
|
|
table.reload('LAY-app-forum-list');
|
|
|
|
|
layer.msg('已删除');
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-08-16 15:19:21 +08:00
|
|
|
|
,add: function(){
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2
|
|
|
|
|
,title: '添加'
|
|
|
|
|
,content: 'add.html'
|
|
|
|
|
,maxmin: true
|
|
|
|
|
,area: ['100%', '100%']
|
|
|
|
|
,btn: ['确定', '取消']
|
|
|
|
|
,yes: function(index, layero){
|
|
|
|
|
var iframeWindow = window['layui-layer-iframe'+ index]
|
|
|
|
|
,submitID = 'article-add'
|
|
|
|
|
,submit = layero.find('iframe').contents().find('#'+ submitID);
|
|
|
|
|
|
|
|
|
|
//监听提交
|
|
|
|
|
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
|
|
|
|
|
var field = data.field; //获取提交的字段
|
|
|
|
|
|
2022-08-16 15:21:08 +08:00
|
|
|
|
// tag
|
|
|
|
|
var numArr = new Array();
|
|
|
|
|
layero.find('iframe').contents().find(".layui-btn-container").children("button").each(function () {
|
|
|
|
|
numArr.push($(this).val()); //添加至数组
|
|
|
|
|
});
|
|
|
|
|
field.tags = numArr.lenth ? "" : numArr.join(",");
|
|
|
|
|
|
2022-08-16 15:19:21 +08:00
|
|
|
|
//提交 Ajax 成功后,静态更新表格中的数据
|
|
|
|
|
$.ajax({
|
|
|
|
|
type:"post",
|
|
|
|
|
url:"{:url('Forum/add')}",
|
|
|
|
|
data: field,
|
|
|
|
|
daType:"json",
|
|
|
|
|
success:function (data){
|
|
|
|
|
if (data.code == 0) {
|
|
|
|
|
layer.msg(data.msg,{
|
|
|
|
|
icon:6,
|
|
|
|
|
time:2000
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
layer.open({
|
|
|
|
|
tiele:'添加失败',
|
|
|
|
|
content:data.msg,
|
|
|
|
|
icon:5,
|
|
|
|
|
anim:6
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
table.reload('LAY-app-forum-list'); //数据刷新
|
|
|
|
|
layer.close(index); //关闭弹层
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
submit.trigger('click');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-08-02 20:48:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('.layui-btn.layuiadmin-btn-forum-list').on('click', function(){
|
|
|
|
|
var type = $(this).data('type');
|
|
|
|
|
active[type] ? active[type].call(this) : '';
|
2020-01-01 13:17:19 +08:00
|
|
|
|
});
|
2022-08-16 15:19:21 +08:00
|
|
|
|
|
|
|
|
|
// $(document).on('focusin', function(e) {
|
|
|
|
|
// if ($(e.target).closest(".tox-tinymce, .tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length) {
|
|
|
|
|
// e.stopImmediatePropagation();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
2022-08-02 20:48:54 +08:00
|
|
|
|
});
|
2020-04-28 18:44:40 +08:00
|
|
|
|
</script>
|
2020-01-01 13:17:19 +08:00
|
|
|
|
{/block}
|