feat: P0-2 订单BOM计算单+Excel导出(openpyxl)
This commit is contained in:
@@ -41,3 +41,13 @@ export async function api<T = any>(method: string, url: string, body?: object):
|
||||
const res = await http.request({ method, url, data: body })
|
||||
return res.data.data as T
|
||||
}
|
||||
|
||||
/** 下载二进制文件(自动带 token),filename 为保存文件名 */
|
||||
export async function apiDownload(url: string, filename: string): Promise<void> {
|
||||
const res = await http.get(url, { responseType: 'blob' })
|
||||
const link = document.createElement('a')
|
||||
link.href = URL.createObjectURL(res.data)
|
||||
link.download = filename
|
||||
link.click()
|
||||
URL.revokeObjectURL(link.href)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user