/* eslint react/no-multi-comp:0, no-console:0 */ import { createForm } from '../index' import { regionStyle, errorStyle } from './styles' const CustomInput = { props: { form: Object, }, data () { return { data: [], } }, methods: { checkUpper (rule, value = '', callback) { if (value !== value.toUpperCase()) { callback(new Error('need to be upper!')) } else { callback() } }, toUpper (v, prev) { if (v === prev) { return v } return v.toUpperCase() }, }, render () { const { getFieldProps, getFieldError } = this.form const errors = getFieldError('upper') return (
upper normalize
{(errors) ? errors.join(',') : null}
) }, } const MaxMin = { props: { form: Object, }, methods: { normalizeMin (value, prevValue, allValues) { console.log('normalizeMin', allValues.min, allValues.max) const previousAllValues = this.form.getFieldsValue() if (allValues.max !== previousAllValues.max) { // max changed if (value === '' || Number(allValues.max) < Number(value)) { return allValues.max } } return value }, normalizeMax (value, prevValue, allValues) { console.log('normalizeMax', allValues.min, allValues.max) const previousAllValues = this.form.getFieldsValue() if (allValues.min !== previousAllValues.min) { // min changed if (value === '' || Number(allValues.min) > Number(value)) { return allValues.min } } return value }, }, render () { const { getFieldProps } = this.form return (
min:
max:
) }, } const Form = { // props: { // form: Object, // }, methods: { onSubmit (e) { e.preventDefault() this.form.validateFields((error, values) => { if (!error) { console.log('ok', values) } else { console.log('error', error, values) } }) }, }, render () { const { form } = this return (

normalize

) }, } export default createForm()(Form)