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

1044 lines
33 KiB
Vue
Raw Normal View History

2023-08-06 16:50:17 +08:00
<template>
2023-09-05 23:28:50 +08:00
<ai-list class="list" v-loading="isLoading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
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-22 20:16:59 +08:00
<el-select v-model="type" @change="changeDataType" placeholder="请选择" size="small">
2023-08-18 17:51:28 +08:00
<el-option
key="0"
label="销售数据"
value="0">
</el-option>
<el-option
key="1"
2023-08-29 13:42:07 +08:00
label="近30天销售(按SKU)"
2023-08-18 17:51:28 +08:00
value="1">
</el-option>
2023-08-29 13:42:07 +08:00
<el-option
key="2"
label="近30天销售(按SKC)"
value="2">
</el-option>
2023-08-18 17:51:28 +08:00
</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>
2024-01-18 00:46:23 +08:00
<ai-dialog
title="导出SKU历史销量"
:visible.sync="downloadSkuSaleNumberDlg"
:close-on-click-modal="false"
width="790px"
append-to-body
customFooter
@close="handleClose">
<el-form class="ai-form" :model="skuDownloadForm" label-width="160px" ref="skuDownloadForm">
<el-form-item label="日期范围" style="width: 100%;" prop="date" :rules="[{ required: true, message: '请选择时间范围', trigger: 'blur' }]">
<el-date-picker
v-model="skuDownloadForm.date"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
</el-form>
<div class="dialog-footer" slot="footer">
<el-button @click="downloadSkuSaleNumberDlg = false"> </el-button>
<el-button type="primary" @click="toDownloadSkuSaleNumber">确定</el-button>
</div>
</ai-dialog>
2023-08-18 17:51:28 +08:00
</template>
</ai-title>
2023-08-22 20:16:59 +08:00
<template slot="content" v-if="type === '0'">
<div class="top">
2023-08-18 17:51:28 +08:00
<div class="item">
2023-08-22 20:16:59 +08:00
<h2>今日销量</h2>
2023-08-18 17:51:28 +08:00
<p>{{ todayTotal }}</p>
</div>
<div class="item">
2023-08-22 20:16:59 +08:00
<h2>今日销售额</h2>
2023-08-18 17:51:28 +08:00
<p>{{ todayMoney }}</p>
</div>
<div class="item">
2024-01-26 00:20:31 +08:00
<h2>可用库存总量()</h2>
2023-08-18 17:51:28 +08:00
<p>{{ inventoryTotal }}</p>
</div>
<div class="item">
2024-01-26 00:20:31 +08:00
<h2>可用库存总额</h2>
<p>{{ inventoryMoney }}</p>
</div>
<div class="item">
<h2><span>在途库存总量()<el-tooltip
effect="dark"
content="包括暂不可用库存以及已发货库存"
placement="right">
<i class="el-icon-question"
style="font-size: 16px; vertical-align: middle;"></i>
</el-tooltip></span></h2>
<p>{{ inroadTotal }}</p>
</div>
<div class="item">
<h2><span>在途库存总额<el-tooltip
effect="dark"
content="(暂不可用库存+已发货库存)*申报价格"
placement="right">
<i class="el-icon-question"
style="font-size: 16px; vertical-align: middle;"></i>
</el-tooltip></span></h2>
<p>{{ inroadTotalMoney }}</p>
2023-08-18 17:51:28 +08:00
</div>
2023-08-22 20:16:59 +08:00
<div class="item">
2023-12-20 22:09:55 +08:00
<h2>已收货总量()</h2>
2023-08-22 20:16:59 +08:00
<p>{{ deliveryTotal }}</p>
</div>
<div class="item">
<h2>已收货总货值</h2>
2024-01-26 00:20:31 +08:00
<p>{{ deliveryMoney }}</p>
2023-08-22 20:16:59 +08:00
</div>
2023-08-18 17:51:28 +08:00
</div>
2023-08-22 20:16:59 +08:00
<ai-card title="数据明细" style="padding-bottom: 40px;">
2023-08-06 16:50:17 +08:00
<template #right>
<json-excel
:data="list"
2023-08-22 20:16:59 +08:00
v-if="type === '0'"
2023-08-06 16:50:17 +08:00
:fields="jsonFields"
:before-generate = "startDownload"
name="销售数据.xls"
worksheet="销售统计">
2023-08-22 20:16:59 +08:00
<el-button type="primary">导出数据</el-button>
2023-08-06 16:50:17 +08:00
</json-excel>
2024-01-10 01:27:15 +08:00
<json-excel
:data="skuSaleNumberList"
v-show="false"
:fields="skuSaleNumberFields"
:before-generate = "startSkuSaleNumberDownload"
name="SKU历史销量.xls"
worksheet="SKU历史销量">
<el-button type="primary" id="downloadSkuSaleNumber"></el-button>
</json-excel>
2024-01-18 00:46:23 +08:00
<el-button type="primary" :disabled="!mallId" @click="toDownload">导出SKU历史销量</el-button>
2023-08-06 16:50:17 +08:00
</template>
2023-08-18 17:51:28 +08:00
<ai-table
2023-10-19 00:03:01 +08:00
ref="table0"
2023-08-18 17:51:28 +08:00
:isShowPagination="false"
:tableData="list"
2023-09-12 16:27:52 +08:00
height="500"
2023-08-18 17:51:28 +08:00
:col-configs="colConfigs"
:total="list.length"
style="margin-top: 8px;"
@getList="() => {}">
</ai-table>
</ai-card>
2023-08-06 16:50:17 +08:00
</template>
2023-08-22 20:16:59 +08:00
<template slot="content" v-if="type === '1'">
<ai-card title="数据明细" style="padding-bottom: 40px;">
<template #right>
<json-excel
v-if="type === '1'"
2023-08-29 13:42:07 +08:00
:data="last30DaySkuList"
:fields="last30DaysSkuJsonFields"
2023-08-22 20:16:59 +08:00
:before-generate = "startDownload"
2023-08-29 13:42:07 +08:00
name="近30天销售数据_按SKU.xls"
worksheet="近30天销售统计_按SKU">
2023-08-22 20:16:59 +08:00
<el-button type="primary">导出数据</el-button>
</json-excel>
</template>
<ai-table
2023-10-19 00:03:01 +08:00
ref="table1"
2023-08-22 20:16:59 +08:00
:isShowPagination="false"
2023-08-29 13:42:07 +08:00
:tableData="last30DaySkuList"
2023-09-12 20:49:22 +08:00
height="500"
2023-08-29 13:42:07 +08:00
: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
2023-10-19 00:03:01 +08:00
ref="table2"
2023-08-29 13:42:07 +08:00
:isShowPagination="false"
:tableData="last30DaySkcList"
2023-09-12 20:49:22 +08:00
height="500"
2023-08-29 13:42:07 +08:00
:col-configs="col30DaysSkcConfigs"
:total="last30DaySkcList.length"
2023-08-22 20:16:59 +08:00
style="margin-top: 8px;"
@getList="() => {}">
</ai-table>
</ai-card>
</template>
2024-01-10 01:27:15 +08:00
2024-01-18 00:46:23 +08:00
2023-08-06 16:50:17 +08:00
</ai-list>
</template>
<script>
2023-09-12 16:04:17 +08:00
import { mapState } from 'vuex'
2023-08-06 16:50:17 +08:00
import {sendChromeAPIMessage} from '@/api/chromeApi'
import JsonExcel from 'vue-json-excel'
2023-08-22 20:16:59 +08:00
import {formatDate} from '@/utils/date'
2023-08-06 16:50:17 +08:00
import { Message } from 'element-ui'
export default {
name: 'ExportSaleData',
data () {
return {
list: [],
2023-08-29 13:42:07 +08:00
last30DaySkcList: [],
last30DaySkuList: [],
2023-08-08 02:13:54 +08:00
mallId: '',
2023-09-12 16:04:17 +08:00
mallName: '',
2023-08-18 17:51:28 +08:00
type: '0',
isLoading: false,
2023-09-25 10:13:54 +08:00
pageSize: 100,
2023-08-06 16:50:17 +08:00
currentPage: 1,
2023-08-14 23:30:05 +08:00
todayTotal: 0,
todayMoney: 0.0,
inventoryTotal: 0,
2024-01-26 00:20:31 +08:00
inventoryMoney: 0.0,
inroadTotal: 0,
inroadTotalMoney: 0.0,
2023-08-22 20:16:59 +08:00
deliveryTotal: 0,
2024-01-26 00:20:31 +08:00
deliveryMoney: 0.0,
2023-08-22 20:16:59 +08:00
allProductList: [],
startDate: '',
endDate: '',
2023-09-25 10:13:54 +08:00
skuIds: [],
2023-08-18 17:51:28 +08:00
jsonFields: {
"商品名称": "productName",
"SPU": "productId",
"SKC": "productSkcId",
"SKU ID": "productSkuId",
"SKU属性": "className",
2023-08-25 00:56:56 +08:00
"SKU货号": "skuExtCode",
"加入站点时长": "onSalesDurationOffline",
"图片链接": "productSkcPicture",
2023-08-18 17:51:28 +08:00
"申报价格(CNY)": {
"field": "supplierPrice",
callback: (value) => {
return value /100;
}
},
"开款核价状态": {
"field": "isVerifyPrice",
callback: (value) => {
return value ? '核价通过': '核价未通过 / 无法备货';
}
},
"缺货数量": "lackQuantity",
"建议备货量": "adviceQuantity",
"可售天数": "availableSaleDays",
"库存可售天数": "availableSaleDaysFromInventory",
"仓内库存可售天数": "warehouseAvailableSaleDays",
"近7日用户加购数量": "inCartNumber7d",
"用户累计加购数量": "inCardNumber",
"已订阅待提醒到货": "nomsgSubsCntCntSth",
"销售数据 - 今日": "todaySaleVolume",
"销售数据 - 近7日": "lastSevenDaysSaleVolume",
"销售数据 - 近30天": "lastThirtyDaysSaleVolume",
"库存数据 - 仓内可用库存": "inventoryNumInfo.warehouseInventoryNum",
2024-01-26 00:20:31 +08:00
"库存数据 - 仓内暂不可用库存": "inventoryNumInfo.waitOnShelfNum",
2023-08-18 17:51:28 +08:00
"库存数据 - 已发货库存": "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",
2024-01-26 00:20:31 +08:00
"可用库存货值(CNY)": "productTotalPrice",
"在途库存货值(CNY)": "inroadTotalPrice",
2023-11-08 13:39:21 +08:00
"店铺名称": "mallName",
"评分": "mark",
2024-01-10 01:27:15 +08:00
"是否热销": 'hotTag',
"生产建议信息 - 建议生产数": 'adviceProduceNum',
2024-03-15 21:13:07 +08:00
"生产建议信息 - 剩余件数": 'availableProduceNum',
"类目": 'category'
2024-01-10 01:27:15 +08:00
},
2024-01-18 00:46:23 +08:00
skuSaleNumberFields: {},
2024-01-10 01:27:15 +08:00
skuSaleNumberList: [],
2024-01-10 11:32:43 +08:00
downloadSkuSaleNumberDlg: false,
2024-01-10 01:27:15 +08:00
skuDownloadForm: {
date: ''
2024-01-18 00:46:23 +08:00
},
2023-08-18 17:51:28 +08:00
}
},
computed: {
2023-09-12 16:04:17 +08:00
...mapState(['mallList']),
2023-08-18 17:51:28 +08:00
colConfigs () {
return [
2023-08-06 16:50:17 +08:00
{
prop: 'productName',
label: '商品名称',
2023-09-12 20:49:22 +08:00
"show-overflow-tooltip": true,
2023-08-25 00:56:56 +08:00
width: '280px',
2023-10-19 00:03:01 +08:00
align: 'left',
fixed: 'left'
2023-08-06 16:50:17 +08:00
},
2023-09-12 16:04:17 +08:00
{
prop: 'mallName',
label: '店铺名称',
2023-09-12 20:49:22 +08:00
"show-overflow-tooltip": true,
2023-09-12 16:04:17 +08:00
width: '120px',
2023-10-19 00:03:01 +08:00
align: 'left',
fixed: 'left'
2023-09-12 16:04:17 +08:00
},
2023-09-25 10:13:54 +08:00
{
prop: 'mark',
label: '评分',
"show-overflow-tooltip": true,
width: '80px',
align: 'left'
},
2023-10-19 00:03:01 +08:00
{
prop: 'hotTag',
label: '是否热销',
"show-overflow-tooltip": true,
width: '80px',
align: 'left'
},
2023-08-06 16:50:17 +08:00
{
prop: 'productId',
label: 'SPU',
2024-01-18 00:46:23 +08:00
width: '120px',
2023-08-06 16:50:17 +08:00
align: 'center'
},
{
prop: 'productSkcId',
label: 'SKC',
2024-01-18 00:46:23 +08:00
width: '120px',
2023-08-06 16:50:17 +08:00
align: 'center'
},
2023-08-14 17:21:31 +08:00
{
prop: 'productSkuId',
label: 'SKU ID',
2024-01-18 00:46:23 +08:00
width: '120px',
2023-08-14 17:21:31 +08:00
align: 'center'
},
2023-08-06 16:50:17 +08:00
{
prop: 'className',
label: 'SKU属性',
align: 'center'
},
2023-08-25 00:56:56 +08:00
{
prop: 'skuExtCode',
label: 'SKU货号',
2024-01-18 00:46:23 +08:00
width: '120px',
2023-08-25 00:56:56 +08:00
align: 'center'
},
{
prop: 'onSalesDurationOffline',
label: '加入站点时长',
2024-01-18 00:46:23 +08:00
width: '160px',
2023-08-25 00:56:56 +08:00
align: 'center'
},
2023-08-14 17:21:31 +08:00
{
prop: 'isVerifyPrice',
label: '开款核价状态',
2024-01-18 00:46:23 +08:00
width: '160px',
2023-08-14 17:21:31 +08:00
align: 'center',
format: v => v ? '核价通过': '核价未通过 / 无法备货'
},
2023-08-06 16:50:17 +08:00
{
prop: 'supplierPrice',
label: '申报价格(CNY)',
2024-01-18 00:46:23 +08:00
width: '160px',
2023-08-06 16:50:17 +08:00
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: '仓内可用库存',
2024-01-18 00:46:23 +08:00
width: '160px',
2023-08-06 16:50:17 +08:00
align: 'center',
2023-08-22 20:16:59 +08:00
fixed: "right",
sortable: true,
'sort-method': (a, b) => {
return a.warehouseInventoryNum - b.warehouseInventoryNum
}
2023-08-06 16:50:17 +08:00
},
2023-08-14 17:21:31 +08:00
{
prop: 'productTotalPrice',
2024-01-26 00:20:31 +08:00
label: '可用库存货值(CNY)',
width: '180px',
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-09-05 23:28:50 +08:00
{
prop: 'purchaseConfig',
label: '备货逻辑',
align: 'center',
2024-01-18 00:46:23 +08:00
width: '120px',
2023-09-05 23:28:50 +08:00
fixed: "right",
sortable: true,
'sort-method': (a, b) => {
if (a.purchaseConfig > b.purchaseConfig) {
return 1
} else if (a.purchaseConfig == b.purchaseConfig) {
return 0
} else {
return -1
}
}
2024-01-10 01:27:15 +08:00
}
2023-09-12 20:49:22 +08:00
2023-08-18 17:51:28 +08:00
]
2023-08-22 20:16:59 +08:00
},
2023-08-29 13:42:07 +08:00
col30DaysSkcConfigs () {
2023-08-22 20:16:59 +08:00
let config = [
{
prop: 'productName',
label: '商品名称',
2023-09-12 20:49:22 +08:00
"show-overflow-tooltip": true,
2023-08-22 20:16:59 +08:00
width: '300px',
align: 'left',
fixed: 'left'
},
2023-09-12 16:04:17 +08:00
{
prop: 'mallName',
label: '店铺名称',
2023-09-12 20:49:22 +08:00
"show-overflow-tooltip": true,
2023-09-12 16:04:17 +08:00
width: '120px',
align: 'left',
fixed: 'left'
},
2023-08-22 20:16:59 +08:00
{
prop: 'productId',
label: 'SPU',
width: '120px',
align: 'center',
fixed: 'left'
},
{
prop: 'productSkcId',
label: 'SKC',
width: '120px',
align: 'center',
fixed: 'left'
},
2023-08-29 13:42:07 +08:00
{
prop: 'skcExtCode',
label: 'SKC货号',
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) => {
2023-09-05 23:28:50 +08:00
if (a > b) {
return 1
} else if (a == b) {
return 0
} else {
return -1
}
2023-08-29 13:42:07 +08:00
}})
}
return config
},
last30DaysSkcJsonFields () {
let jsonFields = {
"商品名称": "productName",
2023-09-12 16:04:17 +08:00
"店铺名称": "mallName",
2023-08-29 13:42:07 +08:00
"SPU": "productId",
"SKC": "productSkcId",
"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: '商品名称',
2023-09-12 20:49:22 +08:00
"show-overflow-tooltip": true,
2023-08-29 13:42:07 +08:00
width: '300px',
align: 'left',
fixed: 'left'
},
2023-09-12 16:04:17 +08:00
{
prop: 'mallName',
label: '店铺名称',
2023-09-12 20:49:22 +08:00
"show-overflow-tooltip": true,
2023-09-12 16:04:17 +08:00
width: '120px',
align: 'left',
fixed: 'left'
},
2023-08-29 13:42:07 +08:00
{
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'
},
2023-08-22 20:16:59 +08:00
{
prop: 'productSkuId',
label: 'SKU ID',
width: '120px',
align: 'center',
fixed: 'left'
2023-08-29 13:42:07 +08:00
},
{
prop: 'skuExtCode',
label: 'SKU货号',
width: '120px',
align: 'center',
fixed: 'left'
2023-08-22 20:16:59 +08:00
}
]
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) => {
2023-09-05 23:28:50 +08:00
if (a > b) {
return 1
} else if (a == b) {
return 0
} else {
return -1
}
2023-08-22 20:16:59 +08:00
}})
}
return config
},
2023-08-29 13:42:07 +08:00
last30DaysSkuJsonFields () {
2023-08-22 20:16:59 +08:00
let jsonFields = {
"商品名称": "productName",
2023-09-12 16:04:17 +08:00
"店铺名称": "mallName",
2023-08-22 20:16:59 +08:00
"SPU": "productId",
"SKC": "productSkcId",
2023-08-29 13:42:07 +08:00
"SKC货号": "skcExtCode",
"SKU ID": "productSkuId",
"SKU货号": "skuExtCode",
"图片链接": "productSkcPicture"
2023-08-22 20:16:59 +08:00
}
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
2023-08-06 16:50:17 +08:00
}
},
components: {
JsonExcel
},
created () {
2023-08-22 20:16:59 +08:00
let date = new Date()
date.setDate(date.getDate() - 30)
this.startDate = formatDate(date)
date.setDate(date.getDate() + 29)
this.endDate = formatDate(date)
2023-08-06 16:50:17 +08:00
},
methods: {
2023-08-22 20:16:59 +08:00
changeDataType() {
2023-10-19 00:03:01 +08:00
this.$nextTick(() => { //在数据加载完,重新渲染表格
this.$refs['table'+this.type].doLayout();
})
2023-08-22 20:16:59 +08:00
},
2023-08-08 02:13:54 +08:00
beforeGetList() {
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
2024-01-26 00:20:31 +08:00
this.inventoryMoney = 0.0
2023-08-14 23:30:05 +08:00
this.inventoryTotal = 0
2024-01-26 00:20:31 +08:00
this.inroadTotalMoney = 0.0
this.inroadTotal = 0
2023-08-24 09:20:22 +08:00
this.deliveryTotal = 0
2024-01-26 00:20:31 +08:00
this.deliveryMoney = 0.0
2023-08-22 20:16:59 +08:00
this.allProductList = []
2023-08-08 02:13:54 +08:00
if (!this.mallId) {
2023-09-12 20:49:22 +08:00
2023-08-08 02:13:54 +08:00
Message.error("请先选择店铺")
return
}
2023-09-12 16:04:17 +08:00
let mallInfo = this.mallList.filter(item => {
return item.mallId == this.mallId
})
this.mallName = mallInfo[0].mallName
2023-08-18 17:55:43 +08:00
this.isLoading = true
2023-08-09 00:55:57 +08:00
this.$userCheck(this.mallId).then(() => {
2023-08-29 13:42:07 +08:00
this.last30DaySkcList = []
2023-08-22 20:16:59 +08:00
this.getAllProductList()
2023-08-09 00:55:57 +08:00
this.getList()
}).catch((err) => {
2023-08-22 20:16:59 +08:00
console.log(err)
2023-08-18 17:55:43 +08:00
this.isLoading = false
2023-08-08 02:13:54 +08:00
})
},
2023-08-22 20:16:59 +08:00
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
}
})
},
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;
2024-03-15 21:13:07 +08:00
data.category = item.category;
2023-08-06 16:50:17 +08:00
data.productId = item.productId;
data.productSkcId = item.productSkcId;
2023-08-29 13:42:07 +08:00
data.skcExtCode = item.skcExtCode;
2023-08-06 16:50:17 +08:00
data.purchaseConfig = item.purchaseConfig;
2023-08-29 13:42:07 +08:00
data.productSkcPicture = item.productSkcPicture;
2023-09-25 10:13:54 +08:00
data.mark = item.mark.toFixed(1)
2023-10-19 00:03:01 +08:00
data.hotTag = item.hotTag ? '是': '否'
2023-09-12 16:04:17 +08:00
data.mallName = this.mallName;
2023-08-29 13:42:07 +08:00
this.last30DaySkcList.push({
productName: item.productName,
2023-09-12 16:04:17 +08:00
mallName: this.mallName,
2023-08-29 13:42:07 +08:00
productId: item.productId,
productSkcId: item.productSkcId,
skcExtCode: item.skcExtCode,
productSkcPicture: item.productSkcPicture
})
2023-08-25 00:56:56 +08:00
if (item.onSalesDurationOffline == 0) {
data.onSalesDurationOffline = '-天'
} else {
data.onSalesDurationOffline = item.onSalesDurationOffline + '天'
}
2023-09-12 20:49:22 +08:00
2023-08-06 16:50:17 +08:00
for(let j = 0;j < item.skuQuantityDetailList.length; j++) {
2023-09-12 20:49:22 +08:00
data = {...data, ...item.skuQuantityDetailList[j],
2023-08-14 17:21:31 +08:00
productTotalPrice: ((item.skuQuantityDetailList[j].supplierPrice / 100) * item.skuQuantityDetailList[j].inventoryNumInfo.warehouseInventoryNum).toFixed(2),
2024-01-26 00:20:31 +08:00
inroadTotalPrice: ((item.skuQuantityDetailList[j].supplierPrice / 100) * (item.skuQuantityDetailList[j].inventoryNumInfo.waitOnShelfNum + item.skuQuantityDetailList[j].inventoryNumInfo.waitReceiveNum)).toFixed(2),
2023-08-14 17:21:31 +08:00
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))
2023-08-22 20:16:59 +08:00
this.todayMoney = new Number(this.todayMoney.toFixed(2))
2023-08-14 23:30:05 +08:00
this.inventoryTotal += item.skuQuantityDetailList[j].inventoryNumInfo.warehouseInventoryNum
2024-01-26 00:20:31 +08:00
this.inventoryMoney += new Number(((item.skuQuantityDetailList[j].supplierPrice / 100) * item.skuQuantityDetailList[j].inventoryNumInfo.warehouseInventoryNum).toFixed(2))
this.inventoryMoney = new Number(this.inventoryMoney.toFixed(2))
this.inroadTotal += (item.skuQuantityDetailList[j].inventoryNumInfo.waitOnShelfNum + item.skuQuantityDetailList[j].inventoryNumInfo.waitReceiveNum)
this.inroadTotalMoney += new Number(((item.skuQuantityDetailList[j].supplierPrice / 100) * (item.skuQuantityDetailList[j].inventoryNumInfo.waitOnShelfNum + item.skuQuantityDetailList[j].inventoryNumInfo.waitReceiveNum)).toFixed(2))
this.inroadTotalMoney = new Number(this.inroadTotalMoney.toFixed(2))
2024-01-10 01:27:15 +08:00
this.adviceProduceNum = item.skuQuantityDetailList[j].adviceProduceNum || '-'
this.availableProduceNum = item.skuQuantityDetailList[j].availableProduceNum || '-'
2023-08-06 16:50:17 +08:00
this.list.push(data);
2023-08-22 20:16:59 +08:00
// 计算已发货货值
for(let k = 0; k < this.allProductList.length; k++) {
if (this.allProductList[k].product_sku_id == data.productSkuId) {
2024-01-26 00:20:31 +08:00
this.deliveryMoney += (item.skuQuantityDetailList[j].supplierPrice / 100) * this.allProductList[k].product_sku_number
this.deliveryMoney = new Number(this.deliveryMoney.toFixed(2))
2023-08-22 20:16:59 +08:00
}
}
2023-08-06 16:50:17 +08:00
}
}
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-22 20:16:59 +08:00
2023-08-29 13:42:07 +08:00
// 初始化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 => {
2023-08-22 20:16:59 +08:00
let temp = {
productName: item.productName,
2023-09-12 16:04:17 +08:00
mallName: this.mallName,
2023-08-22 20:16:59 +08:00
productId: item.productId,
productSkcId: item.productSkcId,
2023-08-29 13:42:07 +08:00
productSkuId: item.productSkuId,
skuExtCode: item.skuExtCode,
skcExtCode: item.skcExtCode,
productSkcPicture: item.productSkcPicture
2023-08-22 20:16:59 +08:00
}
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
})
2023-09-25 10:13:54 +08:00
this.skuIds = this.list.map(item => {
return item.productSkuId
})
this.getSkuDetailList(0)
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
},
2023-09-25 10:13:54 +08:00
getSkuDetailList (page) {
let tempSkuId = []
let i = page * 500
let j = 0
for (; i < this.skuIds.length; i++) {
tempSkuId.push(this.skuIds[i])
j ++
if (j == 500) break
}
if (tempSkuId.length == 0) return
2023-08-22 20:16:59 +08:00
sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/sales/management/querySkuSalesNumber',
needMallId: true,
mallId: this.mallId,
data: {
2023-09-25 10:13:54 +08:00
"productSkuIds": tempSkuId,
2023-08-22 20:16:59 +08:00
"startDate": this.startDate,
2023-09-25 10:13:54 +08:00
// "startDate": '2023-01-17',
2023-08-22 20:16:59 +08:00
"endDate": this.endDate
}}).then((res) => {
if (res.errorCode == 1000000) {
for (let i = 0; i < res.result.length; i++) {
2023-08-29 13:42:07 +08:00
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
}
}
2023-08-22 20:16:59 +08:00
break
}
}
}
2023-09-25 10:13:54 +08:00
this.getSkuDetailList(page + 1)
2023-08-29 13:42:07 +08:00
} else {
setTimeout(() => {
2023-09-25 10:13:54 +08:00
this.getSkuDetailList(page)
2023-08-29 13:42:07 +08:00
}, 1500)
2023-08-22 20:16:59 +08:00
}
})
},
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;
}
}
})
2024-01-10 01:27:15 +08:00
},
toDownload() {
this.downloadSkuSaleNumberDlg = true
},
startSkuSaleNumberDownload() {
},
handleClose() {
2024-01-10 11:32:43 +08:00
this.downloadSkuSaleNumberDlg = false
2024-01-10 01:27:15 +08:00
},
async toDownloadSkuSaleNumber() {
2024-01-18 00:46:23 +08:00
this.downloadSkuSaleNumberDlg = false
2024-01-10 01:27:15 +08:00
this.isLoading = true
if (!this.skuDownloadForm.date) {
Message.error("请选择时间")
return
}
let beginDateStr = formatDate(this.skuDownloadForm.date[0])
2024-01-20 01:37:46 +08:00
let endDateStr = formatDate(this.skuDownloadForm.date[1])
2024-01-10 01:27:15 +08:00
2024-01-18 00:46:23 +08:00
let temp = {}
temp = {
'SKC': 'skc',
'SKU': 'sku',
'SKU货号': 'skuExtCode'
2024-01-10 01:27:15 +08:00
}
2024-01-18 00:46:23 +08:00
let beginTime = new Date(this.skuDownloadForm.date[0])
let endTime = new Date(this.skuDownloadForm.date[1])
for (; beginTime.getTime() <= endTime.getTime(); ) {
let dateStr = formatDate(endTime)
temp[dateStr] = dateStr
2024-01-10 01:27:15 +08:00
2024-01-18 00:46:23 +08:00
endTime.setDate(endTime.getDate() - 1)
2024-01-10 01:27:15 +08:00
}
2024-01-18 00:46:23 +08:00
this.skuSaleNumberFields = temp
2024-01-10 01:27:15 +08:00
let tempSkuList = this.list.filter(item => {
return item.onSalesDurationOffline != '-天'
})
2024-01-20 01:37:46 +08:00
let tempSkuIds = []
2024-01-18 00:46:23 +08:00
tempSkuList.map(i => {
2024-01-20 01:37:46 +08:00
tempSkuIds.push(i.productSkuId)
2024-01-18 00:46:23 +08:00
})
this.skuSaleNumberList = []
this.list.map(item => {
if (item.onSalesDurationOffline != '-天') {
let temp = {
sku: item.productSkuId,
skc: item.productSkcId,
skuExtCode: item.skuExtCode
}
beginTime = new Date(this.skuDownloadForm.date[0])
endTime = new Date(this.skuDownloadForm.date[1])
for (; beginTime.getTime() <= endTime.getTime(); ) {
let dateStr = formatDate(endTime)
temp[dateStr] = 0
2024-01-10 01:27:15 +08:00
2024-01-18 00:46:23 +08:00
endTime.setDate(endTime.getDate() - 1)
}
this.skuSaleNumberList.push(temp)
}
2024-01-10 01:27:15 +08:00
})
2024-01-20 01:37:46 +08:00
let reqSkusIds = [], pageSize = 200
for (let i = 0; i < tempSkuIds.length; i++) {
reqSkusIds.push(tempSkuIds[i])
if (reqSkusIds.length % pageSize == 0 || ((i+1) == tempSkuIds.length)) {
let res = await sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/sales/management/querySkuSalesNumber',
needMallId: true,
mallId: this.mallId,
data: {
"productSkuIds": reqSkusIds,
"startDate": beginDateStr,
"endDate": endDateStr
}})
2024-01-18 00:46:23 +08:00
2024-01-20 01:37:46 +08:00
if (res.success) {
res.result.map(item => {
for (let i = 0; i < this.skuSaleNumberList.length; i++) {
if (this.skuSaleNumberList[i].sku == item.prodSkuId) {
this.skuSaleNumberList[i][item.date] = item.salesNumber
break
}
}
})
} else {
this.isLoading = false
Message.error("获取SKU历史销量数据失败")
break
}
2024-01-10 01:27:15 +08:00
2024-01-20 01:37:46 +08:00
if ((i+1) == tempSkuIds.length) {
document.getElementById('downloadSkuSaleNumber').click()
this.isLoading = false
}
reqSkusIds = []
}
}
2023-08-06 16:50:17 +08:00
}
}
}
</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>