| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634 |
- //此文件为页面载入时需要初始化的内容以及事件
-
- jQuery(function(){
-
-
- /**
- * 判断对象disabled状态
- * @param obj 对象
- * @returns true/false
- */
- function isDisabled(obj) {
- if (obj.disabled) {
- return true;
- }
- return false;
- }
-
- //捕捉键盘事件
- jQuery(document).keydown(function(event){
- var el= event.target || event.srcElement;
- var iLen=0;
- var str="";
-
- if (event.keyCode == 9){//TAB
- return true;
- }
-
- if(event.keyCode==8){ //backspace
- return true;
- }
- if(event.keyCode==46){ //delete
- return true;
- }
-
-
- //处理组合键-快捷方式 ctrl+s、ctrl+y、ctrl+d、ctrl+m、ctrl+q
- //s=83 y=89 n=78 d=68 m=77 q=81
- if(event.ctrlKey && event.keyCode==83){
- $("a").each(function(){
- if(this.keycomb=='ctrl+s' && !isDisabled(this)){
- $(this).trigger("click");
- return true;
- }
- });
- }
-
- if(event.ctrlKey && event.keyCode==89){
- $("a").each(function(){
- if(this.keycomb=='ctrl+y' && !isDisabled(this)){
- $(this).trigger("click");
- return false;
- }
- });
- }
-
- if(event.ctrlKey && event.keyCode==76){
- $("a").each(function(){
- if(this.keycomb=='ctrl+l' && !isDisabled(this)){
- $(this).trigger("click");
- return false;
- }
- });
- }
-
-
- if(event.altKey && event.keyCode==81){
- $("a").each(function(){
- if(this.keycomb=='alt+q' && !isDisabled(this)){
- $(this).trigger("click");
- return true;
- }
- });
- }
-
- if(event.ctrlKey && event.keyCode==68){
- $("a").each(function(){
- if(this.keycomb=='ctrl+d' && !isDisabled(this)){
- $(this).trigger("click");
- return true;
- }
- });
- }
-
- if(event.ctrlKey && event.keyCode==77){
- $("a").each(function(){
- if(this.keycomb=='ctrl+m' && !isDisabled(this)){
- $(this).trigger("click");
- return true;
- }
- });
- }
-
-
- if(event.ctrlKey && event.keyCode==81){
- $("a").each(function(){
- if(this.keycomb=='ctrl+q' && !isDisabled(this)){
- $(this).trigger("click");
- return true;
- }
- });
- }
-
-
- //x=88 信息提示框关闭
- if(event.ctrlKey && event.keyCode==88){
- $("div.fwmessager-tool-close").each(function(){
- if(this.keycomb=='ctrl+x' && !isDisabled(this)){
- $(this).trigger("click");
- return true;
- }
- });
- $("a").each(function(){
- if(this.keycomb=='ctrl+x' && !isDisabled(this)){
- $(this).trigger("click");
- return true;
- }
- });
- }
-
- //单击回车调用TAB键
- if(jQuery(el).is('.textbox,.notpastebox,.datebox,.datetime,.floatbox,.numberbox,.chinessbox,.yearmonthbox,.timebox,.checkbox,.postbox,.phonebox,.idcardbox,.combobox,.zjtextbox,.fwcombox-text,.searchgridbox')){
- if (event.keyCode == 13) {
- event.keyCode = 9;
- return true;
- }
- }
-
- return true;
- });//jQuery(document).keydown 结束
-
-
- //处理按钮
- jQuery('.buttonlink',document).each(function(){
- var plain = $(this).attr("plain");
- if(plain=="false"||plain==null||plain==""){
- $(this).attr({"plain":"true"});
- $(this).linkbutton({plain:false});
- }
- });
-
-
- try {
- //导航栏固定 代码开始
- //以下的代码是为了把本页的导航栏提交到frame名为 navigation 的DIV
- //为了实现导航栏固定在最上方
- var obj_navigator_button = document.all._navigator_button;
-
- if(typeof document.all._menu_button != 'undefined'){
- if(typeof obj_navigator_button != 'undefined'){
- var obj = document.all._menu_button;
- jQuery(obj_navigator_button).html(obj.innerHTML);
- }
- }
- //获取同级的frames的DIV
- if(typeof self.parent.navigation!='undefined'){
-
- if(typeof self.parent.navigation._navigator!='undefined'){
-
- var obj_navigator = self.parent.navigation._navigator;
- var obj_content_navigator = jQuery("#content_navigator");
-
- if(typeof obj_content_navigator != 'undefined' ) {
-
- if(typeof obj_navigator != 'undefined'){ //存在就替换
-
- jQuery(obj_navigator).html(obj_content_navigator.html());
-
- obj_navigator_button = self.parent.navigation._navigator_button;
-
- if(typeof obj_navigator_button != 'undefined'){
-
- jQuery('a',obj_navigator_button).each(function(){
- var tmp = jQuery(this).attr('onclick')+'';
- if(tmp!=null&&tmp!=''){
- var iPos1 = tmp.indexOf('{')+1;
- var iPos2 = tmp.indexOf('}');
- var iLen = iPos2 - iPos1;
- tmp = tmp.substr(iPos1,iLen);
- tmp = "self.parent.workspace." + tmp;
- //这样处理的目的是为了另一层的FRAMES可以执行workspace的函数
- jQuery(this).removeAttr('onclick');
-
- try{
- jQuery(this).bind('click',function(){eval(tmp)});
- }catch(e){}
- }
- });
-
- }
-
-
- }else{
- //不存在就直接显示
- jQuery(document.all.content_navigator).css({display:'block'});
- }
- }else{
- if(typeof obj_navigator != 'undefined'){
- jQuery(obj_navigator).html('');
- }
- }
- }
- }else{
-
- //这种是针对frameset 内还有frameset的情况
- if(typeof self.parent.parent.navigation!='undefined'){
- //如果内嵌的frame/iframe是报表的话,不刷新到导航栏
- if(null != self.location && null != self.location.href && -1!=self.location.href.indexOf("/report.do")){
- //do nothing
- }else{
- var obj_navigator = self.parent.parent.navigation._navigator;
- var obj_content_navigator = jQuery("#content_navigator");
-
- if(obj_content_navigator.size()!=0){ //存在就替换
- jQuery(obj_navigator).html(obj_content_navigator.html());
- }
- }
- }
- }
- //导航栏固定 代码结束
- }catch (ex) {
- //jQuery(document.all.content_navigator).css({display:'block'});
- }
-
- });
- /**
- * 初始化通用树弹出框
- * @param options
- * root 树的根节点
- * whereCls 树节点的查询条件
- * selected 已选结构的机构代码orgcocde
- * bussFuncId 业务通办的业务ID
- */
- function FwOpenOrgTree(options){
- var w=350;
- var h=500;
- var l = (screen.Width-w)/2;
- var t = (screen.Height-h)/2;
- var transpage=contextPath + "/jsp/framework/orgTree.jsp?";
- var locStr = "dialogLeft:" + l + ";dialogTop:" + t;
- var position="status:0;help:0;dialogWidth:"+w+"px;dialogHeight:"+h+"px;"+locStr;
- options['_t']=new Date().getTime();
- var url=transpage+$.param(options,true);
- return showModalDialog(url,null,position);
- }
- /**
- * 验证提示框
- * e.g:
- * FWvalidateTip(document.wfForm.XM,"姓名输入不合法");
- *
- * FWvalidateTip("form[name='wfForm'] input[name='XM']","姓名输入不合法!");
- *
- * @param findObj jQuery查找串或对象
- * @param msg 提示信息
- */
- function FWvalidateTip(findObj,msg) {
- //延迟2秒
- var defaults = {content: {text: msg},
- hide: { delay:2000,
- event: false,
- inactive: 3000},
- position: {
- my: 'center left', // 默认显示在右侧
- at: 'center right'
- }
- };
- var $findObj = $(findObj);
- //距离浏览器窗口右边的距离
- var distance = document.body.clientWidth - $findObj.get(0).getBoundingClientRect().right;
- if(distance <= 200){//如果距离浏览器右边的距离少于200px,则提示信息在下方显示
- defaults.position = {
- my: 'top center',
- at: 'bottom center'
- };
- if($findObj.hasClass("fwcombox-arrow")){
- $findObj.prev().qtip(defaults).qtip("show");
- }else{
- $findObj.qtip(defaults).qtip("show");
- }
- }else{
- $findObj.qtip(defaults).qtip("show");
- }
- }
- /**
- * 有标题和关闭按钮的提示框
- * FWtipDialog(document.wfForm.XM,"错误提示","姓名输入不合法");
- *
- * FWtipDialog("form[name='wfForm'] input[name='XM']","错误提示","姓名输入不合法!");
- *
- * @param findObj jQuery查找串或对象ldn
- * @param titleStr 标题
- * @param msg 提示信息
- */
- function FWtipDialog(findObj,titleStr,msg) {
- var isTitle = true;
- if (jQuery.trim(msg) != ''){
- isTitle = false;
- }
- FWtip(findObj,msg ,{hide: {event: false},
- content:{title: {
- text: titleStr, // Give the tooltip a title using each elements text
- button: true
- },text: function() {
- return !isTitle ? msg : $(this).attr('title');
- }},
- position: {
- my: 'left center', // Use the corner...
- at: 'right center' // ...and opposite corner
- }}).qtip('show');
- }
- /**
- * 普通提示框,可以显示title属性内容,或提定要示的内容
- * e.g:
- * 给 a[title] 对象(对象必须有title属性)属性的title信息提示
- * FWtip('a[title]');
- *
- * 经 a[title] 对象加指定提示信息
- * FWtip('a[title]',"提示信息");
- *
- * @param findObj jQuery查找串或对象
- * @param msg 提示信息
- * @param options 参数
- * @returns qtip对象
- */
- function FWtip(findObj,msg,options) {
- var isTitle = true;
- var options2 = options == undefined || options == null ? {} : options;
- if (jQuery.trim(msg) != ''){
- isTitle = false;
- }
-
- var defaults = {content: {
- text: function() {
- return !isTitle ? msg : $(this).attr('title');
- }
- },
- position: {
- my: 'left center', // Use the corner...
- at: 'right center' // ...and opposite corner
- }};
- jQuery.extend(true,defaults,options2);
- return $(findObj).qtip(defaults);
- }
- /**
- * 动态内容提示框
- * e.g:
- * FWtipDynamic("a[name='tipMsg']",{ajax:{url:"请求链接"});
- *
- * FWtipDynamic("a[name='tipMsg']",{title:{text:'提示',button: true},ajax:{url:"请求链接"});
- *
- * @param findObj jQuery查找串或对象
- * @param options 参数
- * {
- title:{
- text: '提示',
- button: true
- },
- position:{
- at: 'bottom right',
- my: 'top left',
- viewport: $(window)
- }
- */
- function FWtipDynamic(findObj,options) {
-
- var defaultOptions = {
- title:{
- text: '提示',
- button: true
- },
- position:{
- at: 'bottom right',
- my: 'top left',
- viewport: $(window)
- },
- style:'ui-tooltip-wiki'
- };
-
- jQuery.extend(defaultOptions,options || {});
-
- $(findObj).each(function()
- {
- // We make use of the .each() loop to gain access to each element via the "this" keyword...
- $(this).qtip(
- {
- content: {
- text: '<img class="throbber" src="'+contextPath+'/js/ui/qtip/images/throbber.gif" alt="Loading..." />',
- ajax: defaultOptions.ajax || $(this).attr('rel'),
- title: defaultOptions.title
- },
- position: defaultOptions.position,
- show: {
- event: 'click',
- solo: true // Only show one tooltip at a time
- },
- hide: 'unfocus',
- style:defaultOptions.style
- })
-
- // Make sure it doesn't follow the link when we click it
- .click(function() { return false; });
- });
-
- defaultOptions = null;
- }
- /**
- * Job操类
- */
- function FwJob() {
- /**
- * 执行Job
- * @param jobId Job标识
- * @param key Job关键字
- * @param argsObj 传参
- */
- this.execute = function(jobId,key,argsObj) {
- var refresh = eval("job_"+jobId+"_refresh");
- if ($.trim(key) !='') {
- $("#"+jobId+"_key").val(key);
- }
-
- var args = {"_longTransID":""+jobId,"_longTransKey":$("#"+jobId+"_key").val()};
- args = jQuery.extend(args,argsObj);
- new Service({serviceId:'longProcessService',method:'scheduler',parameters:args})
- .sentAjax(function(data){
- if (data == '1') {
- FWalert('此任务已在执行中!');
- } else {
- FWalert('任务提交成功!');
- }
- FwJob.prototype.clearAllRefresh();
- var func = eval("FwJob.prototype.win_job_"+jobId+"_refresh");
- func();
- var t = setInterval("FwJob.prototype.win_job_"+jobId+"_refresh()",refresh);
- FwJob.prototype.__jobRefresh[jobId]=t;
- },function(data){
- FWalert(data);
- FwJob.prototype.clearAllRefresh();
- var t = setInterval("FwJob.prototype.win_job_"+jobId+"_refresh()",refresh);
- FwJob.prototype.__jobRefresh[jobId]=t;
- });
- };
-
-
- }
- FwJob.prototype.__jobRefresh = [];
- FwJob.prototype.__jobWin = [];
- FwJob.prototype.isComplete = function(jobId,key){
- var args = {"TRANSID":""+jobId,"KEY":key};
- new Service({serviceId:'longProcessService',method:'isComplete',parameters:args})
- .sentAjax(function(data){
- if (data == '2') {
- FwJob.prototype.clearRefresh(jobId);
- }
- },function(data){
- FwJob.prototype.clearRefresh(jobId);
- });
- };
- FwJob.prototype.clearAllRefresh = function(){
- for(i = 0;i< FwJob.prototype.__jobRefresh.length; i++){
- window.clearInterval(FwJob.prototype.__jobRefresh[i]);
- }
- };
-
- FwJob.prototype.clearRefresh = function(jobId){
- window.clearInterval(FwJob.prototype.__jobRefresh[jobId]);
- };
- var GBtn = {};
- function __btnClick(obj,doAction,delay) {
- var txt = $(obj).text();
- var times = delay != null && delay != undefined ? delay : 3;
- if(!obj.disabled) {
-
- GBtn[obj] = [];
- GBtn[obj]['i'] = times;
- if (typeof doAction === 'function') {
- var resp = doAction() ;
- resp = resp == null ? true : resp ;
- if (!resp) {
- return ;
- }
- $(obj).linkbutton("disable");
- if (times != -1) {
- $(obj).linkbutton({text:txt+" ("+times+"s)"});
- GBtn[obj]['t'] = setInterval("__btnClick.prototype.delay()", 1000);
- }
- } else {
- window.location.href = doAction;
- }
- }
-
- __btnClick.prototype.delay = function() {
- state = $.data(obj, 'linkbutton');
- if(state.options.disabled && GBtn[obj]['i'] > 0) {
- $(obj).linkbutton({text:txt + " ("+ GBtn[obj]['i'] +"s)"});
- GBtn[obj]['i'] = GBtn[obj]['i'] - 1;
-
- } else {
- clearInterval(GBtn[obj]['t']);
- $(obj).linkbutton("enable");
- $(obj).linkbutton({text:txt});
- //$(this).linkbutton('disable');
- }
- };
- }
- /**
- * 框架封装对象
- */
- var FW = {
- /**
- * 获取全局变量 (访问属性:private)
- * @returns {}
- */
- _getGVAR : function() {
- var twindow = this.getTopWindow(window);
- var rtn = null;
- try{
- rtn = twindow.top.frames['banner'].GVAR || {};
- }catch(e){
- rtn = window.HEAD_GVAR || {};
- }
- return rtn;
- },
-
- /**
- * 获取字典模式 (访问属性:public)
- * @@returns String
- */
- getDictMode : function() {
- return this._getGVAR().dictMode;
- },
-
- /**
- * 字典模式常量 (访问属性:public)
- */
- DICTMODES : {'SERVER':'server', //ajax获取
- 'LOCAL':'local' //本地缓存
- },
-
- /**
- * 获取顶层框窗口 (访问属性:public)
- * @param window self对象
- * @returns top window
- */
- getTopWindow:function(win) {
- var twindow = window;
- while(twindow.dialogArguments!=null || twindow.opener != null){
- while(twindow.dialogArguments!=null){
- twindow = twindow.dialogArguments;
- }
- while(twindow.opener != null){
- twindow = twindow.opener;
- }
- }
- return twindow;
- },
-
- /**
- * (访问属性:private)
- */
- _storeDict: function(dictName,dict) {
- var GVAR = this._getGVAR();
- GVAR.dicts[dictName] = dict;
- },
-
- /**
- * 获取字典信息 (访问属性:public)
- * @param dictName 字典名
- */
- getDict : function(dictName,whereCls) {
- var GVAR = this._getGVAR();
- if (GVAR.dicts[dictName] != null && !jQuery.isEmptyObject(GVAR.dicts[dictName])) {
- return GVAR.dicts[dictName];
- }
- var dict = {};
- jQuery.ajax({
- url:contextPath+'/jsp/framework/getDict.jsp'
- ,data:{dictName:dictName,whereCls:whereCls}
- ,cache:true
- ,type:'post'
- ,dataType:'json'
- ,async:false
- ,error:function (request, textStatus, errorThrown){alert("获取字典出错!");}
- ,success:function (data, textStatus){
- dict = data;
- }
- });
-
- if (dict != null && !jQuery.isEmptyObject(dict)) {
- this._storeDict(dictName, dict);
- }
-
- return dict;
- },
-
- /**
- * 字典是否存在
- * @param dictName 字典名
- */
- isExistsDict:function(dictName) {
- var GVAR = this._getGVAR();
- if (GVAR.dicts[dictName] != null && !jQuery.isEmptyObject(GVAR.dicts[dictName])) {
- return true;
- }
- return false;
- },
- showModalDialog:function(href,options) {
- var opt = options;
- if (opt == null || opt == undefined) {
- var w=600,h=400, l = (screen.Width-w)/2,t = (screen.Height-h)/2;
- var locStr = "dialogLeft:" + l + ";dialogTop:" + t;
- opt="status:0;help:0;dialogWidth:"+w+"px;dialogHeight:"+h+"px;"+locStr;
- }
- href += href.indexOf("?") > 0 ? "&" : "?" +"_t="+new Date().getTime();
- return showModalDialog(href,window,opt);
- }
- };
|