|
|
@ -339,10 +339,39 @@ async function exportContractDetail(ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 导出开票明细表数据 |
|
|
|
*/ |
|
|
|
async function exportInvoicingDetail(ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
let exportData = await models.InvoiceDetail.findAll({ |
|
|
|
order: [['id', 'DESC']] |
|
|
|
}); |
|
|
|
const { utils: { simpleExcelDown, invoicingDetailsColumnKeys } } = ctx.app.fs; |
|
|
|
let header = []; |
|
|
|
Object.keys(invoicingDetailsColumnKeys).map(key => { |
|
|
|
header.push({ title: invoicingDetailsColumnKeys[key], key: key }); |
|
|
|
}) |
|
|
|
const fileName = `开票明细表_${moment().format('YYYYMMDDHHmmss')}` + '.xlsx' |
|
|
|
const filePath = await simpleExcelDown({ data: exportData, header, fileName: fileName, needIndexCell: false }) |
|
|
|
const fileData = fs.readFileSync(filePath); |
|
|
|
ctx.status = 200; |
|
|
|
ctx.set('Content-Type', 'application/x-xls'); |
|
|
|
ctx.set('Content-disposition', 'attachment; filename=' + encodeURI(fileName)); |
|
|
|
ctx.body = fileData; |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path:${ctx.path},error:${error}`) |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { name: 'ExportAllError', message: '导出开票明细表数据失败' } |
|
|
|
} |
|
|
|
} |
|
|
|
module.exports = { |
|
|
|
getReceivedDetail,//回款
|
|
|
|
getAchievementDetail,//业绩
|
|
|
|
getContractDetail, |
|
|
|
getInvoicingDetail, |
|
|
|
exportContractDetail |
|
|
|
exportContractDetail, |
|
|
|
exportInvoicingDetail |
|
|
|
} |