<template>
  <div class="layout">
    <div class="left" :style="{width: width + 'px'}">
      <DragBorder @widthChange="widthChange" @showoutWidth="showoutWidth" :width="width">
      </DragBorder>
      <slot name="left"></slot>
    </div>
    <div class="right" :style="{width:`calc(100% - ${width}px)`}">
      <slot name="right"></slot>
    </div>
  </div>
</template>

<script scoped>
import DragBorder from '@/Common/Components/DragBorder.vue'
export default {
  data() {
    return {
      width: '240'
    }
  },
  methods: {
    widthChange(movement) {
      this.width -= movement
      if (this.width < 200) {
        this.width = 200
      }
      if (this.width > 440) {
        this.width = 440
      }
    },
    showoutWidth(res) {
      if (this.width > 0) {
        this.width = res
      } else {
        this.width = 240
      }
    }
  },
  components: {
    DragBorder
  }
}
</script>

<style>
.left {
  position: relative;
  /* padding-right: 10px; */
  width: 200px;
  height: 100%;
  box-sizing: border-box;
  background-color: #fff;
  padding-top: 10px;
  /* overflow: hidden; */
}
.layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  height: 100%;
  box-sizing: border-box;
}
.right {
  flex: 1;
  height: 100%;
  background-color: #fff;
  overflow: hidden;
}
</style>