feat: 增加顺丰月结列表,支持导出、结算和补填运费
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
77e8c78cb6
commit
a81f177cb6
4 files changed
+532
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import ExcelJS from 'exceljs'
|
||||
import FileSaver from 'file-saver'
|
||||
|
||||
const HEADERS = ['顺丰单号', '创建人', '创建时间', '结算状态', '运费', '结算时间']
|
||||
|
||||
export function buildSfExpressExportRows(list: Array<Record<string, string>>) {
|
||||
return list.map((row) => [
|
||||
row.waybillNo || '—',
|
||||
row.createByName || '—',
|
||||
row.createTime || '—',
|
||||
row.settleStatusLabel || '—',
|
||||
row.freightAmountLabel || '—',
|
||||
row.settleTime || '—'
|
||||
])
|
||||
}
|
||||
|
||||
export async function saveSfExpressSettlementWorkbook(list: Array<Record<string, string>>) {
|
||||
const workbook = new ExcelJS.Workbook()
|
||||
const sheet = workbook.addWorksheet('顺丰月结')
|
||||
sheet.addRow(HEADERS)
|
||||
buildSfExpressExportRows(list).forEach((line) => sheet.addRow(line))
|
||||
const buffer = await workbook.xlsx.writeBuffer()
|
||||
const blob = new Blob([buffer], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
})
|
||||
const stamp = new Date()
|
||||
const pad = (value: number) => String(value).padStart(2, '0')
|
||||
const name = `顺丰月结-${stamp.getFullYear()}${pad(stamp.getMonth() + 1)}${pad(stamp.getDate())}${pad(stamp.getHours())}${pad(stamp.getMinutes())}${pad(stamp.getSeconds())}.xlsx`
|
||||
FileSaver.saveAs(blob, name)
|
||||
}
|
||||
Reference in new issue
Block a user