<template>
  <el-upload
    class="upload-demo"
    ref="upload"
    :action="uploadFile"
    :on-preview="handlePreview"
    :on-remove="handleRemove"
    :on-success="handleSuccess"
    :file-list="fileList"
    :limit="1"
    name="multipartFile"
    :data="fileInfo"
    :auto-upload="false">
    <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  </el-upload>
</template>

<script>

import { upload_UpdateFile } from '@/api/Common/Upload'
export default {
  props: {
    fileInfo: {
      type: Object
    }
  },
  data() {
    return {
      fileList: [],
      uploadFile: upload_UpdateFile
    }
  },
  created() {
    this.fileList = []
    this.uploadFile = upload_UpdateFile
  },
  methods: {
    handleSuccess(event, file, fileList) {
      console.log(file)
      this.$emit('change', file)
    },
    handleRemove(file, fileList) {
      console.log(file, fileList)
    },
    handlePreview(file) {
      console.log(file)
    },
    submitUpload() {
      console.log(this.fileInfo)
      this.$refs.upload.submit()
    }
  }
}
</script>
