Commit 94bf854dd98f37ffb39e9086c565a0610c250205
1 parent
1db72c8f
fix: fix form submit error
Showing
3 changed files
with
10 additions
and
6 deletions
src/components/Form/src/BasicForm.vue
src/components/Form/src/FormItem.tsx
... | ... | @@ -150,7 +150,11 @@ export default defineComponent({ |
150 | 150 | function handleValue(component: ComponentType, field: string) { |
151 | 151 | const val = (props.formModel as any)[field]; |
152 | 152 | if (['Input', 'InputPassword', 'InputSearch', 'InputTextArea'].includes(component)) { |
153 | - return isNumber(val) && val ? `${val}` : val; | |
153 | + if (val && isNumber(val)) { | |
154 | + (props.formModel as any)[field] = `${val}`; | |
155 | + return `${val}`; | |
156 | + } | |
157 | + return val; | |
154 | 158 | } |
155 | 159 | return val; |
156 | 160 | } | ... | ... |
src/components/Form/src/hooks/useFormAction.ts
... | ... | @@ -43,7 +43,7 @@ export function useFormAction({ |
43 | 43 | Object.keys(formModel).forEach((key) => { |
44 | 44 | (formModel as any)[key] = defaultValueRef.value[key]; |
45 | 45 | }); |
46 | - formEl.clearValidate(); | |
46 | + clearValidate(); | |
47 | 47 | emit('reset', toRaw(formModel)); |
48 | 48 | // return values; |
49 | 49 | submitOnReset && handleSubmit(); |
... | ... | @@ -187,7 +187,7 @@ export function useFormAction({ |
187 | 187 | return formElRef.value.validate(nameList); |
188 | 188 | } |
189 | 189 | |
190 | - function clearValidate(name: string | string[]) { | |
190 | + function clearValidate(name?: string | string[]) { | |
191 | 191 | if (!formElRef.value) return; |
192 | 192 | formElRef.value.clearValidate(name); |
193 | 193 | } |
... | ... | @@ -205,7 +205,7 @@ export function useFormAction({ |
205 | 205 | const formEl = unref(formElRef); |
206 | 206 | if (!formEl) return; |
207 | 207 | try { |
208 | - const values = await formEl.validate(); | |
208 | + const values = await validate(); | |
209 | 209 | const res = handleFormValues(values); |
210 | 210 | emit('submit', res); |
211 | 211 | } catch (error) {} | ... | ... |