global.js 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*全局自适应高度*/
  2. function autoFlashHeight(){
  3. var headerHeight = $(".header").height();
  4. var bottomContentHeight = $(".bottom-content").height();
  5. var toolsBar = $(".tools-bar").height();
  6. $(".content").height($(window).height()-headerHeight);
  7. $(".main-side").height($(window).height()-headerHeight-2);
  8. $(".fluid-content").height($(window).height()-headerHeight-1);
  9. $(".side-content").height($(window).height()-headerHeight );
  10. $(".poj-list").height($(window).height()-headerHeight);
  11. $(".form-list").height($(window).height()-headerHeight-50 );
  12. $(".main-data-top").height($(window).height()-headerHeight-toolsBar-bottomContentHeight-2);
  13. $(".main-data-top-fluid").height($(window).height()-headerHeight-bottomContentHeight-2);
  14. $(".main-data").height($(window).height()-headerHeight);
  15. $(".main-side .tab-content").height($(window).height()-headerHeight-38);
  16. $('#partialBody').height($(window).height()-headerHeight-toolsBar - 60);
  17. let partialWidth = $('#tablePartial').width();
  18. $('#tablePartial').find('th:eq(0)').width(partialWidth * 0.06);
  19. $('#tablePartial').find('th:eq(1)').width(partialWidth * 0.3);
  20. $('#tablePartial').find('th:eq(2)').width(partialWidth * 0.64);
  21. $('#partialBody').find('tr').find('td:eq(0)').width(partialWidth * 0.06);
  22. $('#partialBody').find('tr').find('td:eq(1)').width(partialWidth * 0.3);
  23. $('#partialBody').find('tr').find('td:eq(2)').width(partialWidth * 0.64);
  24. //说明
  25. $('#explanationShow').height($(window).height()-headerHeight-toolsBar-100);
  26. //计算规则
  27. $('#ruleTextShow').height($(window).height()-headerHeight-toolsBar-100);
  28. typeof loadRationSubSize !== 'undefined' ? loadRationSubSize() : '';
  29. typeof loadZmhsAdjSize !== 'undefined' ? loadZmhsAdjSize() : '';
  30. typeof sectionTreeObj !== 'undefined' ? sectionTreeObj.loadRateWidth() : '';
  31. };
  32. $(window).resize(autoFlashHeight);
  33. /*全局自适应高度结束*/
  34. $(function(){
  35. /*侧滑*/
  36. $(".open-sidebar").click(function(){
  37. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  38. });
  39. $("body").click(function(event){
  40. var e = event || window.event; //浏览器兼容性
  41. if(!$(event.target).is('a')) {
  42. var elem = event.target || e.srcElement;
  43. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  44. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  45. return false;
  46. }
  47. elem = elem.parentNode;
  48. }
  49. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  50. }
  51. });
  52. /*侧滑*/
  53. /*工具提示*/
  54. $('*[data-toggle=tooltip]').mouseover(function() {
  55. $(this).tooltip('show');
  56. });
  57. /*工具提示*/
  58. });
  59. /**
  60. * 设置本地缓存
  61. *
  62. * @param {String} key
  63. * @param {String|Number} value
  64. * @return {void}
  65. */
  66. function setLocalCache(key, value) {
  67. const storage = window.localStorage;
  68. if (!storage || key === '' || value === '') {
  69. return;
  70. }
  71. storage.setItem(key, value);
  72. }
  73. /**
  74. * 获取本地缓存
  75. *
  76. * @param {String} key
  77. * @return {String}
  78. */
  79. function getLocalCache(key) {
  80. const storage = window.localStorage;
  81. if (!storage || key === '') {
  82. return null;
  83. }
  84. return storage.getItem(key);
  85. }
  86. function removeLocalCache(key) {
  87. const storage = window.localStorage;
  88. if (!storage || key === '') {
  89. return null;
  90. }
  91. return storage.removeItem(key);
  92. }