Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
94bf854d
Commit
94bf854d
authored
Nov 05, 2020
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix form submit error
parent
1db72c8f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
6 deletions
+10
-6
BasicForm.vue
src/components/Form/src/BasicForm.vue
+2
-2
FormItem.tsx
src/components/Form/src/FormItem.tsx
+5
-1
useFormAction.ts
src/components/Form/src/hooks/useFormAction.ts
+3
-3
No files found.
src/components/Form/src/BasicForm.vue
View file @
94bf854d
...
...
@@ -53,8 +53,8 @@
const
formModel
=
reactive
({});
const
actionState
=
reactive
({
resetAction
:
{},
submitAction
:
{},
resetAction
:
()
=>
{},
submitAction
:
()
=>
{},
});
const
advanceState
=
reactive
<
AdvanceState
>
({
...
...
src/components/Form/src/FormItem.tsx
View file @
94bf854d
...
...
@@ -150,7 +150,11 @@ export default defineComponent({
function
handleValue
(
component
:
ComponentType
,
field
:
string
)
{
const
val
=
(
props
.
formModel
as
any
)[
field
];
if
([
'
Input
'
,
'
InputPassword
'
,
'
InputSearch
'
,
'
InputTextArea
'
].
includes
(
component
))
{
return
isNumber
(
val
)
&&
val
?
`
${
val
}
`
:
val
;
if
(
val
&&
isNumber
(
val
))
{
(
props
.
formModel
as
any
)[
field
]
=
`
${
val
}
`
;
return
`
${
val
}
`
;
}
return
val
;
}
return
val
;
}
...
...
src/components/Form/src/hooks/useFormAction.ts
View file @
94bf854d
...
...
@@ -43,7 +43,7 @@ export function useFormAction({
Object
.
keys
(
formModel
).
forEach
((
key
)
=>
{
(
formModel
as
any
)[
key
]
=
defaultValueRef
.
value
[
key
];
});
formEl
.
clearValidate
();
clearValidate
();
emit
(
'
reset
'
,
toRaw
(
formModel
));
// return values;
submitOnReset
&&
handleSubmit
();
...
...
@@ -187,7 +187,7 @@ export function useFormAction({
return
formElRef
.
value
.
validate
(
nameList
);
}
function
clearValidate
(
name
:
string
|
string
[])
{
function
clearValidate
(
name
?
:
string
|
string
[])
{
if
(
!
formElRef
.
value
)
return
;
formElRef
.
value
.
clearValidate
(
name
);
}
...
...
@@ -205,7 +205,7 @@ export function useFormAction({
const
formEl
=
unref
(
formElRef
);
if
(
!
formEl
)
return
;
try
{
const
values
=
await
formEl
.
validate
();
const
values
=
await
validate
();
const
res
=
handleFormValues
(
values
);
emit
(
'
submit
'
,
res
);
}
catch
(
error
)
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment