|
|
@ -552,6 +552,7 @@ export default { |
|
|
|
fileReader.readAsArrayBuffer(file) |
|
|
|
}, |
|
|
|
dealData2(sheetData) { |
|
|
|
let sheetDataTemp = _.cloneDeep(sheetData) |
|
|
|
if (this.fileData1.length === 0) { |
|
|
|
ElMessage({ |
|
|
|
message: `请先导入A表数据`, |
|
|
@ -562,6 +563,7 @@ export default { |
|
|
|
let sdmc = ""//商店名称 |
|
|
|
let xs = ""//箱数 |
|
|
|
let tmt = ""//条码贴 |
|
|
|
let ys = ""//颜色 |
|
|
|
for (let i = 0; i < this.otherChangeList.length; i++) { |
|
|
|
let element = this.otherChangeList[i]; |
|
|
|
if (["商店名称", "商店"].includes(element.value)) { |
|
|
@ -570,6 +572,8 @@ export default { |
|
|
|
xs = element.key |
|
|
|
} else if (["条码贴", "条形码"].includes(element.value)) { |
|
|
|
tmt = element.key |
|
|
|
} else if (["颜色"].includes(element.value)) { |
|
|
|
ys = element.key |
|
|
|
} |
|
|
|
} |
|
|
|
let groupObj = _.groupBy(this.fileData1, sdmc) |
|
|
@ -588,6 +592,7 @@ export default { |
|
|
|
[tmt]: storeItem[tmt],//Barcode |
|
|
|
[xs]: Number(storeItem[xs]),//Quantity of containers |
|
|
|
type: chimaItem.value,//类型 |
|
|
|
ys: storeItem[ys],//类型 |
|
|
|
[chimaItem.key]: Number(storeItem[chimaItem.key]),//Quantity per container(CH) |
|
|
|
typeKey: chimaItem.key, |
|
|
|
}) |
|
|
@ -596,47 +601,50 @@ 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") { |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}, `) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}, `) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}, `) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}, `) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
} else if (this.atype === "a2") { |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type} M`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type} M`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type} M`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type} M`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && 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') |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
} else if (this.atype === "a4") { |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
} else if (this.atype === "a5") { |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => o.Description.includes(`, ${firstItem.type}`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
} |
|
|
|
if (hasBarcodeIndex !== -1) { |
|
|
|
let hasBarcode = sheetData[hasBarcodeIndex] |
|
|
|
let hasBarcodetemp = sheetDataTemp[hasBarcodeIndex] |
|
|
|
// 修改原来的值 |
|
|
|
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] |
|
|
|
hasBarcode["_ishas_"] = true |
|
|
|
hasBarcodetemp["_ishas_"] = true |
|
|
|
let newItem = "" |
|
|
|
if (this.atype === "a1") { |
|
|
|
newItem = _.find(newData, o => o.Description.includes(`, ${firstItem.type}, `) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
newItem = _.find(newData, o => o.Description.includes(`, ${firstItem.type}, `) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
} else if (this.atype === "a2") { |
|
|
|
newItem = _.find(newData, o => o.Description.includes(`, ${firstItem.type} M`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
newItem = _.find(newData, o => o.Description.includes(`, ${firstItem.type} M`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
} 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)) |
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
} else if (this.atype === "a4") { |
|
|
|
newItem = _.find(newData, o => o.Description.includes(`, ${firstItem.type}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
newItem = _.find(newData, o => o.Description.includes(`, ${firstItem.type}`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
} else if (this.atype === "a5") { |
|
|
|
newItem = _.find(newData, o => o.Description.includes(`, ${firstItem.type}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
newItem = _.find(newData, o => o.Description.includes(`, ${firstItem.type}`) && _.toUpper(o.Description.replaceAll(" ", "")).includes(`${_.toUpper(firstItem.ys.replaceAll(" ", ""))}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode) && _.trim(o.Barcode) === _.trim(firstItem[tmt])) |
|
|
|
} |
|
|
|
if (newItem) { |
|
|
|
// 修改新添加的值 |
|
|
@ -650,9 +658,11 @@ export default { |
|
|
|
"Quantity per container": firstItem[firstItem.typeKey] |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log(655, newItem, hasBarcodeIndex, hasBarcode, firstItem); |
|
|
|
} else if (noBarcodeIndex !== -1) { |
|
|
|
let noBarcode = sheetData[noBarcodeIndex] |
|
|
|
noBarcode["_ishas_"] = true |
|
|
|
let noBarcodetemp = sheetDataTemp[noBarcodeIndex] |
|
|
|
noBarcodetemp["_ishas_"] = true |
|
|
|
// 修改原有的值 |
|
|
|
noBarcode["Barcode"] = firstItem[tmt] |
|
|
|
noBarcode["Quantity of containers"] = Number(firstItem[xs]) |
|
|
@ -661,10 +671,11 @@ export default { |
|
|
|
newData.push({ |
|
|
|
...noBarcode, |
|
|
|
}) |
|
|
|
console.log(668, noBarcodeIndex, noBarcode, firstItem); |
|
|
|
} |
|
|
|
} |
|
|
|
let noData = _.filter(sheetData, o => !o._ishas_) |
|
|
|
console.log(662, noData, newData); |
|
|
|
let noData = _.filter(sheetDataTemp, o => !o._ishas_) |
|
|
|
console.log(662, sheetDataTemp, noData, newData); |
|
|
|
this.fileData2 = _.cloneDeep(_.concat(newData, noData)) |
|
|
|
} catch (error) { |
|
|
|
ElMessage({ |
|
|
|