base-panel-right.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. this.$globalEventBus.$emit('toggleRightPanel', this.isHide)
  28. })
  29. },
  30. watch:{
  31. isHidePanel(val){
  32. this.isHide = val
  33. }
  34. },
  35. methods: {
  36. toggleRightPanel() {
  37. console.log('切换右侧面板')
  38. this.isHide = !this.isHide
  39. this.$globalEventBus.$emit('toggleRightPanel', this.isHide)
  40. }
  41. }
  42. }
  43. </script>
  44. <style lang="scss" scoped>
  45. .right-wrapper {
  46. .base-panel-right {
  47. position: absolute;
  48. top: 0;
  49. right: 0;
  50. height: 100%;
  51. width: 3.94rem;
  52. padding-top: 0.46rem;
  53. padding-right: 0.18rem;
  54. transition: all 0.3s ease-in-out;
  55. pointer-events: auto;
  56. z-index: 40;
  57. .rightbtn {
  58. display: block;
  59. width: 0.7rem;
  60. height: 100%;
  61. text-align: center;
  62. font-size: 0.2rem;
  63. left: -0.7rem;
  64. position: absolute;
  65. top: 0;
  66. pointer-events: none;
  67. z-index: 1;
  68. background: url('@/assets/image/common/right_hide.png') no-repeat left center / 100% 100%;
  69. &::after {
  70. content: '';
  71. position: absolute;
  72. left: 0.1rem;
  73. top: 45%;
  74. width: 0.3rem;
  75. height: 2.4rem;
  76. pointer-events: auto;
  77. cursor: pointer;
  78. }
  79. }
  80. .right-background {
  81. position: absolute;
  82. transition: all 0.3s ease-in-out;
  83. pointer-events: none;
  84. width: 6.5rem;
  85. height: 100%;
  86. top: 0;
  87. right: 0;
  88. background: url('@/assets/image/common/dataCenterRightBg.png') no-repeat 0 0 / 100%;
  89. }
  90. .rightHide {
  91. right: -0.32rem;
  92. }
  93. }
  94. .hide {
  95. transform: translateX(3.94rem);
  96. padding-right: 0;
  97. .rightbtn {
  98. right: -1.08rem;
  99. background: url('@/assets/image/common/right_show.png') no-repeat left center / 100% 100%;
  100. }
  101. div {
  102. overflow: hidden;
  103. }
  104. }
  105. }
  106. </style>