Files
temu-plugin/src/view/ExportSaleData.vue

377 lines
11 KiB
Vue
Raw Normal View History

2023-08-06 16:50:17 +08:00
<template>
2023-08-18 17:51:28 +08:00
<ai-list class="list" v-loading="isLoading">
2023-08-06 16:50:17 +08:00
<ai-title
slot="title"
title="销售数据"
isShowBottomBorder>
2023-08-18 17:51:28 +08:00
<template #rightBtn>
<div class="title-right">
<div>
<label style="width:90px">统计类型</label>
2023-08-18 17:54:34 +08:00
<el-select v-model="type" @change="beforeGetList" placeholder="请选择" size="small">
2023-08-18 17:51:28 +08:00
<el-option
key="0"
label="销售数据"
value="0">
</el-option>
<el-option
key="1"
label="近30天销售"
value="1">
</el-option>
</el-select>
</div>
<div>
2023-08-08 02:13:54 +08:00
<label style="width:90px">店铺</label>
2023-08-18 17:54:34 +08:00
<el-select v-model="mallId" @change="beforeGetList" placeholder="请选择" size="small">
2023-08-08 02:13:54 +08:00
<el-option
v-for="item in $store.state.mallList"
:key="item.mallId"
:label="item.mallName"
:value="item.mallId">
</el-option>
</el-select>
</div>
2023-08-18 17:51:28 +08:00
</div>
</template>
</ai-title>
<template slot="content">
<div class="top" v-if="type === '0'">
<div class="item">
<h2>今天销量</h2>
<p>{{ todayTotal }}</p>
</div>
<div class="item">
<h2>今天销售额</h2>
<p>{{ todayMoney }}</p>
</div>
<div class="item">
<h2>库存总量</h2>
<p>{{ inventoryTotal }}</p>
</div>
<div class="item">
<h2>库存总额</h2>
<p>{{ inventoryMoeny }}</p>
</div>
</div>
<ai-card title="销售数据明细" style="padding-bottom: 40px;">
2023-08-06 16:50:17 +08:00
<template #right>
<json-excel
:data="list"
:fields="jsonFields"
:before-generate = "startDownload"
name="销售数据.xls"
worksheet="销售统计">
2023-08-07 13:51:28 +08:00
<el-button type="primary">导出销售数据</el-button>
2023-08-06 16:50:17 +08:00
</json-excel>
</template>
2023-08-18 17:51:28 +08:00
<ai-table
:isShowPagination="false"
:tableData="list"
:col-configs="colConfigs"
:total="list.length"
style="margin-top: 8px;"
@getList="() => {}">
</ai-table>
</ai-card>
2023-08-06 16:50:17 +08:00
</template>
</ai-list>
</template>
<script>
import {sendChromeAPIMessage} from '@/api/chromeApi'
import JsonExcel from 'vue-json-excel'
import { Message } from 'element-ui'
export default {
name: 'ExportSaleData',
data () {
return {
list: [],
2023-08-08 02:13:54 +08:00
mallId: '',
2023-08-18 17:51:28 +08:00
type: '0',
isLoading: false,
2023-08-06 16:50:17 +08:00
pageSize: 10,
currentPage: 1,
2023-08-14 23:30:05 +08:00
todayTotal: 0,
todayMoney: 0.0,
inventoryTotal: 0,
inventoryMoeny: 0.0,
2023-08-18 17:51:28 +08:00
jsonFields: {
"商品名称": "productName",
"SPU": "productId",
"SKC": "productSkcId",
"SKU ID": "productSkuId",
"SKU属性": "className",
"申报价格(CNY)": {
"field": "supplierPrice",
callback: (value) => {
return value /100;
}
},
"SKU货号": "skuExtCode",
"开款核价状态": {
"field": "isVerifyPrice",
callback: (value) => {
return value ? '核价通过': '核价未通过 / 无法备货';
}
},
"缺货数量": "lackQuantity",
"建议备货量": "adviceQuantity",
"可售天数": "availableSaleDays",
"库存可售天数": "availableSaleDaysFromInventory",
"仓内库存可售天数": "warehouseAvailableSaleDays",
"近7日用户加购数量": "inCartNumber7d",
"用户累计加购数量": "inCardNumber",
"已订阅待提醒到货": "nomsgSubsCntCntSth",
"销售数据 - 今日": "todaySaleVolume",
"销售数据 - 近7日": "lastSevenDaysSaleVolume",
"销售数据 - 近30天": "lastThirtyDaysSaleVolume",
"库存数据 - 仓内可用库存": "inventoryNumInfo.warehouseInventoryNum",
"库存数据 - 仓内暂不可用库存": "inventoryNumInfo.unavailableWarehouseInventoryNum",
"库存数据 - 已发货库存": "inventoryNumInfo.waitReceiveNum",
"库存数据 - 已下单待发货库存": "inventoryNumInfo.waitDeliveryInventoryNum",
"库存数据 - 待审核备货库存": "inventoryNumInfo.waitApproveInventoryNum",
"VMI备货单数 - 待发货": "vmiOrderInfo.waitDeliveryNum",
"VMI备货单数 - 在途单数": "vmiOrderInfo.transportationNum",
"VMI备货单数 - 发货延迟": "vmiOrderInfo.deliveryDelayNum",
"VMI备货单数 - 到货延迟": "vmiOrderInfo.arrivalDelayNum",
"非VMI备货单数 - 待发货": "notVmiOrderInfo.waitDeliveryNum",
"非VMI备货单数 - 在途单数": "notVmiOrderInfo.transportationNum",
"非VMI备货单数 - 发货延迟": "notVmiOrderInfo.deliveryDelayNum",
"非VMI备货单数 - 到货延迟": "notVmiOrderInfo.arrivalDelayNum",
"备货逻辑": "purchaseConfig",
"库存货值(CNY)": "productTotalPrice",
}
}
},
computed: {
colConfigs () {
return [
2023-08-06 16:50:17 +08:00
{
prop: 'productName',
label: '商品名称',
2023-08-14 17:21:31 +08:00
"show-overflow-tooltip": true,
width: '300px',
2023-08-06 16:50:17 +08:00
align: 'left'
},
{
prop: 'productId',
label: 'SPU',
align: 'center'
},
{
prop: 'productSkcId',
label: 'SKC',
align: 'center'
},
2023-08-14 17:21:31 +08:00
{
prop: 'productSkuId',
label: 'SKU ID',
align: 'center'
},
2023-08-06 16:50:17 +08:00
{
prop: 'className',
label: 'SKU属性',
align: 'center'
},
2023-08-14 17:21:31 +08:00
{
prop: 'isVerifyPrice',
label: '开款核价状态',
align: 'center',
format: v => v ? '核价通过': '核价未通过 / 无法备货'
},
2023-08-06 16:50:17 +08:00
{
prop: 'supplierPrice',
label: '申报价格(CNY)',
align: 'center',
2023-08-14 17:21:31 +08:00
format: v => v / 100,
fixed: "right"
2023-08-06 16:50:17 +08:00
},
{
2023-08-14 17:21:31 +08:00
prop: 'warehouseInventoryNum',
label: '仓内可用库存',
2023-08-06 16:50:17 +08:00
align: 'center',
2023-08-14 17:21:31 +08:00
fixed: "right"
2023-08-06 16:50:17 +08:00
},
2023-08-14 17:21:31 +08:00
{
prop: 'productTotalPrice',
2023-08-14 23:30:05 +08:00
label: '库存货值(CNY)',
2023-08-14 17:21:31 +08:00
align: 'center',
2023-08-18 17:51:28 +08:00
fixed: "right",
sortable: true,
'sort-method': (a, b) => {
return a.productTotalPrice - b.productTotalPrice
2023-08-06 16:50:17 +08:00
}
},
2023-08-18 17:51:28 +08:00
]
2023-08-06 16:50:17 +08:00
}
},
components: {
JsonExcel
},
created () {
},
methods: {
2023-08-08 02:13:54 +08:00
beforeGetList() {
2023-08-18 17:54:34 +08:00
this.isLoading = true
2023-08-08 02:13:54 +08:00
this.list = []
2023-08-18 17:54:34 +08:00
this.currentPage = 1
2023-08-14 23:30:05 +08:00
this.todayMoney = 0.0
this.todayTotal = 0
this.inventoryMoeny = 0.0
this.inventoryTotal = 0
2023-08-08 02:13:54 +08:00
if (!this.mallId) {
Message.error("请先选择店铺")
return
}
2023-08-09 00:55:57 +08:00
this.$userCheck(this.mallId).then(() => {
this.getList()
}).catch((err) => {
console.log(err)
2023-08-08 02:13:54 +08:00
})
},
2023-08-06 16:50:17 +08:00
getList () {
sendChromeAPIMessage({
url: 'marvel-mms/cn/api/kiana/venom/sales/management/list',
needMallId: true,
2023-08-08 02:13:54 +08:00
mallId: this.mallId,
2023-08-06 16:50:17 +08:00
data: {
pageNo: this.currentPage,
pageSize: this.pageSize,
isLack: 0,
priceAdjustRecentDays: 7
}}).then((res) => {
if (res.errorCode == 1000000) {
for(let i = 0;i < res.result.subOrderList.length; i++) {
let item = res.result.subOrderList[i];
let data = {};
data.productName = item.productName;
data.productId = item.productId;
data.productSkcId = item.productSkcId;
data.purchaseConfig = item.purchaseConfig;
for(let j = 0;j < item.skuQuantityDetailList.length; j++) {
2023-08-14 17:21:31 +08:00
data = {...data, ...item.skuQuantityDetailList[j],
productTotalPrice: ((item.skuQuantityDetailList[j].supplierPrice / 100) * item.skuQuantityDetailList[j].inventoryNumInfo.warehouseInventoryNum).toFixed(2),
warehouseInventoryNum: item.skuQuantityDetailList[j].inventoryNumInfo.warehouseInventoryNum}
2023-08-14 23:30:05 +08:00
this.todayTotal += item.skuQuantityDetailList[j].todaySaleVolume
this.todayMoney += new Number(((item.skuQuantityDetailList[j].supplierPrice / 100) * item.skuQuantityDetailList[j].todaySaleVolume).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))
2023-08-06 16:50:17 +08:00
this.list.push(data);
}
}
if (this.pageSize == res.result.subOrderList.length) {
this.currentPage ++
2023-08-14 23:30:05 +08:00
setTimeout(() => {
this.getList()
2023-08-15 00:04:52 +08:00
}, 1500)
2023-08-17 09:01:30 +08:00
} else {
2023-08-18 17:51:28 +08:00
this.isLoading = false
2023-08-17 09:01:30 +08:00
Message.success('销售数据加载完成,可进行导出')
2023-08-06 16:50:17 +08:00
}
2023-08-09 02:32:02 +08:00
} else {
2023-08-15 11:44:50 +08:00
setTimeout(() => {
this.getList()
}, 1500)
// Message.error("【拼多多】" + res.errorMsg + ", 请重新尝试加载")
2023-08-06 16:50:17 +08:00
}
2023-08-18 17:51:28 +08:00
}).catch(() => {
this.isLoading = false
})
2023-08-06 16:50:17 +08:00
},
startDownload() {
this.$http.post('/api/malluser/info').then(res => {
if (res.code == 0) {
this.$store.commit('setUserInfo', res.data)
if (res.data.flag != 1) {
Message.error('您的账号未激活或已失效,请激活后使用')
this.$store.commit('setActiveDlgShow', true)
return;
}
}
})
}
}
}
</script>
<style scoped lang="scss">
2023-08-18 17:51:28 +08:00
.list {
.title-right {
display: flex;
align-items: center;
& > div:first-child {
margin-right: 20px;
}
}
::v-deep.ai-list {
.ai-list__content--right-wrapper {
background: transparent;
box-shadow: none;
padding: 0!important;
}
}
.top {
display: flex;
justify-content: space-between;
margin-bottom: 24px;
.item {
flex: 1;
margin-right: 20px;
padding: 16px 24px;
background: #FFF;
box-shadow: 0px 4px 6px -2px rgba(15, 15, 21, 0.15);
border-radius: 4px;
&:last-child {
margin-right: 0;
}
&:nth-of-type(1) {
color: #2266ff;
}
&:nth-of-type(2) {
color: #f8b426;
}
&:nth-of-type(3) {
color: #21aa99;
}
&:nth-of-type(4) {
color: #F46;
}
&:nth-of-type(5) {
color: #11A265;
}
h2 {
margin-bottom: 30px;
font-size: 16px;
color: #999;
}
p {
font-weight: 600;
font-size: 28px;
}
}
}
}
2023-08-14 17:21:31 +08:00
.like {
cursor: pointer;
font-size: 25px;
display: inline-block;
}
2023-08-06 16:50:17 +08:00
</style>