<template>
  <div class="upload-prop">
    <!-- <FormItem label="文件字段名">
      <Input v-model="info.form.name" clearable />
    </FormItem> -->
    <FormItem label="文件类型">
      <Select v-model="info.form.fileType" clearable>
        <Option value="img">图片</Option>
        <Option value="video">视频</Option>
        <Option value="audio">音频</Option>
        <Option value="document">文档</Option>
        <Option value="*">不限类型</Option>
      </Select>
    </FormItem>
    <FormItem label="文件大小(KB)">
      <InputNumber v-model="info.form.max" clearable />
    </FormItem>
    <FormItem label="文件数量限制">
      <InputNumber v-model="info.form.count" clearable />
    </FormItem>
    <FormItem label="按钮文字">
      <Input v-model="info.form.placeholder" clearable />
    </FormItem>
    <FormItem label="上传方法">
       <Input v-model="info.form.load" clearable />
    </FormItem>
    <FormItem label="下载方法">
       <Input v-model="info.form.download" clearable />
    </FormItem>
     <FormItem label="清空方法">
       <Input v-model="info.form.clear" clearable />
    </FormItem>
  </div>
</template>
<script>
const DEFAULT_LIST = [
  { key: 'fileType', default: 'file' },
  { key: 'max', default: 2048 },
  { key: 'count', default: 3 },
  { key: 'placeholder', default: '点击上传' },
]

export default {
  name: 'UploadProp',
  props: {
    info: Object,
  },
  watch: {
    'info.form': {
      handler() {
        const { form } = this.info
        if (Object.keys(form).length !== 1) { return }
        for (const val of DEFAULT_LIST) {
          if (!form[val.key] && form[val.key] !== 0) {
            this.$set(form, val.key, val.default)
          }
        }
      },
      deep: true,
      immediate: true,
    },
  },
}
</script>