This commit is contained in:
liushiwei
2023-08-11 08:31:53 +08:00
parent 51a47938a6
commit e6ccd59a9b
3 changed files with 169 additions and 48 deletions

View File

@@ -10,8 +10,25 @@
<template slot="content">
<ai-search-bar>
<template #left>
<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>
<el-dropdown @command="handleClick">
<el-button type="primary" :disabled="isBegin">添加备货单</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="byStore">按店铺添加</el-dropdown-item>
<el-dropdown-item command="loadAll">一键添加所有</el-dropdown-item>
</el-dropdown-menu>
<!--<el-button type="primary" :disabled="isBegin" @click="isShow = true">添加备货单</el-button>
<el-button type="primary" :disabled="isBegin" @click="loadAll">一键加载全部</el-button>-->
</el-dropdown>
<el-dropdown @command="handleRobClick" v-if="!isBegin">
<el-button type="button" :class="'el-button el-button--primary'">开始抢仓</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :disabled="isBegin" command="normal">普通抢仓</el-dropdown-item>
<el-dropdown-item :disabled="isBegin" command="faster">极速抢仓</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button v-else type="button" :icon="isBegin? 'el-icon-loading': ''" :class="isBegin ? 'el-button el-button--danger': 'el-button el-button--primary'" @click="beginRob()">{{ `结束抢仓(${choosedList.length}/${robTotal})` }}</el-button>
<!--<el-checkbox :disabled="isBegin" v-model="isCreateDeliveryBill">立即创建发货单</el-checkbox>-->
</template>
<template #right>
</template>
@@ -21,8 +38,7 @@
:col-configs="robColConfigs"
:total="total"
:isShowPagination="false"
style="margin-top: 8px;"
@getList="getList">
style="margin-top: 8px;">
<el-table-column slot="productName" width="480px" label="商品信息" align="center">
<template slot-scope="scope">
<div class="product">
@@ -100,8 +116,7 @@
:total="total"
:isShowPagination="false"
style="margin-top: 8px;"
@selection-change="onChooseChange"
@getList="getList">
@selection-change="onChooseChange">
<el-table-column slot="productName" width="400px" label="商品信息" align="center">
<template slot-scope="scope">
<div class="product">
@@ -148,7 +163,7 @@
<script>
import { mapState } from 'vuex'
import {sendChromeAPIMessage, sendChromeNotification} from '@/api/chromeApi'
import { Message } from 'element-ui'
import { Message, TimeSelect } from 'element-ui'
export default {
name: 'NormalSendGoods',
@@ -181,7 +196,12 @@
robTotal: 0,
pageSize: 100,
currentPage: 1,
step: 400
step: 400,
timer: [],
loadMallIndex: 0,
loadMode: 0, // 加载模式0表示单个店铺加载1表示一键加载
robMode: 0, // 抢仓模式0表示普通抢仓1表示极速抢仓
isCreateDeliveryBill: false,
}
},
@@ -204,9 +224,10 @@
this.mallName = mallInfo[0].mallName
// 下载数据
this.loadMode = 0
this.tableData = []
this.currentPage = 1
this.getList()
this.getList(this.tableData, this.mallId, this.mallName, 1)
}).catch((err) => {
console.log(err)
})
@@ -226,14 +247,39 @@
})
Message.success("添加成功,可继续添加")
},
loadAll() {
this.$userCheck().then(() => {
this.choosedList = []
this.loadMallIndex = 0
this.loadMode = 1
this.getList(this.choosedList, this.mallList[this.loadMallIndex].mallId, this.mallList[this.loadMallIndex].mallName, 1)
});
},
getList () {
handleClick (e) {
if (e === 'byStore') {
this.isShow = true
} else if (e === 'loadAll') {
this.loadAll()
}
},
handleRobClick (e) {
if (e === 'normal') {
this.robMode = 0
} else if (e === 'faster') {
this.robMode = 1
}
this.beginRob()
},
getList (data, mallId, mallName, currentPage) {
sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/purchase/manager/querySubOrderList',
needMallId: true,
mallId: this.mallId,
mallId: mallId,
data: {
"pageNo": this.currentPage,
"pageNo": currentPage,
"pageSize": this.pageSize,
"urgencyType": 0,
"isCustomGoods": false,
@@ -247,7 +293,7 @@
return item.isCanJoinDeliverPlatform;
})
res.result.subOrderForSupplierList.map((item) => {
this.tableData.push({
data.push({
robTotal: 0,
subPurchaseOrderSn: item.subPurchaseOrderSn,
originalPurchaseOrderSn: item.originalPurchaseOrderSn,
@@ -258,14 +304,23 @@
status: item.status,
detailList: item.skuQuantityDetailList,
category: item.category,
mallId: this.mallId,
mallName: this.mallName
mallId: mallId,
mallName: mallName
})
})
if (this.pageSize == length) {
this.currentPage ++
this.getList()
currentPage ++
this.getList(data, mallId, mallName, currentPage)
} else {
if (this.loadMode == '1') {
this.loadMallIndex ++
if (this.loadMallIndex < this.mallList.length) {
this.getList(data, this.mallList[this.loadMallIndex].mallId, this.mallList[this.loadMallIndex].mallName, 1)
} else {
Message.success("所有店铺备货单已加载完成")
}
}
}
} else {
Message.error("【拼多多】" + res.errorMsg)
@@ -286,25 +341,32 @@
beginRob() {
if (this.isBegin) {
this.isBegin = false;
for (let i = 0;i < this.timer.length; i++) {
clearInterval(this.timer[i].timer);
}
return;
}
if (this.choosedList.length <= 0) {
Message.error('请选择备货单');
Message.error('请添加备货单');
return;
}
this.robTotal = this.choosedList.length
this.isBegin = true;
this.timer = [];
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)*/
setTimeout(() => {
this.rob(this.choosedList[i].subPurchaseOrderSn, this.choosedList[i].mallId)
}, this.step * i)
if (0 == this.robMode) {
setTimeout(() => {
this.rob(this.choosedList[i].subPurchaseOrderSn, this.choosedList[i].mallId)
}, this.step * i)
} else {
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)
}
}
let _this = this;
@@ -314,23 +376,6 @@
clearInterval(tt);
}
}, 1000)
// 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;
// }
// } else {
// console.log("获取用户信息失败")
// }
// });
},
robFunc(sn, mallId) {
let _this = this;
@@ -347,6 +392,16 @@
"subPurchaseOrderSn": sn
}}).then((res) => {
if (res.errorCode == 1000000) {
if (1 == this.robMode) {
let t = this.timer.filter((item) => {
return item.id == sn;
})
if (t.length > 0) {
clearInterval(t[0].timer)
}
}
for (let j = 0; j < this.choosedList.length; j++) {
if (this.choosedList[j].subPurchaseOrderSn == sn) {
this.addSuccessInfo(this.choosedList[j]);
@@ -355,6 +410,11 @@
break;
}
}
// 如果需要创建发货单
if (this.isCreateDeliveryBill) {
this.createDeliveryBill(sn, mallId)
}
} else {
for (let j = 0; j < this.choosedList.length; j++) {
if (this.choosedList[j].subPurchaseOrderSn == sn) {
@@ -362,14 +422,71 @@
break;
}
}
if (this.isBegin) {
setTimeout(() => {
this.rob(sn, mallId)
}, this.choosedList.length * this.step)
if (0 == this.robMode) {
if (this.isBegin) {
setTimeout(() => {
this.rob(sn, mallId)
}, this.choosedList.length * this.step)
}
}
}
})
},
createDeliveryBill(sn, mallId) {
sendChromeAPIMessage({
url: 'bgSongbird-api/supplier/deliverGoods/platform/pageQuerySubPurchaseOrder',
needMallId: true,
mallId: mallId,
data: {
"pageNo": 1,
"pageSize": 10,
"subPurchaseOrderSnList": [
sn
]
}}).then((res) => {
if (res.errorCode == 1000000) {
let data = res.result.list[0]
let deliverOrderDetailInfos = data.orderDetailVOList.map(item => {
return {
productSkuId: item.productSkuId,
deliverSkuNum: item.productSkuPurchaseQuantity
}
})
let packageDetailSaveInfos = data.orderDetailVOList.map(item => {
return {
productSkuId: item.productSkuId,
skuNum: item.productSkuPurchaseQuantity
}
})
let packageInfos = []
packageInfos.push({packageDetailSaveInfos: packageDetailSaveInfos})
let deliveryOrderCreateInfos = []
deliveryOrderCreateInfos.push({
deliverOrderDetailInfos: deliverOrderDetailInfos,
subPurchaseOrderSn: data.subPurchaseOrderBasicVO.subPurchaseOrderSn,
packageInfos: packageInfos
})
let deliveryOrderCreateGroupList = []
deliveryOrderCreateGroupList.push({
deliveryOrderCreateInfos: deliveryOrderCreateInfos,
receiveAddressInfo: data.subPurchaseOrderBasicVO.receiveAddressInfo,
subWarehouseId: data.subPurchaseOrderBasicVO.subWarehouseId
})
console.log(deliveryOrderCreateGroupList)
} else {
setTimeout(this.createDeliveryBillFun(sn, mallId), 1000)
}
})
},
createDeliveryBillFun(sn, mallId) {
let _this = this;
return function() {
_this.createDeliveryBill(sn, mallId);
}
},
addSuccessInfo(obj) {
this.$http.post(`/api/successInfo/add`, {
productName: obj.productName,