Commit b58581cf by yuzhenWang

对接电子薪资单的导出

parent b9a9ca92
......@@ -118,6 +118,15 @@ export function checkSalaryApi(data) {
data: data
})
}
// 电子薪资单导出
export function electronicExport(data) {
return request({
url: '/csf/api/salary/salary/export',
method: 'post',
data: data,
})
}
// 下载选中的发佣数据
export function downloadPolicyFortune(data) {
......
......@@ -149,7 +149,8 @@ import {
delSalaryApi,
electronicSalaryListApi,
pushSalaryApi,
checkSalaryApi
checkSalaryApi,
electronicExport
} from '@/api/salary'
import SearchForm from '@/components/SearchForm/SearchForm.vue'
import { loadDicts, getDictLabel } from '@/utils/useDict'
......@@ -707,14 +708,30 @@ const handlePush = async () => {
}
const handleExport = async () => {
ElMessage.info('导出待开发')
return
// ElMessage.info('导出待开发')
// return
// 获取搜索参数
const params = searchFormRef.value?.getFormData() || {}
const response = await exportReceivedFortune(params)
const response = await electronicExport(params)
console.log('response', response)
// 创建隐藏的下载链接
const link = document.createElement('a')
link.href = response.data.url
link.target = '_blank' // 新窗口打开
// 设置下载文件名(重要)
// 从URL中提取文件名,或者使用返回的文件名
const fileName = '电子薪资单'
link.download = fileName
// 触发下载
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
// 文件名设置为应收款导出_yyyy-MM-dd hh:mm:ss.xlsx,不需要-,用字符串
const fileName = `应收款导出_${new Date().toLocaleString().replace(/\//g, '').replace(/:/g, '').replace(/\s/g, '')}.xlsx`
await safeDownload(response, fileName, 'application/vnd.ms-excel;charset=utf-8')
// const fileName = `电子薪资单导出_${new Date().toLocaleString().replace(/\//g, '').replace(/:/g, '').replace(/\s/g, '')}.xlsx`
// await safeDownload(response, fileName, 'application/vnd.ms-excel;charset=utf-8')
}
const handleReset = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment