This commit is contained in:
liushiwei
2023-08-29 13:42:07 +08:00
parent f7749d1a94
commit 37bafe6279

View File

@@ -16,9 +16,14 @@
</el-option>
<el-option
key="1"
label="近30天销售"
label="近30天销售(按SKU)"
value="1">
</el-option>
<el-option
key="2"
label="近30天销售(按SKC)"
value="2">
</el-option>
</el-select>
</div>
<div>
@@ -89,19 +94,42 @@
<template #right>
<json-excel
v-if="type === '1'"
:data="last30Daylist"
:fields="last30DaysJsonFields"
:data="last30DaySkuList"
:fields="last30DaysSkuJsonFields"
:before-generate = "startDownload"
name="近30天销售数据.xls"
worksheet="近30天销售统计">
name="近30天销售数据_按SKU.xls"
worksheet="近30天销售统计_按SKU">
<el-button type="primary">导出数据</el-button>
</json-excel>
</template>
<ai-table
:isShowPagination="false"
:tableData="last30Daylist"
:col-configs="col30DaysConfigs"
:total="last30Daylist.length"
:tableData="last30DaySkuList"
:col-configs="col30DaysSkuConfigs"
:total="last30DaySkuList.length"
style="margin-top: 8px;"
@getList="() => {}">
</ai-table>
</ai-card>
</template>
<template slot="content" v-if="type === '2'">
<ai-card title="数据明细" style="padding-bottom: 40px;">
<template #right>
<json-excel
v-if="type === '2'"
:data="last30DaySkcList"
:fields="last30DaysSkcJsonFields"
:before-generate = "startDownload"
name="近30天销售数据_按SKC.xls"
worksheet="近30天销售统计_按SKC">
<el-button type="primary">导出数据</el-button>
</json-excel>
</template>
<ai-table
:isShowPagination="false"
:tableData="last30DaySkcList"
:col-configs="col30DaysSkcConfigs"
:total="last30DaySkcList.length"
style="margin-top: 8px;"
@getList="() => {}">
</ai-table>
@@ -122,7 +150,8 @@ import { Message } from 'element-ui'
data () {
return {
list: [],
last30Daylist: [],
last30DaySkcList: [],
last30DaySkuList: [],
mallId: '',
type: '0',
isLoading: false,
@@ -264,7 +293,7 @@ import { Message } from 'element-ui'
]
},
col30DaysConfigs () {
col30DaysSkcConfigs () {
let config = [
{
prop: 'productName',
@@ -289,8 +318,8 @@ import { Message } from 'element-ui'
fixed: 'left'
},
{
prop: 'productSkuId',
label: 'SKU ID',
prop: 'skcExtCode',
label: 'SKC货号',
width: '120px',
align: 'center',
fixed: 'left'
@@ -309,19 +338,105 @@ import { Message } from 'element-ui'
align: 'center',
sortable: true,
'sort-method': (a, b) => {
console.log('1、' + a[dateStr] + ' 2、' + b[dateStr])
return new Number(a[dateStr]) - new Number(b[dateStr])
}})
}
return config
},
last30DaysJsonFields () {
last30DaysSkcJsonFields () {
let jsonFields = {
"商品名称": "productName",
"SPU": "productId",
"SKC": "productSkcId",
"SKU ID": "productSkuId"
"SKC货号": "skcExtCode",
"图片链接": "productSkcPicture"
}
let date = new Date()
date.setDate(date.getDate() )
for (let i = 0; i < 30; i++) {
date.setDate(date.getDate() - 1)
let dateStr = formatDate(date)
jsonFields[dateStr] = dateStr
}
return jsonFields
},
col30DaysSkuConfigs () {
let config = [
{
prop: 'productName',
label: '商品名称',
"show-overflow-tooltip": true,
width: '300px',
align: 'left',
fixed: 'left'
},
{
prop: 'productId',
label: 'SPU',
width: '120px',
align: 'center',
fixed: 'left'
},
{
prop: 'productSkcId',
label: 'SKC',
width: '120px',
align: 'center',
fixed: 'left'
},
{
prop: 'skcExtCode',
label: 'SKC货号',
width: '120px',
align: 'center',
fixed: 'left'
},
{
prop: 'productSkuId',
label: 'SKU ID',
width: '120px',
align: 'center',
fixed: 'left'
},
{
prop: 'skuExtCode',
label: 'SKU货号',
width: '120px',
align: 'center',
fixed: 'left'
}
]
let date = new Date()
date.setDate(date.getDate())
for (let i = 0; i < 30; i++) {
date.setDate(date.getDate() - 1)
let dateStr = formatDate(date)
config.push({
prop: dateStr,
label: dateStr,
width: '100px',
align: 'center',
sortable: true,
'sort-method': (a, b) => {
return new Number(a[dateStr]) - new Number(b[dateStr])
}})
}
return config
},
last30DaysSkuJsonFields () {
let jsonFields = {
"商品名称": "productName",
"SPU": "productId",
"SKC": "productSkcId",
"SKC货号": "skcExtCode",
"SKU ID": "productSkuId",
"SKU货号": "skuExtCode",
"图片链接": "productSkcPicture"
}
let date = new Date()
@@ -369,6 +484,7 @@ import { Message } from 'element-ui'
}
this.isLoading = true
this.$userCheck(this.mallId).then(() => {
this.last30DaySkcList = []
this.getAllProductList()
this.getList()
}).catch((err) => {
@@ -411,13 +527,24 @@ import { Message } from 'element-ui'
data.productName = item.productName;
data.productId = item.productId;
data.productSkcId = item.productSkcId;
data.skcExtCode = item.skcExtCode;
data.purchaseConfig = item.purchaseConfig;
data.productSkcPicture = item.productSkcPicture;
this.last30DaySkcList.push({
productName: item.productName,
productId: item.productId,
productSkcId: item.productSkcId,
skcExtCode: item.skcExtCode,
productSkcPicture: item.productSkcPicture
})
if (item.onSalesDurationOffline == 0) {
data.onSalesDurationOffline = '-天'
} else {
data.onSalesDurationOffline = item.onSalesDurationOffline + '天'
}
data.productSkcPicture = item.productSkcPicture;
for(let j = 0;j < item.skuQuantityDetailList.length; j++) {
data = {...data, ...item.skuQuantityDetailList[j],
@@ -450,12 +577,28 @@ import { Message } from 'element-ui'
this.isLoading = false
Message.success('销售数据加载完成,可进行导出')
this.last30Daylist = this.list.map(item => {
// 初始化SKC数据列表
this.last30DaySkcList = this.last30DaySkcList.map(item => {
let date = new Date()
date.setDate(date.getDate() - 31)
for (let i = 0; i < 30; i++) {
date.setDate(date.getDate() + 1)
let dateStr = formatDate(date)
item[dateStr] = 0
}
return item
})
// 初始化SKU数据列表
this.last30DaySkuList = this.list.map(item => {
let temp = {
productName: item.productName,
productId: item.productId,
productSkcId: item.productSkcId,
productSkuId: item.productSkuId
productSkuId: item.productSkuId,
skuExtCode: item.skuExtCode,
skcExtCode: item.skcExtCode,
productSkcPicture: item.productSkcPicture
}
let date = new Date()
date.setDate(date.getDate() - 31)
@@ -493,13 +636,24 @@ import { Message } from 'element-ui'
}}).then((res) => {
if (res.errorCode == 1000000) {
for (let i = 0; i < res.result.length; i++) {
for (let j = 0; j < this.last30Daylist.length; j++) {
if (this.last30Daylist[j].productSkuId == res.result[i].prodSkuId) {
this.last30Daylist[j][res.result[i].date] = res.result[i].salesNumber
for (let j = 0; j < this.last30DaySkuList.length; j++) {
if (this.last30DaySkuList[j].productSkuId == res.result[i].prodSkuId) {
this.last30DaySkuList[j][res.result[i].date] = res.result[i].salesNumber
for (let k = 0; k < this.last30DaySkcList.length; k++) {
if (this.last30DaySkcList[k].productSkcId == this.last30DaySkuList[j].productSkcId) {
this.last30DaySkcList[k][res.result[i].date] = this.last30DaySkcList[k][res.result[i].date] + res.result[i].salesNumber
break
}
}
break
}
}
}
} else {
setTimeout(() => {
this.getSkuDetailList()
}, 1500)
}
})
},