global.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*全局自适应高度*/
  2. function autoFlashHeight(){
  3. let headerHeight = $(".header").height();
  4. let toolsbarHeight = $(".toolsbar").height();
  5. let ftoolsbarHeight = $(".toolsbar-f").height();
  6. let btntoolsbarHeight = $(".btn-toolbar").height();
  7. // var feeRateToolsbarHeight = $(".toolsbar_feeRate").height();
  8. let toolsBarHeightQ = $(".tools-bar-height-q").height();
  9. let toolsBarHeightD = $(".tools-bar-height-d").height();
  10. let toolsBarHeightZ = $(".tools-bar-height-z").height();
  11. //$(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-302);
  12. $(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-$('#qd').find('.bottom-content').find('.p-0').height()-5);
  13. //$(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-302);
  14. $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-$('#stdSectionRations').height()-5);
  15. $(".main-data-side-zb").height(($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightZ) - $('#billsGuidance_items').height() - $('#zyTools').height() - 12);
  16. /*$(".main-data-side-zi").height($(window).height()-headerHeight-toolsbarHeight- toolsBarHeightZ - $(".main-data-side-zb").height());*/
  17. $('.main-content').width($(window).width()-$('.main-nav').width()-$('.main-side').width()-5);
  18. $('#glj_tree_div .modal-content').width($(window).width() < 1020 + 20 ? $(window).width() - 20 : 1020);
  19. //$("#main .main-data-top").height($(window).height()-headerHeight-toolsbarHeight-bottomContentHeight-1);
  20. typeof(loadMainSize)== 'function' ?loadMainSize():'';//zhang 2018-06-04 统一加载高度方法
  21. typeof(loadProjectGljSize)== 'function'?loadProjectGljSize():'';
  22. $(".main-data-full").height($(window).height()-headerHeight-toolsbarHeight-1);
  23. $(".main-data-full-fl").height($(window).height()-headerHeight-toolsbarHeight-37);
  24. $(".main-data-full-feeRate").height($(window).height()-headerHeight-78);
  25. $(".main-data-full-tender").height($(window).height()-headerHeight-btntoolsbarHeight-10);
  26. $(".main-data-not").height($(window).height()-headerHeight-1);
  27. $(".main-data-side-search").height($(window).height()-headerHeight-toolsbarHeight-64);
  28. $(".side-content").height($(window).height()-headerHeight );
  29. $(".poj-list").height($(window).height()-headerHeight-toolsbarHeight);
  30. $(".gc-list").height($(window).height()-headerHeight-toolsbarHeight-40);
  31. $(".share-list").height($(window).height()-headerHeight-toolsbarHeight-40);
  32. $(".form-view").height($(window).height()-headerHeight-ftoolsbarHeight);
  33. $(".form-list").height($(window).height()-headerHeight-50 );
  34. $('#comments').find('textarea').height($('#comments').height() - 25);
  35. typeof(adaptiveTzjnrWidth)== 'function' ?adaptiveTzjnrWidth():''
  36. };
  37. /*全局自适应高度结束*/
  38. $(function () {
  39. $(window).resize(autoFlashHeight);
  40. /*侧滑*/
  41. /* $(".open-sidebar").click(function () {
  42. $(".slide-sidebar").animate({width: "800"}).addClass("open");
  43. });
  44. $("body").click(function (event) {
  45. var e = event || window.event; //浏览器兼容性
  46. if (!$(event.target).is('a')) {
  47. var elem = event.target || e.srcElement;
  48. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  49. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  50. return false;
  51. }
  52. elem = elem.parentNode;
  53. }
  54. $(".slide-sidebar").animate({width: "0"}).removeClass("open")// 关闭处理
  55. }
  56. });*/
  57. /*侧滑*/
  58. /*工具提示*/
  59. $(function () {
  60. $('[data-toggle="tooltip"]').tooltip();
  61. $('[data-toggle="tooltip"]').click(function () {
  62. $(this).tooltip('hide');
  63. })
  64. });
  65. });
  66. /**
  67. * 设置本地缓存
  68. *
  69. * @param {String} key
  70. * @param {String|Number} value
  71. * @return {void}
  72. */
  73. function setLocalCache(key, value) {
  74. const storage = window.localStorage;
  75. if (!storage || key === '' || value === '') {
  76. return;
  77. }
  78. storage.setItem(key, value);
  79. }
  80. /**
  81. * 获取本地缓存
  82. *
  83. * @param {String} key
  84. * @return {String}
  85. */
  86. function getLocalCache(key) {
  87. const storage = window.localStorage;
  88. if (!storage || key === '') {
  89. return null;
  90. }
  91. return storage.getItem(key);
  92. }
  93. function removeLocalCache(key) {
  94. const storage = window.localStorage;
  95. if (!storage || key === '') {
  96. return null;
  97. }
  98. return storage.removeItem(key);
  99. }
  100. function getFormatter(decimal) {
  101. var pre = "0.";
  102. if (decimal <= 0) {
  103. return "0";
  104. }
  105. for (let i = 0; i < decimal; i++) {
  106. pre += "0"
  107. }
  108. return pre;
  109. }
  110. function getFeeIndex(fees) {
  111. let feesIndex = {};
  112. if (fees) {
  113. for(let fee of fees){
  114. fee.unitFee = parseFloat(fee.unitFee);
  115. fee.totalFee = parseFloat(fee.totalFee);
  116. fee.tenderUnitFee = parseFloat(fee.tenderUnitFee);
  117. fee.tenderTotalFee = parseFloat(fee.tenderTotalFee);
  118. feesIndex[fee.fieldName] = fee;
  119. }
  120. }
  121. return feesIndex;
  122. }
  123. function replaceAll(FindText, RepText,str) {
  124. let regExp = new RegExp(FindText, "g");
  125. return str.replace(regExp, RepText);
  126. };