<template>
  <div class="modal">
    <div class="title">
      <div class="title-1">{{ props.nowPreviewRecord.name }}</div>
      <div class="title-2">
        {{
          props.nowPreviewRecord.createtime +
          ' ' +
          props.nowPreviewRecord.size +
          ' ' +
          props.nowPreviewRecord.id
        }}
      </div>
    </div>
    <div class="closeButton">
      <CloseOutlined @click="closeModal" style="font-size: 25px; color: white" />
    </div>
    <div class="mainBody">
      <div class="imgOrVideo">
        <!-- 图片 -->
        <div class="imageDiv" v-if="props.nowPreviewRecord.type == 'img'">
          <PreviewImage
            :nowPreviewRecord="props.nowPreviewRecord"
            :previewRecordList="props.previewRecordList"
            @chooseNowPreviewRecord="chooseNowPreviewRecord"
            @reloadTable="reloadTable"
            @setHideOrShowTextboxFlag="setHideOrShowTextboxFlag"
          />
        </div>
        <!-- VR全景 -->
        <!-- <div v-if="props.nowPreviewRecord.type == 'vr'">
          <PanoViewer />
        </div> -->
        <!-- 视频 -->
        <div class="videoDiv" v-if="props.nowPreviewRecord.type == 'video'">
          <PreviewVideo
            :nowPreviewRecord="props.nowPreviewRecord"
            :previewRecordList="props.previewRecordList"
            @chooseNowPreviewRecord="chooseNowPreviewRecord"
            @reloadTable="reloadTable"
          />
        </div>
      </div>
      <div class="information">
        <PreviewImageInformation
          v-if="props.nowPreviewRecord.type == 'img'"
          :nowPreviewRecord="props.nowPreviewRecord"
          :previewRecordList="props.previewRecordList"
          @chooseNowPreviewRecord="chooseNowPreviewRecord"
          @reloadTable="reloadTable"
          :hideOrShowTextboxFlag="hideOrShowTextboxFlag"
        />
        <PreviewVideoInformation
          v-if="props.nowPreviewRecord.type == 'video'"
          :nowPreviewRecord="props.nowPreviewRecord"
          :previewRecordList="props.previewRecordList"
          @chooseNowPreviewRecord="chooseNowPreviewRecord"
          @reloadTable="reloadTable"
        />
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
  import { ref } from 'vue';
  import { CloseOutlined } from '@ant-design/icons-vue';
  import {
    PreviewImage,
    PreviewImageInformation,
    PreviewVideo,
    PreviewVideoInformation,
    PanoViewer,
  } from './preview';

  const props = defineProps(['nowPreviewRecord', 'previewRecordList']);
  const emit = defineEmits(['closeModal', 'chooseNowPreviewRecord', 'reloadTable']);

  console.log(props.previewRecordList);

  const hideOrShowTextboxFlag = ref(true);
  function setHideOrShowTextboxFlag(value) {
    hideOrShowTextboxFlag.value = value;
  }

  // 选择
  function chooseNowPreviewRecord(value) {
    emit('chooseNowPreviewRecord', value);
  }
  // 刷新表格
  function reloadTable() {
    emit('reloadTable');
  }
  // 关闭弹窗
  function closeModal() {
    document.body.style.cursor = 'default';
    emit('closeModal');
  }
</script>
<style lang="less" scoped>
  .modal {
    width: 100%;
    height: 920px;

    // 页面不能被选中
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    user-select: none;
  }
  .title {
    pointer-events: none;
    position: absolute;
    top: 10px;
    left: 15px;
    z-index: 100;

    .title-1 {
      font-size: 20px;
      color: #ffffff;
    }
    .title-2 {
      font-size: 16px;
      color: #f0f3f3;
    }
  }
  .closeButton {
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 50;
  }
  .mainBody {
    width: 100%;
    height: 920px;
    display: flex;
    position: absolute;
    top: 0px;
    left: 0px;

    .imgOrVideo {
      width: 80%;
      height: 920px;
      background: #101010;

      .imageDiv {
        // display: flex;
        // align-items: center;
        position: relative;
        justify-content: center;
        width: 100%;
        height: 100%;
      }

      .videoDiv {
        position: relative;
        justify-content: center;
        width: 100%;
        height: 100%;
      }
    }

    .information {
      position: relative;
      width: 20%;
      height: 100%;
      background: #1c1c1c;
    }
  }
</style>
