Browse Source

12.3

master
lichong 3 weeks ago
parent
commit
b91987f822
  1. 2
      package.json
  2. 124
      src/renderer/src/views/shujuguanli.vue

2
package.json

@ -1,6 +1,6 @@
{
"name": "electron",
"version": "1.0.1",
"version": "1.0.2",
"description": "An Electron application with Vue",
"main": "./out/main/index.js",
"author": "lichong",

124
src/renderer/src/views/shujuguanli.vue

@ -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,
})

Loading…
Cancel
Save