Commit a2c89d2e842beb9f15f3fc00d651c42954a57ff7
1 parent
a7a8b894
fix(table): fix table setting error #162
Showing
5 changed files
with
35 additions
and
8 deletions
src/components/Table/src/BasicTable.vue
... | ... | @@ -102,7 +102,13 @@ |
102 | 102 | }); |
103 | 103 | |
104 | 104 | const { getLoading, setLoading } = useLoading(getProps); |
105 | - const { getPaginationInfo, getPagination, setPagination } = usePagination(getProps); | |
105 | + const { | |
106 | + getPaginationInfo, | |
107 | + getPagination, | |
108 | + setPagination, | |
109 | + setShowPagination, | |
110 | + getShowPagination, | |
111 | + } = usePagination(getProps); | |
106 | 112 | |
107 | 113 | const { |
108 | 114 | getRowSelection, |
... | ... | @@ -229,6 +235,8 @@ |
229 | 235 | getCacheColumns, |
230 | 236 | emit, |
231 | 237 | updateTableData, |
238 | + setShowPagination, | |
239 | + getShowPagination, | |
232 | 240 | getSize: () => { |
233 | 241 | return unref(getBindValues).size as SizeType; |
234 | 242 | }, | ... | ... |
src/components/Table/src/components/settings/ColumnSetting.vue
... | ... | @@ -211,18 +211,17 @@ |
211 | 211 | cachePlainOptions.value = columns; |
212 | 212 | state.defaultCheckList = checkList; |
213 | 213 | } else { |
214 | - const fixedColumns = columns.filter((item) => | |
215 | - Reflect.has(item, 'fixed') | |
216 | - ) as BasicColumn[]; | |
214 | + // const fixedColumns = columns.filter((item) => | |
215 | + // Reflect.has(item, 'fixed') | |
216 | + // ) as BasicColumn[]; | |
217 | 217 | |
218 | 218 | unref(plainOptions).forEach((item: BasicColumn) => { |
219 | - const findItem = fixedColumns.find((fCol) => fCol.dataIndex === item.dataIndex); | |
219 | + const findItem = columns.find((col: BasicColumn) => col.dataIndex === item.dataIndex); | |
220 | 220 | if (findItem) { |
221 | 221 | item.fixed = findItem.fixed; |
222 | 222 | } |
223 | 223 | }); |
224 | 224 | } |
225 | - | |
226 | 225 | state.checkedList = checkList; |
227 | 226 | } |
228 | 227 | ... | ... |
src/components/Table/src/hooks/usePagination.tsx
... | ... | @@ -27,13 +27,16 @@ function itemRender({ page, type, originalElement }: ItemRender) { |
27 | 27 | export function usePagination(refProps: ComputedRef<BasicTableProps>) { |
28 | 28 | const configRef = ref<PaginationProps>({}); |
29 | 29 | |
30 | + const show = ref(true); | |
31 | + | |
30 | 32 | const { t } = useI18n(); |
31 | 33 | const getPaginationInfo = computed((): PaginationProps | boolean => { |
32 | 34 | const { pagination } = unref(refProps); |
33 | 35 | |
34 | - if (isBoolean(pagination) && !pagination) { | |
36 | + if (!unref(show) || (isBoolean(pagination) && !pagination)) { | |
35 | 37 | return false; |
36 | 38 | } |
39 | + | |
37 | 40 | return { |
38 | 41 | current: 1, |
39 | 42 | pageSize: PAGE_SIZE, |
... | ... | @@ -60,5 +63,14 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) { |
60 | 63 | function getPagination() { |
61 | 64 | return unref(getPaginationInfo); |
62 | 65 | } |
63 | - return { getPagination, getPaginationInfo, setPagination }; | |
66 | + | |
67 | + function getShowPagination() { | |
68 | + return unref(show); | |
69 | + } | |
70 | + | |
71 | + async function setShowPagination(flag: boolean) { | |
72 | + show.value = flag; | |
73 | + } | |
74 | + | |
75 | + return { getPagination, getPaginationInfo, setShowPagination, getShowPagination, setPagination }; | |
64 | 76 | } | ... | ... |
src/components/Table/src/hooks/useTable.ts
... | ... | @@ -121,6 +121,12 @@ export function useTable( |
121 | 121 | getForm: () => { |
122 | 122 | return unref(formRef) as FormActionType; |
123 | 123 | }, |
124 | + setShowPagination: async (show: boolean) => { | |
125 | + getTableInstance().setShowPagination(show); | |
126 | + }, | |
127 | + getShowPagination: () => { | |
128 | + return getTableInstance().getShowPagination(); | |
129 | + }, | |
124 | 130 | }; |
125 | 131 | |
126 | 132 | return [register, methods]; | ... | ... |
src/components/Table/src/types/table.ts
... | ... | @@ -102,6 +102,8 @@ export interface TableActionType { |
102 | 102 | getCacheColumns: () => BasicColumn[]; |
103 | 103 | emit?: EmitType; |
104 | 104 | updateTableData: (index: number, key: string, value: any) => Recordable; |
105 | + setShowPagination: (show: boolean) => Promise<void>; | |
106 | + getShowPagination: () => boolean; | |
105 | 107 | } |
106 | 108 | |
107 | 109 | export interface FetchSetting { | ... | ... |