推送更新
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
{include file="public/header" /}
|
||||
<div class="config-container">
|
||||
<!-- 页面头部样式 -->
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-notice"></i>
|
||||
<span>内容推送列表</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div>
|
||||
<button class="layui-btn layui-bg-blue" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加推送
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="contentPushTable" lay-filter="contentPushTable"></table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
layui.use(['table', 'layer'], function () {
|
||||
var table = layui.table;
|
||||
var layer = layui.layer;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// 初始化表格
|
||||
table.render({
|
||||
elem: '#contentPushTable',
|
||||
url: '{$config["admin_route"]}yunzeradmin/contentpushlist',
|
||||
page: true,
|
||||
cols: [[
|
||||
{field: 'id', title: 'ID', width: 80, sort: true},
|
||||
{field: 'title', title: '标题', width: 200},
|
||||
{field: 'type', title: '类型', width: 100, templet: function(d){
|
||||
return d.type == 1 ? '普通推送' : '重要推送';
|
||||
}},
|
||||
{field: 'status', title: '状态', width: 100, templet: function(d){
|
||||
return d.status == 1 ?
|
||||
'<span class="layui-badge layui-bg-green">启用</span>' :
|
||||
'<span class="layui-badge">禁用</span>';
|
||||
}},
|
||||
{field: 'sort', title: '排序', width: 100, sort: true},
|
||||
{field: 'create_time', title: '创建时间', width: 180},
|
||||
{title: '操作', width: 200, toolbar: '#tableBar', fixed: 'right'}
|
||||
]],
|
||||
limit: 10,
|
||||
limits: [10, 20, 30, 50]
|
||||
});
|
||||
|
||||
// 监听工具条
|
||||
table.on('tool(contentPushTable)', function(obj){
|
||||
var data = obj.data;
|
||||
if(obj.event === 'edit'){
|
||||
edit(data.id);
|
||||
} else if(obj.event === 'del'){
|
||||
del(data.id);
|
||||
} else if(obj.event === 'status'){
|
||||
changeStatus(data.id, data.status);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 添加
|
||||
function add() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '添加内容推送',
|
||||
shade: 0.3,
|
||||
area: ['800px', '600px'],
|
||||
content: "{$config['admin_route']}yunzeradmin/contentpushadd"
|
||||
});
|
||||
}
|
||||
|
||||
// 编辑
|
||||
function edit(id) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '编辑内容推送',
|
||||
shade: 0.3,
|
||||
area: ['800px', '600px'],
|
||||
content: "{$config['admin_route']}yunzeradmin/contentpushedit?id=" + id
|
||||
});
|
||||
}
|
||||
|
||||
// 删除
|
||||
function del(id) {
|
||||
layer.confirm('确定要删除这条推送吗?', {
|
||||
icon: 3,
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
$.post("{$config['admin_route']}yunzeradmin/contentpushdel", { 'id': id }, function (res) {
|
||||
if (res.code > 0) {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
layui.table.reload('contentPushTable');
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
}
|
||||
|
||||
// 修改状态
|
||||
function changeStatus(id, status) {
|
||||
var newStatus = status == 1 ? 0 : 1;
|
||||
$.post("{$config['admin_route']}yunzeradmin/contentpushstatus", {
|
||||
'id': id,
|
||||
'status': newStatus
|
||||
}, function (res) {
|
||||
if (res.code > 0) {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
layui.table.reload('contentPushTable');
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
// 刷新列表
|
||||
function refresh() {
|
||||
layui.table.reload('contentPushTable');
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- 表格操作列模板 -->
|
||||
<script type="text/html" id="tableBar">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="status">状态</a>
|
||||
</script>
|
||||
|
||||
{include file="public/tail" /}
|
||||
Reference in New Issue
Block a user