global.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. $(".main-data-full").height($(window).height()-headerHeight-toolsbarHeight-1);
  21. $(".main-data-full-fl").height($(window).height()-headerHeight-toolsbarHeight-37);
  22. $(".main-data-full-feeRate").height($(window).height()-headerHeight-78);
  23. $(".main-data-full-tender").height($(window).height()-headerHeight-btntoolsbarHeight-10-30); // 30是留个水平进度条位置
  24. $(".main-data-not").height($(window).height()-headerHeight-1);
  25. $(".main-data-side-search").height($(window).height()-headerHeight-toolsbarHeight-64);
  26. $(".side-content").height($(window).height()-headerHeight );
  27. $(".poj-list").height($(window).height()-headerHeight-toolsbarHeight);
  28. $(".gc-list").height($(window).height()-headerHeight-toolsbarHeight-40);
  29. $(".share-list").height($(window).height()-headerHeight-toolsbarHeight-40);
  30. $(".form-view").height($(window).height()-headerHeight-ftoolsbarHeight);
  31. $(".form-list").height($(window).height()-headerHeight);
  32. $('#comments').find('textarea').height($('#comments').height() - 25);
  33. $('#project-glj-main').width($(window).width()-($('.main-nav').width()+ 2));//-($('.filterType').width()+12)-5); //2、12是padding宽度,width 是不算padding宽度的
  34. $('#project_glj_sheet').width($('#project-glj-main').width()-($('.filterType').width())-1)//1是border宽度,width 是不算padding和border宽度的
  35. typeof(loadProjectGljSize)== 'function'?loadProjectGljSize():'';
  36. typeof(loadMainSize)== 'function' ?loadMainSize():'';//zhang 2018-06-04 统一加载高度方法
  37. //typeof zmhs_obj === 'object' ? zmhs_obj.loadSideResize() : '';
  38. };
  39. /*全局自适应高度结束*/
  40. $(function () {
  41. //拖动头部
  42. $('body').on("show.bs.modal", ".modal", function(){
  43. if (typeof $(this).find('.modal-content').draggable === 'function') {
  44. $(this).find('.modal-content').draggable({handle: '.modal-header', cancel: 'a, button'});
  45. }
  46. });
  47. $(window).resize(autoFlashHeight);
  48. /*侧滑*/
  49. /* $(".open-sidebar").click(function () {
  50. $(".slide-sidebar").animate({width: "800"}).addClass("open");
  51. });
  52. $("body").click(function (event) {
  53. var e = event || window.event; //浏览器兼容性
  54. if (!$(event.target).is('a')) {
  55. var elem = event.target || e.srcElement;
  56. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  57. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  58. return false;
  59. }
  60. elem = elem.parentNode;
  61. }
  62. $(".slide-sidebar").animate({width: "0"}).removeClass("open")// 关闭处理
  63. }
  64. });*/
  65. /*侧滑*/
  66. /*工具提示*/
  67. $(function () {
  68. $('[data-toggle="tooltip"]').tooltip();
  69. if( $('[data-submenu]').submenupicker) $('[data-submenu]').submenupicker();
  70. $('[data-toggle="tooltip"]').click(function () {
  71. $(this).tooltip('hide');
  72. })
  73. });
  74. });
  75. /**
  76. * 设置本地缓存
  77. *
  78. * @param {String} key
  79. * @param {String|Number} value
  80. * @return {void}
  81. */
  82. let storageErrCount = 0;
  83. function setLocalCache(key, value) {
  84. const storage = window.localStorage;
  85. if (!storage || key === '' || value === '') {
  86. return;
  87. }
  88. try {
  89. storage.setItem(key, value);
  90. storageErrCount = 0;
  91. } catch (err) {
  92. storageErrCount++;
  93. if (storageErrCount > 1) {
  94. alert(`字段“${key}”数据过大,存入本地缓存失败。`)
  95. storageErrCount = 0;
  96. return;
  97. }
  98. storage.clear();
  99. setLocalCache(key, value);
  100. }
  101. }
  102. /**
  103. * 获取本地缓存
  104. *
  105. * @param {String} key
  106. * @return {String}
  107. */
  108. function getLocalCache(key) {
  109. const storage = window.localStorage;
  110. if (!storage || key === '') {
  111. return null;
  112. }
  113. return storage.getItem(key);
  114. }
  115. function removeLocalCache(key) {
  116. const storage = window.localStorage;
  117. if (!storage || key === '') {
  118. return null;
  119. }
  120. return storage.removeItem(key);
  121. }
  122. function getFormatter(decimal) {
  123. var pre = "0.";
  124. if (decimal <= 0) {
  125. return "0";
  126. }
  127. for (let i = 0; i < decimal; i++) {
  128. pre += "0"
  129. }
  130. return pre;
  131. }
  132. function getFeeIndex(fees) {
  133. let feesIndex = {};
  134. if (fees) {
  135. for(let fee of fees){
  136. const parsedUnitFee = parseFloat(fee.unitFee);
  137. const parsedTotalFee = parseFloat(fee.totalFee);
  138. const parsedTenderUnitFee = parseFloat(fee.tenderUnitFee);
  139. const parsedTenderTotalFee = parseFloat(fee.tenderTotalFee);
  140. fee.unitFee = parsedUnitFee || 0;
  141. fee.totalFee = parsedTotalFee || 0;
  142. fee.tenderUnitFee = parsedTenderUnitFee || 0;
  143. fee.tenderTotalFee = parsedTenderTotalFee || 0;
  144. feesIndex[fee.fieldName] = fee;
  145. }
  146. }
  147. return feesIndex;
  148. }
  149. function replaceAll(FindText, RepText,str) {
  150. let regExp = new RegExp(FindText, "g");
  151. return str.replace(regExp, RepText);
  152. };
  153. function setTimeoutSync(handle, time) {
  154. return new Promise(function(resolve, reject) {
  155. setTimeout(function () {
  156. if (handle && typeof handle === 'function') {
  157. handle();
  158. }
  159. resolve();
  160. }, time);
  161. });
  162. }
  163. async function progressStart(title,autoProgress = false){
  164. }