<template>
  <div class="upload-prop">
    <FormItem label="展示框宽度">
      <InputNumber v-model="info.form.width" clearable />
    </FormItem>
    <FormItem label="展示框长度">
      <InputNumber v-model="info.form.height" clearable />
    </FormItem>
    <FormItem label="文件大小(KB)">
      <InputNumber v-model="info.form.max" clearable />
    </FormItem>
    <FormItem label="上传方法">
      <Input v-model="info.form.load" clearable />
    </FormItem>
  </div>
</template>
<script>
const DEFAULT_LIST = [
  { key: 'name', default: 'file' },
  { key: 'fileType', default: 'img' },
  { key: 'width', default: 128 },
  { key: 'height', default: 128 },
  { key: 'max', default: 1024 },
]
export default {
  name: 'AvatarProp',
  props: {
    info: Object,
  },
  watch: {
    'info.name': {
      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>
