| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <div class="layui-fluid">
- <div class="layui-card">
- <div class="layui-form layui-form-pane layui-card-header layuiadmin-card-header-auto" lay-filter="LAY-artapp-article-commentlist-search">
- <div class="layui-form-item">
- <div class="layui-inline">
- <label class="layui-form-label">标题</label>
- <div class="layui-input-block">
- <input type="text" name="keywords" placeholder="请输入" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-inline">
- <label class="layui-form-label">状态</label>
- <div class="layui-input-block">
- <select name="status">
- <option value="">全部状态</option>
- <option value="1">已通过</option>
- <option value="2">待审核</option>
- </select>
- </div>
- </div>
- <div class="layui-inline">
- <button class="layui-btn" lay-submit lay-filter="LAY-artapp-article-commentlist-search-btn">
- <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;">
- <button class="layui-btn layuiadmin-btn" data-type="batchdel">删除</button>
- <button class="layui-btn layuiadmin-btn" data-type="batchstatus">批量审核通过</button>
- </div>
-
- <table id="LAY-artapp-article-commentlist-table" lay-filter="LAY-artapp-article-commentlist-table"></table>
- <script type="text/html" id="useravatarTpl">
- <img style="width: 100%; height: 100%;" src="{{d.user.avatar}}" alt="{{d.user.nickname}}">
- </script>
- <script type="text/html" id="usernicknameTpl">
- {{d.user.nickname}}
- </script>
- <script type="text/html" id="detailsTpl">
- {{# if(d.puserid == 0){ }}
- {{d.details}}
- {{# } else { }}
- 回复{{d.puser.nickname}}:{{d.details}}
- {{# } }}
- </script>
- <script type="text/html" id="statusTpl">
- {{# if(d.status == 1){ }}
- 已通过
- {{# } else { }}
- 待审核
- {{# } }}
- </script>
- <script type="text/html" id="setTpl">
- {{# if(d.status == 1){ }}
- <a class="layui-btn layui-btn-xs" lay-event="setstatus"><i class="layui-icon layui-icon-ok"></i>已通过</a>
- {{# } else { }}
- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="setstatus"><i class="layui-icon layui-icon-edit"></i>待审核</a>
- {{# } }}
- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delcomment"><i class="layui-icon layui-icon-delete"></i>删除</a>
- </script>
- </div>
-
- </div>
- </div>
-
- <script>
- layui.config({
- base: '/static/echoui/' //静态资源所在路径
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'form', 'set', 'table'], function() {
- var $ = layui.$,
- setter = layui.setter,
- admin = layui.admin,
- form = layui.form,
- table = layui.table;
- form.render();
-
- table.render({
- elem: '#LAY-artapp-article-commentlist-table',
- url: setter.baseAdminUrl + 'article/listcomment',
- cols: [[
- {type: 'checkbox', fixed: 'left'},
- {field: 'id', width: 80, title: '表ID', sort: true},
- {field: 'useravatar', width: 60, title: '头像', templet: '#useravatarTpl'},
- {field: 'usernickname', width: 150, title: '昵称', templet: '#usernicknameTpl'},
- {field: 'details', title: '内容', templet: '#detailsTpl', edit: 'text'},
- {field: 'status', width: 160, title: '状态', templet: '#statusTpl'},
- {field: 'createtime', width: 160, title: '发布时间', sort: true},
- {title: '操作', width: 200, align: 'center', fixed: 'right', toolbar: '#setTpl'}
- ]],
- page: true,
- limit: 50,
- cellMinWidth: 150,
- text: '对不起,加载出现异常!'
- });
-
- form.on('submit(LAY-artapp-article-commentlist-search-btn)', function(data) {
- table.reload('LAY-artapp-article-commentlist-table', {
- where: data.field,
- page: {
- curr: 1
- }
- });
- });
-
- table.on('edit(LAY-artapp-article-commentlist-table)', function(obj){
- var id = obj.data.id,
- field = obj.field,
- value = obj.value;
- admin.req({
- url: setter.baseAdminUrl + 'article/fieldcomment',
- data: {id: id, field: field, value: value},
- done: function(res) {
- layer.msg('修改成功');
- }
- });
- });
-
- table.on('tool(LAY-artapp-article-commentlist-table)', function(obj) {
- var data = obj.data;
- if (obj.event === 'delcomment') {
- layer.confirm('确定删除此评论吗?', function(index) {
- admin.req({
- url: setter.baseAdminUrl + 'article/delcomment',
- data: {
- idarr: [data.id]
- },
- done: function(res) {
- obj.del();
- layer.msg('已删除');
- }
- });
- layer.close(index);
- });
- } else if (obj.event === 'setstatus') {
- admin.req({
- url: setter.baseAdminUrl + 'article/statuscomment',
- data: {id: data.id},
- done: function(res) {
- layer.msg('状态修改成功');
- layui.table.reload('LAY-artapp-article-commentlist-table');
- }
- });
- }
- });
-
- var active = {
- batchdel: function() {
- var checkStatus = table.checkStatus('LAY-artapp-article-commentlist-table'),
- checkData = checkStatus.data; //得到选中的数据
- if (checkData.length === 0) {
- return layer.msg('请选择数据');
- }
- var idarr = [];
- for (var i = 0; i < checkData.length; i++) {
- idarr.push(checkData[i].id);
- }
- layer.confirm('确定删除所选评论吗?', function(index) {
- admin.req({
- url: setter.baseAdminUrl + 'article/delcomment',
- data: {
- idarr: idarr
- },
- done: function(res) {
- table.reload('LAY-artapp-article-commentlist-table');
- layer.msg('已删除');
- }
- });
- layer.close(index);
- });
- },
- batchstatus: function() {
- var checkStatus = table.checkStatus('LAY-artapp-article-commentlist-table'),
- checkData = checkStatus.data; //得到选中的数据
- if (checkData.length === 0) {
- return layer.msg('请选择数据');
- }
- var idarr = [];
- for (var i = 0; i < checkData.length; i++) {
- idarr.push(checkData[i].id);
- }
- layer.confirm('确定批量通过所选评论吗?', function(index) {
- admin.req({
- url: setter.baseAdminUrl + 'article/statuscommentall',
- data: {
- idarr: idarr
- },
- done: function(res) {
- table.reload('LAY-artapp-article-commentlist-table');
- layer.msg('已审核通过');
- }
- });
- layer.close(index);
- });
- }
- };
-
- $('.layui-btn.layuiadmin-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
-
- });
- </script>
|