From 3bae39f9f514d1044894aec06192614eb74f05db Mon Sep 17 00:00:00 2001 From: zhaoxiaohao <913652501@qq.com> Date: Thu, 14 May 2020 11:47:02 +0800 Subject: [PATCH] 添加 认证管理的 按钮隐藏的功能 --- kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/system/menus.html | 68 ++++++++++++++++++---------------- 1 files changed, 36 insertions(+), 32 deletions(-) diff --git a/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/system/menus.html b/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/system/menus.html index ae9c51f..ea5e862 100644 --- a/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/system/menus.html +++ b/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/system/menus.html @@ -2,16 +2,17 @@ <div class="layui-card-header"> <h2 class="header-title">菜单管理</h2> <span class="layui-breadcrumb pull-right"> - <a href="#!home_console">首页</a> - <a><cite>菜单管理</cite></a> + <a href="#!home_console">首页</a> + <a><cite>菜单管理</cite></a> </span> </div> <div class="layui-card-body"> <div class="layui-form toolbar"> 所属应用:<select id="menu_clients" lay-filter="menu_clients"></select> -  搜索:<input id="menus-edit-search" class="layui-input search-input" type="text" placeholder="输入关键字"/>  +  搜索:<input id="menus-edit-search" class="layui-input search-input" type="text" + placeholder="输入关键字" />  <button id="menus-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button> - <button id="menus-btn-add" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button> + <button id="menus-btn-add" class="layui-btn icon-btn permissions" permissions="saveOrUpdate"><i class="layui-icon"></i>添加</button> <button id="menus-btn-expand" class="layui-btn">全部展开</button> <button id="menus-btn-fold" class="layui-btn">全部折叠</button> </div> @@ -24,8 +25,8 @@ <!-- 表格操作列 --> <script type="text/html" id="menus-state"> <!-- <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="add">下级</a>--> - <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a> - <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> +<a class="layui-btn layui-btn-primary layui-btn-xs permissions" permissions="saveOrUpdate" lay-event="edit">修改</a> +<a class="layui-btn layui-btn-danger layui-btn-xs permissions" permissions="menus-del" lay-event="del">删除</a> </script> @@ -37,7 +38,7 @@ <script> - layui.use(['form', 'table', 'util', 'config', 'admin', 'formSelects', 'treetable'],function () { + layui.use(['form', 'table', 'util', 'config', 'admin', 'formSelects', 'treetable'], function () { let table = layui.table; let layer = layui.layer; let admin = layui.admin; @@ -64,13 +65,13 @@ where: param, page: false, cols: [[ - {type: 'numbers'}, - {field: 'name', minWidth: 200, title: '菜单名称'}, - {field: 'tenantId', minWidth: 80, title: '应用标识'}, - {field: 'url', title: '菜单url'}, - {field: 'path', title: '菜单path'}, - {field: 'css', align: 'center', title: '样式'}, - {field: 'sort', width: 80, align: 'center', title: '排序号'}, + { type: 'numbers' }, + { field: 'name', minWidth: 200, title: '菜单名称' }, + { field: 'tenantId', minWidth: 80, title: '应用标识' }, + { field: 'url', title: '菜单url' }, + { field: 'path', title: '菜单path' }, + { field: 'css', align: 'center', title: '样式' }, + { field: 'sort', width: 80, align: 'center', title: '排序号' }, { field: 'type', width: 80, align: 'center', templet: function (d) { if (d.type === 2) { @@ -83,12 +84,15 @@ } }, title: '类型' }, - {field: 'enabled', width: 100,sort: true, templet: '#menu-tpl-state', title: '状态'}, - {templet: '#menus-state', width: 120, align: 'center', title: '操作'} - ]] + { field: 'enabled', width: 100, sort: true, templet: '#menu-tpl-state', title: '状态' }, + { templet: '#menus-state', width: 120, align: 'center', title: '操作' } + ]], + done: function () { + permissionsInput(); + } }); }; - renderTable({tenantId: config.clientId}); + renderTable({ tenantId: config.clientId }); // 获取应用列表 layer.load(2); @@ -96,7 +100,7 @@ layer.closeAll('loading'); if (0 === data.code) { let selected = false; - $.each(data.data,function(index,item){ + $.each(data.data, function (index, item) { if (config.clientId === item.clientId) { selected = true; } else { @@ -107,7 +111,7 @@ }) form.render(); } else { - layer.msg(data.msg, {icon: 2, time: 500}); + layer.msg(data.msg, { icon: 2, time: 500 }); } }, 'GET'); @@ -120,9 +124,9 @@ }, function (data) { layer.closeAll('loading'); if (data.code == 0) { - layer.msg(data.msg, {icon: 1, time: 500}); + layer.msg(data.msg, { icon: 1, time: 500 }); } else { - layer.msg(data.msg, {icon: 2, time: 500}); + layer.msg(data.msg, { icon: 2, time: 500 }); $(obj.elem).prop('checked', !obj.elem.checked); form.render('checkbox'); } @@ -140,13 +144,13 @@ layer.confirm('确定删除此菜单吗?', function () { layer.load(2); let tenantId = $('#menu_clients').val(); - admin.req('api-user/menus/'+obj.data.id+'?tenantId='+tenantId, {}, function (data) { + admin.req('api-user/menus/' + obj.data.id + '?tenantId=' + tenantId, {}, function (data) { layer.closeAll('loading'); if (0 === data.code) { - layer.msg(data.msg, {icon: 1, time: 500}); - renderTable({tenantId: tenantId}); + layer.msg(data.msg, { icon: 1, time: 500 }); + renderTable({ tenantId: tenantId }); } else { - layer.msg(data.msg, {icon: 2, time: 500}); + layer.msg(data.msg, { icon: 2, time: 500 }); } }, 'DELETE'); }); @@ -157,7 +161,7 @@ var showEditModel = function (data) { let tenantId = $('#menu_clients').val(); let title = data ? '修改菜单' : '添加菜单'; - if (data){ + if (data) { data.type = data.type.toString(); data.hidden = data.hidden.toString(); } else { @@ -170,7 +174,7 @@ title: title, path: 'pages/system/menus_form.html', finish: function () { - renderTable({tenantId: tenantId}); + renderTable({ tenantId: tenantId }); } }); }; @@ -191,13 +195,13 @@ $(this).css('background-color', 'rgba(250,230,160,0.5)'); if (searchCount === 0) { $('.layui-tab-item.layui-show').stop(true); - $('.layui-tab-item.layui-show').animate({scrollTop: $(this).offset().top - 150}, 500); + $('.layui-tab-item.layui-show').animate({ scrollTop: $(this).offset().top - 150 }, 500); } searchCount++; } }); if (keyword !== '' && searchCount === 0) { - layer.msg("没有匹配结果", {icon: 5, time: 500}); + layer.msg("没有匹配结果", { icon: 5, time: 500 }); } else { treetable.expandAll('#menus-table'); } @@ -212,8 +216,8 @@ }); // 应用下来框点击事件 - form.on('select(menu_clients)', function(data){ - renderTable({tenantId: data.value}); + form.on('select(menu_clients)', function (data) { + renderTable({ tenantId: data.value }); }); }); </script> \ No newline at end of file -- Gitblit v1.8.0