This commit is contained in:
qsh
2025-11-04 14:06:59 +08:00
parent cdb497977b
commit 0266fdf2d4
4 changed files with 89 additions and 5 deletions

View File

@@ -251,6 +251,7 @@ import DialogBatchAudit from './DialogBatchAudit.vue'
import { removeNullField } from '@/utils'
import { dateFormatter } from '@/utils/formatTime'
import { useAppStore } from '@/store/modules/app'
import { exportArrayToExcel } from '@/utils/index'
const afterSaleAuditDialog = ref()
@@ -366,8 +367,37 @@ async function afterSalesUpload(data) {
const fd = new FormData()
fd.append('file', data.file)
try {
await AfterSaleApi.importAfterSales(fd)
message.success('导入成功')
const resp = await AfterSaleApi.importAfterSales(fd)
debugger
if (resp && resp.data && resp.data.length) {
const succList = resp.data.filter((item) => item.success)
const failList = resp.data.filter((item) => !item.success)
let msg = `导入完成!成功 ${succList.length} 条,失败 ${failList.length} 条。`
if (failList.length) {
// 如果有失败,提示下载失败文件
msg += '\n请点击消息下载失败明细进行查看。'
}
ElNotification({
title: '导入结果',
message: msg,
type: 'info',
duration: 0,
onClick: () => {
if (failList.length) {
// 将failList生成文件使用前端下载
exportArrayToExcel(failList, `售后导入失败明细${new Date().getTime()}`, [
{ title: '手机号', key: 'phone' },
{ title: '售后原因', key: 'reason' },
{ title: '退款金额', key: 'refundAmount' },
{ title: '提成扣款', key: 'percentageDeductAmount' },
{ title: '解决方案', key: 'solution' },
{ title: '备注', key: 'remark' },
{ title: '失败原因', key: 'message' }
])
}
}
})
}
} finally {
uploading.value = false
getList()