common.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. interface ValidRule {
  2. validType?: import('@/utils').ValidKey; // 表达验证类型
  3. ruleFn?: import('@/utils').RuleFn.ruleFn;
  4. errMsgFn?: (...args: any) => string;
  5. errMsg?: string;
  6. }
  7. interface Valid {
  8. validFormatType?: import('@/utils').InputTypeValue; // 用于验证格式化表单输入类型
  9. validRules?: Array<ValidRule> | ValidRule;
  10. }
  11. declare interface ValidProps {
  12. id: string;
  13. required: boolean;
  14. message: string;
  15. trigger: string;
  16. }
  17. declare interface ValidConfig extends Valid {
  18. validProps?: Partial<ValidProps>;
  19. }
  20. declare interface anyObj {
  21. [key: string]: any;
  22. }
  23. declare interface OtherConfig {
  24. tip: boolean;
  25. tipMsg: string | ((param: any) => string);
  26. }
  27. declare type FunctionVoid = () => void;
  28. // 获取组件中 props 属性类型
  29. declare type PickComponentsProps<T> = {
  30. -readonly [K in keyof Omit<
  31. T,
  32. keyof import('vue').VNodeProps | keyof import('vue').AllowedComponentProps
  33. >]: T[K];
  34. };
  35. interface ColumnProps extends Partial<import('element-plus').FormItemProps> {
  36. label: string | ((form: any) => string);
  37. width: string | number;
  38. }
  39. interface SelectOption extends Options {
  40. optionLabelKey?: string;
  41. optionValueKey?: string;
  42. }
  43. interface Options {
  44. options: any[];
  45. }
  46. interface Supplement {
  47. maxlength: string;
  48. rows: number;
  49. }
  50. declare interface ItemConfig extends ValidConfig {
  51. itemType?:
  52. | 'number'
  53. | 'date'
  54. | 'select'
  55. | 'timeSelect'
  56. | 'text'
  57. | 'time'
  58. | 'radio'
  59. | 'checkbox'
  60. | 'other'
  61. | 'table'
  62. | 'dateTime';
  63. modelKey?: string; // 表单输入项双向绑定 v-model 后端数据字段名
  64. slotName?: string;
  65. dateRange?: boolean;
  66. default?: any; // 默认填充值
  67. columnProps?: Partial<ColumnProps>;
  68. // input | datePicker | timePicker | inputNumber | select 选择器
  69. elInputProps?: Partial<import('element-plus').InputProps & Supplement>;
  70. elDatePickerProps?: Partial<import('element-plus').DatePickerProps>;
  71. elTimePickerProps?: Partial<import('element-plus').TimePickerDefaultProps>;
  72. elInputNumberProps?: Partial<import('element-plus').InputNumberProps>;
  73. elSelectProps?: Partial<import('element-plus').ISelectProps & SelectOption>;
  74. elRadioProps?: Partial<import('element-plus').RadioProps & Options>;
  75. elCheckboxProps?: Partial<import('element-plus').CheckboxProps & Options>;
  76. // el-form-item 的配置
  77. elFormItemProps?: Partial<FormItemProps>;
  78. otherConfig?: OtherConfig;
  79. }
  80. declare interface PageConfig {
  81. id?: string;
  82. labelWidth?: string | number;
  83. items: ItemConfig[];
  84. // form表单的配置同 element plus form
  85. formProps?: Partial<import('element-plus').FormProps>;
  86. isDialogSearch?: boolean;
  87. }
  88. declare interface BtnLoading {
  89. btnLoading?: boolean;
  90. }
  91. declare interface StandardOptions {
  92. value: string | number;
  93. label: string;
  94. }
  95. declare interface TransformedItem extends StandardOptions {
  96. level?: number;
  97. disabled?: boolean;
  98. children?: TransformedItem[];
  99. }