global.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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));
  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);
  34. $('#comments').find('textarea').height($('#comments').height() - 25);
  35. typeof(adaptiveTzjnrWidth)== 'function' ?adaptiveTzjnrWidth():''
  36. typeof MaterialController === 'object' ? MaterialController.initItemWidth() : '';
  37. typeof zmhs_obj === 'object' ? zmhs_obj.loadSideResize() : '';
  38. };
  39. /*全局自适应高度结束*/
  40. $(function () {
  41. $(window).resize(autoFlashHeight);
  42. /*侧滑*/
  43. /* $(".open-sidebar").click(function () {
  44. $(".slide-sidebar").animate({width: "800"}).addClass("open");
  45. });
  46. $("body").click(function (event) {
  47. var e = event || window.event; //浏览器兼容性
  48. if (!$(event.target).is('a')) {
  49. var elem = event.target || e.srcElement;
  50. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  51. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  52. return false;
  53. }
  54. elem = elem.parentNode;
  55. }
  56. $(".slide-sidebar").animate({width: "0"}).removeClass("open")// 关闭处理
  57. }
  58. });*/
  59. /*侧滑*/
  60. /*工具提示*/
  61. $(function () {
  62. $('[data-toggle="tooltip"]').tooltip();
  63. $('[data-toggle="tooltip"]').click(function () {
  64. $(this).tooltip('hide');
  65. })
  66. });
  67. });
  68. /**
  69. * 设置本地缓存
  70. *
  71. * @param {String} key
  72. * @param {String|Number} value
  73. * @return {void}
  74. */
  75. function setLocalCache(key, value) {
  76. const storage = window.localStorage;
  77. if (!storage || key === '' || value === '') {
  78. return;
  79. }
  80. storage.setItem(key, value);
  81. }
  82. /**
  83. * 获取本地缓存
  84. *
  85. * @param {String} key
  86. * @return {String}
  87. */
  88. function getLocalCache(key) {
  89. const storage = window.localStorage;
  90. if (!storage || key === '') {
  91. return null;
  92. }
  93. return storage.getItem(key);
  94. }
  95. function removeLocalCache(key) {
  96. const storage = window.localStorage;
  97. if (!storage || key === '') {
  98. return null;
  99. }
  100. return storage.removeItem(key);
  101. }
  102. function getFormatter(decimal) {
  103. var pre = "0.";
  104. if (decimal <= 0) {
  105. return "0";
  106. }
  107. for (let i = 0; i < decimal; i++) {
  108. pre += "0"
  109. }
  110. return pre;
  111. }
  112. function getFeeIndex(fees) {
  113. let feesIndex = {};
  114. if (fees) {
  115. for(let fee of fees){
  116. fee.unitFee = parseFloat(fee.unitFee);
  117. fee.totalFee = parseFloat(fee.totalFee);
  118. fee.tenderUnitFee = parseFloat(fee.tenderUnitFee);
  119. fee.tenderTotalFee = parseFloat(fee.tenderTotalFee);
  120. feesIndex[fee.fieldName] = fee;
  121. }
  122. }
  123. return feesIndex;
  124. }
  125. function replaceAll(FindText, RepText,str) {
  126. let regExp = new RegExp(FindText, "g");
  127. return str.replace(regExp, RepText);
  128. };