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. 284
      src/renderer/src/views/shujuguanli.vue

2
package.json

@ -6,7 +6,7 @@
"author": "lichong", "author": "lichong",
"homepage": "https://www.electronjs.org", "homepage": "https://www.electronjs.org",
"scripts": { "scripts": {
"npmi": "npm i", "npmi": "npm i -d",
"dev": "electron-vite dev", "dev": "electron-vite dev",
"build": "electron-vite build", "build": "electron-vite build",
"build:win": "npm run build && electron-builder --win --config", "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.on('ready-to-show', () => {
mainWindow.show() mainWindow.show()
mainWindow.webContents.openDevTools() // mainWindow.webContents.openDevTools()
}) })
mainWindow.webContents.setWindowOpenHandler((details) => { mainWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url) shell.openExternal(details.url)

2
src/renderer/src/App.vue

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

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

@ -13,17 +13,9 @@
<template v-if="headerItem.type === 'text'"> <template v-if="headerItem.type === 'text'">
<span>{{ row[headerItem.prop] }}</span> <span>{{ row[headerItem.prop] }}</span>
</template> </template>
<template v-else-if="headerItem.type === 'date'"> <template v-else>
<span>{{ dayjs(row[headerItem.prop]).format("YYYY-MM-DD HH:mm:ss") }}</span> <span>{{ headerItem.type }}!{{ row[headerItem.prop] }}</span>
</template> </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> </template>
</vxe-column> </vxe-column>
</vxe-table> </vxe-table>

284
src/renderer/src/views/shujuguanli.vue

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

Loading…
Cancel
Save