Skip to content

Commit a2c89d2

Browse files
committed
fix(table): fix table setting error #162
1 parent a7a8b89 commit a2c89d2

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

src/components/Table/src/BasicTable.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@
102102
});
103103
104104
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);
106112
107113
const {
108114
getRowSelection,
@@ -229,6 +235,8 @@
229235
getCacheColumns,
230236
emit,
231237
updateTableData,
238+
setShowPagination,
239+
getShowPagination,
232240
getSize: () => {
233241
return unref(getBindValues).size as SizeType;
234242
},

src/components/Table/src/components/settings/ColumnSetting.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,17 @@
211211
cachePlainOptions.value = columns;
212212
state.defaultCheckList = checkList;
213213
} 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[];
217217
218218
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);
220220
if (findItem) {
221221
item.fixed = findItem.fixed;
222222
}
223223
});
224224
}
225-
226225
state.checkedList = checkList;
227226
}
228227

src/components/Table/src/hooks/usePagination.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ function itemRender({ page, type, originalElement }: ItemRender) {
2727
export function usePagination(refProps: ComputedRef<BasicTableProps>) {
2828
const configRef = ref<PaginationProps>({});
2929

30+
const show = ref(true);
31+
3032
const { t } = useI18n();
3133
const getPaginationInfo = computed((): PaginationProps | boolean => {
3234
const { pagination } = unref(refProps);
3335

34-
if (isBoolean(pagination) && !pagination) {
36+
if (!unref(show) || (isBoolean(pagination) && !pagination)) {
3537
return false;
3638
}
39+
3740
return {
3841
current: 1,
3942
pageSize: PAGE_SIZE,
@@ -60,5 +63,14 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) {
6063
function getPagination() {
6164
return unref(getPaginationInfo);
6265
}
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 };
6476
}

src/components/Table/src/hooks/useTable.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ export function useTable(
121121
getForm: () => {
122122
return unref(formRef) as FormActionType;
123123
},
124+
setShowPagination: async (show: boolean) => {
125+
getTableInstance().setShowPagination(show);
126+
},
127+
getShowPagination: () => {
128+
return getTableInstance().getShowPagination();
129+
},
124130
};
125131

126132
return [register, methods];

src/components/Table/src/types/table.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export interface TableActionType {
102102
getCacheColumns: () => BasicColumn[];
103103
emit?: EmitType;
104104
updateTableData: (index: number, key: string, value: any) => Recordable;
105+
setShowPagination: (show: boolean) => Promise<void>;
106+
getShowPagination: () => boolean;
105107
}
106108

107109
export interface FetchSetting {

0 commit comments

Comments
 (0)