common.js 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367
  1. 
  2. jQuery(document).ready(function () {
  3. $(".ui-filter-text").click(function () {
  4. if ($(this).next(".ui-filter-list").is(":hidden")) {
  5. $(this).css("border-bottom-color", "#fff");
  6. $(".ui-filter-list").slideDown(10);
  7. $(this).addClass("active");
  8. } else {
  9. $(this).css("border-bottom-color", "#ccc");
  10. $(".ui-filter-list").slideUp(10);
  11. $(this).removeClass("active");
  12. }
  13. });
  14. $(".profile-nav li").click(function () {
  15. $(".profile-nav li").removeClass("active");
  16. $(".profile-nav li").removeClass("hover");
  17. $(this).addClass("active");
  18. }).hover(function () {
  19. if (!$(this).hasClass("active")) {
  20. $(this).addClass("hover");
  21. }
  22. }, function () {
  23. $(this).removeClass("hover");
  24. });
  25. });
  26. //获取layout内容页高度
  27. $.fn.getLayoutHeight = function () {
  28. if ($(".content").length > 0) { //如果有.content元素,则从content元素开始计算
  29. return $(window).height() - $(".content").offset().top;
  30. } else {
  31. return $(window).height();
  32. }
  33. }
  34. //获取layout bottom底部距离
  35. $.fn.getLayoutBottomHeight=function() {
  36. return 52; //底部距离预设52
  37. }
  38. //获取layout中grid刨除顶部高度(包括上下内边距)
  39. $.fn.getGridTopHeight = function () {
  40. if ($(".gridPanel").length > 0) {
  41. return $(".gridPanel").offset().top;
  42. } else {
  43. return 0;
  44. }
  45. }
  46. //获取layout内容区域高度
  47. $.fn.getLayoutContentHeight=function() {
  48. return $.fn.getLayoutHeight() - $.fn.getLayoutBottomHeight();
  49. }
  50. //获取列表grid自适应高度
  51. $.fn.getGridHeight = function (hasPage) {
  52. var pageHeight = -18;//一种奇怪的bug,临时解决方案-18px
  53. if (hasPage) {
  54. pageHeight = 28;//28代表分页高度
  55. }
  56. return $(window).height() - $.fn.getGridTopHeight() - $.fn.getLayoutBottomHeight() - pageHeight;
  57. }
  58. $.loading = function (bool, text) {
  59. if (bool) {
  60. App.blockUI({
  61. target: 'body',
  62. boxed: true,
  63. message: '加载中' | text//,
  64. // animate: true
  65. });
  66. } else {
  67. App.unblockUI();
  68. }
  69. }
  70. //兼容各种插件中loading
  71. loading = function (bool, text) {
  72. if (bool) {
  73. App.blockUI({
  74. target: 'body',
  75. boxed: true,
  76. message: '加载中' | text//,
  77. // animate: true
  78. });
  79. } else {
  80. App.unblockUI();
  81. }
  82. }
  83. tabiframeId = function () {
  84. var iframeId = top.$(".tab_iframe:visible").attr("id");
  85. return iframeId;
  86. };
  87. $.fn.ComboBox = function (options) {
  88. //options参数:description,height,width,allowSearch,url,param,data
  89. var $select = $(this);
  90. if (!$select.attr("id")) {
  91. return false;
  92. }
  93. if (options) {
  94. if ($select.find(".ui-select-text").length == 0) {
  95. var $select_html = "";
  96. $select_html += "<div class=\"ui-select-text\" style='color:#999;'>" + options.description + "</div>";
  97. $select_html += "<div class=\"ui-select-option\">";
  98. $select_html += "<div class=\"ui-select-option-content\" style=\"max-height: " + options.height + "\">" + $select.html() + "</div>";
  99. if (options.allowSearch) {
  100. $select_html += "<div class=\"ui-select-option-search\"><input type=\"text\" class=\"form-control\" placeholder=\"搜索关键字\" /><span class=\"input-query\" title=\"Search\"><i class=\"fa fa-search\"></i></span></div>";
  101. }
  102. $select_html += "</div>";
  103. $select.html("");
  104. $select.append($select_html);
  105. }
  106. }
  107. var $option_html = $($("<p>").append($select.find(".ui-select-option").clone()).html());
  108. $option_html.attr("id", $select.attr("id") + "-option");
  109. $select.find(".ui-select-option").remove();
  110. if ($option_html.length > 0) {
  111. $("body").find("#" + $select.attr("id") + "-option").remove();
  112. }
  113. $("body").prepend($option_html);
  114. var $option = $("#" + $select.attr("id") + "-option");
  115. if (options.url != undefined) {
  116. $option.find(".ui-select-option-content").html("");
  117. $.ajax({
  118. url: options.url,
  119. data: options.param,
  120. type: "GET",
  121. dataType: "json",
  122. async: false,
  123. success: function (data) {
  124. options.data = data;
  125. var json = data;
  126. loadComboBoxView(json);
  127. },
  128. error: function (XMLHttpRequest, textStatus, errorThrown) {
  129. $.fn.modalMsg(errorThrown, "warning");
  130. }
  131. });
  132. } else if (options.data != undefined) {
  133. var json = options.data;
  134. loadComboBoxView(json);
  135. } else {
  136. $option.find("li").css("padding", "0 5px");
  137. $option.find("li").click(function (e) {
  138. var data_text = $(this).text();
  139. var data_value = $(this).attr("data-value");
  140. $select.attr("data-value", data_value).attr("data-text", data_text);
  141. $select.find(".ui-select-text").html(data_text).css("color", "#000");
  142. $option.slideUp(150);
  143. $select.trigger("change");
  144. e.stopPropagation();
  145. }).hover(function (e) {
  146. if (!$(this).hasClass("liactive")) {
  147. $(this).toggleClass("on");
  148. }
  149. e.stopPropagation();
  150. });
  151. }
  152. function loadComboBoxView(json, searchValue, m) {
  153. if (json.length > 0) {
  154. var $_html = $("<ul></ul>");
  155. if (options.description) {
  156. $_html.append("<li data-value=\"\">" + options.description + "</li>");
  157. }
  158. $.each(json, function (i) {
  159. var row = json[i];
  160. var title = row[options.title];
  161. if (title == undefined) {
  162. title = "";
  163. }
  164. if (searchValue != undefined) {
  165. if (row[m.text].indexOf(searchValue) != -1) {
  166. $_html.append("<li data-value=\"" + row[options.id] + "\" title=\"" + title + "\">" + row[options.text] + "</li>");
  167. }
  168. } else {
  169. $_html.append("<li data-value=\"" + row[options.id] + "\" title=\"" + title + "\">" + row[options.text] + "</li>");
  170. }
  171. });
  172. $option.find(".ui-select-option-content").html($_html);
  173. $option.find("li").css("padding", "0 5px");
  174. $option.find("li").click(function (e) {
  175. var data_text = $(this).text();
  176. var data_value = $(this).attr("data-value");
  177. $select.attr("data-value", data_value).attr("data-text", data_text);
  178. $select.find(".ui-select-text").html(data_text).css("color", "#000");
  179. $option.slideUp(150);
  180. $select.trigger("change");
  181. e.stopPropagation();
  182. }).hover(function (e) {
  183. if (!$(this).hasClass("liactive")) {
  184. $(this).toggleClass("on");
  185. }
  186. e.stopPropagation();
  187. });
  188. }
  189. }
  190. //操作搜索事件
  191. if (options.allowSearch) {
  192. $option.find(".ui-select-option-search").find("input").bind("keypress", function (e) {
  193. if (event.keyCode == "13") {
  194. var value = $(this).val();
  195. loadComboBoxView($(this)[0].options.data, value, $(this)[0].options);
  196. }
  197. }).focus(function () {
  198. $(this).select();
  199. })[0]["options"] = options;
  200. }
  201. $select.unbind("click");
  202. $select.bind("click", function (e) {
  203. if ($select.attr("readonly") == "readonly" || $select.attr("disabled") == "disabled") {
  204. return false;
  205. }
  206. $(this).addClass("ui-select-focus");
  207. if ($option.is(":hidden")) {
  208. $select.find(".ui-select-option").hide();
  209. $(".ui-select-option").hide();
  210. var left = $select.offset().left;
  211. var top = $select.offset().top + 29;
  212. var width = $select.width();
  213. if (options.width) {
  214. width = options.width;
  215. }
  216. if (($option.height() + top) < $(window).height()) {
  217. $option.slideDown(150).css({ top: top, left: left, width: width });
  218. } else {
  219. var _top = (top - $option.height() - 32);
  220. $option.show().css({ top: _top, left: left, width: width });
  221. $option.attr("data-show", true);
  222. }
  223. $option.css("border-top", "1px solid #ccc");
  224. $option.find("li").removeClass("liactive");
  225. $option.find("[data-value=" + $select.attr("data-value") + "]").addClass("liactive");
  226. $option.find(".ui-select-option-search").find("input").select();
  227. } else {
  228. if ($option.attr("data-show")) {
  229. $option.hide();
  230. } else {
  231. $option.slideUp(150);
  232. }
  233. }
  234. e.stopPropagation();
  235. });
  236. $(document).click(function (e) {
  237. var e = e ? e : window.event;
  238. var tar = e.srcElement || e.target;
  239. if (!$(tar).hasClass("form-control")) {
  240. if ($option.attr("data-show")) {
  241. $option.hide();
  242. } else {
  243. $option.slideUp(150);
  244. }
  245. $select.removeClass("ui-select-focus");
  246. e.stopPropagation();
  247. }
  248. });
  249. return $select;
  250. };
  251. $.fn.ComboBoxSetValue = function (value) {
  252. if ($.isNullOrEmpty(value)) {
  253. return;
  254. }
  255. var $select = $(this);
  256. var $option = $("#" + $select.attr("id") + "-option");
  257. $select.attr("data-value", value);
  258. var data_text = $option.find("ul").find("[data-value=" + value + "]").html();
  259. if (data_text) {
  260. $select.attr("data-text", data_text);
  261. $select.find(".ui-select-text").html(data_text).css("color", "#000");
  262. $option.find("ul").find("[data-value=" + value + "]").addClass("liactive");
  263. }
  264. return $select;
  265. };
  266. $.fn.ComboBoxTree = function (options) {
  267. //options参数:description,height,allowSearch,appendTo,click,url,param,method,icon
  268. var $select = $(this);
  269. if (!$select.attr("id")) {
  270. return false;
  271. }
  272. if ($select.find(".ui-select-text").length == 0) {
  273. var $select_html = "";
  274. $select_html += "<div class=\"ui-select-text\" style='color:#999;'>" + options.description + "</div>";
  275. $select_html += "<div class=\"ui-select-option\">";
  276. $select_html += "<div class=\"ui-select-option-content\" style=\"max-height: " + options.height + "\"></div>";
  277. if (options.allowSearch) {
  278. $select_html += "<div class=\"ui-select-option-search\"><input type=\"text\" class=\"form-control\" placeholder=\"搜索关键字\" /><span class=\"input-query\" title=\"Search\"><i class=\"fa fa-search\" title=\"按回车查询\"></i></span></div>";
  279. }
  280. $select_html += "</div>";
  281. $select.append($select_html);
  282. }
  283. var $option_html = $($("<p>").append($select.find(".ui-select-option").clone()).html());
  284. $option_html.attr("id", $select.attr("id") + "-option");
  285. $select.find(".ui-select-option").remove();
  286. if (options.appendTo) {
  287. $(options.appendTo).prepend($option_html);
  288. } else {
  289. $("body").prepend($option_html);
  290. }
  291. var $option = $("#" + $select.attr("id") + "-option");
  292. var $option_content = $("#" + $select.attr("id") + "-option").find(".ui-select-option-content");
  293. loadtreeview(options.url);
  294. function loadtreeview(url) {
  295. $option_content.treeview({
  296. onnodeclick: function (item) {
  297. $select.attr("data-value", item.id).attr("data-text", item.text);
  298. $select.find(".ui-select-text").html(item.text).css("color", "#000");
  299. $select.trigger("change");
  300. if (options.click) {
  301. options.click(item);
  302. }
  303. },
  304. height: options.height,
  305. url: url,
  306. param: options.param,
  307. method: options.method,
  308. description: options.description
  309. });
  310. }
  311. if (options.allowSearch) {
  312. $option.find(".ui-select-option-search").find("input").attr("data-url", options.url);
  313. $option.find(".ui-select-option-search").find("input").bind("keypress", function (e) {
  314. if (event.keyCode == "13") {
  315. var value = $(this).val();
  316. var url = changeUrlParam($option.find(".ui-select-option-search").find("input").attr("data-url"), "keyword", escape(value));
  317. loadtreeview(url);
  318. }
  319. }).focus(function () {
  320. $(this).select();
  321. });
  322. }
  323. if (options.icon) {
  324. $option.find("i").remove();
  325. $option.find("img").remove();
  326. }
  327. $select.find(".ui-select-text").unbind("click");
  328. $select.find(".ui-select-text").bind("click", function (e) {
  329. if ($select.attr("readonly") == "readonly" || $select.attr("disabled") == "disabled") {
  330. return false;
  331. }
  332. $(this).parent().addClass("ui-select-focus");
  333. if ($option.is(":hidden")) {
  334. $select.find(".ui-select-option").hide();
  335. $(".ui-select-option").hide();
  336. var left = $select.offset().left;
  337. var top = $select.offset().top + 29;
  338. var width = $select.width();
  339. if (options.width) {
  340. width = options.width;
  341. }
  342. if (($option.height() + top) < $(window).height()) {
  343. $option.slideDown(150).css({ top: top, left: left, width: width });
  344. } else {
  345. var _top = (top - $option.height() - 32);
  346. $option.show().css({ top: _top, left: left, width: width });
  347. $option.attr("data-show", true);
  348. }
  349. $option.css("border-top", "1px solid #ccc");
  350. if (options.appendTo) {
  351. $option.css("position", "inherit");
  352. }
  353. $option.find(".ui-select-option-search").find("input").select();
  354. } else {
  355. if ($option.attr("data-show")) {
  356. $option.hide();
  357. } else {
  358. $option.slideUp(150);
  359. }
  360. }
  361. e.stopPropagation();
  362. });
  363. $select.find("li div").click(function (e) {
  364. var e = e ? e : window.event;
  365. var tar = e.srcElement || e.target;
  366. if (!$(tar).hasClass("bbit-tree-ec-icon")) {
  367. $option.slideUp(150);
  368. e.stopPropagation();
  369. }
  370. });
  371. $(document).click(function (e) {
  372. var e = e ? e : window.event;
  373. var tar = e.srcElement || e.target;
  374. if (!$(tar).hasClass("bbit-tree-ec-icon") && !$(tar).hasClass("form-control")) {
  375. if ($option.attr("data-show")) {
  376. $option.hide();
  377. } else {
  378. $option.slideUp(150);
  379. }
  380. $select.removeClass("ui-select-focus");
  381. e.stopPropagation();
  382. }
  383. });
  384. return $select;
  385. };
  386. $.fn.ComboBoxTreeSetValue = function (value) {
  387. if (value == "") {
  388. return;
  389. }
  390. var $select = $(this);
  391. var $option = $("#" + $select.attr("id") + "-option");
  392. $select.attr("data-value", value);
  393. var data_text = $option.find("ul").find("[data-value=" + value + "]").html();
  394. if (data_text) {
  395. $select.attr("data-text", data_text);
  396. $select.find(".ui-select-text").html(data_text).css("color", "#000");
  397. $option.find("ul").find("[data-value=" + value + "]").parent().parent().addClass("bbit-tree-selected");
  398. }
  399. return $select;
  400. };
  401. $.fn.GetWebControls = function (keyValue,ignore) {
  402. var reVal = "";
  403. $(this).find("input,select,textarea,.ui-select").not(ignore).each(function (r) {
  404. var id = $(this).attr("id");
  405. var type = $(this).attr("type");
  406. switch (type) {
  407. case "checkbox":
  408. if ($("#" + id).is(":checked")) {
  409. reVal += "\"" + id + "\"" + ":" + "\"1\",";
  410. } else {
  411. reVal += "\"" + id + "\"" + ":" + "\"0\",";
  412. }
  413. break;
  414. case "select":
  415. var value = $("#" + id).attr("data-value");
  416. if (value == "") {
  417. value = "&nbsp;";
  418. }
  419. reVal += "\"" + id + "\"" + ":" + "\"" + $.trim(value) + "\",";
  420. break;
  421. case "selectTree":
  422. var value = $("#" + id).attr("data-value");
  423. if (value == "") {
  424. value = "&nbsp;";
  425. }
  426. reVal += "\"" + id + "\"" + ":" + "\"" + $.trim(value) + "\",";
  427. break;
  428. default:
  429. var value = $("#" + id).val();
  430. if (value == "") {
  431. value = "&nbsp;";
  432. }
  433. reVal += "\"" + id + "\"" + ":" + "\"" + $.trim(value) + "\",";
  434. break;
  435. }
  436. });
  437. reVal = reVal.substr(0, reVal.length - 1);
  438. if (!keyValue) {
  439. reVal = reVal.replace(/&nbsp;/g, "");
  440. }
  441. reVal = reVal.replace(/\\/g, "\\\\");
  442. reVal = reVal.replace(/\n/g, "\\n");
  443. var postdata = jQuery.parseJSON("{" + reVal + "}");
  444. //阻止伪造请求
  445. //if ($('[name=__RequestVerificationToken]').length > 0) {
  446. // postdata["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val();
  447. //}
  448. return postdata;
  449. };
  450. $.fn.SetWebControls = function (data) {
  451. var $id = $(this);
  452. for (var key in data) {
  453. var id = $id.find("#" + key);
  454. if (id.attr("id")) {
  455. var type = id.attr("type");
  456. if (id.hasClass("input-datepicker")) {
  457. type = "datepicker";
  458. }
  459. if (!type && id[0] && (id[0].nodeName === "DIV" || id[0].nodeName === "SPAN")) {
  460. type = id[0].nodeName;
  461. }
  462. var value = $.trim(data[key]).replace(/&nbsp;/g, "");
  463. switch (type) {
  464. case "checkbox":
  465. if (value === 1||value === true) {
  466. id.attr("checked", "checked");
  467. id.parent().addClass("checked");
  468. } else {
  469. id.removeAttr("checked");
  470. }
  471. break;
  472. case "select":
  473. id.ComboBoxSetValue(value);
  474. break;
  475. case "selectTree":
  476. id.ComboBoxTreeSetValue(value);
  477. break;
  478. case "datepicker":
  479. id.val(formatDate(value, "yyyy-MM-dd"));
  480. break;
  481. case "DIV":
  482. case "SPAN":
  483. id.html(value);
  484. break;
  485. default:
  486. id.val(value);
  487. break;
  488. }
  489. }
  490. }
  491. };
  492. $.fn.Contextmenu = function () {
  493. var element = $(this);
  494. var oMenu = $(".contextmenu");
  495. $(document).click(function () {
  496. oMenu.hide();
  497. });
  498. $(document).mousedown(function (e) {
  499. if (3 == e.which) {
  500. oMenu.hide();
  501. }
  502. });
  503. var aUl = oMenu.find("ul");
  504. var aLi = oMenu.find("li");
  505. var showTimer = hideTimer = null;
  506. var i = 0;
  507. var maxWidth = maxHeight = 0;
  508. var aDoc = [document.documentElement.offsetWidth, document.documentElement.offsetHeight];
  509. oMenu.hide();
  510. for (i = 0; i < aLi.length; i++) {
  511. //为含有子菜单的li加上箭头
  512. aLi[i].getElementsByTagName("ul")[0] && (aLi[i].className = "sub");
  513. //鼠标移入
  514. aLi[i].onmouseover = function () {
  515. var oThis = this;
  516. var oUl = oThis.getElementsByTagName("ul");
  517. //鼠标移入样式
  518. oThis.className += " active";
  519. //显示子菜单
  520. if (oUl[0]) {
  521. clearTimeout(hideTimer);
  522. showTimer = setTimeout(function () {
  523. for (i = 0; i < oThis.parentNode.children.length; i++) {
  524. oThis.parentNode.children[i].getElementsByTagName("ul")[0] &&
  525. (oThis.parentNode.children[i].getElementsByTagName("ul")[0].style.display = "none");
  526. }
  527. oUl[0].style.display = "block";
  528. oUl[0].style.top = oThis.offsetTop + "px";
  529. oUl[0].style.left = oThis.offsetWidth + "px";
  530. //最大显示范围
  531. maxWidth = aDoc[0] - oUl[0].offsetWidth;
  532. maxHeight = aDoc[1] - oUl[0].offsetHeight;
  533. //防止溢出
  534. maxWidth < getOffset.left(oUl[0]) && (oUl[0].style.left = -oUl[0].clientWidth + "px");
  535. maxHeight < getOffset.top(oUl[0]) && (oUl[0].style.top = -oUl[0].clientHeight + oThis.offsetTop + oThis.clientHeight + "px");
  536. }, 300);
  537. }
  538. };
  539. //鼠标移出
  540. aLi[i].onmouseout = function () {
  541. var oThis = this;
  542. var oUl = oThis.getElementsByTagName("ul");
  543. //鼠标移出样式
  544. oThis.className = oThis.className.replace(/\s?active/, "");
  545. clearTimeout(showTimer);
  546. hideTimer = setTimeout(function () {
  547. for (i = 0; i < oThis.parentNode.children.length; i++) {
  548. oThis.parentNode.children[i].getElementsByTagName("ul")[0] &&
  549. (oThis.parentNode.children[i].getElementsByTagName("ul")[0].style.display = "none");
  550. }
  551. }, 300);
  552. };
  553. }
  554. //自定义右键菜单
  555. $(element).bind("contextmenu", function () {
  556. var event = event || window.event;
  557. oMenu.show();
  558. oMenu.css("top", event.clientY + "px");
  559. oMenu.css("left", event.clientX + "px");
  560. //最大显示范围
  561. maxWidth = aDoc[0] - oMenu.width();
  562. maxHeight = aDoc[1] - oMenu.height();
  563. //防止菜单溢出
  564. if (oMenu.offset().top > maxHeight) {
  565. oMenu.css("top", maxHeight + "px");
  566. }
  567. if (oMenu.offset().left > maxWidth) {
  568. oMenu.css("left", maxWidth + "px");
  569. }
  570. return false;
  571. }).bind("click", function () {
  572. oMenu.hide();
  573. });
  574. };
  575. $.fn.panginationEx = function (options) {
  576. var $pager = $(this);
  577. if (!$pager.attr("id")) {
  578. return false;
  579. }
  580. var defaults = {
  581. firstBtnText: "首页",
  582. lastBtnText: "尾页",
  583. prevBtnText: "上一页",
  584. nextBtnText: "下一页",
  585. showInfo: true,
  586. showJump: true,
  587. jumpBtnText: "跳转",
  588. showPageSizes: true,
  589. infoFormat: "{start} ~ {end}条,共{total}条",
  590. sortname: "",
  591. url: "",
  592. success: null,
  593. beforeSend: null,
  594. complete: null
  595. };
  596. var options = $.extend(defaults, options);
  597. var params = $.extend({ sidx: options.sortname, sord: "asc" }, options.params);
  598. options.remote = {
  599. url: options.url, //请求地址
  600. params: params, //自定义请求参数
  601. beforeSend: function (XMLHttpRequest) {
  602. if (options.beforeSend != null) {
  603. options.beforeSend(XMLHttpRequest);
  604. }
  605. },
  606. success: function (result, pageIndex) {
  607. //回调函数
  608. //result 为 请求返回的数据,呈现数据
  609. if (options.success != null) {
  610. options.success(result.rows, pageIndex);
  611. }
  612. },
  613. complete: function (XMLHttpRequest, textStatu) {
  614. if (options.complete != null) {
  615. options.complete(XMLHttpRequest, textStatu);
  616. }
  617. //...
  618. },
  619. pageIndexName: "page", //请求参数,当前页数,索引从0开始
  620. pageSizeName: "rows", //请求参数,每页数量
  621. totalName: "records" //指定返回数据的总数据量的字段名
  622. };
  623. $pager.page(options);
  624. };
  625. $.fn.LeftListShowOfemail = function (options) {
  626. var $list = $(this);
  627. if (!$list.attr("id")) {
  628. return false;
  629. }
  630. $list.append("<ul style=\"padding-top: 10px;\"></ul>");
  631. var defaults = {
  632. id: "id",
  633. name: "text",
  634. img: "fa fa-file-o",
  635. };
  636. var options = $.extend(defaults, options);
  637. $list.height(options.height);
  638. $.ajax({
  639. url: options.url,
  640. data: options.param,
  641. type: "GET",
  642. dataType: "json",
  643. async: false,
  644. success: function (data) {
  645. $.each(data, function (i, item) {
  646. var $_li = $("<li class=\"\" data-value=\"" + item[options.id] + "\" data-text=\"" + item[options.name] + "\" ><i class=\"" + options.img + "\" style=\"vertical-align: middle; margin-top: -2px; margin-right: 8px; font-size: 14px; color: #666666; opacity: 0.9;\"></i>" + item[options.name] + "</li>");
  647. if (i == 0) {
  648. $_li.addClass("active");
  649. }
  650. $list.find("ul").append($_li);
  651. });
  652. $list.find("li").click(function () {
  653. var key = $(this).attr("data-value");
  654. var value = $(this).attr("data-text");
  655. $list.find("li").removeClass("active");
  656. $(this).addClass("active");
  657. options.onnodeclick({ id: key, name: value });
  658. });
  659. },
  660. error: function (XMLHttpRequest, textStatus, errorThrown) {
  661. $.fn.modalMsg(errorThrown, "warning");
  662. }
  663. });
  664. };
  665. $.fn.authorizeButton = function () {
  666. var $element = $(this);
  667. $element.find("a.btn").attr("authorize", "no");
  668. $element.find("ul.dropdown-menu").find("li").attr("authorize", "no");
  669. var moduleId = tabiframeId().substring(11);
  670. $.getJSON("/SysMgr/PermissionUserMgr/GetUserPermissionButtonsByModuleId", { moduleId: moduleId }, function (data) {
  671. if (data) {
  672. $.each(data, function(i) {
  673. $element.find("." + data[i].EnCode).attr("authorize", "yes");
  674. });
  675. }
  676. $element.find("[authorize=no]").remove();
  677. });
  678. };
  679. $.fn.authorizeColModel = function () {
  680. var $element = $(this);
  681. var columnModel = $element.jqGrid("getGridParam", "colModel");
  682. $.each(columnModel, function (i) {
  683. if (columnModel[i].name != "rn") {
  684. $element.hideCol(columnModel[i].name);
  685. }
  686. });
  687. var moduleId = tabiframeId().substr(6);
  688. var data = top.authorizeColumnData[moduleId];
  689. if (data != undefined) {
  690. $.each(data, function (i) {
  691. $element.showCol(data[i].F_EnCode);
  692. });
  693. }
  694. };
  695. $.fn.jqGridEx = function (options) {
  696. var $jqGrid = $(this);
  697. var _selectedRowIndex;
  698. if (!$jqGrid.attr("id")) {
  699. return false;
  700. }
  701. var defaults = {
  702. url: "",
  703. datatype: "json",
  704. height: $(window).height() - 139.5,
  705. autowidth: true,
  706. colModel: [],
  707. viewrecords: true,
  708. rowNum: 30,
  709. rowList: [30, 50, 100],
  710. pager: "#gridPager",
  711. sortname: "CreationTime desc",
  712. rownumbers: true,
  713. shrinkToFit: false,
  714. gridview: true,
  715. onSelectRow: function () {
  716. _selectedRowIndex = $("#" + this.id).getGridParam("selrow");
  717. },
  718. gridComplete: function () {
  719. $("#" + this.id).setSelection(_selectedRowIndex, false);
  720. }
  721. };
  722. var options = $.extend(defaults, options);
  723. $jqGrid.jqGrid(options);
  724. };
  725. $.fn.jqGridRowValue = function (code) {
  726. var $jgrid = $(this);
  727. var json = [];
  728. var selectedRowIds = $jgrid.jqGrid("getGridParam", "selarrrow");
  729. if (selectedRowIds != undefined && selectedRowIds != "") {
  730. var len = selectedRowIds.length;
  731. for (var i = 0; i < len; i++) {
  732. var rowData = $jgrid.jqGrid("getRowData", selectedRowIds[i]);
  733. json.push(rowData[code]);
  734. }
  735. } else {
  736. var rowData = $jgrid.jqGrid("getRowData", $jgrid.jqGrid("getGridParam", "selrow"));
  737. json.push(rowData[code]);
  738. }
  739. return String(json);
  740. };
  741. $.fn.jqGridRow = function () {
  742. var $jgrid = $(this);
  743. var json = [];
  744. var selectedRowIds = $jgrid.jqGrid("getGridParam", "selarrrow");
  745. if (selectedRowIds != "") {
  746. var len = selectedRowIds.length;
  747. for (var i = 0; i < len; i++) {
  748. var rowData = $jgrid.jqGrid("getRowData", selectedRowIds[i]);
  749. json.push(rowData);
  750. }
  751. } else {
  752. var rowData = $jgrid.jqGrid("getRowData", $jgrid.jqGrid("getGridParam", "selrow"));
  753. json.push(rowData);
  754. }
  755. return json;
  756. };
  757. $.fn.modalOpen = function (options) {
  758. var defaults = {
  759. id: null,
  760. title: '系统窗口',
  761. width: "100px",
  762. height: "100px",
  763. url: '',
  764. shade: 0.3,
  765. btn: ['确认', '关闭'],
  766. // btnclass: ['btn btn-primary', 'btn btn-danger'],
  767. callBack: null,
  768. allowOverParent: false
  769. };
  770. var options = $.extend(defaults, options);
  771. var _width = options.width, _height = options.height;
  772. if (!options.allowOverParent) {
  773. _width = top.$(window).width() > parseInt(options.width.replace('px', '')) ? options.width : top.$(window).width() + 'px';
  774. _height = top.$(window).height() > parseInt(options.height.replace('px', '')) ? options.height : top.$(window).height() + 'px';
  775. }
  776. top.layer.open({
  777. id: options.id,
  778. type: 2,
  779. shade: options.shade,
  780. title: options.title,
  781. fix: false,
  782. area: [_width, _height],
  783. content: options.url,
  784. btn: options.btn,
  785. btnclass: options.btnclass,
  786. yes: function (index) {
  787. options.callBack("layui-layer-iframe" + index)
  788. }, cancel: function (index) {
  789. if (options.cancelCallBack) {
  790. options.cancelCallBack("layui-layer-iframe" + index);
  791. }
  792. return true;
  793. }
  794. });
  795. }
  796. $.fn.modalConfirm = function (content, callBack) {
  797. top.layer.confirm(content, {
  798. icon: 3,
  799. title: "系统提示",
  800. btn: ['确认', '取消'],
  801. // btnclass: ['btn btn-primary', 'btn btn-danger'],
  802. }, function () {
  803. callBack(true);
  804. }, function () {
  805. callBack(false)
  806. });
  807. }
  808. $.fn.modalAlert = function (content, type) {
  809. var icon = "";
  810. var iconType = 0;
  811. if (type == 'success') {
  812. icon = "fa-check-circle";
  813. iconType = 1;
  814. }
  815. if (type == 'error') {
  816. icon = "fa-times-circle";
  817. iconType = 2;
  818. }
  819. if (type == 'warning') {
  820. icon = "fa-exclamation-circle";
  821. iconType = 3;
  822. }
  823. top.layer.alert(content, {
  824. icon: iconType,
  825. title: "系统提示",
  826. btn: ['确认'],
  827. // btnclass: ['btn btn-primary'],
  828. });
  829. }
  830. $.fn.modalMsg = function (content, type) {
  831. var iconType = 0;
  832. if (type != undefined) {
  833. var icon = "";
  834. if (type == 'success') {
  835. icon = "fa-check-circle";
  836. iconType = 1;
  837. }
  838. if (type == 'error') {
  839. icon = "fa-times-circle";
  840. iconType = 2;
  841. }
  842. if (type == 'warning') {
  843. icon = "fa-exclamation-circle";
  844. iconType = 3;
  845. }
  846. top.layer.msg(content, { icon: iconType, time: 4000, shift: 5 });
  847. top.$(".layui-layer-msg").find('i.' + iconType).parents('.layui-layer-msg').addClass('layui-layer-msg-' + type);
  848. } else {
  849. top.layer.msg(content);
  850. }
  851. }
  852. $.fn.modalClose = function () {
  853. var index = top.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  854. var $IsdialogClose = top.$("#layui-layer" + index).find('.layui-layer-btn').find("#IsdialogClose");
  855. var IsClose = $IsdialogClose.is(":checked");
  856. if ($IsdialogClose.length == 0) {
  857. IsClose = true;
  858. }
  859. if (IsClose) {
  860. top.layer.close(index);
  861. } else {
  862. location.reload();
  863. }
  864. }
  865. $.fn.submitForm = function (options) {
  866. var defaults = {
  867. url: "",
  868. param: [],
  869. loading: "正在提交数据...",
  870. success: null,
  871. close: true
  872. };
  873. var options = $.extend(defaults, options);
  874. $.loading(true, options.loading);
  875. window.setTimeout(function () {
  876. $.ajax({
  877. url: options.url,
  878. data: options.param,
  879. type: "post",
  880. dataType: "json",
  881. success: function (data) {
  882. if (data.IsSucceeded==true) {
  883. options.success(data);
  884. $.fn.modalMsg(data.Message, "success");
  885. if (options.close == true) {
  886. $.fn.modalClose();
  887. }
  888. } else {
  889. $.fn.modalAlert(data.Message, "danger");
  890. }
  891. },
  892. error: function (XMLHttpRequest, textStatus, errorThrown) {
  893. $.loading(false);
  894. $.fn.modalMsg(errorThrown, "error");
  895. },
  896. beforeSend: function () {
  897. $.loading(true, options.loading);
  898. },
  899. complete: function () {
  900. $.loading(false);
  901. }
  902. });
  903. }, 500);
  904. }
  905. //提交ajax请求
  906. $.fn.submitAjax = function (options) {
  907. App.blockUI({
  908. target: options.target,
  909. boxed: true,
  910. message: '加载中'//,
  911. // animate: true
  912. });
  913. window.setTimeout(function () {
  914. $.ajax({
  915. url: options.url,
  916. data: options.param,
  917. type: "post",
  918. dataType: "json",
  919. success: function (data) {
  920. if (data.IsSucceeded == true) {
  921. options.success(data);
  922. } else {
  923. $.fn.modalAlert(data.Message, "danger");
  924. }
  925. },
  926. error: function (xmlHttpRequest, textStatus, errorThrown) {
  927. App.unblockUI(options.target);
  928. $.fn.modalMsg(errorThrown, "error");
  929. },
  930. beforeSend: function () {
  931. App.unblockUI(options.target);
  932. },
  933. complete: function () {
  934. App.unblockUI(options.target);
  935. }
  936. });
  937. }, 500);
  938. }
  939. $.fn.deleteForm = function (options) {
  940. var defaults = {
  941. prompt: "注:您确定要删除该项数据吗?",
  942. url: "",
  943. param: [],
  944. loading: "正在删除数据...",
  945. success: null,
  946. close: true
  947. };
  948. var options = $.extend(defaults, options);
  949. $.fn.modalConfirm(options.prompt, function (r) {
  950. if (r) {
  951. $.loading(true, options.loading);
  952. window.setTimeout(function () {
  953. $.ajax({
  954. url: options.url,
  955. data: options.param,
  956. type: "post",
  957. dataType: "json",
  958. success: function (data) {
  959. if (data.IsSucceeded==true) {
  960. options.success(data);
  961. $.fn.modalMsg(data.Message, "success");
  962. } else {
  963. $.fn.modalAlert(data.Message, "danger");
  964. }
  965. },
  966. error: function (XMLHttpRequest, textStatus, errorThrown) {
  967. $.loading(false);
  968. $.fn.modalMsg(errorThrown, "error");
  969. },
  970. beforeSend: function () {
  971. $.loading(true, options.loading);
  972. },
  973. complete: function () {
  974. $.loading(false);
  975. }
  976. });
  977. }, 500);
  978. }
  979. });
  980. }
  981. $.fn.request = function (name) {
  982. var search = location.search.slice(1);
  983. var arr = search.split("&");
  984. for (var i = 0; i < arr.length; i++) {
  985. var ar = arr[i].split("=");
  986. if (ar[0] == name) {
  987. if (unescape(ar[1]) == 'undefined') {
  988. return "";
  989. } else {
  990. return unescape(ar[1]);
  991. }
  992. }
  993. }
  994. return "";
  995. }
  996. $.fn.setForm = function (options) {
  997. var defaults = {
  998. url: "",
  999. param: [],
  1000. type: "get",
  1001. dataType: "json",
  1002. success: null,
  1003. async: false
  1004. };
  1005. var options = $.extend(defaults, options);
  1006. $.ajax({
  1007. url: options.url,
  1008. data: options.param,
  1009. type: options.type,
  1010. dataType: options.dataType,
  1011. async: options.async,
  1012. success: function (data) {
  1013. if (data != null && data.type == "3") {
  1014. $.fn.modalAlert(data.meesage, "danger");
  1015. } else {
  1016. options.success(data);
  1017. }
  1018. },
  1019. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1020. $.fn.modalAlert(errorThrown, "danger");
  1021. }, beforeSend: function () {
  1022. $.loading(true);
  1023. },
  1024. complete: function () {
  1025. $.loading(false);
  1026. }
  1027. });
  1028. }
  1029. $.fn.existField = function (controlId, url, param) {
  1030. var $control = $("#" + controlId);
  1031. if (!$control.val()) {
  1032. return false;
  1033. }
  1034. var data = {
  1035. keyValue: $.fn.request('keyValue')
  1036. };
  1037. data[controlId] = $control.val();
  1038. var options = $.extend(data, param);
  1039. $.ajax({
  1040. url: url,
  1041. data: options,
  1042. type: "get",
  1043. dataType: "text",
  1044. async: false,
  1045. success: function (data) {
  1046. if (data.toLocaleLowerCase() == 'false') {
  1047. ValidationMessage($control, '已存在,请重新输入');
  1048. $control.attr('fieldexist', 'yes');
  1049. } else {
  1050. $control.attr('fieldexist', 'no');
  1051. }
  1052. },
  1053. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1054. $.fn.modalMsg(errorThrown, "warning");
  1055. }
  1056. });
  1057. }
  1058. $.fn.confirmAjax = function (options) {
  1059. var defaults = {
  1060. msg: "提示信息",
  1061. loading: "正在处理数据...",
  1062. url: "",
  1063. param: [],
  1064. type: "post",
  1065. dataType: "json",
  1066. success: null
  1067. };
  1068. var options = $.extend(defaults, options);
  1069. $.fn.modalConfirm(options.msg, function (r) {
  1070. if (r) {
  1071. $.loading(true, options.loading);
  1072. window.setTimeout(function () {
  1073. var postdata = options.param;
  1074. $.ajax({
  1075. url: options.url,
  1076. data: postdata,
  1077. type: options.type,
  1078. dataType: options.dataType,
  1079. success: function (data) {
  1080. $.loading(false);
  1081. if (data.type == "3") {
  1082. $.fn.modalAlert(data.Message, "warning");
  1083. } else {
  1084. $.fn.modalMsg(data.Message, "warning");
  1085. options.success(data);
  1086. }
  1087. },
  1088. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1089. $.loading(false);
  1090. $.fn.modalMsg(errorThrown, "warning");
  1091. },
  1092. beforeSend: function () {
  1093. $.loading(true, options.loading);
  1094. },
  1095. complete: function () {
  1096. $.loading(false);
  1097. }
  1098. });
  1099. }, 200);
  1100. }
  1101. });
  1102. }
  1103. reload = function () {
  1104. location.reload();
  1105. return false;
  1106. };
  1107. newGuid = function () {
  1108. var guid = "";
  1109. for (var i = 1; i <= 32; i++) {
  1110. var n = Math.floor(Math.random() * 16.0).toString(16);
  1111. guid += n;
  1112. if ((i == 8) || (i == 12) || (i == 16) || (i == 20)) guid += "-";
  1113. }
  1114. return guid;
  1115. };
  1116. formatDate = function (v, format) {
  1117. if (!v) return "";
  1118. var d = v;
  1119. if (typeof v === "string") {
  1120. if (v.indexOf("/Date(") > -1)
  1121. d = new Date(parseInt(v.replace("/Date(", "").replace(")/", ""), 10));
  1122. else
  1123. d = new Date(Date.parse(v.replace(/-/g, "/").replace("T", " ").split(".")[0])); //.split(".")[0] 用来处理出现毫秒的情况,截取掉.xxx,否则会出错
  1124. }
  1125. var o = {
  1126. "M+": d.getMonth() + 1, //month
  1127. "d+": d.getDate(), //day
  1128. "h+": d.getHours(), //hour
  1129. "m+": d.getMinutes(), //minute
  1130. "s+": d.getSeconds(), //second
  1131. "q+": Math.floor((d.getMonth() + 3) / 3), //quarter
  1132. "S": d.getMilliseconds() //millisecond
  1133. };
  1134. if (/(y+)/.test(format)) {
  1135. format = format.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length));
  1136. }
  1137. for (var k in o) {
  1138. if (new RegExp("(" + k + ")").test(format)) {
  1139. format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
  1140. }
  1141. }
  1142. return format;
  1143. };
  1144. toDecimal = function (num) {
  1145. if (num == null) {
  1146. num = "0";
  1147. }
  1148. num = num.toString().replace(/\$|\,/g, "");
  1149. if (isNaN(num))
  1150. num = "0";
  1151. sign = (num == (num = Math.abs(num)));
  1152. num = Math.floor(num * 100 + 0.50000000001);
  1153. cents = num % 100;
  1154. num = Math.floor(num / 100).toString();
  1155. if (cents < 10)
  1156. cents = "0" + cents;
  1157. for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3) ; i++)
  1158. num = num.substring(0, num.length - (4 * i + 3)) + "" +
  1159. num.substring(num.length - (4 * i + 3));
  1160. return (((sign) ? "" : "-") + num + "." + cents);
  1161. };
  1162. Date.prototype.DateAdd = function (strInterval, Number) {
  1163. //y年 q季度 m月 d日 w周 h小时 n分钟 s秒 ms毫秒
  1164. var dtTmp = this;
  1165. switch (strInterval) {
  1166. case "s":
  1167. return new Date(Date.parse(dtTmp) + (1000 * Number));
  1168. case "n":
  1169. return new Date(Date.parse(dtTmp) + (60000 * Number));
  1170. case "h":
  1171. return new Date(Date.parse(dtTmp) + (3600000 * Number));
  1172. case "d":
  1173. return new Date(Date.parse(dtTmp) + (86400000 * Number));
  1174. case "w":
  1175. return new Date(Date.parse(dtTmp) + ((86400000 * 7) * Number));
  1176. case "q":
  1177. return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number * 3, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
  1178. case "m":
  1179. return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
  1180. case "y":
  1181. return new Date((dtTmp.getFullYear() + Number), dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
  1182. }
  1183. };
  1184. request = function (keyValue) {
  1185. var search = location.search.slice(1);
  1186. var arr = search.split("&");
  1187. for (var i = 0; i < arr.length; i++) {
  1188. var ar = arr[i].split("=");
  1189. if (ar[0] == keyValue) {
  1190. if (unescape(ar[1]) == "undefined") {
  1191. return "";
  1192. } else {
  1193. return unescape(ar[1]);
  1194. }
  1195. }
  1196. }
  1197. return "";
  1198. };
  1199. changeUrlParam = function (url, key, value) {
  1200. var newUrl = "";
  1201. var reg = new RegExp("(^|)" + key + "=([^&]*)(|$)");
  1202. var tmp = key + "=" + value;
  1203. if (url.match(reg) != null) {
  1204. newUrl = url.replace(eval(reg), tmp);
  1205. } else {
  1206. if (url.match("[\?]")) {
  1207. newUrl = url + "&" + tmp;
  1208. } else {
  1209. newUrl = url + "?" + tmp;
  1210. }
  1211. }
  1212. return newUrl;
  1213. };
  1214. $.currentIframe = function () {
  1215. if ($.isbrowsername() == "Chrome" || $.isbrowsername() == "FF") {
  1216. return top.frames[tabiframeId()].contentWindow;
  1217. } else {
  1218. return top.frames[tabiframeId()];
  1219. }
  1220. };
  1221. $.isbrowsername = function () {
  1222. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  1223. var isOpera = userAgent.indexOf("Opera") > -1;
  1224. if (isOpera) {
  1225. return "Opera";
  1226. }; //判断是否Opera浏览器
  1227. if (userAgent.indexOf("Firefox") > -1) {
  1228. return "FF";
  1229. } //判断是否Firefox浏览器
  1230. if (userAgent.indexOf("Chrome") > -1) {
  1231. if (window.navigator.webkitPersistentStorage.toString().indexOf("DeprecatedStorageQuota") > -1) {
  1232. return "Chrome";
  1233. } else {
  1234. return "360";
  1235. }
  1236. } //判断是否Chrome浏览器//360浏览器
  1237. if (userAgent.indexOf("Safari") > -1) {
  1238. return "Safari";
  1239. } //判断是否Safari浏览器
  1240. if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
  1241. return "IE";
  1242. }; //判断是否IE浏览器
  1243. };
  1244. $.download = function (url, data, method) {
  1245. if (url && data) {
  1246. data = typeof data == "string" ? data : jQuery.param(data);
  1247. var inputs = "";
  1248. $.each(data.split("&"), function () {
  1249. var pair = this.split("=");
  1250. inputs += "<input type=\"hidden\" name=\"" + pair[0] + "\" value=\"" + pair[1] + "\" />";
  1251. });
  1252. $("<form action=\"" + url + "\" method=\"" + (method || "post") + "\">" + inputs + "</form>").appendTo("body").submit().remove();
  1253. };
  1254. };
  1255. $.standTabchange = function (object, forid) {
  1256. $(".standtabactived").removeClass("standtabactived");
  1257. $(object).addClass("standtabactived");
  1258. $(".standtab-pane").css("display", "none");
  1259. $("#" + forid).css("display", "block");
  1260. };
  1261. $.isNullOrEmpty = function (obj) {
  1262. if ((typeof (obj) == "string" && obj == "") || obj == null || obj == undefined) {
  1263. return true;
  1264. } else {
  1265. return false;
  1266. }
  1267. };
  1268. $.arrayClone = function (data) {
  1269. return $.map(data, function (obj) {
  1270. return $.extend(true, {}, obj);
  1271. });
  1272. };
  1273. $.windowWidth = function () {
  1274. return $(window).width();
  1275. };
  1276. $.windowHeight = function () {
  1277. return $(window).height();
  1278. };
  1279. IsNumber = function (obj) {
  1280. $("#" + obj).bind("contextmenu", function () {
  1281. return false;
  1282. });
  1283. $("#" + obj).css("ime-mode", "disabled");
  1284. $("#" + obj).keypress(function (e) {
  1285. if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
  1286. return false;
  1287. }
  1288. });
  1289. };
  1290. IsMoney = function (obj) {
  1291. $("#" + obj).bind("contextmenu", function () {
  1292. return false;
  1293. });
  1294. $("#" + obj).css("ime-mode", "disabled");
  1295. $("#" + obj).bind("keydown", function (e) {
  1296. var key = window.event ? e.keyCode : e.which;
  1297. if (isFullStop(key)) {
  1298. return $(this).val().indexOf(".") < 0;
  1299. }
  1300. return (isSpecialKey(key)) || ((isNumber(key) && !e.shiftKey));
  1301. });
  1302. function isNumber(key) {
  1303. return key >= 48 && key <= 57;
  1304. }
  1305. function isSpecialKey(key) {
  1306. return key == 8 || key == 46 || (key >= 37 && key <= 40) || key == 35 || key == 36 || key == 9 || key == 13;
  1307. }
  1308. function isFullStop(key) {
  1309. return key == 190 || key == 110;
  1310. }
  1311. };
  1312. checkedArray = function (id) {
  1313. var isOK = true;
  1314. if (id == undefined || id == "" || id == "null" || id == "undefined") {
  1315. isOK = false;
  1316. $.fn.modalMsg("您没有选中任何项,请您选中后再操作。", "warning");
  1317. }
  1318. return isOK;
  1319. };
  1320. checkedRow = function (id) {
  1321. var isOK = true;
  1322. if (id == undefined || id == "" || id == "null" || id == "undefined") {
  1323. isOK = false;
  1324. $.fn.modalMsg("您没有选中任何项,请您选中后再操作。", "warning");
  1325. } else if (id.split(",").length > 1) {
  1326. isOK = false;
  1327. $.fn.modalMsg("很抱歉,一次只能选择一条记录!", "warning");
  1328. }
  1329. return isOK;
  1330. };
  1331. getQueryString=function(name) {
  1332. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  1333. var r = window.location.search.substr(1).match(reg);
  1334. if (r != null) return unescape(r[2]); return null;
  1335. }