Browse Source

11.29

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

194
src/renderer/src/views/shujuguanli.vue

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

Loading…
Cancel
Save