<template>
  <div class="upload-form">
    <el-form-item
      :key="item.model"
      :prop="item.model"
      :label="item.label || ''"
      :label-width="item.labelWidth || item['label-width'] || ''"
      :required="item.required || false"
      :rules="item.rules || []"
      :size="item.size"
    >
      <el-upload
        :action="item.action"
        :data="item.data"
        :before-upload="beforeUploadFile"
        :on-success="onSuccessFile"
        :with-credentials="true"
        v-bind="item.attrs || {}">
        <el-button type="primary">点击上传</el-button>
        <template v-if="formData[item.model]">
          <!-- 遍历显示文件 -->

        </template>
      </el-upload>
      <div class='info' style="line-height: 1.5;" v-html="item.html"></div>

      <!-- <el-input :style="{ width: item.modelWidth || item['model-width'] || '100%' }"
        v-bind="item.attrs || {}"
        v-on="$listeners"
        v-model="formData[item.model]"
        :disabled="item.disabled || false"
        :placeholder="item.placeholder || ''"
      ></el-input> -->
    </el-form-item>
  </div>
</template>

<script>
// import ajax from './ajax'

export default {
  name: 'UploadForm',
  componentName: 'UploadForm',
  props: {
    item: {
      type: Object,
      default () {
        return {}
      }
    },
    formData: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    return {
      filesArr: []
    }
  },
  methods: {
    beforeUploadFile (file) {},
    onSuccessFile (response, file, fileList) {
      debugger
    }
  }
}
</script>
