<template>
  <div>
    <!--查看图片Dialog  ext=="jpeg"||ext=="jpg"||ext=="bmp"||ext=="gif"||ext=="png"-->
    <el-dialog title="查看" :visible.sync="viewPhotoDialogVisible">
      <div style="" v-loading="viewPhotoAreaLoading">
        <el-row type="flex" class="row-bg" justify="center" align="middle">
          <el-col :span="24">
            <div style="text-align:center;padding:10px;" v-html="photo.name"></div>
          </el-col>
        </el-row>
        <el-row type="flex" class="row-bg" justify="center" align="middle">
          <el-col :span="24">
            <div style="text-align:center;padding:10px;">
              <img v-if="photo.fullPath" class="img-responsive center-block" :src="photo.fullPath" />
              <font v-else> 图片加载失败 ！</font>
            </div>
          </el-col>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="viewPhotoDialogVisible=false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

export default {
  data() {
    return {
      viewPhotoDialogVisible: false,
      viewPhotoAreaLoading: false,
      photo: {
        name: '',
        fullPath: ''
      }
    }
  },
  methods: {
    // 加载图片ext === "jpeg" || ext === "jpg" || ext === "bmp" || ext === "gif" || ext === "png"
    async loadPhoto(param) {
      this.viewPhotoDialogVisible = true
      this.photo.name = param.name
      if (param.imgSrc) {
        this.photo.fullPath = param.imgSrc
        return
      }

      this.photo.fullPath = ''
      this.viewPhotoAreaLoading = true
      let res = await axios.get(`/ui/core/file/imagefullpath`, { params: param })
      let data = res.data
      if (data.status === 1) {
        this.photo.fullPath = data.data.fullpath
      }
      this.viewPhotoAreaLoading = false
    }
  }
}
</script>
