vben
authored
|
1
|
<template>
|
vben
authored
|
2
3
4
5
6
7
8
9
|
<PageWrapper
class="high-form"
title="高级表单"
content=" 高级表单常见于一次性输入和提交大批量数据的场景。"
>
<a-card title="仓库管理" :bordered="false">
<BasicForm @register="register" />
</a-card>
|
Vben
authored
|
10
|
<a-card title="任务管理" :bordered="false" class="!mt-5">
|
vben
authored
|
11
12
|
<BasicForm @register="registerTask" />
</a-card>
|
|
13
|
<a-card title="成员管理" :bordered="false" class="!mt-5">
|
vben
authored
|
14
15
|
<PersonTable ref="tableRef" />
</a-card>
|
vben
authored
|
16
|
|
vben
authored
|
17
|
<template #rightFooter>
|
vben
authored
|
18
|
<a-button type="primary" @click="submitAll"> 提交 </a-button>
|
vben
authored
|
19
20
|
</template>
</PageWrapper>
|
vben
authored
|
21
22
23
24
25
|
</template>
<script lang="ts">
import { BasicForm, useForm } from '/@/components/Form';
import { defineComponent, ref } from 'vue';
import PersonTable from './PersonTable.vue';
|
vben
authored
|
26
|
import { PageWrapper } from '/@/components/Page';
|
vben
authored
|
27
|
import { schemas, taskSchemas } from './data';
|
vben
authored
|
28
|
import { Card } from 'ant-design-vue';
|
vben
authored
|
29
30
|
export default defineComponent({
|
|
31
|
name: 'FormHightPage',
|
vben
authored
|
32
|
components: { BasicForm, PersonTable, PageWrapper, [Card.name]: Card },
|
vben
authored
|
33
34
35
36
|
setup() {
const tableRef = ref<{ getDataSource: () => any } | null>(null);
const [register, { validate }] = useForm({
|
|
37
|
layout: 'vertical',
|
vben
authored
|
38
39
40
41
42
43
44
45
|
baseColProps: {
span: 6,
},
schemas: schemas,
showActionButtonGroup: false,
});
const [registerTask, { validate: validateTaskForm }] = useForm({
|
|
46
|
layout: 'vertical',
|
vben
authored
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
baseColProps: {
span: 6,
},
schemas: taskSchemas,
showActionButtonGroup: false,
});
async function submitAll() {
try {
if (tableRef.value) {
console.log('table data:', tableRef.value.getDataSource());
}
const [values, taskValues] = await Promise.all([validate(), validateTaskForm()]);
console.log('form data:', values, taskValues);
} catch (error) {}
}
return { register, registerTask, submitAll, tableRef };
},
});
</script>
<style lang="less" scoped>
.high-form {
padding-bottom: 48px;
}
</style>
|