|
@@ -1,3 +1,4 @@
|
|
|
+import {validateErrorTip} from '@utils';
|
|
|
import {toTypedSchema} from '@vee-validate/zod';
|
|
|
import {useForm} from 'vee-validate';
|
|
|
import {Ref} from 'vue';
|
|
@@ -10,17 +11,6 @@ type FormState = {
|
|
|
licenseImage: string;
|
|
|
};
|
|
|
|
|
|
-const validate = object({
|
|
|
- enterprise: string({errorMap: () => ({message: 'register.errors.enterprise'})})
|
|
|
- .min(1, 'register.errors.enterprise'),
|
|
|
- phone: string({errorMap: () => ({message: 'register.errors.phone'})})
|
|
|
- .min(1, 'register.errors.phone'),
|
|
|
- idCardImage: string({errorMap: () => ({message: 'register.errors.idcard'})})
|
|
|
- .min(1, 'register.errors.idcard'),
|
|
|
- licenseImage: string({errorMap: () => ({message: 'register.errors.licenseImage'})})
|
|
|
- .min(1, 'register.errors.licenseImage'),
|
|
|
-});
|
|
|
-
|
|
|
export function useFormState(isSuccess: Ref<boolean>) {
|
|
|
const {handleSubmit, handleReset} = useForm<FormState>({
|
|
|
initialValues: {
|
|
@@ -29,7 +19,16 @@ export function useFormState(isSuccess: Ref<boolean>) {
|
|
|
idCardImage: '',
|
|
|
licenseImage: '',
|
|
|
},
|
|
|
- validationSchema: toTypedSchema(validate),
|
|
|
+ validationSchema: toTypedSchema(object({
|
|
|
+ enterprise: string(validateErrorTip('register.errors.enterprise'))
|
|
|
+ .min(1, 'register.errors.enterprise'),
|
|
|
+ phone: string(validateErrorTip('register.errors.phone'))
|
|
|
+ .min(1, 'register.errors.phone'),
|
|
|
+ idCardImage: string(validateErrorTip('register.errors.idcard'))
|
|
|
+ .min(1, 'register.errors.idcard'),
|
|
|
+ licenseImage: string(validateErrorTip('register.errors.licenseImage'))
|
|
|
+ .min(1, 'register.errors.licenseImage'),
|
|
|
+ })),
|
|
|
});
|
|
|
|
|
|
const onSubmit = handleSubmit(function(value) {
|