112 lines
2.9 KiB
HTML

{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<form class="layui-form gg-form-bar border-t border-x">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="ID/分类名" class="layui-input" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="sitemap" lay-filter="sitemap"></table>
</div>
<script type="text/html" id="status">
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="add">+ 添加网站地图分类</button>
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-xs layui-btn-normal" href="/admin/sitemap/sitemap_info?id={{d.id}}"></a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"></a></div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#sitemap',
title: '网站地图分类列表',
toolbar: '#toolbarDemo',
url: '/admin/sitemap/index', //数据接口
page: true, //开启分页
limit: 20,
cols: [
[ //表头
{
field: 'id',
title: 'ID号',
align: 'center',
width: 80
}, {
field: 'sort',
title: '排序',
align: 'center',
width: 80
}, {
field: 'name',
title: '网站地图分类名称'
}, {
field: 'right',
title: '操作',
toolbar: '#barDemo',
align: 'center',
width: 200
}
]
]
});
//表头工具栏事件
table.on('toolbar(sitemap)', function (obj) {
if (obj.event === 'add') {
tool.side("/admin/sitemap/add", "900px");
return;
}
});
//监听行工具事件
table.on('tool(sitemap)', function (obj) {
var data = obj.data;
if (obj.event === 'edit') {
tool.side('/admin/sitemap/add?id=' + obj.data.id, "900px");
return;
}
if (obj.event === 'del') {
layer.confirm('确定要删除该数据吗?', {
icon: 3,
title: '提示'
}, function (index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete("/admin/sitemap/delete", { id: data.id }, callback);
layer.close(index);
});
}
});
//监听搜索提交
form.on('submit(webform)', function (data) {
layui.pageTable.reload({
where: {
keywords: data.field.keywords
},
page: {
curr: 1
}
});
return false;
});
}
</script>
{/block}
<!-- /脚本 -->