<template>
  <Dialog :show="tempData.show"
          :vue-name="dialogConfig.vueName"
          :height="dialogConfig.height"
          :resize="true"
          :width="dialogConfig.width"
          :header="dialogConfig.header"
          :dialog-type="dialogConfig.type"
          :position="dialogConfig.position">
    <template slot="default">
      <PortOfCall :ship-data="tempData.infoData.shipData" ref="PortOfCallTemp"></PortOfCall>
    </template>
  </Dialog>
</template>
<script lang="ts">
import {Component, Vue, Watch} from 'vue-property-decorator'
import Dialog from '@/components/dialog/index.vue'
import PortOfCall from '@/views/on-map-view/PortOfCall.vue'

@Component({
  components: {
    Dialog,
    PortOfCall
  },
  props: {
    tempData: {
      type: Object,
      required: true,
      default: () => {
        return {}
      }
    }
  }
})
export default class PortOfCallTemp extends Vue {
  private dialogConfig = {
    width: '39.375rem',
    height: '25rem',
    header: {
      title: '',
      hasIcon: false,
      iconSrc: '',
      hasMin: true,
      hasMax: false
    },
    position: {
      top: '16.875rem',
      left: '48.125rem'
    },
    vueName: ''
  }

  @Watch('tempData', {
    deep: true,
    immediate: true
  })
  dataChange(data: any) {
    const dialogData = data.dialogData
    this.dialogConfig.vueName = dialogData.vueName
    this.dialogConfig.header.title = `${this.$t('message.portOfCall.portCalling')}`
  }

  public mounted() {
    window.addEventListener('setItemEvent', (e: any) => {
      if (e.key === 'language') {
        this.dialogConfig.header.title = `${this.$t('message.portOfCall.portCalling')}`
      }
    })
  }
}
</script>

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