<template>
  <div class="overlay" v-if="props.modelValue"></div>
  <el-card v-if="props.modelValue" class="pop-card">
    <template #header>
      <div class="flex justify-between items-center pop-head">
        <span class="pop-head-name">共享相机</span>
        <el-icon :size="16" class="mr-3" @click="updateValue(false)"><Close /></el-icon>
      </div>
    </template>
    <div class="pop-content">
      <ShareCameraDetail :form-data="props.shareData" />
    </div>
  </el-card>
</template>

<script setup lang="ts">
  import { ref } from 'vue';
  import { cameraAddType } from '@/types/camera/constant';
  import { Close } from '@element-plus/icons-vue';
  import ShareCameraDetail from './ShareCameraDetail.vue';
  import { CameraDetailServer } from '@/types/camera/type';

  const props = defineProps<{ modelValue: boolean; shareData?: CameraDetailServer | null }>();

  const emits = defineEmits(['update:modelValue']);

  const addType = ref(cameraAddType[0].value);

  const updateValue = (value) => {
    addType.value = cameraAddType[0].value;
    emits('update:modelValue', value);
  };
</script>

<style scoped lang="scss">
  .overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }
  .pop-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
  }

  .pop-head {
    height: 56px;

    &-name {
      margin-left: 24px;
      font-size: 16px;
      font-weight: 500;
      color: #252525;
    }

    &-tabs {
      margin-top: 18px;

      :first-child {
        border-radius: 8px 0px 0px 0px;
      }

      :last-child {
        border-radius: 0px 8px 0px 0px;
      }
    }
  }

  .tab-item {
    width: 188px;
    height: 38px;
    background: #fafafa;
    border: 1px solid #d9d9d9;
    cursor: pointer;

    &-active {
      background: #e2eefe;
      border: 1px solid #1890ff;
    }
  }

  .pop-content {
    height: 480px;
    display: flex;
    justify-content: center;
    padding: 35px;
    overflow: auto;
  }

  :deep(.el-card__header) {
    padding: 0;
  }
  :deep(.el-card__body) {
    padding: 0;
  }
</style>
