From dd1cd41f2d415ad281deafbddd7aaafd9ea7dfdd Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Tue, 20 Oct 2026 16:34:26 +0800 Subject: [PATCH] =?UTF-8?q?2026-10-20=20=E5=AF=BC=E5=87=BA=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/shopOrder/productionReport.js | 3 + .../searchSfdcRollsReport.vue | 112 ++++++++++-------- 2 files changed, 63 insertions(+), 52 deletions(-) diff --git a/src/api/shopOrder/productionReport.js b/src/api/shopOrder/productionReport.js index 3d978ba..77d8a97 100644 --- a/src/api/shopOrder/productionReport.js +++ b/src/api/shopOrder/productionReport.js @@ -24,6 +24,9 @@ export const searchProductionLineOutputReport = data => createAPI(`/productionRe // 订单产出标签报表--查询 export const searchSfdcRollsReport = data => createAPI(`/productionReport/searchSfdcRollsReport`,'post',data) +// 订单产出标签报表--导出 +export const exportSfdcRollsReport = data => createAPI(`/productionReport/exportSfdcRollsReport`,'post',data, 'download') + // 订单产出标签报表--保存属性变更 export const updateSfdcRollsAttribute = data => createAPI(`/productionReport/updateSfdcRollsAttribute`,'post',data) diff --git a/src/views/modules/shopOrder/productionReport/searchSfdcRollsReport.vue b/src/views/modules/shopOrder/productionReport/searchSfdcRollsReport.vue index 7f740fe..b27e0e6 100644 --- a/src/views/modules/shopOrder/productionReport/searchSfdcRollsReport.vue +++ b/src/views/modules/shopOrder/productionReport/searchSfdcRollsReport.vue @@ -150,20 +150,7 @@
{{ buttons.search }} - - {{ buttons.download }} - + {{ buttons.download }} 打印 属性变动
@@ -509,7 +496,7 @@ import { searchFunctionButtonList, } from "@/api/sysLanguage.js" -import {searchSfdcRollsReport, updateSfdcRollsAttribute, executeSfdcRollsReport} from "../../../../api/shopOrder/productionReport"; +import {searchSfdcRollsReport, exportSfdcRollsReport, updateSfdcRollsAttribute, executeSfdcRollsReport} from "../../../../api/shopOrder/productionReport"; import {updateInventoryStockAttribute} from "../../../../api/wms/wms"; import getLodop from '@/utils/LodopFuncs.js'; import {getPartLabelTemplateList, callUspPartLabelTemplate} from '@/api/wms/wms.js'; @@ -581,12 +568,7 @@ import labelPrintTemplates from '@/mixins/labelPrintTemplates.js'; objectType: 'label' }, tagNo:'', - // 导出 start - exportData: [], - exportName: "产线产量报告"+this.dayjs().format('YYYYMMDDHHmmss'), - exportHeader: ["产线产量报告"], - exportFooter: [], - // 导出 end + exportName: "订单产出标签统计"+this.dayjs().format('YYYYMMDDHHmmss'), tableHeight: 400, modelFlag:false, modelInputFlag:true, @@ -1299,20 +1281,46 @@ import labelPrintTemplates from '@/mixins/labelPrintTemplates.js'; this.pageIndex = val; this.getData(); }, - //导出excel - async createExportData() { + async exportSfdcRollsData() { + this.startDownload() + const params = { + ...this.searchData + } try { - const params = { - ...this.searchData, - page: 0, - limit: 1000000 - }; - const { data } = await searchSfdcRollsReport(params); - return data.rows || []; + const response = await exportSfdcRollsReport(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) { - console.error('获取导出数据失败:', error); - this.$message.error('获取导出数据失败!'); - return []; + this.$message.error('导出失败:' + (error.message || '请稍后重试')) + } finally { + this.finishDownload() } }, selectionChangeHandle(val){ @@ -1697,6 +1705,7 @@ import labelPrintTemplates from '@/mixins/labelPrintTemplates.js'; }); }, startDownload() { + this.exportName = "订单产出标签统计" + this.dayjs().format('YYYYMMDDHHmmss') this._exportLoading = this.$loading({ lock: true, text: '正在导出数据,请稍候...', @@ -1710,28 +1719,27 @@ import labelPrintTemplates from '@/mixins/labelPrintTemplates.js'; this._exportLoading = null } }, - formatExportText(value) { - if (value === '' || value === null || value === undefined) { + parseDownloadFileName(disposition) { + if (!disposition) { return '' } - const safeValue = String(value).replace(/"/g, '""') - return `="${safeValue}"` - }, - fields() { - const fieldMap = {} - this.columnList.forEach(item => { - if (item.columnProp === 'packingList') { - fieldMap[item.columnLabel] = { - field: item.columnProp, - callback: value => this.formatExportText(value) - } - return - } - fieldMap[item.columnLabel] = item.columnProp - }) - return fieldMap + 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 + } }, - // 导出 end //多语言 getMultiLanguageList() { //首先查询当前按钮的多语言