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-08 15:13:48 +08:00
< div class = "p-3" >
< form class = "layui-form gg-form-bar border-t border-x" >
2021-11-15 23:51:08 +08:00
< div class = "layui-input-inline" style = "width:300px;" >
2021-11-23 17:04:53 +08:00
< input type = "text" name = "keywords" placeholder = "名称/备注" class = "layui-input" autocomplete = "off" / >
2021-11-15 23:51:08 +08:00
< / div >
< button class = "layui-btn layui-btn-normal" lay-submit = "" lay-filter = "webform" > 提交搜索< / button >
< / form >
2022-06-08 15:13:48 +08:00
< table class = "layui-hide" id = "role" lay-filter = "role" > < / 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 { }}red layui-icon-close{{# } }}" > < / i >
2021-11-15 23:51:08 +08:00
< / script >
< script type = "text/html" id = "toolbarDemo" >
< 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 >
2022-06-08 15:13:48 +08:00
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table, tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#role',
2021-11-15 23:51:08 +08:00
toolbar: '#toolbarDemo',
2021-12-05 00:23:33 +08:00
url: "/home/role/index", //数据接口
2021-11-15 23:51:08 +08:00
page: true, //开启分页
limit: 20,
cols: [[ //表头
{ field: 'id', title: 'ID号', align: 'center', width: 80 }
2021-11-23 17:04:53 +08:00
, { field: 'title', title: '权限组名称', width: 200 }
2021-11-15 23:51:08 +08:00
, { field: 'desc', title: '备注' }
2021-11-16 14:57:25 +08:00
, { field: 'status', title: '状态', toolbar: '#status', align: 'center', width: 80 }
2021-11-23 17:30:16 +08:00
, { width: 100,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 = "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
//表头工具栏事件
2022-06-08 15:13:48 +08:00
table.on('toolbar(role)', function(obj){
2021-11-23 17:04:53 +08:00
if (obj.event === 'add') {
2022-06-08 15:13:48 +08:00
tool.side("/home/role/add");
2021-11-23 17:04:53 +08:00
return;
}
});
2021-11-15 23:51:08 +08:00
//监听行工具事件
2022-06-08 15:13:48 +08:00
table.on('tool(role)', function (obj) {
2021-11-15 23:51:08 +08:00
var data = obj.data;
2021-11-23 17:04:53 +08:00
if (obj.event === 'edit') {
2022-06-08 15:13:48 +08:00
tool.side('/home/role/add?id='+obj.data.id);
2021-11-23 17:04:53 +08:00
return;
}
2021-11-15 23:51:08 +08:00
if (obj.event === 'del') {
2021-11-17 00:24:24 +08:00
layer.confirm('确定要删除该权限角色吗?', { icon: 3, title: '提示' }, function (index) {
2022-06-08 15:13:48 +08:00
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
layer.msg(res.msg);
if (res.code == 0) {
2021-11-15 23:51:08 +08:00
obj.del();
2022-06-08 15:13:48 +08:00
layer.close(index);
2021-11-15 23:51:08 +08:00
}
}
2022-06-08 15:13:48 +08:00
}
tool.delete("/home/role/delete", { id: obj.data.id }, callback);
2021-11-15 23:51:08 +08:00
layer.close(index);
});
}
});
//监听搜索提交
form.on('submit(webform)', function (data) {
2022-06-08 15:13:48 +08:00
layui.pageTable.reload({
2021-11-15 23:51:08 +08:00
where: { keywords: data.field.keywords },
page: { curr: 1 }
});
return false;
});
}
< / script >
{/block}
<!-- /脚本 -->