Browse Source

1230

master
lichong 4 months ago
parent
commit
aa8b95739c
  1. 5
      src/main/index.js
  2. BIN
      src/renderer/src/assets/excel/尺码.xlsx
  3. BIN
      src/renderer/src/assets/excel/生成的资料.xlsx
  4. 6
      src/renderer/src/assets/js/db.js
  5. 11
      src/renderer/src/components/tablecomponent.vue
  6. 68
      src/renderer/src/views/chima.vue
  7. 87
      src/renderer/src/views/shujuchuli.vue
  8. 68
      src/renderer/src/views/ziliao.vue

5
src/main/index.js

@ -10,7 +10,8 @@ function createWindow() {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
minWidth: 1366, minWidth: 1366,
minHeight: 900, minHeight: 900,
height: 1260, height: 1020,
width: 1499,
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: true,
icon: logoIcon, icon: logoIcon,
@ -23,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)

BIN
src/renderer/src/assets/excel/尺码.xlsx

Binary file not shown.

BIN
src/renderer/src/assets/excel/生成的资料.xlsx

Binary file not shown.

6
src/renderer/src/assets/js/db.js

@ -3,8 +3,8 @@ import Dexie from 'dexie';
export const myDatabase = new Dexie('myDatabase'); export const myDatabase = new Dexie('myDatabase');
// 定义数据库版本 // 定义数据库版本
myDatabase.version(2).stores({ myDatabase.version(1).stores({
chima: '++id, 性别, US, 尺码2, 尺码1, 型号, 尺码代码, create_at, update_at', chima: '++id, 性别, US, 尺码2, 尺码1, 型号, &尺码代码, create_at, update_at',
ziliao: '++id, 品名, 货号, 商品, 颜色, 颜色描述, 尺码代码, 尺码2, 型号, 国标码, 款号, 零售价, 性别, 鞋面材料, 鞋底材料, 执行标准, 等级, 本厂分区, SKU, create_at, update_at', ziliao: '++id, 品名, 货号, 商品, 颜色, 颜色描述, 尺码代码, 尺码2, 型号, 国标码, 款号, 零售价, 性别, 鞋面材料, 鞋底材料, 执行标准, 等级, 本厂分区, &SKU, create_at, update_at',
shujuchuli: '++id, 唯一码, 防伪码, 品名, 货号, 颜色, 颜色代码, 尺码1, 型号, 尺码2, 尺码代码, SKU, 零售价, 等级, 鞋面材料, 执行标准, 国际码, 数量, 图片名称, 本厂分区, 下单数, create_at, update_at', shujuchuli: '++id, 唯一码, 防伪码, 品名, 货号, 颜色, 颜色代码, 尺码1, 型号, 尺码2, 尺码代码, SKU, 零售价, 等级, 鞋面材料, 执行标准, 国际码, 数量, 图片名称, 本厂分区, 下单数, create_at, update_at',
}); });

11
src/renderer/src/components/tablecomponent.vue

@ -7,6 +7,11 @@
:checkbox-config="{ labelField: 'seq', highlight: true }" @checkbox-all="selectAllChangeEvent" :checkbox-config="{ labelField: 'seq', highlight: true }" @checkbox-all="selectAllChangeEvent"
@checkbox-change="selectChange" ref="tableRef" border min-height="806px" @checkbox-change="selectChange" ref="tableRef" border min-height="806px"
:column-config="{ resizable: true }"> :column-config="{ resizable: true }">
<vxe-column type="seq" width="70">
<template #default="{ row, rowIndex }">
{{ pageVO.pageSize * (pageVO.currentPage - 1) + rowIndex + 1 }}
</template>
</vxe-column>
<vxe-column type="checkbox" width="60"></vxe-column> <vxe-column type="checkbox" width="60"></vxe-column>
<vxe-column :field="headerItem.prop" :title="headerItem.label" <vxe-column :field="headerItem.prop" :title="headerItem.label"
v-for="(headerItem, headerIndex) in tableHeader" :key="headerIndex" :sortable="headerItem.isSort" v-for="(headerItem, headerIndex) in tableHeader" :key="headerIndex" :sortable="headerItem.isSort"
@ -71,8 +76,8 @@ export default {
return { return {
total: 0, total: 0,
currentPage: 1, currentPage: 1,
pageSize: 16, pageSize: 17,
pageSizes: [16, 30, 50, 100] pageSizes: [17, 30, 50, 100]
} }
} }
}, },
@ -124,7 +129,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
.tableClass { .tableClass {
height: calc(100vh - 100px); height: calc(100vh - 102px);
text-align: center; text-align: center;
text-align-last: center; text-align-last: center;
} }

68
src/renderer/src/views/chima.vue

@ -87,8 +87,8 @@ export default {
pageVO: { pageVO: {
total: 0, total: 0,
currentPage: 1, currentPage: 1,
pageSize: 16, pageSize: 17,
pageSizes: [16, 30, 50, 100] pageSizes: [17, 30, 50, 100]
}, },
loading: false, loading: false,
fileOriData: null, fileOriData: null,
@ -117,7 +117,24 @@ export default {
let workbook = XLSX.read(data, { type: 'binary' }) let workbook = XLSX.read(data, { type: 'binary' })
let sheetName = workbook.SheetNames[0] 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])
that.fileData = _.concat(that.fileData, sheetData) let chimaList = []
for (let i = 0; i < sheetData.length; i++) {
let element = sheetData[i];
let item = {}
for (let key in element) {
item[_.trim(key)] = _.trim(element[key])
}
chimaList.push({ ...item, create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss') })
}
try {
await myDatabase.chima.bulkAdd(chimaList)
await that.updateSeach()
} catch (error) {
ElMessage({
message: error,
type: "error"
})
}
} }
fileReader.onerror = function (error) { fileReader.onerror = function (error) {
ElMessage({ ElMessage({
@ -157,51 +174,6 @@ export default {
formData: {} formData: {}
} }
}, },
//
async submitImport() {
let that = this
let dealDataObj = {
"销售数量": 1.2,
"销售金额": 1.2,
"退货数量": 1,
"退货金额": 1,
"数量小计": 1.2,
"金额小计": 1.2,
}
let allList = []
for (let i = 0; i < this.fileData.length; i++) {
let element = this.fileData[i];
let item = {}
for (let key in element) {
item[_.trim(key)] = _.trim(element[key])
}
if (item["行号"] && item["品名"] && item["供应商名称"]) {
for (let key in item) {
if (dealDataObj[_.trim(key)]) {
item[_.trim(key)] = Number((Number(_.trim(element[key])) * dealDataObj[_.trim(key)]).toFixed(2))
}
}
allList.push({
...item,
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss')
})
}
}
try {
await myDatabase.chima.bulkAdd(allList)
this.cancelDialog()
await that.updateSeach()
} catch (error) {
ElMessage({
message: `销售数据重复,error:${error}`,
type: 'error',
})
}
await that.updateSeach()
},
// //
async submitDialog() { async submitDialog() {
let params = { ...this.dialogFrom.formData, } let params = { ...this.dialogFrom.formData, }

87
src/renderer/src/views/shujuchuli.vue

@ -23,13 +23,13 @@
<span>清空</span> <span>清空</span>
</el-button> </el-button>
<el-upload :show-file-list="false" v-model="fileOriData" :before-upload="beforeAvatarUpload" <el-upload :show-file-list="false" v-model="fileOriData" :before-upload="beforeAvatarUpload"
:http-request="successSubmit" accept=".xls,.xlsx,.csv" :http-request="successSubmit" accept=".txt"
style="display: inline-block;position: relative;top: 3px;left: 12px;margin-right: 24px;" multiple> style="display: inline-block;position: relative;top: 3px;left: 12px;margin-right: 24px;" multiple>
<el-button type="success" size="large"> <el-button type="success" size="large">
<el-icon> <el-icon>
<Upload /> <Upload />
</el-icon> </el-icon>
<span>上传表格</span> <span>上传txt</span>
</el-button> </el-button>
</el-upload> </el-upload>
</el-col> </el-col>
@ -66,7 +66,15 @@ import { ElMessage, ElMessageBox } from 'element-plus'
export default { export default {
name: 'shujuchuli', name: 'shujuchuli',
components: { tablecomponent, formcomponent }, components: { tablecomponent, formcomponent },
watch: {}, watch: {
count: {
handler: function (val) {
if (val == 0) {
this.submitImport()
}
}
}
},
computed: {}, computed: {},
data() { data() {
return { return {
@ -87,21 +95,23 @@ export default {
pageVO: { pageVO: {
total: 0, total: 0,
currentPage: 1, currentPage: 1,
pageSize: 16, pageSize: 17,
pageSizes: [16, 30, 50, 100] pageSizes: [17, 30, 50, 100]
}, },
loading: false, loading: false,
fileOriData: null, fileOriData: null,
count: 0,
} }
}, },
methods: { methods: {
beforeAvatarUpload(rawFile) { beforeAvatarUpload(rawFile) {
let imgList = ['text/csv', 'application/vnd.ms-excel', "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] this.count++
let imgList = ["text/plain"]
if (imgList.indexOf(rawFile.type) === -1) { if (imgList.indexOf(rawFile.type) === -1) {
this.$msgbox.alert('请上传excel,csv格式的表格文件!') this.$msgbox.alert('请上传txt格式的文件!')
return false return false
} else if (rawFile.size / 1024 / 1024 > 50) { } else if (rawFile.size / 1024 / 1024 > 50) {
this.$msgbox.alert('表格文件的大小为小于50MB,数据过多时会处理过慢') this.$msgbox.alert('txt文件的大小为小于50MB,数据过多时会处理过慢')
return true return true
} }
return true return true
@ -118,6 +128,7 @@ export default {
let sheetName = workbook.SheetNames[0] 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])
that.fileData = _.concat(that.fileData, sheetData) that.fileData = _.concat(that.fileData, sheetData)
that.count--
} }
fileReader.onerror = function (error) { fileReader.onerror = function (error) {
ElMessage({ ElMessage({
@ -125,7 +136,7 @@ export default {
type: 'error', type: 'error',
}) })
} }
fileReader.readAsArrayBuffer(file) fileReader.readAsText(file, 'UTF-8')
}, },
// //
async updateSeach() { async updateSeach() {
@ -160,32 +171,46 @@ export default {
// //
async submitImport() { async submitImport() {
let that = this let that = this
let dealDataObj = { let skuObj = _.groupBy(this.fileData, 'SKU')
"销售数量": 1.2, let skuList = _.keys(skuObj)
"销售金额": 1.2, let ziliaocollection = myDatabase.ziliao
"退货数量": 1, if (skuList.length) {
"退货金额": 1, ziliaocollection = ziliaocollection.where('SKU').anyOf(skuList)
"数量小计": 1.2,
"金额小计": 1.2,
}
let allList = []
for (let i = 0; i < this.fileData.length; i++) {
let element = this.fileData[i];
let item = {}
for (let key in element) {
item[_.trim(key)] = _.trim(element[key])
}
if (item["行号"] && item["品名"] && item["供应商名称"]) {
for (let key in item) {
if (dealDataObj[_.trim(key)]) {
item[_.trim(key)] = Number((Number(_.trim(element[key])) * dealDataObj[_.trim(key)]).toFixed(2))
} }
let ziliaoList = await ziliaocollection.toArray()
let chimaObj = _.groupBy(ziliaoList, '尺码代码')
let chimadaimaList = _.keys(chimaObj)
let chimacollection = myDatabase.chima
if (chimadaimaList.length) {
chimacollection = chimacollection.where('尺码代码').anyOf(chimadaimaList)
} }
allList.push({ let chimaList = await chimacollection.toArray()
...item, let allList = []
for (let key in skuObj) {
let value = skuObj[key]
let ziliaoItem = _.find(ziliaoList, { SKU: key })
let chimaItem = _.find(chimaList, { 尺码代码: ziliaoItem.尺码代码 })
let valueLength = value.length
for (let i = 0; i < valueLength; i++) {
let element = value[i];
let listItem = {
...element,
...ziliaoItem,
...chimaItem,
"鞋面材料": `${_.trim(chimaItem["性别"])} ${_.trim(ziliaoItem["鞋面材料"])}/大底材质`,
"颜色": ziliaoItem["颜色描述"],
"执行标准": `${ziliaoItem["执行标准"]} `,
"颜色代码": ziliaoItem["颜色"],
"图片名称": `${ziliaoItem["货号"]}.jpg`,
"国际码": ziliaoItem["国标码"],
"数量": `${valueLength}`,
"下单数": ``,
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss') update_at: dayjs().format('YYYY-MM-DD HH:mm:ss')
}) }
delete listItem.id
allList.push(listItem)
} }
} }
try { try {

68
src/renderer/src/views/ziliao.vue

@ -87,8 +87,8 @@ export default {
pageVO: { pageVO: {
total: 0, total: 0,
currentPage: 1, currentPage: 1,
pageSize: 16, pageSize: 17,
pageSizes: [16, 30, 50, 100] pageSizes: [17, 30, 50, 100]
}, },
loading: false, loading: false,
fileOriData: null, fileOriData: null,
@ -117,7 +117,24 @@ export default {
let workbook = XLSX.read(data, { type: 'binary' }) let workbook = XLSX.read(data, { type: 'binary' })
let sheetName = workbook.SheetNames[0] 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])
that.fileData = _.concat(that.fileData, sheetData) let ziliaoList = []
for (let i = 0; i < sheetData.length; i++) {
let element = sheetData[i];
let item = {}
for (let key in element) {
item[_.trim(key)] = _.trim(element[key])
}
ziliaoList.push({ ...item, create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss') })
}
try {
await myDatabase.ziliao.bulkAdd(ziliaoList)
await that.updateSeach()
} catch (error) {
ElMessage({
message: error,
type: "error"
})
}
} }
fileReader.onerror = function (error) { fileReader.onerror = function (error) {
ElMessage({ ElMessage({
@ -157,51 +174,6 @@ export default {
formData: {} formData: {}
} }
}, },
//
async submitImport() {
let that = this
let dealDataObj = {
"销售数量": 1.2,
"销售金额": 1.2,
"退货数量": 1,
"退货金额": 1,
"数量小计": 1.2,
"金额小计": 1.2,
}
let allList = []
for (let i = 0; i < this.fileData.length; i++) {
let element = this.fileData[i];
let item = {}
for (let key in element) {
item[_.trim(key)] = _.trim(element[key])
}
if (item["行号"] && item["品名"] && item["供应商名称"]) {
for (let key in item) {
if (dealDataObj[_.trim(key)]) {
item[_.trim(key)] = Number((Number(_.trim(element[key])) * dealDataObj[_.trim(key)]).toFixed(2))
}
}
allList.push({
...item,
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss')
})
}
}
try {
await myDatabase.ziliao.bulkAdd(allList)
this.cancelDialog()
await that.updateSeach()
} catch (error) {
ElMessage({
message: `销售数据重复,error:${error}`,
type: 'error',
})
}
await that.updateSeach()
},
// //
async submitDialog() { async submitDialog() {
let params = { ...this.dialogFrom.formData, } let params = { ...this.dialogFrom.formData, }

Loading…
Cancel
Save