form.d.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import type { CSSProperties } from 'vue'
  2. import { ColProps, ComponentProps, ComponentName } from '@/types/components'
  3. import type { AxiosPromise } from 'axios'
  4. export type FormSetPropsType = {
  5. field: string
  6. path: string
  7. value: any
  8. }
  9. export type FormValueType = string | number | string[] | number[] | boolean | undefined | null
  10. export type FormItemProps = {
  11. labelWidth?: string | number
  12. required?: boolean
  13. rules?: Recordable
  14. error?: string
  15. showMessage?: boolean
  16. inlineMessage?: boolean
  17. style?: CSSProperties
  18. }
  19. export type FormSchema = {
  20. // 唯一值
  21. field: string
  22. // 标题
  23. label?: string
  24. // 提示
  25. labelMessage?: string
  26. // col组件属性
  27. colProps?: ColProps
  28. // 表单组件属性,slots对应的是表单组件的插槽,规则:${field}-xxx,具体可以查看element-plus文档
  29. componentProps?: { slots?: Recordable } & ComponentProps
  30. // formItem组件属性
  31. formItemProps?: FormItemProps
  32. // 渲染的组件
  33. component?: ComponentName
  34. // 初始值
  35. value?: FormValueType
  36. // 是否隐藏
  37. hidden?: boolean
  38. // 远程加载下拉项
  39. api?: <T = any>() => AxiosPromise<T>
  40. }