<template>
  <!-- <base-dialog
    v-if="showDialog"
    v-model="visible"
    less
    title="试卷预览"
    :can-resize="resizeKey ? resizeKey : 'can-resize2'"
    :modal="false"
    class="preview-dialog"
    modal-class="no-mask preview-clear-mask"
  >
    <div class="preview-content" :class="{ 'is-big': isBig }">
      <img v-show="!!url" class="small-img" :src="url" alt="" />
    </div>
  </base-dialog> -->
  <div
    v-if="visible"
    v-customDialogResizeImg="resizeKey ? resizeKey : 'can-resize2'"
    class="preview-custom-dialog"
    :class="[resizeKey ? resizeKey : 'can-resize2']"
  >
    <div class="preview-head">
      <span>试卷预览</span>
      <div class="head-btn-box flex justify-center items-center" @click="closeDialog">
        <el-icon><close /></el-icon>
      </div>
    </div>
    <div class="preview-body">
      <img v-show="!!url" class="small-img" :src="url" alt="" />
    </div>
    <!-- <div class="preview-foot"></div> -->
  </div>
</template>

<script setup lang="ts" name="ImagePreview">
// import BaseDialog from '../element/BaseDialog.vue'
import useVModel from '@/hooks/useVModel'
import { ref, watch } from 'vue'
import { Close } from '@element-plus/icons-vue'
import { ElIcon } from 'element-plus'

const showDialog = ref(true)

const props = defineProps<{
  modelValue: boolean
  url?: string
  isBig?: boolean
  resizeKey?: string
}>()
const visible = useVModel(props)
const closeDialog = () => {
  visible.value = false
}
watch(
  () => props.url,
  () => {
    showDialog.value = false
    setTimeout(() => {
      showDialog.value = true
    }, 1)
  }
)
</script>

<style scoped lang="scss">
.preview-custom-dialog {
  display: flex;
  flex-direction: column;
  position: fixed;
  z-index: 500;
  border-radius: 6px;
  box-shadow: 0px 12px 32px 4px rgba(0, 0, 0, 0.04), 0px 8px 20px rgba(0, 0, 0, 0.08);
  .preview-head {
    background-color: #f8f8f8;
    border-radius: 6px 6px 0 0;
    color: #333;
    font-size: 14px;
    height: 44px;
    line-height: 44px;
    padding: 0 10px;
    position: relative;
    .head-btn-box {
      position: absolute;
      right: 0;
      top: 0;
      width: 44px;
      height: 44px;
      z-index: 1;
      cursor: pointer;
      &:hover {
        :deep(i) {
          color: $color--primary;
        }
      }
    }
  }
  .preview-body {
    flex: 1;
    padding: 2px;
    overflow: auto;
    img {
      width: 100%;
      height: auto;
    }
  }
}
</style>
