From de77eeb68749e80885edaa592cc26dd3e2546e05 Mon Sep 17 00:00:00 2001 From: shijing Date: Thu, 30 Oct 2025 16:59:16 +0800 Subject: [PATCH 01/14] =?UTF-8?q?fix:=E6=AF=9B=E5=9D=AF=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/statistics/bxerp/maopi.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/statistics/bxerp/maopi.vue b/src/views/statistics/bxerp/maopi.vue index 8b3fc178..4e251a7b 100644 --- a/src/views/statistics/bxerp/maopi.vue +++ b/src/views/statistics/bxerp/maopi.vue @@ -296,7 +296,7 @@ export default { }else if(index==9){ values = data.map((item) =>!item.data[propert]&&!item.data['毛坯检测_缺陷项_剪切¢18.3mm可加工']?1:0); }else if(index==13){ - values = data.map((item) =>!item.data[propert]&&!item.data['毛坯检测_检测项_暗点不合格']?1:0); + values = data.map((item) =>!item.data[propert]&&!item.data['毛坯检测_缺陷项_暗点不合格']?1:0); }else{ values = data.map((item) =>item.data[propert]&&item.data[propert]!==undefined?Number(item.data[propert]):0); } From a0814191a78370b844990cf9ed5125875174dc04 Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 31 Oct 2025 10:53:47 +0800 Subject: [PATCH 02/14] =?UTF-8?q?fix:=E5=91=98=E5=B7=A5=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E5=8F=8A=E7=BC=BA=E9=99=B7=E7=BB=9F=E8=AE=A1=E5=88=9D=E7=89=88?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/statistics/bxerp/defect.vue | 127 ++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 src/views/statistics/bxerp/defect.vue diff --git a/src/views/statistics/bxerp/defect.vue b/src/views/statistics/bxerp/defect.vue new file mode 100644 index 00000000..fd53568d --- /dev/null +++ b/src/views/statistics/bxerp/defect.vue @@ -0,0 +1,127 @@ + + + + + From 48ea04138b6f179d6221c209a75350d0c67de77d Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sun, 2 Nov 2025 00:22:29 +0800 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20base=20=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=A2=9E=E5=8A=A0=E9=80=9A=E7=94=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/scTable/index.vue | 41 +++++++++++++- src/utils/exportExcel.js | 97 +++++++++++++++++++++++++------- 2 files changed, 116 insertions(+), 22 deletions(-) diff --git a/src/components/scTable/index.vue b/src/components/scTable/index.vue index eba599fb..00a5816f 100644 --- a/src/components/scTable/index.vue +++ b/src/components/scTable/index.vue @@ -45,6 +45,14 @@ + + +
1导出本页数据
+
2导出本页数据
+
3导出全部数据
+
@@ -82,7 +90,7 @@ import config from "@/config/table"; import columnSetting from "./columnSetting"; import { genTree } from "@/utils/verificate"; - +import { domToExcel } from "@/utils/exportExcel"; export default { name: "scTable", components: { @@ -115,6 +123,8 @@ export default { hideDo: { type: Boolean, default: false }, hideRefresh: { type: Boolean, default: false }, hideSetting: { type: Boolean, default: false }, + hideExport: { type: Boolean, default: false }, + hExportExcel: { type: Function, default: null }, paginationLayout: { type: String, default: config.paginationLayout }, }, watch: { @@ -299,6 +309,35 @@ export default { this.getData(); this.$emit("resetQuery"); }, + //导出 + exportExcel(type=0) { + if (type === 0) { + try { + domToExcel(this.$refs.scTable.$el, "表格数据"); + } catch (error) { + console.error('导出失败:', error); + this.$message.error("导出失败"); + } + } + else if (type === 1) { + this.hExportExcel(this.tableData); + }else if (type === 2) { + var c = Object.assign({}, this.query, this.tableParams, {[this.orderStr]: this.order}, {page: 0}) + let ElLoading = this.$loading({ + lock: true, + text: '数据请求中,请稍后...', + background: 'rgba(0, 0, 0, 0)', + }) + this.apiObj.req(c).then(res=>{ + ElLoading.close(); + this.hExportExcel(res); + }).catch(err=>{ + ElLoading.close(); + console.log(err) + this.$message.error("导出失败"); + }) + } + }, //自定义变化事件 columnSettingChange(userColumn) { this.userColumn = userColumn; diff --git a/src/utils/exportExcel.js b/src/utils/exportExcel.js index 23bcbae0..01bf6b5a 100644 --- a/src/utils/exportExcel.js +++ b/src/utils/exportExcel.js @@ -1,4 +1,11 @@ import * as XLSX from 'xlsx'; + +export const domToExcel = (dom, name="data") => { + const worksheet = XLSX.utils.table_to_sheet(dom); + const workbook = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(workbook, worksheet); + XLSX.writeFile(workbook, `${name}.xlsx`); +} /** * eg: .columns = [ * { header: 'Id', key: 'id', wpx: 10 }, @@ -10,35 +17,83 @@ import * as XLSX from 'xlsx'; * @param data 数据 * @param name 文件名 */ -export const generateExcel = (columns = [], data = [], name = '') => { +export const dataToExcel = (columns = [], data = [], name = 'data') => { const headers = columns.map((item) => item.header); - const otherConfigs = columns.map(({ key, header, ...item }) => item); const dataList = data.map((item) => { let obj = {}; - columns.forEach((col) => { - obj[col.header] = item[col.key]; + columns.forEach(col => { + obj[col.header] = getNestedValue(item, col.key) ?? ''; }); return obj; }); const workbook = XLSX.utils.book_new(); - workbook.SheetNames.push(name); + // workbook.SheetNames.push(name); const worksheet = XLSX.utils.json_to_sheet(dataList, { header: headers, }); - worksheet['!cols'] = otherConfigs; - workbook.Sheets[name] = worksheet; - // 生成Blob数据 - const excelData = XLSX.write(workbook, { type: 'array', bookType: 'xlsx' }); - const blobData = new Blob([excelData], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); - // 创建Blob URL - const blobUrl = URL.createObjectURL(blobData); - // 创建一个隐藏的标签并设置href属性为Blob URL - const link = document.createElement('a'); - link.href = blobUrl; - link.target = '_blank'; - link.download = `${name}.xlsx`; - // 触发点击操作,开始下载文件 - link.click(); - // 释放Blob URL - URL.revokeObjectURL(blobUrl); + // 自动计算列宽 + worksheet['!cols'] = calculateColumnWidths(columns, dataList); + // const otherConfigs = columns.map(({ key, header, ...item }) => item); + // worksheet['!cols'] = otherConfigs; + XLSX.utils.book_append_sheet(workbook, worksheet); + XLSX.writeFile(workbook, `${name}.xlsx`); + // workbook.Sheets[name] = worksheet; + // // 生成Blob数据 + // const excelData = XLSX.write(workbook, { type: 'array', bookType: 'xlsx' }); + // const blobData = new Blob([excelData], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); + // // 创建Blob URL + // const blobUrl = URL.createObjectURL(blobData); + // // 创建一个隐藏的标签并设置href属性为Blob URL + // const link = document.createElement('a'); + // link.href = blobUrl; + // link.target = '_blank'; + // link.download = `${name}.xlsx`; + // // 触发点击操作,开始下载文件 + // link.click(); + // // 释放Blob URL + // URL.revokeObjectURL(blobUrl); +}; + +const getNestedValue = (obj, path, defaultValue = '') => { + if (!obj || !path) return defaultValue; + + const keys = path.split('.'); + let result = obj; + + for (const key of keys) { + if (result === null || result === undefined) { + return defaultValue; + } + result = result[key]; + } + + return result !== undefined ? result : defaultValue; +}; +const calculateColumnWidths = (columns, dataList) => { + // 确保 dataList 有数据 + if (!dataList || dataList.length === 0) { + return columns.map(col => ({ wch: 15 })); // 返回默认宽度 + } + + return columns.map(col => { + // 固定宽度优先 + if (col.wpx) return { wpx: col.wpx }; + if (col.wch) return { wch: col.wch }; + if (col.width) return { wch: col.width }; + + const header = col.header || ''; + let maxWidth = header.length; + + // 遍历数据计算最大宽度 + for (let i = 0; i < Math.min(dataList.length, 100); i++) { + const item = dataList[i]; + // 确保使用正确的键名 + const value = item[header] !== undefined ? String(item[header]) : ''; + if (value.length > maxWidth) { + maxWidth = value.length; + } + } + + return { wch: Math.min(Math.max(maxWidth + 2, 8), 50) }; + }); }; \ No newline at end of file From dce7e72d8f7a9adcf42022adf100d2dbbe71c31f Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sun, 2 Nov 2025 00:23:02 +0800 Subject: [PATCH 04/14] =?UTF-8?q?feat:=20=E6=88=90=E5=93=81=E5=BA=93?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/inm/good.vue | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/views/inm/good.vue b/src/views/inm/good.vue index e6d0589f..0f7d9601 100644 --- a/src/views/inm/good.vue +++ b/src/views/inm/good.vue @@ -41,6 +41,7 @@ row-key="id" stripe :params="params" + :hExportExcel="hExportExcel" > @@ -101,6 +102,7 @@ row-key="id" :params="paramsWm" stripe + :hExportExcel="hExportExcel2" > @@ -156,6 +158,7 @@ From 176ad3e2332e1d57950c8b07c275fd32bd45a5a6 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sun, 2 Nov 2025 00:23:26 +0800 Subject: [PATCH 05/14] =?UTF-8?q?feat:=20worktask=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=BC=95=E5=85=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/wpm/worktask.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/wpm/worktask.vue b/src/views/wpm/worktask.vue index 5026b0ac..d70c4f2f 100644 --- a/src/views/wpm/worktask.vue +++ b/src/views/wpm/worktask.vue @@ -532,7 +532,7 @@ From adef92c959a29caa85d88f6e6c6cf6edc193eb76 Mon Sep 17 00:00:00 2001 From: shijing Date: Tue, 4 Nov 2025 09:00:44 +0800 Subject: [PATCH 08/14] =?UTF-8?q?fix:=E5=85=89=E8=8A=AF=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=97=AE=E9=A2=98=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/statistics/stock_statistics.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/views/statistics/stock_statistics.vue b/src/views/statistics/stock_statistics.vue index 0debe0b7..c66cd498 100644 --- a/src/views/statistics/stock_statistics.vue +++ b/src/views/statistics/stock_statistics.vue @@ -81,7 +81,7 @@ id="exportDiv11" stripe hideDo - :pageSize="500" + hidePagination :summary-method="getSummaries2" show-summary > @@ -241,7 +241,7 @@ export default { mioTypeEnum, apiObj: this.$API.mtm.material.list, materialType: "", - params: { is_hidden: false, type: 10, count__gte: 1 }, + params: { is_hidden: false, type: 10, count__gte: 1,page:0 }, query: { material: "", mio_type: mioTypeEnum.values[0].key, @@ -370,9 +370,9 @@ export default { that.params.name = that.material_name; } this.$API.mtm.material.list.req(that.params).then((res) => { - that.tableData11 = res.results; - if(res.results.length>0){ - res.results.forEach((ite) =>{ + that.tableData11 = res; + if(res.length>0){ + res.forEach((ite) =>{ if (nameList.indexOf(ite.name) > -1) {} else { nameList.push(ite.name); let obj = {}; From b181a3717e72665eaea6df7756dc192c6906bb78 Mon Sep 17 00:00:00 2001 From: shijing Date: Tue, 4 Nov 2025 09:04:35 +0800 Subject: [PATCH 09/14] =?UTF-8?q?fix:=E7=8E=BB=E7=BA=A4=E6=A3=80=E9=AA=8C?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/wpm_bx/mlogbw_check_table.vue | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/views/wpm_bx/mlogbw_check_table.vue b/src/views/wpm_bx/mlogbw_check_table.vue index e6584f95..ad3893ce 100644 --- a/src/views/wpm_bx/mlogbw_check_table.vue +++ b/src/views/wpm_bx/mlogbw_check_table.vue @@ -990,18 +990,22 @@ export default { that.$refs.dialogForm.validate((valid) => { if (valid) { that.selectWpr.forEach(item => { - item.ftest.ftestdefects.forEach(defect => { - let defectindex = that.setForm.defectids.indexOf(defect.defect); - if(defectindex > -1){ - defect.has = that.defectlists[defectindex].value; - } - }) - item.ftest.ftestitems.forEach(testitem => { - let testitemindex = that.setForm.testitemids.indexOf(testitem.testitem); - if( testitemindex > -1){ - testitem.test_val_json = that.testitemlists[testitemindex].value; - } - }) + item.ftest.ftestdefects = []; + if(that.defectlists.length>0){ + that.defectlists.forEach((item1) => { + let obj = {}; + obj.defect = item1.defect; + obj.has = item1.value; + item.ftest.ftestdefects.push(obj); + }) + } + + // item.ftest.ftestdefects.forEach(defect => { + // let defectindex = that.setForm.defectids.indexOf(defect.defect); + // if(defectindex > -1){ + // defect.has = that.defectlists[defectindex].value; + // } + // }) }); that.$API.wpm.mlogbw.update.req("bulk",that.selectWpr).then((res) => { that.setVisible = false; From a4402edf9296cc5fa69675dd5e69e1c46ee0e728 Mon Sep 17 00:00:00 2001 From: shijing Date: Tue, 4 Nov 2025 09:19:27 +0800 Subject: [PATCH 10/14] =?UTF-8?q?fix:=E5=BA=93=E5=AD=98=E8=BE=85=E5=8A=A9?= =?UTF-8?q?=E6=9D=90=E6=96=99=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/statistics/stock_statistics.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/statistics/stock_statistics.vue b/src/views/statistics/stock_statistics.vue index c66cd498..e4f80cb1 100644 --- a/src/views/statistics/stock_statistics.vue +++ b/src/views/statistics/stock_statistics.vue @@ -78,7 +78,7 @@ v-else ref="tables11" :data="tableData11" - id="exportDiv11" + id="exportDiv1" stripe hideDo hidePagination From ea830b524631cbaf037c682c3b843af1822b7e8d Mon Sep 17 00:00:00 2001 From: shijing Date: Tue, 4 Nov 2025 10:59:40 +0800 Subject: [PATCH 11/14] =?UTF-8?q?feat:=E7=8E=BB=E7=BA=A4=E6=8E=92=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=A3=92=EF=BC=8C=E8=BE=93=E5=87=BA=E7=9A=84=E7=89=A9?= =?UTF-8?q?=E6=96=99=E7=BC=96=E5=8F=B7=EF=BC=8C=E7=82=B9=E5=87=BB=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=81=9A=E6=88=90=E5=8F=AF=E4=BB=A5=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/wpm_bx/mlogbw_check_table.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/wpm_bx/mlogbw_check_table.vue b/src/views/wpm_bx/mlogbw_check_table.vue index ad3893ce..cb5b9181 100644 --- a/src/views/wpm_bx/mlogbw_check_table.vue +++ b/src/views/wpm_bx/mlogbw_check_table.vue @@ -38,7 +38,7 @@ From 50ef851482474a6c50887ca552a5fc540f29a3e5 Mon Sep 17 00:00:00 2001 From: shijing Date: Tue, 4 Nov 2025 11:00:51 +0800 Subject: [PATCH 12/14] =?UTF-8?q?fix:=E7=8E=BB=E7=BA=A4=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=8A=8A=E5=88=86=E9=A1=B5=E5=8E=BB=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mtm/routepack_form.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/mtm/routepack_form.vue b/src/views/mtm/routepack_form.vue index d11e3bb2..d8f2d936 100644 --- a/src/views/mtm/routepack_form.vue +++ b/src/views/mtm/routepack_form.vue @@ -124,6 +124,7 @@ row-key="id" hideDo stripe + hidePagination > @@ -150,7 +151,7 @@ label="操作" fixed="right" align="center" - width="200" + width="140" >