<template>
  <div class="fullheight">
    <el-image
      class="fullheight"
      v-if="fileId"
      :src="src"
      :fit="fit"
    ></el-image>
    <el-image
      class="fullheight"
      v-if="!fileId"
      :src="require('@/assets/img/datav/defaultCover.png')"
      :fit="fit"
    ></el-image>
  </div>
</template>
<script>
  import req from '@/request.js'
  export default {
    name: 'datav-cover',
    data() {
      return {
        src: '',
        defaultSrc: require('@/assets/img/datav/defaultCover.png'),
      }
    },
    props: {
      fileId: {
        type: String,
      },
      width: {
        type: Number,
      },
      height: {
        type: Number,
      },
      fit: {
        type: String,
        default: 'cover'
      }
    },
    created() {
      this.initImageData()
    },
    methods: {
      initImageData() {
        if (this.fileId) {
          this.src = `${window.context.portal}/system/file/v1/downloadFile?fileId=${this.fileId}` || this.defaultSrc
        }
      },
    },
  }
</script>
<style>
</style>