var DialogHelper = { showLoading : function ($show) { if ($show == true) { //alert("open"); $('#dlg_loading').dialog('center'); $('#dlg_loading').dialog('open'); } else { //alert("close"); $("#dlg_loading").dialog("close"); //$("#dlg_loading").dialog("destroy"); } }, showModelDialog : function (msg, h) { if (msg == null || msg == "") return; this.showModelAlert(msg, "info"); }, showModelAlert : function (msg, type, fn) { if (msg == null || msg == "") return; $.messager.alert("消息", msg, type, fn); }, showMessage : function (pTitle, pContent, pTimeout) { $.messager.show({ height:200, title:pTitle, msg:pContent, showType:'show', timeout:pTimeout }); }, confirm : function (pMsg, funcb,funNo) { $.messager.confirm("提醒", pMsg, function(r){ if (r){ if(funcb) funcb(); }else{ if(funNo) funNo(); } }); }, _createDialog : function () { var dlgId = "ID_dlg_" + Math.round(Math.random() * 100000); var dlgCt = "
"; //document.write(dlgCt); // $("#dlg_Others").html($("#dlg_Others").html() + dlgCt); $("#dlg_Others").append(dlgCt); return dlgId; }, load : function (url, options) { // url = escape(url); LoginHelper.check(); if (url == "") { this.showModelDialog("功能尚未实现"); return false; } var option = options || {}; var dlgId = this._createDialog(); if (url.indexOf("?") > 0) url += "&"; else url += "?"; var onClose = option.onClose; var onComplete = option.onComplete; if (onClose) delete option.onClose; if (onComplete) delete option.onComplete; url += $.param(option); if(Object.keys(option).length < 1){ url += "__dlgid=" + dlgId; }else{ url += "&__dlgid=" + dlgId; } this.showLoading(true); url = encodeURI(url); $("#" + dlgId).load(url, function() { DialogHelper.showLoading(false); var dlgObj = window[dlgId]; if(!dlgObj && !lgObj.width){ DialogHelper.showModelAlert("网络调用失败,请重试。", 'error'); return; } if(typeof(dlgObj.width) == "string" && dlgObj.width.indexOf("%") != -1){ dlgObj.width = parseInt(dlgObj.width)*$(window).width()/100; } if(typeof(dlgObj.height) == "string" && dlgObj.height.indexOf("%") != -1){ dlgObj.height = parseInt(dlgObj.height)*$(window).height()/100; } $("#" + dlgId).dialog({ title: dlgObj.title, width: dlgObj.width, height: dlgObj.height, buttons: dlgObj.buttons, maximizable: dlgObj.maximizable, onResize: dlgObj.onResize, onClose: function() { if (onClose) onClose(); $(this).dialog('destroy').remove(); window[dlgId] = null; delete window[dlgId]; dlgId = null; }, onOpen: function(){$(document).trigger('tabload')} }); $("#" + dlgId).dialog("open"); if (onComplete) onComplete(); }); return true; }, checkLoad : function (url) { if (url == "") { this.showModelDialog("功能尚未实现"); return false; } var dlgId = this._createDialog(); if (url.indexOf("?") > 0) url += "&"; else url += "?"; url += "__dlgid=" + dlgId; this.showLoading(true); $("#" + dlgId).load(url, function() { DialogHelper.showLoading(false); var dlgObj = window[dlgId]; if(!dlgObj && !lgObj.width){ DialogHelper.showModelAlert("网络调用失败,请重试。", 'error'); return; } if(typeof(dlgObj.width) == "string" && dlgObj.width.indexOf("%") != -1){ dlgObj.width = parseInt(dlgObj.width)*$(window).width()/100; } if(typeof(dlgObj.height) == "string" && dlgObj.height.indexOf("%") != -1){ dlgObj.height = parseInt(dlgObj.height)*$(window).height()/100; } $("#" + dlgId).dialog({ title: dlgObj.title, width: dlgObj.width, height: dlgObj.height, buttons: dlgObj.buttons, maximizable: dlgObj.maximizable, onResize: dlgObj.onResize, onClose: function() { $(this).dialog('destroy').remove(); window[dlgId] = null; delete window[dlgId]; dlgId = null; }, onOpen: function(){$(document).trigger('tabload')} }); $("#" + dlgId).dialog("open"); }); return true; }, mload : function (url, options) { // url = escape(url); // LoginHelper.check(); if (url == "") { this.showModelDialog("功能尚未实现"); return false; } var option = options || {}; var dlgId = this._createDialog(); if (url.indexOf("?") > 0) url += "&"; else url += "?"; var onClose = option.onClose; var onComplete = option.onComplete; if (onClose) delete option.onClose; if (onComplete) delete option.onComplete; url += $.param(option); if(Object.keys(option).length < 1){ url += "__dlgid=" + dlgId; }else{ url += "&__dlgid=" + dlgId; } this.showLoading(true); // console.log($("#" + dlgId),url) $("#" + dlgId).load(url, function() { DialogHelper.showLoading(false); //console.log(2) var dlgObj = window[dlgId]; if(!dlgObj && !lgObj.width){ DialogHelper.showModelAlert("网络调用失败,请重试。", 'error'); return; } if(typeof(dlgObj.width) == "string" && dlgObj.width.indexOf("%") != -1){ dlgObj.width = parseInt(dlgObj.width)*$(window).width()/100; } if(typeof(dlgObj.height) == "string" && dlgObj.height.indexOf("%") != -1){ dlgObj.height = parseInt(dlgObj.height)*$(window).height()/100; } $("#" + dlgId).dialog({ title: dlgObj.title, width: dlgObj.width, height: dlgObj.height, buttons: dlgObj.buttons, maximizable: dlgObj.maximizable, onResize: dlgObj.onResize, onClose: function() { if (onClose) onClose(); $(this).dialog('destroy').remove(); window[dlgId] = null; delete window[dlgId]; dlgId = null; }, onOpen: function(){$(document).trigger('tabload')} }); $("#" + dlgId).dialog("open"); if (onComplete) onComplete(); }); return true; }, openHelp : function (page) { this.load("/dlg/dlg.help.php", {page: page}); }, doAuditTask : function (tskid,teid,finishcb) { //alert("doAudit..."+teid); this.load("/dlg/dlg.task.do.php?tskid="+tskid+"&teid="+teid,null,function(){ if(finishcb) finishcb(tskid); }); }, viewAuditTask : function (tskid) { this.load("/dlg/dlg.task.view.php?tskid="+tskid); }, viewTerms : function (val) { this.load("/dlg/dlg.device.selector.php",{ stype : 'view', val : val }); } };