Browse Source

2026-05-21

实时库存导出,超10000条的,导不出
master
fengyuan_yang 3 weeks ago
parent
commit
9a3881dc88
  1. 1
      src/api/wms/wms.js
  2. 102
      src/views/modules/print/rePrintPoPart.vue

1
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 deletePoPartLabelData = data => createAPI(`wmsPrint/deletePoPartLabelData`,'POST',data)
export const getKuCunLabelData = data => createAPI(`wmsPrint/getKuCunLabelData`,'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 freezeStatusInventoryStock = data => createAPI(`wmsPrint/freezeStatusInventoryStock`,'POST',data)
// 更新库存标签属性 // 更新库存标签属性
export const updateInventoryStockAttribute = data => createAPI(`wmsPrint/updateInventoryStockAttribute`,'POST',data) export const updateInventoryStockAttribute = data => createAPI(`wmsPrint/updateInventoryStockAttribute`,'POST',data)

102
src/views/modules/print/rePrintPoPart.vue

@ -150,24 +150,14 @@
@click="freezeStatus"> @click="freezeStatus">
冻结 冻结
</el-button> </el-button>
<download-excel
:fields="exportFields()"
:data="exportData"
type="xls"
:name="exportName"
:header="exportHeader"
:footer="exportFooter"
:fetch="createExportData"
:before-generate="startDownload"
:before-finish="finishDownload"
worksheet="实时库存数据"
class="export-btn">
<el-button <el-button
class="export-btn"
type="success" type="success"
icon="el-icon-download">
icon="el-icon-download"
:loading="exportLoading"
@click="exportInventoryData">
导出 导出
</el-button> </el-button>
</download-excel>
</div> </div>
</div> </div>
</el-col> </el-col>
@ -525,6 +515,7 @@ import {rollPrint} from '@/api/finishedProductWarehouse/rollPrint.js'
import { import {
getInboundQcResultData, getInboundQcResultData,
getKuCunLabelData, getKuCunLabelData,
exportKuCunLabelData,
updateInventoryStockAttribute, updateInventoryStockAttribute,
getWarehouseList, getWarehouseList,
freezeStatusInventoryStock, freezeStatusInventoryStock,
@ -992,10 +983,7 @@ export default {
printLoading: false, printLoading: false,
multiPartNoTip: '', multiPartNoTip: '',
// //
exportData: [],
exportName: "实时库存数据", exportName: "实时库存数据",
exportHeader: ["实时库存数据"],
exportFooter: [],
exportLoading: false 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 = { const params = {
...this.searchData,
page: 1,
limit: 999999 //
...this.searchData
} }
try { 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) { } catch (error) {
this.$message.error('获取导出数据失败:' + error.message)
return []
this.$message.error('导出失败:' + (error.message || '请稍后重试'))
} finally {
this.finishDownload()
} }
}, },
startDownload() { startDownload() {
@ -1561,6 +1565,28 @@ export default {
this._exportLoadingInstance.close() this._exportLoadingInstance.close()
this._exportLoadingInstance = null 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() { created() {

Loading…
Cancel
Save