<script>
import { deepCopy } from "@/utils"
import formBuilder from '@/utils/formBuilder'
export default {
  props: {
    originalForm: {
      type: Object,
      default: () => ({}),
      required: true
    },
    subForm: {
      type: Map,
      default: () => new Map()
    },
    device: {
      type: String,
      default: 'desktop',
      required: true
    },
    info: {
      type: Array,
      default: () => [],
      required: true
    }
  },
  data() {
    return {
      form: {},
      file: {
        ggg: []
      }
    }
  },
  methods: {
  },
  computed: {

  },
  watch: {
    info(newVal) {
      let keys = newVal.map(i => i.name)
      keys.forEach(key => {
        this.form[key] = ''
      })
    },
    originalForm(newVal) {
      this.form = deepCopy(newVal)
    }
  },
  render(h) {
    return h('el-form', {
      class: 'form',
      props: {
        model: this.form,
        'label-position': 'top'
      }
    },this.info.map(field => formBuilder.bind(this)(this.device, field, h)))
  }
}
</script>

<style scoped lang="scss">
.form {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-gap: 20px;
}
::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-form-item__label {
  padding-bottom: 0;
}
</style>
