<template>
  <div class="right-wrapper">
    <div class="base-panel-right" :class="{ hide: isHide }">
      <slot></slot>
      <div class="rightbtn" @click="toggleRightPanel"></div>
      <div class="right-background" :class="{ rightHide: isHide }"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BasePanelRight',
 props:{
    isHidePanel:{
      type:Boolean,
      default:false
    }
  },
  data() {
    return {
      isHide: false
    }
  },
  mounted(){
    this.$globalEventBus.$on('hideRightPanel',(val)=>{
      this.isHide = val
      this.$globalEventBus.$emit('toggleRightPanel', this.isHide)
    })
  },
  watch:{
    isHidePanel(val){
      this.isHide = val
    }
  },
  methods: {
    toggleRightPanel() {
      console.log('切换右侧面板')
      this.isHide = !this.isHide
      this.$globalEventBus.$emit('toggleRightPanel', this.isHide)
    }
  }
}
</script>

<style lang="scss" scoped>
.right-wrapper {
  .base-panel-right {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 3.94rem;
    padding-top: 0.46rem;
    padding-right: 0.18rem;
    transition: all 0.3s ease-in-out;
    pointer-events: auto;
    z-index: 40;
    .rightbtn {
      display: block;
      width: 0.7rem;
      height: 100%;
      text-align: center;
      font-size: 0.2rem;
      left: -0.7rem;
      position: absolute;
      top: 0;
      pointer-events: none;
      z-index: 1;
      background: url('@/assets/image/common/right_hide.png') no-repeat left center / 100% 100%;
      &::after {
        content: '';
        position: absolute;
        left: 0.1rem;
        top: 45%;
        width: 0.3rem;
        height: 2.4rem;
        pointer-events: auto;
        cursor: pointer;
      }
    }
    .right-background {
      position: absolute;
      transition: all 0.3s ease-in-out;
      pointer-events: none;
      width: 6.5rem;
      height: 100%;
      top: 0;
      right: 0;
      background: url('@/assets/image/common/dataCenterRightBg.png') no-repeat 0 0 / 100%;
    }
    .rightHide {
      right: -0.32rem;
    }
  }
  .hide {
    transform: translateX(3.94rem);
    padding-right: 0;
    .rightbtn {
      right: -1.08rem;
      background: url('@/assets/image/common/right_show.png') no-repeat left center / 100% 100%;
    }
    div {
      overflow: hidden;
    }
  }
}
</style>
