<template>
  <el-dialog
    v-if="visible"
    :visible.sync="visible"
    :before-close="handleClose"
    :title="title"
    :append-to-body="appendToBody"
    width="60%">
    <UploadFile :file-list.sync = "files"/>
    <span slot="footer" class="dialog-footer">
      <el-button @click="closeWindow">取 消</el-button>
      <el-button type="primary" @click="confirm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import waves from '@/directive/waves' // waves directive
import UploadFile from '../uploadFile'

export default {
  components: { Pagination, UploadFile },
  directives: { waves },
  props: {
    title: {
      type: String,
      default: ''
    },
    appendToBody: {
      type: Boolean,
      default: false
    },
    limit: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {
      visible: false,
      files: [],
      heirloom: {}
    }
  },
  methods: {
    init(e) {
      this.visible = true
      this.heirloom = e
    },
    handleClose() {
      this.visible = false
      this.files = []
    },
    closeWindow() {
      this.handleClose()
    },
    confirm() {
      if (this.files.length <= 0) {
        this.$message.error('未选择文件')
        return
      }
      this.$emit('getChoose', { heirloom: this.heirloom, info: this.files, name: 'uploadExcel' })
      this.visible = false
    }
  }
}

</script>

<style scoped>
.information >>> .el-scrollbar__wrap {
  overflow-x: hidden;
}
</style>
