|
|
@ -321,6 +321,7 @@ 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) |
|
|
@ -559,9 +560,9 @@ export default { |
|
|
|
let element = this.otherChangeList[i]; |
|
|
|
if (element.value === "商店名称") { |
|
|
|
sdmc = element.key |
|
|
|
} else if (element.value === "箱数") { |
|
|
|
} else if (["店铺箱数", "箱数"].includes(element.value)) { |
|
|
|
xs = element.key |
|
|
|
} else if (element.value === "条码贴") { |
|
|
|
} else if (["条码贴", "条形码"].includes(element.value)) { |
|
|
|
tmt = element.key |
|
|
|
} |
|
|
|
} |
|
|
@ -614,14 +615,14 @@ export default { |
|
|
|
let hasBarcode = sheetData[hasBarcodeIndex] |
|
|
|
// 修改原来的值 |
|
|
|
hasBarcode["Barcode"] = firstItem[tmt] |
|
|
|
hasBarcode["Quantity of containers"] += firstItem[xs] |
|
|
|
hasBarcode["Quantity of containers"] += Number(firstItem[xs]) |
|
|
|
hasBarcode["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
|
|
hasBarcode["Quantity per container"] = firstItem[firstItem.typeKey] |
|
|
|
let newItem = "" |
|
|
|
if (this.atype === "a1") { |
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}, `) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
} else if (this.atype === "a2") { |
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)} M`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
} else if (this.atype === "a3") { |
|
|
|
let typeTemp = firstItem.type.replace(/([0-9])([a-zA-Z])/g, '$1 $2').replace(/([a-zA-Z])([0-9])/g, '$1 $2') |
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
@ -630,23 +631,25 @@ export default { |
|
|
|
} else if (this.atype === "a5") { |
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
} |
|
|
|
if (newItem) { |
|
|
|
// 修改新添加的值 |
|
|
|
newItem["Quantity of containers"] += firstItem[xs] |
|
|
|
newItem["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
|
|
newItem["Quantity of containers"] += Number(firstItem[xs]) |
|
|
|
// newItem["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
|
|
// 再新增一条数据 |
|
|
|
newData.push({ |
|
|
|
...hasBarcode, |
|
|
|
"Barcode": firstItem[tmt], |
|
|
|
"Quantity of containers": "", |
|
|
|
"Quantity of containers": 0, |
|
|
|
"Quantity to deliver": "", |
|
|
|
"Quantity per container": firstItem[firstItem.typeKey] |
|
|
|
}) |
|
|
|
} |
|
|
|
} else if (noBarcodeIndex !== -1) { |
|
|
|
let noBarcode = sheetData[noBarcodeIndex] |
|
|
|
// 修改原有的值 |
|
|
|
noBarcode["Barcode"] = firstItem[tmt] |
|
|
|
noBarcode["Quantity of containers"] = firstItem[xs] |
|
|
|
noBarcode["Quantity to deliver"] = firstItem[firstItem.typeKey] |
|
|
|
noBarcode["Quantity of containers"] = Number(firstItem[xs]) |
|
|
|
// noBarcode["Quantity to deliver"] = firstItem[firstItem.typeKey] |
|
|
|
noBarcode["Quantity per container"] = firstItem[firstItem.typeKey] |
|
|
|
newData.push({ |
|
|
|
...noBarcode, |
|
|
@ -716,13 +719,19 @@ export default { |
|
|
|
"Barcode", "Quantity per container", "Total", "Cluster", |
|
|
|
"", "", "", "" |
|
|
|
]; |
|
|
|
|
|
|
|
// 处理数据,保留三位小数 |
|
|
|
let lilstLocal = listCopy.map(item => ({ |
|
|
|
let eTotal = 0 |
|
|
|
let iTotal = 0 |
|
|
|
let lilstLocal = [] |
|
|
|
for (let i = 0; i < listCopy.length; i++) { |
|
|
|
let item = listCopy[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(); |
|
|
|
let worksheet = workbook.addWorksheet('Sheet1'); |
|
|
@ -747,6 +756,11 @@ export default { |
|
|
|
cell.font = { name: 'Arial', size: 10, color: { argb: '000000' } }; |
|
|
|
cell.alignment = { horizontal: 'center', vertical: 'center' }; |
|
|
|
} |
|
|
|
if (Number(row["Quantity to deliver"]) < Number(row["Quantity per container"])) { |
|
|
|
let qpcCol = _.findIndex(rowKeys, o => o === "Quantity per container") |
|
|
|
let cell = worksheet.getCell(rowIndex + 2, qpcCol + 1); |
|
|
|
cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFFF00' }, }; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 生成文件名 |
|
|
|