From 55c408ac6cbcc08ddb80225f8d83af5e0220b370 Mon Sep 17 00:00:00 2001 From: liushiwei <499672082@qq.com> Date: Tue, 15 Aug 2023 11:41:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/view/NormalSendGoods.vue | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/view/NormalSendGoods.vue b/src/view/NormalSendGoods.vue index 98daf77..da95fc4 100644 --- a/src/view/NormalSendGoods.vue +++ b/src/view/NormalSendGoods.vue @@ -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) {