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,7 +102,13 @@ | ||
102 | }); | 102 | }); |
103 | 103 | ||
104 | const { getLoading, setLoading } = useLoading(getProps); | 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 | const { | 113 | const { |
108 | getRowSelection, | 114 | getRowSelection, |
@@ -229,6 +235,8 @@ | @@ -229,6 +235,8 @@ | ||
229 | getCacheColumns, | 235 | getCacheColumns, |
230 | emit, | 236 | emit, |
231 | updateTableData, | 237 | updateTableData, |
238 | + setShowPagination, | ||
239 | + getShowPagination, | ||
232 | getSize: () => { | 240 | getSize: () => { |
233 | return unref(getBindValues).size as SizeType; | 241 | return unref(getBindValues).size as SizeType; |
234 | }, | 242 | }, |
src/components/Table/src/components/settings/ColumnSetting.vue
@@ -211,18 +211,17 @@ | @@ -211,18 +211,17 @@ | ||
211 | cachePlainOptions.value = columns; | 211 | cachePlainOptions.value = columns; |
212 | state.defaultCheckList = checkList; | 212 | state.defaultCheckList = checkList; |
213 | } else { | 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 | unref(plainOptions).forEach((item: BasicColumn) => { | 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 | if (findItem) { | 220 | if (findItem) { |
221 | item.fixed = findItem.fixed; | 221 | item.fixed = findItem.fixed; |
222 | } | 222 | } |
223 | }); | 223 | }); |
224 | } | 224 | } |
225 | - | ||
226 | state.checkedList = checkList; | 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,13 +27,16 @@ function itemRender({ page, type, originalElement }: ItemRender) { | ||
27 | export function usePagination(refProps: ComputedRef<BasicTableProps>) { | 27 | export function usePagination(refProps: ComputedRef<BasicTableProps>) { |
28 | const configRef = ref<PaginationProps>({}); | 28 | const configRef = ref<PaginationProps>({}); |
29 | 29 | ||
30 | + const show = ref(true); | ||
31 | + | ||
30 | const { t } = useI18n(); | 32 | const { t } = useI18n(); |
31 | const getPaginationInfo = computed((): PaginationProps | boolean => { | 33 | const getPaginationInfo = computed((): PaginationProps | boolean => { |
32 | const { pagination } = unref(refProps); | 34 | const { pagination } = unref(refProps); |
33 | 35 | ||
34 | - if (isBoolean(pagination) && !pagination) { | 36 | + if (!unref(show) || (isBoolean(pagination) && !pagination)) { |
35 | return false; | 37 | return false; |
36 | } | 38 | } |
39 | + | ||
37 | return { | 40 | return { |
38 | current: 1, | 41 | current: 1, |
39 | pageSize: PAGE_SIZE, | 42 | pageSize: PAGE_SIZE, |
@@ -60,5 +63,14 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) { | @@ -60,5 +63,14 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) { | ||
60 | function getPagination() { | 63 | function getPagination() { |
61 | return unref(getPaginationInfo); | 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,6 +121,12 @@ export function useTable( | ||
121 | getForm: () => { | 121 | getForm: () => { |
122 | return unref(formRef) as FormActionType; | 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 | return [register, methods]; | 132 | return [register, methods]; |
src/components/Table/src/types/table.ts
@@ -102,6 +102,8 @@ export interface TableActionType { | @@ -102,6 +102,8 @@ export interface TableActionType { | ||
102 | getCacheColumns: () => BasicColumn[]; | 102 | getCacheColumns: () => BasicColumn[]; |
103 | emit?: EmitType; | 103 | emit?: EmitType; |
104 | updateTableData: (index: number, key: string, value: any) => Recordable; | 104 | updateTableData: (index: number, key: string, value: any) => Recordable; |
105 | + setShowPagination: (show: boolean) => Promise<void>; | ||
106 | + getShowPagination: () => boolean; | ||
105 | } | 107 | } |
106 | 108 | ||
107 | export interface FetchSetting { | 109 | export interface FetchSetting { |