global.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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-29);
  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. $('body').on("show.bs.modal", ".modal", function(){
  37. if (typeof $(this).find('.modal-content').draggable === 'function') {
  38. $(this).find('.modal-content').draggable({handle: '.modal-header', cancel: 'a, button'});
  39. }
  40. });
  41. /*侧滑*/
  42. $(".open-sidebar").click(function(){
  43. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  44. });
  45. $("body").click(function(event){
  46. var e = event || window.event; //浏览器兼容性
  47. if(!$(event.target).is('a')) {
  48. var elem = event.target || e.srcElement;
  49. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  50. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  51. return false;
  52. }
  53. elem = elem.parentNode;
  54. }
  55. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  56. }
  57. });
  58. /*侧滑*/
  59. /*工具提示*/
  60. $('*[data-toggle=tooltip]').mouseover(function() {
  61. $(this).tooltip('show');
  62. });
  63. /*工具提示*/
  64. });
  65. /**
  66. * 设置本地缓存
  67. *
  68. * @param {String} key
  69. * @param {String|Number} value
  70. * @return {void}
  71. */
  72. function setLocalCache(key, value) {
  73. const storage = window.localStorage;
  74. if (!storage || key === '' || value === '') {
  75. return;
  76. }
  77. try {
  78. storage.setItem(key, value);
  79. } catch (err) {
  80. storage.clear();
  81. storage.setItem(key, value);
  82. }
  83. }
  84. /**
  85. * 获取本地缓存
  86. *
  87. * @param {String} key
  88. * @return {String}
  89. */
  90. function getLocalCache(key) {
  91. const storage = window.localStorage;
  92. if (!storage || key === '') {
  93. return null;
  94. }
  95. return storage.getItem(key);
  96. }
  97. function removeLocalCache(key) {
  98. const storage = window.localStorage;
  99. if (!storage || key === '') {
  100. return null;
  101. }
  102. return storage.removeItem(key);
  103. }