123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- 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('<div style="border:none;"><table cellspacing="0" cellpadding="0" height="60" style="border:none;"><tr style="border:none;"><td width="29%" style="border:none;"><div align="right" style="border:none;"><img src="images/progress.gif" /><div style="border:none;"><td style="border:none;"><td style="border:none;">页面加载中,请稍候...</td></tr></table></div>');
- 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 = '<table width="100%" cellspacing="0" cellpadding="0">'
- + '<tr><td width="29%" height="125"><div align="right"><img src="images/progress.gif" /></div></td>'
- + '<td width="59%"><span id= "msgText">' + msg
- + '......<span></td><td width="12%"> </td></tr></table>';
- jQuery(process).appendTo(processDialogDiv);
- // 解决遮住下拉框
- var iframeHTML = '<IFRAME style="DISPLAY: block; Z-INDEX: -1; FILTER: alpha(opacity=0); LEFT: 0px; WIDTH: 100%; ZOOM: 1; POSITION: absolute; TOP: 0px; HEIGHT: 100%" src="javascript:false;document.write(\'\')" frameborder="0" scrolling="no"></IFRAME>';
- 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('<div align="right"><img onclick="huimv.closeError();" src="images/close.gif" width="44" height="20"></div>')
- .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('<div align="right"><img onclick="huimv.closeError();" src="images/close.gif" width="44" height="20"></div>')
- .appendTo(errorInfoDiv);
- jQuery(errorMsg).appendTo(errorInfoDiv);
- // 解决遮住下拉框
- var iframeHTML = '<IFRAME style="DISPLAY: block; Z-INDEX: -1; FILTER: alpha(opacity=0); LEFT: 0px; WIDTH: 100%; ZOOM: 1; POSITION: absolute; TOP: 0px; HEIGHT: 100%" src="javascript:false;document.write(\'\')" frameborder="0" scrolling="no"></IFRAME>';
- 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 = "<table cellpadding=0><tr><td width=150 style='font-size:14px;'>"
- + dataObj.qhmc
- + "</td><td width=260 style='font-size:14px;'>- "
- + dataObj.sjqhmc + "</td><tr></table>";
- 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('');
- }
- }
- }
- }
- };
|