You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
21 KiB

2 years ago
/* * @Author: https://github.com/WangEn * @Author: https://gitee.com/lovetime/ * @Date: 2018-01-01 * @lastModify 2018-3-27 15:00:35 * +---------------------------------------------------------------------- * | Weadmin [ 后台管理模板 ] * | 基于Layui http://www.layui.com/ * +---------------------------------------------------------------------- */ layui.define(['jquery', 'form', 'layer', 'element'], function (exports) { var $ = layui.jquery, form = layui.form, layer = layui.layer, element = layui.element; var menu = []; var curMenu; /* * @todo 初始化加载完成执行方法 * 打开或刷新后执行 */ $(function () { /* * @todo 读取本地存储中记录的已打开的tab项 * 刷新后读取记录打开原来已打开的tab项 */ /* * @todo table事件 */ tableCheck = { init: function () { $(".layui-form-checkbox").click(function (event) { if ($(this).hasClass('layui-form-checked')) { $(this).removeClass('layui-form-checked'); if ($(this).hasClass('header')) { $(".layui-form-checkbox").removeClass('layui-form-checked'); } } else { $(this).addClass('layui-form-checked'); if ($(this).hasClass('header')) { $(".layui-form-checkbox").addClass('layui-form-checked'); } } var len1 = $("tbody .layui-form-checkbox").length; var len2 = $("tbody .layui-form-checked").length; if (len1 == len2) { $(".header").addClass('layui-form-checked'); } else { $(".header").removeClass('layui-form-checked'); } }); }, } //开启表格多选 tableCheck.init(); //延时加载 setTimeout(function () { if (sessionStorage.getItem("menu")) { menu = JSON.parse(sessionStorage.getItem("menu")); for (var i = 0; i < menu.length; i++) { tab.tabAdd(menu[i].title, menu[i].url, menu[i].id); } } else { return false; } if (sessionStorage.getItem("curMenu")) { $('.layui-tab-title').find('layui-this').removeClass('layui-class'); curMenu = JSON.parse(sessionStorage.getItem("curMenu")); id = curMenu.id; if (id) { //因为默认桌面首页不存在lay-id,所以要对此判断 $('.layui-tab-title li[lay-id="' + id + '"]').addClass('layui-this'); tab.tabChange(id); } else { $(".layui-tab-title li").eq(0).addClass('layui-this'); //未生效 $('.layui-tab-content iframe').eq(0).parent().addClass('layui-show'); } } else { $(".layui-tab-title li").eq(0).addClass('layui-this'); //未生效 $('.layui-tab-content iframe').eq(0).parent().addClass('layui-show'); } }, 100); //点击tab标题时触发reloadTab函数 $('#tabName').on('click', 'li', function () { var txt = this.innerText.substr(0, this.innerText.length - 1); var layId = $(this).attr('lay-id'); if (txt == "整体报告") { if (layId == -1) { tab.tabChange($(this).attr("data-id")); var othis = $('.layui-tab-title').find('>li[lay-id="' + layId + '"]'), index = othis.parent().children('li').index(othis), parents = othis.parents('.layui-tab').eq(0), item = parents.children('.layui-tab-content').children('.layui-tab-item'),