PageSourceSearch

https://ztbzx.cqu.edu.cn/sfw_cms/theme/javascripts/speed/common.js?v=1.0

js cqu.edu.cn collected 2026-10-01 10:21:06 UTC 89,221 bytes, 3,176 lines download raw bytes

1var AJAX_CONFIG={
2	"timeout": 5*60*1000,
3	"async": true,
4	contentType: "application/x-www-form-urlencoded;charset=utf-8"
5};
6
7/**
8 * 打开一个窗口
9 * 
10 * @param url
11 *            要打开的窗口的url
12 * @param data
13 *            要传入新窗口的参数
14 * @param target
15 *            要在哪个现有窗口中打开
16 */
17function openWindow(url, data, target) {
18	var lc_ = getQueryStringRegExp("lc_");
19	data = $.extend(true, {}, data);
20	if (lc_) {
21		data["lc_"] = lc_;
22	}
23	$("#__windowOpenForm").remove();
24	var fmhtml =$('<form id="__windowOpenForm" method="post" action=""></form>');
25	fmhtml.attr("action", url);
26	fmhtml.attr("target", target || "_blank");
27	var input,inputStr = "<input type='hidden'>";
28	for (var o in data) {
29		if($.isArray(data[o])){
30			for ( var i = 0; i < data[o].length; i++) {
31				input = $(inputStr);
32				input.attr("name",o);
33				input.val(data[o][i]);
34				fmhtml.append(input);
35			}
36		}else{
37			input = $(inputStr);
38			input.attr("name",o);
39			input.val(data[o]);
40			fmhtml.append(input);
41		}
42	}
43	$(document).find("body").append(fmhtml);
44	fmhtml = $("#__windowOpenForm");
45	fmhtml.submit();
46	fmhtml.remove();
47}
48
49function openWindowWithParent(data, target) {
50	target = target || "_blank";
51	data = $.extend(true, {}, decodeURLParams(top.location.search), data);
52	openWindow(top.location.pathname, data, target);
53}
54
55function refreshValidImage() {
56	  $("img[src^='validimage.jpg']").attr("src", "validimage.jpg?t=" + new Date().getTime());
57}
58
59/**
60 * 显示业务须知
61 * 
62 * @param introduceCode
63 *            system_introduce表中才code
64 * @param isAuto
65 */
66function showIntroduce(introduceCode, isAuto) {
67	var cc = "introduce_" + (typeof pageid != "undefined" ? pageid : "") + "_" + introduceCode;
68	if (isAuto && isAuto !="0" && $.cookie(cc)=="true") {
69		return;
70	}
71	var url = "e?page=base.business.introduce.show&code=" + introduceCode + "&cc=" + cc + (typeof isAuto != "undefined" ? "&np=1" : "")
72	var lc_ = getQueryStringRegExp("lc_");
73	if (lc_) {
74		url += "&lc_=" + lc_;
75	}
76	modal(url,
77			"业务办理须知", {width:"70%",height:"80%"});
78}
79
80/**
81 * 退出
82 * 
83 * @param url
84 * @param target
85 */
86function logout(url, target) {
87	if(confirm("您确定要退出系统吗?")){
88		var ul = (url ? "?logout_url=" + encodeURIComponent(url) : "");
89		var contextArr = ["sfw","sfw2","sfw_u"];
90		for (var i = 0; i < contextArr.length; i++) {
91			logoutAjax("/"+contextArr[i]+"/logout"+ul);
92		}
93		window.open(getContextPath()+"/logout" + ul, target || "_self");
94		
95	}
96}
97function logoutAjax(url){
98	$.ajax({
99		"async": false,
100		"contentType" : "application/x-www-form-urlencoded; charset=UTF-8",
101		"cache" : false,
102		"url" : url,
103		"timeout" : AJAX_CONFIG["timeout"],
104		"data" : "",
105		"success" : function(rtn) {
106			console.log(rtn);
107		},
108		"error" : function(rtn) {
109			console.log(rtn);
110		},
111	});
112}
113function initCurrInnderDiv(){
114	try{
115		window.top.curr_innderdiv;
116		if(window.top.curr_innderdiv == undefined){
117			window.top.curr_innderdiv = [];
118		}
119	}catch(e){
120		;
121	}
122
123	try{
124		self.curr_innderdiv;
125		if(self.curr_innderdiv == undefined){
126			self.curr_innderdiv = [];
127		}
128	}catch(e){
129		;
130	}
131}
132initCurrInnderDiv();
133try{
134	window.top.curr_confirmdiv;
135	if(window.top.curr_confirmdiv == undefined){
136		window.top.curr_confirmdiv = [];
137	}
138}catch(e){
139	;
140}
141
142function modalHtml(html, title, options) {
143	initCurrInnderDiv();
144	options = options||{};
145	var lc_ = getQueryStringRegExp("lc_");
146	var o = $.extend(true, {}, options);
147	if (lc_) {
148		o["lc_"] = lc_;
149	}
150	var _innderdivArr = [];
151	curr_temp = "_innderdiv_"+new Date().getTime();
152	_innderdivArr.push("<div id=\""+curr_temp+"\">");
153	_innderdivArr.push(html);
154	_innderdivArr.push("</div>");
155	_innderdiv = $(_innderdivArr.join(""));
156	o.width = o.width || "80%";
157	if (o.height) {
158		if ((o.height + "").indexOf("%") > -1) {
159			var p = +(o.height.substring(0, o.height.indexOf("%")));
160			o.height = $(top).innerHeight() * p / 100;
161		}else if(!((o.height + "").indexOf("px") > -1)){
162			o.height = o.height+"px";
163		}
164	} else {
165		o.height = $(top).innerHeight() * 0.8;
166	}
167	o.callback = options.callback || function(rtn) {};
168	delete options["height"];
169	delete options["title"];
170	delete options["width"];
171	delete options["callback"];
172	var param = excuteURLParams(options);
173	if(param != ""){
174		if (url.indexOf("?") > -1) {
175			url += "&" + param;
176		} else {
177			url += "?" + param;
178		}
179	}
180	o.autoload = false;
181	o.modal = true;
182	if(title){
183		o.title = title;
184	}else{
185		
186	}
187	o.onEscape = function() {
188		top.curr_innderdiv.pop();
189		if($.isFunction(o.callback)){
190			o.callback();
191		}
192	};
193	if('undefined' !=typeof(sfwcontextpath)){
194		if(top.contextPath != undefined && top.contextPath.indexOf("/")!=0){
195			url = sfwcontextpath+"/"+url;
196		}
197	}
198	o.message = _innderdiv;
199	var dialog = top.bootbox.dialog(o);
200	dialog.callback = o.callback;
201	dialog.init(function(){dialog.find(".modal-dialog").css({"width":o.width})});
202	top.curr_innderdiv.push(dialog);
203	dialog.close=function(){
204		dialog.modal('hide');
205	}
206}
207
208/**
209 * 打开一个内部窗口.
210 * 
211 * @param url
212 *            打开的窗口的url地址
213 * @param title
214 *            窗口标题
215 * @param options
216 *            窗口选项,包含height,width,callback等等
217 */
218function modal(url, title, options,canresize) {
219	initCurrInnderDiv();
220	if((canresize || typeof canresize == 'undefined') && !contextconfig.isMobile){
221		resizeModal(url,title,options);
222	}else{
223		dialogModal(url, title, options);
224	}
225}
226
227function modal_lg(url, title, options,canresize) {
228	options = $.extend(true, {width:'90%',height:'90%'}, options);
229	modal(url,title,options,canresize);
230}
231function modal_sm(url, title, options,canresize) {
232	options = $.extend(true, {width:'60%',height:'60%'}, options);
233	modal(url,title,options,canresize);
234}
235function modal_xs(url, title, options,canresize) {
236	options = $.extend(true, {width:'40%',height:'40%'}, options);
237	modal(url,title,options,canresize);
238}
239
240/**
241 * 本窗iframe内弹出modal
242 * 
243 * @param url
244 * @param title
245 * @param options
246 * @param canresize
247 */
248function localModal(url, title, options,canresize) {
249	if((canresize || typeof canresize == 'undefined') && !contextconfig.isMobile){
250		resizeModal(url,title,options,true);
251	}else{
252		dialogModal(url, title, options,true);
253	}
254}
255function dialogModal(url, title, options,selfopen){
256	options = options||{};
257	var lc_ = getQueryStringRegExp("lc_");
258	var o = $.extend(true, {}, options);
259	if (lc_) {
260		o["lc_"] = lc_;
261	}
262
263	var openObject = top;
264	if(selfopen){
265		openObject = self;
266	}
267	
268	var _innderdivArr = [];
269	var modalId = new Date().getTime();
270	curr_temp = "_innderdiv_"+modalId;
271	_innderdivArr.push("<div id=\""+curr_temp+"\">");
272	_innderdivArr.push("<iframe src=\"about:blank\" name=\"_inner\" frameborder=\"0\" scrolling=\"auto\" style=\"width:100%;height:99%;\"></iframe>");
273	_innderdivArr.push("</div>");
274	_innderdiv = $(_innderdivArr.join(""));
275	if(contextconfig.isMobile){
276		if(o.height && (o.height+"").indexOf("px")>-1){
277		}else{
278			o.height=window.screen.height*0.88+"px";
279		}
280		o.width="95%";
281	}else{
282		o.width = o.width || "80%";
283		if (o.height) {
284			if ((o.height + "").indexOf("%") > -1) {
285				var p = +(o.height.substring(0, o.height.indexOf("%")));
286				o.height = $(top).innerHeight() * p / 100;
287				o.height = o.height-80;// 80为上下margin
288			}else if(!((o.height + "").indexOf("px") > -1)){
289				o.height = o.height+"px";
290			}
291		} else {
292			o.height = $(top).innerHeight() * 0.8;
293		}
294	}
295	o.callback = options.callback || function(rtn) {};
296	delete options["height"];
297	delete options["title"];
298	delete options["width"];
299	delete options["callback"];
300	var param = excuteURLParams(options);
301	if(param != ""){
302		if (url.indexOf("?") > -1) {
303			url += "&" + param+"&modalId="+modalId;
304		} else {
305			url += "?" + param+"&modalId="+modalId;
306		}
307	}
308	o.autoload = false;
309	o.modal = false;
310	if(title){
311		o.title = title;
312	}
313	o.onEscape = function() {
314		openObject.curr_innderdiv.pop();
315		if($.isFunction(o.callback)){
316			o.callback();
317		}
318	};
319	url = contextconfig.sfwcontextpath+"/"+url;
320	_innderdiv.find("iframe").attr("src", url).css("height",o.height);
321	o.message = _innderdiv;
322	o.size = 'large';
323	var dialog = openObject.bootbox.dialog(o);
324	dialog.callback = o.callback;
325	dialog.init(function(){dialog.find(".modal-dialog").css({"width":o.width})});
326	openObject.curr_innderdiv.push(dialog);
327	dialog.close=function(){
328		dialog.modal('hide');
329	}
330}
331
332function resizeModal(url, title, options,selfopen) {
333	var $lc = getQueryStringRegExp("$lc");
334	options = $.extend(true, {}, options);
335	if ($lc) {
336		options["$lc"] = $lc;
337	}
338	var openObject = top;
339	if(selfopen){
340		openObject = self;
341	}
342	
343//	var current = self;
344//	while(true){
345//		var currentParent = current.parent;
346//		if(currentParent == current){
347//			break;
348//		}
349//		if(currentParent == top){
350//			openObject = current;
351//		}
352//		current = currentParent;
353//	}
354	
355//	openObject = current;
356	var topDoc = openObject.$(openObject.document);
357	var topBody = openObject.$(openObject.document.body);
358	topDoc.find("#_innderdiv").remove();
359	var _innderdivArr = [];
360	curr_temp = "_innderdiv_"+new Date().getTime();
361	_innderdivArr.push("<div id=\""+curr_temp+"\" style=\"display:none\">");
362	_innderdivArr.push("<iframe name=\"_inner\" frameborder=\"0\" scrolling=\"auto\" style=\"width:100%;height:99%;\"></iframe>");
363	_innderdivArr.push("</div>");
364	
365	var _innderdiv = topDoc.find("body div[id^=_innderdiv]");
366	_innderdiv.each(function(){
367		var _innderdivParent = $(this).parent("div");
368		if(_innderdivParent.is(":hidden")){
369			$(this).remove();
370			_innderdivParent.remove();
371		}
372	});
373	topBody.append(_innderdivArr.join(""));
374	_innderdiv = topBody.find("#"+curr_temp);
375
376	var o = openObject.$.extend(true, {}, options);
377	if(contextconfig.isMobile){
378		o.width="95%";
379		if(o.height && o.height.indexOf("px")>-1 && $(window).height()*0.95 < o.height){
380
381		}else{
382			o.height=$(window).height()*0.88+"px";
383		}
384		o.width=$(window).width()*0.95+"px";
385	}else{
386		o.width = o.width || "80%";
387		o.width = o.width+"";
388		o.width = o.width.replace("px","");
389		if (o.height) {
390			if ((o.height + "").indexOf("%") > -1) {
391				var p = +(o.height.substring(0, o.height.indexOf("%")));
392				o.height = $(openObject).innerHeight() * p / 100;
393				o.height = o.height;// 80为上下margin
394			}else if(((o.height + "").indexOf("px") > -1)){
395				o.height = o.height.replace("px","");
396			}
397		} else {
398			o.height = $(openObject).innerHeight() * 0.8;
399		}
400	}
401	o.autoload = false;
402	o.modal = true;
403	o.title = title || o.title;
404	o.callback = o.callback || function(rtn) {};
405	o.close = function() {
406		if (!this.closeMethodCallBackOk) {	// 判断标志信息,确定有没有调用过回调方法
407			openObject.closeModal();
408		}
409	};
410	delete options["width"];
411	delete options["height"];
412	delete options["title"];
413	delete options["callback"];
414	delete options["closeOnEscape"];
415	var data = options;
416	for (var key in data) {
417		if ($.isFunction(data[key])) {
418			delete data[key];
419		}
420	}
421	var param = excuteURLParams(options);
422	if (url.indexOf("?") > -1) {
423		url += "&" + param;
424	} else {
425		url += "?" + param;
426	}
427	if(url.indexOf("http") != 0){
428		url = contextconfig.sfwcontextpath+"/"+url;
429	}
430	var dialogObj = _innderdiv.dialog(o)[0];
431	_innderdiv.find("iframe").attr("src", url);
432	openObject.curr_innderdiv.push(dialogObj);
433	dialogObj.callback=function(returnValue){
434		// 在关闭中处理callback;
435		// this.returnValue=returnValue;
436		this.closeMethodCallBackOk = true;	// 修改判断标志信息,防止重复调用过回调方法
437		o.callback(returnValue);
438	}
439	dialogObj.close=function(){
440		_innderdiv.dialog("close");
441	}
442	//判断是否需要关闭按钮
443	if(options.hideClose != null && options.hideClose){
444		$(dialogObj).prev().find("button.ui-dialog-titlebar-close").remove();
445	}
446}
447function resizeModalHtml(html, title, options) {
448	var $lc = getQueryStringRegExp("$lc");
449	options = $.extend(true, {}, options);
450	if ($lc) {
451		options["$lc"] = $lc;
452	}
453	var topDoc = top.$(window.top.document);
454	var topBody = top.$(window.top.document.body);
455	topDoc.find("#_innderdiv").remove();
456	var _innderdivArr = [];
457	curr_temp = "_innderdiv_"+new Date().getTime();
458	_innderdivArr.push("<div id=\""+curr_temp+"\" style=\"display:none;overflow-y:auto\">");
459	_innderdivArr.push(html);
460	_innderdivArr.push("</div>");
461	
462	var _innderdiv = topDoc.find("body div[id^=_innderdiv]");
463	_innderdiv.each(function(){
464		var _innderdivParent = $(this).parent("div");
465		if(_innderdivParent.is(":hidden")){
466			$(this).remove();
467			_innderdivParent.remove();
468		}
469	});
470	topBody.append(_innderdivArr.join(""));
471	_innderdiv = topBody.find("#"+curr_temp);
472
473	var o = parent.$.extend(true, {}, options);
474	if(contextconfig.isMobile){
475		o.width="95%";
476		if(o.height && o.height.indexOf("px")>-1 && $(window).height()*0.95 < o.height){
477
478		}else{
479			o.height=$(window).height()*0.88+"px";
480		}
481		o.width=$(window).width()*0.95+"px";
482	}else{
483		o.width = o.width || "80%";
484		o.width = o.width+"";
485		o.width = o.width.replace("px","");
486		if (o.height) {
487			if ((o.height + "").indexOf("%") > -1) {
488				var p = +(o.height.substring(0, o.height.indexOf("%")));
489				o.height = $(top).innerHeight() * p / 100;
490				o.height = o.height;// 80为上下margin
491			}else if(((o.height + "").indexOf("px") > -1)){
492				o.height = o.height.replace("px","");
493			}
494		} else {
495			o.height = $(top).innerHeight() * 0.8;
496		}
497	}
498	o.autoload = false;
499	o.modal = true;
500	o.title = title || o.title;
501	o.callback = o.callback || function(rtn) {};
502	o.close = function() {
503		if (!this.closeMethodCallBackOk) {	// 判断标志信息,确定有没有调用过回调方法
504			o.callback();
505		}
506	};
507	delete options["title"];
508	delete options["callback"];
509	var param = excuteURLParams(options);
510	var dialogObj = _innderdiv.dialog(o)[0];
511	top.curr_innderdiv.push(dialogObj);
512	dialogObj.callback=function(returnValue){
513		this.closeMethodCallBackOk = true;
514		o.callback(returnValue);
515	}
516	dialogObj.close=function(){
517		_innderdiv.dialog("close");
518	}
519	return dialogObj;
520}
521
522/**
523 * 关闭内部窗口,与上面的打开对应,一般在打开了的内部窗口中调用,以达到关闭这个窗口的作用 parent.closeModal()
524 * 
525 * @param value
526 *            父页面要接受的参数,没有则不传
527 */
528function closeModal(value) {
529	if(top.curr_innderdiv.length < 1){
530		return;
531	}
532	var dialogObj = top.curr_innderdiv.pop();
533	dialogObj.callback(value);
534	dialogObj.close();
535}
536function closeLocalModal(value) {
537	if(curr_innderdiv.length < 1){
538		return;
539	}
540	var dialogObj = curr_innderdiv.pop();
541	dialogObj.callback(value);
542	dialogObj.close();
543}
544try{
545	top.logindiv;
546	if(top.logindiv == undefined){
547		top.logindiv = {};
548		top.logindiv.hasLogin=false;
549	}
550}catch(e){}
551
552function callResource(url,data,success, error){
553	data["window_"] = "html";
554	data["t_"] = Math.random();
555	data["request_method_"] = "ajax";
556	data["browser_version_"] = $.browser.version;
557	if ($.browser.msie) {
558		data["browser_"] = "msie";
559	}
560	else {
561		data["browser_"] = "notmsie";
562	}
563	data = $.extend(true, {}, data);
564	var type = "POST";
565	if(data.$type){
566		type = data.$type;
567	}
568	delete data.$type;
569	delete data.$pagination;
570	$.ajax({
571		"async": false,
572		"dataType" : "html",
573		"type" : type,
574		"contentType" : "application/x-www-form-urlencoded; charset=UTF-8",
575		"cache" : true,
576		"url" : url,
577		"timeout" : AJAX_CONFIG["timeout"],
578		"data" : excuteURLParams(data),
579		"beforeSend" : function() {
580			// $.mask("正在提交数据,请稍等...");
581		},
582		"complete" : function() {
583			// $.unmask();
584		},
585		"success" : function(rtn) {
586			if(success){
587				if(!rtn){
588					success(rtn);
589					return;
590				}
591				if(!rtn[contextconfig.exceptionPrefix]){
592					success(rtn);
593				}else{
594					var validMsg = [];
595					var result = "";
596					try{
597						var exceptionObj = rtn;
598						if(exceptionObj.type == contextconfig.validbeanException){
599							var result = JSON.parse(exceptionObj.message);
600							for(var i in result){
601								validMsg.push(result[i].message);
602							}
603						}else{
604							var result = exceptionObj.message;
605							validMsg.push(result);
606						}
607					}catch(exception){
608						var exceptionObj = $.parseJSON(exceptionString);
609						validMsg.push(exceptionObj);
610					}
611					var messageArray = validMsg.join("<br>");
612					if (error) {
613						error(messageArray);
614					}else{
615						$.notice(messageArray,"操作失败","error","top-right");
616					}
617				}
618			}
619		},
620		"error" : function(XMLHttpRequest, textStatus, errorThrown) {
621			if(XMLHttpRequest.status == 0 || XMLHttpRequest.readyState == 0){
622				if(XMLHttpRequest.statusText == "timeout"){
623					var message = "请求超时,可能由于当前请求需要处理大量数据";
624					if (error) {
625						error(message);
626					}else{
627						$.notice(message,"请求超时","error","top-right");
628					}
629				}
630				return;
631			}
632			
633			var rtn= XMLHttpRequest.responseText;
634			if (error) {
635				error(rtn);
636			}else{
637				$.notice(rtn,"请求“"+url+"”失败","error","top-right");
638			}
639		}
640	});
641}
642function callPage(page, data, success, error){
643	data["window_"] = "html";
644	data["t_"] = Math.random();
645	data["request_method_"] = "ajax";
646	data["browser_version_"] = $.browser.version;
647	if ($.browser.msie) {
648		data["browser_"] = "msie";
649	}
650	else {
651		data["browser_"] = "notmsie";
652	}
653	var lc_ = getQueryStringRegExp("lc_");
654	data = $.extend(true, {}, data);
655	if (lc_) {
656		data["lc_"] = lc_;
657	}
658	var url = "";
659	var type = "POST";
660	if(data.$type){
661		type = data.$type;
662	}
663	data["page"] = page;
664	url = 'e';
665	url = contextconfig.sfwcontextpath+'/e';
666	if(url.indexOf("$[")>-1){
667		url = excuteExpressionD(url,$pageParam);
668	}
669	delete data.$type;
670	delete data.$pagination;
671	$.ajax({
672		"async": AJAX_CONFIG["async"],
673		"dataType" : "html",
674		"type" : type,
675		"contentType" : "application/x-www-form-urlencoded; charset=UTF-8",
676		"cache" : false,
677		"url" : url,
678		"timeout" : AJAX_CONFIG["timeout"],
679		"data" : excuteURLParams(data),
680		"beforeSend" : function() {
681			// $.mask("正在提交数据,请稍等...");
682		},
683		"complete" : function() {
684			// $.unmask();
685		},
686		"success" : function(rtn) {
687			if(success){
688				if(!rtn){
689					success(rtn);
690					return;
691				}
692				if(!rtn[contextconfig.exceptionPrefix]){
693					success(rtn);
694				}else{
695					var validMsg = [];
696					var result = "";
697					try{
698						var exceptionObj = rtn;
699						if(exceptionObj.type == contextconfig.validbeanException){
700							var result = JSON.parse(exceptionObj.message);
701							for(var i in result){
702								validMsg.push(result[i].message);
703							}
704						}else{
705							var result = exceptionObj.message;
706							validMsg.push(result);
707						}
708					}catch(exception){
709						var exceptionObj = $.parseJSON(exceptionString);
710						validMsg.push(exceptionObj);
711					}
712					var messageArray = validMsg.join("<br>");
713					if (error) {
714						error(messageArray);
715					}else{
716						$.notice(messageArray,"操作失败","error","top-right");
717					}
718				}
719			}
720		},
721		"error" : function(XMLHttpRequest, textStatus, errorThrown) {
722			if(XMLHttpRequest.status == 0 || XMLHttpRequest.readyState == 0){
723				if(XMLHttpRequest.statusText == "timeout"){
724					var message = "请求超时,可能由于当前请求需要处理大量数据";
725					if (error) {
726						error(message);
727					}else{
728						$.notice(message,"请求超时","error","top-right");
729					}
730				}
731				return;
732			}
733			if(XMLHttpRequest.status == 401){
734				if(top.logindiv.hasLogin == false){
735					top.logindiv.hasLogin = true;
736					try{
737						// 增加page参数用于notlogin.jsp判断产品化的notloginforlogin.jsp
738						var loginUrl = "login.jsp?lastAccessPage="+encodeURIComponent(contextconfig.sfwcontextpath+"/user/loginsuccess.jsp");
739						modal(loginUrl, "请先登录",{title:'请先登录',width:"95%",height:"95%",'callback':function(){
740								top.logindiv.hasLogin = false;
741								if(arguments[0] == true){
742									callAction(page, data, success, error);
743								}
744						}});
745					}catch(e){
746						top.logindiv.hasLogin = false;
747					}
748				}
749				return;
750			}
751			var rtn= XMLHttpRequest.responseText;
752			try{
753				rtn=$.parseJSON(XMLHttpRequest.responseText);
754			}catch(e){
755				$.console(rtn);
756			}
757			if(!rtn || typeof rtn =='string'){
758				if (error) {
759					error(messageArray);
760				}else{
761					$.notice(messageArray,"操作失败","error","top-right");
762				}
763			}else{
764				if(rtn && !rtn[contextconfig.exceptionPrefix]){
765					var t = XMLHttpRequest.responseText;
766					var dm = $(t).find("#ajaxMessage");
767					var message = "";
768					if (dm.length > 0) {
769						message = dm.html();
770					}
771					else {
772						if (!textStatus) {
773							if (XMLHttpRequest.status != 200) {
774								message = "访问服务端异常,HTTP错误代码:" + XMLHttpRequest.status;
775							}
776							else {
777								message = "访问服务端异常,错误原因:" + errorThrown.message;
778							}
779						}else if (textStatus == "timeout"){
780							message = "连接服务器超时。";
781						}else if (textStatus == "error"){
782							message = "服务端处理异常。";
783							return;
784						}else if (textStatus == "notmodified"){
785							message = "服务端未更新。";
786						}else if (textStatus == "parsererror"){
787							message = "解析服务端返回信息异常。";
788						}else{
789							message = textStatus;
790						}
791					}
792					if (error) {
793						error(message);
794					}else{
795						var messageArray = message.split("<br>");
796						$.notice(messageArray[0],messageArray[1],"error","top-right");
797					}
798				}else{
799					var validMsg = [];
800					var result = "";
801					var errorTitle = "";
802					try{
803						var exceptionObj = rtn;
804						if(exceptionObj.type == contextconfig.validbeanException){
805							var result = JSON.parse(exceptionObj.message);
806							for(var i in result){
807								validMsg.push(result[i].message);
808							}
809							errorTitle = "操作失败,请修改相关数据项目,原因:";
810						}else{
811							var result = exceptionObj.message;
812							validMsg.push(result);
813							errorTitle = "操作失败,原因:";
814						}
815					}catch(exception){
816						var exceptionObj = $.parseJSON(exception);
817						validMsg.push(exceptionObj);
818					}
819					var messageArray = validMsg.join("<br>");
820					if (error) {
821						error(messageArray);
822					}else{
823						$.notice(messageArray,errorTitle,"error","top-right");
824					}
825				}
826			}
827		}
828	});
829}
830
831/**
832 * 通过ajax的方式调用后台action
833 * 
834 * @param page
835 *            要调用的action地址 ,如:base.teacher.query
836 * @param data
837 *            要传递到后台Action的参数
838 * @param success
839 *            调用成功返回后的回调方法
840 * @param error
841 *            调用失败返回的回调方法
842 */
843function callAction(page, data, success, error,usePageRule) {
844	// TODO 开锁,如果同一page,开锁的情况下,不允许多次访问
845	data["window_"] = "json";
846	data["t_"] = Math.random();
847	data["request_method_"] = "ajax";
848	data["browser_version_"] = $.browser.version;
849	if(usePageRule){
850		data["referer_page_"]=getQueryStringRegExp("page",location.href);
851	}
852	if ($.browser.msie) {
853		data["browser_"] = "msie";
854	}
855	else {
856		data["browser_"] = "notmsie";
857	}
858	var lc_ = getQueryStringRegExp("lc_");
859	data = $.extend(true, {}, data);
860	if (lc_) {
861		data["lc_"] = lc_;
862	}
863	var url = "";
864	var type = "POST";
865	if(data.$type){
866		type = data.$type;
867	}
868
869	data["page"] = page;
870	url = 'e';
871	url = contextconfig.sfwcontextpath+'/e';
872
873	if(url.indexOf("$[")>-1){
874		url = excuteExpressionD(url,$pageParam);
875	}
876	delete data.$type;
877	delete data.$pagination;
878	$.ajax({
879		"async": AJAX_CONFIG["async"],
880		"dataType" : "json",
881		"type" : type,
882		"contentType" : "application/x-www-form-urlencoded; charset=UTF-8",
883		"cache" : false,
884		"url" : url,
885		"timeout" : AJAX_CONFIG["timeout"],
886		"data" : excuteURLParams(data),
887		"beforeSend" : function() {
888			// $.mask("正在提交数据,请稍等...");
889		},
890		"complete" : function() {
891			// $.unmask();
892		},
893		"success" : function(rtn) {
894			if(success){
895				if(!rtn){
896					success(rtn);
897					return;
898				}
899				if(!rtn[contextconfig.exceptionPrefix]){
900					success(rtn);
901				}else{
902					var validMsg = [];
903					var result = "";
904					try{
905						var exceptionObj = rtn;
906						if(exceptionObj.type == contextconfig.validbeanException){
907							var result = JSON.parse(exceptionObj.message);
908							for(var i in result){
909								validMsg.push(result[i].message);
910							}
911						}else{
912							var result = exceptionObj.message;
913							validMsg.push(result);
914						}
915					}catch(exception){
916						var exceptionObj = $.parseJSON(exceptionString);
917						validMsg.push(exceptionObj);
918					}
919					var messageArray = validMsg.join("<br>");
920					if (error) {
921						error(messageArray);
922					}else{
923						$.notice(messageArray,"操作失败","error","top-right");
924					}
925				}
926			}
927		},
928		"error" : function(XMLHttpRequest, textStatus, errorThrown) {
929			if(XMLHttpRequest.status == 0 || XMLHttpRequest.readyState == 0){
930				if(XMLHttpRequest.statusText == "timeout"){
931					var message = "请求超时,可能由于当前请求需要处理大量数据";
932					if (error) {
933						error(message);
934					}else{
935						$.notice(message,"请求超时","error","top-right");
936					}
937				}
938				return;
939			}
940			if(XMLHttpRequest.status == 401){
941				if(top.logindiv.hasLogin == false){
942					top.logindiv.hasLogin = true;
943					try{
944						// 增加page参数用于notlogin.jsp判断产品化的notloginforlogin.jsp
945						var loginUrl = "login.jsp?lastAccessPage="+encodeURIComponent(contextconfig.sfwcontextpath+"/user/loginsuccess.jsp");
946						modal(loginUrl, "请先登录",{title:'请先登录',width:"95%",height:"95%",'callback':function(){
947								top.logindiv.hasLogin = false;
948								if(arguments[0] == true){
949									callAction(page, data, success, error);
950								}
951						}});
952					}catch(e){
953						top.logindiv.hasLogin = false;
954					}
955				}
956				return;
957			}
958			if(XMLHttpRequest.status == 499){
959				var validMsg = [];
960				var result = "";
961				try{
962					result = $.parseJSON(decodeURIComponent(XMLHttpRequest.responseText))
963					for(var i in result){
964						validMsg.push(result[i].message);
965					}
966				}catch(exception){
967					result = XMLHttpRequest.responseText;
968					validMsg.push(result);
969				}
970				var messageArray = validMsg.join("<br>");
971				$.notice(messageArray,"操作失败","error","top-right");
972				return;
973			}
974			if(XMLHttpRequest.status == 403){
975				var validMsg = [];
976				var result = "";
977				try{
978					result = $(XMLHttpRequest.responseText).find("#ajaxMessage").html();
979					validMsg.push(result);
980				}catch(exception){
981					result = XMLHttpRequest.responseText;
982					validMsg.push(result);
983				}					
984				var messageArray = validMsg.join("<br>");
985				if (error) {
986					error(validMsg);
987				}else{
988					$.notice(messageArray,"操作失败","error","top-right");
989				}
990				return;
991			}
992			var rtn= XMLHttpRequest.responseText;
993			try{
994				rtn=$.parseJSON(XMLHttpRequest.responseText);
995			}catch(e){
996				$.console(rtn);
997			}
998			if(!rtn || typeof rtn =='string'){
999				if (error) {
1000					error(messageArray);
1001				}else{
1002					$.notice(messageArray,"操作失败","error","top-right");
1003				}
1004			}else{
1005				if(rtn && !rtn[contextconfig.exceptionPrefix]){
1006					var t = XMLHttpRequest.responseText;
1007					var dm = $(t).find("#ajaxMessage");
1008					var message = "";
1009					if (dm.length > 0) {
1010						message = dm.html();
1011					}
1012					else {
1013						if (!textStatus) {
1014							if (XMLHttpRequest.status != 200) {
1015								message = "访问服务端异常,HTTP错误代码:" + XMLHttpRequest.status;
1016							}
1017							else {
1018								message = "访问服务端异常,错误原因:" + errorThrown.message;
1019							}
1020						}else if (textStatus == "timeout"){
1021							message = "连接服务器超时。";
1022						}else if (textStatus == "error"){
1023							message = "服务端处理异常。";
1024							return;
1025						}else if (textStatus == "notmodified"){
1026							message = "服务端未更新。";
1027						}else if (textStatus == "parsererror"){
1028							message = "解析服务端返回信息异常。";
1029						}else{
1030							message = textStatus;
1031						}
1032					}
1033					if (error) {
1034						error(message);
1035					}else{
1036						var messageArray = message.split("<br>");
1037						$.notice(messageArray[0],messageArray[1],"error","top-right");
1038					}
1039				}else{
1040					var validMsg = [];
1041					var result = "";
1042					var errorTitle = "";
1043					try{
1044						var exceptionObj = rtn;
1045						if(exceptionObj.type == contextconfig.validbeanException){
1046							var result = JSON.parse(exceptionObj.message);
1047							for(var i in result){
1048								validMsg.push(result[i].message);
1049							}
1050							errorTitle = "操作失败,请修改相关数据项目,原因:";
1051						}else{
1052							var result = exceptionObj.message;
1053							validMsg.push(result);
1054							errorTitle = "操作失败,原因:";
1055						}
1056					}catch(exception){
1057						var exceptionObj = $.parseJSON(exception);
1058						validMsg.push(exceptionObj);
1059					}
1060					var messageArray = validMsg.join("<br>");
1061					if (error) {
1062						error(messageArray);
1063					}else{
1064						$.notice(messageArray,errorTitle,"error","top-right");
1065					}
1066				}
1067			}
1068		}
1069	});
1070}
1071
1072/**
1073 * 此方法目前只treeselect.js使用,主要是当treeselect异步加载数据的时候,职权范围取的是treeselect的action的职权范围,而非当前页面的,故增加此方法修复这个问题
1074 * 
1075 * @param page
1076 * @param data
1077 * @param success
1078 * @param error
1079 */
1080function callActionWithPageRule(page, data, success, error) {
1081	callAction(page,data,success,error,true);
1082}
1083
1084/**
1085 * 导出excel数据
1086 * 
1087 * @param action
1088 *            要导出excel数据的Action
1089 * @param data
1090 *            参数
1091 */
1092function exportExcel(action, data) {
1093	var data = $.extend(true, {}, data);
1094	action = action || data["action"];
1095	delete data["action"];
1096	var lc_ = getQueryStringRegExp("lc_");
1097	var data = $.extend(true, {}, data);
1098	if (lc_) {
1099		data["lc_"] = lc_;
1100	}
1101	
1102	data["window_"] = "excel";
1103	var url = 'e';
1104	if('undefined' !=typeof(sfwcontextpath)){
1105		url = sfwcontextpath+'/e';
1106	}
1107	window.open(url + "?page=" + action + "&" + excuteURLParams(data), "_blank");
1108};
1109
1110
1111/**
1112 * 替换表达式值 $[name] excuteExpressionD('$[name]',{name:'张三'})
1113 * 
1114 * @param str
1115 *            要处理的表达式
1116 * @param map
1117 *            值对象 ,一般是一个js对象
1118 * @returns 返回处理后的值
1119 */
1120function excuteExpressionD(str, map) {
1121	if (str == undefined || str == null) {
1122		return "";
1123	}
1124	str = "" + str;
1125	for ( var t in map) {
1126		while (str.indexOf("$[" + t + "]") > -1) {
1127			str = str.replace("$[" + t + "]", map[t] == null ? "" : map[t]);
1128		}
1129	}
1130	while (str.indexOf("$[") > -1) {
1131		var t1 = str.substring(0, str.indexOf("$["));
1132		var t2 = str.substring(str.indexOf("$["));
1133		t2 = t2.substring(t2.indexOf("]") + 1);
1134		str = t1 + t2;
1135	}
1136	return str;
1137}
1138
1139/**
1140 * 格式化数字
1141 * 
1142 * @param srcstr
1143 *            需要格式的数字
1144 * @param nafterdot
1145 *            格式化格式 如:"#,##0.00"
1146 * @returns 格式后的值
1147 */
1148function formatnumber(srcstr, nafterdot) {
1149	nafterdot = nafterdot || "#,##0.00";
1150	// TODO: 将format中的自定义字符换掉
1151	if (srcstr == "" || srcstr == undefined || srcstr == null || srcstr == "0") {
1152		return srcstr;
1153	}
1154	srcstr = srcstr+"";
1155	var dataArrays = srcstr.match(/[\d\.]+/g);
1156	if(dataArrays){
1157		for(var i =0;i< dataArrays.length;i++){
1158			var substr = dataArrays[i];
1159			var v = format(nafterdot, substr);
1160			srcstr = srcstr.replace(substr,v);
1161		}
1162	}
1163	return srcstr;
1164}
1165
1166
1167function decodeURLParams(url) {
1168	var p = {};
1169	if (url.indexOf("?") < 0) {
1170		return p;
1171	}
1172	url = url.substring(url.indexOf("?") + 1);
1173	var params = url.split("&");
1174	for (var i = 0; i < params.length; i ++) {
1175		var t = params[i].split("=");
1176		p[t[0]] = t[1];
1177	}
1178	return p;
1179}
1180
1181function excuteURLParams(data) {
1182	var temp = [];
1183	for ( var key in data) {
1184		if ($.isArray(data[key])) {
1185			for ( var i = 0; i < data[key].length; i++) {
1186				var t = data[key][i];
1187				temp.push(key + "=" + (t ==='' || typeof t == undefined || t==null ?"": encodeURIComponent(t)));
1188			}
1189		} else {
1190			var t = data[key];
1191			temp.push(key + "=" + (t ==='' || typeof t == undefined || t==null ?"": encodeURIComponent(t)));
1192		}
1193	}
1194	return temp.join("&");
1195}
1196
1197// 窗口关闭 window.close();
1198function windowClose() {
1199	var topInners = top.windows;// 关闭inner
1200	var topComs = top.windowComs;
1201	if (topInners != null && topInners.length > 0) {
1202		var win = topInners[topInners.length - 1];
1203		var parentWin = topComs[topComs.length - 1];
1204		if (parentWin != null) {
1205			parentWin.commitPage();
1206		}
1207		win.destroy();
1208		topInners.pop();
1209		topComs.pop();
1210	} else {
1211		window.open('','_top');
1212		window.top.close();
1213	}
1214}
1215
1216/*
1217 * Date Parsing
1218 * -----------------------------------------------------------------------------
1219 */
1220
1221/**
1222 * 将日期格式的字符串转换称 js的Date
1223 */
1224function parseDate(s, ignoreTimezone) { // ignoreTimezone defaults to true
1225	if (typeof s == 'object') { // already a Date object
1226		return s;
1227	}
1228	if (typeof s == 'number') { // a UNIX timestamp
1229		return new Date(s * 1000);
1230	}
1231	if (typeof s == 'string') {
1232		if (s.match(/^\d+$/)) { // a UNIX timestamp
1233			return new Date(parseInt(s, 10) * 1000);
1234		}
1235		if (ignoreTimezone === undefined) {
1236			ignoreTimezone = true;
1237		}
1238		return parseISO8601(s, ignoreTimezone) || (s ? new Date(s.replace("CST ","")) : null);
1239	}
1240	
1241	return null;
1242}
1243
1244
1245function parseISO8601(s, ignoreTimezone) { // ignoreTimezone defaults to false
1246	// derived from htp//delete.me.uk/2005/03/iso8601.html
1247
1248	var m = s.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?$/);
1249	if (!m) {
1250		return null;
1251	}
1252	var date = new Date(m[1], 0, 1);
1253	if (ignoreTimezone || !m[14]) {
1254		var check = new Date(m[1], 0, 1, 9, 0);
1255		if (m[3]) {
1256			date.setMonth(m[3] - 1);
1257			check.setMonth(m[3] - 1);
1258		}
1259		if (m[5]) {
1260			date.setDate(m[5]);
1261			check.setDate(m[5]);
1262		}
1263		fixDate(date, check);
1264		if (m[7]) {
1265			date.setHours(m[7]);
1266		}
1267		if (m[8]) {
1268			date.setMinutes(m[8]);
1269		}
1270		if (m[10]) {
1271			date.setSeconds(m[10]);
1272		}
1273		if (m[12]) {
1274			date.setMilliseconds(Number("0." + m[12]) * 1000);
1275		}
1276		fixDate(date, check);
1277	}else{
1278		date.setUTCFullYear(
1279			m[1],
1280			m[3] ? m[3] - 1 : 0,
1281			m[5] || 1
1282		);
1283		date.setUTCHours(
1284			m[7] || 0,
1285			m[8] || 0,
1286			m[10] || 0,
1287			m[12] ? Number("0." + m[12]) * 1000 : 0
1288		);
1289		var offset = Number(m[16]) * 60 + Number(m[17]);
1290		offset *= m[15] == '-' ? 1 : -1;
1291		date = new Date(+date + (offset * 60 * 1000));
1292	}
1293	return date;
1294}
1295
1296function fixDate(d, check) { // force d to be on check's YMD, for daylight
1297								// savings purposes
1298	if (+d) { // prevent infinite looping on invalid dates
1299		while (d.getDate() != check.getDate()) {
1300			d.setTime(+d + (d < check ? 1 : -1) * HOUR_MS);
1301		}
1302	}
1303}
1304
1305function parseTime(s) { // returns minutes since start of day
1306	if (typeof s == 'number') { // an hour
1307		return s * 60;
1308	}
1309	if (typeof s == 'object') { // a Date object
1310		return s.getHours() * 60 + s.getMinutes();
1311	}
1312	var m = s.match(/(\d+)(?::(\d+))?\s*(\w+)?/);
1313	if (m) {
1314		var h = parseInt(m[1], 10);
1315		if (m[3]) {
1316			h %= 12;
1317			if (m[3].toLowerCase().charAt(0) == 'p') {
1318				h += 12;
1319			}
1320		}
1321		return h * 60 + (m[2] ? parseInt(m[2], 10) : 0);
1322	}
1323}
1324
1325/*
1326 * Date Formatting
1327 * -----------------------------------------------------------------------------
1328 */
1329
1330
1331function formatDate(date, format, options) {
1332	return formatDates(date, null, format, options);
1333}
1334
1335
1336function formatDates(date1, date2, format, options) {
1337	var defaults = {
1338		dayNamesShort : [ "周日", "周一", "周二", "周三", "周四", "周五", "周六" ],
1339		dayNames : [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" ],
1340		monthNamesShort : [ '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月',
1341				'9月', '10月', '11月', '12月' ],
1342		monthNames : [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月",
1343				"十月", "十一月", "十二月" ]
1344	};
1345	options = options || defaults;
1346	var date = date1, otherDate = date2, i, len = format.length, c, i2, formatter, res = '';
1347	for (i = 0; i < len; i++) {
1348		c = format.charAt(i);
1349		if (c == "'") {
1350			for (i2 = i + 1; i2 < len; i2++) {
1351				if (format.charAt(i2) == "'") {
1352					if (date) {
1353						if (i2 == i + 1) {
1354							res += "'";
1355						} else {
1356							res += format.substring(i + 1, i2);
1357						}
1358						i = i2;
1359					}
1360					break;
1361				}
1362			}
1363		} else if (c == '(') {
1364			for (i2 = i + 1; i2 < len; i2++) {
1365				if (format.charAt(i2) == ')') {
1366					var subres = formatDate(date, format.substring(i + 1, i2),
1367							options);
1368					if (parseInt(subres.replace(/\D/, ''), 10)) {
1369						res += subres;
1370					}
1371					i = i2;
1372					break;
1373				}
1374			}
1375		} else if (c == '[') {
1376			for (i2 = i + 1; i2 < len; i2++) {
1377				if (format.charAt(i2) == ']') {
1378					var subformat = format.substring(i + 1, i2);
1379					var subres = formatDate(date, subformat, options);
1380					if (subres != formatDate(otherDate, subformat, options)) {
1381						res += subres;
1382					}
1383					i = i2;
1384					break;
1385				}
1386			}
1387		} else if (c == '{') {
1388			date = date2;
1389			otherDate = date1;
1390		} else if (c == '}') {
1391			date = date1;
1392			otherDate = date2;
1393		} else {
1394			for (i2 = len; i2 > i; i2--) {
1395				if (formatter = dateFormatters[format.substring(i, i2)]) {
1396					if (date) {
1397						res += formatter(date, options);
1398					}
1399					i = i2 - 1;
1400					break;
1401				}
1402			}
1403			if (i2 == i) {
1404				if (date) {
1405					res += c;
1406				}
1407			}
1408		}
1409	}
1410	return res;
1411};
1412
1413var dateFormatters = {
1414	s : function(d) {
1415		return d.getSeconds();
1416	},
1417	ss : function(d) {
1418		return zeroPad(d.getSeconds());
1419	},
1420	sss : function(d) {
1421		return zeroPad(d.getMilliseconds(), 3);
1422	},
1423	m : function(d) {
1424		return d.getMinutes();
1425	},
1426	mm : function(d) {
1427		return zeroPad(d.getMinutes());
1428	},
1429	h : function(d) {
1430		return d.getHours() % 12 || 12;
1431	},
1432	hh : function(d) {
1433		return zeroPad(d.getHours() % 12 || 12);
1434	},
1435	H : function(d) {
1436		return d.getHours();
1437	},
1438	HH : function(d) {
1439		return zeroPad(d.getHours());
1440	},
1441	d : function(d) {
1442		return d.getDate();
1443	},
1444	dd : function(d) {
1445		return zeroPad(d.getDate());
1446	},
1447	ddd : function(d, o) {
1448		return o.dayNamesShort[d.getDay()];
1449	},
1450	dddd : function(d, o) {
1451		return o.dayNames[d.getDay()];
1452	},
1453	M : function(d) {
1454		return d.getMonth() + 1;
1455	},
1456	MM : function(d) {
1457		return zeroPad(d.getMonth() + 1);
1458	},
1459	MMM : function(d, o) {
1460		return o.monthNamesShort[d.getMonth()];
1461	},
1462	MMMM : function(d, o) {
1463		return o.monthNames[d.getMonth()];
1464	},
1465	yy : function(d) {
1466		return (d.getFullYear() + '').substring(2);
1467	},
1468	yyyy : function(d) {
1469		return d.getFullYear();
1470	},
1471	t : function(d) {
1472		return d.getHours() < 12 ? 'a' : 'p';
1473	},
1474	tt : function(d) {
1475		return d.getHours() < 12 ? 'am' : 'pm';
1476	},
1477	T : function(d) {
1478		return d.getHours() < 12 ? 'A' : 'P';
1479	},
1480	TT : function(d) {
1481		return d.getHours() < 12 ? 'AM' : 'PM';
1482	},
1483	u : function(d) {
1484		return formatDate(d, "yyyy-MM-dd'T'HH:mm:ss'Z'");
1485	},
1486	S : function(d) {
1487		var date = d.getDate();
1488		if (date > 10 && date < 20) {
1489			return 'th';
1490		}
1491		return [ 'st', 'nd', 'rd' ][date % 10 - 1] || 'th';
1492	}
1493};
1494
1495function zeroPad(n, p) {
1496	p = p || 2;
1497	return ((n < Math.pow(10,p)) ? ("" + (Math.pow(10,p) + n)).substring(1) : n);
1498}
1499function getModalMinWidth(){
1500	var minWidth = "400";
1501	if(contextconfig.isMobile){
1502		minWidth = "300";
1503	}
1504	return minWidth;
1505}
1506function messageAppendOptions(options,extOptions){
1507			options = $.extend(options,extOptions);
1508	        if(options.autoClose){
1509	        	var html = [];
1510	        	html.push("<div style='text-align:center;color:#ccc;' class='message-dialog'>3秒后自动关闭</div>");
1511				$("body").append("<script>countDown(3,function(count){$('.message-dialog:last').html(''+count+'秒后自动关闭')},function(){});</script>");
1512	        	options.timer=3000;
1513				options.text=options.text+"<br/>"+html.join("");
1514	        }
1515	        return options;
1516		}
1517
1518
1519var getTopSwal = function(){
1520	var swalObj = top.swal;
1521	if(!swalObj){
1522		swalObj = swal;
1523	}
1524	return swalObj;
1525}
1526
1527var topSwal = function(options,callback){
1528	var swalObj = getTopSwal();
1529	swalObj(options,callback);
1530}
1531topSwal.close = function(){
1532	var swalObj = getTopSwal();
1533	swalObj.close();
1534}
1535topSwal.callback=function(callbackFun,param){
1536	setTimeout(function(){
1537		callbackFun(param);
1538	},400)
1539}
1540topSwal.getMsg = function(message){
1541	var style = "";
1542	if(message && message.length> 34){
1543		style = "text-align:left";
1544	}
1545	var msg = "<div style='"+style+"'>"+message+"</div>";
1546	return msg;
1547}
1548$.extend( {
1549	"mask" : function(message) {
1550		var html = [];
1551		html.push('<div id="_mask" style="display:none;overflow:hide;position:fixed;left: 0px;top: 0px;z-index: 100000;width:100%;height:100%;">');
1552		html.push('<div style="background:#000000;opacity:.3;filter:alpha(opacity=30);position: fixed;left: 0px;top: 0px;z-index:-1;width:100%;height:100%;"></div>'); 
1553		html.push('<table style="width:100%;height:100%;"><tr><td style="text-align:center;vertical-align:middle;"><span class="mask-span" style="top:40%;left:40%;position: fixed;padding: 20px;border: 1px solid #FFF;border-radius: 10px;">');
1554		html.push('<span style="opacity:.5;filter:alpha(opacity=50);width:100%;height:100%;position: absolute;
1554left: 0px;top: 0px;border-radius: 10px;z-index:-1;"></span>');
1555		html.push("<i class='icon-spinner9 spinner position-left' style='font-size:40px'></i>");
1556		html.push((message || '正在处理中,请耐心等待.......'));
1557		html.push('</span></span></td></tr></table></div>');
1558		var divObj = top.$(html.join(""));
1559		// 创建一个 Mask 层,追加到 document.body
1560		divObj.appendTo(top.$("body"));
1561		divObj.css({
1562			width: $(top.document).width(),
1563			height: $(top.document).height(),
1564		});
1565		divObj.fadeIn("slow");	
1566		var topwidth = $(top.window).width();
1567		var maskSpanObj = divObj.find(".mask-span");
1568		maskSpanObj.css({
1569			left:(((topwidth-maskSpanObj.outerWidth())/2)-20+"px")
1570		});
1571		maskSpanObj.css({
1572			left:(((topwidth-maskSpanObj.outerWidth())/2)+"px")
1573		});
1574	},
1575	"unmask" : function() {
1576		top.$("#_mask").remove();
1577	},
1578	"message" : function(message, callback,isAutoClose,extOptions) {
1579// top.bootbox.setDefaults("locale","zh_CN");
1580		var msg = topSwal.getMsg(message);
1581		var options = {
1582            title: "操作提示",
1583            text: msg,
1584            confirmButtonColor: "#3A4AA0",
1585            confirmButtonText: "知道了",
1586            type: "info",
1587            callback:callback,
1588            html:true
1589        };
1590		if($.isFunction(callback)){
1591			options.callback=callback;
1592		}
1593		if(arguments.length==2){
1594			if($.isFunction(callback)){
1595				options.callback=callback;
1596			}else if(callback == true || callback == "true"){
1597				isAutoClose = true; 
1598			}else{
1599				isAutoClose = false;
1600			}
1601		}else if(arguments.length==3){
1602			if($.isFunction(callback)){
1603				options.callback=callback;
1604			}
1605			if(isAutoClose == true || callback == "true"){
1606				isAutoClose = true; 
1607			}else{
1608				isAutoClose = false;
1609			}
1610		}
1611        if(isAutoClose){
1612        	extOptions = extOptions||{};
1613        	extOptions.autoClose = true;
1614        }
1615		options = messageAppendOptions(options,extOptions);
1616		topSwal(options,function(isConfirm){
1617			if(options.callback){
1618				topSwal.close();
1619				topSwal.callback(options.callback);
1620			}
1621        });
1622	},
1623	"warning" : function(message, callback,extOptions) {
1624		var msg = topSwal.getMsg(message);
1625		var options = {
1626            title: "警告",
1627            text: msg,
1628            type: "warning",
1629            confirmButtonColor: "#3A4AA0",
1630            confirmButtonText: "知道了",
1631            callback:callback,
1632            html:true
1633        };
1634		options = messageAppendOptions(options,extOptions);
1635		topSwal(options,function(isConfirm){
1636			if(options.callback){
1637           		topSwal.close();
1638				topSwal.callback(options.callback);
1639			}
1640        });
1641	},
1642	"error" : function(message, callback,extOptions) {
1643		var msg = topSwal.getMsg(message);
1644		var options = {
1645            title: "异常提示",
1646            text: msg,
1647            type: "error",
1648            confirmButtonColor: "#3A4AA0",
1649            confirmButtonText: "知道了",
1650            callback:callback,
1651            html:true
1652        };
1653		options = messageAppendOptions(options,extOptions);
1654		topSwal(options,function(isConfirm){
1655			if(options.callback){
1656           		topSwal.close();
1657				topSwal.callback(options.callback);
1658			}
1659        });
1660	},
1661	"confirm" : function(message, callback,extOptions) {
1662		var msg = topSwal.getMsg(message);
1663		var options = {
1664            title: "请确认",
1665            text: msg,
1666            type: "warning",
1667            showCancelButton: true,
1668            confirmButtonColor: "#3A4AA0",
1669            confirmButtonText: "确定",
1670            cancelButtonText: "取消",
1671            callback:callback,
1672            html:true
1673        };
1674        options = messageAppendOptions(options,extOptions);
1675		topSwal(options,function(isConfirm){
1676			if(options.callback){
1677           		topSwal.close();
1678				 if (isConfirm) {
1679					topSwal.callback(options.callback,true);
1680				 }else{
1681					topSwal.callback(options.callback,false);
1682				 }
1683			}
1684        });
1685	},
1686	"audit_confirm" : function(message, callback,extOptions) {
1687		extOptions = extOptions||{};
1688		extOptions.confirmButtonText='批准';
1689		extOptions.cancelButtonText='驳回';
1690        extOptions.confirmButtonColor= "#66BB6A";
1691		$.confirm(message,callback,extOptions)
1692	},
1693	"inputbox" : function(message, defaultvalue, callback, cancelbackParam, extOptionsParam) {
1694		var cancelback = null;
1695		var extOptions = null;
1696		if(extOptionsParam){
1697			extOptions = extOptionsParam;
1698		}
1699		if('function'== typeof cancelbackParam){
1700			cancelback = cancelbackParam;
1701		}else{
1702			extOptions = cancelbackParam;
1703		}
1704        var options = {
1705            title: message,
1706            text:"",
1707            type:"",
1708            showCancelButton: true,
1709            confirmButtonColor: "#3A4AA0",
1710            confirmButtonText: "确定",
1711            cancelButtonText: "取消",
1712            callback:callback,
1713            cancelback:cancelback,
1714            html:true
1715        };
1716        options = messageAppendOptions(options,extOptions);
1717        var textarea = ""
1718        var html = [];
1719		html.push("<div class='inputbox' style='margin:0px;overflow-y: auto;'>");
1720		var idSeq = contextconfig.getSequence();
1721		html.push("<textarea id='"+idSeq+"' style='width:100%;min-height:94px;padding:5px;border:1px solid #ccc;'>" + (defaultvalue || '') + "</textarea>");
1722		html.push("</div>");
1723		options.text=options.text+html.join("");
1724		topSwal(options,function(isConfirm){
1725			 if (isConfirm) {
1726				 if(options.callback){
1727					var textareaObj = $("#"+idSeq);
1728				 	if(top.swal){
1729						textareaObj = top.$("#"+idSeq);
1730				 	}
1731					var val = textareaObj.val();
1732				 	if(val){
1733           				topSwal.close();
1734           			}
1735					topSwal.callback(options.callback,val);
1736				 }
1737			}else{
1738				if(options.cancelback){
1739					topSwal.callback(options.cancelback,false);
1740				}
1741			 }
1742        });
1743		
1744	},
1745	"audit_reject" : function(taskId,title, callback) {
1746		modal("e?page=base.task.rejectadvice",title,{taskId:taskId,width:"1200px",height:"600px",callback:callback},true);
1747	},
1748	"audit_approval" : function(taskId,title, callback,defaultAdvice) {
1749		var options = {taskId:taskId,width:"1200px",height:"600px",callback:callback};
1750		options.defaultAdvice = defaultAdvice;
1751		modal("e?page=base.task.approvaladvice",title,options,true);
1752	},
1753	"appoint_actor" : function(taskId,title, callback) {
1754		var options = {taskId:taskId,width:"1000px",height:"500px",callback:callback};
1755		modal("e?page=base.task.appointActor",title,options,true);
1756	},
1757	"select_next_actor" : function(taskId,title, callback) {
1758		var options = {taskId:taskId,width:"1200px",height:"650px",callback:callback};
1759		modal("e?page=base.task.selectnextactor",title,options,true);
1760	},
1761	"getMonthAge" : function(date) {
1762		var now = new Date();
1763		var target;
1764		if (date instanceof Date) {
1765			target = date;
1766		} else {
1767			target = $.datepicker.parseDate("yy-mm-dd", date);
1768		}
1769		var c = (now.getFullYear() - target.getFullYear()) * 12
1770				+ (now.getMonth() - target.getMonth());
1771
1772		return parseInt(c / 12) + "年" + (c % 12) + "个月";
1773	},
1774	"parseNumber": function(str) {
1775		if (typeof str == 'number') return str;
1776		var v = str.replace(/,/g, '');
1777		v = v.replace('ï¿¥', '');
1778		v = v.replace('$', '');
1779		try {
1780			v = parseFloat(v);
1781		}
1782		catch (e) {
1783			v = str;
1784		}
1785		return v;
1786	},
1787	"sameValue":function(table,controlName,sameFlag){
1788		if (typeof table === 'string') {
1789			table = $("#" + table + "");
1790			if (table.length == 0) {
1791				table = $("[name='" + table + "']");
1792			}
1793			if (table.length == 0) {
1794				throw "unkown table control: " + table;
1795			}
1796		}
1797		else if (table instanceof HTMLTableElement) {
1798			table = $(table);
1799		}
1800		var t1 = new Date().getTime();
1801		var trs = table.find("tbody tr");
1802		var controls = trs.not(trs.first()).find("input[name='"+controlName+"'],select[name='"+controlName+"']");
1803		var t2 = new Date().getTime();
1804		if(!sameFlag){
1805			controls.not(firstRowControl).each(function(){
1806				if(this.setReadonly)
1807					this.setReadonly(false);
1808			})
1809			controls.removeAttr("readonly");
1810			controls.prev("[sfwtype='autocomplete']").removeAttr("readonly");
1811		}
1812		else
1813		{
1814			var t3 = new Date().getTime();
1815			controls.attr("readonly",true);
1816			controls.prev("[sfwtype='autocomplete']").attr("readonly", true);
1817			var firstRowControl = trs.first().find("input[name='"+controlName+"'],select[name='"+controlName+"']");
1818			firstRowControl.removeAttr("readonly");
1819			firstRowControl.prev("[sfwtype='autocomplete']").removeAttr("readonly");
1820			var t4 = new Date().getTime();
1821			$.console("t4-t3:"+(t4-t3))
1822			if (table.dataTable().fnGetData().length > 0) {
1823				var control = firstRowControl.eq(0);
1824				if(control.prev().is("[sfwtype='autocomplete']")) {
1825					var t5 = new Date().getTime();
1826					controls.each(function(){
1827						this.setValue({text:control[0]['aclabel'],value:control.val()});
1828						if(this.setReadonly){
1829							this.setReadonly(true);
1830						}
1831					})
1832					var t6 = new Date().getTime();
1833					$.console("t6-t5:"+(t6-t5))
1834				}else {
1835					var t7 = new Date().getTime();
1836					var value = trs.first().getData()[controlName];
1837					var t8 = new Date().getTime();
1838					$.console("t8-t7:"+(t8-t7))
1839					var t9 = new Date().getTime();
1840					if(control.is("[sfwtype='numberfield']")) {
1841						if (control.is("[numbertype='number']")) {
1842							var format = control.attr("format") || "#,###.#";
1843							value = formatnumber(value, format);
1844						}
1845						else if (control.is("[numbertype='decimal']")) {
1846							var format = control.attr("format") || "#,##0.00";
1847							value = formatnumber(value, format);
1848						}
1849						else if (control.is("[numbertype='currency']")) {
1850							var format = control.attr("format") || "#,##0.00";
1851							value = "ï¿¥" + formatnumber(value, format);
1852						}
1853					}
1854					controls.each(function(){
1855						this.setValue(value);
1856						if(this.setReadonly){
1857							this.setReadonly(true);
1858						}
1859					})
1860					var t10 = new Date().getTime();
1861					$.console("t10-t9:"+(t10-t9))
1862				}								
1863			}
1864		}
1865		
1866	},
1867	"computeFileSize": function(size, level) {
1868		if (level == undefined) level = 0;
1869		var d = ["B", "KB", "MB", "GB", "TB"];
1870		if (size >= 1024) {
1871			size = size / 1024;
1872			level ++;
1873			return $.computeFileSize(size, level);
1874		}
1875		else {
1876			return formatnumber(size, "#,###.#") + d[level];
1877		}
1878	},
1879	"capitalize": function(str) {
1880		return str.replace(/\b\w+\b/g, function(word) {   
1881			return word.substring(0,1).toUpperCase( ) +  word.substring(1);   
1882		});   
1883	},
1884	"console": function(msg) {
1885		if ( window.console && console.log ){
1886// $.console(formatDate(new Date(), "yyyy-MM-dd HH:mm:ss.sss") + " : " );
1887			console.log(msg);
1888		}
1889	},
1890	"notice":function(msg,title,type,position,options){
1891		if(typeof top.toastr == 'undefined'){
1892			console.log("没有提示插件!!");
1893			return;
1894		}
1895		var position = position||"top-center";
1896		var type = type||'info';
1897		var defaultOptions = {
1898				  "closeButton": false,
1899				  "debug": false,
1900				  "positionClass": "toast-"+position,
1901				  "onclick": null,
1902				  "showDuration": "300",
1903				  "hideDuration": "1000",
1904				  "timeOut": "3000",
1905				  "extendedTimeOut": "1000",
1906				  "showEasing": "swing",
1907				  "hideEasing": "linear",
1908				  "showMethod": "fadeIn",
1909				  "hideMethod": "fadeOut"
1910				};
1911		/*title = title || "操作提示";*/
1912		top.toastr.options = $.extend(true, defaultOptions, options||{});
1913		if("success" == type){
1914			top.toastr.success(msg,title);
1915		}else if("error" == type){
1916			top.toastr.error(msg,title);
1917		}else if("info" == type){
1918			top.toastr.info(msg,title);
1919		}else if("warning" == type){
1920			top.toastr.warning(msg,title);
1921		}
1922	}
1923});
1924/**
1925 * 获取浏览器类型及 版本
1926 * 
1927 * @returns 返回对象,两属性,type:表示浏览器类型,version:表示版本 {___anonymous25556_25557}
1928 */
1929function getUserAgent(){
1930	var Sys={};
1931	var ua=navigator.userAgent.toLowerCase();
1932	var s;
1933	(s=ua.match(/msie ([\d.]+)/))?(Sys['type']='ie',Sys['version']=s[1]):
1934	(s=ua.match(/rv:([\d.]+)/))?(Sys['type']='ie',Sys['version']=s[1]):
1935	(s=ua.match(/firefox\/([\d.]+)/))?(Sys['type']='firefox',Sys['version']=s[1]):
1936	(s=ua.match(/edge\/([\d.]+)/))?(Sys['type']='edge',Sys['version']=s[1]):
1937	(s=ua.match(/chrome\/([\d.]+)/))?(Sys['type']='chrome',Sys['version']=s[1]):
1938	(s=ua.match(/opera.([\d.]+)/))?(Sys['type']='opera',Sys['version']=s[1]):
1939	(s=ua.match(/version\/([\d.]+).*safari/))?(Sys['type']='safari',Sys['version']=s[1]):0;
1940	return Sys;
1941}
1942// 判断业务流程提交次数信息
1943$(document).ready(function() {
1944// var _audit_url = window.location.href;
1945// if(_audit_url.indexOf(".audit.") > 0 || _audit_url.indexOf(".audit_") > 0 ||
1946// _audit_url.indexOf(".audit&") > 0 || _audit_url.indexOf(".process.") > 0){
1947// var _bpm_no = getQueryStringRegExp('bpm_no');
1948// if(_bpm_no != null){
1949// callAction("base.task.getBusinessSubmitTimes", {"bpm_no": _bpm_no},
1950// function(rtn) {
1951// if(rtn > 1){
1952// $("div[sfwtype*='toolbar']:first").prepend('<span
1953// style="float:left;padding:3px;margin-top:4px;font-size:14px">'
1954// +'<i class="splashy-warning"></i>这是该业务第<b>'
1955// + rtn + '</b>次提交!<a href="javascript:void(0)"
1956// onclick="modal(\'e?page=base.task.history&bpm_no=' +_bpm_no + '\',
1957// \'业务提交历史\','
1958// +'{ '
1959// +' width : 850, '
1960// +' height : 500, '
1961// +' callback : function(rtn) { '
1962// +' } '
1963// +'})">点击查看</a>。</span>');
1964// }
1965// });
1966// }
1967// }
1968	
1969	// 替换页面导航、增加刷新按钮
1970	if($(".nav_page").length > 0 && $(".page-bar-top").length > 0 && $(".page-bar-top").eq(0).html() == ""){
1971		$(".nav_page").children("li").eq(0).prepend('<i class="nav-page-home"></i>');
1972		$(".nav_page").appendTo($(".page-bar-top"));
1973		if($(".page-bar-top").eq(0).html()!=''){
1974			$(".page-bar-top").eq(0).append('<a href="#" onclick="self.location.reload();" style="float:right;margin-top:7px;margin-right:5px"><i class="nav-page-refresh"></i>刷新</a>');
1975		}
1976	}
1977	if($(".page-bar-top").length > 0 && $(".page-bar-top").eq(0).html()== ""){
1978		$(".page-bar-top").remove();
1979	} 
1980	// 初始化到顶部的快捷按钮
1981	handleGoTop();
1982	setTableTopBorder();
1983});
1984function setTableTopBorder(){
1985	setTimeout(function(){
1986		var tableWrapper = $(".dataTables_wrapper");
1987		if(tableWrapper.prev(".table_toolbar_wrapper").length == 0){
1988			tableWrapper.css("border-top","1px solid #ddd");
1989		}
1990	},10);
1991}
1992
1993// 获取页面url参数
1994function getQueryStringRegExp(name,href){
1995	if(href ==undefined || href == ""){
1996		href = location.href;
1997	}
1998	var qop = decodeURLParams(href);
1999	return qop[name] || "";
2000}
2001
2002try{
2003	window.autoFrameInterval;
2004	if(window.autoFrameInterval == undefined){
2005		window.autoFrameInterval = [];
2006	}
2007}catch(e){
2008	;
2009}
2010
2011/**
2012 * 自动计算iframe高度,存在这种情况:当设置了高度,横向滚动条没了后ï¼
2012Œé¡µé¢å¸ƒå±€å˜åŒ–,导致main_content高度减少,下次调用此方法,会设置高度为
2013 * 
2014 * @param ruleFrame
2015 *            要计算的iframe的id
2016 * @param time
2017 *            计算周期 不传则默认是 800ms
2018 * @param together
2019 *            同步计算的jquery对象,将同步对象的min-height设为和iframe一样高。
2020 */
2021function autoFrameHeight(frameid,time,together){
2022	time = time||((Math.random()+0.5)*500+500);
2023	var autoFrameHeightInterval = setInterval(function(){
2024		var ruleFrameObj = $("#"+frameid);
2025		var offsetheight=ruleFrameObj.innerHeight();
2026		if(ruleFrameObj.contents()!=null){
2027			try{// 用于防止 跨域报错
2028				var docH = ruleFrameObj.contents().outerHeight(true);
2029				var pageContainer = ruleFrameObj.contents().find("div.page-container");
2030				var mainH = pageContainer.outerHeight(true);
2031				var _h = docH+20;//20为iframe相对比页面多的部分
2032				if(pageContainer.length > 0){
2033					_h =Math.max(docH, mainH+250);
2034				}
2035				if(mainH>10){
2036					_h = Math.max(docH, mainH+60);
2037				}
2038				// 当iframe内容为PDF等时,无法取到高度,直接设置为400
2039				if(_h == 0)
2040					_h = 400;
2041				// 20范围内不设置值
2042				if(offsetheight > _h + 150){// 减小高度的时候
2043					if(ruleFrameObj.data("lastHeight") != _h){
2044						ruleFrameObj.data("lastHeight",ruleFrameObj.height());
2045						ruleFrameObj.height(_h);
2046						ruleFrameObj.data("currentHeight",ruleFrameObj.height());
2047					}else{
2048						// 高度相同了,就会出现跳动,所以忽略掉
2049					}
2050				}else if(offsetheight < _h - 60){// 增加高度
2051					ruleFrameObj.data("lastHeight",ruleFrameObj.height());
2052					ruleFrameObj.height(_h);
2053					ruleFrameObj.data("currentHeight",ruleFrameObj.height());
2054				}
2055			}catch(e){
2056				
2057			}
2058		}
2059		if (together) {
2060			together.css("min-height", ruleFrameObj.height() + "px");
2061		}
2062	}, time);
2063	autoFrameInterval[frameid] = autoFrameHeightInterval;
2064}
2065
2066function stopAutoFrameHeight(frameid){
2067	if(autoFrameInterval[frameid] != undefined){
2068		var code = autoFrameInterval[frameid];
2069		window.clearInterval(code);
2070	}
2071}
2072/**
2073 * 打开ERP系统页面,同时传递产品、来源页等信息到目标页
2074 * 
2075 * @param url
2076 */
2077function openerp(url){
2078	var iframe=$("iframe")[0],src,action,content,param;
2079	if(iframe){
2080		src=iframe.contentWindow.location.href;
2081		action=getQueryStringRegExp("page",src);
2082		content=iframe.contentWindow.document.body.innerHTML;
2083	}
2084	else
2085		action=getQueryStringRegExp("page");
2086	param={
2087		"_from":action,
2088		"_to":"speederp.csm.customer.request",
2089		"_product":action.split(".")[0]
2090	};
2091	openWindow(url,param);
2092}
2093
2094function openpms(url,_to){
2095	var iframe=$("iframe")[0],src,action,content,param;
2096	if(iframe){
2097		src=iframe.contentWindow.location.href;
2098		action=getQueryStringRegExp("page",src);
2099		content=iframe.contentWindow.document.body.innerHTML;
2100	}
2101	else
2102		action=getQueryStringRegExp("page");
2103	param={
2104		"_from":action,
2105		"_to":_to,
2106		"_product":action.split(".")[0]
2107	};
2108	openWindow(url,param);
2109}
2110
2111if(typeof printableBill == 'undefined' || typeof printableBill == undefined ){
2112	printableBill = null;
2113}
2114
2115if(typeof billResultArray == 'undefined' || typeof billResultArray == undefined ){
2116	billResultArray = [];
2117}
2118
2119/**
2120 * 流程打印
2121 * 
2122 * @param process
2123 *            流程定义名
2124 * @param node
2125 *            节点名
2126 * @param bpm_no
2127 *            流水号
2128 * @param task_id
2129 *            任务实例id
2130 * @param params
2131 *            需要传给打印action的参数,json格式的字符串,如果存在中文,请自行编码, 如:{no:'2000101',age:'30'}
2132 */
2133function processPrint(process,node,params){
2134	if(!(process && node && bpm_no)){
2135		return;
2136	}
2137	if(params == undefined){
2138		params = {};
2139	}
2140	var data = params;
2141	data.process_ = process;
2142	data.node_ = node;
2143	callAction("base.bill.queryTemplateByProcess", data, function(templateResult) {
2144		function openPrintWindow(templateRecord,params){
2145			return function(){
2146				openPrint(templateRecord,params);
2147			};
2148		}
2149		function openPrint(templateRecord,params){
2150			if (templateRecord != undefined && templateRecord != "" ) {
2151				if(templateRecord.path!="")
2152					data.$_jasper=templateRecord.path;
2153				var url = [];
2154				url.push("e?page="+billTemplate.action);
2155				url.push("&window_="+billTemplate.defaultView);
2156				url.push("&type_=" + billTemplate.type);
2157				for (var key in params) {
2158					if (key =="window_"  || key =="type_") {
2159						continue;
2160					}
2161					url.push("&" + key + "=" + param[key]);
2162				}
2163				openWindow(url.join(","), data,"_blank");
2164			}
2165		}
2166		for(var i=0;i<templateResult.resultset.length;i++){
2167			var templateRecord = templateResult.resultset[i];
2168			window.setTimeout(openPrintWindow(templateRecord,params), 1000*i);// 为了处理当打印的
2169																			  // 业务存在多个的情况
2170		}
2171	});
2172}
2173
2174
2175
2176if(typeof printableBillMap == 'undefined' || typeof printableBillMap == undefined ){
2177	printableBillMap = [];
2178}
2179if(typeof printableBillConfigMap == 'undefined' || typeof printableBillConfigMap == undefined ){
2180	printableBillConfigMap = [];
2181}
2182if(typeof printableNodeMap == 'undefined' || typeof printableNodeMap == undefined ){
2183	printableNodeMap = [];
2184}
2185
2186/**
2187 * 能够打印的单据
2188 * 
2189 * @param businessCode
2190 * @param params
2191 */
2192function queryPrintableBill(businessCode,role,params){
2193	if(!(businessCode && role)){
2194		return;
2195	}
2196// var key = businessCode+"_"+role;
2197	if(params == undefined){
2198		params = {};
2199	}
2200	// 如果不缓存,非常影响效率
2201//	if(printableBill){
2202//		return printableBill;
2203//	}
2204//	var async = AJAX_CONFIG["async"];
2205//	AJAX_CONFIG["async"] = false;
2206//	callAction("base.business.bill.queryPrintableBill", {}, function(result) {
2207//		printableBill=result;
2208//	});
2209//	AJAX_CONFIG["async"] = async;
2210	if(typeof billAndConfigCache == 'undefined' || !billAndConfigCache ){
2211		var async = AJAX_CONFIG["async"];
2212		AJAX_CONFIG["async"] = false;
2213		callAction("base.business.bill.queryPrintableBill", {}, function(result) {
2214			billAndConfigCache = result;
2215		});
2216		AJAX_CONFIG["async"] = async;
2217	}
2218	
2219	var result = billAndConfigCache;//如果界面优引入表格,则会自动加载一个js,此js包含此变量
2220	var billList = result.bill.resultset;
2221	var billConfigList = result.billConfig.resultset;
2222	
2223	for(var i in billList){
2224		var bill = billList[i];
2225// if(bill.businessCode == businessCode){
2226// if(bill.default_use_role && bill.default_use_role.indexOf(role)!=-1){
2227				printableBillMap[""+bill.id]=bill;
2228// }
2229// }
2230	}
2231	
2232	for(var i in billConfigList){
2233		var billConfig = billConfigList[i];
2234		if(printableBillMap[billConfig.business_bill_id]){
2235			if(!printableBillConfigMap[billConfig.business_bill_id]){
2236				printableBillConfigMap[billConfig.business_bill_id]=[];
2237			}
2238			printableBillConfigMap[billConfig.business_bill_id].push(billConfig);
2239		}
2240	}
2241	
2242	if(typeof sortedNodeCache == 'undefined' || !sortedNodeCache ){
2243		var async = AJAX_CONFIG["async"];
2244		AJAX_CONFIG["async"] = false;
2245		callAction("base.business.process.node.querySortedNodeAll", {}, function(result) {
2246			sortedNodeCache = result;
2247		});
2248		AJAX_CONFIG["async"] = async;
2249	}
2250	
2251	//表格就会加载一个js文件,这个js文件里面有此变量
2252	var sortedNodeList = sortedNodeCache;
2253	for(var i in sortedNodeList){
2254		var node = sortedNodeList[i];
2255// if(node.business_code == businessCode){
2256// if(node.businessProcessCode == params.businessProcessCode){
2257				printableNodeMap[node.p+"$"+node.c]=node.o;
2258// }
2259// }
2260	}
2261}
2262
2263function getPrintableBillHtml(businessCode,role,params,businessProcessCode,currentNodeCode,state){
2264	var result = getPrintableBill(businessCode,role,params,businessProcessCode,currentNodeCode,state);
2265	var html = [];
2266	if(result && result.length > 0){
2267		for(var i=0;i<result.length;i++){
2268			var bill = result[i];
2269			var billHtml = "<a class='btn tbl-op-btn' href='javascript:printPreview(&#39;"+bill.code+"&#39;,&#39;"+bill.params+"&#39;)'>"+bill.name+"</a>";
2270			html.push(billHtml);
2271		}
2272	}
2273	return html;
2274}
2275function getPrintableBill(businessCode,role,params,businessProcessCode,currentNodeCode,state){
2276	var long1 = new Date();
2277	queryPrintableBill(businessCode, role, params);
2278	var html = [];
2279	var billList = billAndConfigCache.bill.resultset;
2280	if(billList && billList.length>0){
2281		for(var i in printableBillMap){
2282			var bill = printableBillMap[i];
2283			if(bill.business_code != businessCode || (bill.default_use_role && bill.default_use_role.indexOf(role)==-1)){
2284				continue;
2285			}
2286			var billHtml = {code:bill.code,name:bill.name,action:'e?page=base.business.bill.printpreview',params:$.toJSON(params)};
2287			// "<a class='btn'
2288			// href='javascript:printPreview(&#39;"+bill.code+"&#39;,&#39;"+$.toJSON(params)+"&#39;)'>"+bill.name+"</a>";
2289			var billConfigArray = printableBillConfigMap[bill.id+""];
2290			var needAdd  = false;
2291			var billConfig = null;
2292			if(billConfigArray){
2293				for(var j in billConfigArray){
2294					billConfig = billConfigArray[j];
2295					if(billConfig.condition){
2296						var condition = billConfig.condition.replace(new RegExp(' gt ','g')," > ");
2297						condition = condition.replace(new RegExp(' lt ','g')," < ");
2298						condition = condition.replace(new RegExp(' ge ','g')," >= ");
2299						condition = condition.replace(new RegExp(' le ','g')," <= ");
2300						condition = condition.replace(new RegExp(' eq ','g')," == ");
2301						condition = condition.replace(new RegExp(' ne ','g')," != ");
2302						condition = condition.replace(new RegExp(' and ','g')," && ");
2303						condition = condition.replace(new RegExp(' or ','g')," || ");
2304						condition = condition.replace("${","").replace("}","");
2305						var evalStr = [];
2306						for(var i in params){
2307							if(params[i]){
2308								evalStr.push("var "+i+"='"+params[i]+"'");
2309							}else{
2310								evalStr.push("var "+i+"=''");
2311							}
2312						}
2313						evalStr.push(condition);
2314						var result = false;
2315						try{
2316							result = eval(evalStr.join(";"));
2317						}catch(e){
2318							$.console(e);
2319							result = false;
2320						}
2321						needAdd = result;
2322					}else{
2323						needAdd = true;
2324					}
2325					if(needAdd){
2326						if(billConfig.business_process_code && billConfig.business_process_node_code && currentNodeCode && businessProcessCode){
2327							var currentNodeOrder = printableNodeMap[businessProcessCode+"$"+currentNodeCode];
2328							var configNodeOrder = printableNodeMap[billConfig.business_process_code+"$"+billConfig.business_process_node_code];
2329							if(state == -1){
2330								break;
2331							}else if(currentNodeOrder && configNodeOrder && configNodeOrder < currentNodeOrder){
2332								html.push(billHtml);
2333								break;
2334							}else if(state == 1){
2335								html.push(billHtml);
2336								break;
2337							}
2338						}else{
2339							html.push(billHtml);
2340							break;
2341						}
2342					}
2343				}
2344				
2345			}
2346		}
2347	}
2348	return html;
2349}
2350
2351// $.console(getPrintableBillHtml("scrap","personal",{}));
2352/**
2353 * 单据打印业务
2354 * 
2355 * @param productCode
2356 *            产品编码 如 :assets、psms
2357 * @param businessCode
2358 *            业务编码 如:apply,request
2359 * @param billCode
2360 *            报表编码 如:tag
2361 * @param params
2362 *            需要传给打印action的参数,json格式的字符串,如果存在中文,请自行编码, 如:{no:'2000101',age:'30'}
2363 */
2364function billPrint(billCode,params){
2365	if(!(billCode)){
2366		return;
2367	}
2368	if(params == undefined){
2369		params = {};
2370	}
2371// if(!(printableBill[billCode])){ 一个页面多次的可能不多,故不缓存
2372		var data = params;
2373		data.code = billCode;
2374		var async = AJAX_CONFIG["async"];
2375		AJAX_CONFIG["async"] = false;
2376		callAction("base.business.bill.queryByBusinessBill", data, function(templateRecord) {
2377			if (templateRecord) {
2378				if(data,params["print"]){
2379					$("#__printFrame").remove();
2380					var fmhtml =$("<iframe frameborder='0' height='1' width='1' id='__printFrame' name='__printFrame'></iframe>");
2381					$(document).find("body").append(fmhtml);
2382				}
2383				if(templateRecord.path!="")
2384					data.$_jasper=templateRecord.path;
2385				data.action=templateRecord.action;
2386				data.window="jasper";
2387				data.$_type="pdf";
2388				openWindow("e?page="+data.action, data,params["print"]?"__printFrame":"_blank");
2389			}
2390		});
2391		AJAX_CONFIG["async"] = async;
2392// }
2393}
2394
2395function printPreview(billCode,params){
2396	if(!(billCode)){
2397		return;
2398	}
2399	if(params == undefined){
2400		params = "{}";
2401	}
2402	var data = $.parseJSON(params);
2403	data.code = billCode;
2404	openWindow("e?page=base.business.bill.printpreview",data);
2405}
2406/**
2407 * 产品所有的单据
2408 * 
2409 * @param productCode
2410 * @returns {Array}
2411 */
2412function queryAllBill(productCode){
2413	var resultArray = [];
2414	if(billResultArray[productCode] == undefined){
2415		var async = AJAX_CONFIG["async"];
2416		AJAX_CONFIG["async"] = false;
2417		callAction("base.business.bill.querySimpleAll", {system_product_code:productCode}, function(rtn){
2418			var result = rtn.resultset;
2419			for(var i in result){
2420				var record = result[i];
2421				resultArray[record.systemProductCode+"_"+record.code]=record;
2422			}
2423		});
2424		AJAX_CONFIG["async"] = async;
2425		billResultArray[productCode]=resultArray;
2426	}
2427	return billResultArray[productCode];
2428}
2429
2430function getFileTypeByFileName(filename){
2431	if(!filename){
2432		return "default.icon.gif";
2433	}
2434	var point = filename.lastIndexOf(".");  
2435	var type = filename.substr(point+1).toLowerCase(); 
2436	if(".ai.avi.bmp.cs.dll.doc.exe.fla.gif.png.htm.html.jpg.js.mdb.mp3.pdf.ppt.rdp.swf.swt.txt.vsd.xls.xml.zip.rar.docm.docx.dotx.dotm.xlsx.xlsm.xltx.xlsb.xlam.pptx.pptm.ppsx.ppsm.potx.potm.ppam".indexOf(type) > -1){
2437		type = type+".gif";
2438	}else{
2439		type = "default.icon.gif";
2440	}
2441	return type;
2442}
2443
2444// Handles the go to top button at the footer
2445var handleGoTop = function () {
2446    var offset = 300;
2447    var duration = 400;
2448
2449    if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {  // ios supported
2450        $(window).bind("touchend touchcancel touchleave", function(e){
2451           if ($(this).scrollTop() > offset) {
2452                $('.scroll-to-top').fadeIn(duration);
2453            } else {
2454                $('.scroll-to-top').fadeOut(duration);
2455            }
2456        });
2457    } else {  // general
2458        $(window).scroll(function() {
2459            if ($(this).scrollTop() > offset) {
2460                $('.scroll-to-top').fadeIn(duration);
2461            } else {
2462                $('.scroll-to-top').fadeOut(duration);
2463            }
2464        });
2465    }
2466    
2467    $('.scroll-to-top').click(function(e) {
2468        e.preventDefault();
2469        $('html, body').animate({scrollTop: 0}, duration);
2470        return false;
2471    });
2472};
2473
2474
2475/**
2476 * 设置cookie到根目录
2477 * 
2478 * @param cookieName
2479 * @param cookieValue
2480 */
2481function setCookie(cookieName, cookieValue) {
2482	if (cookieName) {
2483		$.cookie(cookieName, cookieValue, {path: '/'});
2484	}
2485}
2486
2487/**
2488 * 获取cookie
2489 * 
2490 * @param cookieName
2491 */
2492function getCookie(cookieName) {
2493	if (cookieName) {
2494		return $.cookie(cookieName);
2495	}
2496}
2497
2498function underscoreToCamel(string) {
2499    if(string.indexOf('-') < 0 && string.indexOf('_') < 0) {
2500        return string;
2501    }
2502    return string.replace(/[-_][^-_]/g , function(match) {
2503        return match.charAt(1).toUpperCase();
2504    });
2505    
2506}
2507function camelToUnderscore(camelName) {
2508	if(camelName){}else{
2509		return "";
2510	}
2511	if(camelName.indexOf("_")>-1){
2512		return camelName;
2513	}
2514	// 先把第一个字母大写
2515	camelName = camelName.charAt(0).toUpperCase()+camelName.substring(1);
2516	var underscoreName = camelName.replace(new RegExp(/([A-Z][a-z_\d]*)/g), "$1_");
2517	// output: Pur_Order_Id_ 接下来把最后一个_去掉,然后全部改小写
2518	underscoreName = underscoreName.toLowerCase().substring(0, underscoreName.length-1);
2519    return underscoreName ;
2520}
2521// 兼容IE8 ,bootstrap-select
2522if (!Object.keys) {
2523	  Object.keys = (function() {
2524	    'use strict';
2525	    var hasOwnProperty = Object.prototype.hasOwnProperty,
2526	        hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
2527	        dontEnums = [
2528	          'toString',
2529	          'toLocaleString',
2530	          'valueOf',
2531	          'hasOwnProperty',
2532	          'isPrototypeOf',
2533	          'propertyIsEnumerable',
2534	          'constructor'
2535	        ],
2536	        dontEnumsLength = dontEnums.length;
2537
2538	    return function(obj) {
2539	      if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
2540	        throw new TypeError('Object.keys called on non-object');
2541	      }
2542
2543	      var result = [], prop, i;
2544
2545	      for (prop in obj) {
2546	        if (hasOwnProperty.call(obj, prop)) {
2547	          result.push(prop);
2548	        }
2549	      }
2550
2551	      if (hasDontEnumBug) {
2552	        for (i = 0; i < dontEnumsLength; i++) {
2553	          if (hasOwnProperty.call(obj, dontEnums[i])) {
2554	            result.push(dontEnums[i]);
2555	          }
2556	        }
2557	      }
2558	      return result;
2559	    };
2560	  }());
2561	}
2562
2563/**
2564 * 获取流程业务状态
2565 * 
2566 * @param state
2567 *            流程状态,advice 意见
2568 * @return 返回html代码:展示页面、展示方法
2569 */
2570function getBpmStateName(state,advice,nodeName){
2571	var states = {
2572			"0":{"name":"审批中","icon":"clock","color":"yellow"},
2573			"1":{"name":"已办结","icon":"check","color":"green"},
2574			"-2":{"name":"已合并","icon":"size-actual","color":"green"},
2575			"-1":{"name":"被驳回","icon":"close","color":"red"},
2576			"-9":{"name":"已撤回","icon":"mail-reply","color":"default"},
2577			"ns":{"name":"未提交","icon":"cloud-upload","color":"default"}
2578			};
2579	if(state === null || state === ""){
2580		state = "ns";
2581	}
2582	var html = [];
2583	if(states[state]){
2584		var name = states[state].name;
2585		var color = states[state].color;
2586		var icon = states[state].icon;
2587		// 审批中
2588		if(state == 0 && nodeName){
2589			name = "待"+ nodeName;
2590		}
2591		html.push('<span class="font-'+color+'"><span class="icon-'+icon+'"></span>&nbsp;'+name+'</span>');
2592		if(advice && state == -1){
2593			html.push(',<span class="font-'+color+'">'+advice+'</span>');
2594		}
2595	}
2596	return html.join("");
2597}
2598function getContextPath() {
2599	if(document.cookie.indexOf("contextpath")>-1){
2600		var arr,reg=new RegExp("(^| )contextpath=([^;]*)(;|$)");
2601		if(arr=document.cookie.match(reg)){
2602			if(unescape(arr[2]) == "\"\""){
2603				return "";
2604			}else{
2605				return unescape(arr[2]);
2606			}
2607		}
2608	}
2609    var pathName = document.location.pathname;
2610    var index = pathName.substr(1).indexOf("/");
2611    var result = pathName.substr(0,index+1);
2612    return result;
2613}
2614
2615/*
2616 * 业务入口按钮,不足4个,自动补齐占位
2617 */
2618function createBlankBlockButton(){
2619	if($(".top-news").length > 0){
2620		var blankBlockButtonHtml = '<div class="col-lg-3 hidden-md hidden-sm hidden-xs">'+
2621		'<div style=" background: #fff; border: 1px dashed #eee;height:61px;margin-top:0px;
2621cursor: not-allowed;">'+
2622		'</div></div>';
2623		var obj = $(".top-news").parent().parent();
2624		var i = obj.find(".top-news").length;
2625		if(i % 4 != 0) {
2626			for (var j=0;j < (4- (i % 4));j++){
2627				obj.append(blankBlockButtonHtml);
2628			}
2629		}
2630	}
2631}
2632createBlankBlockButton();
2633
2634// var buttonclick = function(){
2635// var $this = $(this);
2636// if($this.hasClass("readonly")){
2637// return;
2638// }
2639// $this.addClass("readonly");
2640// $(document).off("click","a[data-buttonsequence='"+$this.attr("data-buttonsequence")+"']");
2641// setTimeout(function(){
2642// $this.removeClass("readonly");
2643// $(document).on("click","a[data-buttonsequence='"+$this.attr("data-buttonsequence")+"']",function(){eval(this.onclickfun);});
2644// $(document).on("click","a[data-buttonsequence='"+$this.attr("data-buttonsequence")+"']",buttonclick);
2645// }, 3000);
2646// }
2647//
2648// function buttonClickSet(){
2649// $("a[data-buttonsequence]").each(function(){
2650// var $this = $(this);
2651// var href = $this.attr("href");
2652// var onclickfun = $this.attr("onclick");
2653// $this.attr("onclickfun",onclickfun);
2654// this.onclickfun = onclickfun;
2655// if(onclickfun){
2656// $this.removeAttr("onclick");
2657// $this.attr("href","javascript:void(0);");
2658// $(document).on("click","a[data-buttonsequence='"+$this.attr("data-buttonsequence")+"']",function(){eval(onclickfun);});
2659// $(document).on("click","a[data-buttonsequence='"+$this.attr("data-buttonsequence")+"']",buttonclick);
2660// }
2661// });
2662// }
2663$(document).ready(function(){
2664	viewConfigModalSet();
2665// buttonClickSet();
2666	//由于这里定时设置body的宽度,会导致modal框的body过宽,部分内容超出右边界
2667	/*if (navigator.userAgent.match(/iPad|iPhone/i) && top != self){
2668		setInterval(function(){ 
2669				if($("body").width != $(top).width()){
2670					$("body").width($(top).width());
2671				}
2672	    },1000);
2673	}*/
2674})
2675function viewConfigModalSet(){
2676	$(document).on("dblclick",".sfw-config-modal",function(){
2677		var $this = $(this);
2678		toViewConfigPage($this);
2679	});
2680}
2681function toViewConfigPage($this){
2682	var data = {};
2683	var attrs = $this[0].attributes;
2684	var prx = "data-s";
2685	for(var i in attrs){
2686		if(typeof attrs[i] == "object" && attrs[i].name.indexOf(prx) == 0){
2687			if($this.attr(attrs[i].name)){
2688				data[attrs[i].name.substring(prx.length)]=attrs[i].value;
2689			}
2690		}
2691	}
2692	data.pageCode=data.pagecode;
2693	data.formId=data.formid;
2694	data.scid=data.cid;
2695	data.minLength=data.minlength;
2696	data.maxLength=data.maxlength;
2697	// stype主要是复合组件,获取sfwtype错误的问题
2698	data.componentType = $this.attr("stype") || $this.find("[sfwtype]").eq(0).attr("sfwtype");
2699	delete data.pagecode;
2700	delete data.formid;
2701	delete data.minLength;
2702	delete data.maxLength;
2703	delete data.cid;
2704	data.callback=function(rtn){
2705		if(rtn){
2706			location.reload(true);
2707		}
2708	}
2709	var param = {};
2710	param.height="85%";
2711	param.width="85%";
2712	param.content = JSON.stringify(data);// encodeURIComponent(
2713	top.viewconfigparam=param;
2714	modal("e?page=base.system.view.config.entry","界面配置","");
2715}
2716
2717var _configBtn = null;
2718function btnViewConfig(){
2719	if(_configBtn){
2720		toViewConfigPage(_configBtn);
2721	}
2722}
2723if($("body").hasClass("config-modal-body")){
2724	var menud = $("#__menu");
2725	window.oncontextmenu=function(e){
2726		//取消默认的浏览器自带右键 很重要!!
2727		var src = e.srcElement;
2728		var $this = $(src);
2729		if($this.attr("sfwtype") == "button"){
2730			_configBtn = $this;
2731		}else{
2732			var parentBtn = $this.parents("[sfwtype='button']");
2733			if(parentBtn.length > 0){
2734				_configBtn = parentBtn.eq(0);
2735			}
2736		}
2737		if(_configBtn){
2738			//获取我们自定义的右键菜单
2739			//根据事件对象中鼠标点击的位置,进行定位
2740			var css = {"left":e.clientX+'px',
2741					"top":e.clientY+'px',
2742					"width":'125px',
2743					"height":'25px'};
2744			menud.css(css);
2745			_configBtn.attr("data-slabel",_configBtn.text());
2746			menud.show();
2747			e.preventDefault();
2748		}else{
2749			menud.hide();
2750		}
2751	}
2752	//关闭右键菜单,很简单
2753	window.onclick=function(e){
2754		menud.hide();
2755	}
2756}
2757/*
2758 * 获取一个进度条的html val-百分比 color:danger 红色 success 绿色
2759 */
2760function getProgressHtml(val,color){
2761	var html="";
2762	html += '<div class="progress progress-striped active" sfwtype="progress" max="100" class="col-xs-12" min="0" value="'+val+'" style="margin-bottom: 0px;">';
2763	html += '<div class="progress-bar progress-bar-'+color+'" role="progressbar" aria-valuenow="'+ val +'" aria-valuemin="0" aria-valuemax="100" style="width: '+val+'%;">';
2764	html += '</div><div class="progress-text">'+ val + '%</div>';
2765	html += '</div>';
2766	return html;
2767}
2768
2769String.prototype.startWith=function(str){ var reg=new RegExp("^"+str); return reg.test(this); } 
2770String.prototype.endWith=function(str){ var reg=new RegExp(str+"$"); return reg.test(this); }
2771
2772/**
2773 * 保护隐私(将部分字符串替换为*)
2774 * 
2775 * @param {String}
2776 *            val 需要处理的数据
2777 * @param {Number}
2778 *            starCount 替换为星号个数,使用小数时则是占总长度的百分比(可为空)
2779 * @param {Number}
2780 *            endCount 末尾保留显示个数,使用小数时则是占总长度的百分比(可为空)
2781 */
2782function hideData(val, starCount, endCount) {
2783	if (!starCount) {
2784		starCount = 4;	// 默认值
2785	}
2786	if (!endCount) {
2787		endCount = 1;	// 默认值
2788	}
2789	var len = val.length;
2790	if (starCount < 1) {
2791		starCount = Math.round(len * starCount);
2792	}
2793	if (endCount < 1) {
2794		endCount = Math.round(len * endCount);
2795	}
2796	if (len < endCount) {
2797		return val;
2798	} else if (len < starCount + endCount) {
2799		val = val.substring(len - endCount, len);
2800		while (val.length < len) {
2801			val = "*" + val;
2802		}
2803		return val;
2804	} else {
2805		var tmp = val.substring(0, len - endCount - starCount);
2806		for (var i = 0; i < starCount; i++) {
2807			tmp += '*';
2808		}
2809		tmp += val.substring(len - endCount, len);
2810		val = tmp;
2811		return val;
2812	}
2813}
2814
2815function auditClose() {
2816	top.closeAndRefreshOpener();
2817}
2818function auditRefreshOpener() {
2819	top.refreshOpener();
2820}
2821
2822aduitRefreshOpener=auditRefreshOpener;
2823aduitClose=auditClose;
2824function countDown(count,generalback,finishback) {
2825	window.setTimeout(function() {
2826		count--;
2827		if (count > 0) {
2828			generalback.call(this,count);
2829			countDown(count,generalback,finishback);
2830		} else {
2831			finishback.call(this,count);
2832		}
2833	}, 1000);
2834}
2835
2836function label(name,defaultValue){
2837	if(typeof labelCache == "undefined"){
2838		var async = AJAX_CONFIG["async"];
2839		AJAX_CONFIG["async"] = false;
2840		callAction("base.business.configLabel.queryAllByCache", {}, function(templateResult) {
2841			labelCache = templateResult;
2842		});
2843		AJAX_CONFIG["async"] = async;
2844	}
2845	var value = labelCache[name];
2846	if(!value){
2847		return defaultValue;
2848	}else{
2849		return value.label;
2850	}
2851}
2852function fullscreen(obj) {
2853	$(top).find("body").append(obj[0]);
2854}
2855
2856var arrayUnique=function(filesStr){
2857// 去重 begin
2858	if(!filesStr){
2859		return filesStr;
2860	}
2861	var filesArray = filesStr.split(",");
2862	var res = [];
2863	var tmpJson = {};
2864	for (var i = 0; i < filesArray.length; i++) {
2865		var curVal = filesArray[i];
2866		if(!tmpJson[curVal]){
2867			res.push(curVal);
2868			tmpJson[curVal]=1;
2869		}
2870	}
2871	return res.join(",");
2872// 去重 end
2873}
2874function fileNameReplace(fileName){
2875	return fileName.replace(new RegExp('[\'\(\) =]','g'),"_");
2876}
2877// 用于判断上传是否完成begin
2878if (typeof $FileImageStateObj == 'undefined') {
2879	$FileImageStateObj = {};
2880	$FileImageStateObj.setState = function(id, state) {
2881		if ($FileImageStateObj.hasOwnProperty(id)) {
2882			var uping = false;
2883			for ( var pro in $FileImageStateObj) {
2884				if (pro == id) {
2885					$FileImageStateObj[pro] = state;
2886				}
2887				if (pro != "setState") {
2888					if ($FileImageStateObj[pro] == 1) {
2889						uping = true;
2890					}
2891				}
2892			}
2893			if (uping) {
2894				$FileImageState = 1;
2895			} else {
2896				$FileImageState = 0;
2897			}
2898		} else {
2899			eval("$FileImageStateObj." + id + "=" + state);
2900		}
2901	};
2902}
2903
2904var Global = {};
2905
2906/**
2907 * datatable changeRow数据处理 返回处理结果
2908 */
2909Global.handleChangeRow = function(field, record, changeRowFieldValue) {
2910	var fieldValue = changeRowFieldValue[field];
2911	var valueType = typeof fieldValue;
2912	var html = "";
2913	if(valueType == undefined) {
2914		html = record[field];
2915	} else if(valueType == "function") {
2916		html = fieldValue(record);
2917	} else if (valueType == "string") {
2918		html = fieldValue;
2919	}
2920	return html;
2921};
2922
2923/**
2924 * 处理tab.panel组件中iframe内容页面的padding,美化展示效果 Author Robin 2017.12.20
2925 * tab.panel内部padding导致内容对不齐
2926 */
2927$(parent.document).find("iframe").each(function(){
2928	var id = $(this).attr("id");
2929	if(id && id.indexOf('ab_panel_frame') > 0){
2930		$(".content").css("padding","0px 0px 30px 0px");
2931		return false;
2932	}
2933});
2934
2935/*******************************************************************************
2936 * ***处理tab组件上的queryform组件样式 Author Robin 2018.1.2 **************** *
2937 ******************************************************************************/
2938if($('.tab-container').parent().find("div.query-form-div").length > 0 ){
2939	$(".query-form-div").find('.search-bar').addClass('mb20');
2940	$(".query-form-div").find('.query-default').addClass('has-border-bottom');
2941}
2942
2943
2944function businessSuccess(bpmNo, buttons,intro) {
2945	var param = {};
2946	param.bpmNo=bpmNo;
2947	param.buttons=buttons;
2948	param.intro=intro;
2949	openWindow("e?page=base.business.success",{data:JSON.stringify(param)},"_self");
2950}
2951// 解决jquery-ui导致inputbox textarea输入不行的问题
2952top.$("body").delegate(".inputbox textarea","focusin",function(event){
2953	event.stopPropagation();
2954	return false;
2955})
2956var tools = {};
2957tools.statisticByAction = function(action,actionParam,statisticParam,callback){
2958	var actionParam = $.extend(true, actionParam||{}, {limit:1,start:0,chartsprovider_:"noQuery"});
2959	callAction(action,actionParam,function(r){
2960		statisticParam = statisticParam||{};
2961		statisticParam.queryId=r.queryId;
2962		statisticParam = {data:JSON.stringify(statisticParam)};
2963		callAction("base.charts.query", statisticParam, function(rtn) {
2964			callback(rtn);
2965		});
2966	});
2967}
2968$(function(){setTimeout(function(){__customePageNote()},5000);});
2969
2970function __customePageNote(){$('.customePageNote').hide(500)};
2971
2972
2973/**
2974 * title	新开tab页标题
2975 * url		tab页链接地址
2976 * target	使用框架tab还是浏览器tab,_blank 使用浏览器tab打开,_frame使用框架tab打开
2977 * */
2978function openTab(title,url,target){
2979	try{
2980		//判断是否在iframe内,是则调用父页面的openTab方法
2981		if(self.frameElement && self.frameElement.tagName == "IFRAME"){
2982			parent.openTab(title,url,target);
2983		}else if(homeTab != null){
2984			homeTab.open(title,url,target);
2985		}else{
2986			throw "openTab异常";
2987		}
2988	}catch(err){
2989		if(target == "_blank"){
2990			open(url);
2991		}else{
2992			window.location.href = url;
2993		}
2994	}
2995}
2996
2997StringFormat = function () {
2998    if (arguments.length == 0)
2999        return null;
3000
3001    var str = arguments[0];
3002    for (var i = 1; i < arguments.length; i++) {
3003        var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
3004        str = str.replace(re, arguments[i]);
3005    }
3006    return str;
3007}
3008
3009function copy(str){
3010	var save = function (e){
3011		e.clipboardData.setData('text/plain',str);//下面会说到clipboardData对象
3012		e.preventDefault();//阻止默认行为
3013	}
3014	document.addEventListener('copy',save);
3015	document.execCommand("copy");//使文档处于可编辑状态,否则无效
3016	$.message("复制成功!");
3017}
3018
3019//调用拨号功能
3020function callPhone(phoneNumber){
3021	if(isMobile){
3022		window.location.href = 'tel:' + phoneNumber;
3023	}else{
3024		$.message("唤出系统拨号功能仅支持手机端使用!");
3025	}
3026}
3027
3028
3029$(document).ready(function(){
3030	//console.log(location.href);
3031	//console.log(location.href.indexOf("_inner=true"));
3032	if(location.href.indexOf("_inner=true") > -1){
3033		console.log("=================aaaaaaaa=========");
3034		$("body").addClass("bg-fff");
3035		$(".content").attr("style","padding:0px !important");
3036	}
3037	if($(".page-footer-default").length > 0){
3038		$(".content:first").addClass("had-footer");
3039	}
3040})
3041
3042var link = {};
3043
3044/**
3045 * 获取操作列操作下拉html代码
3046 * 
3047 * @param links
3048 *            数组 一般短操作链接,billLink 数组 单据、长链接
3049 * @return 返回html代码
3050 */
3051link.operation = function(links,billLink) {
3052	var len = 6;
3053	if(billLink != undefined && billLink != null ){
3054		if(billLink.length > 0){
3055			len = len - 1;
3056		}
3057		$.merge(links, billLink);
3058	}else if(links.length > len){
3059		len = len - 1;
3060	}
3061	var html = [];
3062	html.push("<div class='table-btn-box'>");
3063	for (var i = 0; i < links.length && i < len; i++) {
3064		html.push(links[i]);
3065	}
3066	if (links.length > len) {
3067		html.push("<div class='btn-group'>");
3068		html
3069				.push("<button class='btn btn-xs dropdown-toggle font-blue' type='button' data-toggle='dropdown' aria-expanded='false' style='background:none'>更多&nbsp;<i class='fa fa-angle-down'></i></button>");
3070		html.push("<ul class='dropdown-menu' role='menu'>");
3071		for (var i = len; i < links.length; i++) {
3072			html.push("<li>");
3073			html.push(links[i]);
3074			html.push("</li>");
3075		}
3076		html.push("</ul></div>");
3077	}
3078	html.push("</div>");
3079	return html.join("");
3080}
3081
3082
3083/**
3084 * 获取教师资产类详情信息 如果base_teacher_no不为空返回详情链接
3085 * 
3086 * @param base_teacher_no
3087 *            教师编号,text 教师名称
3088 * @return 返回html代码:展示页面、展示方法
3089 */
3090link.teacher = function(base_teacher_no, text) {
3091	if(!text){
3092		return "";
3093	}
3094	return '<a href="javascript:void(0)" onclick="modal(&#39;e?page=base.teacher.detail&no='+base_teacher_no+'&#39;,&#39;详情&#39;,{width : &#39;85%&#39;,height : 600})">'+text+'</a>';
3095}
3096/**
3097 * 获取存放地资产类详情信息 如果base_room_id不为空返回详情链接
3098 * 
3099 * @param base_room_id
3100 *            房间编号,text 存放地名称
3101 * @return 返回html代码:展示页面、展示方法
3102 */
3103link.room = function(base_room_id, text) {
3104	if(!text){
3105		return "";
3106	}
3107	return '<a href="javascript:void(0)" onclick="modal(&#39;e?page=base.room.detail&id='+base_room_id+'&#39;,&#39;详情&#39;,{width : &#39;85%&#39;,height : 600})">'+text+'</a>';
3108}
3109/**
3110 * 获取单位资产类详情信息 如果base_dep_code不为空返回详情链接
3111 * 
3112 * @param base_dep_code
3113 *            单位编号,text 显示内容
3114 * @return 返回html代码:展示页面、展示方法
3115 */
3116link.dep = function(base_dep_code, text) {
3117	if(!text){
3118		return "";
3119	}
3120	return '<a href="javascript:void(0)" onclick="modal(&#39;e?page=base.dep.detail&code='+base_dep_code+'&#39;,&#39;详情&#39;,{width : &#39;85%&#39;,height : 600})">'+text+'</a>';
3121}
3122/**
3123* 获取业务流程详情
3124* 
3125* @param bpm_no
3126*            业务号,text展示的内容
3127* @return 返回html代码:展示页面、展示方法
3128*/
3129link.bmp = function(bpm_no, text) {
3130	var html = [];
3131	if (bpm_no != null && text != null) {
3132		return '<a target="newblank" href="e?page=base.task.detail&bpmNo='
3133				+ bpm_no + '">' + text + '</a>';
3134	} else if (text) {
3135		return text;
3136	} else {
3137		return "";
3138	}
3139}
3140
3141
3142/**
3143* 获取当前页面url中的参数
3144* 
3145* @param name
3146*           待获取参数名称
3147* @return    参数对应的值,若没有返回null
3148*/
3149function getUrlParam(name)
3150{
3151	var query = window.location.search.substring(1);
3152	var vars = query.split("&");
3153	for (var i=0;i<vars.length;i++) {
3154		var pair = vars[i].split("=");
3155		if(pair[0] == name){
3156			return pair[1];
3157		}
3158	}
3159	return null;
3160}
3161/**
3162 * 用于调整 
3163 * 问题反馈,我要吐槽等按钮使用在线客服
3164 * @returns
3165 */
3166function openKf(){
3167	//判断当前页面是否有在线客服组件
3168	if ($("#kf5-support-btn")[0]){
3169		$('#kf5-support-btn').click();
3170	}else if(self.frameElement && self.frameElement.tagName == 	"IFRAME"){
3171		//判断是否在iframe内,是则调用父页面的openKf方法
3172		parent.openKf();
3173	}
3174}
3175
3176

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.