form.d.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import type { CSSProperties } from 'vue'
  2. declare global {
  3. declare type ComponentName =
  4. | 'Radio'
  5. | 'RadioButton'
  6. | 'Checkbox'
  7. | 'CheckboxButton'
  8. | 'Input'
  9. | 'Autocomplete'
  10. | 'InputNumber'
  11. | 'Select'
  12. | 'Cascader'
  13. | 'Switch'
  14. | 'Slider'
  15. | 'TimePicker'
  16. | 'DatePicker'
  17. | 'Rate'
  18. | 'ColorPicker'
  19. | 'Transfer'
  20. | 'Divider'
  21. | 'TimeSelect'
  22. | 'SelectV2'
  23. | 'InputPassword'
  24. declare type ColProps = {
  25. span?: number
  26. xs?: number
  27. sm?: number
  28. md?: number
  29. lg?: number
  30. xl?: number
  31. tag?: string
  32. }
  33. declare type FormValueType = string | number | string[] | number[] | boolean | undefined | null
  34. declare type FormItemProps = {
  35. labelWidth?: string | number
  36. required?: boolean
  37. rules?: Recordable
  38. error?: string
  39. showMessage?: boolean
  40. inlineMessage?: boolean
  41. style?: CSSProperties
  42. }
  43. declare type ComponentOptions = {
  44. label?: string
  45. value?: FormValueType
  46. disabled?: boolean
  47. key?: string | number
  48. children?: ComponentOptions[]
  49. options?: ComponentOptions[]
  50. } & Recordable
  51. declare type ComponentOptionsAlias = {
  52. labelField?: string
  53. valueField?: string
  54. }
  55. declare type ComponentProps = {
  56. optionsAlias?: ComponentOptionsAlias
  57. options?: ComponentOptions[]
  58. optionsSlot?: boolean
  59. } & Recordable
  60. declare type FormSchema = {
  61. // 唯一值
  62. field: string
  63. // 标题
  64. label?: string
  65. // col组件属性
  66. colProps?: ColProps
  67. // 表单组件属性,slots对应的是表单组件的插槽,规则:${field}-xxx,具体可以查看element-plus文档
  68. componentProps?: { slots?: Recordable } & ComponentProps
  69. // formItem组件属性
  70. formItemProps?: FormItemProps
  71. // 渲染的组件
  72. component?: ComponentName
  73. // 初始值
  74. value?: FormValueType
  75. // 是否隐藏
  76. hidden?: boolean
  77. }
  78. declare type FormSetPropsType = {
  79. field: string
  80. path: string
  81. value: any
  82. }
  83. }