global.js 3.6 KB

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