...
parent
6e2d98d86a
commit
95d3cb0c46
|
|
@ -7,6 +7,9 @@ layui.use(['element', 'layer', 'okUtils', 'okTab'], function () {
|
||||||
okTab = layui.okTab({
|
okTab = layui.okTab({
|
||||||
url: "./data/navs.json",
|
url: "./data/navs.json",
|
||||||
openTabNum: 30, //允许同时选项卡的个数
|
openTabNum: 30, //允许同时选项卡的个数
|
||||||
|
parseData:function (data) {//如果返回的结果和navs.json中的数据结构一致可省略这个方法
|
||||||
|
return data;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
okTab.render(function () {
|
okTab.render(function () {
|
||||||
|
|
@ -72,6 +75,7 @@ layui.use(['element', 'layer', 'okUtils', 'okTab'], function () {
|
||||||
$("#fullScreen").children("i").eq(0).addClass("okicon-screen-restore");
|
$("#fullScreen").children("i").eq(0).addClass("okicon-screen-restore");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("body").on("click", "#fullScreen", function () {
|
$("body").on("click", "#fullScreen", function () {
|
||||||
if ($(this).children("i").hasClass("okicon-screen-restore")) {
|
if ($(this).children("i").hasClass("okicon-screen-restore")) {
|
||||||
screenFun(2).then(function(){
|
screenFun(2).then(function(){
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
this.tabConfig = {
|
this.tabConfig = {
|
||||||
openTabNum: 30, //最大可打开窗口数量默认30
|
openTabNum: 30, //最大可打开窗口数量默认30
|
||||||
tabFilter: "ok-tab", //添加窗口的filter
|
tabFilter: "ok-tab", //添加窗口的filter
|
||||||
url: "./data/navs.json" //获取菜单的接口地址
|
url: "", //获取菜单的接口地址
|
||||||
|
data:[],//菜单数据列表(如果传入了url则data无效)
|
||||||
|
parseData:''//这是一个方法处理url请求地址的返回值(该方法必须提供一个返回值)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
|
@ -214,7 +216,7 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
if (typeof (strData) == "string") {
|
if (typeof (strData) == "string") {
|
||||||
var data = JSON.parse(strData); //有可能是字符串,转换一下
|
var data = JSON.parse(strData); //有可能是字符串,转换一下
|
||||||
} else {
|
} else {
|
||||||
data = strData;
|
data = strData || [];
|
||||||
}
|
}
|
||||||
var ulItem = '';
|
var ulItem = '';
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
|
@ -296,9 +298,29 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
|
|
||||||
//重新对导航进行渲染(此处有个回调函数,主要用作渲染完成之后的操作)
|
//重新对导航进行渲染(此处有个回调函数,主要用作渲染完成之后的操作)
|
||||||
okTab.prototype.render = function (fun) {
|
okTab.prototype.render = function (fun) {
|
||||||
let _this = this;//data
|
var _this = this;//data
|
||||||
$.get(_this.tabConfig.url, function (data) {
|
var _data = _this.tabConfig.data;
|
||||||
$("#navBar").html(_this.navBar(data));
|
if(_this.tabConfig.url){
|
||||||
|
$.get(_this.tabConfig.url, function (res) {
|
||||||
|
_data = res;
|
||||||
|
if(typeof _this.tabConfig.parseData == "function"){
|
||||||
|
_data = _this.tabConfig.parseData(res);
|
||||||
|
}
|
||||||
|
$("#navBar").html(_this.navBar(_data));
|
||||||
|
element.render('nav');
|
||||||
|
$(window).resize(function () {
|
||||||
|
$("#navBar").height($(window).height() - 245);
|
||||||
|
});
|
||||||
|
if (typeof fun == "function") {
|
||||||
|
fun();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else if($.type(_data) == 'array'){
|
||||||
|
if(_data.length < 1){
|
||||||
|
alert("菜单集合中无任何数据");
|
||||||
|
}
|
||||||
|
var _data = _this.tabConfig.data;
|
||||||
|
$("#navBar").html(_this.navBar(_data));
|
||||||
element.render('nav');
|
element.render('nav');
|
||||||
$(window).resize(function () {
|
$(window).resize(function () {
|
||||||
$("#navBar").height($(window).height() - 245);
|
$("#navBar").height($(window).height() - 245);
|
||||||
|
|
@ -306,7 +328,9 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
if (typeof fun == "function") {
|
if (typeof fun == "function") {
|
||||||
fun();
|
fun();
|
||||||
}
|
}
|
||||||
});
|
}else{
|
||||||
|
alert("你的菜单配置有误请查看菜单配置说明");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//刷新当前tab页
|
//刷新当前tab页
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue