From b55d39b755e290505b6ece3cd6c256aec82c0064 Mon Sep 17 00:00:00 2001 From: DZero Date: Thu, 27 Oct 2022 16:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=AF=BC=E5=87=BA=E5=8F=82=E6=95=B0=E7=9A=84=E8=B5=8B?= =?UTF-8?q?=E5=80=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/system/useListPage.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hooks/system/useListPage.ts b/src/hooks/system/useListPage.ts index 6d09d6c..3f25b74 100644 --- a/src/hooks/system/useListPage.ts +++ b/src/hooks/system/useListPage.ts @@ -24,7 +24,7 @@ interface ListPageOptions { // 导出文件名 name?: string | (() => string); //导出参数 - params?: object; + params?: object | (() => string); }; // 导入配置 importConfig?: { @@ -64,10 +64,11 @@ export function useListPage(options: ListPageOptions) { // 导出 excel async function onExportXls() { //update-begin---author:wangshuai ---date:20220411 for:导出新增自定义参数------------ - let { url, name, params } = options?.exportConfig ?? {}; - let realUrl = typeof url === 'function' ? url() : url; + const { url, name, params } = options?.exportConfig ?? {}; + const realParams = typeof params === 'function' ? params() : params; + const realUrl = typeof url === 'function' ? url() : url; if (realUrl) { - let title = typeof name === 'function' ? name() : name; + const title = typeof name === 'function' ? name() : name; //update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知- let paramsForm = {}; try { @@ -78,10 +79,10 @@ export function useListPage(options: ListPageOptions) { //update-end-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知- //如果参数不为空,则整合到一起 //update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出动态设置mainId - if (params) { - Object.keys(params).map((k) => { - let temp = (params as object)[k]; - if (temp) { + if (realParams !== undefined && realParams !== null) { + Object.keys(realParams).map((k) => { + const temp = (realParams as object)[k]; + if (temp !== undefined && temp !== null && temp !== '') { paramsForm[k] = unref(temp); } });