<!-- 自定义封装弹层 -->
<template>
  <el-dialog
    :custom-class="`super-dialog ${customClass}`"
    v-on="$listeners"
    v-bind="$attrs"
    :visible.sync="dialogVisible"
    :show-close="false"
    close-on-click-modal
    :top="top"
    append-to-body
    :close-on-press-escape="false"
  >
    <!-- 关闭图标 -->
    <i
      class="el-icon-close close-icon"
      @click="dialogVisible = false"
    />
    <!-- 自定义头部内容 -->
    <div class="super-dialog-title">
      <div class="title-left">
        <span class="title">
          {{ title }}
        </span>
        <el-tooltip
          v-if="hintLanguage"
          class="prompt"
          effect="dark"
          :content="hintLanguage"
          placement="bottom-start"
          popper-class="prompt-popper"
        >
          <img src="@/assets/img/components/superDialog/question-circle.png" alt="" />
        </el-tooltip>

      </div>
      <div class="title-end">
        <slot name="title-end"></slot>
      </div>
    </div>
    <!-- 内容默认插槽 -->
    <div class="super-dialog-content">
      <slot></slot>
    </div>
    <!-- 尾部按钮插槽 -->
    <template v-slot:footer>
      <slot name="footer"></slot>
    </template>
  </el-dialog>
</template>

<script>
export default {
  name: 'SuperDialog',
  model: {
    prop: 'showDialog',
    event: 'changeDialog'
  },
  props: {
    showDialog: {
      default: false,
      type: Boolean
    },
    title: {
      default: '标题',
      type: String
    },
    // 距离页面顶部高度
    top: {
      default: '20vh',
      type: String
    },
    // 自定义class
    customClass: {
      default: '',
      type: String
    },
    // 提示语
    hintLanguage: {
      default: '',
      type: String
    }
  },
  computed: {
    dialogVisible: {
      get() {
        return this.showDialog
      },
      set(val) {
        this.$emit('changeDialog', val)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import "~@/assets/css/element-variables";

::v-deep .super-dialog {
  box-sizing: border-box;
  background-color: $--system-background-color;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(lighten($--color-black, 5%), 0.4);

  .super-dialog-title {
    width: 100%;
    height: 44px;
    display: flex;
    justify-content: space-between;
    background: url("~@/assets/img/publicLayout/header-bg.png") no-repeat 50% 50%, linear-gradient(180deg, $--system-module-color1 0%, $--system-module-color1 100%);
    background-size: 100% 100%;
    color: $--color-white;
    padding: 0 20px;
    box-sizing: border-box;
    user-select: none;

    > * {
      height: 100%;
    }

    .title-left {
      display: flex;
      align-items: center;

      .title {
        width: 100%;
        font-size: 17px;
        font-weight: bold;

      }

      .prompt {
        width: 19px;
        height: 19.5px;
        margin: 0 8px;
        cursor: pointer;
      }

    }

    .title-end {
      display: flex;
      align-items: center;
    }
  }

  .super-dialog-content {
    box-sizing: border-box;
    padding: 20px;
  }

  .el-dialog__header {
    width: 0;
    height: 0;
    padding: 0;
  }

  .el-dialog__body {
    padding: 0;
  }

  .el-dialog__footer {
    padding-top: 0;
  }

  .close-icon {
    position: absolute;
    top: 14px;
    right: 16px;
    color: $--color-white;
    cursor: pointer;
    transition: color 0.15s;

    &::before {
      font-size: 18px !important;
    }

    &:hover {
      color: $--system-hover-active-text;
    }
  }
}
</style>

<style lang="scss">
.prompt-popper {
  font-size: 13.5px !important;
}
</style>
