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