Browse Source

12.3

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

2
package.json

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

128
src/renderer/src/views/shujuguanli.vue

@ -71,6 +71,8 @@ export default {
fileData2: [], fileData2: [],
tableData: [], tableData: [],
loading: false, loading: false,
chimaList: [],
otherChangeList: [],
} }
}, },
methods: { methods: {
@ -103,6 +105,8 @@ export default {
let sheetName = workbook.SheetNames[0]; let sheetName = workbook.SheetNames[0];
let sheetData = workbook.Sheets[sheetName]; let sheetData = workbook.Sheets[sheetName];
let range = XLSX.utils.decode_range(sheetData['!ref']); 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']; let mergeRanges = sheetData['!merges'];
if (!mergeRanges) { if (!mergeRanges) {
@ -117,6 +121,19 @@ export default {
r: rowIndex r: rowIndex
})]; })];
let cellContent = ''; 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) { if (cell && cell.t) {
cellContent = XLSX.utils.format_cell(cell); cellContent = XLSX.utils.format_cell(cell);
} }
@ -192,7 +209,6 @@ export default {
fileReader.readAsArrayBuffer(file) fileReader.readAsArrayBuffer(file)
}, },
dealData2(sheetData) { dealData2(sheetData) {
let groupObj = _.groupBy(this.fileData1, 'g')
if (this.fileData1.length === 0) { if (this.fileData1.length === 0) {
ElMessage({ ElMessage({
message: `请先导入A表数据`, message: `请先导入A表数据`,
@ -200,104 +216,74 @@ export default {
}) })
} else { } else {
try { 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 itemTemp = []
let newData = [] let newData = []
for (let key in groupObj) { for (let key in groupObj) {
if (key && _.isNumber(Number(key))) { if (key && _.isNumber(Number(key))) {
let itemList = groupObj[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++) { for (let j = 0; j < itemList.length; j++) {
let storeItem = itemList[j]; let storeItem = itemList[j];
if (Number(storeItem.j)) { if (Number(storeItem[chimaItem.key])) {
itemTemp.push({ itemTemp.push({
g: storeItem.g,//Store [sdmc]: storeItem[sdmc],//Store
h: storeItem.h,//Barcode [tmt]: storeItem[tmt],//Barcode
f: Number(storeItem.f),//Quantity of containers [xs]: Number(storeItem[xs]),//Quantity of containers
type: "CH",// type: chimaItem.value,//
j: Number(storeItem.j),//Quantity per container(CH) [chimaItem.key]: Number(storeItem[chimaItem.key]),//Quantity per container(CH)
k: 0,//Quantity per container(M) typeKey: chimaItem.key,
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.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++) { for (let i = 0; i < itemTemp.length; i++) {
let firstItem = itemTemp[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 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.g && !_.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) { if (hasBarcodeIndex !== -1) {
let hasBarcode = sheetData[hasBarcodeIndex] let hasBarcode = sheetData[hasBarcodeIndex]
// //
hasBarcode["Barcode"] = firstItem.h hasBarcode["Barcode"] = firstItem[tmt]
hasBarcode["Quantity of containers"] += firstItem.f hasBarcode["Quantity of containers"] += firstItem[xs]
hasBarcode["Quantity to deliver"] += firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 hasBarcode["Quantity to deliver"] += firstItem[firstItem.typeKey]
hasBarcode["Quantity per container"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 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.g && _.trim(o.Barcode)) 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 of containers"] += firstItem[xs]
newItem["Quantity to deliver"] += firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 newItem["Quantity to deliver"] += firstItem[firstItem.typeKey]
// //
newData.push({ newData.push({
...hasBarcode, ...hasBarcode,
"Barcode": firstItem.h, "Barcode": firstItem[tmt],
"Quantity of containers": "", "Quantity of containers": "",
"Quantity to deliver": "", "Quantity to deliver": "",
"Quantity per container": firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 "Quantity per container": firstItem[firstItem.typeKey]
}) })
} }
if (noBarcodeIndex !== -1) { if (noBarcodeIndex !== -1) {
let noBarcode = sheetData[noBarcodeIndex] let noBarcode = sheetData[noBarcodeIndex]
// //
noBarcode["Barcode"] = firstItem.h noBarcode["Barcode"] = firstItem[tmt]
noBarcode["Quantity of containers"] = firstItem.f noBarcode["Quantity of containers"] = firstItem[xs]
noBarcode["Quantity to deliver"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 noBarcode["Quantity to deliver"] = firstItem[firstItem.typeKey]
noBarcode["Quantity per container"] = firstItem.j || firstItem.k || firstItem.l || firstItem.m || 0 noBarcode["Quantity per container"] = firstItem[firstItem.typeKey]
newData.push({ newData.push({
...noBarcode, ...noBarcode,
}) })
@ -321,8 +307,8 @@ export default {
let tableHeader = [] let tableHeader = []
let tableData = [] let tableData = []
let widthObj = { let widthObj = {
"Order":105, "Order": 105,
"Sku":165, "Sku": 165,
// "Description":126, // "Description":126,
"Type of merchandise": 100, "Type of merchandise": 100,
"Quantity to deliver": 100, "Quantity to deliver": 100,

Loading…
Cancel
Save