From c017b4f8fed413fbbe504f48aa9ec143868369b6 Mon Sep 17 00:00:00 2001 From: lichong <18518571399@163.com> Date: Mon, 23 Dec 2024 22:18:38 +0800 Subject: [PATCH] 12.23 --- src/renderer/src/views/shujuguanli.vue | 44 ++++++++++++++++---------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/renderer/src/views/shujuguanli.vue b/src/renderer/src/views/shujuguanli.vue index eae523b..3e01c50 100644 --- a/src/renderer/src/views/shujuguanli.vue +++ b/src/renderer/src/views/shujuguanli.vue @@ -179,6 +179,7 @@ export default { chimaList: [], otherChangeList: [], atype: "", + fileData2Local: [], } }, methods: { @@ -213,6 +214,7 @@ export default { that.atype = fun that.chimaList = [] that.otherChangeList = [] + that.fileData2Local = [] that[fun](sheetData) } fileReader.onerror = function (error) { @@ -327,7 +329,6 @@ export default { } // 获取其他修改 if (rowIndex === 2) { - console.log(317, XLSX.utils.format_cell(cell)); that.otherChangeList.push({ key: String.fromCharCode("a".charCodeAt() + colIndex), value: XLSX.utils.format_cell(cell) @@ -470,6 +471,11 @@ export default { key: key, value: "条码贴" }) + } else if (key.includes("颜色")) { + this.otherChangeList.push({ + key: key, + value: "颜色" + }) } else if (!_.isNaN(parseInt(key))) { this.chimaList.push({ key: key, @@ -503,6 +509,11 @@ export default { key: key, value: "条码贴" }) + } else if (key.includes("颜色")) { + this.otherChangeList.push({ + key: key, + value: "颜色" + }) } else if (!_.isNaN(parseInt(key))) { this.chimaList.push({ key: key, @@ -553,6 +564,7 @@ export default { }, dealData2(sheetData) { let sheetDataTemp = _.cloneDeep(sheetData) + this.fileData2Local = _.cloneDeep(sheetData) if (this.fileData1.length === 0) { ElMessage({ message: `请先导入A表数据`, @@ -572,7 +584,7 @@ export default { xs = element.key } else if (["条码贴", "条形码"].includes(element.value)) { tmt = element.key - } else if (["颜色"].includes(element.value)) { + } else if (element.value.includes("颜色")) { ys = element.key } } @@ -580,7 +592,7 @@ export default { let itemTemp = [] let newData = [] for (let key in groupObj) { - if (key && _.isNumber(Number(key))) { + if (key && _.isNumber(Number(key)) && !_.isNaN(Number(key))) { let itemList = groupObj[key] || [] for (let i = 0; i < this.chimaList.length; i++) { let chimaItem = this.chimaList[i]; @@ -601,10 +613,8 @@ export default { } } } - console.log(600, itemTemp, this); for (let i = 0; i < itemTemp.length; i++) { let firstItem = itemTemp[i]; - console.log(607, firstItem.ys); let hasBarcodeIndex let noBarcodeIndex if (this.atype === "a1") { @@ -630,7 +640,6 @@ export default { // 修改原来的值 hasBarcode["Barcode"] = firstItem[tmt] hasBarcode["Quantity of containers"] += Number(firstItem[xs]) - hasBarcode["Quantity to deliver"] += firstItem[firstItem.typeKey] hasBarcode["Quantity per container"] = firstItem[firstItem.typeKey] hasBarcodetemp["_ishas_"] = true let newItem = "" @@ -658,7 +667,6 @@ export default { "Quantity per container": firstItem[firstItem.typeKey] }) } - console.log(655, newItem, hasBarcodeIndex, hasBarcode, firstItem); } else if (noBarcodeIndex !== -1) { let noBarcode = sheetData[noBarcodeIndex] let noBarcodetemp = sheetDataTemp[noBarcodeIndex] @@ -666,16 +674,13 @@ export default { // 修改原有的值 noBarcode["Barcode"] = firstItem[tmt] noBarcode["Quantity of containers"] = Number(firstItem[xs]) - // noBarcode["Quantity to deliver"] = firstItem[firstItem.typeKey] noBarcode["Quantity per container"] = firstItem[firstItem.typeKey] newData.push({ ...noBarcode, }) - console.log(668, noBarcodeIndex, noBarcode, firstItem); } } let noData = _.filter(sheetDataTemp, o => !o._ishas_) - console.log(662, sheetDataTemp, noData, newData); this.fileData2 = _.cloneDeep(_.concat(newData, noData)) } catch (error) { ElMessage({ @@ -740,17 +745,23 @@ export default { "", "", "", "" ]; // 处理数据,保留三位小数 - let eTotal = 0 - let iTotal = 0 + let lilstLocalTemp = [] + for (let i = 0; i < this.fileData2Local.length; i++) { + let item = this.fileData2Local[i]; + let oldList = _.filter(listCopy, o => o.Store === item.Store && o.Description === item.Description && o["Quantity to deliver"] === item["Quantity to deliver"]) + if (oldList.length) { + lilstLocalTemp.push(...oldList) + } else { + lilstLocalTemp.push({ ...item }) + } + } let lilstLocal = [] - for (let i = 0; i < listCopy.length; i++) { - let item = listCopy[i]; + for (let i = 0; i < lilstLocalTemp.length; i++) { + let item = lilstLocalTemp[i]; lilstLocal.push({ ...item, 'Quantity to deliver': item["Quantity to deliver"] ? item["Quantity to deliver"].toFixed(3) : "" }) - eTotal += Number(item["Quantity to deliver"]) - iTotal += Number(item["Quantity per container"]) } // 创建一个新的工作簿和工作表 let workbook = new ExcelJS.Workbook(); @@ -782,7 +793,6 @@ export default { cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFFF00' }, }; } }); - // 生成文件名 let fileName = `数据表格管理${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.xlsx`; console.log(`生成的文件名: ${fileName}`);