<template>
  <!-- 可折叠面板标题 -->
  <keep-alive>
      <div class="collapseTitle-box">
        <!-- 头部标题 -->
        <div class="collapseTitle-header" :style="collapseTitleMargin">
          <div class="collapseTitle-flex-spaceB" style="width:100%">
            <div>
              <div :class="{ 'collapseTitle-bar': isActive }"></div>
              <div :ref="title" class="collapseTitle-name" :class="{ collapseTitleColor: color }">{{title}}
                <slot name="titleName"></slot>
              </div>
            </div>
            <div class="collapseTitle-flex-button">
              <slot name="button"></slot>
              <btn-batch-download :size="'medium'" type="primary" v-if="isfileDown" :fileID="fileID" :classType="classType" :downloadButtonMsg="downloadButtonMsg" :class="{ collapseTitleBottom: bottom }"></btn-batch-download>
              <i v-if="isCollapse" class="iconfont iconycxiala icon-select" :class="{ iconOperation: visible }" @click.stop="toggle"></i>
           </div>
          </div>
        </div>
        <!-- 折叠内容 -->
        <el-collapse-transition v-if="isCollapse">
          <div v-show="!visible">
            <slot name="transition"></slot>
          </div>
        </el-collapse-transition>
        <slot v-else name="unfolded"></slot>
      </div>
  </keep-alive>
</template>

<script>
import { btnBatchDownload } from 'newepoch-components'
export default {
  name: 'externalTransition',
  components: {
    btnBatchDownload
  },
  props: {
    // 标题
    title: {
      type: String,
      require: false,
      default () {
        return ''
      }
    },
    // 标题
    color: {
      type: Boolean,
      default () {
        return false
      }
    },
    // 标题
    bottom: {
      type: Boolean,
      default () {
        return false
      }
    },
    // 是否可下载
    isfileDown: {
      type: Boolean,
      default () {
        return false
      }
    },
    // 文件ID
    fileID: {
      type: Array,
      require: false,
      default () {
        return null
      }
    },
    // 是否缓存
    cache: {
      type: Boolean,
      default () {
        return false
      }
    },
    // 是否折叠
    isCollapse: {
      type: Boolean,
      default () {
        return false
      }
    },
    // 亮蓝色条是否显示
    isActive: {
      type: Boolean,
      default () {
        return true
      }
    },
    // 亮蓝色条是否显示
    downloadButtonMsg: {
      type: String,
      default () {
        return ''
      }
    },
    // 外边距数据
    collapseTitleMargin: {
      type: String,
      default () {
        return 'margin: 0 0 10px 0'
      }
    }
  },
  data () {
    return {
      classType: true, // 下载控件样式显示
      visible: false // 显隐控件
    }
  },
  computed: {
    // 自定义外边距
    collapseTitleMarginChange () {
      return {
        margin: this.collapseTitleMargin
      }
    }
  },
  methods: {
    // 下拉、收起操作
    toggle () {
      this.visible = !this.visible
    }
  }
}
</script>
<style lang="scss" scoped>
.collapseTitle-box {
  .collapseTitle-header {
    width: 100%;
    border-bottom: 2px solid #e0e8f5;
    padding: 0px 0px 10px 0px;
    position: relative;
    .collapseTitle-flex-spaceB {
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      .collapseTitle-bar{
        position: absolute;
        width: 70px;
        height: 2px;
        background: #1890ff;
        bottom: -2px;
        left: 0;
      }
      .collapseTitle-name{
        font-size:14px;color:#6e778f
      }
      .collapseTitleColor {
        color: rgba(229, 28, 35, 1)
      }
      .collapseTitle-flex-button {
        display: flex;
        align-items: flex-end;
        .collapseTitleBottom {
          margin-bottom: -10px
        }
        .iconOperation {
          transform: rotate(-90deg);
        }
        .icon-select{
          margin: 0 0 0 10px;
          color:#6e778f;font-size: 16px
        }
        .icon-select:hover {
          color:  #1890ff !important;
          transition: transform .3s;
        }
      }
    }
  }
}
</style>
