/* eslint no-console:0 */ import { DatePicker } from 'ant-design-vue'; import createDOMForm from '../src/createDOMForm'; import { regionStyle, errorStyle } from './styles'; const Form = { props: { form: Object, }, methods: { onSubmit(e) { console.log('submit'); e.preventDefault(); this.form.validateFieldsAndScroll((error, values) => { if (!error) { console.log('ok', values); } else { console.log('error', error, values); } }); }, reset(e) { e.preventDefault(); this.form.resetFields(); }, checkStart(rule, value, callback) { const { validateFields } = this.form; validateFields(['end'], { force: true }); callback(); }, checkEnd(rule, value, callback) { const end = value; const { getFieldValue } = this.form; const start = getFieldValue('start'); if (!end || !start) { callback('please select both start and end time'); } else if (end.valueOf() < start.valueOf()) { callback('start time should be less than end time'); } else { callback(); } }, }, render() { const { form } = this; const { getFieldProps, getFieldError } = form; return (

startTime and endTime validation

start:
end:
{getFieldError('end') ? getFieldError('end').join(',') : ''}
 
); }, }; export default createDOMForm()(Form);