huimv.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. var huimv = new Object();
  2. var lightbox = null;
  3. var processDialog = null;
  4. var errorbox = null;
  5. var errorInfo = null;
  6. var huimvMaxIndex = 300;
  7. /**
  8. * 加载页面到所在ID
  9. *
  10. * @param id
  11. * 需加截页面位置ID (不能为空)
  12. *
  13. * @param p
  14. * url: 加载页面URL (不能为空) data:加载页面参数 callback:加载成功时调用函数
  15. *
  16. */
  17. huimv.loadPage = function (id, url, param, callback) {
  18. var pageObj = jQuery("#" + id);
  19. 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>');
  20. var top = window.screen.availHeight / 2 - 100;
  21. loadDivObj.css({
  22. top: "50%",
  23. left: "50%",
  24. width: '290px',
  25. height: '55px',
  26. 'font-weight': 'bold',
  27. 'border': ' 1px #1fa700 solid',
  28. 'text-align': 'center',
  29. 'margin': 'auto',
  30. 'margin-top': top + 'px'
  31. });
  32. pageObj.empty().append(loadDivObj);
  33. if (typeof(param) == 'undefined') {
  34. jQuery.ajaxSetup({
  35. cache: false
  36. });
  37. }
  38. pageObj.load(url, param, function () {
  39. loadDivObj.hide("slow");
  40. if (callback) {
  41. callback();
  42. }
  43. });
  44. };
  45. /**
  46. * 显示处理信息框
  47. *
  48. * @param {显示处理信息}
  49. * msg
  50. */
  51. huimv.showProcessModel = function (msg, error, customHeight) {
  52. if (!msg) {
  53. msg = "正在处理中,请稍候";
  54. }
  55. var lightboxDiv = document.createElement("div");
  56. lightboxDiv.id = "lightbox";
  57. 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";
  58. lightboxDiv.style.height = ((document.documentElement.clientHeight > document.documentElement.scrollHeight)
  59. ? document.documentElement.clientHeight + 1000
  60. : document.documentElement.scrollHeight) + 1000
  61. + "px";
  62. var processDialogDiv = document.createElement("div");
  63. processDialogDiv.style.cssText = "position:absolute;width:400px;height:125px;text-align:center;z-index:10001;font-weight: bold;border: 1px #1fa700 solid;top:"
  64. + (+225 + document.documentElement.scrollTop)
  65. + "px"
  66. + ";left:30%;font-size: 14px;background: url(images/load_bg.gif) repeat-x #ffffff;";
  67. var process = '<table width="100%" cellspacing="0" cellpadding="0">'
  68. + '<tr><td width="29%" height="125"><div align="right"><img src="images/progress.gif" /></div></td>'
  69. + '<td width="59%"><span id= "msgText">' + msg
  70. + '......<span></td><td width="12%">&nbsp;</td></tr></table>';
  71. jQuery(process).appendTo(processDialogDiv);
  72. // 解决遮住下拉框
  73. 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>';
  74. document.body.appendChild(processDialogDiv);
  75. document.body.appendChild(lightboxDiv);
  76. lightbox = jQuery(lightboxDiv);
  77. lightbox.css('zIndex', (++huimvMaxIndex));
  78. processDialog = jQuery(processDialogDiv);
  79. lightbox.append(iframeHTML);
  80. processDialog.show();
  81. lightbox.show();
  82. };
  83. /**
  84. * 隐藏处理信息框
  85. */
  86. huimv.hideProcessModel = function () {
  87. if (null != processDialog) {
  88. processDialog.fadeOut("slow", function () {
  89. processDialog.remove();
  90. lightbox.remove();
  91. processDialog = null;
  92. lightbox = null;
  93. });
  94. }
  95. };
  96. /**
  97. * 搜索列表 (使用需在页面中包含js/jquery/grid/grid.js js/jquery/grid/grid.css)
  98. *
  99. * @param {列表ID}
  100. * gid
  101. * @param {列表选项参数}
  102. * p
  103. */
  104. huimv.searchGrid = function (gid, p, title) {
  105. this.getGrid(gid).gridSearch(p);
  106. if (typeof(title) != "undefined") {
  107. this.getGrid(gid).setTitle(title);
  108. }
  109. };
  110. huimv.showError = function (errorMsg) {
  111. huimv.hideProcessModel();
  112. if (errorbox != null && errorInfo != null) {
  113. errorInfo.empty();
  114. jQuery('<div align="right"><img onclick="huimv.closeError();" src="images/close.gif" width="44" height="20"></div>')
  115. .appendTo(errorInfo);
  116. jQuery(errorMsg).appendTo(errorInfo);
  117. errorInfo.show();
  118. errorbox.show();
  119. return;
  120. }
  121. var errorDiv = document.createElement("div");
  122. errorDiv.id = "errorBox";
  123. 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";
  124. errorDiv.style.height = ((document.documentElement.clientHeight > document.documentElement.scrollHeight)
  125. ? document.documentElement.clientHeight
  126. : document.documentElement.scrollHeight)
  127. + "px";
  128. var errorInfoDiv = document.createElement("div");
  129. errorInfoDiv.id = "errorInfoDiv";
  130. errorInfoDiv.style.cssText = "position:absolute;width:800px;height:auto;text-align:center;z-index:10001;border: 1px #1fa700 solid;top:"
  131. + (+50 + document.documentElement.scrollTop)
  132. + "px"
  133. + ";left:10%;font-size: 14px;background: url(images/load_bg.gif) repeat-x #ffffff;";
  134. jQuery('<div align="right"><img onclick="huimv.closeError();" src="images/close.gif" width="44" height="20"></div>')
  135. .appendTo(errorInfoDiv);
  136. jQuery(errorMsg).appendTo(errorInfoDiv);
  137. // 解决遮住下拉框
  138. 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>';
  139. document.body.appendChild(errorInfoDiv);
  140. document.body.appendChild(errorDiv);
  141. errorbox = jQuery(errorDiv);
  142. errorbox.css('zIndex', (++huimvMaxIndex));
  143. errorInfo = jQuery(errorInfoDiv);
  144. errorbox.append(iframeHTML);
  145. errorInfo.show();
  146. errorbox.show();
  147. };
  148. huimv.closeError = function () {
  149. errorbox.hide();
  150. errorInfo.hide();
  151. };
  152. /**
  153. * 刷新列表 (使用需在页面中包含js/jquery/grid/grid.js js/jquery/grid/grid.css)
  154. *
  155. * @param {列表ID}
  156. * gid
  157. */
  158. huimv.reloadGrid = function (gid) {
  159. jQuery("#" + gid).gridReload();
  160. };
  161. /**
  162. * 根据ID获取
  163. *
  164. * @param {列表ID}
  165. * gid
  166. */
  167. huimv.getGrid = function (gid) {
  168. return jQuery("#" + gid);
  169. };
  170. /**
  171. * 系统输入器
  172. */
  173. huimv.suggestComplete = function (p) {
  174. if (p.lx == '操作用户') {
  175. p.scrollHeight = 200;
  176. }
  177. if (typeof(p.hiddenId) != 'undefined' && p.hiddenId != '') {
  178. $('#' + p.hiddenId).val("");
  179. }
  180. $("#" + p.srqId).autocomplete("getSuggestData.htm", {
  181. scroll: true,
  182. mustMatch: p.mustMatch,
  183. max: p.max || 100,
  184. noDataCallBack: p.noDataCallBack,
  185. scrollHeight: p.scrollHeight || 400,
  186. width: p.width || 355,
  187. minChars: p.minChars || 1,
  188. dataType: 'text',
  189. extraParams: jQuery.extend({
  190. "lx": p.lx,
  191. "maxNum": (p.max + 1) || 100,
  192. "deal": p.deal
  193. }, p.params),
  194. formatItem: function (row, i, max) {
  195. var lx = row[0];
  196. var dataObj = eval(row[1]);
  197. if (p.formatViewData) {
  198. p.formatViewData(lx, dataObj);
  199. } else {
  200. if (lx == '操作用户') {
  201. return dataObj.yhxm;
  202. } else if (lx == '行政区划') {
  203. var t = "<table cellpadding=0><tr><td width=150 style='font-size:14px;'>"
  204. + dataObj.qhmc
  205. + "</td><td width=260 style='font-size:14px;'>-&nbsp;&nbsp;"
  206. + dataObj.sjqhmc + "</td><tr></table>";
  207. return t;
  208. } else if (lx == '公用代码') {
  209. return dataObj.dmmc;
  210. }
  211. }
  212. },
  213. formatResult: function (row) {
  214. var lx = row[0];
  215. var dataObj = eval(row[1]); // 数据对象
  216. if (p.formatSelectResult) {
  217. return p.formatSelectResult(lx, dataObj);
  218. } else {
  219. if (lx == '操作用户') {
  220. return dataObj.yhxm;
  221. } else if (lx == '行政区划') {
  222. return dataObj.qhmc;
  223. } else if (lx == '公用代码') {
  224. return dataObj.dmmc;
  225. }
  226. }
  227. }
  228. });
  229. $("#" + p.srqId).result(function (event, row, format) {
  230. var dataObj = eval(row[1]);// 数据对象
  231. var lx = row[0];
  232. if (p.selectCallBack) {
  233. p.selectCallBack(dataObj, lx, event, format);
  234. }
  235. });
  236. };
  237. /**
  238. * 处理页面显示隐藏保存时清除功能
  239. * @param paraObj
  240. */
  241. huimv.clearHideVal = function (paraObj) {
  242. for (var i = 0; i < paraObj.length; i++) {
  243. var pType = paraObj[i].pType;
  244. var pId = paraObj[i].pId;
  245. var clearVal = paraObj[i].clearVal;
  246. clearVal = ',' + clearVal + ',';
  247. var clear = false;
  248. if (pType == 'radio' || pType == 'select') {
  249. var dqval = '';
  250. if (pType == 'radio') {
  251. dqval = $('input[id=' + pId + ']:checked').val();
  252. } else if (pType == 'select') {
  253. dqval = $('#' + pId).val();
  254. }
  255. if (dqval == '') {
  256. dqval = '空';
  257. }
  258. dqval = ',' + dqval + ',';
  259. if (clearVal.indexOf(dqval) == -1) {
  260. clear = true;
  261. }
  262. } else if (pType == 'checkbox') {
  263. var cbval = '';
  264. $('input[id=' + pId + ']:checked').each(function () {
  265. cbval = cbval + $(this).val() + ',';
  266. });
  267. cbval = ',' + cbval;
  268. if (cbval.indexOf(clearVal) == -1) {
  269. clear = true;
  270. }
  271. }
  272. if (clear) {
  273. var cIds = paraObj[i].cIds;
  274. for (var j = 0; j < cIds.length; j++) {
  275. var cId = cIds[j].cId;
  276. var cType = cIds[j].cType;
  277. if (cType == 'select') {
  278. $('#' + cId).attr('value', '');
  279. } else if (cType == 'radio' || cType == 'checkbox') {
  280. $('input[id=' + cId + ']:checked').each(function () {
  281. $(this).attr('checked', false);
  282. });
  283. } else if (cType == 'input') {
  284. $('#' + cId).val('');
  285. }
  286. }
  287. }
  288. }
  289. };