var huimv = new Object(); var lightbox = null; var processDialog = null; var errorbox = null; var errorInfo = null; var huimvMaxIndex = 300; /** * 加载页面到所在ID * * @param id * 需加截页面位置ID (不能为空) * * @param p * url: 加载页面URL (不能为空) data:加载页面参数 callback:加载成功时调用函数 * */ huimv.loadPage = function (id, url, param, callback) { var pageObj = jQuery("#" + id); var loadDivObj = jQuery('
页面加载中,请稍候...
'); var top = window.screen.availHeight / 2 - 100; loadDivObj.css({ top: "50%", left: "50%", width: '290px', height: '55px', 'font-weight': 'bold', 'border': ' 1px #1fa700 solid', 'text-align': 'center', 'margin': 'auto', 'margin-top': top + 'px' }); pageObj.empty().append(loadDivObj); if (typeof(param) == 'undefined') { jQuery.ajaxSetup({ cache: false }); } pageObj.load(url, param, function () { loadDivObj.hide("slow"); if (callback) { callback(); } }); }; /** * 显示处理信息框 * * @param {显示处理信息} * msg */ huimv.showProcessModel = function (msg, error, customHeight) { if (!msg) { msg = "正在处理中,请稍候"; } var lightboxDiv = document.createElement("div"); lightboxDiv.id = "lightbox"; lightboxDiv.style.cssText = "position:absolute;left:0px;display:none;top:0px;width:100%;background:#dddddd;text-align:center;filter:Alpha(Opacity=50,Style=0);opacity:0.4"; lightboxDiv.style.height = ((document.documentElement.clientHeight > document.documentElement.scrollHeight) ? document.documentElement.clientHeight + 1000 : document.documentElement.scrollHeight) + 1000 + "px"; var processDialogDiv = document.createElement("div"); processDialogDiv.style.cssText = "position:absolute;width:400px;height:125px;text-align:center;z-index:10001;font-weight: bold;border: 1px #1fa700 solid;top:" + (+225 + document.documentElement.scrollTop) + "px" + ";left:30%;font-size: 14px;background: url(images/load_bg.gif) repeat-x #ffffff;"; var process = '' + '' + '
' + msg + '...... 
'; jQuery(process).appendTo(processDialogDiv); // 解决遮住下拉框 var iframeHTML = ''; document.body.appendChild(processDialogDiv); document.body.appendChild(lightboxDiv); lightbox = jQuery(lightboxDiv); lightbox.css('zIndex', (++huimvMaxIndex)); processDialog = jQuery(processDialogDiv); lightbox.append(iframeHTML); processDialog.show(); lightbox.show(); }; /** * 隐藏处理信息框 */ huimv.hideProcessModel = function () { if (null != processDialog) { processDialog.fadeOut("slow", function () { processDialog.remove(); lightbox.remove(); processDialog = null; lightbox = null; }); } }; /** * 搜索列表 (使用需在页面中包含js/jquery/grid/grid.js js/jquery/grid/grid.css) * * @param {列表ID} * gid * @param {列表选项参数} * p */ huimv.searchGrid = function (gid, p, title) { this.getGrid(gid).gridSearch(p); if (typeof(title) != "undefined") { this.getGrid(gid).setTitle(title); } }; huimv.showError = function (errorMsg) { huimv.hideProcessModel(); if (errorbox != null && errorInfo != null) { errorInfo.empty(); jQuery('
') .appendTo(errorInfo); jQuery(errorMsg).appendTo(errorInfo); errorInfo.show(); errorbox.show(); return; } var errorDiv = document.createElement("div"); errorDiv.id = "errorBox"; errorDiv.style.cssText = "position:absolute;left:0px;display:none;top:0px;width:100%;background:#dddddd;text-align:center;filter:Alpha(Opacity=50,Style=0);opacity:0.4"; errorDiv.style.height = ((document.documentElement.clientHeight > document.documentElement.scrollHeight) ? document.documentElement.clientHeight : document.documentElement.scrollHeight) + "px"; var errorInfoDiv = document.createElement("div"); errorInfoDiv.id = "errorInfoDiv"; errorInfoDiv.style.cssText = "position:absolute;width:800px;height:auto;text-align:center;z-index:10001;border: 1px #1fa700 solid;top:" + (+50 + document.documentElement.scrollTop) + "px" + ";left:10%;font-size: 14px;background: url(images/load_bg.gif) repeat-x #ffffff;"; jQuery('
') .appendTo(errorInfoDiv); jQuery(errorMsg).appendTo(errorInfoDiv); // 解决遮住下拉框 var iframeHTML = ''; document.body.appendChild(errorInfoDiv); document.body.appendChild(errorDiv); errorbox = jQuery(errorDiv); errorbox.css('zIndex', (++huimvMaxIndex)); errorInfo = jQuery(errorInfoDiv); errorbox.append(iframeHTML); errorInfo.show(); errorbox.show(); }; huimv.closeError = function () { errorbox.hide(); errorInfo.hide(); }; /** * 刷新列表 (使用需在页面中包含js/jquery/grid/grid.js js/jquery/grid/grid.css) * * @param {列表ID} * gid */ huimv.reloadGrid = function (gid) { jQuery("#" + gid).gridReload(); }; /** * 根据ID获取 * * @param {列表ID} * gid */ huimv.getGrid = function (gid) { return jQuery("#" + gid); }; /** * 系统输入器 */ huimv.suggestComplete = function (p) { if (p.lx == '操作用户') { p.scrollHeight = 200; } if (typeof(p.hiddenId) != 'undefined' && p.hiddenId != '') { $('#' + p.hiddenId).val(""); } $("#" + p.srqId).autocomplete("getSuggestData.htm", { scroll: true, mustMatch: p.mustMatch, max: p.max || 100, noDataCallBack: p.noDataCallBack, scrollHeight: p.scrollHeight || 400, width: p.width || 355, minChars: p.minChars || 1, dataType: 'text', extraParams: jQuery.extend({ "lx": p.lx, "maxNum": (p.max + 1) || 100, "deal": p.deal }, p.params), formatItem: function (row, i, max) { var lx = row[0]; var dataObj = eval(row[1]); if (p.formatViewData) { p.formatViewData(lx, dataObj); } else { if (lx == '操作用户') { return dataObj.yhxm; } else if (lx == '行政区划') { var t = "
" + dataObj.qhmc + "-  " + dataObj.sjqhmc + "
"; return t; } else if (lx == '公用代码') { return dataObj.dmmc; } } }, formatResult: function (row) { var lx = row[0]; var dataObj = eval(row[1]); // 数据对象 if (p.formatSelectResult) { return p.formatSelectResult(lx, dataObj); } else { if (lx == '操作用户') { return dataObj.yhxm; } else if (lx == '行政区划') { return dataObj.qhmc; } else if (lx == '公用代码') { return dataObj.dmmc; } } } }); $("#" + p.srqId).result(function (event, row, format) { var dataObj = eval(row[1]);// 数据对象 var lx = row[0]; if (p.selectCallBack) { p.selectCallBack(dataObj, lx, event, format); } }); }; /** * 处理页面显示隐藏保存时清除功能 * @param paraObj */ huimv.clearHideVal = function (paraObj) { for (var i = 0; i < paraObj.length; i++) { var pType = paraObj[i].pType; var pId = paraObj[i].pId; var clearVal = paraObj[i].clearVal; clearVal = ',' + clearVal + ','; var clear = false; if (pType == 'radio' || pType == 'select') { var dqval = ''; if (pType == 'radio') { dqval = $('input[id=' + pId + ']:checked').val(); } else if (pType == 'select') { dqval = $('#' + pId).val(); } if (dqval == '') { dqval = '空'; } dqval = ',' + dqval + ','; if (clearVal.indexOf(dqval) == -1) { clear = true; } } else if (pType == 'checkbox') { var cbval = ''; $('input[id=' + pId + ']:checked').each(function () { cbval = cbval + $(this).val() + ','; }); cbval = ',' + cbval; if (cbval.indexOf(clearVal) == -1) { clear = true; } } if (clear) { var cIds = paraObj[i].cIds; for (var j = 0; j < cIds.length; j++) { var cId = cIds[j].cId; var cType = cIds[j].cType; if (cType == 'select') { $('#' + cId).attr('value', ''); } else if (cType == 'radio' || cType == 'checkbox') { $('input[id=' + cId + ']:checked').each(function () { $(this).attr('checked', false); }); } else if (cType == 'input') { $('#' + cId).val(''); } } } } };