nk-lihaink-cn/app/admin/view/nav/nav_info.html

132 lines
3.3 KiB
HTML

{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<div class="gg-form-bar border-t border-x">
<button class="layui-btn layui-btn-sm add-menu">+ 添加导航</button>
<button class="layui-btn layui-btn-primary layui-btn-sm add-back">返回</button>
</div>
<div>
<table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
</div>
</div>
<script type="text/html" id="target">
<i class="layui-icon {{# if(d.target == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="status">
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
var nid = {$nav_id};
const moduleInit = ['tool', 'treeGrid'];
function gouguInit() {
var treeGrid = layui.treeGrid,table = layui.table, tool = layui.tool;
var pageTable = treeGrid.render({
id: 'treeTable',
elem: '#treeTable',
idField: 'id',
url: '/admin/nav/nav_info', //数据接口
where: {
id:nid
},
cellMinWidth: 100,
treeId: 'id', //树形id字段名称
treeUpId: 'pid', //树形父id字段名称
treeShowName: 'title', //以树形式显示的字段
cols: [
[{
field: 'sort',
width: 80,
title: '排序',
align: 'center'
}, {
field: 'id',
width: 80,
title: 'ID号',
align: 'center'
}, {
field: 'title',
width: 220,
title: '名称',
}, {
field: 'pid',
title: '父级ID',
width: 80,
align: 'center'
}, {
field: 'src',
title: '链接'
},{
field: 'target',
title: '新窗口打开',
toolbar: '#target',
align: 'center',
width: 100
},{
field: 'status',
title: '状态',
toolbar: '#status',
align: 'center',
width: 60
}, {
width: 160,
title: '操作',
align: 'center',
templet: function (d) {
var html = '';
var addBtn =
'<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 addBtn;
}
}]
],
page: false
});
//表头工具栏事件
$('.add-menu').on('click',function(){
tool.side("/admin/nav/nav_info_add?nid="+nid);
return;
});
//监听返回
$('.add-back').on('click',function () {
history.back(-1);
return false;
});
//删除
treeGrid.on('tool(treeTable)', function (obj) {
if (obj.event === 'add') {
tool.side('/admin/nav/nav_info_add?nid='+nid+'&pid='+obj.data.id);
return;
}
if (obj.event === 'edit') {
tool.side('/admin/nav/nav_info_add?nid='+nid+'&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();
}
}
tool.delete("/admin/nav/nav_info_delete", { id: obj.data.id }, callback);
layer.close(index);
});
}
});
}
</script>
{/block}
<!-- /脚本 -->