<template>
  <div v-if="visible" v-dialogResizeStandard="'can-resize3'" class="standard-dialog can-resize3">
    <div class="standard-head">
      <span>评分标准</span>
      <div class="head-btn-box flex justify-center items-center" @click="closeDialog">
        <el-icon><close /></el-icon>
      </div>
    </div>
    <div class="standard-body">
      <div id="my-iframe-mask"></div>
      <iframe v-if="iframeSrc" style="width: 100%; height: 100%; prevent-events: pointer" :src="iframeSrc"></iframe>
    </div>
  </div>
</template>

<script setup lang="ts" name="StandardDialog">
import useVModel from '@/hooks/useVModel'
import { ref, computed } from 'vue'
import { Close } from '@element-plus/icons-vue'
import { ElIcon } from 'element-plus'
import useFetch from '@/hooks/useFetch'

const props = defineProps<{
  modelValue: boolean
  resizeKey?: string
}>()
const visible = useVModel(props)
const closeDialog = () => {
  visible.value = false
}

const { fetch: fetchStandard, result: standardRes } = useFetch('getMarkingStandard')
fetchStandard()
const iframeSrc = computed(() => {
  return standardRes.value?.url
    ? standardRes.value?.url + '#view=FitH&scrollbar=0&toolbar=0&statusbar=0&messages=0&navpanes=0'
    : ''
})
</script>
//
<style scoped lang="scss">
.standard-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);
  .standard-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;
        }
      }
    }
  }
  .standard-body {
    flex: 1;
    padding: 2px;
    position: relative;
    #my-iframe-mask {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      top: 0;
      z-index: 10;
      display: none;
    }
  }
}
</style>
