代码拉取完成,页面将自动刷新
同步操作将从 陨落人间/treetable-lay 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>tree-table</title>
<link rel="stylesheet" href="assets/layui/css/layui.css">
<link rel="stylesheet" href="assets/common.css"/>
<style>
input {
height: 33px;
line-height: 33px;
padding: 0 7px;
border: 1px solid #ccc;
border-radius: 2px;
margin-bottom: -2px;
outline: none;
}
input:focus {
border-color: #009E94;
}
</style>
</head>
<body>
<div class="layui-container">
<br><br>
<a class="layui-btn layui-btn-normal" href="index.html"><<返回</a>
<div class="layui-btn-group">
<button class="layui-btn" id="btn-expand">全部展开</button>
<button class="layui-btn" id="btn-fold">全部折叠</button>
</div>
<input id="edt-search" type="text" placeholder="输入关键字" style="width: 120px;"/>
<button class="layui-btn" id="btn-search"> 搜索 </button>
<table id="auth-table" class="layui-table" lay-filter="auth-table"></table>
</div>
<script src="assets/layui/layui.js"></script>
<script>
layui.config({
base: 'module/'
}).extend({
treetable: 'treetable-lay/treetable'
}).use(['table', 'treetable'], function () {
var $ = layui.jquery;
var table = layui.table;
var treetable = layui.treetable;
// 渲染表格
layer.load(2);
treetable.render({
treeColIndex: 1,
treeSpid: -1,
treeIdName: 'authorityId',
treePidName: 'parentId',
elem: '#auth-table',
url: 'json/menus.json',
page: false,
cols: [[
{type: 'numbers'},
{field: 'authorityName', minWidth: 200, title: '权限名称'},
{field: 'authority', title: '权限标识'},
{field: 'menuUrl', title: '菜单url'},
{
field: 'isMenu', width: 80, align: 'center', templet: function (d) {
if (d.isMenu == 1) {
return '<span class="layui-badge layui-bg-gray">按钮</span>';
}
if (d.parentId == -1) {
return '<span class="layui-badge layui-bg-blue">目录</span>';
} else {
return '<span class="layui-badge-rim">菜单</span>';
}
}, title: '类型'
}
]],
done: function () {
layer.closeAll('loading');
}
});
$('#btn-expand').click(function () {
treetable.expandAll('#auth-table');
});
$('#btn-fold').click(function () {
treetable.foldAll('#auth-table');
});
$('#btn-search').click(function () {
var keyword = $('#edt-search').val();
var searchCount = 0;
$('#auth-table').next('.treeTable').find('.layui-table-body tbody tr td').each(function () {
$(this).css('background-color', 'transparent');
var text = $(this).text();
if (keyword != '' && text.indexOf(keyword) >= 0) {
$(this).css('background-color', 'rgba(250,230,160,0.5)');
if (searchCount == 0) {
treetable.expandAll('#auth-table');
$('html,body').stop(true);
$('html,body').animate({scrollTop: $(this).offset().top - 150}, 500);
}
searchCount++;
}
});
if (keyword == '') {
layer.msg("请输入搜索内容", {icon: 5});
} else if (searchCount == 0) {
layer.msg("没有匹配结果", {icon: 5});
}
});
});
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。