<template>
  <div class="analysis-box-wrapper" :style="{ width: width ? width : '100%', height: height ? height : '100%' }">
    <div class="wrapper-header">
      <div class="header-icon"></div>
      <div class="header-title">
        <div v-if="title">{{ title }}</div>
        <slot v-else name="custom-title"></slot>
      </div>
      <div class="header-btn" v-if="!showAllBtn">
        <slot name="header-btn"></slot>
      </div>
      <div class="header-btn1" v-else>
        <slot name="header-btn"></slot>
      </div>
      <div class="header-right">
        <div class="header-right-btn" @click="handleSave" v-if="showAllBtn">
          <img src="@/assets/icons/box-header-icon1.png" alt="">
        </div>
        <div class="header-right-btn" @click="handleDownload">
          <img src="@/assets/icons/box-header-icon2.png" alt="">
        </div>
        <div class="header-right-btn" @click="handleCollect">
          <img src="@/assets/icons/box-header-icon3.png" alt="">
        </div>
      </div>
    </div>
    <div class="wrapper-main">
      <slot></slot>
    </div>
  </div>
</template>

<script setup>
import { ElMessage } from 'element-plus'
import { ref, computed } from 'vue'

const props = defineProps({
  title: {
    type: String,
    default: ''
  },
  width: {
    type: String,
    default: ''
  },
  height: {
    type: String,
    default: ''
  },
  showAllBtn: {
    type: Boolean,
    default: true
  },
  // 当业务功能尚未实现时，点击右上角图标仅弹出统一提示
  devTip: {
    type: Boolean,
    default: false
  }
})

const handleSave = () => {
  if (props.devTip) {
    ElMessage.warning('当前功能正在开发中，敬请期待！')
    return
  }
  ElMessage.success('保存当前内容')
  // emit('save')
}

const handleDownload = () => {
  if (props.devTip) {
    ElMessage.warning('当前功能正在开发中，敬请期待！')
    return
  }
  ElMessage.success('下载当前内容')
  // emit('download')

}

const handleCollect = () => {
  if (props.devTip) {
    ElMessage.warning('当前功能正在开发中，敬请期待！')
    return
  }
  ElMessage.success('收藏当前内容')
  // emit('collect')

}

const emit = defineEmits(['save', 'download', 'collect'])

</script>

<style lang="scss" scoped>
.analysis-box-wrapper {
  border: 1px solid rgba(234, 236, 238, 1);
  border-radius: 10px;
  box-shadow: 0px 0px 20px 0px rgba(25, 69, 130, 0.1);
  background: rgba(255, 255, 255, 1);

  .wrapper-header {
    height: 45px;
    display: flex;
    padding-right: 14px;
    align-items: center;
    box-sizing: border-box;

    .header-icon {
      width: 8px;
      height: 20px;
      background: var(--color-main-active);
      border-radius: 0 4px 4px 0;
      margin-right: 14px;
    }
    
    .header-title {
      flex: auto;
      width: 20px;
      // color: var(--color-main-active);
      // font-family: Source Han Sans CN;
      // font-size: 20px;
      // font-weight: 700;
      // line-height: 26px;
      // letter-spacing: 0px;
      height: 100%;
      &>div {
        height: 100%;
        color: var(--color-main-active);
        font-family: Microsoft YaHei;
        font-size: 20px;
        line-height: 45px;
        font-weight: 700;
      }
    }

    .header-btn {
      // display: flex;
      // justify-content: flex-end;
      // gap: 8px;
      margin-right: 10px;
    }

    // .header-btn1 {
    //   position: absolute;
    //   top: 14px;
    //   right: 116px;
    // }

    .header-right {
      height: 28px;
      display: flex;
      justify-content: flex-end;
      gap: 4px;

      .header-right-btn {
        width: 28px;
        height: 28px;
        cursor: pointer;

        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }

  .wrapper-main {
    height: calc(100% - 45px);
    overflow: hidden;
    // overflow-y: auto;
    padding: 5px auto;
  }
}
</style>
