|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<el-drawer
|
|
|
v-loading="load"
|
|
|
- title="订单发货(批量逐一发货)"
|
|
|
+ :title="data.length <= 1 ? '订单发货' : '订单发货(批量逐一发货)'"
|
|
|
:visible.sync="drawer"
|
|
|
:direction="direction"
|
|
|
size="50%">
|
|
@@ -16,22 +16,23 @@
|
|
|
</el-pagination>
|
|
|
</div>
|
|
|
<deliveryGoodsInfo @editState="editState" @editResult="editResult" ref="info" />
|
|
|
- <deliveryPrice :data="priceObj[data[currentOrder].omsOrderIds]" v-if="data[currentOrder] && priceObj[data[currentOrder].omsOrderIds]" @prichChange="prichChange" />
|
|
|
+ <deliveryPrice :data="priceObj[data[currentOrder].omsOrderIds]" ref="price" v-if="data[currentOrder] && priceObj[data[currentOrder].omsOrderIds]"
|
|
|
+ @prichChange="prichChange" :currentValue="currentPrice[data[currentOrder].omsOrderIds]" />
|
|
|
</div>
|
|
|
<div class="space"></div>
|
|
|
<div class="deli-footer">
|
|
|
<div class="d-left">
|
|
|
<div class="estimate-total">
|
|
|
- 订单小计<span class="total">¥16.00</span> <span class="detail">明细></span>
|
|
|
+ 订单小计<span class="total">¥{{data[currentOrder] && currentPrice[data[currentOrder].omsOrderIds]?currentPrice[data[currentOrder].omsOrderIds].estimateFreight:'0.00'}}</span> <span class="detail">明细></span>
|
|
|
</div>
|
|
|
- <div class="estimate-total">
|
|
|
+ <!-- <div class="estimate-total">
|
|
|
预计总价<span class="total">¥48.00</span>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
<div class="agreement">
|
|
|
<el-checkbox v-model="checked">已读并同意《XXX电子运单协议》</el-checkbox>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="send-btn" @click="btn">确认,下一单</div>
|
|
|
+ <div class="send-btn" @click="btn" :class="{'stopBtn':stopHandle}">确认</div>
|
|
|
</div>
|
|
|
</el-drawer>
|
|
|
</template>
|
|
@@ -41,7 +42,7 @@ import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
import DeliveryGoodsInfo from "./deliveryGoodsInfo.vue";
|
|
|
import DeliveryPrice from "./deliveryPrice.vue";
|
|
|
import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
|
|
|
-import { queryPricePackage,addmultiple } from '@/api/delivery'
|
|
|
+import { queryPricePackage,addmultiple,getInventoryByStoreHouseIdAndSkuids } from '@/api/delivery'
|
|
|
import Format from '@/benyun/utils/dateFormat'
|
|
|
|
|
|
@Component({components:{DeliveryGoodsInfo,DeliveryPrice}})
|
|
@@ -51,6 +52,7 @@ export default class BatchbyOneModal extends Vue {
|
|
|
checked=false;
|
|
|
data:Array<any>=[];
|
|
|
currentOrder=0;
|
|
|
+ stopHandle=false;
|
|
|
load = false;
|
|
|
priceObj:any={};
|
|
|
currentPrice:any={};
|
|
@@ -59,19 +61,25 @@ export default class BatchbyOneModal extends Vue {
|
|
|
}
|
|
|
editResult(v:any){
|
|
|
this.data[this.currentOrder] = v;
|
|
|
+ this.getStoreCount(v);
|
|
|
this.getPriceInfo(v);
|
|
|
}
|
|
|
prichChange(index:number){
|
|
|
this.currentPrice[this.data[this.currentOrder].omsOrderIds] = this.priceObj[this.data[this.currentOrder].omsOrderIds][index];
|
|
|
+ this.$forceUpdate();
|
|
|
}
|
|
|
currentChange(v:number){
|
|
|
this.currentOrder = v-1;
|
|
|
+ this.$forceUpdate();
|
|
|
this.$nextTick(()=>{
|
|
|
(this.$refs.info as any).setValue(this.data[this.currentOrder]);
|
|
|
})
|
|
|
}
|
|
|
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()
|
|
@@ -102,7 +110,8 @@ export default class BatchbyOneModal extends Vue {
|
|
|
obj.subItem.push({
|
|
|
requestId:requestId,
|
|
|
omsOrderId:item.id,
|
|
|
- omsOrderItemId:i.id,
|
|
|
+ omsOrderItemId:i.itemId,
|
|
|
+ // omsOrderItemSkuId:i.itemId,
|
|
|
tmsGoodsModel:i.styleId,
|
|
|
tmsGoodsCode:i.skuId,
|
|
|
tmsQuantity:i.qty,
|
|
@@ -126,15 +135,27 @@ export default class BatchbyOneModal extends Vue {
|
|
|
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
|
}
|
|
|
btn(){
|
|
|
+ if(this.stopHandle){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(!this.checked){
|
|
|
+ this.$message('请阅读并同意运单协议!')
|
|
|
+ return
|
|
|
+ }
|
|
|
if(!this.data[0].orderType || !this.data[0].tmsShipmentConsignor){
|
|
|
this.$message("请编辑订单信息");
|
|
|
return
|
|
|
}
|
|
|
+ if(!this.currentPrice[this.data[this.currentOrder].omsOrderIds]){
|
|
|
+ this.$message("请选择价格!");
|
|
|
+ return
|
|
|
+ }
|
|
|
if(this.data.length > 1){
|
|
|
+ this.currentOrder = 0;
|
|
|
let ids='';
|
|
|
for(const item of this.data){
|
|
|
if(!item.orderType || !item.tmsShipmentConsignor){
|
|
|
- ids = ids ? ids + ',' + item.omsOrderIds : item.omsOrderIds
|
|
|
+ ids = ids ? ids + ',' + item.omsOrderIds : String(item.omsOrderIds)
|
|
|
}
|
|
|
}
|
|
|
if(ids){
|
|
@@ -144,19 +165,62 @@ export default class BatchbyOneModal extends Vue {
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
this.setOnEditOrderInfo(ids);
|
|
|
- for(const item of this.data){
|
|
|
- this.sendGoods(item);
|
|
|
- }
|
|
|
+ this.sendGoods(this.data[0]);
|
|
|
+ // let i = 0;
|
|
|
+ // for(const item of this.data){
|
|
|
+ // if(i == 0){
|
|
|
+ // this.sendGoods(item);
|
|
|
+ // }else{
|
|
|
+ // this.getStoreCount(item,this.getPriceInfo);
|
|
|
+ // }
|
|
|
+ // i++;
|
|
|
+ // }
|
|
|
}).catch(() => {});
|
|
|
}else{
|
|
|
- for(const item of this.data){
|
|
|
- this.sendGoods(item);
|
|
|
- }
|
|
|
+ this.sendGoods(this.data[0]);
|
|
|
+ // for(const item of this.data){
|
|
|
+ // this.sendGoods(item);
|
|
|
+ // }
|
|
|
}
|
|
|
}else{
|
|
|
this.sendGoods(this.data[0]);
|
|
|
}
|
|
|
}
|
|
|
+ //查库存
|
|
|
+ getStoreCount(item:any,callback?:Function){
|
|
|
+ let params:any={};
|
|
|
+ params.storeHouseId = item.storeHouse;
|
|
|
+ params.skuIds=[]
|
|
|
+ if(item.subItem){
|
|
|
+ for(const i of item.subItem){
|
|
|
+ params.skuIds.push(i.omsOrderItemId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.load = true;
|
|
|
+ getInventoryByStoreHouseIdAndSkuids(params).then((res:any) => {
|
|
|
+ this.load = false;
|
|
|
+ let m='';
|
|
|
+ for(const i of item.subItem){
|
|
|
+ for(const d of res.data){
|
|
|
+ if(i.omsOrderItemId == d.skuid && d.inventory <=0){
|
|
|
+ m = m ? m + ',' + i.name : i.name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(m){
|
|
|
+ this.$message({
|
|
|
+ message:'商品“'+m+'”库存不足!',
|
|
|
+ type:'error'
|
|
|
+ })
|
|
|
+ this.stopHandle = true;
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(callback) callback(item,this.sendGoods)
|
|
|
+ }).catch(()=>{
|
|
|
+ this.load = false;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //发货
|
|
|
sendGoods(item:any){
|
|
|
let params:any=(this as any).$lodash.cloneDeep(item);
|
|
|
if(this.priceObj[item.omsOrderIds]){
|
|
@@ -168,10 +232,24 @@ export default class BatchbyOneModal extends Vue {
|
|
|
params.priceId = this.currentPrice[item.omsOrderIds].id;
|
|
|
}
|
|
|
params.omsOrderIds = [item.omsOrderIds];
|
|
|
+ this.load = true;
|
|
|
addmultiple(params).then((res:any) => {
|
|
|
-
|
|
|
- }).catch((err:any) => {
|
|
|
-
|
|
|
+ this.load = false;
|
|
|
+ if(res.code == 200){
|
|
|
+ this.currentOrder ++;
|
|
|
+ if(this.currentOrder < this.data.length){
|
|
|
+ let item:any = this.data[this.currentOrder];
|
|
|
+ if(this.currentPrice[item.omsOrderIds]){
|
|
|
+ this.sendGoods(item);
|
|
|
+ }else{
|
|
|
+ this.getStoreCount(item,this.getPriceInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$forceUpdate();
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+
|
|
|
+ this.load = false;
|
|
|
})
|
|
|
}
|
|
|
setOnEditOrderInfo(ids:string){
|
|
@@ -179,6 +257,9 @@ export default class BatchbyOneModal extends Vue {
|
|
|
for(const item of this.data){
|
|
|
if(ids.indexOf(item.omsOrderIds) > -1){
|
|
|
item.orderType = _value.orderType;
|
|
|
+ item.storeHouse = _value.storeHouse;
|
|
|
+ item.tmsArrivalDate = _value.tmsArrivalDate;
|
|
|
+ item.tmsDeliveryDate =_value.tmsDeliveryDate;
|
|
|
item.tmsTransportMethod = _value.tmsTransportMethod;
|
|
|
item.tmsBusinessMan = _value.tmsBusinessMan;
|
|
|
item.tmsBusinessPhone = _value.tmsBusinessPhone;
|
|
@@ -207,6 +288,7 @@ export default class BatchbyOneModal extends Vue {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //获取价格
|
|
|
getPriceInfo(data:any,callback?:Function){
|
|
|
let params:any={};
|
|
|
params.startAddressCode = data.tmsShipmentCityNo + '000';
|
|
@@ -214,18 +296,25 @@ export default class BatchbyOneModal extends Vue {
|
|
|
params.omsIds=[this.data[0].omsOrderIds];
|
|
|
this.load = true;
|
|
|
queryPricePackage(params).then((res:any) => {
|
|
|
- if(this.currentPrice && this.currentPrice[data.omsOrderIds]){
|
|
|
- delete this.currentPrice[data.omsOrderIds]
|
|
|
- }
|
|
|
+ // if(this.currentPrice && this.currentPrice[data.omsOrderIds]){
|
|
|
+ // delete this.currentPrice[data.omsOrderIds]
|
|
|
+ // }
|
|
|
|
|
|
this.load=false;
|
|
|
+ let current=null;
|
|
|
for(let item of res.data[0].data){
|
|
|
let d = new Date().getTime() + item.duration*60*60*1000;
|
|
|
- item.endTime=Format(new Date(d),'MM月dd日 HH:mm')
|
|
|
+ item.endTime=Format(new Date(d),'MM月dd日 HH:mm');
|
|
|
+ if(!current) current = item;
|
|
|
+ if(Number(current.estimateFreight) > Number(item.estimateFreight)){
|
|
|
+ current = item
|
|
|
+ }
|
|
|
}
|
|
|
this.priceObj[data.omsOrderIds] = res.data[0].data;
|
|
|
+ this.currentPrice[data.omsOrderIds] = current;
|
|
|
+ this.$forceUpdate();
|
|
|
if(callback){
|
|
|
- callback()
|
|
|
+ callback(data)
|
|
|
}
|
|
|
}).catch((err:any)=>{
|
|
|
this.load = false;
|
|
@@ -289,6 +378,9 @@ export default class BatchbyOneModal extends Vue {
|
|
|
box-shadow: 0px 2px 6px 0px rgba(93, 167, 249, 100);
|
|
|
cursor: pointer;
|
|
|
}
|
|
|
+ .stopBtn{
|
|
|
+ opacity: 0.7;
|
|
|
+ }
|
|
|
}
|
|
|
.space{
|
|
|
height: 80px;
|