BasicFormConAttribute.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!-- 控件属性 -->
  2. <template>
  3. <!-- 自定义表单 -->
  4. <BasicForm @register="registerForm" style="margin-top: 20px" />
  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. componentProps: {
  16. disabled: true,
  17. },
  18. defaultValue: '张三',
  19. },
  20. {
  21. label: '性别',
  22. field: 'sex',
  23. component: 'Select',
  24. //填写组件的属性
  25. componentProps: {
  26. options: [
  27. { label: '男', value: 1 },
  28. { label: '女', value: 2 },
  29. { label: '未知', value: 3 },
  30. ],
  31. },
  32. //默认值
  33. defaultValue: 3,
  34. },
  35. {
  36. label: '年龄',
  37. field: 'age',
  38. component: 'Input',
  39. },
  40. {
  41. label: '入职时间',
  42. subLabel: '( 选填 )',
  43. field: 'entryTime',
  44. component: 'TimePicker',
  45. },
  46. ];
  47. /**
  48. * BasicForm绑定注册;
  49. */
  50. const [registerForm] = useForm({
  51. //注册表单列
  52. schemas: formSchemas,
  53. labelWidth: '150px',
  54. showResetButton: false,
  55. submitButtonOptions: { text: '提交', preIcon: '' },
  56. actionColOptions: { span: 17 },
  57. });
  58. </script>
  59. <style scoped></style>