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) { 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 if (Number(storeItem.k)) {
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, G, AZUL MARINO WKM`)) { itemTemp.push({
element["Quantity per container"] = itemList[0].l g: storeItem.g,//Store
} h: storeItem.h,//Barcode
// EG f: Number(storeItem.f),//Quantity of containers
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, EG, AZUL MARINO WKM`)) { type: "M",//
element["Quantity per container"] = itemList[0].m j: 0,//Quantity per container(CH)
} k: Number(storeItem.k),//Quantity per container(M)
} else if (itemList.length > 1) { l: 0,//Quantity per container(G)
// j: "CH" k: "M" l: "G" m: "EG" m: 0//Quantity per container(EG)
// CH })
if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, CH, AZUL MARINO WKM`)) { }
let allCHData = _.filter(itemList, v => Number(v.j)) if (Number(storeItem.l)) {
let containerList = _.filter(sheetData, v => v.Store === element.Store && Number(v["Quantity per container"]) && _.startsWith(`${v.Description}`, `VESTIDO DISNEY DTR, CH, AZUL MARINO WKM`)) itemTemp.push({
let isHas = !!(containerList.length) g: storeItem.g,//Store
if (!isHas) { h: storeItem.h,//Barcode
element["Barcode"] = allCHData[0].h f: Number(storeItem.f),//Quantity of containers
// type: "G",//
element["Quantity of containers"] = _.sumBy(allCHData, o => Number(o.f)) j: 0,//Quantity per container(CH)
// CH k: 0,//Quantity per container(M)
element["Quantity per container"] = allCHData[0].j l: Number(storeItem.l),//Quantity per container(G)
// todo m: 0//Quantity per container(EG)
} })
else { }
let iteml = allCHData[containerList.length] if (Number(storeItem.m)) {
element["Barcode"] = iteml.h itemTemp.push({
// CH g: storeItem.g,//Store
element["Quantity per container"] = iteml.j h: storeItem.h,//Barcode
} f: Number(storeItem.f),//Quantity of containers
} type: "EG",//
// M j: 0,//Quantity per container(CH)
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, M, AZUL MARINO WKM`)) { k: 0,//Quantity per container(M)
let allCHData = _.filter(itemList, v => Number(v.k)) l: 0,//Quantity per container(G)
let containerList = _.filter(sheetData, v => v.Store === element.Store && Number(v["Quantity per container"]) && _.startsWith(`${v.Description}`, `VESTIDO DISNEY DTR, M, AZUL MARINO WKM`)) m: Number(storeItem.m)//Quantity per container(EG)
let isHas = !!(containerList.length) })
if (!isHas) { }
element["Barcode"] = allCHData[0].h }
// }
element["Quantity of containers"] = _.sumBy(allCHData, o => Number(o.f)) }
// M for (let i = 0; i < itemTemp.length; i++) {
element["Quantity per container"] = allCHData[0].k 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))
else { let noBarcodeIndex = _.findIndex(sheetData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem.g && !_.trim(o.Barcode))
let iteml = allCHData[containerList.length] if (hasBarcodeIndex !== -1) {
element["Barcode"] = iteml.h let hasBarcode = sheetData[hasBarcodeIndex]
// M //
element["Quantity per container"] = iteml.k hasBarcode["Barcode"] = firstItem.h
} hasBarcode["Quantity of containers"] += firstItem.f
} hasBarcode["Quantity to deliver"] += firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0
// G hasBarcode["Quantity per container"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, G, AZUL MARINO WKM`)) { let newItem = _.find(newData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem.g && _.trim(o.Barcode))
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`)) newItem["Quantity of containers"] += firstItem.f
let isHas = !!(containerList.length) newItem["Quantity to deliver"] += firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0
if (!isHas) { //
element["Barcode"] = allCHData[0].h newData.push({
// ...hasBarcode,
element["Quantity of containers"] = _.sumBy(allCHData, o => Number(o.f)) "Barcode": firstItem.h,
// G "Quantity of containers": "",
element["Quantity per container"] = allCHData[0].l "Quantity to deliver": "",
} "Quantity per container": firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0
else { })
let iteml = allCHData[containerList.length] }
element["Barcode"] = iteml.h if (noBarcodeIndex !== -1) {
// G let noBarcode = sheetData[noBarcodeIndex]
element["Quantity per container"] = iteml.l //
} noBarcode["Barcode"] = firstItem.h
} noBarcode["Quantity of containers"] = firstItem.f
// EG noBarcode["Quantity to deliver"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0
else if (_.startsWith(`${element.Description}`, `VESTIDO DISNEY DTR, EG, AZUL MARINO WKM`)) { noBarcode["Quantity per container"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0
let allCHData = _.filter(itemList, v => Number(v.m)) newData.push({
let containerList = _.filter(sheetData, v => v.Store === element.Store && Number(v["Quantity per container"]) && _.startsWith(`${v.Description}`, `VESTIDO DISNEY DTR, EG, AZUL MARINO WKM`)) ...noBarcode,
let isHas = !!(containerList.length) })
if (!isHas) { }
element["Barcode"] = allCHData[0].h }
// this.fileData2 = _.cloneDeep(newData)
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
} 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