Browse Source

11.29

master
lichong 3 weeks ago
parent
commit
ed9bceca7f
  1. 208
      src/renderer/src/views/shujuguanli.vue

208
src/renderer/src/views/shujuguanli.vue

@ -192,124 +192,108 @@ export default {
},
dealData2(sheetData) {
let groupObj = _.groupBy(this.fileData1, 'g')
if (this.fileData1.length === 0) {
ElMessage({
message: `请先导入A表数据`,
type: 'error',
})
} else {
try {
for (let i = 0; i < sheetData.length; i++) {
let element = sheetData[i];
let itemList = groupObj[element.Store] || []
if (itemList.length === 1) {
// a: "STYLE NO." b: "STYLE NO." c: "" d: "" e: "" f: "" g: "" h: ""
// i: "" j: "CH" k: "M" l: "G" m: "EG" n: "" o: "" p: "\n(KGS)" q: "\n(KGS)"
// r: "\n(KGS)" s: "\n(KGS)" t: "" u: "" v: "" w: "CBM" x: ""
//
element["Barcode"] = itemList[0].h
//
element["Quantity of containers"] = itemList[0].f
// CH
if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, CH, AZUL MARINO WKM`)) {
element["Quantity per container"] = itemList[0].j
}
// M
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, M, AZUL MARINO WKM`)) {
element["Quantity per container"] = itemList[0].k
}
// G
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, G, AZUL MARINO WKM`)) {
element["Quantity per container"] = itemList[0].l
}
// EG
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, EG, AZUL MARINO WKM`)) {
element["Quantity per container"] = itemList[0].m
}
} else if (itemList.length > 1) {
// j: "CH" k: "M" l: "G" m: "EG"
// CH
if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, CH, AZUL MARINO WKM`)) {
let allCHData = _.filter(itemList, v => Number(v.j))
let containerList = _.filter(sheetData, v => v.Store === element.Store && Number(v["Quantity per container"]) && _.startsWith(`${v.Description}`, `VESTIDO DISNEY DTR, CH, AZUL MARINO WKM`))
let isHas = !!(containerList.length)
if (!isHas) {
element["Barcode"] = allCHData[0].h
//
element["Quantity of containers"] = _.sumBy(allCHData, o => Number(o.f))
// CH
element["Quantity per container"] = allCHData[0].j
// todo
}
else {
let iteml = allCHData[containerList.length]
element["Barcode"] = iteml.h
// CH
element["Quantity per container"] = iteml.j
}
}
// M
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, M, AZUL MARINO WKM`)) {
let allCHData = _.filter(itemList, v => Number(v.k))
let containerList = _.filter(sheetData, v => v.Store === element.Store && Number(v["Quantity per container"]) && _.startsWith(`${v.Description}`, `VESTIDO DISNEY DTR, M, AZUL MARINO WKM`))
let isHas = !!(containerList.length)
if (!isHas) {
element["Barcode"] = allCHData[0].h
//
element["Quantity of containers"] = _.sumBy(allCHData, o => Number(o.f))
// M
element["Quantity per container"] = allCHData[0].k
}
else {
let iteml = allCHData[containerList.length]
element["Barcode"] = iteml.h
// M
element["Quantity per container"] = iteml.k
}
}
// G
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, G, AZUL MARINO WKM`)) {
let allCHData = _.filter(itemList, v => Number(v.l))
let containerList = _.filter(sheetData, v => v.Store === element.Store && Number(v["Quantity per container"]) && _.startsWith(`${v.Description}`, `VESTIDO DISNEY DTR, G, AZUL MARINO WKM`))
let isHas = !!(containerList.length)
if (!isHas) {
element["Barcode"] = allCHData[0].h
//
element["Quantity of containers"] = _.sumBy(allCHData, o => Number(o.f))
// G
element["Quantity per container"] = allCHData[0].l
}
else {
let iteml = allCHData[containerList.length]
element["Barcode"] = iteml.h
// G
element["Quantity per container"] = iteml.l
}
}
// EG
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, EG, AZUL MARINO WKM`)) {
let allCHData = _.filter(itemList, v => Number(v.m))
let containerList = _.filter(sheetData, v => v.Store === element.Store && Number(v["Quantity per container"]) && _.startsWith(`${v.Description}`, `VESTIDO DISNEY DTR, EG, AZUL MARINO WKM`))
let isHas = !!(containerList.length)
if (!isHas) {
element["Barcode"] = allCHData[0].h
//
element["Quantity of containers"] = _.sumBy(allCHData, o => Number(o.f))
// EG
element["Quantity per container"] = allCHData[0].m
}
else {
let iteml = allCHData[containerList.length]
element["Barcode"] = iteml.h
// EG
element["Quantity per container"] = iteml.m
}
}
}
}
this.fileData2 = sheetData
let itemTemp = []
let newData = []
for (let key in groupObj) {
if (key && _.isNumber(Number(key))) {
let itemList = groupObj[key] || []
for (let j = 0; j < itemList.length; j++) {
let storeItem = itemList[j];
if (Number(storeItem.j)) {
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)
})
}
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)
})
}
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)
})
}
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))
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))
//
newItem["Quantity of containers"] += firstItem.f
newItem["Quantity to deliver"] += firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0
//
newData.push({
...hasBarcode,
"Barcode": firstItem.h,
"Quantity of containers": "",
"Quantity to deliver": "",
"Quantity per container": firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0
})
}
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
newData.push({
...noBarcode,
})
}
}
this.fileData2 = _.cloneDeep(newData)
} catch (error) {
ElMessage({
message: `表格处理出错:, ${error}`,
@ -351,7 +335,7 @@ export default {
let lilstLocal = []
for (let i = 0; i < listCopy.length; i++) {
let item = listCopy[i];
lilstLocal.push({ ...item, 'Quantity to deliver': item["Quantity to deliver"].toFixed(3) })
lilstLocal.push({ ...item, 'Quantity to deliver': item["Quantity to deliver"] ? item["Quantity to deliver"].toFixed(3) : "" })
}
let jsonWorkSheet = XLSX.utils.json_to_sheet(lilstLocal);
for (let index = 0; index < newHeaders.length; index++) {

Loading…
Cancel
Save