增加权限验证

This commit is contained in:
暮光:城中城
2018-12-02 21:12:04 +08:00
parent f3d2b4eeab
commit 67c584761d
70 changed files with 21137 additions and 366 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,340 @@
/**
* 一些公用方法
* @author 暮光:城中城
* @since 2017年5月7日
*/
function serialize(value) {
if (typeof value === 'string') {
return value;
}
return JSON.stringify(value);
}
function deserialize(value) {
if (typeof value !== 'string' || isEmpty(value)) {
return undefined;
}
try {
return JSON.parse(value);
} catch (e) {
try {
return eval('(' + value + ')');// 处理变态的单双引号共存字符串
} catch (e) {
return value || undefined;
}
}
}
function validateResult(result) {
if(result.errCode == 200) {
return true;
} else {
alert(result.errMsg);
}
return false;
}
function getNowDate() {
var date = new Date();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + "-" + month + "-" + strDate;
return currentdate;
}
function getNowTime() {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
if (hours >= 1 && hours <= 9) {
hours = "0" + hours;
}
if (minutes >= 0 && minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds >= 0 && seconds <= 9) {
seconds = "0" + seconds;
}
var currentdate = hours + ":" + minutes + ":" + seconds;
return currentdate;
}
function getNowDateTime() {
var currentdate = getNowDate() + " " + getNowTime();
return currentdate;
}
/**
* 返回不为空的字符串为空返回def
*/
function getNotEmptyStr(str, def) {
if (isEmpty(str)) {
return isEmpty(def) ? "" : def;
}
return str;
}
/**
* 是否是空对象
* @param obj
* @returns
*/
function isEmptyObject(obj){
return $.isEmptyObject(obj);
}
/**
* 是否是空字符串
* @param str
* @returns
*/
function isNull(str){
return (str == null || str == undefined);
}
/**
* 是否不是空字符串
* @param str
* @returns
*/
function isNotNull(str){
return !isNull(str);
}
/**
* 是否是空字符串
* @param str
* @returns
*/
function isEmpty(str){
return (str == "" || str == null || str == undefined);
}
/**
* 是否不是空字符串
* @param str
* @returns
*/
function isNotEmpty(str){
return !isEmpty(str);
}
/**
* 数组转字符串,使用空格分隔
* @param array
* @returns
*/
function arrToString(array){
var temStr = "";
if(isEmpty(array)){
return temStr;
}
array.forEach(function(e){
if(isNotEmpty(temStr)) {
temStr += " ";
}
temStr += e;
});
return temStr;
}
/**
* 数组array中是否包含str字符串
* @param array
* @param str
* @returns
*/
function haveString(array, str){
if(isEmpty(array)) {
return false;
}
for (var i = 0; i < array.length; i++) {
if(array[i] == str) {
return true;
}
}
return false;
}
/**
* 直接返回对象的第一个属性
* @param data
* @returns
*/
function getObjectFirstAttribute(data) {
for ( var key in data) {
return data[key];
}
}
/**
* 如果对象只有一个属性则返回第一个属性否则返回null
* @param data
* @returns
*/
function getObjectFirstAttributeIfOnly(data) {
var len = 0, value = "";
for ( var key in data) {
if (++len > 1) {
return null;
}
value = data[key];
}
return value;
}
function post(url, param, success, fail, complete) {
ajaxTemp(url, "POST", "JSON", param, success, fail, complete);
}
/**
* ajax处理事件模板
*
* @url 后台处理的url即action
* @dataSentType 数据发送的方式有postget方式
* @dataReceiveType 数据接收格式有html json text等
* @paramsStr 传入后台的参数
* @successFunction ajax成功后执行的函数名 ajaxTemp("", "GET", "html", {}, function(){},
* function(){}, "");
*/
function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction, errorFunction, completeFunction, id) {
$.ajax({
url : url, // 后台处理程序
sync : false,
type : dataSentType, // 数据发送方式
dataType : dataReceiveType, // 接受数据格式
data : eval(paramsStr),
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
success : function(msg) {
if(typeof successFunction == "function") {
successFunction(msg,id);
}
},
beforeSend : function() {
},
complete : function(msg) {
if(typeof completeFunction == "function") {
completeFunction(msg,id);
}
},
error : function(msg) {
if(typeof errorFunction == "function") {
errorFunction(msg,id);
}
}
});
}
/**
* 获取cookie
* @param name
* @returns
*/
function getCookie(name) {
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)){
return unescape(arr[2]);
}
return null;
}
/**
* 字符串格式化
*/
String.prototype.format = function(args) {
if (arguments.length > 0) {
var result = this;
if (arguments.length == 1 && typeof (args) == "object") {
for ( var key in args) {
var reg = new RegExp("({" + key + "})", "g");
result = result.replace(reg, args[key]);
}
} else {
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] == undefined) {
return "";
} else {
var reg = new RegExp("({[" + i + "]})", "g");
result = result.replace(reg, arguments[i]);
}
}
}
return result;
} else {
return this;
}
}
String.prototype.endWith = function(str) {
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
return false;
}
return (this.substring(this.length - str.length) == str);
};
String.prototype.startWith = function(str) {
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
return false;
}
return (this.substr(0, str.length) == str);
};
var common = {
//获取页面顶部被卷起来的高度函数
scrollTop : function(){
return Math.max(
//chrome
document.body.scrollTop,
//firefox/IE
document.documentElement.scrollTop);
},
//获取页面文档的总高度
documentHeight : function(){
//现代浏览器IE9+和其他浏览器和IE8的document.body.scrollHeight和document.documentElement.scrollHeight都可以
return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
},
//获取页面浏览器视口的高度
windowHeight : function(){
return (document.compatMode == "CSS1Compat")?
document.documentElement.clientHeight:
document.body.clientHeight;
},
//提取地址栏信息
getRequest: function () {
var url = location.search;// 获取url中"?"符后的字串
url = decodeURIComponent(url);
var theRequest = {};
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
},
getParam: function(name){
var url = location.search;// 获取url中"?"符后的字串
url = decodeURIComponent(url);
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
var nameTemp = strs[i].split("=")[0];
if(name == nameTemp) {
return unescape(strs[i].split("=")[1]);
}
}
}
return "";
}
};

View File

@@ -0,0 +1,106 @@
/**
* 两个元素上下、左右拖动动态改变大小
* @author 暮光:城中城
* @since 2017年5月7日
*/
(function($){
$.fn.mgResizebleHeight = function(options) {
var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999};
var opts = $.extend(defaults, options);
var disY = 0, prevH = 0, nextH = 0, isStart = false;
var prev, next, thisObj = this;
$(document).mousemove(function(ev){
if(!isStart){return;}
var ev = ev || window.event;
var H = ev.clientY - disY;
var prevHNow = prevH+H, nextHNow = nextH-H;
if(opts.prevHtMin >= prevHNow) {
prevHNow = opts.prevHtMin;
nextHNow = next.outerHeight();
}
if(opts.nextHtMin >= nextHNow) {
nextHNow = opts.nextHtMin;
prevHNow = prev.outerHeight();
}
if(opts.prevHtMax <= prevHNow) {
prevHNow = opts.prevHtMax;
nextHNow = next.outerHeight();
}
if(opts.nextHtMax <= nextHNow) {
nextHNow = opts.nextHtMax;
prevHNow = prev.outerHeight();
}
//prev.css("height", prevHNow + 'px');
//next.css("height", nextHNow + 'px');
if(typeof opts.onresize == 'function') {
opts.onresize(prevHNow, nextHNow);
}
}).mouseup(function(ev){
isStart = false;
});
$(this).mousedown(function(ev){
var ev = ev || window.event;
disY = ev.clientY;
prev = (opts.prev == thisObj)?$(opts.prev).prev():$(opts.prev);
next = (opts.next == thisObj)?$(opts.next).next():$(opts.next);
prevH = prev.outerHeight();
nextH = next.outerHeight();
isStart = true;
});
}
/**
* 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作
*/
$.fn.mgResizebleWidth = function(options) {
var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999};
var opts = $.extend(defaults, options);
var disX = 0, prevW = 0, nextW = 0, isStart = false;
var prev, next, thisObj = this;
$(document).mousemove(function(ev){
if(!isStart){return;}
var ev = ev || window.event;
var W = ev.clientX - disX;
var prevWNow = prevW+W, nextWNow = nextW-W;
if(opts.prevWtMin >= prevWNow) {
prevWNow = opts.prevWtMin;
nextWNow = next.outerWidth();
}
if(opts.nextWtMin >= nextWNow) {
nextWNow = opts.nextWtMin;
prevWNow = prev.outerWidth();
}
if(opts.prevWtMax <= prevWNow) {
prevWNow = opts.prevWtMax;
nextWNow = next.outerWidth();
}
if(opts.nextWtMax <= nextWNow) {
nextWNow = opts.nextWtMax;
prevWNow = prev.outerWidth();
}
//prev.css("width", prevWNow + 'px');
//next.css("width", nextWNow + 'px');
if(typeof opts.onresize == 'function') {
opts.onresize(prevWNow, nextWNow);
}
}).mouseup(function(ev){
if(!isStart){return;}
isStart = false;
if(typeof opts.onfinish == 'function') {
opts.onfinish();
}
});
$(this).mousedown(function(ev){
var ev = ev || window.event;
disX = ev.clientX;
prev = (opts.prev == thisObj)?$(opts.prev).prev():$(opts.prev);
next = (opts.next == thisObj)?$(opts.next).next():$(opts.next);
prevW = prev.outerWidth();
nextW = next.outerWidth();
isStart = true;
if(typeof opts.onstart == 'function') {
opts.onstart();
}
});
}
})(jQuery);

View File

@@ -0,0 +1,33 @@
/**
* 提示工具类
* @author 暮光:城中城
* @since 2017年5月7日
*/
var Toast = {
notOpen:function(){
var data = {
message:"该功能暂未开放,敬请期待!",
icon: 'exclamation-sign',type:"warning",
};
this.show(data);
},
warn:function(msg, time){
var data = {
message:msg,time:time,
icon: 'exclamation-sign',type:'warning',
};
this.show(data);
},
error:function(msg, time){
var data = {
message:msg,time:time,
icon: 'exclamation-sign',type:'danger',
};
this.show(data);
},
show:function(data){
data.time = isEmpty(data.time)?2000:data.time;
data.placement = isEmpty(data.placement)?'top':data.placement;
new $.zui.Messager(data.message, data).show();
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 290 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,146 @@
/*!
* ZUI: 标签页管理器 - v1.8.1 - 2018-01-18
* http://zui.sexy
* GitHub: https://github.com/easysoft/zui.git
* Copyright (c) 2018 cnezsoft.com; Licensed MIT
*/
.tabs {
position: relative;
min-height: 400px;
}
.tabs-navbar {
padding: 4px 4px 0 4px;
}
.tabs-nav {
height: 30px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border-bottom: none;
border-bottom: 1px solid #ddd;
}
.tab-nav-item {
width: 160px;
min-width: 0;
max-width: 160px;
padding-right: 2px;
margin-bottom: 0;
border: none;
}
.tab-nav-item:hover {
min-width: 95px;
}
.tab-nav-link {
position: relative;
height: 30px;
margin: 0;
overflow: hidden;
background-color: rgba(255, 255, 255, .65);
background-color: #e5e5e5;
border-color: #ddd;
border-bottom: none;
border-radius: 2px 2px 0 0;
}
.tab-nav-link > .title {
position: absolute;
top: 5px;
right: 5px;
left: 30px;
display: block;
overflow: hidden;
font-size: 14px;
line-height: 20px;
text-overflow: ellipsis;
white-space: nowrap;
}
.tab-nav-link > .icon {
position: absolute;
top: 5px;
left: 5px;
display: block;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
opacity: .8;
}
.tab-nav-item.loading .tab-nav-link > .icon:before {
content: '\e97b';
-webkit-animation: spin 2s infinite linear;
-o-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
}
.tab-nav-link > .close {
position: absolute;
top: 5px;
right: 5px;
width: 20px;
height: 20px;
font-weight: 200;
line-height: 16px;
text-align: center;
text-shadow: none;
visibility: hidden;
border-radius: 4px;
opacity: 0;
-webkit-transition: all .2s;
-o-transition: all .2s;
transition: all .2s;
}
.tab-nav-link > .close:hover {
color: #fff;
background-color: #ea644a;
}
.tab-nav-link:hover > .title {
right: 25px;
}
.tab-nav-link:hover > .close {
visibility: visible;
opacity: 1;
}
.tab-nav-link.not-closable > .close {
display: none;
}
.nav-tabs.tabs-nav > li > a,
.nav-tabs.tabs-nav > li > a:hover,
.nav-tabs.tabs-nav > li > a:focus {
border-color: #ddd #ddd transparent #ddd;
}
.tab-nav-condensed .tab-nav-link > .title {
left: 5px;
text-overflow: initial;
}
.tab-nav-condensed .tab-nav-link > .icon {
display: none;
}
.tabs-container {
position: absolute;
top: 34px;
right: 0;
bottom: 0;
left: 0;
}
.tabs-container > .tab-pane {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: none;
}
.tabs-container > .tab-pane.active {
display: block;
}
.tab-iframe-cover {
display: none;
}
.tabs-show-contextmenu .tab-iframe-cover {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: block;
}

View File

@@ -0,0 +1,488 @@
/*!
* ZUI: 标签页管理器 - v1.8.1 - 2018-01-18
* http://zui.sexy
* GitHub: https://github.com/easysoft/zui.git
* Copyright (c) 2018 cnezsoft.com; Licensed MIT
*/
/* ========================================================================
* ZUI: tabs.js
* http://zui.sexy
* ========================================================================
* Copyright (c) 2017-2018 cnezsoft.com; Licensed MIT
* ======================================================================== */
(function($) {
'use strict';
/**
* Tab object
* @param {Object | String} tab
*/
var Tab = function(tab) {
var that = this;
if(typeof tab === 'string') {
that.url = tab;
} else if($.isPlainObject(tab)) {
$.extend(that, tab);
}
if(!that.id) {
that.id = $.zui.uuid();
}
if(!that.type) {
if(that.iframe) {
that.type = 'iframe';
that.url = that.url || that.iframe;
} else if(that.ajax) {
that.type = 'ajax';
that.url = that.url || ($.isPlainObject(that.ajax) ? that.ajax.url : that.ajax);
} else if(that.url) {
that.type = tab.ajax ? 'ajax' : 'iframe';
} else {
that.type = 'custom';
}
}
that.createTime = new Date().getTime();
that.openTime = 0;
that.onCreate && that.onCreate.call(that);
};
Tab.prototype.open = function() {
var that = this;
that.openTime = new Date().getTime();
that.onOpen && that.onOpen.call(that);
};
Tab.prototype.close = function() {
var that = this;
that.openTime = 0;
that.onClose && that.onClose.call(that);
};
Tab.create = function(data) {
if (data instanceof Tab) {
return data;
}
return new Tab(data);
};
var NAME = 'zui.tabs'; // model name
var DEFAULTS = {
tabs: [],
defaultTabIcon: 'icon-window',
contextMenu: true,
errorTemplate: '<div class="alert alert-block alert-danger with-icon"><i class="icon-warning-sign"></i><div class="content">{0}</div></div>',
// messagerOptions: null,
showMessage: true,
navTemplate: '<nav class="tabs-navbar"></nav>',
containerTemplate: '<div class="tabs-container"></div>'
};
var LANG = {
zh_cn: {
reload: '重新加载',
close: '关闭',
closeOthers: '关闭其他标签页',
closeRight: '关闭右侧标签页',
reopenLast: '恢复上次关闭的标签页',
errorCannotFetchFromRemote: '无法从远程服务器({0})获取内容。'
},
zh_tw: {
reload: '重新加載',
close: '關閉',
closeOthers: '關閉其他標籤頁',
closeRight: '關閉右側標籤頁',
reopenLast: '恢復上次關閉的標籤頁',
errorCannotFetchFromRemote: '無法從遠程服務器({0})獲取內容。'
},
en: {
reload: 'Reload',
close: 'Close',
closeOthers: 'Close others',
closeRight: 'Close right',
reopenLast: 'Reopen last',
errorCannotFetchFromRemote: 'Cannot fetch data from remote server {0}.'
}
};
// The tabs model class
var Tabs = function(element, options) {
var that = this;
that.name = NAME;
that.$ = $(element);
options = that.options = $.extend({}, DEFAULTS, this.$.data(), options);
var lang = options.lang || 'zh_cn';
that.lang = $.isPlainObject(lang) ? ($.extend(true, {}, LANG[lang.lang || $.zui.clientLang()], lang)) : LANG[lang];
// Initialize here
var $navbar = that.$.find('.tabs-navbar');
if (!$navbar.length) {
$navbar = $(options.navTemplate).appendTo(that.$);
}
that.$navbar = $navbar;
var $nav = $navbar.find('.tabs-nav');
if (!$nav.length) {
$nav = $('<ul class="tabs-nav nav nav-tabs"></ul>').appendTo($navbar);
}
that.$nav = $nav;
var $tabs = that.$.find('.tabs-container');
if (!$tabs.length) {
$tabs = $(options.containerTemplate).appendTo(that.$);
}
that.$tabs = $tabs;
that.activeTabId = options.defaultTab;
var tabs = options.tabs || [];
that.tabs = {};
$.each(tabs, function(index, item) {
var tab = Tab.create(item);
that.tabs[tab.id] = tab;
if (!that.activeTabId) {
that.activeTabId = tab.id;
}
that.renderTab(tab);
});
that.closedTabs = [];
that.open(that.getActiveTab());
$nav.on('click.' + NAME, '.tab-nav-link', function () {
that.open(that.getTab($(this).data('id')));
}).on('click.' + NAME, '.tab-nav-close', function (e) {
that.close($(this).closest('.tab-nav-link').data('id'));
e.stopPropagation();
}).on('resize.' + NAME, function () {
that.adjustNavs();
});
if (options.contextMenu) {
$nav.contextmenu({
selector: '.tab-nav-link',
itemsCreator: function (e) {
return that.createMenuItems(that.getTab($(this).data('id')));
},
onShow: function () {
that.$.addClass('tabs-show-contextmenu');
},
onHide: function () {
that.$.removeClass('tabs-show-contextmenu');
}
});
}
};
Tabs.prototype.createMenuItems = function (tab) {
var that = this;
var lang = that.lang;
return [{
label: lang.reload,
onClick: function () {
that.open(tab, true);
}
}, '-', {
label: lang.close,
disabled: tab.forbidClose,
onClick: function () {
that.close(tab.id);
}
}, {
label: lang.closeOthers,
disabled: that.$nav.find('.tab-nav-item:not(.hidden)').length <= 1,
onClick: function () {
that.closeOthers(tab.id);
}
}, {
label: lang.closeRight,
disabled: !$('#tab-nav-item-' + tab.id).next('.tab-nav-item:not(.hidden)').length,
onClick: function () {
that.closeRight(tab.id);
}
}, '-', {
label: lang.reopenLast,
disabled: !that.closedTabs.length,
onClick: function () {
that.reopen();
}
}];
};
Tabs.prototype.adjustNavs = function (immediately) {
var that = this;
if (!immediately) {
if (that.adjustNavsTimer) {
clearTimeout(that.adjustNavsTimer);
}
that.adjustNavsTimer = setTimeout(function() {
that.adjustNavs(true);
}, 50);
return;
}
if (that.adjustNavsTimer) {
that.adjustNavsTimer = null;
}
var $nav = that.$nav;
var $navItems = $nav.find('.tab-nav-item:not(.hidden)');
var totalWidth = $nav.width();
var totalCount = $navItems.length;
var maxWidth = Math.floor(totalWidth/totalCount);
if(maxWidth < 96) {
maxWidth = Math.floor((totalWidth-96)/(totalCount-1))
}
$nav.toggleClass('tab-nav-condensed', maxWidth <= 50);
$navItems.css('max-width', maxWidth);
};
Tabs.prototype.renderTab = function(tab, beforeTabId) {
var that = this;
var $nav = that.$nav;
var $tabNav = $('#tab-nav-item-' + tab.id);
if (!$tabNav.length) {
var $a = $('<a class="tab-nav-link"><i class="icon"></i><span class="title"></span><i class="close tab-nav-close" title="' + that.lang.close + '">&times;</i></a>').attr({
href: '#tabs-item-' + tab.id,
'data-id': tab.id
});
$tabNav = $('<li class="tab-nav-item" data-id="' + tab.id + '" id="tab-nav-item-' + tab.id + '" />').append($a).appendTo(that.$nav);
if (beforeTabId) {
var $before$nav = $('#tab-nav-item-' + beforeTabId);
if ($before$nav.length) {
$tabNav.insertAfter($before$nav);
}
}
that.adjustNavs();
}
var $a = $tabNav.find('a').attr('title', tab.desc).toggleClass('not-closable', !!tab.forbidClose);
$a.find('.icon').attr('class', 'icon ' + (tab.icon || that.options.defaultTabIcon));
$a.find('.title').text(tab.title || tab.defaultTitle || '');
return $tabNav;
};
Tabs.prototype.getActiveTab = function() {
var that = this;
return that.activeTabId ? that.tabs[that.activeTabId] : null;
};
Tabs.prototype.getTab = function(tabId) {
var that = this;
if (!tabId) {
return that.getActiveTab();
}
if (typeof tabId === 'object') {
tabId = tabId.id;
}
return that.tabs[tabId];
};
Tabs.prototype.close = function(tabId, forceClose) {
var that = this;
var tab = that.getTab(tabId);
if (tab && (forceClose || !tab.forbidClose)) {
$('#tab-nav-item-' + tab.id).remove();
$('#tab-' + tab.id).remove();
tab.close();
delete that.tabs[tab.id];
that.closedTabs.push(tab);
that.$.callComEvent(that, 'onClose', tab);
var lastTab;
$.each(that.tabs, function (tabId, tab) {
if (!lastTab || lastTab.openTime < tab.openTime) {
lastTab = tab;
}
});
lastTab && that.open(lastTab);
}
};
Tabs.prototype.open = function(tab, forceReload) {
var that = this;
if (!(tab instanceof Tab)) {
tab = Tab.create(tab);
}
var $tabNav = that.renderTab(tab);
that.$nav.find('.tab-nav-item.active').removeClass('active');
$tabNav.addClass('active');
var $tabPane = $('#tab-' + tab.id);
if (!$tabPane.length) {
$tabPane = $('<div class="tab-pane" id="tab-' + tab.id + '" />').appendTo(that.$tabs);
}
that.$tabs.find('.tab-pane.active').removeClass('active');
$tabPane.addClass('active');
tab.open();
that.activeTabId = tab.id;
that.tabs[tab.id] = tab;
if (forceReload || !tab.loaded) {
that.reload(tab);
}
that.$.callComEvent(that, 'onOpen', tab);
};
Tabs.prototype.showMessage = function (message, type) {
$.zui.messager.show(message, $.extend({
placement: 'center'
}, this.options.messagerOptions, {
type: type
}));
};
Tabs.prototype.reload = function(tab) {
var that = this;
if (typeof tab === 'string') {
tab = that.getTab(tab);
} else if (!tab) {
tab = that.getActiveTab();
}
if (!tab) {
return;
}
if (!tab.openTime) {
return that.open(tab);
}
var $tabNav = $('#tab-nav-item-' + tab.id).addClass('loading').removeClass('has-error');
var $tabPane = $('#tab-' + tab.id).addClass('loading').removeClass('has-error');
var afterRefresh = function (content, error) {
if (!tab.openTime) {
return;
}
$tabNav.removeClass('loading');
$tabPane.removeClass('loading');
that.$.callComEvent(that, 'onLoad', tab);
if(typeof content === 'string' || content instanceof $) {
if (tab.contentConverter) {
content = tab.contentConverter(content, tab);
}
$tabPane.empty().append(content);
if (!tab.title) {
content = $tabPane.text().replace(/\n/g, '');
tab.title = content.length > 10 ? content.substr(0, 10) : content;
that.renderTab(tab);
}
}
if (error) {
$tabNav.addClass('has-error');
$tabPane.addClass('has-error');
var showMessage = that.options.showMessage;
if (showMessage) {
if ($.isFunction(showMessage)) {
error = showMessage(error);
}
that.showMessage(error, 'danger');
}
if (!content) {
$tabPane.html(that.options.errorTemplate.format(error));
}
}
tab.loaded = new Date().getTime();
};
if (tab.type === 'ajax') {
var ajaxOption = {
type: 'get',
url: tab.url,
error: function(jqXHR, textStatus, errorThrown) {
afterRefresh(false, that.lang.errorCannotFetchFromRemote.format(tab.url));
},
success: function(data) {
afterRefresh(data);
}
};
if($.isPlainObject(tab.ajax)) {
ajaxOption = $.extend(ajaxOption, tab.ajax);
}
$.ajax(ajaxOption);
} else if (tab.type === 'iframe') {
try {
var iframeName = 'tab-iframe-' + tab.id;
var $iframe = $('<iframe id="' + iframeName + '" name="' + iframeName + '" src="' + (tab.url) + '" frameborder="no" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" allowtransparency="true" scrolling="auto" style="width: 100%; height: 100%; left: 0px;"></iframe>');
$iframe.appendTo($tabPane.empty());
$('<div class="tab-iframe-cover" />').appendTo($tabPane);
var frame = document.getElementById(iframeName);
frame.onload = frame.onreadystatechange = function() {
if(this.readyState && this.readyState != 'complete') return;
afterRefresh();
var contentDocument = frame.contentDocument;
if (contentDocument && !tab.title) {
tab.title = contentDocument.title;
that.renderTab(tab);
}
};
} catch (e) {
afterRefresh();
}
} else {
var content = tab.content || tab.custom;
if (typeof content === 'function') {
content = content(tab, afterRefresh, that);
if (content !== true) {
afterRefresh(content);
}
} else {
afterRefresh(content);
}
}
};
Tabs.prototype.closeOthers = function(tabId) {
var that = this;
that.$nav.find('.tab-nav-link:not(.hidden)').each(function() {
var thisTabId = $(this).data('id');
if (thisTabId !== tabId) {
that.close(thisTabId);
}
});
};
Tabs.prototype.closeRight = function(tabId) {
var $tabNav = $('#tab-nav-item-' + tabId);
var $rightNav = $tabNav.next('.tab-nav-item:not(.hidden)');
while ($rightNav.length) {
this.close($rightNav.data('id'));
$rightNav = $tabNav.next('.tab-nav-item:not(.hidden)');
}
};
Tabs.prototype.closeAll = function() {
var that = this;
that.$nav.find('.tab-nav-link:not(.hidden)').each(function() {
that.close($(this).data('id'));
});
};
Tabs.prototype.reopen = function() {
var that = this;
if(that.closedTabs.length) {
that.open(that.closedTabs.pop());
}
};
// Extense jquery element
$.fn.tabs = function(option) {
return this.each(function() {
var $this = $(this);
var data = $this.data(NAME);
var options = typeof option == 'object' && option;
if(!data) $this.data(NAME, (data = new Tabs(this, options)));
if(typeof option == 'string') data[option]();
});
};
Tabs.NAME = NAME;
$.fn.tabs.Constructor = Tabs;
}(jQuery));

View File

@@ -0,0 +1,6 @@
/*!
* ZUI: 标签页管理器 - v1.8.1 - 2018-01-18
* http://zui.sexy
* GitHub: https://github.com/easysoft/zui.git
* Copyright (c) 2018 cnezsoft.com; Licensed MIT
*/.tabs{position:relative;min-height:400px}.tabs-navbar{padding:4px 4px 0 4px}.tabs-nav{height:30px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-bottom:none;border-bottom:1px solid #ddd}.tab-nav-item{width:160px;min-width:0;max-width:160px;padding-right:2px;margin-bottom:0;border:none}.tab-nav-item:hover{min-width:95px}.tab-nav-link{position:relative;height:30px;margin:0;overflow:hidden;background-color:rgba(255,255,255,.65);background-color:#e5e5e5;border-color:#ddd;border-bottom:none;border-radius:2px 2px 0 0}.tab-nav-link>.title{position:absolute;top:5px;right:5px;left:30px;display:block;overflow:hidden;font-size:14px;line-height:20px;text-overflow:ellipsis;white-space:nowrap}.tab-nav-link>.icon{position:absolute;top:5px;left:5px;display:block;width:20px;height:20px;line-height:20px;text-align:center;opacity:.8}.tab-nav-item.loading .tab-nav-link>.icon:before{content:'\e97b';-webkit-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;animation:spin 2s infinite linear}.tab-nav-link>.close{position:absolute;top:5px;right:5px;width:20px;height:20px;font-weight:200;line-height:16px;text-align:center;text-shadow:none;visibility:hidden;border-radius:4px;opacity:0;-webkit-transition:all .2s;-o-transition:all .2s;transition:all .2s}.tab-nav-link>.close:hover{color:#fff;background-color:#ea644a}.tab-nav-link:hover>.title{right:25px}.tab-nav-link:hover>.close{visibility:visible;opacity:1}.tab-nav-link.not-closable>.close{display:none}.nav-tabs.tabs-nav>li>a,.nav-tabs.tabs-nav>li>a:focus,.nav-tabs.tabs-nav>li>a:hover{border-color:#ddd #ddd transparent #ddd}.tab-nav-condensed .tab-nav-link>.title{left:5px;text-overflow:initial}.tab-nav-condensed .tab-nav-link>.icon{display:none}.tabs-container{position:absolute;top:34px;right:0;bottom:0;left:0}.tabs-container>.tab-pane{position:absolute;top:0;right:0;bottom:0;left:0;display:none}.tabs-container>.tab-pane.active{display:block}.tab-iframe-cover{display:none}.tabs-show-contextmenu .tab-iframe-cover{position:absolute;top:0;right:0;bottom:0;left:0;display:block}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>hello</title>
</head>
<body>
<div id="app">fasfasfasfa艾斯德斯大所大所大所多撒多撒多撒多</div>
</body>
<script>
</script>
<style>
.reason {
color: #f00;
font-size: 12px;
}
</style>
</html>

View File

@@ -0,0 +1,80 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>登录</title>
<link rel="stylesheet" type="text/css" href="../lib/mzui/css/mzui.min.css">
</head>
<body>
<div id="app">
<div class="page fade scale-from-center display in" style="overflow: hidden">
<div class="dock blur-lg" style="background: url('../lib/mzui/img/loginBg.jpg') no-repeat center; background-size: cover; top: -2rem; right: -2rem; bottom: -2rem; left: -2rem"></div>
<div class="dock flex flex-center">
<div class="modal rounded" style="width: 18rem; height: 10rem; margin: auto;">
<div class="heading divider primary-pale">
<div class="title">登录 <span class="reason"> 您没有权限访问该内容或需要登录</span></div>
</div>
<form action="/login" method="post">
<div class="content box">
<div class="control has-label-left"><!-- has-error -->
<input type="text" name="username" class="input" v-model="userId" placeholder="用户名">
<label for="account"><i class="icon-user"></i></label>
<div class="help-text" v-if="errorInfo.length > 0">{{errorInfo}}</div>
</div>
<div class="control has-label-left">
<input type="password" name="password" v-model="password" class="input" placeholder="密码">
<input type="hidden" name="validateCode" value="1234">
<label for="account"><i class="icon-key"></i></label>
</div>
<div class="control">
<button type="submit" v-on:click="loginSubmit1" class="btn block primary">登录</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
<script src="../lib/jquery/jquery-3.1.0.min.js"></script>
<script src="../lib/mzui/js/mzui.min.js"></script>
<script src="../lib/vue/vue.js"></script>
<script src="../lib/mg/js/common.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
userId: "",
password: "",
errorInfo: ""
},
methods: {
loginSubmit: function() {
var param = {
username: app.userId,
password: app.password,
validateCode: "1234"
};
post("/login", param, function(result) {
if(result.errCode == 200) {
//location.href = "/manage/web/home";
alert("登录失败1" + result.errMsg);
} else {
alert("登录失败," + result.errMsg);
}
});
}
}
});
</script>
<style>
.reason{color: #f00;font-size: 12px;}
</style>
</html>