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" >
2023-05-18 12:26:49 +08:00
< div class = "gg-form-bar border-t border-x" style = "padding-bottom:12px;" >
< button class = "layui-btn layui-btn-sm add-menu" > + 添加分类< / button >
2021-11-15 23:51:08 +08:00
< / div >
2021-11-29 16:04:07 +08:00
< div >
2021-11-15 23:51:08 +08:00
< table class = "layui-hide" id = "treeTable" lay-filter = "treeTable" > < / table >
< / div >
< / div >
< script type = "text/html" id = "switchStatus" >
< input type = "checkbox" name = "status" value = "{{d.id}}" lay-skin = "switch" lay-text = "是|否" lay-filter = "status" { { d . status = = 1 ? ' checked ' : ' ' } } >
< / script >
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
2022-06-08 15:13:48 +08:00
< script >
2023-05-18 12:26:49 +08:00
const moduleInit = ['tool'];
2022-06-08 15:13:48 +08:00
function gouguInit() {
2023-05-18 12:26:49 +08:00
var treeTable = layui.treeTable, tool = layui.tool;
layui.pageTable = treeTable.render({
elem: '#treeTable'
,url: "/article/cate/cate"
,tree: { // treeTable 特定属性集
customName: {name:'title'},
data: {},
view: {showIcon:false},
async: {},
callback: {}
}
,cols: [[
{field:'id',width:80, title: 'ID号', align:'center'}
,{field: 'sort', title: '排序',align:'center', width:80}
,{field:'title', edit:'text',width:240, title: '分类名称'}
,{field:'pid', title: '父级ID', width:80, align:'center'}
,{field:'desc', title: '描述', }
,{width:160,title: '操作', align:'center',templet: function(d){
var html = '< span class = "layui-btn-group" > < button class = "layui-btn layui-btn-normal layui-btn-xs" lay-event = "add" > 添加子分类< / button > < 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 > < / span > ';
return html;
}
}
]]
,page:false
//,skin:'line'
});
2021-11-23 23:09:15 +08:00
2023-05-18 12:26:49 +08:00
//表头工具栏事件
$('.add-menu').on('click', function(){
tool.side("/article/cate/cate_add");
return;
});
//操作按钮
treeTable.on('tool(treeTable)', function (obj) {
if (obj.event === 'add') {
tool.side('/article/cate/cate_add?pid='+obj.data.id);
2021-11-23 23:09:15 +08:00
return;
2023-05-18 12:26:49 +08:00
}
if (obj.event === 'edit') {
tool.side('/article/cate/cate_add?id='+obj.data.id);
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();
2022-06-08 15:13:48 +08:00
}
2023-05-18 12:26:49 +08:00
}
tool.delete("/article/cate/cate_delete", { id: obj.data.id }, callback);
layer.close(index);
});
}
});
}
< / script >
2021-11-15 23:51:08 +08:00
{/block}
<!-- /脚本 -->