<template>
  <div style="width: 100%;">
    <div v-if="type === 'normal'" class="info-title">
      <div class="left">
        <svg-icon icon-class="infoTitle" style="width: 18px; height: 18px; margin-right: 5px;" />

        <div class="name">
          <slot />
        </div>
      </div>
      <div class="right">
        <slot name="right" />
      </div>
    </div>
    <div v-if="type === 'collapse'" class="info-title-collapse">
      <el-collapse v-model="activeName">
        <el-collapse-item name="1">
          <template slot="title">
            <div class="title-box">
              <svg-icon icon-class="infoTitle" style="width: 18px; height: 18px; margin-right: 5px;" />
              <div class="name">
                {{ name }}
              </div>
            </div>
          </template>
          <slot />
        </el-collapse-item>
      </el-collapse>
    </div>
    <div
      v-if="type === 'center' || type === 'left'"
      :class="{
        'info-title-center': type === 'center',
        'info-title-left': type === 'left'
      }"
    >
      <div>
        <slot />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    type: {
      type: String,
      default: 'normal' // collapse 折叠  center 居中
    },
    name: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      activeName: ['1']
    }
  }
}

</script>

<style lang="scss" scoped>
.info-title {
  padding-left: 5px;
  background-color: #F5F6F6;
  font-size: 14px;
  color: #333;
  min-height: 35px;
  line-height: 35px;
  width: 100%;
  position: relative;
  display: flex;
  justify-content: space-between;
  .left {
    display: flex;
    align-items: center;
    .name {
      font-size: 16px;
      font-weight: 700;
      margin-top: 2px;
    }
  }
  .right {
    margin-right: 10px;
  }
}

.info-title-collapse {
  .title-box {
    display: flex;
    align-items: center;
    margin-left: 5px;
    .name {
      font-size: 16px;
      font-weight: 700;
      margin-top: 2px;
    }
  }
}

.info-title-center {
  height: 37px;
  width: 100%;
  font-size: 16px;
  color: #222931;
  line-height: 37px;
  text-align: center;
  font-weight: 600;
  margin-top: 10px;
}
.info-title-left {
  height: 37px;
  width: 100%;
  font-size: 16px;
  color: #222931;
  line-height: 37px;
  text-align: left;
  font-weight: 600;
  margin-top: 10px;
}

</style>

<style lang="scss">
.info-title-collapse {
  border: 0px;
  .el-collapse-item__header {
    height: 37px;
    border: 0px;
    background-color: #F5F6F6;
    padding-bottom: 0px;
  }
  .el-collapse-item__arrow {
    color: #FE7D0B;
    font-weight: 700;
    font-size: 18px;
  }
  .el-collapse-item__wrap {
    background-color: #fff;
    border: 0px;
  }
  .el-collapse-item__content {
    padding-bottom: 0px;
  }

}

</style>
