Commit 8447331197fc0975f32f5df9cc306ece4a09f400
Committed by
GitHub
1 parent
787bc462
chore: table size放到settings (#1294)
Showing
4 changed files
with
19 additions
and
3 deletions
src/components/Table/src/BasicTable.vue
@@ -222,7 +222,6 @@ | @@ -222,7 +222,6 @@ | ||
222 | const getBindValues = computed(() => { | 222 | const getBindValues = computed(() => { |
223 | const dataSource = unref(getDataSourceRef); | 223 | const dataSource = unref(getDataSourceRef); |
224 | let propsData: Recordable = { | 224 | let propsData: Recordable = { |
225 | - size: 'middle', | ||
226 | // ...(dataSource.length === 0 ? { getPopupContainer: () => document.body } : {}), | 225 | // ...(dataSource.length === 0 ? { getPopupContainer: () => document.body } : {}), |
227 | ...attrs, | 226 | ...attrs, |
228 | customRow, | 227 | customRow, |
src/components/Table/src/const.ts
@@ -2,7 +2,14 @@ import componentSetting from '/@/settings/componentSetting'; | @@ -2,7 +2,14 @@ import componentSetting from '/@/settings/componentSetting'; | ||
2 | 2 | ||
3 | const { table } = componentSetting; | 3 | const { table } = componentSetting; |
4 | 4 | ||
5 | -const { pageSizeOptions, defaultPageSize, fetchSetting, defaultSortFn, defaultFilterFn } = table; | 5 | +const { |
6 | + pageSizeOptions, | ||
7 | + defaultPageSize, | ||
8 | + fetchSetting, | ||
9 | + defaultSize, | ||
10 | + defaultSortFn, | ||
11 | + defaultFilterFn, | ||
12 | +} = table; | ||
6 | 13 | ||
7 | export const ROW_KEY = 'key'; | 14 | export const ROW_KEY = 'key'; |
8 | 15 | ||
@@ -15,6 +22,9 @@ export const PAGE_SIZE = defaultPageSize; | @@ -15,6 +22,9 @@ export const PAGE_SIZE = defaultPageSize; | ||
15 | // Common interface field settings | 22 | // Common interface field settings |
16 | export const FETCH_SETTING = fetchSetting; | 23 | export const FETCH_SETTING = fetchSetting; |
17 | 24 | ||
25 | +// Default Size | ||
26 | +export const DEFAULT_SIZE = defaultSize; | ||
27 | + | ||
18 | // Configure general sort function | 28 | // Configure general sort function |
19 | export const DEFAULT_SORT_FN = defaultSortFn; | 29 | export const DEFAULT_SORT_FN = defaultSortFn; |
20 | 30 |
src/components/Table/src/props.ts
@@ -7,9 +7,10 @@ import type { | @@ -7,9 +7,10 @@ import type { | ||
7 | SorterResult, | 7 | SorterResult, |
8 | TableCustomRecord, | 8 | TableCustomRecord, |
9 | TableRowSelection, | 9 | TableRowSelection, |
10 | + SizeType, | ||
10 | } from './types/table'; | 11 | } from './types/table'; |
11 | import type { FormProps } from '/@/components/Form'; | 12 | import type { FormProps } from '/@/components/Form'; |
12 | -import { DEFAULT_FILTER_FN, DEFAULT_SORT_FN, FETCH_SETTING } from './const'; | 13 | +import { DEFAULT_FILTER_FN, DEFAULT_SORT_FN, FETCH_SETTING, DEFAULT_SIZE } from './const'; |
13 | import { propTypes } from '/@/utils/propTypes'; | 14 | import { propTypes } from '/@/utils/propTypes'; |
14 | 15 | ||
15 | export const basicProps = { | 16 | export const basicProps = { |
@@ -141,4 +142,8 @@ export const basicProps = { | @@ -141,4 +142,8 @@ export const basicProps = { | ||
141 | }) => Promise<any> | 142 | }) => Promise<any> |
142 | >, | 143 | >, |
143 | }, | 144 | }, |
145 | + size: { | ||
146 | + type: String as PropType<SizeType>, | ||
147 | + default: DEFAULT_SIZE, | ||
148 | + }, | ||
144 | }; | 149 | }; |
src/settings/componentSetting.ts
@@ -21,6 +21,8 @@ export default { | @@ -21,6 +21,8 @@ export default { | ||
21 | pageSizeOptions: ['10', '50', '80', '100'], | 21 | pageSizeOptions: ['10', '50', '80', '100'], |
22 | // Default display quantity on one page | 22 | // Default display quantity on one page |
23 | defaultPageSize: 10, | 23 | defaultPageSize: 10, |
24 | + // Default Size | ||
25 | + defaultSize: 'middle', | ||
24 | // Custom general sort function | 26 | // Custom general sort function |
25 | defaultSortFn: (sortInfo: SorterResult) => { | 27 | defaultSortFn: (sortInfo: SorterResult) => { |
26 | const { field, order } = sortInfo; | 28 | const { field, order } = sortInfo; |