props.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import type { PropType } from 'vue';
  2. import type { PaginationProps } from './types/pagination';
  3. import type { BasicColumn, FetchSetting, TableSetting, SorterResult, TableCustomRecord, TableRowSelection, SizeType } from './types/table';
  4. import type { FormProps } from '/@/components/Form';
  5. import { DEFAULT_FILTER_FN, DEFAULT_SORT_FN, FETCH_SETTING, DEFAULT_SIZE, COLUMN_DEFAULT_TEXT } from './const';
  6. import { propTypes } from '/@/utils/propTypes';
  7. export const basicProps = {
  8. clickToRowSelect: propTypes.bool.def(true),
  9. isTreeTable: propTypes.bool.def(false),
  10. tableSetting: propTypes.shape<TableSetting>({}),
  11. inset: propTypes.bool,
  12. sortFn: {
  13. type: Function as PropType<(sortInfo: SorterResult) => any>,
  14. default: DEFAULT_SORT_FN,
  15. },
  16. filterFn: {
  17. type: Function as PropType<(data: Partial<Recordable<string[]>>) => any>,
  18. default: DEFAULT_FILTER_FN,
  19. },
  20. showTableSetting: propTypes.bool.def(false),
  21. autoCreateKey: propTypes.bool.def(true),
  22. striped: propTypes.bool.def(true),
  23. showSummary: propTypes.bool,
  24. summaryFunc: {
  25. type: [Function, Array] as PropType<(...arg: any[]) => any[]>,
  26. default: null,
  27. },
  28. summaryData: {
  29. type: Array as PropType<Recordable[]>,
  30. default: null,
  31. },
  32. indentSize: propTypes.number.def(24),
  33. canColDrag: propTypes.bool.def(true),
  34. api: {
  35. type: Function as PropType<(...arg: any[]) => Promise<any>>,
  36. default: null,
  37. },
  38. beforeFetch: {
  39. type: Function as PropType<Fn>,
  40. default: null,
  41. },
  42. afterFetch: {
  43. type: Function as PropType<Fn>,
  44. default: null,
  45. },
  46. handleSearchInfoFn: {
  47. type: Function as PropType<Fn>,
  48. default: null,
  49. },
  50. fetchSetting: {
  51. type: Object as PropType<FetchSetting>,
  52. default: () => {
  53. return FETCH_SETTING;
  54. },
  55. },
  56. // 立即请求接口
  57. immediate: propTypes.bool.def(true),
  58. emptyDataIsShowTable: propTypes.bool.def(true),
  59. // 额外的请求参数
  60. searchInfo: {
  61. type: Object as PropType<Recordable>,
  62. default: null,
  63. },
  64. // 默认的排序参数
  65. defSort: {
  66. type: Object as PropType<Recordable>,
  67. default: null,
  68. },
  69. // 使用搜索表单
  70. useSearchForm: propTypes.bool,
  71. // 表单配置
  72. formConfig: {
  73. type: Object as PropType<Partial<FormProps>>,
  74. default: null,
  75. },
  76. columns: {
  77. type: [Array] as PropType<BasicColumn[]>,
  78. default: () => [],
  79. },
  80. showIndexColumn: propTypes.bool.def(true),
  81. indexColumnProps: {
  82. type: Object as PropType<BasicColumn>,
  83. default: null,
  84. },
  85. showActionColumn: {
  86. type: Boolean,
  87. default: true,
  88. },
  89. actionColumn: {
  90. type: Object as PropType<BasicColumn>,
  91. default: null,
  92. },
  93. ellipsis: propTypes.bool.def(true),
  94. canResize: propTypes.bool.def(true),
  95. clearSelectOnPageChange: propTypes.bool,
  96. resizeHeightOffset: propTypes.number.def(0),
  97. rowSelection: {
  98. type: Object as PropType<TableRowSelection | null>,
  99. default: null,
  100. },
  101. title: {
  102. type: [String, Function] as PropType<string | ((data: Recordable) => string)>,
  103. default: null,
  104. },
  105. titleHelpMessage: {
  106. type: [String, Array] as PropType<string | string[]>,
  107. },
  108. minHeight: propTypes.number,
  109. maxHeight: propTypes.number,
  110. // 代码逻辑说明: 【TV360X-116】内嵌风格字段较多时表格错位
  111. expandColumnWidth: propTypes.number.def(48),
  112. // 统一设置列最大宽度
  113. maxColumnWidth: propTypes.number,
  114. dataSource: {
  115. type: Array as PropType<Recordable[]>,
  116. default: null,
  117. },
  118. rowKey: {
  119. type: [String, Function] as PropType<string | ((record: Recordable) => string)>,
  120. default: '',
  121. },
  122. bordered: propTypes.bool,
  123. pagination: {
  124. type: [Object, Boolean] as PropType<PaginationProps | boolean>,
  125. default: null,
  126. },
  127. loading: propTypes.bool,
  128. rowClassName: {
  129. type: Function as PropType<(record: TableCustomRecord<any>, index: number) => string>,
  130. },
  131. scroll: {
  132. // 代码逻辑说明: 【issues/1188】BasicTable加上scrollToFirstRowOnChange类型定义
  133. type: Object as PropType<{ x?: number | true | string; y?: number | string; scrollToFirstRowOnChange?: boolean }>,
  134. default: null,
  135. },
  136. beforeEditSubmit: {
  137. type: Function as PropType<(data: { record: Recordable; index: number; key: string | number; value: any }) => Promise<any>>,
  138. },
  139. size: {
  140. type: String as PropType<SizeType>,
  141. default: DEFAULT_SIZE,
  142. },
  143. expandedRowKeys: {
  144. type: Array,
  145. default: null,
  146. },
  147. defaultBodyCellText: {
  148. type: String,
  149. default: COLUMN_DEFAULT_TEXT,
  150. },
  151. };