| 12345678910111213141516171819202122 |
- import { ValidateErrorEntity } from "ant-design-vue/lib/form/interface";
- import { Ref, toRaw, UnwrapRef } from "vue";
- /**
- * 表单验证
- * @param formRef
- * @param formState
- * @returns
- */
- export function validateAction<T>(formRef: Ref<any>, formState: UnwrapRef<T>): Promise<T> {
- return formRef.value
- .validate()
- .then(() => {
- const param = toRaw(formState);
- console.log('请求参数:', param);
- return param
- })
- .catch((error: ValidateErrorEntity<T>) => {
- console.error('表单验证错误:', error);
- Promise.reject(error)
- });
- }
|