From c2a6bdf7d901a6fa94405091f8719901a0a0c270 Mon Sep 17 00:00:00 2001 From: qiankanghui Date: Wed, 15 Jul 2026 10:56:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(excel):=20=E8=A7=A3=E5=86=B3Excel=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=97=B6=E5=B7=A5=E4=BD=9C=E8=A1=A8=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E9=9D=9E=E6=B3=95=E5=AD=97=E7=AC=A6=E5=92=8C=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E9=99=90=E5=88=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复Excel工作表名称中包含非法字符\ / ? * [ ]导致的导出失败 - 添加工作表名称长度限制为31个字符的处理逻辑 - 更新英文翻译中的导出前缀文本格式 - 清理代码中的多余空行以提高可读性 - 简化导出函数中的参数格式化逻辑 --- cclqms-vue/src/i18n/locales/qc.en.js | 2 +- cclqms-vue/src/utils/excel-util.js | 22 ++++++++++++++++--- .../src/views/modules/qc/qcPartAttribute.vue | 17 +++++++------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/cclqms-vue/src/i18n/locales/qc.en.js b/cclqms-vue/src/i18n/locales/qc.en.js index 9fdc083..a7befe0 100644 --- a/cclqms-vue/src/i18n/locales/qc.en.js +++ b/cclqms-vue/src/i18n/locales/qc.en.js @@ -976,7 +976,7 @@ module.exports = { dataSyncConfirm: 'Run material catalog data sync?', dataSyncSuccess: 'Data sync completed', dataSyncFail: 'Data sync failed', - exportPrefix: 'InspectionTemplateByMaterial', + exportPrefix: 'Inspection template by material', exportHeader: 'Inspection template by material', tableNameMain: 'Material attribute settings', tableNameTemplate: 'Inspection template list', diff --git a/cclqms-vue/src/utils/excel-util.js b/cclqms-vue/src/utils/excel-util.js index 4f86f55..af4a708 100644 --- a/cclqms-vue/src/utils/excel-util.js +++ b/cclqms-vue/src/utils/excel-util.js @@ -154,9 +154,25 @@ let export2Excel = opt => { setStyle(ws, merges); } // console.log(ws); - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, options.fileName.replace(/\.xlsx/, "")); - XLSX.writeFile(wb, options.fileName); + const wb = XLSX.utils.book_new(); + +// Excel sheet名称限制:最大31个字符,且不能包含 \ / ? * [ ] + let sheetName = options.fileName + .replace(/\.xlsx/, "") + .replace(/[\\\/\?\*\[\]]/g, ""); + +// 限制31字符 + if (sheetName.length > 31) { + sheetName = sheetName.substring(0, 31); + } + + XLSX.utils.book_append_sheet( + wb, + ws, + sheetName + ); + + XLSX.writeFile(wb, options.fileName); }); } diff --git a/cclqms-vue/src/views/modules/qc/qcPartAttribute.vue b/cclqms-vue/src/views/modules/qc/qcPartAttribute.vue index 908cee0..662d4f4 100644 --- a/cclqms-vue/src/views/modules/qc/qcPartAttribute.vue +++ b/cclqms-vue/src/views/modules/qc/qcPartAttribute.vue @@ -373,7 +373,7 @@ - + @@ -412,7 +412,7 @@ - + @@ -942,7 +942,7 @@ - + @@ -4949,7 +4949,7 @@ export default { }, openQcSpecWarningDialog(row) { this.qcSpecWarningCurrentRow = row - + this.qcSpecWarningList = [] this.qcSpecWarningDialogFlag = true this.loadQcSpecWarningDictOptions().then(() => { @@ -6640,13 +6640,12 @@ export default { this.searchData.page = 1 excel.exportTable({ url: '/pms/qc/qcPartAttributeSearch', - columnMapping: this.columnList, //可以直接用table,不需要的列就剔除 - mergeSetting: [], //需要合并的列 + columnMapping: this.columnList, params: this.searchData, fileName: this.exportName + '.xlsx', - rowFetcher: (res) => res.data, - columnFormatter: [], - dropColumns: [], + rowFetcher: (res) => { + return res.data + }, }) },