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