global.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. };
  31. $(window).resize(autoFlashHeight);
  32. /*全局自适应高度结束*/
  33. $(function(){
  34. /*侧滑*/
  35. $(".open-sidebar").click(function(){
  36. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  37. });
  38. $("body").click(function(event){
  39. var e = event || window.event; //浏览器兼容性
  40. if(!$(event.target).is('a')) {
  41. var elem = event.target || e.srcElement;
  42. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  43. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  44. return false;
  45. }
  46. elem = elem.parentNode;
  47. }
  48. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  49. }
  50. });
  51. /*侧滑*/
  52. /*工具提示*/
  53. $('*[data-toggle=tooltip]').mouseover(function() {
  54. $(this).tooltip('show');
  55. });
  56. /*工具提示*/
  57. });
  58. /**
  59. * 设置本地缓存
  60. *
  61. * @param {String} key
  62. * @param {String|Number} value
  63. * @return {void}
  64. */
  65. function setLocalCache(key, value) {
  66. const storage = window.localStorage;
  67. if (!storage || key === '' || value === '') {
  68. return;
  69. }
  70. storage.setItem(key, value);
  71. }
  72. /**
  73. * 获取本地缓存
  74. *
  75. * @param {String} key
  76. * @return {String}
  77. */
  78. function getLocalCache(key) {
  79. const storage = window.localStorage;
  80. if (!storage || key === '') {
  81. return null;
  82. }
  83. return storage.getItem(key);
  84. }
  85. function removeLocalCache(key) {
  86. const storage = window.localStorage;
  87. if (!storage || key === '') {
  88. return null;
  89. }
  90. return storage.removeItem(key);
  91. }