Browse Source

12.16

master
lichong 5 days ago
parent
commit
02e8835e11
  1. BIN
      a表类型.docx
  2. 2
      package.json
  3. 4
      src/main/index.js
  4. 2
      src/renderer/src/App.vue
  5. BIN
      src/renderer/src/assets/images/a1.png
  6. BIN
      src/renderer/src/assets/images/a2.png
  7. BIN
      src/renderer/src/assets/images/a3.png
  8. BIN
      src/renderer/src/assets/images/a4.png
  9. BIN
      src/renderer/src/assets/images/a5.png
  10. 3
      src/renderer/src/components/tablecomponent.vue
  11. 400
      src/renderer/src/views/shujuguanli.vue

BIN
a表类型.docx

Binary file not shown.

2
package.json

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

4
src/main/index.js

@ -10,8 +10,8 @@ function createWindow() {
mainWindow = new BrowserWindow({
minWidth: 1366,
minHeight: 900,
height: 1260,
width: 1730,
height: 900,
width: 1366,
show: false,
autoHideMenuBar: true,
icon: logoIcon,

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-17T00:00:00').valueOf()
if (!this.isVip) {
if (dayjs().valueOf() > fiveDay) {
this.isVip = false

BIN
src/renderer/src/assets/images/a1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

BIN
src/renderer/src/assets/images/a2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

BIN
src/renderer/src/assets/images/a3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 KiB

BIN
src/renderer/src/assets/images/a4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

BIN
src/renderer/src/assets/images/a5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

3
src/renderer/src/components/tablecomponent.vue

@ -10,7 +10,8 @@
v-for="(headerItem, headerIndex) in tableHeader" :key="headerIndex" :sortable="headerItem.isSort">
<template #default="{ row }">
<template v-if="headerItem.type === 'text'">
<span>{{ row[headerItem.prop] }}</span>
<span>{{ headerItem.width }}</span>
<span>!{{ row[headerItem.prop] }}</span>
</template>
<template v-else>
<span> {{ headerItem.type }}!{{ row[headerItem.prop] }}</span>

400
src/renderer/src/views/shujuguanli.vue

@ -5,12 +5,96 @@
<el-col>
<div class="inputClass uploadClass">
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload"
:http-request="successSubmit1" accept=".xls,.xlsx,.csv">
:http-request="async opts => await successSubmit1(opts, 'a1')" accept=".xls,.xlsx,.csv">
<el-button type="success">
<el-icon>
<Upload />
</el-icon>
<span>导入A表</span>
<el-tooltip>
<template #content>
<div>
<el-image style="width: 100px; height: 100px" :preview-src-list="[url1]" :src="url1"
fit="scale-down" />
</div>
</template>
<span>导入A1表</span>
</el-tooltip>
</el-button>
</el-upload>
</div>
<div class="inputClass uploadClass">
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload"
:http-request="async opts => await successSubmit1(opts, 'a2')" accept=".xls,.xlsx,.csv">
<el-button type="success">
<el-icon>
<Upload />
</el-icon>
<el-tooltip>
<template #content>
<div>
<el-image style="width: 100px; height: 100px" :preview-src-list="[url2]" :src="url2"
fit="scale-down" />
</div>
</template>
<span>导入A2表</span>
</el-tooltip>
</el-button>
</el-upload>
</div>
<div class="inputClass uploadClass">
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload"
:http-request="async opts => await successSubmit1(opts, 'a3')" accept=".xls,.xlsx,.csv">
<el-button type="success">
<el-icon>
<Upload />
</el-icon>
<el-tooltip>
<template #content>
<div>
<el-image style="width: 100px; height: 100px" :preview-src-list="[url3]" :src="url3"
fit="scale-down" />
</div>
</template>
<span>导入A3表</span>
</el-tooltip>
</el-button>
</el-upload>
</div>
<div class="inputClass uploadClass">
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload"
:http-request="async opts => await successSubmit1(opts, 'a4')" accept=".xls,.xlsx,.csv">
<el-button type="success">
<el-icon>
<Upload />
</el-icon>
<el-tooltip>
<template #content>
<div>
<el-image style="width: 100px; height: 100px" :preview-src-list="[url4]" :src="url4"
fit="scale-down" />
</div>
</template>
<span>导入A4表</span>
</el-tooltip>
</el-button>
</el-upload>
</div>
<div class="inputClass uploadClass">
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload"
:http-request="async opts => await successSubmit1(opts, 'a5')" accept=".xls,.xlsx,.csv">
<el-button type="success">
<el-icon>
<Upload />
</el-icon>
<el-tooltip>
<template #content>
<div>
<el-image style="width: 100px; height: 100px" :preview-src-list="[url5]" :src="url5"
fit="scale-down" />
</div>
</template>
<span>导入A5表</span>
</el-tooltip>
</el-button>
</el-upload>
</div>
@ -37,6 +121,12 @@
</el-icon>
<span>导出</span>
</el-button>
<el-button type="danger" @click="refrash">
<el-icon>
<Refresh />
</el-icon>
<span>清空数据</span>
</el-button>
</el-col>
</el-row>
</div>
@ -48,8 +138,13 @@
</template>
<script>
import _, { min } from 'lodash'
import _ from 'lodash'
import dayjs from 'dayjs'
import urla1 from "../assets/images/a1.png"
import urla2 from "../assets/images/a2.png"
import urla3 from "../assets/images/a3.png"
import urla4 from "../assets/images/a4.png"
import urla5 from "../assets/images/a5.png"
import * as XLSX from 'xlsx';
import ExcelJS from "exceljs";
import tablecomponent from "../components/tablecomponent.vue"
@ -62,17 +157,22 @@ export default {
data() {
return {
_: _,
url1: urla1,
url2: urla2,
url3: urla3,
url4: urla4,
url5: urla5,
dayjs: dayjs,
tableHeader: [],
fileOriData1: null,
fileData1: [],
fileData1Header: {},
fileOriData2: null,
fileData2: [],
tableData: [],
loading: false,
chimaList: [],
otherChangeList: [],
atype: "",
}
},
methods: {
@ -92,7 +192,7 @@ export default {
return true
},
//A
async successSubmit1(opts) {
async successSubmit1(opts, fun) {
let that = this
let file = opts.file
this.fileDealData = []
@ -104,6 +204,22 @@ export default {
//
let sheetName = workbook.SheetNames[0];
let sheetData = workbook.Sheets[sheetName];
that.atype = fun
that.chimaList = []
that.otherChangeList = []
that[fun](sheetData)
}
fileReader.onerror = function (error) {
ElMessage({
message: `Error reading file:, ${error}`,
type: 'error',
})
}
fileReader.readAsArrayBuffer(file)
},
//
async a1(sheetData) {
let that = this
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)]
@ -169,20 +285,230 @@ export default {
}
allCells.push(newRow);
}
that.fileData1Header = { ...allCells[3] }
ElMessage({
message: `导入成功,请导入下一个文件`,
type: 'success',
duration: 500,
})
that.fileData1 = allCells
},
//
async a2(sheetData) {
let that = this
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'];
if (!mergeRanges) {
mergeRanges = [];
}
let allCells = [];
for (let rowIndex = range.s.r; rowIndex <= range.e.r; ++rowIndex) {
let newRow = {};
for (let colIndex = range.s.c; colIndex <= range.e.c; ++colIndex) {
let cell = sheetData[XLSX.utils.encode_cell({
c: colIndex,
r: rowIndex
})];
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) {
cellContent = XLSX.utils.format_cell(cell);
}
//
let isMergedCell = false;
for (let i = 0; i < mergeRanges.length; i++) {
let mergeRange = mergeRanges[i];
if (rowIndex >= mergeRange.s.r && rowIndex <= mergeRange.e.r &&
colIndex >= mergeRange.s.c && colIndex <= mergeRange.e.c) {
isMergedCell = true;
break;
}
}
if (isMergedCell) {
//
for (let i = 0; i < mergeRanges.length; i++) {
let mergeRange = mergeRanges[i];
if (rowIndex >= mergeRange.s.r && rowIndex <= mergeRange.e.r &&
colIndex >= mergeRange.s.c && colIndex <= mergeRange.e.c) {
let topLeftCell = sheetData[XLSX.utils.encode_cell({
c: mergeRange.s.c,
r: mergeRange.s.r
})];
if (topLeftCell && topLeftCell.t) {
cellContent = XLSX.utils.format_cell(topLeftCell);
}
break;
}
}
}
newRow[String.fromCharCode("a".charCodeAt() + colIndex)] = cellContent;
}
allCells.push(newRow);
}
fileReader.onerror = function (error) {
ElMessage({
message: `Error reading file:, ${error}`,
type: 'error',
message: `导入成功,请导入下一个文件`,
type: 'success',
duration: 500,
})
that.fileData1 = allCells
},
//
async a3(sheetData) {
let that = this
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'];
if (!mergeRanges) {
mergeRanges = [];
}
fileReader.readAsArrayBuffer(file)
let allCells = [];
for (let rowIndex = range.s.r; rowIndex <= range.e.r; ++rowIndex) {
let newRow = {};
for (let colIndex = range.s.c; colIndex <= range.e.c; ++colIndex) {
let cell = sheetData[XLSX.utils.encode_cell({
c: colIndex,
r: rowIndex
})];
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) {
cellContent = XLSX.utils.format_cell(cell);
}
//
let isMergedCell = false;
for (let i = 0; i < mergeRanges.length; i++) {
let mergeRange = mergeRanges[i];
if (rowIndex >= mergeRange.s.r && rowIndex <= mergeRange.e.r &&
colIndex >= mergeRange.s.c && colIndex <= mergeRange.e.c) {
isMergedCell = true;
break;
}
}
if (isMergedCell) {
//
for (let i = 0; i < mergeRanges.length; i++) {
let mergeRange = mergeRanges[i];
if (rowIndex >= mergeRange.s.r && rowIndex <= mergeRange.e.r &&
colIndex >= mergeRange.s.c && colIndex <= mergeRange.e.c) {
let topLeftCell = sheetData[XLSX.utils.encode_cell({
c: mergeRange.s.c,
r: mergeRange.s.r
})];
if (topLeftCell && topLeftCell.t) {
cellContent = XLSX.utils.format_cell(topLeftCell);
}
break;
}
}
}
newRow[String.fromCharCode("a".charCodeAt() + colIndex)] = cellContent;
}
allCells.push(newRow);
}
ElMessage({
message: `导入成功,请导入下一个文件`,
type: 'success',
duration: 500,
})
that.fileData1 = allCells
},
//
async a4(sheetData) {
let sheetDataTemp = XLSX.utils.sheet_to_json(sheetData)
for (let key in sheetDataTemp[0]) {
if (key === "商店") {
this.otherChangeList.push({
key: key,
value: "商店名称"
})
} else if (key === "箱数") {
this.otherChangeList.push({
key: key,
value: "箱数"
})
} else if (key === "SKU") {
this.otherChangeList.push({
key: key,
value: "条码贴"
})
} else if (!_.isNaN(parseInt(key))) {
this.chimaList.push({
key: key,
value: key
})
}
}
ElMessage({
message: `导入成功,请导入下一个文件`,
type: 'success',
duration: 500,
})
this.fileData1 = _.cloneDeep(sheetDataTemp)
},
//
async a5(sheetData) {
let sheetDataTemp = XLSX.utils.sheet_to_json(sheetData)
for (let key in sheetDataTemp[0]) {
if (key === "Store店铺") {
this.otherChangeList.push({
key: key,
value: "商店名称"
})
} else if (key === "箱数") {
this.otherChangeList.push({
key: key,
value: "箱数"
})
} else if (key === "Sku") {
this.otherChangeList.push({
key: key,
value: "条码贴"
})
} else if (!_.isNaN(parseInt(key))) {
this.chimaList.push({
key: key,
value: key
})
}
}
ElMessage({
message: `导入成功,请导入下一个文件`,
type: 'success',
duration: 500,
})
this.fileData1 = _.cloneDeep(sheetDataTemp)
},
//B
async successSubmit2(opts) {
@ -194,11 +520,20 @@ export default {
let data = this.result
let workbook = XLSX.read(data, { type: 'binary' })
let sheetName = workbook.SheetNames[0]
let sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName])
let sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName],)
for (let i = 0; i < sheetData.length; i++) {
let element = sheetData[i];
for (let key in element) {
let keyTemp = key.replaceAll("\r", "")
keyTemp = keyTemp.replaceAll("\n", "")
element[keyTemp] = element[key]
}
}
that.dealData2(sheetData)
ElMessage({
message: `导入成功,请预览或者导出`,
type: 'success',
duration: 500,
})
}
fileReader.onerror = function (error) {
@ -256,8 +591,25 @@ export default {
}
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[sdmc] && _.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))
let hasBarcodeIndex
let noBarcodeIndex
if (this.atype === "a1") {
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}, `) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}, `) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode))
} else if (this.atype === "a2") {
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode))
} else if (this.atype === "a3") {
let typeTemp = firstItem.type.replace(/([0-9])([a-zA-Z])/g, '$1 $2').replace(/([a-zA-Z])([0-9])/g, '$1 $2')
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode))
} else if (this.atype === "a4") {
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode))
} else if (this.atype === "a5") {
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode))
}
if (hasBarcodeIndex !== -1) {
let hasBarcode = sheetData[hasBarcodeIndex]
//
@ -265,7 +617,19 @@ export default {
hasBarcode["Quantity of containers"] += firstItem[xs]
hasBarcode["Quantity to deliver"] += firstItem[firstItem.typeKey]
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[sdmc] && _.trim(o.Barcode))
let newItem = ""
if (this.atype === "a1") {
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}, `) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
} else if (this.atype === "a2") {
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
} else if (this.atype === "a3") {
let typeTemp = firstItem.type.replace(/([0-9])([a-zA-Z])/g, '$1 $2').replace(/([a-zA-Z])([0-9])/g, '$1 $2')
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
} else if (this.atype === "a4") {
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
} else if (this.atype === "a5") {
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode))
}
//
newItem["Quantity of containers"] += firstItem[xs]
newItem["Quantity to deliver"] += firstItem[firstItem.typeKey]
@ -277,8 +641,7 @@ export default {
"Quantity to deliver": "",
"Quantity per container": firstItem[firstItem.typeKey]
})
}
if (noBarcodeIndex !== -1) {
} else if (noBarcodeIndex !== -1) {
let noBarcode = sheetData[noBarcodeIndex]
//
noBarcode["Barcode"] = firstItem[tmt]
@ -412,6 +775,11 @@ export default {
downloadExcel();
},
//
refrash() {
//
location.reload();
}
},
async mounted() { },
}

Loading…
Cancel
Save