fix(table): fix table setting error #162
This commit is contained in:
parent
a7a8b894c1
commit
a2c89d2e84
|
|
@ -102,7 +102,13 @@
|
|||
});
|
||||
|
||||
const { getLoading, setLoading } = useLoading(getProps);
|
||||
const { getPaginationInfo, getPagination, setPagination } = usePagination(getProps);
|
||||
const {
|
||||
getPaginationInfo,
|
||||
getPagination,
|
||||
setPagination,
|
||||
setShowPagination,
|
||||
getShowPagination,
|
||||
} = usePagination(getProps);
|
||||
|
||||
const {
|
||||
getRowSelection,
|
||||
|
|
@ -229,6 +235,8 @@
|
|||
getCacheColumns,
|
||||
emit,
|
||||
updateTableData,
|
||||
setShowPagination,
|
||||
getShowPagination,
|
||||
getSize: () => {
|
||||
return unref(getBindValues).size as SizeType;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -211,18 +211,17 @@
|
|||
cachePlainOptions.value = columns;
|
||||
state.defaultCheckList = checkList;
|
||||
} else {
|
||||
const fixedColumns = columns.filter((item) =>
|
||||
Reflect.has(item, 'fixed')
|
||||
) as BasicColumn[];
|
||||
// const fixedColumns = columns.filter((item) =>
|
||||
// Reflect.has(item, 'fixed')
|
||||
// ) as BasicColumn[];
|
||||
|
||||
unref(plainOptions).forEach((item: BasicColumn) => {
|
||||
const findItem = fixedColumns.find((fCol) => fCol.dataIndex === item.dataIndex);
|
||||
const findItem = columns.find((col: BasicColumn) => col.dataIndex === item.dataIndex);
|
||||
if (findItem) {
|
||||
item.fixed = findItem.fixed;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
state.checkedList = checkList;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,13 +27,16 @@ function itemRender({ page, type, originalElement }: ItemRender) {
|
|||
export function usePagination(refProps: ComputedRef<BasicTableProps>) {
|
||||
const configRef = ref<PaginationProps>({});
|
||||
|
||||
const show = ref(true);
|
||||
|
||||
const { t } = useI18n();
|
||||
const getPaginationInfo = computed((): PaginationProps | boolean => {
|
||||
const { pagination } = unref(refProps);
|
||||
|
||||
if (isBoolean(pagination) && !pagination) {
|
||||
if (!unref(show) || (isBoolean(pagination) && !pagination)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
current: 1,
|
||||
pageSize: PAGE_SIZE,
|
||||
|
|
@ -60,5 +63,14 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) {
|
|||
function getPagination() {
|
||||
return unref(getPaginationInfo);
|
||||
}
|
||||
return { getPagination, getPaginationInfo, setPagination };
|
||||
|
||||
function getShowPagination() {
|
||||
return unref(show);
|
||||
}
|
||||
|
||||
async function setShowPagination(flag: boolean) {
|
||||
show.value = flag;
|
||||
}
|
||||
|
||||
return { getPagination, getPaginationInfo, setShowPagination, getShowPagination, setPagination };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,12 @@ export function useTable(
|
|||
getForm: () => {
|
||||
return unref(formRef) as FormActionType;
|
||||
},
|
||||
setShowPagination: async (show: boolean) => {
|
||||
getTableInstance().setShowPagination(show);
|
||||
},
|
||||
getShowPagination: () => {
|
||||
return getTableInstance().getShowPagination();
|
||||
},
|
||||
};
|
||||
|
||||
return [register, methods];
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ export interface TableActionType {
|
|||
getCacheColumns: () => BasicColumn[];
|
||||
emit?: EmitType;
|
||||
updateTableData: (index: number, key: string, value: any) => Recordable;
|
||||
setShowPagination: (show: boolean) => Promise<void>;
|
||||
getShowPagination: () => boolean;
|
||||
}
|
||||
|
||||
export interface FetchSetting {
|
||||
|
|
|
|||
Loading…
Reference in New Issue