123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <template>
- <div>
- <a-page-header title="基础表单" :ghost="false">
- 表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。
- </a-page-header>
- <div class="m-5 form-wrap">
- <BasicForm @register="register" />
- </div>
- </div>
- </template>
- <script lang="ts">
- import { BasicForm, useForm } from '/@/components/Form';
- import { defineComponent } from 'vue';
- import { schemas } from './data';
- import { useMessage } from '/@/hooks/web/useMessage';
- export default defineComponent({
- components: { BasicForm },
- setup() {
- const { createMessage } = useMessage();
- const [register, { validate, setProps }] = useForm({
- labelCol: {
- span: 7,
- },
- wrapperCol: {
- span: 10,
- },
- schemas: schemas,
- actionColOptions: {
- offset: 8,
- },
- 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;
- background: #fff;
- }
- </style>
|