<template>
  <Dialog :show="tempData.show"
          :vue-name="dialogConfig.vueName"
          :height="dialogConfig.height"
          :width="dialogConfig.width"
          :resize="true"
          :header="dialogConfig.header"
          :dialog-type="dialogConfig.type"
          :position="dialogConfig.position">
    <template slot="default">
      <CarInfo :car-data="tempData.infoData.carData" ref="CarInfoTemp"></CarInfo>
    </template>
  </Dialog>
</template>

<script lang="ts">
import {Component, Vue, Watch} from 'vue-property-decorator'
import Dialog from '@/components/dialog/index.vue'
import CarInfo from '@/views/on-map-view/CarInfo.vue'

@Component({
  components: {
    Dialog,
    CarInfo
  },
  props: {
    tempData: {
      type: Object,
      required: true,
      default: () => {
        return {}
      }
    }
  }
})
export default class ShipInfoTemp extends Vue {
  private dialogConfig = {
    width: '500px',
    height: '31.25rem',
    header: {
      title: '船舶历史轨迹',
      hasAfterIcon: true,
      hasIcon: false,
      iconSrc: '',
      hasMin: true,
      hasMax: false
    },
    position: {
      top: '9.375rem',
      left: '16.25rem'
    },
    vueName: ''
  }

  @Watch('tempData', {
    deep: true,
    immediate: true
  })
  dataChange(data: any) {
    console.log(data)
    const dialogData = data.dialogData
    this.dialogConfig.header.title = dialogData.title
    this.dialogConfig.vueName = dialogData.vueName
  }

  public mounted() {
    const width = window.screen.width
    if (width <= 1280) {
      this.dialogConfig.position.top = '10px'
    }
  }
}
</script>

<style scoped lang="scss">
</style>
