| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- /**
- * @author herong 对话框组件
- */
- var CFWWin = _FW.fCreateClass();
- /**
- * 对话框组件API
- */
- CFWWin.prototype = {
- /**
- * 初始化
- */
- fInitialize : function(options) {
- },
- /**
- * 处理控件重新布局(调整控件大小和位置,如果原先控件是隐藏的,那么可能需要手动调用它来重新调整)。
- * 需要布局的,手动调用这个,传入父级dom,比如外层div,或者form
- *
- * @param oFindObj(必需)
- * 控件对象 使用举例: CFW.oWin.fnResizeObject(findObj);
- */
- fnResizeObject : function(findObj) {
- // 查找节点对象里面的所有需要重新调整的节点
- $('.fwresize', findObj).trigger('fwresize');
- },
- /**
- * 关闭DIV
- *
- * @param sDivID(必需)
- * 网页DIV的ID 使用举例: CFW.oWin.fnDivClose(sDivID);
- */
- fnDivClose : function(sTabId) {
- var tabId = "#" + sTabId;
- $(tabId).fwwindow('close');
- // $(tabId).hide();
- },
- /**
- * 打开DIV
- *
- * @param sDivID(必需)
- * 网页DIV的ID 使用举例: CFW.oWin.fnDivOpen(sDivID);
- */
- fnDivOpen : function(sTabId) {
- var tabId = "#" + sTabId;
- $(tabId).fwwindow('open');
- // $(tabId).show();
- },
- /**
- * 提示消息
- *
- * @param sMsg
- * 消息 应用实例
- *
- * <pre>
- * CFW.oWin.fnAlert("hello world!");
- * </pre>
- */
- fnAlert : function(sMsg) {
- alert(sMsg);
- },
- /**
- * 提示窗口(带样式)
- *
- * @param sMsg
- * 消息 应用实例
- * @param mArgs
- * 参数。窗口宽度(dialogWidth),窗口高度(dialogHeight)
- *
- * <pre>
- * CFW.oWin.fnAlertStyle("hello world!");
- * 或
- * var mArgs = {'dialogWidth':'500px','dialogHeight':'250px'};
- * CFW.oWin.fnAlertStyle("hello world!", "mArgs");
- * </pre>
- */
- fnAlertStyle : function(sMsg, mArgs) {
- if(mArgs==null){
- mArgs={type:'AppMsg'};
- }
- this._fnAlert(sMsg, mArgs);
- },
-
-
- /**
- * 提交form需要跟 <hnisi:htmlBack> 配合起来使用
- *
- * @param sf
- * 需要提交的foem
- * @param callBackFunction
- * 回调函数
- *
- * <pre>
- * CFW.oWin.fnSubmitForm("cxtjForm","testFresh()");
- * </pre>
- */
- fnSubmitForm : function(sf,callBackFunction) {
- if(sf==null||sf==""){
- alert("请输入要提交的Form");
- return;
- }
- var form = document.getElementsByName(sf)[0];
- if(callBackFunction==null){
- callBackFunction = "";
- }
- var height=$(window).height();
- document.getElementById("div_body").style.display="none";
- var formTarget = form.target;
- var backseq=$("#callBackFunction").attr("SEQ");
- form.target = "callIframe_"+backseq;
- //$("#callIframe_"+backseq).height(height);
- form.submit();
- //根据iframe中的内容高度来设置iframe高度
- $("#callIframe_"+backseq).css("height","auto");
- $("#"+form.target).unbind("load").load(function(){
- var mainheight = $(this).contents().height();//页面内容的高度
- var availHeight=document.documentElement.clientHeight;//工作区页面的高度
- //alert("mainheight="+mainheight+"-------------------availHeight="+availHeight+"-------"+"-backseq---"+backseq);
- var contntH=mainheight;
- if(availHeight>mainheight){
- contntH=availHeight;
- }else{
- contntH=mainheight;
- }
- contntH=contntH-30;
- $(this).height(contntH);
- if($(this).attr("contentHeight")==undefined){
- $(this).attr("contentHeight",contntH);
- }
-
- var doc = document, p = window;
- while(p = p.parent){
- var frameId=$("iframe",p.document.getElementById('add_back_div')).attr("id");
- if(frameId!="callIframe_"+backseq && contntH!=0 && frameId.indexOf("callIframe_")>-1){$("iframe",p.document.getElementById('add_back_div')).css("height",contntH+100);}
- if(p == top){ break; }
- }
-
-
- });
- form.target =formTarget;
- document.getElementById("callBackFunction").value=callBackFunction;
- document.getElementById("add_back_div").style.display="block";
- },
- /**
- * 返回提交页面需要跟 <hnisi:htmlBack> 配合起来使用
- *
- * @param step
- * 返回前几个页面
- *
- * <pre>
- * CFW.oWin.fnGoCallBack(1);
- * </pre>
- */
- fnGoCallBack : function(step) {
- if(step==null){
- step = 1;
- }
- try{
- var win=window;
- for(var i=0;i<step;i++){
- win = win.parent;
- }
-
- win.document.getElementById("div_body").style.display="inline";
- win.document.getElementById("add_back_div").style.display="none";
- var obj = win.document.getElementById("callBackFunction");
- var callBackFunction = "";
- if(obj!=null && typeof(obj)=='object'){
- callBackFunction=obj.value;
- }
- if(callBackFunction!=""){
- win.eval("setTimeout(function(){"+callBackFunction+";},150)");
- }
- win.document.getElementById("callBackFunction").value="";
- //win.document.getElementById("callIframe_"+win.document.getElementById("callBackFunction").SEQ).src="about:blank";
- ///*
- if($("iframe",win.document.getElementById('add_back_div')).length>0){
- var frameId=$("iframe",win.parent.document.getElementById('add_back_div')).attr("id");
- var contentHeight=$("#"+frameId,win.parent.document.getElementById('add_back_div')).attr("contentHeight");
- $("#"+frameId,win.parent.document.getElementById('add_back_div')).height(contentHeight);
- }
- //*/
- }catch(e){
-
- }
- },
- /**
- * 确认提示对话窗口(带样式)
- *
- * @param sMsg
- * 消息
- * @param mArgs
- * 参数。窗口宽度(dialogWidth),窗口高度(dialogHeight)
- * <pre>
- * CFW.oWin.fnConfirmStyle("是否打印");
- *
- * 或
- *
- * var mArgs = {'dialogWidth':'500px','dialogHeight':'250px'};
- * CFW.oWin.fnConfirmStyle("是否打印",mArgs);
- * </pre>
- */
- fnConfirmStyle : function(sMsg, mArgs) {
- return this._fnConfirm(sMsg, mArgs);
- },
-
-
- /**
- * 提示消息
- *
- * @param sMsg
- * 消息
- * @param fnCallback
- * 回调函数 应用实例
- *
- * <pre>
- * CFW.oWin.fnConfirm("是否打印", function(bResult) {
- * if (bResult) {
- *
- * } else {
- *
- * }
- * });
- * </pre>
- */
- fnConfirm : function(sMsg, fnCallback) {
- // jQuery.fwmessager.confirm(msg,fn);
- //var fun = fun = window[fnCallback];
- if (window.confirm(sMsg)) {
- if (fnCallback) {
- fnCallback.call(this,true);
- }
- } else if (fnCallback) {
- fnCallback.call(this,false);
- }
- return false;
- },
- /**
- * 通用机构树弹出框
- *
- * @param oOptions
- * 必须,JSON对象,具有属性 1. root:机构树的顶端机构的机构代码,例如'4419' 2. whereCls :
- * 树节点的查询条件,一般是'1=1'。 3. selected 已选结构的机构代码orgcocde 4. bussFuncId
- * 业务通办的业务ID
- * @return JSON对象,具有属性 1.title 机构名 2.key 机构代码
- *
- * <pre>
- * 例子:
- * var rst = CFW.oWin.fnOpenOrgTree({root:orgCode,whereCls:'1=1'});
- * if(!rst){//如果选择机构节点,则不处理
- * return ;
- * }else{
- * document.qForm.ORGNAME.value = rst.title;
- * document.qForm.BAE001.value = rst.key;
- * }
- * </pre>
- */
- fnOpenOrgTree : function(oOptions) {
- 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;
- oOptions['_t'] = new Date().getTime();
- var url = transpage + $.param(oOptions, true);
- return showModalDialog(url, null, position);
- },
- _fnAlert : function(msg, args) {
- var parentdiv=$('<div></div>'); //创建一个父div
- parentdiv.attr('id','_exceptionWindow'); //给父div设置id
- parentdiv.addClass('window'); //添加css样式
- parentdiv.css('display','none');
- var msgdiv=$('<div></div>'); //创建一个子div
- msgdiv.attr('id','div_exception_context'); //给子div设置id
- msgdiv.css({
- "width":"100%",
- "height":"100%"
- }); //添加css样式
- msgdiv.appendTo(parentdiv); //将子div添加到父div中
- var resultMsg = '<iframe name="_exceptionFrame" src="" width="100%" height="100%" frameborder="0"></iframe>';
- msgdiv.empty().append(resultMsg);
- var dialogdiv=$('<div></div>'); //创建一个子div
-
- dialogdiv.attr('id','divMsgDialogBtn'); //给子div设置id
- dialogdiv.addClass('wfDialogBtn exception-btn-background'); //添加css样式
- dialogdiv.css('display','block');
- var confirmYbutton;
- var confirmNbutton;
- var closebutton;
- if(args['confrim'] == '1'){
- confirmYbutton=$('<a></a>'); //创建一个关闭按钮
- confirmYbutton.attr('id','btn_confirm_yes');
- confirmYbutton.addClass('buttonlink'); //添加css样式
- confirmYbutton.attr('href','javascript:void(0);');
- confirmYbutton.attr('keycomb','');
- confirmYbutton.attr({"plain":"true"});
- confirmYbutton.text('确认');
- confirmYbutton.appendTo(dialogdiv);
- confirmNbutton=$('<a></a>'); //创建一个关闭按钮
- confirmNbutton.attr('id','btn_confirm_no');
- confirmNbutton.addClass('buttonlink'); //添加css样式
- confirmNbutton.attr('href','javascript:void(0);');
- confirmNbutton.attr('keycomb','');
- confirmNbutton.attr({"plain":"true"});
- confirmNbutton.text('取消');
- confirmNbutton.appendTo(dialogdiv);
- }else{
- closebutton=$('<a></a>'); //创建一个关闭按钮
- closebutton.attr('id','btn_exception_close');
- closebutton.addClass('buttonlink'); //添加css样式
- closebutton.attr('href','javascript:void(0);');
- closebutton.attr('keycomb','');
- closebutton.attr({"plain":"true"});
- closebutton.text('关闭');
- closebutton.appendTo(dialogdiv);
- }
-
- dialogdiv.appendTo(parentdiv); //将子div添加到父div中
- parentdiv.appendTo('body');
-
- parentdiv.fwwindow({
- title: '提示',
- noheader:true,
- width: 600,
- modal: true,
- shadow: false,
- closed: true,
- closable : false,
- height: 340
- });
- if(args['confrim'] == '1'){
- confirmYbutton.linkbutton({plain:false});
- confirmYbutton.unbind('click').click(function(){
- parentdiv.fwwindow('close');
- $('[name=exceptionForm]').remove();
- parentdiv.fwwindow('destroy');
- return 1;
- });
- confirmNbutton.linkbutton({plain:false});
- confirmNbutton.unbind('click').click(function(){
- parentdiv.fwwindow('close');
- $('[name=exceptionForm]').remove();
- parentdiv.fwwindow('destroy');
- return 0;
- });
- }else{
- closebutton.linkbutton({plain:false});
- closebutton.unbind('click').click(function(){
- parentdiv.fwwindow('close');
- $('[name=exceptionForm]').remove();
- parentdiv.fwwindow('destroy');
- return 1;
- });
- }
-
- var frag = document.createDocumentFragment();
- var form = document.createElement("form");
- form.name="exceptionForm";
- form.action=contextPath + '/jsp/framework/alert.jsp?t='+new Date().getTime();
- form.target='_exceptionFrame';
-
- var str =" <input type=\"hidden\" name=\"type\" value=\""+args.type+"\"> ";
- str+=" <input type=\"hidden\" name=\"msg\" value=\""+msg+"\"> ";
- form.innerHTML=str;
- frag.appendChild(form);
- document.body.appendChild(frag);
- form.submit();
- parentdiv.fwwindow('open');
- },
- _fnConfirm : function(msg, args) {
- args = args || {};
- args['confrim'] = '1';
- return this._fnAlert(msg, args);
- }
- };
|