大调整

This commit is contained in:
liushiwei
2023-08-22 20:16:59 +08:00
parent f03d1ccf2e
commit 3bd2c7d246
12 changed files with 996 additions and 44 deletions

View File

@@ -8,7 +8,7 @@
<div class="title-right">
<div>
<label style="width:90px">统计类型</label>
<el-select v-model="type" @change="beforeGetList" placeholder="请选择" size="small">
<el-select v-model="type" @change="changeDataType" placeholder="请选择" size="small">
<el-option
key="0"
label="销售数据"
@@ -35,14 +35,14 @@
</div>
</template>
</ai-title>
<template slot="content">
<div class="top" v-if="type === '0'">
<template slot="content" v-if="type === '0'">
<div class="top">
<div class="item">
<h2>销量</h2>
<h2>销量</h2>
<p>{{ todayTotal }}</p>
</div>
<div class="item">
<h2>销售额</h2>
<h2>销售额</h2>
<p>{{ todayMoney }}</p>
</div>
<div class="item">
@@ -53,16 +53,25 @@
<h2>库存总额</h2>
<p>{{ inventoryMoeny }}</p>
</div>
<div class="item">
<h2>已收货总量</h2>
<p>{{ deliveryTotal }}</p>
</div>
<div class="item">
<h2>已收货总货值</h2>
<p>{{ deliveryMoeny }}</p>
</div>
</div>
<ai-card title="销售数据明细" style="padding-bottom: 40px;">
<ai-card title="数据明细" style="padding-bottom: 40px;">
<template #right>
<json-excel
:data="list"
v-if="type === '0'"
:fields="jsonFields"
:before-generate = "startDownload"
name="销售数据.xls"
worksheet="销售统计">
<el-button type="primary">导出销售数据</el-button>
<el-button type="primary">导出数据</el-button>
</json-excel>
</template>
<ai-table
@@ -75,12 +84,36 @@
</ai-table>
</ai-card>
</template>
<template slot="content" v-if="type === '1'">
<ai-card title="数据明细" style="padding-bottom: 40px;">
<template #right>
<json-excel
v-if="type === '1'"
:data="last30Daylist"
:fields="last30DaysJsonFields"
:before-generate = "startDownload"
name="近30天销售数据.xls"
worksheet="近30天销售统计">
<el-button type="primary">导出数据</el-button>
</json-excel>
</template>
<ai-table
:isShowPagination="false"
:tableData="last30Daylist"
:col-configs="col30DaysConfigs"
:total="last30Daylist.length"
style="margin-top: 8px;"
@getList="() => {}">
</ai-table>
</ai-card>
</template>
</ai-list>
</template>
<script>
import {sendChromeAPIMessage} from '@/api/chromeApi'
import JsonExcel from 'vue-json-excel'
import {formatDate} from '@/utils/date'
import { Message } from 'element-ui'
export default {
@@ -89,6 +122,7 @@ import { Message } from 'element-ui'
data () {
return {
list: [],
last30Daylist: [],
mallId: '',
type: '0',
isLoading: false,
@@ -98,6 +132,11 @@ import { Message } from 'element-ui'
todayMoney: 0.0,
inventoryTotal: 0,
inventoryMoeny: 0.0,
deliveryTotal: 0,
deliveryMoeny: 0.0,
allProductList: [],
startDate: '',
endDate: '',
jsonFields: {
"商品名称": "productName",
"SPU": "productId",
@@ -194,7 +233,11 @@ import { Message } from 'element-ui'
prop: 'warehouseInventoryNum',
label: '仓内可用库存',
align: 'center',
fixed: "right"
fixed: "right",
sortable: true,
'sort-method': (a, b) => {
return a.warehouseInventoryNum - b.warehouseInventoryNum
}
},
{
prop: 'productTotalPrice',
@@ -208,6 +251,75 @@ import { Message } from 'element-ui'
},
]
},
col30DaysConfigs () {
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: 'productSkuId',
label: 'SKU ID',
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
},
last30DaysJsonFields () {
let jsonFields = {
"商品名称": "productName",
"SPU": "productId",
"SKC": "productSkcId",
"SKU ID": "productSkuId"
}
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
}
},
@@ -216,9 +328,17 @@ import { Message } from 'element-ui'
},
created () {
let date = new Date()
date.setDate(date.getDate() - 30)
this.startDate = formatDate(date)
date.setDate(date.getDate() + 29)
this.endDate = formatDate(date)
},
methods: {
changeDataType() {
},
beforeGetList() {
this.list = []
this.currentPage = 1
@@ -226,6 +346,7 @@ import { Message } from 'element-ui'
this.todayTotal = 0
this.inventoryMoeny = 0.0
this.inventoryTotal = 0
this.allProductList = []
if (!this.mallId) {
Message.error("请先选择店铺")
@@ -233,11 +354,30 @@ import { Message } from 'element-ui'
}
this.isLoading = true
this.$userCheck(this.mallId).then(() => {
this.getAllProductList()
this.getList()
}).catch((err) => {
console.log(err)
this.isLoading = false
})
},
getAllProductList() {
this.$http.post('/api/deliveryOrder/totalDelivery',null, {
params: {mallId: this.mallId}
}).then(res => {
if (res.code === 0) {
this.deliveryTotal = res.data
}
})
this.$http.post('/api/deliveryOrder/getAllProductList', null, {
params: {mallId: this.mallId}
}).then(res => {
if (res.code == 0) {
this.allProductList = res.data
}
})
},
getList () {
sendChromeAPIMessage({
url: 'marvel-mms/cn/api/kiana/venom/sales/management/list',
@@ -265,9 +405,19 @@ import { Message } from 'element-ui'
this.todayTotal += item.skuQuantityDetailList[j].todaySaleVolume
this.todayMoney += new Number(((item.skuQuantityDetailList[j].supplierPrice / 100) * item.skuQuantityDetailList[j].todaySaleVolume).toFixed(2))
this.todayMoney = new Number(this.todayMoney.toFixed(2))
this.inventoryTotal += item.skuQuantityDetailList[j].inventoryNumInfo.warehouseInventoryNum
this.inventoryMoeny += new Number(((item.skuQuantityDetailList[j].supplierPrice / 100) * item.skuQuantityDetailList[j].inventoryNumInfo.warehouseInventoryNum).toFixed(2))
this.inventoryMoeny = new Number(this.inventoryMoeny.toFixed(2))
this.list.push(data);
// 计算已发货货值
for(let k = 0; k < this.allProductList.length; k++) {
if (this.allProductList[k].product_sku_id == data.productSkuId) {
this.deliveryMoeny += (item.skuQuantityDetailList[j].supplierPrice / 100) * this.allProductList[k].product_sku_number
this.deliveryMoeny = new Number(this.deliveryMoeny.toFixed(2))
}
}
}
}
if (this.pageSize == res.result.subOrderList.length) {
@@ -278,6 +428,24 @@ import { Message } from 'element-ui'
} else {
this.isLoading = false
Message.success('销售数据加载完成,可进行导出')
this.last30Daylist = this.list.map(item => {
let temp = {
productName: item.productName,
productId: item.productId,
productSkcId: item.productSkcId,
productSkuId: item.productSkuId
}
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)
temp[dateStr] = 0
}
return temp
})
this.getSkuDetailList()
}
} else {
setTimeout(() => {
@@ -289,6 +457,32 @@ import { Message } from 'element-ui'
this.isLoading = false
})
},
getSkuDetailList () {
let skuIds = this.list.map(item => {
return item.productSkuId
})
sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/sales/management/querySkuSalesNumber',
needMallId: true,
mallId: this.mallId,
data: {
"productSkuIds": skuIds,
"startDate": this.startDate,
"endDate": this.endDate
}}).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
break
}
}
}
}
})
},
startDownload() {
this.$http.post('/api/malluser/info').then(res => {
if (res.code == 0) {