diff --git a/src/utils/excel-util.js b/src/utils/excel-util.js index a3ca248..663f767 100644 --- a/src/utils/excel-util.js +++ b/src/utils/excel-util.js @@ -20,7 +20,8 @@ const exportOptionDefault = { mergeSetting: { refs: [], //检测需要合并的数据列属性名 columns: [] //检测需要合并后,要合并的列,以第一条数据为准合并 - } + }, + dropColumns: [],//导出时需要过滤掉的列 }; let HEADERS = []; for (let i =0;i< 200;i++) { @@ -88,15 +89,17 @@ let getMergeSetting = (data, s, allCols) => { let setStyle = (ws, s) => {} -let getColSetting = mapping => { +let getColSetting = (mapping,dropColums) => { let columns = []; for (let i = 0; i < mapping.length; i++) { let c = mapping[i]; + if (dropColums.indexOf(c.columnProp) == -1) { columns.push({ - property: c.prop || c.property, - label: c.label, - type: "default" + property: c.columnProp || c.property, + label: c.columnLabel, + type: "default" }); + } } return { columns: columns @@ -105,7 +108,7 @@ let getColSetting = mapping => { let export2Excel = opt => { validOption(opt); let options = Object.assign({}, exportOptionDefault, opt); - let expColSetting = !!options.tableRef ? options.tableRef : getColSetting(options.columnMapping); + let expColSetting = !!options.tableRef ? options.tableRef : getColSetting(options.columnMapping, options.dropColumns); ajax.$post(options.url, options.params, resp => { if (resp.status !== 200) { Message.error({ diff --git a/src/utils/export-options.js b/src/utils/export-options.js index b11e146..1570fe8 100644 --- a/src/utils/export-options.js +++ b/src/utils/export-options.js @@ -1,64 +1,64 @@ const PalletSku = { columnMapping: [ { - prop: "seqNo", - label: "序号", + columnProp: "seqNo", + columnLabel: "序号", }, { - prop: "cmcInvoice", - label: "发票号", + columnProp: "cmcInvoice", + columnLabel: "发票号", }, { - prop: "seqNo", - label: "托盘号/箱号", + columnProp: "seqNo", + columnLabel: "托盘号/箱号", }, { - prop: "customerPO", - label: "PO", + columnProp: "customerPO", + columnLabel: "PO", }, { - prop: "pn", - label: "PN", + columnProp: "pn", + columnLabel: "PN", }, { - prop: "qty", - label: "数量", + columnProp: "qty", + columnLabel: "数量", }, { - prop: "seqNo", - label: "箱数", + columnProp: "boxQty", + columnLabel: "箱数", }, { - prop: "seqNo", - label: "Rolls", + columnProp: "Rolls", + columnLabel: "Rolls", }, { - prop: "seqNo", - label: "托数", + columnProp: "pallet_qty", + columnLabel: "托数", }, { - prop: "seqNo", - label: "长(M)", + columnProp: "length", + columnLabel: "长(M)", }, { - prop: "seqNo", - label: "宽(M)", + columnProp: "width", + columnLabel: "宽(M)", }, { - prop: "seqNo", - label: "高(M)", + columnProp: "height", + columnLabel: "高(M)", }, { - prop: "seqNo", - label: "体积", + columnProp: "volume", + columnLabel: "体积", }, { - prop: "seqNo", - label: "毛重", + columnProp: "grossWeight", + columnLabel: "毛重", }, { - prop: "seqNo", - label: "净重", + columnProp: "netWeight", + columnLabel: "净重", } ], mergeSetting: { diff --git a/src/views/modules/ecss/pallet_upload_excel.vue b/src/views/modules/ecss/pallet_upload_excel.vue index 9b23326..d6cf848 100644 --- a/src/views/modules/ecss/pallet_upload_excel.vue +++ b/src/views/modules/ecss/pallet_upload_excel.vue @@ -106,41 +106,41 @@ columnLabel: "数量", }, { - columnProp: "seqNo", + columnProp: "boxQty", columnLabel: "箱数", }, { - columnProp: "seqNo", + columnProp: "Rolls", columnLabel: "Rolls", }, { - columnProp: "seqNo", + columnProp: "pallet_qty", columnLabel: "托数", }, { - columnProp: "seqNo", + columnProp: "length", columnLabel: "长(M)", }, { - columnProp: "seqNo", + columnProp: "width", columnLabel: "宽(M)", }, { - columnProp: "seqNo", + columnProp: "height", columnLabel: "高(M)", }, { - columnProp: "seqNo", + columnProp: "volume", columnLabel: "体积", }, { - columnProp: "seqNo", + columnProp: "grossWeight", columnLabel: "毛重", }, { - columnProp: "seqNo", + columnProp: "netWeight", columnLabel: "净重", - }, + } ], } }, @@ -153,15 +153,15 @@ cmcInvoice: this.pageData.cmcInvoice, createBy: this.$store.state.user.name, } - let columnMapping = excelOpts.PalletSku.columnMapping; excel.exportTable({ url: "/ecss/coDel/searchEcssCoDelNotifyDetail", - columnMapping: columnMapping, - mergeSetting: excelOpts.PalletSku.mergeSetting, + columnMapping: this.columnList1,//可以直接用table,不需要的列就剔除 + mergeSetting: [],//需要合并的列 params: searchData, fileName: this.exportName+".xlsx", rowFetcher: res => res.data, - columnFormatter: [] + columnFormatter: [], + dropColumns: [],//需要剔除的列,例如dropColumns: ["netWeight"],即剔除净重列 }); }, // 初始化组件的参数