<template>
  <el-form :label-width="labelWidth"
           :label-position="labelPosition"
           ref="form"
           :size="size"
           :label-suffix="labelSuffix" :rules="rules">
    <el-row>
      <slot>
      </slot>
    </el-row>
  </el-form>
</template>

<script>
  export default {
    name: 'LineDescribeForm',
    props: {
      // 表单域标签的宽度
      labelWidth: {
        default: '120px'
      },
      // 表单域标签的位置，如果值为 left 或者 right 时，则需要设置 label-width
      labelPosition: {
        default: 'right'
      },
      // 表单域标签的后缀
      labelSuffix: {
        default: ':'
      },
      rules: {
        type: Object,
        default: function () {
          return {}
        }
      },
      size: 'small'
    },
    data () {
      return {}
    },
    methods: {
      resetField () {
        return this.$refs.form.resetField();
      },
      validate () {
        return new Promise(resolve => {
          this.$refs.form.validate((valid, invalidFields) => {
            if (valid) {
              resolve(valid, invalidFields)
            }
          });
        })
      }
    }
  }
</script>

<style scoped>

</style>
