vben
authored
|
1
|
<template>
|
vben
authored
|
2
3
|
<PageWrapper
title="基础表单"
|
vben
authored
|
4
|
contentBackground
|
vben
authored
|
5
|
content=" 表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。"
|
vben
authored
|
6
|
contentClass="p-4"
|
vben
authored
|
7
8
9
|
>
<BasicForm @register="register" />
</PageWrapper>
|
vben
authored
|
10
11
12
13
14
15
|
</template>
<script lang="ts">
import { BasicForm, useForm } from '/@/components/Form';
import { defineComponent } from 'vue';
import { schemas } from './data';
import { useMessage } from '/@/hooks/web/useMessage';
|
vben
authored
|
16
17
|
import { PageWrapper } from '/@/components/Page';
|
vben
authored
|
18
|
export default defineComponent({
|
vben
authored
|
19
|
components: { BasicForm, PageWrapper },
|
vben
authored
|
20
21
22
23
|
setup() {
const { createMessage } = useMessage();
const [register, { validate, setProps }] = useForm({
labelCol: {
|
|
24
|
span: 8,
|
vben
authored
|
25
26
27
28
29
30
31
|
},
wrapperCol: {
span: 10,
},
schemas: schemas,
actionColOptions: {
offset: 8,
|
|
32
|
span: 12,
|
vben
authored
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
},
submitButtonOptions: {
text: '提交',
},
submitFunc: customSubmitFunc,
});
async function customSubmitFunc() {
try {
await validate();
setProps({
submitButtonOptions: {
loading: true,
},
});
setTimeout(() => {
setProps({
submitButtonOptions: {
loading: false,
},
});
createMessage.success('提交成功!');
}, 2000);
} catch (error) {}
}
return { register };
},
});
</script>
<style lang="less" scoped>
.form-wrap {
padding: 24px;
|
Vben
authored
|
66
|
background-color: @component-background;
|
vben
authored
|
67
68
|
}
</style>
|