<template>
  <div
    class="basic-container"
    :style="styleName"
    :class="{ 'basic-container--block': block }"
  >
    <el-card class="basic-container__card">
      <div v-show="show">
        <slot></slot>
      </div>
      <div v-if="showBtn" class="basic-container-foot" @click="show = !show" @mouseenter="enter" @mouseleave="leave">
        <div v-show="show">
          <i class="el-icon-caret-top" /><span v-show="showSpan">隐藏</span>
        </div>
        <div v-show="!show">
          <i class="el-icon-caret-bottom" /><span v-show="showSpan">显示</span>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "basicContainer",
  data() {
    return {
      show: true,
      showSpan: false
    };
  },
  props: {
    radius: {
      type: [String, Number],
      default: 10
    },
    background: {
      type: String
    },
    block: {
      type: Boolean,
      default: false
    },
    showBtn: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    enter() {
      this.showSpan = true;
    },
    leave() {
      this.showSpan = false;
    }
  },
  computed: {
    styleName() {
      return {
        borderRadius: this.setPx(this.radius),
        background: this.background
      };
    }
  }
};
</script>

<style lang="scss">
.basic-container {
  padding: 5px 6px;
  box-sizing: border-box;
  &--block {
    height: 100%;
    .basic-container__card {
      height: 100%;
    }
  }
  &__card {
    width: 100%;
  }
  &:first-child {
    padding-top: 6px;
  }
  &-foot {
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #d3dce6;
    span {
      margin-left: 4px;
      font-size: 14px;
    }
  }
  &-foot:hover {
    color: #409eff;
  }
}
</style>
