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

471 lines
16 KiB
Vue
Raw Normal View History

2023-08-06 16:50:17 +08:00
<template>
<div>
<ai-list class="list">
<ai-title
slot="title"
title="普通备货单"
tips="请先在当前浏览器登录“拼多多跨境卖家中心”,期间保持登录状态"
isShowBottomBorder>
</ai-title>
<template slot="content">
<ai-search-bar>
<template #left>
2023-08-08 04:14:08 +08:00
<el-button type="primary" :disabled="isBegin" @click="isShow = true">添加备货单</el-button>
<el-button type="button" :icon="isBegin? 'el-icon-loading': ''" :class="isBegin ? 'el-button el-button--danger': 'el-button el-button--primary'" @click="beginRob()">{{isBegin ? `结束抢仓(${choosedList.length}/${robTotal})`: '开始抢仓'}}</el-button>
2023-08-06 16:50:17 +08:00
</template>
<template #right>
</template>
</ai-search-bar>
<ai-table
2023-08-07 15:04:07 +08:00
:tableData="choosedList"
2023-08-08 04:14:08 +08:00
:col-configs="robColConfigs"
2023-08-06 16:50:17 +08:00
:total="total"
:isShowPagination="false"
style="margin-top: 8px;"
2023-08-07 13:51:28 +08:00
@getList="getList">center
<el-table-column slot="productName" width="480px" label="商品信息" show-overflow-tooltip align="center">
2023-08-06 16:50:17 +08:00
<template slot-scope="scope">
2023-08-07 13:51:28 +08:00
<div class="order-manage_productInfo__1pD83">
<img :src="scope.row.productSkcPicture">
<div class="right">
<div>备货母单号: {{ scope.row.originalPurchaseOrderSn }}</div>
<div>{{ scope.row.productName }}</div>
<div>SKC: {{ scope.row.productSkcId }}</div>
<div>货号: {{ scope.row.productSn }}</div>
2023-08-06 16:50:17 +08:00
</div>
</div>
</template>
</el-table-column>
2023-08-08 04:14:08 +08:00
<el-table-column slot="robInfo" label="抢仓信息" width="140px" show-overflow-tooltip fixed="right" align="center">
2023-08-06 16:50:17 +08:00
<template slot-scope="scope">
<div data-testid="beast-core-box" style="margin-right: 2px;">
已抢仓 <div style="color: red; display: inline;">{{ scope.row.robTotal }}</div>
</div>
</template>
</el-table-column>
2023-08-07 13:51:28 +08:00
<el-table-column slot="className" label="SKU信息" width="440px" show-overflow-tooltip align="center">
2023-08-06 16:50:17 +08:00
<template slot-scope="scope">
2023-08-07 13:51:28 +08:00
<div class="order-manage_skuInfo__FW-Nd" v-for="(item, index) in scope.row.detailList" :key="index">
2023-08-06 16:50:17 +08:00
<div>
<div data-testid="beast-core-box" class="outerWrapper-1-3-1 outerWrapper-d18-1-3-20 index-module__image-preview___2fiZX">
<div class="index-module__img___p3B1N" :style="getStyle(item.thumbUrlList[0])"></div>
</div>
</div>
<div class="order-manage_contentInfo__1Cjd6" style="max-width: 150px;">
<div class="order-manage_title__1VTO5">属性{{ item.className }}下单数量{{ item.purchaseQuantity }}</div>
<div>SKU ID {{ item.productSkuId }}</div>
<div class="order-manage_productSku__XP_ke">SKU 货号 {{ item.extCode }}</div>
</div>
</div>
</template>
</el-table-column>
2023-08-08 04:14:08 +08:00
<el-table-column slot="status" label="状态" show-overflow-tooltip align="center" width="120px">
2023-08-07 13:51:28 +08:00
<template slot-scope="scope">
<div data-testid="beast-core-box" class="outerWrapper-1-3-1 outerWrapper dot-module__dot___M-RuH " style="margin-right: 2px;">
<div class="dot-module__circle___2l2UV" style="background-color: var(--pc-dot-warn-bg-color,#ff6800);"></div>待发货
</div>
</template>
</el-table-column>
2023-08-08 04:14:08 +08:00
<el-table-column slot="options" label="操作" width="80px" v-if="!isBegin" show-overflow-tooltip align="center" fixed="right">
<template slot-scope="{ row }">
<div class="table-options">
<el-button type="text" @click="remove(row.subPurchaseOrderSn)">移除</el-button>
</div>
</template>
</el-table-column>
2023-08-06 16:50:17 +08:00
</ai-table>
2023-08-07 13:51:28 +08:00
<AiDialog
2023-08-08 04:14:08 +08:00
title="添加备货单"
2023-08-07 13:51:28 +08:00
:visible.sync="isShow"
:close-on-click-modal="false"
2023-08-08 04:14:08 +08:00
customFooter
2023-08-07 15:04:07 +08:00
@confirm="onConfirm"
2023-08-07 13:51:28 +08:00
width="1290px">
2023-08-08 04:14:08 +08:00
<label style="width:90px">店铺</label>
<el-select v-model="mallId" placeholder="请选择" @change="mallChange">
2023-08-07 13:51:28 +08:00
<el-option
v-for="item in mallList"
:key="item.mallId"
:label="item.mallName"
2023-08-08 04:14:08 +08:00
:value="item.mallId">
2023-08-07 13:51:28 +08:00
{{ item.mallName }}
</el-option>
</el-select>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
:isShowPagination="false"
style="margin-top: 8px;"
2023-08-07 15:04:07 +08:00
@selection-change="onChooseChange"
@getList="getList">
2023-08-07 13:51:28 +08:00
<el-table-column slot="productName" width="400px" label="商品信息" show-overflow-tooltip align="center">
<template slot-scope="scope">
<div class="order-manage_productInfo__1pD83">
<img :src="scope.row.productSkcPicture">
<div class="right">
<div>备货母单号: {{ scope.row.originalPurchaseOrderSn }}</div>
<div>{{ scope.row.productName }}</div>
<div>SKC: {{ scope.row.productSkcId }}</div>
<div>货号: {{ scope.row.productSn }}</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column slot="className" label="SKU信息" width="400px" show-overflow-tooltip align="center">
<template slot-scope="scope">
<div class="order-manage_skuInfo__FW-Nd" v-for="(item, index) in scope.row.detailList" :key="index">
<div>
<div data-testid="beast-core-box" class="outerWrapper-1-3-1 outerWrapper-d18-1-3-20 index-module__image-preview___2fiZX">
<div class="index-module__img___p3B1N" :style="getStyle(item.thumbUrlList[0])"></div>
</div>
</div>
<div class="order-manage_contentInfo__1Cjd6" style="max-width: 150px;">
<div class="order-manage_title__1VTO5">属性{{ item.className }}下单数量{{ item.purchaseQuantity }}</div>
<div>SKU ID {{ item.productSkuId }}</div>
<div class="order-manage_productSku__XP_ke">SKU 货号 {{ item.extCode }}</div>
</div>
</div>
</template>
</el-table-column>
</ai-table>
2023-08-08 04:14:08 +08:00
<span slot="footer" class="dialog-footer">
<el-button @click="isShow = false"> </el-button>
<el-button type="primary" @click="onConfirm">添加</el-button>
</span>
2023-08-07 13:51:28 +08:00
</AiDialog>
2023-08-06 16:50:17 +08:00
</template>
</ai-list>
</div>
</template>
<script>
2023-08-07 13:51:28 +08:00
import { mapState } from 'vuex'
2023-08-06 16:50:17 +08:00
import {sendChromeAPIMessage, sendChromeNotification} from '@/api/chromeApi'
import { Message } from 'element-ui'
export default {
name: 'NormalSendGoods',
data () {
return {
2023-08-07 13:51:28 +08:00
isShow: false,
2023-08-06 16:50:17 +08:00
colConfigs: [
2023-08-07 13:51:28 +08:00
{ type: "selection", width: '70px', align: 'left' },
2023-08-07 15:04:07 +08:00
{ prop: 'subPurchaseOrderSn', label: '备货单号', align: 'left' },
2023-08-07 13:51:28 +08:00
{ slot: 'productName' },
2023-08-06 16:50:17 +08:00
{ slot: 'className'},
{ slot: 'robInfo'},
{ slot: 'status' }
],
2023-08-08 04:14:08 +08:00
robColConfigs: [
{ prop: 'subPurchaseOrderSn', width: '180px', label: '备货单号', align: 'left' },
{ slot: 'productName' },
{ prop: 'mallName', label: '店铺来源', width: '120px', align: 'center' },
{ slot: 'className'},
{ slot: 'robInfo'},
{ slot: 'status' }
],
2023-08-07 13:51:28 +08:00
mallId: '',
2023-08-08 04:14:08 +08:00
mallName: '',
2023-08-06 16:50:17 +08:00
tableData: [],
total: 0,
isBegin: false,
2023-08-07 15:04:07 +08:00
timer: null,
choosedList: [],
2023-08-08 04:14:08 +08:00
arr: [],
robTotal: 0
2023-08-06 16:50:17 +08:00
}
},
2023-08-07 15:04:07 +08:00
computed: {
2023-08-08 04:14:08 +08:00
...mapState(['mallList'])
2023-08-07 15:04:07 +08:00
},
2023-08-07 13:51:28 +08:00
2023-08-06 16:50:17 +08:00
created () {
2023-08-08 04:14:08 +08:00
this.mallId = this.mallList[0].mallId
this.mallName = this.mallList[0].mallName
2023-08-06 16:50:17 +08:00
this.getList()
},
methods: {
2023-08-07 15:04:07 +08:00
onChooseChange (e) {
this.arr = e
},
2023-08-08 04:14:08 +08:00
mallChange() {
let mallInfo = this.mallList.filter(item => {
return item.mallId == this.mallId
})
this.mallName = mallInfo.mallName
this.getList()
2023-08-07 15:04:07 +08:00
},
2023-08-08 04:14:08 +08:00
onConfirm () {
if (this.arr.length == 0) {
Message.error("请选择备货单")
return
}
this.arr.map(item => {
let temp = this.choosedList.filter(i => {
return i.subPurchaseOrderSn == item.subPurchaseOrderSn
})
if (temp.length == 0) {
this.choosedList.push(item)
2023-08-07 15:04:07 +08:00
}
})
2023-08-08 04:14:08 +08:00
Message.success("添加成功,可继续添加")
2023-08-07 15:04:07 +08:00
},
2023-08-06 16:50:17 +08:00
getList () {
2023-08-08 04:14:08 +08:00
this.tableData = []
2023-08-06 16:50:17 +08:00
sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/purchase/manager/querySubOrderList',
needMallId: true,
2023-08-08 04:14:08 +08:00
mallId: this.mallId,
2023-08-06 16:50:17 +08:00
data: {
"pageNo": 1,
"pageSize": 100,
"urgencyType": 0,
"isCustomGoods": false,
"statusList": [
1
]
}}).then((res) => {
if (res.errorCode == 1000000) {
res.result.subOrderForSupplierList = res.result.subOrderForSupplierList.filter((item) => {
return item.isCanJoinDeliverPlatform;
})
this.tableData = res.result.subOrderForSupplierList.map((item) => {
return {
robTotal: 0,
subPurchaseOrderSn: item.subPurchaseOrderSn,
originalPurchaseOrderSn: item.originalPurchaseOrderSn,
productName: item.productName,
productSn: item.productSn,
productSkcId: item.productSkcId,
productSkcPicture: item.productSkcPicture,
status: item.status,
2023-08-08 04:14:08 +08:00
detailList: item.skuQuantityDetailList,
category: item.category,
mallId: this.mallId,
mallName: this.mallName
2023-08-06 16:50:17 +08:00
};
})
} else {
Message.error("【拼多多】" + res.error_msg)
}
})
},
2023-08-08 04:14:08 +08:00
remove(sn) {
for (let i = 0; i < this.choosedList.length; i++) {
if (this.choosedList[i].subPurchaseOrderSn == sn) {
this.choosedList.splice(i, 1)
break
}
}
2023-08-06 16:50:17 +08:00
},
getStyle(url) {
return "background-image: url(" + url + "); width: 72px; height: 72px; cursor: pointer; border-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.14);";
},
beginRob() {
if (this.isBegin) {
this.isBegin = false;
for (let i = 0;i < this.timer.length; i++) {
clearInterval(this.timer[i].timer);
}
return;
}
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;
}
if (res.data.type != 4 && this.$store.state.mallId != this.$store.state.userInfo.mallId) {
Message.error('您当前登录的TEMU账号与会员绑定账号不一致')
return;
}
2023-08-08 04:14:08 +08:00
if (this.choosedList.length <= 0) {
Message.error('请选择备货单');
2023-08-06 16:50:17 +08:00
return;
}
2023-08-08 04:14:08 +08:00
this.robTotal = this.choosedList.length
2023-08-06 16:50:17 +08:00
this.isBegin = true;
this.timer = [];
2023-08-08 04:14:08 +08:00
for (let i = 0;i < this.choosedList.length; i++) {
setTimeout(() => {
let t = setInterval(this.robFunc(this.choosedList[i].subPurchaseOrderSn, this.choosedList[i].mallId), 1000);
this.timer.push({id: this.choosedList[i].subPurchaseOrderSn, timer: t})
}, 100 * i)
2023-08-06 16:50:17 +08:00
}
let _this = this;
let tt = setInterval(function() {
2023-08-08 04:14:08 +08:00
if (_this.choosedList.length == 0) {
2023-08-06 16:50:17 +08:00
_this.isBegin = false;
clearInterval(tt);
}
}, 1000)
} else {
console.log("获取用户信息失败")
}
});
},
2023-08-08 04:14:08 +08:00
robFunc(sn, mallId) {
2023-08-06 16:50:17 +08:00
let _this = this;
return function() {
2023-08-08 04:14:08 +08:00
_this.rob(sn, mallId);
2023-08-06 16:50:17 +08:00
}
},
2023-08-08 04:14:08 +08:00
rob(sn, mallId) {
2023-08-06 16:50:17 +08:00
sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/purchase/manager/joinDeliveryGoodsOrderPlatform',
needMallId: true,
2023-08-08 04:14:08 +08:00
mallId: mallId,
2023-08-06 16:50:17 +08:00
data: {
"subPurchaseOrderSn": sn
}}).then((res) => {
if (res.errorCode == 1000000) {
2023-08-08 04:14:08 +08:00
for (let i = 0;i < this.choosedList.length; i++) {
if (this.choosedList[i].subPurchaseOrderSn == sn) {
this.choosedList.splice(i, 1)
2023-08-06 16:50:17 +08:00
break;
}
}
let t = this.timer.filter((item) => {
return item.id == sn;
})
if (t.length > 0) {
clearInterval(t[0].timer)
}
2023-08-08 04:14:08 +08:00
for (let j = 0; j < this.choosedList.length; j++) {
if (this.choosedList[j].subPurchaseOrderSn == sn) {
this.addSuccessInfo(this.choosedList[j]);
this.sendNotification(this.choosedList[j]);
this.choosedList.splice(j, 1);
2023-08-06 16:50:17 +08:00
break;
}
}
} else {
2023-08-08 04:14:08 +08:00
for (let j = 0; j < this.choosedList.length; j++) {
if (this.choosedList[j].subPurchaseOrderSn == sn) {
this.choosedList[j].robTotal ++;
2023-08-06 16:50:17 +08:00
break;
}
}
}
})
},
2023-08-08 04:14:08 +08:00
addSuccessInfo(obj) {
this.$http.post(`/api/successInfo/add`, null, {
2023-08-06 16:50:17 +08:00
params: {
2023-08-08 04:14:08 +08:00
productName: obj.productName,
subPurchaseOrderSn: obj.subPurchaseOrderSn,
mallId: obj.mallId,
mallName: obj.mallName,
categoryName: obj.category
2023-08-06 16:50:17 +08:00
}
}).then(res => {
console.log(res)
})
},
2023-08-08 04:14:08 +08:00
sendNotification(obj) {
sendChromeNotification({productName: obj.productName, mallName: obj.mallName})
2023-08-06 16:50:17 +08:00
}
}
}
</script>
<style scoped lang="scss">
2023-08-07 13:51:28 +08:00
.order-manage_productInfo__1pD83 {
display: flex;
align-items: center;
justify-content: center;
2023-08-06 16:50:17 +08:00
2023-08-07 13:51:28 +08:00
.right {
text-align: left;
}
}
2023-08-06 16:50:17 +08:00
.order-manage_productInfo__1pD83>img {
2023-08-07 13:51:28 +08:00
2023-08-06 16:50:17 +08:00
width: 60px;
2023-08-07 13:51:28 +08:00
margin-right: 10px;
2023-08-06 16:50:17 +08:00
}
.order-manage_productInfo__1pD83 {
min-height: 60px;
padding-left: 70px;
position: relative;
}
.order-manage_productInfo__1pD83>div:nth-child(2) {
color: rgba(0,0,0,.8);
}
.outerWrapper {
margin: 4px 4px 0px 0px;
}
.dot-module__dot___M-RuH .dot-module__circle___2l2UV {
flex-shrink: 0;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 8px;
}
.dot-module__dot___M-RuH {
display: inline-flex;
align-items: center;
}
.index-module__image-preview___2fiZX .index-module__img___p3B1N {
width: 60px;
height: 60px;
2023-08-07 13:51:28 +08:00
margin-right: 10px;
2023-08-06 16:50:17 +08:00
background-repeat: no-repeat;
background-size: cover;
background-color: #f5f5f5;
font-size: 12px;
display: flex;
justify-content: center;
align-items: center;
color: var(--bc-Table-emptyTextColor);
position: relative;
}
.order-manage_skuInfo__FW-Nd, .order-manage_skuInfo__FW-Nd .order-manage_contentInfo__1Cjd6 {
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
2023-08-07 13:51:28 +08:00
justify-content: center;
2023-08-06 16:50:17 +08:00
}
.order-manage_skuInfo__FW-Nd .order-manage_contentInfo__1Cjd6 {
-webkit-flex-direction: column;
-moz-box-orient: vertical;
-moz-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
color: rgba(0,0,0,.4);
-webkit-flex: 1 0 auto;
-moz-box-flex: 1;
-ms-flex: 1 0 auto;
flex: 1 0 auto;
}
.order-manage_skuInfo__FW-Nd .order-manage_contentInfo__1Cjd6 .order-manage_title__1VTO5 {
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
color: rgba(0,0,0,.8);
}
</style>