<template>
  <div>
    <div class="container">
      <div class="title">
        <div class="redcolumn"></div>
        <div class="container-title">{{ title }}</div>
      </div>
      <div v-if="showBtn" class="container-foot" @click="open">
        <div v-show="show" style="height: 20px">
          <span><i class="el-icon-arrow-up" :style="styleIocup"/></span>
        </div>
        <div v-show="!show" style="height: 20px">
          <span><i class="el-icon-arrow-down"/></span>
        </div>
      </div>
    </div>
    <div
      class="basic-container"
      :style="styleName"
      :class="{ 'basic-container--block': block }"
    >
      <el-card class="basic-container__card" style="padding: 0;">
        <el-collapse-transition>
          <div v-show="show">
            <slot></slot>
          </div>
        </el-collapse-transition>
      </el-card>
    </div>
  </div>
</template>

<script>
export default {
  name: 'basicContainer',
  data() {
    return {};
  },
  props: {
    radius: {
      type: [String, Number],
      default: 10
    },
    background: {
      type: String
    },
    block: {
      type: Boolean,
      default: false
    },
    showBtn: {
      type: Boolean,
      default: true
    },
    title: {
      type: String
    },
    show: {
      type: Boolean,
      default: true
    },
    styleIocup: {
      type: String,
      default: ''
    }
  },
  methods: {
    open() {
      this.show = !this.show;
      this.$emit('openClose', this.show);
    }
  },
  computed: {
    styleName() {
      return {
        borderRadius: this.setPx(this.radius),
        background: this.background
      };
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  display: flex;
  justify-content: space-between;
  margin-left: 10px;
  margin-right: 10px;
  background-color: inherit;
  height: 18px;
  // padding-bottom: 12px;
  vertical-align: middle;

  .title {
    display: flex;

    .redcolumn {
      width: 4px;
      height: 13px;
      background-color: #d6000f;
      margin: 3px 4px 0 0;
    }

    .container-title {
      font-size: 12px;
      line-height: 20px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #323233;
    }
  }

  .container-foot {
    font-size: 16px;
    font-weight: 1000;
  }
}

.basic-container {
  padding: 5px 6px;
  box-sizing: border-box;

  &--block {
    height: 100%;

    .basic-container__card {
      height: 100%;
    }
  }

  ::v-deep .el-card .el-card__body {
    padding: 5px !important;
  }
  &__card {
    width: 100%;
  }

  &:first-child {
    padding-top: 6px;
  }
}
</style>
