This commit is contained in:
liushiwei
2023-08-15 11:41:23 +08:00
parent 4790270f06
commit 55c408ac6c

View File

@@ -235,6 +235,7 @@
total: 0,
isBegin: false,
choosedList: [],
choosedSnMallList: [],
arr: [],
robTotal: 0,
pageSize: 100,
@@ -411,12 +412,19 @@
Message.error('请添加备货单');
return;
}
this.choosedSnMallList = this.choosedList.map(item => {
return {sn: item.subPurchaseOrderSn, mallId: item.mallId}
})
this.robTotal = this.choosedList.length
this.isBegin = true;
this.timer = [];
for (let i = 0;i < this.choosedList.length; i++) {
if (0 == this.robMode) {
this.rob()
}
/*for (let i = 0;i < this.choosedList.length; i++) {
if (0 == this.robMode) {
setTimeout(() => {
this.rob(this.choosedList[i].subPurchaseOrderSn, this.choosedList[i].mallId)
@@ -427,7 +435,7 @@
this.timer.push({id: this.choosedList[i].subPurchaseOrderSn, timer: t})
}, 100 * i)
}
}
}*/
let _this = this;
let tt = setInterval(function() {
@@ -443,7 +451,13 @@
_this.rob(sn, mallId);
}
},
rob(sn, mallId) {
rob() {
let obj = this.choosedSnMallList.shift()
if (!obj || !this.isBegin) {
return
}
let sn = obj.sn
let mallId = obj.mallId
sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/purchase/manager/joinDeliveryGoodsOrderPlatform',
needMallId: true,
@@ -461,7 +475,6 @@
}
}
for (let j = 0; j < this.choosedList.length; j++) {
if (this.choosedList[j].subPurchaseOrderSn == sn) {
this.successList.push(this.choosedList[j])
@@ -477,23 +490,30 @@
this.createDeliveryBill(sn, mallId)
}
} else {
this.choosedSnMallList.push(obj)
for (let j = 0; j < this.choosedList.length; j++) {
if (this.choosedList[j].subPurchaseOrderSn == sn) {
this.choosedList[j].robTotal ++;
break;
}
}
if (0 == this.robMode) {
/*if (0 == this.robMode) {
if (this.isBegin) {
setTimeout(() => {
this.rob(sn, mallId)
}, this.choosedList.length * this.step + Math.floor((Math.random() * this.randomValue) + 1))
}, this.choosedList.length * this.step)
}
}
}*/
}
if (!res.errorCode && res.error_code) {
this.networkErrorCount ++
}
if (0 == this.robMode) {
// 继续抢
setTimeout(() => {
this.rob()
}, this.step + Math.floor(Math.random() * this.randomValue))
}
})
},
createDeliveryBill(sn, mallId) {