2021-11-15 23:51:08 +08:00
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
2021-11-29 16:04:07 +08:00
< div class = "body-table" >
2021-11-15 23:51:08 +08:00
< table class = "layui-hide" id = "test" lay-filter = "test" > < / 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" >
2021-11-17 00:10:16 +08:00
< div class = "layui-btn-container" >
2021-11-23 17:04:53 +08:00
< button class = "layui-btn layui-btn-normal layui-btn-sm" lay-event = "add" > + 添加配置项< / button >
2021-11-15 23:51:08 +08:00
< / div >
< / script >
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
< script >
2021-11-27 11:13:29 +08:00
var tableIns = null;
2021-11-15 23:51:08 +08:00
function init(layui) {
var table = layui.table,
2021-11-23 17:04:53 +08:00
rightpage = layui.rightpage,
2021-11-15 23:51:08 +08:00
form = layui.form;
2021-11-27 11:13:29 +08:00
tableIns = table.render({
2021-11-15 23:51:08 +08:00
elem: '#test',
title: '配置列表',
toolbar: '#toolbarDemo',
url: "{:url('home/conf/index')}",
page: true, //开启分页
limit: 20,
cols: [
[{
field: 'id',
width: 80,
title: 'ID编号',
align: 'center'
},{
field: 'title',
2021-11-16 23:54:15 +08:00
width: 200,
2021-11-15 23:51:08 +08:00
title: '配置名称'
}, {
field: 'name',
title: '配置标识(新增的模板文件名称需与标识名称一致)'
},{
field: 'status',
width: 80,
title: '状态',
templet: '#status',
align: 'center'
}, {
width: 160,
title: '操作',
align: 'center',
templet: function (d) {
2021-11-23 17:04:53 +08:00
var html = '< div class = "layui-btn-group" > < button class = "layui-btn layui-btn-xs" lay-event = "add" > 修改< / button > < button class = "layui-btn layui-btn-normal layui-btn-xs" lay-event = "edit" > 编辑配置< / button > < button class = "layui-btn layui-btn-danger layui-btn-xs" lay-event = "del" > 删除< / button > < / div > ';
2021-11-15 23:51:08 +08:00
return html;
}
}]
]
});
2021-11-23 17:04:53 +08:00
//监听行工具事件
table.on('tool(test)', function(obj){
var data = obj.data;
if(obj.event === 'add'){
rightpage.open('/home/conf/add?id='+data.id);
return;
}
if(obj.event === 'edit'){
rightpage.open('/home/conf/edit?id='+data.id);
return;
2021-11-15 23:51:08 +08:00
}
if (obj.event === 'del') {
layer.confirm('确定要删除吗?', {
icon: 3,
title: '提示'
}, function (index) {
$.ajax({
url: "{:url('home/conf/delete')}",
type: 'post',
data: {
id: obj.data.id
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
obj.del();
}
}
})
layer.close(index);
});
}
});
2021-11-23 17:04:53 +08:00
//表头工具栏事件
table.on('toolbar(test)', function(obj){
if (obj.event === 'add') {
rightpage.open("{:url('home/conf/add')}");
return;
}
});
//监听搜索提交
form.on('submit(webform)', function (data) {
if (data.field.keywords) {
tableIns.reload({
where: {
keywords: data.field.keywords
},
page: {
curr: 1
}
});
} else {
location.reload();
}
return false;
});
2021-11-15 23:51:08 +08:00
}
< / script >
2021-11-23 17:04:53 +08:00
{include file="common/layui" base="base" extend="['rightpage']" callback="init" /}
2021-11-15 23:51:08 +08:00
{/block}
<!-- /脚本 -->