|
@@ -36,8 +36,8 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="btn-box">
|
|
|
- <div class="send-btn" @click="btn" :class="{'stopBtn':stopHandle}">一键发货</div>
|
|
|
<div class="send-btn" @click="nextBtn" :class="{'stopBtn':stopHandle}" v-if="data.length > 1">确认,下一单</div>
|
|
|
+ <div class="send-btn" @click="btn" :class="{'stopBtn':stopHandle}">一键发货</div>
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
@@ -69,6 +69,9 @@ export default class BatchbyOneModal extends Vue {
|
|
|
this.priceObj={};
|
|
|
this.currentPrice={};
|
|
|
this.isSuccess = false;
|
|
|
+ this.stopHandle = false;
|
|
|
+ this.currentOrder = 0;
|
|
|
+ this.checked = false;
|
|
|
}
|
|
|
close(){
|
|
|
if(this.isSuccess){
|
|
@@ -96,9 +99,7 @@ export default class BatchbyOneModal extends Vue {
|
|
|
}
|
|
|
setValue(data:Array<any>){
|
|
|
this.data = [];
|
|
|
- this.stopHandle = false;
|
|
|
- this.currentOrder = 0;
|
|
|
- this.checked = false;
|
|
|
+
|
|
|
if(data && data.length > 0){
|
|
|
for(const item of data){
|
|
|
const requestId = new Date().getTime() + this.getUuid()
|
|
@@ -154,7 +155,11 @@ export default class BatchbyOneModal extends Vue {
|
|
|
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
|
}
|
|
|
btn(){
|
|
|
- this.currentOrder = 0;
|
|
|
+ this.noSentOrder();
|
|
|
+ if(!this.data[this.currentOrder]){
|
|
|
+ this.$message('没有需要发货的订单!')
|
|
|
+ return
|
|
|
+ }
|
|
|
if(this.stopHandle){
|
|
|
this.$message('库存不足!')
|
|
|
return
|
|
@@ -163,7 +168,7 @@ export default class BatchbyOneModal extends Vue {
|
|
|
this.$message('请阅读并同意运单协议!')
|
|
|
return
|
|
|
}
|
|
|
- if(!this.data[0].orderType || !this.data[0].tmsShipmentConsignor){
|
|
|
+ if(!this.data[this.currentOrder].tmsShipmentAddress || !this.data[this.currentOrder].tmsShipmentConsignor || !this.data[this.currentOrder].tmsUnloadingAddress || !this.data[this.currentOrder].tmsUnloadingConsignor){
|
|
|
this.$message("请编辑订单信息");
|
|
|
return
|
|
|
}
|
|
@@ -175,7 +180,7 @@ export default class BatchbyOneModal extends Vue {
|
|
|
|
|
|
let ids='';
|
|
|
for(const item of this.data){
|
|
|
- if(!item.orderType || !item.tmsShipmentConsignor){
|
|
|
+ if(!item.tmsShipmentAddress || !item.tmsShipmentConsignor || !item.tmsUnloadingAddress || !item.tmsUnloadingConsignor){
|
|
|
ids = ids ? ids + ',' + item.omsOrderIds : String(item.omsOrderIds)
|
|
|
}
|
|
|
}
|
|
@@ -186,17 +191,25 @@ export default class BatchbyOneModal extends Vue {
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
this.setOnEditOrderInfo(ids);
|
|
|
- this.sendGoods(this.data[0]);
|
|
|
+ this.sendGoods(this.data[this.currentOrder]);
|
|
|
|
|
|
}).catch(() => {});
|
|
|
}else{
|
|
|
- this.sendGoods(this.data[0]);
|
|
|
+ this.sendGoods(this.data[this.currentOrder]);
|
|
|
}
|
|
|
}else{
|
|
|
+ if(this.data[0].isSuccess){
|
|
|
+ this.$message('订单:'+this.data[0].omsOrderIds+'已执行过发货操作!');
|
|
|
+ return
|
|
|
+ }
|
|
|
this.sendGoods(this.data[0]);
|
|
|
}
|
|
|
}
|
|
|
nextBtn(){
|
|
|
+ if(this.currentOrder >= this.data.length){
|
|
|
+ this.$message('已经是最后一单!')
|
|
|
+ return
|
|
|
+ }
|
|
|
if(this.stopHandle){
|
|
|
this.$message('库存不足!')
|
|
|
return
|
|
@@ -205,18 +218,26 @@ export default class BatchbyOneModal extends Vue {
|
|
|
this.$message('请阅读并同意运单协议!')
|
|
|
return
|
|
|
}
|
|
|
- if(!this.data[this.currentOrder].tmsShipmentAddress || !this.data[this.currentOrder].tmsShipmentConsignor){
|
|
|
+ const _value = this.data[this.currentOrder];
|
|
|
+ if(!_value.tmsShipmentAddress || !_value.tmsShipmentConsignor || !_value.tmsUnloadingAddress || !_value.tmsUnloadingConsignor){
|
|
|
this.$message("请编辑订单信息");
|
|
|
return
|
|
|
}
|
|
|
- if(!this.currentPrice[this.data[this.currentOrder].omsOrderIds]){
|
|
|
+ if(!this.currentPrice[_value.omsOrderIds]){
|
|
|
this.$message('请选择价格!')
|
|
|
return
|
|
|
}
|
|
|
- this.sendGoods(this.data[this.currentOrder],true);
|
|
|
+ if(_value.isSuccess){
|
|
|
+ this.$message('订单:'+_value.omsOrderIds+'已执行过发货操作!');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.sendGoods(_value,true);
|
|
|
}
|
|
|
//查库存
|
|
|
getStoreCount(item:any,callback?:Function){
|
|
|
+ if(!item){
|
|
|
+ return
|
|
|
+ }
|
|
|
let params:any={};
|
|
|
params.storeHouseId = item.storeHouse;
|
|
|
params.skuIds=[]
|
|
@@ -257,8 +278,10 @@ export default class BatchbyOneModal extends Vue {
|
|
|
//发货
|
|
|
sendGoods(item:any,isNext?:boolean){
|
|
|
if(!item){
|
|
|
+ this.$message('订单不存在!')
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
let params:any=(this as any).$lodash.cloneDeep(item);
|
|
|
if(this.priceObj[item.omsOrderIds]){
|
|
|
try{
|
|
@@ -278,20 +301,32 @@ export default class BatchbyOneModal extends Vue {
|
|
|
message:'订单:'+item.omsOrderIds+'发货成功!',
|
|
|
type:'success'
|
|
|
})
|
|
|
- this.currentOrder ++;
|
|
|
-
|
|
|
- if(this.currentOrder < this.data.length){
|
|
|
- if(!isNext){
|
|
|
- let item:any = this.data[this.currentOrder];
|
|
|
- if(this.currentPrice[item.omsOrderIds]){
|
|
|
- this.sendGoods(item);
|
|
|
+ for(let it of this.data){
|
|
|
+ if(it.omsOrderIds == item.omsOrderIds){
|
|
|
+ it.isSuccess=true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!isNext){
|
|
|
+ //寻找未发货的订单
|
|
|
+ this.noSentOrder();
|
|
|
+ let _item:any = this.data[this.currentOrder];
|
|
|
+ //是否是最后一单
|
|
|
+ if(this.currentOrder >= this.data.length){
|
|
|
+ this.drawer = false;
|
|
|
}else{
|
|
|
- this.getStoreCount(item,this.getPriceInfo);
|
|
|
+ if(this.currentPrice[_item.omsOrderIds]){
|
|
|
+ this.sendGoods(_item);
|
|
|
+ }else{
|
|
|
+ this.getStoreCount(_item,this.getPriceInfo);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- this.setInfo();
|
|
|
}else{
|
|
|
- this.drawer=false;
|
|
|
+ if(this.currentOrder < this.data.length - 1) {
|
|
|
+ this.currentOrder ++;
|
|
|
+ this.setInfo();
|
|
|
+ }
|
|
|
}
|
|
|
this.$forceUpdate();
|
|
|
}
|
|
@@ -299,10 +334,23 @@ export default class BatchbyOneModal extends Vue {
|
|
|
this.load = false;
|
|
|
})
|
|
|
}
|
|
|
+ //寻找未发货订单
|
|
|
+ noSentOrder(){
|
|
|
+ this.currentOrder = this.data.length;
|
|
|
+ for(let i = 0; i < this.data.length; i++){
|
|
|
+ if(!this.data[i].isSuccess){
|
|
|
+ this.currentOrder = i;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // if(this.data[this.currentOrder]){
|
|
|
+ this.setInfo();
|
|
|
+ // }
|
|
|
+ }
|
|
|
setOnEditOrderInfo(ids:string){
|
|
|
let _value = this.data[0]
|
|
|
for(const item of this.data){
|
|
|
- if(ids.indexOf(item.omsOrderIds) > -1){
|
|
|
+ if(ids.indexOf(item.omsOrderIds) > -1 && !item.isSuccess){
|
|
|
item.orderType = _value.orderType;
|
|
|
item.storeHouse = _value.storeHouse;
|
|
|
item.tmsArrivalDate = _value.tmsArrivalDate;
|