2022-02-11 13:23:31 +08:00
{extend name="../../base/view/common/base" /}
2021-11-15 23:51:08 +08:00
<!-- 主体 -->
{block name="body"}
2022-06-26 19:53:28 +08:00
< div class = "p-3" >
< form class = "layui-form gg-form-bar border-x border-t" >
2021-11-15 23:51:08 +08:00
< div class = "layui-input-inline" style = "width:300px;" >
< input type = "text" name = "keywords" placeholder = "关键字名称" class = "layui-input" autocomplete = "off" / >
< / div >
2023-05-18 12:26:49 +08:00
< div class = "layui-input-inline" style = "width:150px;" >
< button class = "layui-btn layui-btn-normal" lay-submit = "" lay-filter = "webform" > < i class = "layui-icon layui-icon-search mr-1" > < / i > 搜索< / button >
< button type = "reset" class = "layui-btn layui-btn-reset" lay-filter = "reset" > 清空< / button >
< / div >
2021-11-15 23:51:08 +08:00
< / form >
2022-06-26 19:53:28 +08:00
< table class = "layui-hide" id = "test" lay-filter = "test" > < / table >
2021-11-15 23:51:08 +08:00
< / div >
< script type = "text/html" id = "status" >
2022-06-27 01:27:33 +08:00
< i class = "layui-icon {{# if(d.status == 1){ }}green layui-icon-ok{{# } else { }}yellow layui-icon-close{{# } }}" > < / i >
2021-11-15 23:51:08 +08:00
< / script >
< script type = "text/html" id = "toolbarDemo" >
2022-06-26 19:53:28 +08:00
< div class = "layui-btn-container" >
2022-08-01 09:53:02 +08:00
< button class = "layui-btn layui-btn-sm" lay-event = "add" > + 添加关键字< / button >
2021-11-15 23:51:08 +08:00
< / div >
< / script >
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
2022-06-26 19:53:28 +08:00
< script >
2022-06-18 08:58:49 +08:00
const moduleInit = ['tool'];
function gouguInit() {
2022-06-26 19:53:28 +08:00
var table = layui.table, tool = layui.tool, form = layui.form;
2022-06-18 08:58:49 +08:00
layui.pageTable = table.render({
2021-11-15 23:51:08 +08:00
elem: '#test',
title: '关键字列表',
toolbar: '#toolbarDemo',
2022-12-29 17:44:59 +08:00
defaultToolbar: false,
2021-12-05 00:23:33 +08:00
url: "/home/keywords/index",
2021-11-15 23:51:08 +08:00
page: true, //开启分页
limit: 20,
cols: [
[{
field: 'id',
width: 80,
title: 'ID编号',
align: 'center'
}, {
field: 'sort',
width: 80,
title: '排序',
align: 'center',
edit: "text"
}, {
field: 'title',
title: '关键字名称',
edit: "text"
}, {
field: 'status',
width: 80,
title: '状态',
templet: '#status',
align: 'center'
}, {
width: 100,
title: '操作',
align: 'center',
templet: function (d) {
2022-08-01 09:53:02 +08:00
var html = '< div class = "layui-btn-group" > < 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;
}
}]
]
});
//监听搜索提交
form.on('submit(webform)', function (data) {
if (data.field.keywords) {
2022-06-18 08:58:49 +08:00
layui.pageTable.reload({
2021-11-15 23:51:08 +08:00
where: {
keywords: data.field.keywords
},
page: {
curr: 1
}
});
} else {
location.reload();
}
return false;
});
2021-11-23 17:30:16 +08:00
//表头工具栏事件
table.on('toolbar(test)', function(obj){
if (obj.event === 'add') {
2022-06-18 08:58:49 +08:00
tool.side("/home/keywords/add");
2021-11-23 17:30:16 +08:00
return;
}
});
//监听行工具事件
2021-11-15 23:51:08 +08:00
table.on('tool(test)', function (obj) {
2021-11-23 17:30:16 +08:00
var data = obj.data;
if (obj.event === 'edit') {
2022-06-18 08:58:49 +08:00
tool.side('/home/keywords/add?id='+obj.data.id);
2021-11-23 17:30:16 +08:00
return;
}
2021-11-15 23:51:08 +08:00
if (obj.event === 'del') {
2021-11-23 17:30:16 +08:00
layer.confirm('确定要删除吗?', { icon: 3, title: '提示' }, function (index) {
2022-06-18 08:58:49 +08:00
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
2021-11-15 23:51:08 +08:00
}
2022-06-18 08:58:49 +08:00
}
tool.delete("/home/keywords/delete", { id: data.id }, callback);
2021-11-15 23:51:08 +08:00
layer.close(index);
});
}
});
}
< / script >
{/block}
<!-- /脚本 -->