<script>
import AiTitle from "../basic/AiTitle.vue";

export default {
  name: "AiPage",
  components: {AiTitle},
  props: {
    contentString: {default: "card"},
    showBack: Boolean
  }
}
</script>

<template>
  <section class="AiPage">
    <slot v-if="$slots.title" name="title"/>
    <ai-title v-else-if="$attrs.title" :title="$attrs.title" isShowBottomBorder :isShowBack="showBack" @onBackClick="$router.push({})"/>
    <div class="fill main">
      <div v-if="$slots.left" class="left">
        <slot name="left"/>
      </div>
      <el-scrollbar class="fill" :class="[contentString,$slots.footer?'hasFooter':'']">
        <slot/>
      </el-scrollbar>
    </div>
    <div class="footer" v-if="$slots.footer">
      <slot name="footer"/>
    </div>
  </section>
</template>

<style scoped lang="scss">
.AiPage {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0 20px;
  overflow: hidden;
  background: #f3f6f9;
  position: relative;

  .main {
    display: flex;
    padding: 20px 0;
    gap: 10px;
    overflow: hidden;
    height: 100%;


    :deep(.el-scrollbar__wrap) {
      overflow-x: hidden;
      overflow-y: auto;
      padding-right: 16px;
    }

    & > .fill {
      &.card {
        padding: 12px 16px 12px;
        background: #FFFFFF;
        border-radius: 2px;
        box-shadow: 0 4px 6px -2px rgba(15, 15, 21, 0.15);
      }

      &.detail {
        margin-left: 50%;
        transform: translateX(-50%);
        max-width: 1200px;
        overflow-y: auto;

      }

      &.blank {
        width: 100%;
        overflow-y: auto;
      }

      &.hasFooter {
        padding-bottom: 64px;
      }
    }


  }

  .footer {
    position: absolute;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    left: 0;
    right: 0;
    height: 64px;
    background: #F5F5F5;
    box-shadow: 0 1px 0 0 #E5E5E5;

    .el-button {
      width: 92px;
    }
  }

  .left {
    max-width: 50%;
    width: auto;
  }
}
</style>
