|
|
@ -71,6 +71,8 @@ export default { |
|
|
|
fileData2: [], |
|
|
|
tableData: [], |
|
|
|
loading: false, |
|
|
|
chimaList: [], |
|
|
|
otherChangeList: [], |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
@ -103,6 +105,8 @@ export default { |
|
|
|
let sheetName = workbook.SheetNames[0]; |
|
|
|
let sheetData = workbook.Sheets[sheetName]; |
|
|
|
let range = XLSX.utils.decode_range(sheetData['!ref']); |
|
|
|
let chima = _.sortBy(_.filter(sheetData["!merges"], o => o.s.r === 2 && o.e.r === 2), o => o.s.c) |
|
|
|
let colRange = [_.get(chima[0], 's.c', 0), _.get(chima[0], 'e.c', 0)] |
|
|
|
// 获取合并单元格的范围信息 |
|
|
|
let mergeRanges = sheetData['!merges']; |
|
|
|
if (!mergeRanges) { |
|
|
@ -117,6 +121,19 @@ export default { |
|
|
|
r: rowIndex |
|
|
|
})]; |
|
|
|
let cellContent = ''; |
|
|
|
// 获取尺码 |
|
|
|
if (rowIndex === 3 && colIndex >= colRange[0] && colIndex <= colRange[1]) { |
|
|
|
that.chimaList.push({ |
|
|
|
key: String.fromCharCode("a".charCodeAt() + colIndex), |
|
|
|
value: XLSX.utils.format_cell(cell) |
|
|
|
}) |
|
|
|
} |
|
|
|
if (rowIndex === 2) { |
|
|
|
that.otherChangeList.push({ |
|
|
|
key: String.fromCharCode("a".charCodeAt() + colIndex), |
|
|
|
value: XLSX.utils.format_cell(cell) |
|
|
|
}) |
|
|
|
} |
|
|
|
if (cell && cell.t) { |
|
|
|
cellContent = XLSX.utils.format_cell(cell); |
|
|
|
} |
|
|
@ -192,7 +209,6 @@ export default { |
|
|
|
fileReader.readAsArrayBuffer(file) |
|
|
|
}, |
|
|
|
dealData2(sheetData) { |
|
|
|
let groupObj = _.groupBy(this.fileData1, 'g') |
|
|
|
if (this.fileData1.length === 0) { |
|
|
|
ElMessage({ |
|
|
|
message: `请先导入A表数据`, |
|
|
@ -200,104 +216,74 @@ export default { |
|
|
|
}) |
|
|
|
} else { |
|
|
|
try { |
|
|
|
let sdmc = ""//商店名称 |
|
|
|
let xs = ""//箱数 |
|
|
|
let tmt = ""//条码贴 |
|
|
|
for (let i = 0; i < this.otherChangeList.length; i++) { |
|
|
|
let element = this.otherChangeList[i]; |
|
|
|
if (element.value === "商店名称") { |
|
|
|
sdmc = element.key |
|
|
|
} else if (element.value === "箱数") { |
|
|
|
xs = element.key |
|
|
|
} else if (element.value === "条码贴") { |
|
|
|
tmt = element.key |
|
|
|
} |
|
|
|
} |
|
|
|
let groupObj = _.groupBy(this.fileData1, sdmc) |
|
|
|
let itemTemp = [] |
|
|
|
let newData = [] |
|
|
|
for (let key in groupObj) { |
|
|
|
if (key && _.isNumber(Number(key))) { |
|
|
|
let itemList = groupObj[key] || [] |
|
|
|
for (let i = 0; i < this.chimaList.length; i++) { |
|
|
|
let chimaItem = this.chimaList[i]; |
|
|
|
for (let j = 0; j < itemList.length; j++) { |
|
|
|
let storeItem = itemList[j]; |
|
|
|
if (Number(storeItem.j)) { |
|
|
|
if (Number(storeItem[chimaItem.key])) { |
|
|
|
itemTemp.push({ |
|
|
|
g: storeItem.g,//Store |
|
|
|
h: storeItem.h,//Barcode |
|
|
|
f: Number(storeItem.f),//Quantity of containers |
|
|
|
type: "CH",//类型 |
|
|
|
j: Number(storeItem.j),//Quantity per container(CH) |
|
|
|
k: 0,//Quantity per container(M) |
|
|
|
l: 0,//Quantity per container(G) |
|
|
|
m: 0//Quantity per container(EG) |
|
|
|
[sdmc]: storeItem[sdmc],//Store |
|
|
|
[tmt]: storeItem[tmt],//Barcode |
|
|
|
[xs]: Number(storeItem[xs]),//Quantity of containers |
|
|
|
type: chimaItem.value,//类型 |
|
|
|
[chimaItem.key]: Number(storeItem[chimaItem.key]),//Quantity per container(CH) |
|
|
|
typeKey: chimaItem.key, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
for (let j = 0; j < itemList.length; j++) { |
|
|
|
let storeItem = itemList[j]; |
|
|
|
if (Number(storeItem.k)) { |
|
|
|
itemTemp.push({ |
|
|
|
g: storeItem.g,//Store |
|
|
|
h: storeItem.h,//Barcode |
|
|
|
f: Number(storeItem.f),//Quantity of containers |
|
|
|
type: "M",//类型 |
|
|
|
j: 0,//Quantity per container(CH) |
|
|
|
k: Number(storeItem.k),//Quantity per container(M) |
|
|
|
l: 0,//Quantity per container(G) |
|
|
|
m: 0//Quantity per container(EG) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
for (let j = 0; j < itemList.length; j++) { |
|
|
|
let storeItem = itemList[j]; |
|
|
|
if (Number(storeItem.l)) { |
|
|
|
itemTemp.push({ |
|
|
|
g: storeItem.g,//Store |
|
|
|
h: storeItem.h,//Barcode |
|
|
|
f: Number(storeItem.f),//Quantity of containers |
|
|
|
type: "G",//类型 |
|
|
|
j: 0,//Quantity per container(CH) |
|
|
|
k: 0,//Quantity per container(M) |
|
|
|
l: Number(storeItem.l),//Quantity per container(G) |
|
|
|
m: 0//Quantity per container(EG) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
for (let j = 0; j < itemList.length; j++) { |
|
|
|
let storeItem = itemList[j]; |
|
|
|
if (Number(storeItem.m)) { |
|
|
|
itemTemp.push({ |
|
|
|
g: storeItem.g,//Store |
|
|
|
h: storeItem.h,//Barcode |
|
|
|
f: Number(storeItem.f),//Quantity of containers |
|
|
|
type: "EG",//类型 |
|
|
|
j: 0,//Quantity per container(CH) |
|
|
|
k: 0,//Quantity per container(M) |
|
|
|
l: 0,//Quantity per container(G) |
|
|
|
m: Number(storeItem.m)//Quantity per container(EG) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = 0; i < itemTemp.length; i++) { |
|
|
|
let firstItem = itemTemp[i]; |
|
|
|
let hasBarcodeIndex = _.findIndex(sheetData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem.g && _.trim(o.Barcode)) |
|
|
|
let noBarcodeIndex = _.findIndex(sheetData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem.g && !_.trim(o.Barcode)) |
|
|
|
let hasBarcodeIndex = _.findIndex(sheetData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem[sdmc] && _.trim(o.Barcode)) |
|
|
|
let noBarcodeIndex = _.findIndex(sheetData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem[sdmc] && !_.trim(o.Barcode)) |
|
|
|
if (hasBarcodeIndex !== -1) { |
|
|
|
let hasBarcode = sheetData[hasBarcodeIndex] |
|
|
|
// 修改原来的值 |
|
|
|
hasBarcode["Barcode"] = firstItem.h |
|
|
|
hasBarcode["Quantity of containers"] += firstItem.f |
|
|
|
hasBarcode["Quantity to deliver"] += firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 |
|
|
|
hasBarcode["Quantity per container"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 |
|
|
|
let newItem = _.find(newData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem.g && _.trim(o.Barcode)) |
|
|
|
hasBarcode["Barcode"] = firstItem[tmt] |
|
|
|
hasBarcode["Quantity of containers"] += firstItem[xs] |
|
|
|
hasBarcode["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
|
|
hasBarcode["Quantity per container"] = firstItem[firstItem.typeKey] |
|
|
|
let newItem = _.find(newData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem[sdmc] && _.trim(o.Barcode)) |
|
|
|
// 修改新添加的值 |
|
|
|
newItem["Quantity of containers"] += firstItem.f |
|
|
|
newItem["Quantity to deliver"] += firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 |
|
|
|
newItem["Quantity of containers"] += firstItem[xs] |
|
|
|
newItem["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
|
|
// 再新增一条数据 |
|
|
|
newData.push({ |
|
|
|
...hasBarcode, |
|
|
|
"Barcode": firstItem.h, |
|
|
|
"Barcode": firstItem[tmt], |
|
|
|
"Quantity of containers": "", |
|
|
|
"Quantity to deliver": "", |
|
|
|
"Quantity per container": firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 |
|
|
|
"Quantity per container": firstItem[firstItem.typeKey] |
|
|
|
}) |
|
|
|
} |
|
|
|
if (noBarcodeIndex !== -1) { |
|
|
|
let noBarcode = sheetData[noBarcodeIndex] |
|
|
|
// 修改原有的值 |
|
|
|
noBarcode["Barcode"] = firstItem.h |
|
|
|
noBarcode["Quantity of containers"] = firstItem.f |
|
|
|
noBarcode["Quantity to deliver"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 |
|
|
|
noBarcode["Quantity per container"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 |
|
|
|
noBarcode["Barcode"] = firstItem[tmt] |
|
|
|
noBarcode["Quantity of containers"] = firstItem[xs] |
|
|
|
noBarcode["Quantity to deliver"] = firstItem[firstItem.typeKey] |
|
|
|
noBarcode["Quantity per container"] = firstItem[firstItem.typeKey] |
|
|
|
newData.push({ |
|
|
|
...noBarcode, |
|
|
|
}) |
|
|
@ -321,8 +307,8 @@ export default { |
|
|
|
let tableHeader = [] |
|
|
|
let tableData = [] |
|
|
|
let widthObj = { |
|
|
|
"Order":105, |
|
|
|
"Sku":165, |
|
|
|
"Order": 105, |
|
|
|
"Sku": 165, |
|
|
|
// "Description":126, |
|
|
|
"Type of merchandise": 100, |
|
|
|
"Quantity to deliver": 100, |
|
|
|