|
@@ -0,0 +1,105 @@
|
|
|
+{extend name='table'}
|
|
|
+
|
|
|
+{block name="button"}
|
|
|
+{if auth("add")}
|
|
|
+<button data-open='{:url("add")}' class='layui-btn layui-btn-sm layui-btn-primary'>添加新闻</button>
|
|
|
+{/if}
|
|
|
+
|
|
|
+<!--{if auth("remove")}-->
|
|
|
+<button data-action='{:url("remove")}' data-table-id="NewsTable" data-rule="id#{id}" data-confirm="确定要批量删除新闻吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
|
|
|
+<!--{/if}-->
|
|
|
+{/block}
|
|
|
+
|
|
|
+{block name="content"}
|
|
|
+<div class="layui-tab layui-tab-card">
|
|
|
+ <ul class="layui-tab-title">
|
|
|
+ {foreach ['index'=>'新闻管理',] as $k=>$v}{if isset($type) and $type eq $k}
|
|
|
+ <li data-open="{:url('index')}?type={$k}" class="layui-this">{$v}</li>
|
|
|
+ {else}
|
|
|
+ <li data-open="{:url('index')}?type={$k}">{$v}</li>
|
|
|
+ {/if}{/foreach}
|
|
|
+ </ul>
|
|
|
+ <div class="layui-tab-content">
|
|
|
+ {include file='xw/index_search'}
|
|
|
+ <table id="NewsTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+{/block}
|
|
|
+
|
|
|
+{block name='script'}
|
|
|
+<script>
|
|
|
+ $(function () {
|
|
|
+ // 初始化表格组件
|
|
|
+ $('#NewsTable').layTable({
|
|
|
+ even: true, height: 'full',
|
|
|
+ sort: {field: 'id desc', type: 'desc'},
|
|
|
+ where: {},
|
|
|
+ cols: [[
|
|
|
+ {checkbox: true, fixed: true},
|
|
|
+ {field: 'id', title: 'ID', align: "center", width: 80},
|
|
|
+ {field: 'category.name', title: '分类', align: "center", width: 80,templet(d){
|
|
|
+ return d.category.name
|
|
|
+ }},
|
|
|
+ {
|
|
|
+ field: 'images', title: '封面', align: 'center', templet: function (d) {
|
|
|
+ if (!d.images) return '';
|
|
|
+ let a=[]
|
|
|
+ d.images.split('|').forEach(i=>{
|
|
|
+ let b= layui.laytpl(`<div data-tips-image data-tips-hover class="headimg headimg-xs headimg-no margin-0" data-lazy-src="${i}"></div>`).render(d);
|
|
|
+ a.push(b)
|
|
|
+ })
|
|
|
+ return a.join('')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {field: 'title', title: '新闻标题', align: 'left', minWidth: 140},
|
|
|
+ {field: 'source', title: '来源', align: 'center', minWidth: 80, style: 'color:blue;font-size:16px'},
|
|
|
+ {field: 'status', title: '状态', align: 'center', minWidth: 110, templet: '#StatusSwitchTpl'},
|
|
|
+ {field: 'likes_count', title: '点赞',align: 'center'},
|
|
|
+ {field: 'comments_count', title: '评论数',align: 'center'},
|
|
|
+ {field: 'create_time', title: '创建时间', align: 'center', minWidth: 170, sort: true},
|
|
|
+ {field: 'update_time', title: '更新时间', align: 'center', minWidth: 170, sort: true},
|
|
|
+ {toolbar: '#toolbar', title: '操作面板', align: 'center', minWidth: 80, fixed: 'right'},
|
|
|
+ ]]
|
|
|
+ });
|
|
|
+
|
|
|
+ // 数据状态切换操作
|
|
|
+ layui.form.on('switch(StatusSwitch)', function (obj) {
|
|
|
+ var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
|
|
|
+ $.form.load("{:url('state')}", data, 'post', function (ret) {
|
|
|
+ if (ret.code < 1) $.msg.error(ret.info, 3, function () {
|
|
|
+ $('#NewsTable').trigger('reload');
|
|
|
+ }); else {
|
|
|
+ $('#NewsTable').trigger('reload');
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }, false);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<!-- 列表排序权重模板 -->
|
|
|
+<script type="text/html" id="SortInputTpl">
|
|
|
+ <input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
|
|
|
+</script>
|
|
|
+
|
|
|
+<!-- 数据状态切换模板 -->
|
|
|
+<script type="text/html" id="StatusSwitchTpl">
|
|
|
+ <!--{if auth("state")}-->
|
|
|
+ <input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{-d.status>0?'checked':''}}>
|
|
|
+ <!--{else}-->
|
|
|
+ {{-d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}
|
|
|
+ <!--{/if}-->
|
|
|
+</script>
|
|
|
+
|
|
|
+<!-- 数据操作工具条模板 -->
|
|
|
+<script type="text/html" id="toolbar">
|
|
|
+ <!--{if auth("edit")}-->
|
|
|
+ <a class="layui-btn layui-btn-primary layui-btn-sm" data-open='{:url("edit")}?id={{d.id}}'>编 辑</a>
|
|
|
+ <!--{/if}-->
|
|
|
+
|
|
|
+ <!--{if auth("remove")}-->
|
|
|
+ <a class="layui-btn layui-btn-danger layui-btn-sm" data-action="{:url('remove')}" data-value="id#{{d.id}}" data-confirm="确定要删除吗?">删 除</a>
|
|
|
+ <!--{/if}-->
|
|
|
+</script>
|
|
|
+{/block}
|