base-panel-right.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="right-wrapper">
  3. <div class="base-panel-right" :class="{ hide: isHide }">
  4. <slot></slot>
  5. <div class="rightbtn" @click="toggleRightPanel"></div>
  6. <div class="right-background" :class="{ rightHide: isHide }"></div>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. name: 'BasePanelRight',
  13. props:{
  14. isHidePanel:{
  15. type:Boolean,
  16. default:false
  17. }
  18. },
  19. data() {
  20. return {
  21. isHide: false
  22. }
  23. },
  24. mounted(){
  25. this.$globalEventBus.$on('hideRightPanel',(val)=>{
  26. this.isHide = val
  27. })
  28. },
  29. watch:{
  30. isHidePanel(val){
  31. this.isHide = val
  32. }
  33. },
  34. methods: {
  35. toggleRightPanel() {
  36. console.log('切换右侧面板')
  37. this.isHide = !this.isHide
  38. this.$globalEventBus.$emit('toggleRightPanel', this.isHide)
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="scss" scoped>
  44. .right-wrapper {
  45. .base-panel-right {
  46. position: absolute;
  47. top: 0;
  48. right: 0;
  49. height: 100%;
  50. width: 3.94rem;
  51. padding-top: 0.46rem;
  52. padding-right: 0.18rem;
  53. transition: all 0.3s ease-in-out;
  54. pointer-events: auto;
  55. z-index: 40;
  56. .rightbtn {
  57. display: block;
  58. width: 0.7rem;
  59. height: 100%;
  60. text-align: center;
  61. font-size: 0.2rem;
  62. left: -0.7rem;
  63. position: absolute;
  64. top: 0;
  65. pointer-events: none;
  66. z-index: 1;
  67. background: url('@/assets/image/common/right_hide.png') no-repeat left center / 100% 100%;
  68. &::after {
  69. content: '';
  70. position: absolute;
  71. left: 0.1rem;
  72. top: 45%;
  73. width: 0.3rem;
  74. height: 2.4rem;
  75. pointer-events: auto;
  76. cursor: pointer;
  77. }
  78. }
  79. .right-background {
  80. position: absolute;
  81. transition: all 0.3s ease-in-out;
  82. pointer-events: none;
  83. width: 6.5rem;
  84. height: 100%;
  85. top: 0;
  86. right: 0;
  87. background: url('@/assets/image/common/dataCenterRightBg.png') no-repeat 0 0 / 100%;
  88. }
  89. .rightHide {
  90. right: -0.32rem;
  91. }
  92. }
  93. .hide {
  94. transform: translateX(3.94rem);
  95. padding-right: 0;
  96. .rightbtn {
  97. right: -1.08rem;
  98. background: url('@/assets/image/common/right_show.png') no-repeat left center / 100% 100%;
  99. }
  100. div {
  101. overflow: hidden;
  102. }
  103. }
  104. }
  105. </style>