From 9a3881dc8859bac1d231c3bf74caf97dfbbf6c66 Mon Sep 17 00:00:00 2001
From: fengyuan_yang <1976974459@qq.com>
Date: Fri, 22 May 2026 14:53:50 +0800
Subject: [PATCH] =?UTF-8?q?2026-05-21=20=E5=AE=9E=E6=97=B6=E5=BA=93?=
=?UTF-8?q?=E5=AD=98=E5=AF=BC=E5=87=BA=EF=BC=8C=E8=B6=8510000=E6=9D=A1?=
=?UTF-8?q?=E7=9A=84=EF=BC=8C=E5=AF=BC=E4=B8=8D=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/wms/wms.js | 1 +
src/views/modules/print/rePrintPoPart.vue | 108 ++++++++++++++--------
2 files changed, 68 insertions(+), 41 deletions(-)
diff --git a/src/api/wms/wms.js b/src/api/wms/wms.js
index ae09987..81ac26d 100644
--- a/src/api/wms/wms.js
+++ b/src/api/wms/wms.js
@@ -8,6 +8,7 @@ export const getPoPartLabelData = data => createAPI(`wmsPrint/getPoPartLabelData
export const deletePoPartLabelData = data => createAPI(`wmsPrint/deletePoPartLabelData`,'POST',data)
export const getKuCunLabelData = data => createAPI(`wmsPrint/getKuCunLabelData`,'POST',data)
+export const exportKuCunLabelData = data => createAPI(`wmsPrint/exportKuCunLabelData`,'POST',data, 'download')
export const freezeStatusInventoryStock = data => createAPI(`wmsPrint/freezeStatusInventoryStock`,'POST',data)
// 更新库存标签属性
export const updateInventoryStockAttribute = data => createAPI(`wmsPrint/updateInventoryStockAttribute`,'POST',data)
diff --git a/src/views/modules/print/rePrintPoPart.vue b/src/views/modules/print/rePrintPoPart.vue
index 845f2b6..45973ca 100644
--- a/src/views/modules/print/rePrintPoPart.vue
+++ b/src/views/modules/print/rePrintPoPart.vue
@@ -150,24 +150,14 @@
@click="freezeStatus">
冻结
-
-
- 导出
-
-
+
+ 导出
+
@@ -525,6 +515,7 @@ import {rollPrint} from '@/api/finishedProductWarehouse/rollPrint.js'
import {
getInboundQcResultData,
getKuCunLabelData,
+ exportKuCunLabelData,
updateInventoryStockAttribute,
getWarehouseList,
freezeStatusInventoryStock,
@@ -992,10 +983,7 @@ export default {
printLoading: false,
multiPartNoTip: '',
// 导出相关
- exportData: [],
exportName: "实时库存数据",
- exportHeader: ["实时库存数据"],
- exportFooter: [],
exportLoading: false
}
},
@@ -1518,31 +1506,47 @@ export default {
})
},
// 导出相关方法
- exportFields() {
- let json = {}
- this.columnList.forEach((item) => {
- json[item.columnLabel] = item.columnProp
- })
- return json
- },
- async createExportData() {
- // 构建查询参数,获取所有数据(不分页)
+ async exportInventoryData() {
+ this.startDownload()
const params = {
- ...this.searchData,
- page: 1,
- limit: 999999 // 获取所有数据
+ ...this.searchData
}
try {
- const {data} = await getKuCunLabelData(params)
- if (data.code === 0) {
- return data.page.list || []
- } else {
- this.$message.error('获取导出数据失败')
- return []
+ const response = await exportKuCunLabelData(params)
+ const fileBlob = response && response.data ? response.data : null
+ if (!fileBlob || fileBlob.size === 0) {
+ throw new Error('导出文件为空')
}
+ const contentType = fileBlob.type || ''
+ if (contentType.indexOf('application/json') > -1) {
+ const text = await fileBlob.text()
+ let errMsg = '导出失败'
+ try {
+ const json = JSON.parse(text)
+ errMsg = json.msg || json.message || errMsg
+ } catch (e) {
+ errMsg = text || errMsg
+ }
+ throw new Error(errMsg)
+ }
+
+ const disposition = response.headers && response.headers['content-disposition']
+ const defaultFileName = `${this.exportName}.xlsx`
+ const fileName = this.parseDownloadFileName(disposition) || defaultFileName
+ const linkNode = document.createElement('a')
+ const url = URL.createObjectURL(fileBlob)
+ linkNode.href = url
+ linkNode.download = fileName
+ linkNode.style.display = 'none'
+ document.body.appendChild(linkNode)
+ linkNode.click()
+ document.body.removeChild(linkNode)
+ URL.revokeObjectURL(url)
+ this.$message.success('导出成功')
} catch (error) {
- this.$message.error('获取导出数据失败:' + error.message)
- return []
+ this.$message.error('导出失败:' + (error.message || '请稍后重试'))
+ } finally {
+ this.finishDownload()
}
},
startDownload() {
@@ -1561,6 +1565,28 @@ export default {
this._exportLoadingInstance.close()
this._exportLoadingInstance = null
}
+ },
+ parseDownloadFileName(disposition) {
+ if (!disposition) {
+ return ''
+ }
+ let fileName = ''
+ const utf8Match = disposition.match(/filename\*=UTF-8''([^;]+)/i)
+ if (utf8Match && utf8Match[1]) {
+ fileName = utf8Match[1]
+ } else {
+ const normalMatch = disposition.match(/filename="?([^"]+)"?/i)
+ fileName = normalMatch && normalMatch[1] ? normalMatch[1] : ''
+ }
+
+ if (!fileName) {
+ return ''
+ }
+ try {
+ return decodeURIComponent(fileName)
+ } catch (e) {
+ return fileName
+ }
}
},
created() {