form.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import type { CSSProperties } from 'vue'
  2. import {
  3. ColProps,
  4. ComponentProps,
  5. ComponentName,
  6. InputComponentProps,
  7. AutocompleteComponentProps,
  8. InputNumberComponentProps,
  9. SelectComponentProps
  10. } from '@/types/components'
  11. import { FormValueType, FormValueType } from '@/types/form'
  12. import type { AxiosPromise } from 'axios'
  13. export type FormSetPropsType = {
  14. field: string
  15. path: string
  16. value: any
  17. }
  18. export type FormValueType = string | number | string[] | number[] | boolean | undefined | null
  19. export type FormItemProps = {
  20. labelWidth?: string | number
  21. required?: boolean
  22. rules?: Recordable
  23. error?: string
  24. showMessage?: boolean
  25. inlineMessage?: boolean
  26. style?: CSSProperties
  27. }
  28. export interface FormSchema {
  29. /**
  30. * 唯一标识
  31. */
  32. field: string
  33. /**
  34. * 标题
  35. */
  36. label?: string
  37. /**
  38. * 提示信息
  39. */
  40. labelMessage?: string
  41. /**
  42. * col组件属性
  43. */
  44. colProps?: ColProps
  45. /**
  46. * 表单组件属性,具体可以查看element-plus文档
  47. */
  48. componentProps?:
  49. | InputComponentProps
  50. | AutocompleteComponentProps
  51. | InputNumberComponentProps
  52. | SelectComponentProps
  53. /**
  54. * formItem组件属性,具体可以查看element-plus文档
  55. */
  56. formItemProps?: FormItemProps
  57. /**
  58. * 渲染的组件名称
  59. */
  60. component?: ComponentName
  61. /**
  62. * 初始值
  63. */
  64. value?: FormValueType
  65. /**
  66. * 是否隐藏
  67. */
  68. hidden?: boolean
  69. /**
  70. * @returns 远程加载下拉项
  71. */
  72. api?: <T = any>() => AxiosPromise<T>
  73. }