[/issues/409]导出功能没有按排序结果导出,支持默认排序、自定义排序导出
parent
7efc12fc65
commit
7699729a89
20339
pnpm-lock.yaml
20339
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -130,6 +130,7 @@
|
|||
reload,
|
||||
getAutoCreateKey,
|
||||
updateTableData,
|
||||
getBeforeFetch,
|
||||
} = useDataSource(
|
||||
getProps,
|
||||
{
|
||||
|
@ -274,6 +275,7 @@
|
|||
getSize: () => {
|
||||
return unref(getBindValues).size as SizeType;
|
||||
},
|
||||
getBeforeFetch,
|
||||
};
|
||||
createTableContext({ ...tableAction, wrapRef, getBindValues });
|
||||
|
||||
|
|
|
@ -313,6 +313,21 @@ export function useDataSource(
|
|||
return await fetch(opt);
|
||||
}
|
||||
|
||||
async function getBeforeFetch() {
|
||||
const { beforeFetch } = unref(propsRef);
|
||||
const { sortInfo = {}, filterInfo } = searchState;
|
||||
|
||||
let params: Recordable = {
|
||||
...sortInfo,
|
||||
...filterInfo,
|
||||
};
|
||||
if (beforeFetch && isFunction(beforeFetch)) {
|
||||
params = (await beforeFetch(params)) || params;
|
||||
}
|
||||
console.log(params);
|
||||
return params;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
useTimeoutFn(() => {
|
||||
unref(propsRef).immediate && fetch();
|
||||
|
@ -334,5 +349,6 @@ export function useDataSource(
|
|||
insertTableDataRecord,
|
||||
findTableDataRecord,
|
||||
handleTableChange,
|
||||
getBeforeFetch,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -161,7 +161,10 @@ export function useTable(tableProps?: Props): [
|
|||
},
|
||||
getTableRef: () => {
|
||||
return getTableRef();
|
||||
}
|
||||
},
|
||||
getBeforeFetch: async () => {
|
||||
return await getTableInstance().getBeforeFetch();
|
||||
},
|
||||
};
|
||||
|
||||
return [register, methods];
|
||||
|
|
|
@ -114,6 +114,7 @@ export interface TableActionType {
|
|||
setShowPagination: (show: boolean) => Promise<void>;
|
||||
getShowPagination: () => boolean;
|
||||
setCacheColumnsByField?: (dataIndex: string | undefined, value: BasicColumn) => void;
|
||||
getBeforeFetch: () => Promise<{}>;
|
||||
}
|
||||
|
||||
export interface FetchSetting {
|
||||
|
|
|
@ -59,7 +59,7 @@ export function useListPage(options: ListPageOptions) {
|
|||
|
||||
const tableContext = useListTable(options.tableProps);
|
||||
|
||||
const [, { getForm, reload, setLoading }, { selectedRowKeys }] = tableContext;
|
||||
const [, { getForm, reload, setLoading, getBeforeFetch }, { selectedRowKeys }] = tableContext;
|
||||
|
||||
// 导出 excel
|
||||
async function onExportXls() {
|
||||
|
@ -78,9 +78,8 @@ export function useListPage(options: ListPageOptions) {
|
|||
//update-end-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知-
|
||||
|
||||
//update-begin-author:liusq date:20230410 for:[/issues/409]导出功能没有按排序结果导出,设置导出默认排序,创建时间倒序
|
||||
if(!paramsForm?.column){
|
||||
Object.assign(paramsForm,{column:'createTime',order:'desc'});
|
||||
}
|
||||
const bfParams = await getBeforeFetch();
|
||||
Object.assign(paramsForm, bfParams);
|
||||
//update-begin-author:liusq date:20230410 for: [/issues/409]导出功能没有按排序结果导出,设置导出默认排序,创建时间倒序
|
||||
|
||||
//如果参数不为空,则整合到一起
|
||||
|
|
Loading…
Reference in New Issue