BasicFiledsLayotForm.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!-- 标题与字段布局 -->
  2. <template>
  3. <!-- 自定义表单 -->
  4. <BasicForm @register="registerForm" @submit="handleSubmit" style="margin: 20px auto" />
  5. </template>
  6. <script lang="ts" setup>
  7. //引入依赖
  8. import { useForm, BasicForm, FormSchema } from '/@/components/Form';
  9. //自定义表单字段
  10. const formSchemas: FormSchema[] = [
  11. {
  12. label: '姓名',
  13. field: 'name',
  14. component: 'Input',
  15. },
  16. {
  17. label: '年龄',
  18. field: 'password',
  19. component: 'InputNumber',
  20. },
  21. {
  22. label: '生日',
  23. field: 'birthday',
  24. component: 'DatePicker',
  25. },
  26. {
  27. label: '头像',
  28. field: 'avatar',
  29. component: 'JImageUpload',
  30. },
  31. ];
  32. /**
  33. * BasicForm绑定注册;
  34. */
  35. const [registerForm] = useForm({
  36. //注册表单列
  37. schemas: formSchemas,
  38. showActionButtonGroup: false,
  39. actionColOptions: { span: 12 },
  40. //控制标题宽度占比
  41. labelCol: {
  42. xs: 2,
  43. sm: 2,
  44. md: 2,
  45. lg: 9,
  46. xl: 3,
  47. xxl: 2,
  48. },
  49. //控制组件宽度占比
  50. wrapperCol: {
  51. xs: 15,
  52. sm: 14,
  53. md: 16,
  54. lg: 17,
  55. xl: 19,
  56. xxl: 20,
  57. },
  58. });
  59. /**
  60. * 点击提交按钮的value值
  61. * @param values
  62. */
  63. function handleSubmit(values: any) {
  64. console.log('提交按钮数据::::', values);
  65. }
  66. </script>
  67. <style scoped>
  68. /** 时间和数字输入框样式 */
  69. :deep(.ant-input-number) {
  70. width: 100%;
  71. }
  72. :deep(.ant-picker) {
  73. width: 100%;
  74. }
  75. </style>