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
85b92a9a
Unverified
Commit
85b92a9a
authored
Apr 19, 2021
by
jinmao88
Committed by
GitHub
Apr 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: add AppendFormDemo (#503)
Co-authored-by:
haha
<
admin@qq.com
>
parent
bd83eccd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
0 deletions
+131
-0
form.ts
src/locales/lang/en/routes/demo/form.ts
+1
-0
form.ts
src/locales/lang/zh_CN/routes/demo/form.ts
+1
-0
comp.ts
src/router/menus/modules/demo/comp.ts
+4
-0
comp.ts
src/router/routes/modules/demo/comp.ts
+8
-0
AppendForm.vue
src/views/demo/form/AppendForm.vue
+117
-0
No files found.
src/locales/lang/en/routes/demo/form.ts
View file @
85b92a9a
...
...
@@ -7,4 +7,5 @@ export default {
ruleForm
:
'
Form validation
'
,
dynamicForm
:
'
Dynamic
'
,
customerForm
:
'
Custom
'
,
appendForm
:
'
Append
'
,
};
src/locales/lang/zh_CN/routes/demo/form.ts
View file @
85b92a9a
...
...
@@ -7,4 +7,5 @@ export default {
ruleForm
:
'
表单验证
'
,
dynamicForm
:
'
动态表单
'
,
customerForm
:
'
自定义组件
'
,
appendForm
:
'
表单增删示例
'
,
};
src/router/menus/modules/demo/comp.ts
View file @
85b92a9a
...
...
@@ -47,6 +47,10 @@ const menu: MenuModule = {
path
:
'
customerForm
'
,
name
:
t
(
'
routes.demo.form.customerForm
'
),
},
{
path
:
'
appendForm
'
,
name
:
t
(
'
routes.demo.form.appendForm
'
),
},
],
},
{
...
...
src/router/routes/modules/demo/comp.ts
View file @
85b92a9a
...
...
@@ -89,6 +89,14 @@ const comp: AppRouteModule = {
title
:
t
(
'
routes.demo.form.customerForm
'
),
},
},
{
path
:
'
appendForm
'
,
name
:
'
appendFormDemo
'
,
component
:
()
=>
import
(
'
/@/views/demo/form/AppendForm.vue
'
),
meta
:
{
title
:
t
(
'
routes.demo.form.appendForm
'
),
},
},
],
},
{
...
...
src/views/demo/form/AppendForm.vue
0 → 100644
View file @
85b92a9a
<
template
>
<PageWrapper
title=
"表单增删示例"
>
<CollapseContainer
title=
"表单增删"
>
<BasicForm
@
register=
"register"
@
submit=
"handleSubmit"
>
<template
#add
="
{ field }">
<Button
v-if=
"field === 1"
@
click=
"add"
>
+
</Button>
<Button
v-if=
"field > 1"
@
click=
"del(field)"
>
-
</Button>
</
template
>
</BasicForm>
</CollapseContainer>
</PageWrapper>
</template>
<
script
lang=
"ts"
>
import
{
defineComponent
,
ref
}
from
'
vue
'
;
import
{
BasicForm
,
useForm
}
from
'
/@/components/Form/index
'
;
import
{
CollapseContainer
}
from
'
/@/components/Container/index
'
;
import
{
Input
}
from
'
ant-design-vue
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
import
{
Button
}
from
'
/@/components/Button
'
;
export
default
defineComponent
({
components
:
{
BasicForm
,
CollapseContainer
,
PageWrapper
,
[
Input
.
name
]:
Input
,
Button
},
setup
()
{
const
[
register
,
{
appendSchemaByField
,
removeSchemaByFiled
,
validate
}]
=
useForm
({
schemas
:
[
{
field
:
'
field1a
'
,
component
:
'
Input
'
,
label
:
'
字段1
'
,
colProps
:
{
span
:
8
,
},
required
:
true
,
},
{
field
:
'
field1b
'
,
component
:
'
Input
'
,
label
:
'
字段1
'
,
colProps
:
{
span
:
8
,
},
required
:
true
,
},
{
field
:
'
1
'
,
component
:
'
Input
'
,
label
:
'
'
,
colProps
:
{
span
:
8
,
},
slot
:
'
add
'
,
},
],
labelWidth
:
100
,
actionColOptions
:
{
span
:
24
},
});
async
function
handleSubmit
()
{
try
{
const
data
=
await
validate
();
console
.
log
(
data
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
const
n
=
ref
(
2
);
function
add
()
{
appendSchemaByField
(
{
field
:
'
field
'
+
n
.
value
+
'
a
'
,
component
:
'
Input
'
,
label
:
'
字段2
'
,
colProps
:
{
span
:
8
,
},
required
:
true
,
},
''
);
appendSchemaByField
(
{
field
:
'
field
'
+
n
.
value
+
'
b
'
,
component
:
'
Input
'
,
label
:
'
字段2
'
,
colProps
:
{
span
:
8
,
},
required
:
true
,
},
''
);
appendSchemaByField
(
{
field
:
`
${
n
.
value
}
`
,
component
:
'
Input
'
,
label
:
'
'
,
colProps
:
{
span
:
8
,
},
slot
:
'
add
'
,
},
''
);
n
.
value
++
;
}
function
del
(
field
)
{
console
.
log
(
field
);
removeSchemaByFiled
([
`field
${
field
}
a`
,
`field
${
field
}
b`
,
`
${
field
}
`
]);
}
return
{
register
,
handleSubmit
,
add
,
del
};
},
});
</
script
>
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