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