Browse Source

11.22

master
lichong 4 weeks ago
parent
commit
99d39fe745
  1. 2
      package.json
  2. 2
      src/main/index.js
  3. 2
      src/renderer/src/App.vue
  4. 12
      src/renderer/src/components/tablecomponent.vue
  5. 254
      src/renderer/src/views/shujuguanli.vue

2
package.json

@ -6,7 +6,7 @@
"author": "lichong",
"homepage": "https://www.electronjs.org",
"scripts": {
"npmi": "npm i",
"npmi": "npm i -d",
"dev": "electron-vite dev",
"build": "electron-vite build",
"build:win": "npm run build && electron-builder --win --config",

2
src/main/index.js

@ -24,7 +24,7 @@ function createWindow() {
})
mainWindow.on('ready-to-show', () => {
mainWindow.show()
mainWindow.webContents.openDevTools()
// mainWindow.webContents.openDevTools()
})
mainWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url)

2
src/renderer/src/App.vue

@ -30,7 +30,7 @@ export default {
methods: {
},
async mounted() {
let fiveDay = dayjs('2024-12-7T00:00:00').valueOf()
let fiveDay = dayjs('2024-12-1T00:00:00').valueOf()
if (!this.isVip) {
if (dayjs().valueOf() > fiveDay) {
this.isVip = false

12
src/renderer/src/components/tablecomponent.vue

@ -13,17 +13,9 @@
<template v-if="headerItem.type === 'text'">
<span>{{ row[headerItem.prop] }}</span>
</template>
<template v-else-if="headerItem.type === 'date'">
<span>{{ dayjs(row[headerItem.prop]).format("YYYY-MM-DD HH:mm:ss") }}</span>
<template v-else>
<span>{{ headerItem.type }}!{{ row[headerItem.prop] }}</span>
</template>
<template v-else-if="headerItem.type === 'photo'">
<span v-if="row[headerItem.prop]">
<el-image style="width: 45px" :src="row[headerItem.prop]" :zoom-rate="1.2" :max-scale="7"
:min-scale="0.2" :preview-src-list="[row[headerItem.prop]]" :initial-index="4" fit="cover" />
</span>
<span v-else></span>
</template>
<template v-else>{{ row[headerItem.prop] }}</template>
</template>
</vxe-column>
</vxe-table>

254
src/renderer/src/views/shujuguanli.vue

@ -17,7 +17,7 @@
<div class="inputClass uploadClass">
<el-upload :show-file-list="false" v-model="fileOriData2" :before-upload="beforeAvatarUpload"
:http-request="successSubmit2" accept=".xls,.xlsx,.csv">
<el-button type="success">
<el-button type="success" :disabled="!fileData1.length">
<el-icon>
<Upload />
</el-icon>
@ -25,13 +25,13 @@
</el-button>
</el-upload>
</div>
<el-button type="primary" @click="viewTable" :disabled="!tableData.length">
<el-button type="primary" @click="viewTable" :disabled="!fileData2.length">
<el-icon>
<Download />
</el-icon>
<span>预览</span>
</el-button>
<el-button type="primary" @click="exportData" :disabled="!tableData.length">
<el-button type="primary" @click="exportData" :disabled="!fileData2.length">
<el-icon>
<Download />
</el-icon>
@ -41,7 +41,7 @@
</el-row>
</div>
<div v-loading="loading">
<tablecomponent :tableHeader="tableHeader" :tableData="fileData2" ref="tableComponentRef">
<tablecomponent :tableHeader="tableHeader" :tableData="tableData" ref="tableComponentRef">
</tablecomponent>
</div>
</div>
@ -64,9 +64,10 @@ export default {
dayjs: dayjs,
tableHeader: [],
fileOriData1: null,
fileData1: null,
fileData1: [],
fileData1Header: {},
fileOriData2: null,
fileData2: null,
fileData2: [],
tableData: [],
loading: false,
}
@ -149,7 +150,7 @@ export default {
}
allCells.push(newRow);
}
console.log(122, allCells);
that.fileData1Header = { ...allCells[3] }
that.fileData1 = allCells
}
fileReader.onerror = function (error) {
@ -182,142 +183,181 @@ export default {
fileReader.readAsArrayBuffer(file)
},
dealData2(sheetData) {
console.log(155, 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 = _.filter(this.fileData1, o => {
// CH
if (`${o.G4}` === `${element.Store}` && `${o.H4}` === `${element.Order}`) {
return true
} else {
return false
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 (`${o.G4}` === `${element.Store}` && `${o.H4}` === `${element.Order}` && `${element.Description}` === `VESTIDO DISNEY DTR, CH, AZUL MARINO WKM`) {
// }
// // G
// else if (`${o.G4}` === `${element.Store}` && `${o.H4}` === `${element.Order}` && `${element.Description}` === `VESTIDO DISNEY DTR, CH, AZUL MARINO WKM`) {
// }
// // EG
// else if (`${o.G4}` === `${element.Store}` && `${o.H4}` === `${element.Order}` && `${element.Description}` === `VESTIDO DISNEY DTR, CH, AZUL MARINO WKM`) {
// }
// Description: "VESTIDO DISNEY DTR, CH, AZUL MARINO WKM"
// Order: "6000046296"
// Store: "0000000491"
})
for (let j = 0; j < itemList.length; j++) {
let item = itemList[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
}
}
that.fileData2 = sheetData
}
},
//
//
xlsxMergeParse(merges) {
let arr = []
merges.map(v => {
let { s, e } = v
let result = []
let addNum = 1 //使Excel
if (s.c === e.c) {
for (let i = s.r; i < e.r + 1; i++) { result.push([i + addNum, s.c + addNum]) }
} else {
for (let i = s.c; i < e.c + 1; i++) { result.push([s.r + addNum, i + addNum]) }
}
arr.push(result)
this.fileData2 = sheetData
} catch (error) {
ElMessage({
message: `表格处理出错:, ${error}`,
type: 'error',
duration: 0,
showClose: true
})
}
return arr
}
},
//
//
mergeIndex(mergesParse) {
let datas = []
mergesParse.map((v, i) => {
let row = []
v.map((v1, i1) => {
row.push(v1.join(','))
row.push([i, i1].join('-'))
//
viewTable() {
let that = this
let tableHeader = []
let tableData = []
for (let key in that.fileData2[0]) {
tableHeader.push({
prop: key,
label: key,
type: "text"
})
datas.push(row)
}
for (let index = 0; index < that.fileData2.length; index++) {
let element = that.fileData2[index];
tableData.push({
...element
})
return datas.flat(Infinity)
},
//
autoFill(point, index, mergesParses, sheetData) {
//
let isNeed = index.indexOf(point.join(','))
if (isNeed < 0) return undefined
//
let target = index[isNeed + 1]
let result = target.split('-')[0]
result = mergesParses[result][0]
//
result = sheetData[String.fromCharCode(result[1] + 64) + result[0]].w
return result
}
this.tableHeader = tableHeader
this.tableData = tableData
},
//
viewTable() { },
//
async exportData() {
let listCopy = _.cloneDeep(this.tableData)
let that = this
let listCopy = _.cloneDeep(that.fileData2)
//
let newHeaders = ["Order", "Sku", "Description", "Type of merchandise", "Quantity to deliver", "Store", "Quantity of containers", "Barcode", "Quantity per container", "Total", "Cluster", "", "", "", ""]
let lilstLocal = []
for (let i = 0; i < listCopy.length; i++) {
let item = listCopy[i];
let listItem = {}
for (let j = 0; j < this.exportHeader.length; j++) {
let headerItem = this.exportHeader[j];
listItem[headerItem.label] = item[`${headerItem.prop}_org`] || item[`${headerItem.prop}`]
}
lilstLocal.push(listItem)
}
console.log(135, lilstLocal);
// let jsonWorkSheet = XLSX.utils.json_to_sheet(lilstLocal);
// let workBook = {
// SheetNames: ["sheet1"],
// Sheets: {
// ["sheet1"]: jsonWorkSheet,
// }
// };
// XLSX.writeFile(workBook, `${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.xls`);
lilstLocal.push({ ...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++) {
let element = newHeaders[index];
//
jsonWorkSheet[`${XLSX.utils.encode_cell({ c: index, r: 0 })}`].v = element
}
let workBook = {
SheetNames: ["sheet1"],
Sheets: {
["sheet1"]: jsonWorkSheet,
}
};
XLSX.writeFile(workBook, `数据表格管理${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.xls`);
},
},
async mounted() { },

Loading…
Cancel
Save