|
|
|
@ -8,7 +8,7 @@ import { useMessage } from '/@/hooks/web/useMessage'; |
|
|
|
|
import { useMethods } from '/@/hooks/system/useMethods'; |
|
|
|
|
import { useDesign } from '/@/hooks/web/useDesign'; |
|
|
|
|
import { filterObj } from '/@/utils/common/compUtils'; |
|
|
|
|
const { handleExportXls, handleImportXls,handleExportXlsMb } = useMethods(); |
|
|
|
|
const { handleExportXls, handleImportXls,handleExportXlsMb,handleExportXlstj } = useMethods(); |
|
|
|
|
|
|
|
|
|
// 定义 useListPage 方法所需参数
|
|
|
|
|
interface ListPageOptions { |
|
|
|
@ -33,6 +33,13 @@ interface ListPageOptions { |
|
|
|
|
//导出参数
|
|
|
|
|
params?: object; |
|
|
|
|
}; |
|
|
|
|
exportConfigtj?: { |
|
|
|
|
url: string | (() => string); |
|
|
|
|
// 导出文件名
|
|
|
|
|
name?: string | (() => string); |
|
|
|
|
//导出参数
|
|
|
|
|
params?: object; |
|
|
|
|
}; |
|
|
|
|
// 导入配置
|
|
|
|
|
importConfig?: { |
|
|
|
|
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的
|
|
|
|
@ -158,6 +165,51 @@ export function useListPage(options: ListPageOptions) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 导出奖项推荐数据 excel
|
|
|
|
|
async function onExportXlstj() { |
|
|
|
|
//update-begin---author:wangshuai ---date:20220411 for:导出新增自定义参数------------
|
|
|
|
|
let { url, name, params } = options?.exportConfigtj ?? {}; |
|
|
|
|
let realUrl = typeof url === 'function' ? url() : url; |
|
|
|
|
if (realUrl) { |
|
|
|
|
let title = typeof name === 'function' ? name() : name; |
|
|
|
|
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知-
|
|
|
|
|
let paramsForm:any = {}; |
|
|
|
|
try { |
|
|
|
|
paramsForm = await getForm().validate(); |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error(e); |
|
|
|
|
} |
|
|
|
|
//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'}); |
|
|
|
|
} |
|
|
|
|
//update-begin-author:liusq date:20230410 for: [/issues/409]导出功能没有按排序结果导出,设置导出默认排序,创建时间倒序
|
|
|
|
|
|
|
|
|
|
//如果参数不为空,则整合到一起
|
|
|
|
|
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出动态设置mainId
|
|
|
|
|
if (params) { |
|
|
|
|
Object.keys(params).map((k) => { |
|
|
|
|
let temp = (params as object)[k]; |
|
|
|
|
if (temp) { |
|
|
|
|
paramsForm[k] = unref(temp); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
//update-end-author:taoyan date:20220507 for: erp代码生成 子表 导出动态设置mainId
|
|
|
|
|
if (selectedRowKeys.value && selectedRowKeys.value.length > 0) { |
|
|
|
|
paramsForm['selections'] = selectedRowKeys.value.join(','); |
|
|
|
|
} |
|
|
|
|
console.log() |
|
|
|
|
return handleExportXlstj(title as string, realUrl, filterObj(paramsForm)); |
|
|
|
|
//update-end---author:wangshuai ---date:20220411 for:导出新增自定义参数--------------
|
|
|
|
|
} else { |
|
|
|
|
$message.createMessage.warn('没有传递 exportConfig.url 参数'); |
|
|
|
|
return Promise.reject(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 导入 excel
|
|
|
|
|
function onImportXls(file) { |
|
|
|
|
let { url, success } = options?.importConfig ?? {}; |
|
|
|
@ -220,6 +272,7 @@ export function useListPage(options: ListPageOptions) { |
|
|
|
|
...$message, |
|
|
|
|
onExportXls, |
|
|
|
|
onExportXlsMb, |
|
|
|
|
onExportXlstj, |
|
|
|
|
onImportXls, |
|
|
|
|
doRequest, |
|
|
|
|
doDeleteRecord, |
|
|
|
|