Browse Source

工单7,8

逆水行舟 2 months ago
parent
commit
080b4328d7

+ 103 - 121
src/benyun/components/byForm/byForm.vue

@@ -1,50 +1,30 @@
 <template>
-  <div class="by-form" :style="{width:attrs.width}">
-    <el-descriptions v-if="attrs.showType=='desc'" :title="attrs.title" :column="attrs.itemCount" :border="attrs.border" :direction="attrs.direction" 
-    :size="attrs.size?attrs.size:'medium'" :colon="attrs.colon" contentClassName="clas123">
-      <template v-for="(itemChild,index) of columns">
-        <el-descriptions-item :label="item.label" v-for="(item,_ind) of itemChild" :span="item.colspan" :key="index+'-'+_ind">
-          <slot v-if="item.descSlot" :name='item.prop+"_desc"' :value='value'></slot>
-          <template v-else>{{value[item.prop]?value[item.prop]:'--'}}</template>
+  <div class="by-form" :style="{ width: attrs.width }">
+    <el-descriptions v-if="attrs.showType == 'desc'" :title="attrs.title" :column="attrs.itemCount" :border="attrs.border"
+      :direction="attrs.direction" :size="attrs.size ? attrs.size : 'medium'" :colon="attrs.colon"
+      contentClassName="clas123">
+      <template v-for="(itemChild, index) of columns">
+        <el-descriptions-item :label="item.label" v-for="(item, _ind) of itemChild" :span="item.colspan"
+          :key="index + '-' + _ind">
+          <slot v-if="item.descSlot" :name='item.prop + "_desc"' :value='value'></slot>
+          <template v-else>{{ value[item.prop] ? value[item.prop] : '--' }}</template>
         </el-descriptions-item>
       </template>
     </el-descriptions>
-    <el-form class="byForm" 
-    v-else
-    :style="{ height: attrs.height ? attrs.height + 'px' : 'auto' }" 
-    :model="value" 
-    ref="byForm" 
-    :validate-on-rule-change="false" 
-    :size="attrs.size ? attrs.size : 'small'" 
-    :inline-message="true" 
-    v-bind="$attrs" 
-    :disabled="attrs.disabled"
-    :label-width="attrs.labelWidth?attrs.labelWidth:'100px'"
-    :rules="attrs.readonly?{}:attrs.rules"
-    :label-position="attrs.labelPosition ? attrs.labelPosition : ''">
-      <el-row class="form-row" v-for="(itemChild,index) of columns" :key="index">
-        <el-col v-for="(item,_ind) of itemChild" :span="item.span" :key="'itemChild'+_ind">
-          <el-form-item class="by-form-item" 
-            :label="item.label" 
-            :rules="attrs.readonly?[]:item.rules" 
-            :prop="item.prop" 
-            :required="item.required"
-            :error="item.error"
-            :size="item.size"
-            :label-width="item.labelWidth">
-            <component v-bind:is="item.component" 
-              class="form-comp"
-              :propConfig="item.compConfig" 
-              :ref="item.prop+suffixCode" 
-              :parentValue="value"
-              :propValue="value[item.prop]" 
-              @onChange="onChange($event,item)" 
-              v-bind="$attrs" 
-              v-on="$listeners" 
-              />
-              <slot v-if="item.slot" :name='item.prop' :value='value'></slot>
-              <!-- <slot :[item.prop]="value" ></slot> -->
-              <div class="readonly-cover" v-if="attrs.readonly"></div>
+    <el-form class="byForm" v-else :style="{ height: attrs.height ? attrs.height + 'px' : 'auto' }" :model="value"
+      ref="byForm" :validate-on-rule-change="false" :size="attrs.size ? attrs.size : 'small'" :inline-message="true"
+      v-bind="$attrs" :disabled="attrs.disabled" :label-width="attrs.labelWidth ? attrs.labelWidth : '100px'"
+      :rules="attrs.readonly ? {} : attrs.rules" :label-position="attrs.labelPosition ? attrs.labelPosition : ''">
+      <el-row class="form-row" v-for="(itemChild, index) of columns" :key="index">
+        <el-col v-for="(item, _ind) of itemChild" :span="item.span" :key="'itemChild' + _ind">
+          <el-form-item class="by-form-item" :label="item.label" :rules="attrs.readonly ? [] : item.rules" :prop="item.prop"
+            :required="item.required" :error="item.error" :size="item.size" :label-width="item.labelWidth">
+            <component v-bind:is="item.component" class="form-comp" :propConfig="item.compConfig"
+              :ref="item.prop + suffixCode" :parentValue="value" :propValue="value[item.prop]"
+              @onChange="onChange($event, item)" v-bind="$attrs" v-on="$listeners" />
+            <slot v-if="item.slot" :name='item.prop' :value='value'></slot>
+            <!-- <slot :[item.prop]="value" ></slot> -->
+            <div class="readonly-cover" v-if="attrs.readonly"></div>
           </el-form-item>
         </el-col>
       </el-row>
@@ -98,90 +78,90 @@ import { Component, Prop, Vue, Watch } from "vue-property-decorator";
 import VueViews from '@/benyun/compVue/VueViews'
 @Component
 export default class ByForm extends VueViews {
-  value:any={}
-  suffixCode="--comp"
-  get columns(){
-    let columns:Array<any> = this.config?.columns ? this.config.columns : []
-      //分栏设置
-    if(columns.length > 0){
+  value: any = {}
+  suffixCode = "--comp"
+  get columns() {
+    let columns: Array<any> = this.config?.columns ? this.config.columns : []
+    //分栏设置
+    if (columns.length > 0) {
       for (const itemChild of columns) {
         let spans = 24
         let n = itemChild.length
-        for(const item of itemChild){
+        for (const item of itemChild) {
           if (item && ((Number(item.span) > 0 && Number(item.span) <= 24))) {
             spans = spans - Number(item.span)
             n--;
           }
         }
 
-        for(const item of itemChild){
+        for (const item of itemChild) {
           if (Number(item.span) > 0 && Number(item.span) <= 24) {
             item.span = Number(item.span)
           } else {
             item.span = spans / n
           }
         }
-        
+
       }
     }
     return columns
   }
 
-  created(){
-    if(this.propConfig){
+  created() {
+    if (this.propConfig) {
       this.setConfig(this.propConfig)
     }
   }
-  mounted(){
-    if(this.attrs.data){
+  mounted() {
+    if (this.attrs.data) {
       this.setValue(this.attrs.data);
     }
   }
-  getValueData(){
-    console.log('表单数据',this.value)
+  getValueData() {
+    console.log('表单数据', this.value)
   }
   //设置数据
-  setValue(data:any){
-    if(data){
+  setValue(data: any) {
+    if (data) {
       this.value = (this as any).$lodash.cloneDeep(data);
-    }else{
+    } else {
       this.value = {};
     }
-    this.$nextTick(()=>{
+    this.$nextTick(() => {
       this.setChildrenComValue();
     })
-    setTimeout(()=>{
+    setTimeout(() => {
       this.clearValidate();
-    },100)
+    }, 100)
     this.$forceUpdate();
   }
 
-  clearValue(){
+  clearValue() {
     this.value = {};
     this.clearChildrenComp();
     this.defaultHandle();
-    setTimeout(()=>{
+    setTimeout(() => {
       this.clearValidate();
-    },100)
+    }, 100)
   }
 
   //获取数据
-  getValue(){
+  getValue() {
     return (this as any).$lodash.cloneDeep(this.value);
   }
   //设置表单内某组件配置
-  setCompConfig(code:any,c:any){
-    if(this.$refs[code+this.suffixCode] && (this.$refs[code+this.suffixCode] as any)[0] && (this.$refs[code+this.suffixCode] as any)[0].setConfig){
-      (this.$refs[code+this.suffixCode] as any)[0].setConfig(c)
+  setCompConfig(code: any, c: any) {
+    if (this.$refs[code + this.suffixCode] && (this.$refs[code + this.suffixCode] as any)[0] && (this.$refs[code + this.suffixCode] as any)[0].setConfig) {
+      (this.$refs[code + this.suffixCode] as any)[0].setConfig(c)
     }
   }
-  setConfigAfter(){
-    this.$nextTick(()=>{
-      if(this.columns.length > 0){
-        for(const itemData of this.columns){
-          for(const item of itemData){
-            if(this.$refs[item.prop+this.suffixCode] && (this.$refs[item.prop+this.suffixCode] as any)[0] && (this.$refs[item.prop+this.suffixCode] as any)[0].setConfig){
-              (this.$refs[item.prop+this.suffixCode] as any)[0].setConfig(item.compConfig)
+  setConfigAfter() {
+    this.$nextTick(() => {
+      if (this.columns.length > 0) {
+        for (const itemData of this.columns) {
+          for (const item of itemData) {
+            if (this.$refs[item.prop + this.suffixCode] && (this.$refs[item.prop + this.suffixCode] as any)[0] && (this.$refs[item.prop + this.suffixCode] as any)[0].setConfig) {
+              (this.$refs[item.prop + this.suffixCode] as any)[0].setConfig(item.compConfig)
             }
           }
         }
@@ -190,30 +170,30 @@ export default class ByForm extends VueViews {
   }
 
   //清除下级组件组件值
-  clearChildrenComp(){
-    for(const key in this.$refs){
-      if(key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key][0] && (this as any).$refs[key][0].clearValue){
+  clearChildrenComp() {
+    for (const key in this.$refs) {
+      if (key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key][0] && (this as any).$refs[key][0].clearValue) {
         (this as any).$refs[key][0].clearValue()
       }
     }
   }
   //下级组件默认值
-  defaultHandle(){
-    for(const key in this.$refs){
-      if(key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key][0] && (this as any).$refs[key][0].defaultHandle){
+  defaultHandle() {
+    for (const key in this.$refs) {
+      if (key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key][0] && (this as any).$refs[key][0].defaultHandle) {
         (this as any).$refs[key][0].defaultHandle()
       }
     }
   }
 
   //设置下级组件值
-  setChildrenComValue(){
-    for(const key in (this as any).$refs){
-      if(key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key] && (this as any).$refs[key][0] && (this as any).$refs[key][0].setValue){
+  setChildrenComValue() {
+    for (const key in (this as any).$refs) {
+      if (key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key] && (this as any).$refs[key][0] && (this as any).$refs[key][0].setValue) {
         const code = key.split(this.suffixCode)[0];
-        if(this.value){
+        if (this.value) {
           (this as any).$refs[key][0].setValue(this.value[code])
-        }else{
+        } else {
           (this as any).$refs[key][0].setValue(null)
         }
       }
@@ -221,36 +201,36 @@ export default class ByForm extends VueViews {
   }
 
   //表单数据变化
-  onChange(v:any,config:any){
+  onChange(v: any, config: any) {
     let code = config.prop;
-    if (v && (v as any).constructor === Object){
-      for(const key in v){
-        this.changeSetValue(key,v[key])
+    if (v && (v as any).constructor === Object) {
+      for (const key in v) {
+        this.changeSetValue(key, v[key])
       }
-    }else{
-      this.changeSetValue(code,v)
+    } else {
+      this.changeSetValue(code, v)
     }
-    if((this as any).$refs.byForm){
+    if ((this as any).$refs.byForm) {
       (this as any).$refs.byForm.validateField(code);
     }
-    this.$emit('formChange',{value:v,code:code})
+    this.$emit('formChange', { value: v, code: code })
   }
-  
-  changeSetValue(code:string,v:any){
-    if(this.value[code]){
+
+  changeSetValue(code: string, v: any) {
+    if (this.value[code]) {
       this.value[code] = v;
-    }else{
+    } else {
       Vue.set(this.value, code, v);
     }
   }
   //表单验证
-  validate(parames?:any):Promise<any>{
-    return new Promise((resolve:Function, reject:Function) => {
-      if(!this.$refs.byForm){
+  validate(parames?: any): Promise<any> {
+    return new Promise((resolve: Function, reject: Function) => {
+      if (!this.$refs.byForm) {
         resolve(true)
       }
       const failHandel = () => {
-        if(!parames || !parames.noMsg){
+        if (!parames || !parames.noMsg) {
           (this as any).$message({
             message: '验证未通过,请检查!',
             type: 'warning',
@@ -258,24 +238,24 @@ export default class ByForm extends VueViews {
         }
         reject()
       }
-      (this as any).$refs.byForm.validate((valid:any) => {
+      (this as any).$refs.byForm.validate((valid: any) => {
         if (valid) {
           let va = true
-          for(const col of this.columns){
-            for(const item of col){
-              if(this.$refs[item.prop+this.suffixCode] && (this.$refs[item.prop+this.suffixCode] as any)[0] && (this.$refs[item.prop+this.suffixCode] as any)[0].validate){
-                va = (this.$refs[item.prop+this.suffixCode] as any)[0].validate()
-                if(!va) break
+          for (const col of this.columns) {
+            for (const item of col) {
+              if (this.$refs[item.prop + this.suffixCode] && (this.$refs[item.prop + this.suffixCode] as any)[0] && (this.$refs[item.prop + this.suffixCode] as any)[0].validate) {
+                va = (this.$refs[item.prop + this.suffixCode] as any)[0].validate()
+                if (!va) break
               }
             }
-            if(!va) break
+            if (!va) break
           }
-          if(va){
+          if (va) {
             resolve(true)
-          }else{
+          } else {
             failHandel()
           }
-          
+
         } else {
           failHandel()
         }
@@ -283,8 +263,8 @@ export default class ByForm extends VueViews {
     })
   }
   //清除过滤提示
-  clearValidate(){
-    if(this.$refs.byForm){
+  clearValidate() {
+    if (this.$refs.byForm) {
       (this.$refs.byForm as any).clearValidate();
     }
   }
@@ -292,13 +272,15 @@ export default class ByForm extends VueViews {
 </script>
 
 <style lang="scss" scoped>
-.by-form{
+.by-form {
   width: 100%;
   margin: 0 auto;
-  .form-comp{
+
+  .form-comp {
     width: 100%;
   }
-  .readonly-cover{
+
+  .readonly-cover {
     position: absolute;
     height: 100%;
     width: 100%;
@@ -309,7 +291,7 @@ export default class ByForm extends VueViews {
 </style>
 
 <style lang="scss">
-.by-form-item{
+.by-form-item {
   margin-bottom: 10px !important;
 }
 </style>

+ 155 - 155
src/views/audit/store/components/batchbyOneModal.vue

@@ -1,23 +1,13 @@
 <template>
-  <el-drawer
-    v-loading="load"
-    title="短驳生成单"
-    :visible.sync="drawer"
-    @close="close"
-    :direction="direction"
-    size="50%">
+  <el-drawer v-loading="load" title="短驳生成单" :visible.sync="drawer" @close="close" :direction="direction" size="50%">
     <div class="content">
       <div class="order-top" v-if="data.length > 1">
-        <el-pagination
-          background
-          :page-size="1"
-          :current-page="currentOrder + 1"
-          layout="prev, pager, next"
-          @current-change="currentChange"
-          :total="data.length">
+        <el-pagination background :page-size="1" :current-page="currentOrder + 1" layout="prev, pager, next"
+          @current-change="currentChange" :total="data.length">
         </el-pagination>
       </div>
-      <deliveryGoodsInfo :hideOrderCode="true" @editState="editState" @editResult="editResult" @qtyChange="qtyChange" ref="info" />
+      <deliveryGoodsInfo :hideOrderCode="true" @editState="editState" @editResult="editResult" @qtyChange="qtyChange"
+        ref="info" />
       <!-- <deliveryPrice :data="priceObj[data[currentOrder].omsOrderIds]" ref="price" v-if="data[currentOrder] && priceObj[data[currentOrder].omsOrderIds]" 
       @prichChange="prichChange" :currentValue="currentPrice[data[currentOrder].omsOrderIds]" /> -->
     </div>
@@ -34,7 +24,7 @@
       <div class="btn-box">
         <div class="send-btn" @click="btn">提交</div>
       </div>
-      
+
     </div>
   </el-drawer>
 </template>
@@ -43,96 +33,96 @@
 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 { getShortBargePrice,WMSAddEntryOrder,getInventoryByStoreHouseIdAndSkuids } from  '@/api/delivery'
+import { add, multiply, subtract, divide } from '@/benyun/utils/accuracy'
+import { getShortBargePrice, WMSAddEntryOrder, getInventoryByStoreHouseIdAndSkuids } from '@/api/delivery'
 import Format from '@/benyun/utils/dateFormat'
 
-@Component({components:{DeliveryGoodsInfo,DeliveryPrice}})
+@Component({ components: { DeliveryGoodsInfo, DeliveryPrice } })
 export default class BatchbyOneModal extends Vue {
-  drawer=false;
-  direction='rtl'
-  checked=false;
-  data:Array<any>=[];
-  currentOrder=0;
-  isSuccess=false;
-  stopHandle=false;
+  drawer = false;
+  direction = 'rtl'
+  checked = false;
+  data: Array<any> = [];
+  currentOrder = 0;
+  isSuccess = false;
+  stopHandle = false;
   load = false;
-  priceObj:any={};
-  currentPrice:any={};
-  setShow(v:boolean){
-    this.drawer=v;
-    this.priceObj={};
-    this.currentPrice={};
+  priceObj: any = {};
+  currentPrice: any = {};
+  setShow(v: boolean) {
+    this.drawer = v;
+    this.priceObj = {};
+    this.currentPrice = {};
     this.isSuccess = false;
     this.stopHandle = false;
     this.currentOrder = 0;
     this.checked = false;
   }
-  close(){
-    if(this.isSuccess){
+  close() {
+    if (this.isSuccess) {
       this.$emit('handleSuccess');
     }
   }
-  editResult(v:any){
+  editResult(v: any) {
     this.data[this.currentOrder] = v;
     this.getStoreCount(v);
     // this.getPriceInfo(v);
   }
-  prichChange(index:number){
+  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;
+  currentChange(v: number) {
+    this.currentOrder = v - 1;
     this.$forceUpdate();
-    this.$nextTick(()=>{
+    this.$nextTick(() => {
       this.setInfo();
     })
   }
-  setInfo(){
+  setInfo() {
     (this.$refs.info as any).setValue(this.data[this.currentOrder]);
   }
-  setValue(data:Array<any>){
+  setValue(data: Array<any>) {
     this.data = [];
-    const requestId =  new Date().getTime() + this.getUuid()
-    let obj:any={
+    const requestId = new Date().getTime() + this.getUuid()
+    let obj: any = {
       // tmsBusinessMan: (this as any).$store.getters.userInfo.userName,
       // tmsBusinessPhone: (this as any).$store.getters.userInfo.phonenumber,
-      requestId:requestId
+      requestId: requestId
     };
-    obj.subItem=[];
-    for(const item of data){
+    obj.subItem = [];
+    for (const item of data) {
       obj.subItem.push({
-        requestId:requestId,
-        barCode:item.barCode,
+        requestId: requestId,
+        barCode: item.barCode,
         omsOrderItemId: item.id,
-        tmsGoodsModel:item.itemNumber,
-        tmsGoodsCode:item.skuCode,
-        tmsQuantity:1,
-        tmsGoodsTotalPrice:item.price,
-        name:item.skuTitle,
-        price:item.price,
-        weight:item.weight
+        tmsGoodsModel: item.itemNumber,
+        tmsGoodsCode: item.skuCode,
+        tmsQuantity: 1,
+        tmsGoodsTotalPrice: item.price,
+        name: item.skuTitle,
+        price: item.price,
+        weight: item.weight
       })
     }
-   
+
     this.data.push(obj)
 
-    
-    this.$nextTick(()=>{
+
+    this.$nextTick(() => {
       (this.$refs.info as any).setValue(this.data[this.currentOrder])
     })
   }
-  getUuid(){
+  getUuid() {
     return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
   }
-  btn(){
+  btn() {
     // this.noSentOrder();
-    if(!this.data[this.currentOrder]){
+    if (!this.data[this.currentOrder]) {
       this.$message('没有需要发货的订单!')
       return
     }
-    if(this.stopHandle){
+    if (this.stopHandle) {
       this.$message('库存不足!')
       return
     }
@@ -140,7 +130,7 @@ export default class BatchbyOneModal extends Vue {
     //   this.$message('请阅读并同意运单协议!')
     //   return
     // }
-    if(!this.data[this.currentOrder].tmsShipmentConsignor || !this.data[this.currentOrder].tmsUnloadingConsignor || !this.data[this.currentOrder].out_storeHouseId){
+    if (!this.data[this.currentOrder].tmsShipmentConsignor || !this.data[this.currentOrder].tmsUnloadingConsignor || !this.data[this.currentOrder].out_storeHouseId) {
       this.$message("请编辑订单信息");
       return
     }
@@ -150,8 +140,8 @@ export default class BatchbyOneModal extends Vue {
     // }
     this.sendGoods(this.data[0]);
   }
-  nextBtn(){
-    if(this.stopHandle){
+  nextBtn() {
+    if (this.stopHandle) {
       this.$message('库存不足!')
       return
     }
@@ -160,7 +150,7 @@ export default class BatchbyOneModal extends Vue {
     //   return
     // }
     const _value = this.data[this.currentOrder];
-    if(!_value.tmsShipmentAddress || !_value.tmsShipmentConsignor || !_value.tmsUnloadingAddress || !_value.tmsUnloadingConsignor){
+    if (!_value.tmsShipmentAddress || !_value.tmsShipmentConsignor || !_value.tmsUnloadingAddress || !_value.tmsUnloadingConsignor) {
       this.$message("请编辑订单信息");
       return
     }
@@ -168,72 +158,72 @@ export default class BatchbyOneModal extends Vue {
     //   this.$message('请选择价格!')
     //   return
     // }
-    if(_value.isSuccess){
-      this.$message('订单:'+_value.omsOrderIds+'已执行过发货操作!');
+    if (_value.isSuccess) {
+      this.$message('订单:' + _value.omsOrderIds + '已执行过发货操作!');
       return
     }
-    this.sendGoods(_value,true);
+    this.sendGoods(_value, true);
   }
-  qtyChange(v:any){
+  qtyChange(v: any) {
     this.data[this.currentOrder] = v;
     this.getStoreCount(v);
     // this.getPriceInfo(v);
   }
   //查库存
-  getStoreCount(item:any,callback?:Function){
-    if(!item){
+  getStoreCount(item: any, callback?: Function) {
+    if (!item) {
       return
     }
-    if(!item.out_storeHouseId || item.subItem.length == 0){
+    if (!item.out_storeHouseId || item.subItem.length == 0) {
       return
     }
-    let params:any={};
+    let params: any = {};
     params.storeHouseId = item.out_storeHouseId;
-    params.skuIds=[];
-    if(item.subItem){
-      for(const i of item.subItem){
-        if(params.skuIds.indexOf(i.omsOrderItemId) == -1){
+    params.skuIds = [];
+    if (item.subItem) {
+      for (const i of item.subItem) {
+        if (params.skuIds.indexOf(i.omsOrderItemId) == -1) {
           params.skuIds.push(i.omsOrderItemId);
         }
       }
     }
     this.load = true;
-    getInventoryByStoreHouseIdAndSkuids(params).then((res:any) => {
+    getInventoryByStoreHouseIdAndSkuids(params).then((res: any) => {
       this.load = false;
-      let m='';
-      for(const i of item.subItem){
-        for(const d of res.data){
+      let m = '';
+      for (const i of item.subItem) {
+        for (const d of res.data) {
           let s = Number(d.inventory) - Number(d.useInventory) - Number(i.tmsQuantity);
-          if(i.omsOrderItemId == d.skuid && s < 0){
-            m = m ? m + ',' + i.name : i.name;          
-          }else{
+          if (i.omsOrderItemId == d.skuid && s < 0) {
+            m = m ? m + ',' + i.name : i.name;
+          } else {
             d.inventory = subtract(d.inventory, i.tmsQuantity);
           }
         }
       }
-      if(m){
+      if (m) {
         this.$message({
-          message:'商品“'+m+'”库存不足!',
-          type:'error'
+          message: '商品“' + m + '”库存不足!',
+          type: 'error'
         })
         this.stopHandle = true;
         return
-      }else{
-		  this.stopHandle = false
-	  }
-      if(callback) callback(item,this.sendGoods)
-    }).catch(()=>{
+      } else {
+        this.stopHandle = false
+      }
+      if (callback) callback(item, this.sendGoods)
+    }).catch(() => {
       this.load = false;
     })
   }
   //发货
-  sendGoods(item:any,isNext?:boolean){
-    if(!item){
+  sendGoods(item: any, isNext?: boolean) {
+    if (!item) {
       this.$message('信息不存在!')
       return
     }
-    
-    let params:any=(this as any).$lodash.cloneDeep(item);
+
+    let params: any = (this as any).$lodash.cloneDeep(item);
     // if(this.priceObj[item.omsOrderIds]){
     //   try{
     //     params.pricePlan = JSON.stringify(this.priceObj[item.omsOrderIds])
@@ -242,42 +232,42 @@ export default class BatchbyOneModal extends Vue {
     // if(this.currentPrice[item.omsOrderIds]){
     //   params.priceId = this.currentPrice[item.omsOrderIds].id;
     // }
-    params.tmsMaterials=[];
-    if(item.subItem){
-      let skuIds:Array<any>=[];
-      for(const i of item.subItem){
+    params.tmsMaterials = [];
+    if (item.subItem) {
+      let skuIds: Array<any> = [];
+      for (const i of item.subItem) {
         let ind = skuIds.indexOf(item.omsOrderItemId)
-        if(ind == -1){
+        if (ind == -1) {
           skuIds.push(item.omsOrderItemId);
           params.tmsMaterials.push({
-            qty:i.tmsQuantity,
-            materialSkuId:i.omsOrderItemId,
-            storeHouseId:item.out_storeHouseId,
-            storingLocationId:item.entry_storeHouseId
+            qty: i.tmsQuantity,
+            materialSkuId: i.omsOrderItemId,
+            storeHouseId: item.out_storeHouseId,
+            storingLocationId: item.entry_storeHouseId
           })
-        }else{
-          for(let paramsItem of params.tmsMaterials){
-            if(paramsItem.materialSkuId == i.omsOrderItemId){
-              paramsItem.qty = add(Number(paramsItem.qty),Number(i.tmsQuantity))
+        } else {
+          for (let paramsItem of params.tmsMaterials) {
+            if (paramsItem.materialSkuId == i.omsOrderItemId) {
+              paramsItem.qty = add(Number(paramsItem.qty), Number(i.tmsQuantity))
               break
             }
           }
         }
-        
+
       }
     }
     delete params.subItem;
     this.load = true;
-    WMSAddEntryOrder(params).then((res:any) => {
+    WMSAddEntryOrder(params).then((res: any) => {
       this.load = false;
-      if(res.code == 200){
+      if (res.code == 200) {
         this.isSuccess = true;
         this.$message({
-          message:'操作成功!',
-          type:'success'
+          message: '操作成功!',
+          type: 'success'
         })
         this.drawer = false;
-        
+
         this.$forceUpdate();
       }
     }).catch(() => {
@@ -285,26 +275,26 @@ export default class BatchbyOneModal extends Vue {
     })
   }
   //寻找未发货订单
-  noSentOrder(){
+  noSentOrder() {
     this.currentOrder = this.data.length;
-    for(let i = 0; i < this.data.length; i++){
-      if(!this.data[i].isSuccess){
+    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();
+    this.setInfo();
     // } 
   }
-  setOnEditOrderInfo(ids:string){
+  setOnEditOrderInfo(ids: string) {
     let _value = this.data[0]
-    for(const item of this.data){
-      if(ids.indexOf(item.omsOrderIds) > -1 && !item.isSuccess){
+    for (const item of this.data) {
+      if (ids.indexOf(item.omsOrderIds) > -1 && !item.isSuccess) {
         item.orderType = _value.orderType;
         item.storeHouseId = _value.storeHouseId;
         item.tmsArrivalDate = _value.tmsArrivalDate;
-        item.tmsDeliveryDate =_value.tmsDeliveryDate;
+        item.tmsDeliveryDate = _value.tmsDeliveryDate;
         item.tmsTransportMethod = _value.tmsTransportMethod;
         item.tmsBusinessMan = _value.tmsBusinessMan;
         item.tmsBusinessPhone = _value.tmsBusinessPhone;
@@ -334,66 +324,68 @@ export default class BatchbyOneModal extends Vue {
     }
   }
   //获取价格
-  getPriceInfo(data:any,callback?:Function){
-    let params:any={};
-    if(!data.out_storeHouseId || !data.entry_storeHouseId || data.subItem.length == 0){
+  getPriceInfo(data: any, callback?: Function) {
+    let params: any = {};
+    if (!data.out_storeHouseId || !data.entry_storeHouseId || data.subItem.length == 0) {
       return
     }
     params.startStoreHouseId = data.out_storeHouseId;
     params.endStoreHouseId = data.entry_storeHouseId;
     params.materialInfos = []
-    if(data.subItem){
-      for(const i of data.subItem){
+    if (data.subItem) {
+      for (const i of data.subItem) {
         params.materialInfos.push({
           skuId: i.omsOrderItemId,
-          qty:i.tmsQuantity,
+          qty: i.tmsQuantity,
         })
       }
     }
     this.load = true;
-    getShortBargePrice(params).then((res:any) => {
+    getShortBargePrice(params).then((res: any) => {
       // if(this.currentPrice && this.currentPrice[data.omsOrderIds]){
       //   delete this.currentPrice[data.omsOrderIds]
       // }
-      
-      this.load=false;
-      let current:any=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');
-        if(!current) current = item;
-        if(Number(current.estimateFreight) > Number(item.estimateFreight)){
+
+      this.load = false;
+      let current: any = 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');
+        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){
+      if (callback) {
         callback(data)
       }
-    }).catch((err:any)=>{
+    }).catch((err: any) => {
       this.load = false;
     })
   }
-  editState(v:boolean){
+  editState(v: boolean) {
     this.drawer = v
   }
 }
 </script>
 <style lang="scss" scoped>
-.content{
+.content {
   width: 100%;
   box-sizing: border-box;
   padding: 0 16px;
   background-color: #FFF;
-  .order-top{
+
+  .order-top {
     padding-bottom: 16px;
     display: flex;
     justify-content: center;
   }
 }
-.deli-footer{
+
+.deli-footer {
   height: 80px;
   width: 100%;
   box-shadow: 0 -5px 10px #EEE;
@@ -401,52 +393,60 @@ export default class BatchbyOneModal extends Vue {
   box-sizing: border-box;
   display: flex;
   justify-content: space-between;
-  align-items:flex-end;
+  align-items: flex-end;
   position: absolute;
   background-color: #FFF;
   left: 0;
   bottom: 0;
   z-index: 10;
-  .d-left{
+
+  .d-left {
     width: 50%;
-    .estimate-total{
+
+    .estimate-total {
       font-size: 14px;
       padding-bottom: 4px;
-      .total{
+
+      .total {
         font-size: 16px;
         color: #F00;
       }
-      .detail{
+
+      .detail {
         color: #1684FC;
         padding-left: 16px;
         cursor: pointer;
       }
     }
   }
-  .send-btn{
+
+  .send-btn {
     width: 120px;
     height: 40px;
     line-height: 40px;
     margin-left: 16px;
     border-radius: 8px;
-    background: linear-gradient(129.2deg, rgba(22,132,252,1) 9.81%,rgba(93,167,249,1) 97.4%);
+    background: linear-gradient(129.2deg, rgba(22, 132, 252, 1) 9.81%, rgba(93, 167, 249, 1) 97.4%);
     color: rgba(255, 255, 255, 100);
     font-size: 14px;
     text-align: center;
     box-shadow: 0px 2px 6px 0px rgba(93, 167, 249, 100);
     cursor: pointer;
   }
-  .stopBtn{
+
+  .stopBtn {
     opacity: 0.7;
   }
-  .btn-box{
+
+  .btn-box {
     width: 50%;
     display: flex;
     justify-content: flex-end;
     align-items: center;
   }
 }
-.space{
+
+.space {
   height: 80px;
   width: 100%;
   margin-top: 16px;

+ 9 - 0
src/views/oms/B2BOrder/components/autoAudit.vue

@@ -65,6 +65,15 @@ export default class AutoAudit extends Vue {
     }
     setShow(v: boolean) {
         this.value = v;
+        setTimeout(() => {
+            let data = localStorage.getItem('autoAudit');
+            if (data) {
+                let v = JSON.parse(data);
+                v.jobState = v.jobState == 1 ? true : false;
+                console.info(v);
+                (this.$refs.form as any).setValue(v);
+            }
+        }, 200);
     }
     btn() {
         let v = (this.$refs.form as any).getValue();

+ 237 - 217
src/views/oms/B2BOrder/components/batchbyOneModal.vue

@@ -1,27 +1,18 @@
 <template>
-  <el-drawer
-    v-loading="load"
-    :title="data.length <= 1 ? '订单发货' : '订单发货(批量逐一发货)'"
-    :visible.sync="drawer"
-    @close="close"
-    :direction="direction"
-    size="50%">
+  <el-drawer v-loading="load" :title="data.length <= 1 ? '订单发货' : '订单发货(批量逐一发货)'" :visible.sync="drawer" @close="close"
+    :direction="direction" size="50%">
     <div class="content">
       <div class="err" v-if="failOrder.length > 0 && data.length > 1">
         <span>发货失败订单:</span>
-        <span class="error-page" v-for="item of failOrder" @click="exchangeTag(item)" :key="item">【{{item + 1 }}】</span>
+        <span class="error-page" v-for="item of failOrder" @click="exchangeTag(item)" :key="item">【{{ item + 1
+        }}】</span>
       </div>
       <div class="order-top" v-if="data.length > 1">
-        <el-pagination
-          background
-          :page-size="1"
-          :current-page="currentOrder + 1"
-          layout="prev, pager, next"
-          @current-change="currentChange"
-          :total="data.length">
+        <el-pagination background :page-size="1" :current-page="currentOrder + 1" layout="prev, pager, next"
+          @current-change="currentChange" :total="data.length">
         </el-pagination>
       </div>
-      <deliveryGoodsInfo @editState="editState" @editResult="editResult" ref="info" />
+      <deliveryGoodsInfo @editState="editState" @editResult="editResult" @emptyInventory="emptyInventory" ref="info" />
       <!-- <deliveryPrice :data="priceObj[data[currentOrder].omsOrderIds]" ref="price" v-if="data[currentOrder] && priceObj[data[currentOrder].omsOrderIds]" 
       @prichChange="prichChange" :currentValue="currentPrice[data[currentOrder].omsOrderIds]" /> -->
     </div>
@@ -36,10 +27,12 @@
         </div> -->
       </div>
       <div class="btn-box">
-        <div class="send-btn" @click="nextBtn" :class="{'stopBtn':stopHandle}" v-if="data.length > 1">{{currentOrder + 1 == data.length ? '确认' : '确认,下一单'}}</div>
-        <div class="send-btn" @click="btn" :class="{'stopBtn':stopHandle}">一键发货</div>
+        <div class="send-btn" @click="nextBtn" :class="{ 'stopBtn': stopHandle }" v-if="data.length > 1">{{ currentOrder
+          + 1
+          == data.length ? '确认' : '确认,下一单' }}</div>
+        <div class="send-btn" @click="btn" :class="{ 'stopBtn': stopHandle }">一键发货</div>
       </div>
-      
+
     </div>
   </el-drawer>
 </template>
@@ -48,126 +41,129 @@
 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,getInventoryByStoreHouseIdAndSkuids } from  '@/api/delivery'
+import { add, multiply, subtract, divide } from '@/benyun/utils/accuracy'
+import { queryPricePackage, addmultiple, getInventoryByStoreHouseIdAndSkuids } from '@/api/delivery'
 import api from '@/api/currency'
 import Format from '@/benyun/utils/dateFormat'
 
-@Component({components:{DeliveryGoodsInfo,DeliveryPrice}})
+@Component({ components: { DeliveryGoodsInfo, DeliveryPrice } })
 export default class BatchbyOneModal extends Vue {
-  drawer=false;
-  direction='rtl'
-  checked=false;
-  data:Array<any>=[];
-  currentOrder=0; //当前显示订单
-  isSuccess=false; //是否有成功订单
-  stopHandle=false; //是否停止操作
-  failOrder:Array<any>=[]; //
+  //是否库存不足
+  isEmptyInventory: Boolean = false;
+  drawer = false;
+  direction = 'rtl'
+  checked = false;
+  data: Array<any> = [];
+  currentOrder = 0; //当前显示订单
+  isSuccess = false; //是否有成功订单
+  stopHandle = false; //是否停止操作
+  failOrder: Array<any> = []; //
   load = false;
-  priceObj:any={};
-  currentPrice:any={};
-  warehouseData:Array<any>=[];
-  setShow(v:boolean){
-    this.drawer=v;
-    this.priceObj={};
-    this.currentPrice={};
+  priceObj: any = {};
+  currentPrice: any = {};
+  warehouseData: Array<any> = [];
+  setShow(v: boolean) {
+    this.drawer = v;
+    this.priceObj = {};
+    this.currentPrice = {};
     this.isSuccess = false;
     this.stopHandle = false;
     this.currentOrder = 0;
     this.checked = false;
     this.failOrder = [];
   }
-  close(){
-    if(this.isSuccess){
+  close() {
+    if (this.isSuccess) {
       this.$emit('handleSuccess');
     }
   }
-  exchangeTag(v:number){
+  exchangeTag(v: number) {
     this.currentOrder = v;
     this.setInfo()
   }
-  editResult(v:any){
-    if(this.currentOrder >= this.data.length){
-      this.data[this.currentOrder-1] = v;
-    }else{
+  editResult(v: any) {
+    if (this.currentOrder >= this.data.length) {
+      this.data[this.currentOrder - 1] = v;
+    } else {
       this.data[this.currentOrder] = v;
     }
-    
+
     // this.getStoreCount(v);
     // this.getPriceInfo(v);
   }
-  prichChange(index:number){
+  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;
+  currentChange(v: number) {
+    this.currentOrder = v - 1;
     this.$forceUpdate();
-    this.$nextTick(()=>{
+    this.$nextTick(() => {
       this.setInfo();
     })
   }
-  setInfo(){
-    if(this.data[this.currentOrder]){
+  setInfo() {
+    if (this.data[this.currentOrder]) {
       (this.$refs.info as any).setValue(this.data[this.currentOrder]);
     }
   }
-  setValue(data:Array<any>){
+  setValue(data: Array<any>) {
     this.data = [];
-    if(data && data.length > 0){
-      for(const item of data){
-        const requestId =  new Date().getTime() + this.getUuid()
-        let obj:any={
-          tmsTransportMethod:'零担',
+    if (data && data.length > 0) {
+      for (const item of data) {
+        const requestId = new Date().getTime() + this.getUuid()
+        let obj: any = {
+          tmsTransportMethod: '零担',
           tmsBusinessMan: (this as any).$store.getters.userInfo.nickName,
           tmsBusinessPhone: (this as any).$store.getters.userInfo.phonenumber,
-          requestId:requestId,
-          omsOrderIds:item.id,
-          weight:item.weight,
-          tmsUnloadingProvince:item.receiverProvince,
-          tmsUnloadingProvinceNo:item.receiverProvinceCode,
-          tmsUnloadingCity:item.receiverCity,
-          tmsUnloadingCityNo:item.receiverCityCode,
-          tmsUnloadingRegion:item.receiverDistrict,
-          tmsUnloadingRegionNo:item.receiverDistrictCode,
-          tmsUnloadingStreet:item.receiverTown,
-          tmsUnloadingStreetNo:item.receiverTownCode,
-          tmsUnloadingAddress:item.receiverAddress,
-          tmsUnloadingConsignor:item.receiverName,
-          tmsUnloadingContacts:item.receiverMobile,
+          requestId: requestId,
+          omsOrderIds: item.id,
+          weight: item.weight,
+          tmsUnloadingProvince: item.receiverProvince,
+          tmsUnloadingProvinceNo: item.receiverProvinceCode,
+          tmsUnloadingCity: item.receiverCity,
+          tmsUnloadingCityNo: item.receiverCityCode,
+          tmsUnloadingRegion: item.receiverDistrict,
+          tmsUnloadingRegionNo: item.receiverDistrictCode,
+          tmsUnloadingStreet: item.receiverTown,
+          tmsUnloadingStreetNo: item.receiverTownCode,
+          tmsUnloadingAddress: item.receiverAddress,
+          tmsUnloadingConsignor: item.receiverName,
+          tmsUnloadingContacts: item.receiverMobile,
           wmsSendType: 'B2BCK',
           tmsArrivalDate: this.getTime(3600 * 1000 * 24 * 2),
           tmsDeliveryDate: this.getTime(3600 * 1000 * (24 * 2 + 2)),
         };
 
-        obj.subItem=[];
-        if(item.items && item.items.length > 0){
-          for(const i of item.items){
-            let total:any = 0;
-            if(Number(i.qty) && Number(i.price) && i.isGift !== 1){
-              total = multiply(Number(i.qty),Number(i.price))
+        obj.subItem = [];
+        if (item.items && item.items.length > 0) {
+          for (const i of item.items) {
+            let total: any = 0;
+            if (Number(i.qty) && Number(i.price) && i.isGift !== 1) {
+              total = multiply(Number(i.qty), Number(i.price))
             }
-            
+
             obj.subItem.push({
-              isGift:i.isGift,
-              barCode:i.barCode,
-              requestId:requestId,
-              omsOrderId:item.id,
-              omsOrderItemId:i.itemId,
+              isGift: i.isGift,
+              barCode: i.barCode,
+              requestId: requestId,
+              omsOrderId: item.id,
+              omsOrderItemId: i.itemId,
               // omsOrderItemSkuId:i.itemId,
-              tmsGoodsModel:i.styleId,
-              tmsGoodsCode:i.skuId,
-              tmsQuantity:i.qty,
-              tmsGoodsTotalPrice:total,
-              name:i.name,
+              tmsGoodsModel: i.styleId,
+              tmsGoodsCode: i.skuId,
+              tmsQuantity: i.qty,
+              remainAmount: 0,
+              tmsGoodsTotalPrice: total,
+              name: i.name,
               price: i.isGift === 1 ? 0 : i.price,
-              weight:i.weight
+              weight: i.weight
             })
           }
         }
         this.data.push(obj)
       }
-    }else{
+    } else {
       this.data = []
     }
     this.loadWarehouse()
@@ -183,38 +179,41 @@ export default class BatchbyOneModal extends Vue {
       pageSize: 1000
     }, 'maindataStorehouse').then((res: any) => {
       this.warehouseData = res.data.records;
-      if(this.warehouseData.length > 0){
-        for(const item of this.data){
-          item.tmsShipmentConsignor=this.warehouseData[0].shipper;
-          item.tmsShipmentContacts=this.warehouseData[0].shipperPhone;
-          item.tmsShipmentProvince= this.warehouseData[0].province;
-          item.tmsShipmentProvinceNo=this.warehouseData[0].provinceCode;
-          item.tmsShipmentCity= this.warehouseData[0].city;
-          item.tmsShipmentCityNo= this.warehouseData[0].cityCode;
-          item.tmsShipmentRegion= this.warehouseData[0].region;
-          item.tmsShipmentRegionNo= this.warehouseData[0].regionCode;
-          item.tmsShipmentStreetNo= this.warehouseData[0].streetCode;
-          item.tmsShipmentStreet= this.warehouseData[0].street;
-          item.tmsShipmentAddress=this.warehouseData[0].address;
-          item.storeHouseId= this.warehouseData[0].id;
-          item.storeHouseName= this.warehouseData[0].name;
+      if (this.warehouseData.length > 0) {
+        for (const item of this.data) {
+          item.tmsShipmentConsignor = this.warehouseData[0].shipper;
+          item.tmsShipmentContacts = this.warehouseData[0].shipperPhone;
+          item.tmsShipmentProvince = this.warehouseData[0].province;
+          item.tmsShipmentProvinceNo = this.warehouseData[0].provinceCode;
+          item.tmsShipmentCity = this.warehouseData[0].city;
+          item.tmsShipmentCityNo = this.warehouseData[0].cityCode;
+          item.tmsShipmentRegion = this.warehouseData[0].region;
+          item.tmsShipmentRegionNo = this.warehouseData[0].regionCode;
+          item.tmsShipmentStreetNo = this.warehouseData[0].streetCode;
+          item.tmsShipmentStreet = this.warehouseData[0].street;
+          item.tmsShipmentAddress = this.warehouseData[0].address;
+          item.storeHouseId = this.warehouseData[0].id;
+          item.storeHouseName = this.warehouseData[0].name;
         }
         (this.$refs.info as any).setValue(this.data[this.currentOrder]);
       }
-    }).catch(() => {})
+    }).catch(() => { })
   }
-  getTime(n:number) {
+  getTime(n: number) {
     const start = new Date();
     start.setTime(start.getTime() + n);
-    const t = Format(new Date(start),'yyyy-MM-dd HH:mm:ss');
+    const t = Format(new Date(start), 'yyyy-MM-dd HH:mm:ss');
     return t
   }
-  getUuid(){
+  getUuid() {
     return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
   }
-  btn(){
+  btn() {
+    if (this.isEmptyInventory) {
+      this.$message('订单商品暂无库存')
+    }
     this.noSentOrder(true);
-    if(!this.data[this.currentOrder]){
+    if (!this.data[this.currentOrder]) {
       this.$message('没有需要发货的订单!')
       return
     }
@@ -226,7 +225,7 @@ export default class BatchbyOneModal extends Vue {
     //   this.$message('请阅读并同意运单协议!')
     //   return
     // }
-    if(!this.data[this.currentOrder].tmsShipmentConsignor || !this.data[this.currentOrder].tmsUnloadingAddress || !this.data[this.currentOrder].tmsUnloadingConsignor){
+    if (!this.data[this.currentOrder].tmsShipmentConsignor || !this.data[this.currentOrder].tmsUnloadingAddress || !this.data[this.currentOrder].tmsUnloadingConsignor) {
       this.$message("订单信息不完善,请前往编辑!");
       return
     }
@@ -234,15 +233,15 @@ export default class BatchbyOneModal extends Vue {
     //   this.$message("请选择价格!");
     //   return
     // }
-    if(this.data.length > 1){
-      let ids='';
-      for(const item of this.data){
-        if(!item.tmsShipmentConsignor || !item.tmsUnloadingAddress || !item.tmsUnloadingConsignor){
+    if (this.data.length > 1) {
+      let ids = '';
+      for (const item of this.data) {
+        if (!item.tmsShipmentConsignor || !item.tmsUnloadingAddress || !item.tmsUnloadingConsignor) {
           ids = ids ? ids + ',' + item.omsOrderIds : String(item.omsOrderIds)
         }
       }
-      if(ids){
-        this.$confirm('订单'+ids + '未编辑,是否以第一条订单为基准', '提示', {
+      if (ids) {
+        this.$confirm('订单' + ids + '未编辑,是否以第一条订单为基准', '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
           type: 'warning'
@@ -250,23 +249,26 @@ export default class BatchbyOneModal extends Vue {
           this.setOnEditOrderInfo(ids);
           this.sendGoods(this.data[this.currentOrder]);
 
-        }).catch(() => {});
-      }else{
+        }).catch(() => { });
+      } else {
         this.sendGoods(this.data[this.currentOrder]);
       }
-    }else{
-      if(this.data[0].isSuccess){
-        this.$message('订单:'+this.data[0].omsOrderIds+'已执行过发货操作!');
+    } 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){
+  nextBtn() {
+    if (this.currentOrder >= this.data.length) {
       this.$message('已经是最后一单!')
       return
     }
+    if (this.isEmptyInventory) {
+      this.$message('订单商品暂无库存')
+    }
     // if(this.stopHandle){
     //   this.$message('库存不足!')
     //   return
@@ -276,11 +278,11 @@ export default class BatchbyOneModal extends Vue {
     //   return
     // }
     const _value = this.data[this.currentOrder];
-    if(!_value.tmsBusinessMan || !_value.tmsBusinessPhone || !_value.tmsShipmentConsignor || !_value.tmsShipmentContacts || !_value.tmsUnloadingConsignor || !_value.tmsUnloadingContacts || !_value.tmsUnloadingProvince || !_value.tmsUnloadingAddress || !_value.storeHouseId){
+    if (!_value.tmsBusinessMan || !_value.tmsBusinessPhone || !_value.tmsShipmentConsignor || !_value.tmsShipmentContacts || !_value.tmsUnloadingConsignor || !_value.tmsUnloadingContacts || !_value.tmsUnloadingProvince || !_value.tmsUnloadingAddress || !_value.storeHouseId) {
       this.$message("订单信息不完整,请编辑信息!");
       return
     }
-    if(_value.tmsBusinessMan.length >= 10){
+    if (_value.tmsBusinessMan.length >= 10) {
       this.$message("业务员名称不能超过10个字符!");
       return
     }
@@ -288,62 +290,62 @@ export default class BatchbyOneModal extends Vue {
     //   this.$message('请选择价格!')
     //   return
     // }
-    if(_value.isSuccess){
-      this.$message('订单:'+_value.omsOrderIds+'已执行过发货操作!');
+    if (_value.isSuccess) {
+      this.$message('订单:' + _value.omsOrderIds + '已执行过发货操作!');
       return
     }
-    this.sendGoods(_value,true);
+    this.sendGoods(_value, true);
   }
   //查库存
-  getStoreCount(item:any,callback?:Function){
-    if(!item){
+  getStoreCount(item: any, callback?: Function) {
+    if (!item) {
       return
     }
-    let params:any={};
+    let params: any = {};
     params.storeHouseId = item.storeHouseId;
-    params.skuIds=[];
-    if(item.subItem){
-      for(const i of item.subItem){
-        if(params.skuIds.indexOf(i.omsOrderItemId) == -1){
+    params.skuIds = [];
+    if (item.subItem) {
+      for (const i of item.subItem) {
+        if (params.skuIds.indexOf(i.omsOrderItemId) == -1) {
           params.skuIds.push(i.omsOrderItemId);
         }
       }
     }
     this.load = true;
-    getInventoryByStoreHouseIdAndSkuids(params).then((res:any) => {
+    getInventoryByStoreHouseIdAndSkuids(params).then((res: any) => {
       this.load = false;
-      let m='';
-      for(const i of item.subItem){
-        for(const d of res.data){
+      let m = '';
+      for (const i of item.subItem) {
+        for (const d of res.data) {
           let s = Number(d.inventory) - Number(d.useInventory) - Number(i.tmsQuantity);
-          if(i.omsOrderItemId == d.skuid && s < 0){
-            m = m ? m + ',' + i.name : i.name;          
-          }else{
+          if (i.omsOrderItemId == d.skuid && s < 0) {
+            m = m ? m + ',' + i.name : i.name;
+          } else {
             d.inventory = subtract(d.inventory, i.tmsQuantity);
           }
         }
       }
-      if(m){
+      if (m) {
         this.$message({
-          message:'商品“'+m+'”库存不足!',
-          type:'error'
+          message: '商品“' + m + '”库存不足!',
+          type: 'error'
         })
         this.stopHandle = true;
         return
       }
-      if(callback) callback(item,this.sendGoods)
-    }).catch(()=>{
+      if (callback) callback(item, this.sendGoods)
+    }).catch(() => {
       this.load = false;
     })
   }
   //发货
-  sendGoods(item:any,isNext?:boolean){
-    if(!item){
+  sendGoods(item: any, isNext?: boolean) {
+    if (!item) {
       this.$message('订单不存在!')
       return
     }
-    
-    let params:any=(this as any).$lodash.cloneDeep(item);
+
+    let params: any = (this as any).$lodash.cloneDeep(item);
     // if(this.priceObj[item.omsOrderIds]){
     //   try{
     //     params.pricePlan = JSON.stringify(this.priceObj[item.omsOrderIds])
@@ -364,32 +366,32 @@ export default class BatchbyOneModal extends Vue {
     // }
     delete params.subItem;
     this.load = true;
-    const resHandle = (s:string,msg?:string) => {
-      for(let it of this.data){
-        if(it.omsOrderIds == item.omsOrderIds){
+    const resHandle = (s: string, msg?: string) => {
+      for (let it of this.data) {
+        if (it.omsOrderIds == item.omsOrderIds) {
           it.state = s;
-          if(msg){
+          if (msg) {
             it.msg = msg;
-          }else{
+          } else {
             it.msg = '';
           }
           break;
         }
       }
 
-      if(!isNext){
+      if (!isNext) {
         //寻找未发货的订单
         this.noSentOrder();
         //是否是最后一单
-        if(this.currentOrder >= this.data.length){
-          if(this.failOrder.length == 0){
+        if (this.currentOrder >= this.data.length) {
+          if (this.failOrder.length == 0) {
             this.drawer = false;
-          }else{
-            (this.$refs.info as any).setValue(this.data[this.currentOrder-1]);
+          } else {
+            (this.$refs.info as any).setValue(this.data[this.currentOrder - 1]);
           }
-          
-        }else{
-          let _item:any = this.data[this.currentOrder];
+
+        } else {
+          let _item: any = this.data[this.currentOrder];
           this.sendGoods(_item);
           // if(this.currentPrice[_item.omsOrderIds]){
           //   this.sendGoods(_item);
@@ -399,61 +401,61 @@ export default class BatchbyOneModal extends Vue {
           //   // this.getStoreCount(_item,this.getPriceInfo);
           // }
         }
-      }else{
-        if(this.currentOrder < this.data.length - 1) {
-          this.currentOrder ++;
+      } else {
+        if (this.currentOrder < this.data.length - 1) {
+          this.currentOrder++;
           this.setInfo();
         }
       }
       this.$forceUpdate();
     }
     //发货
-    addmultiple(params).then((res:any) => {
+    addmultiple(params).then((res: any) => {
       this.load = false;
-      if(res.code == 200){
+      if (res.code == 200) {
         this.isSuccess = true;
         this.$message({
-          message:'订单:'+item.omsOrderIds+'发货成功!',
-          type:'success'
+          message: '订单:' + item.omsOrderIds + '发货成功!',
+          type: 'success'
         })
         let fLen = this.failOrder.indexOf(this.currentOrder);
-        if(fLen >= 0){
-          this.failOrder.splice(fLen,1);
+        if (fLen >= 0) {
+          this.failOrder.splice(fLen, 1);
         }
         resHandle('success')
       }
-    }).catch((err:any) => {
+    }).catch((err: any) => {
       this.load = false;
-      if(this.failOrder.indexOf(this.currentOrder) == -1){
+      if (this.failOrder.indexOf(this.currentOrder) == -1) {
         this.failOrder.push(this.currentOrder);
       }
-      resHandle('fail',err);
+      resHandle('fail', err);
     })
   }
   //寻找未发货订单
-  noSentOrder(isCkick?:boolean){
+  noSentOrder(isCkick?: boolean) {
     this.currentOrder = this.data.length;
-    for(let i = 0; i < this.data.length; i++){
-      if(!this.data[i].state){
+    for (let i = 0; i < this.data.length; i++) {
+      if (!this.data[i].state) {
         this.currentOrder = i;
         break
       }
     }
-    if(isCkick && this.currentOrder == this.data.length && this.failOrder.length > 0){
+    if (isCkick && this.currentOrder == this.data.length && this.failOrder.length > 0) {
       this.currentOrder = this.failOrder[0];
     }
     // if(this.data[this.currentOrder]){
-      this.setInfo();
+    this.setInfo();
     // } 
   }
-  setOnEditOrderInfo(ids:string){
+  setOnEditOrderInfo(ids: string) {
     let _value = this.data[0]
-    for(const item of this.data){
-      if(ids.indexOf(item.omsOrderIds) > -1 && !item.isSuccess){
+    for (const item of this.data) {
+      if (ids.indexOf(item.omsOrderIds) > -1 && !item.isSuccess) {
         item.orderType = _value.orderType;
         item.storeHouseId = _value.storeHouseId;
         item.tmsArrivalDate = _value.tmsArrivalDate;
-        item.tmsDeliveryDate =_value.tmsDeliveryDate;
+        item.tmsDeliveryDate = _value.tmsDeliveryDate;
         item.tmsTransportMethod = _value.tmsTransportMethod;
         item.tmsBusinessMan = _value.tmsBusinessMan;
         item.tmsBusinessPhone = _value.tmsBusinessPhone;
@@ -483,59 +485,68 @@ export default class BatchbyOneModal extends Vue {
     }
   }
   //获取价格
-  getPriceInfo(data:any,callback?:Function){
-    let params:any={};
+  getPriceInfo(data: any, callback?: Function) {
+    let params: any = {};
     params.startStoreHouseId = data.storeHouseId;
     // params.startAddressCode = data.tmsShipmentCityNo + '00000';
     params.endAddressCode = data.tmsUnloadingCityNo + '00000';
-    params.omsIds=[this.data[0].omsOrderIds];
+    params.omsIds = [this.data[0].omsOrderIds];
     params.planType = data.tmsTransportMethod;
     this.load = true;
-    queryPricePackage(params).then((res:any) => {
-      this.load=false;
-      let current:any=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');
-        if(!current) current = item;
-        if(Number(current.estimateFreight) > Number(item.estimateFreight)){
+    queryPricePackage(params).then((res: any) => {
+      this.load = false;
+      let current: any = 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');
+        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){
+      if (callback) {
         callback(data)
       }
-    }).catch((err:any)=>{
+    }).catch((err: any) => {
       this.load = false;
     })
   }
-  editState(v:boolean){
+  editState(v: boolean) {
     this.drawer = v
   }
+  emptyInventory(v: boolean) {
+    this.isEmptyInventory = v;
+  }
+
+
 }
 </script>
 <style lang="scss" scoped>
-.content{
+.content {
   width: 100%;
   box-sizing: border-box;
   padding: 0 16px;
   background-color: #FFF;
-  .err{
+
+  .err {
     font-size: 14px;
     color: #F00;
     padding-bottom: 8px;
   }
-  .error-page{
+
+  .error-page {
     cursor: pointer;
   }
-  .order-top{
+
+  .order-top {
     padding-bottom: 16px;
     display: flex;
     justify-content: center;
-    .item-page{
+
+    .item-page {
       height: 28px;
       width: 28px;
       background-color: #F3F3F3;
@@ -551,60 +562,69 @@ export default class BatchbyOneModal extends Vue {
     }
   }
 }
-.deli-footer{
+
+.deli-footer {
   height: 60px;
   width: 100%;
   box-shadow: 0 -5px 10px #EEE;
   padding: 0 16px;
   box-sizing: border-box;
   display: flex;
-  justify-content:space-between;
+  justify-content: space-between;
   align-items: center;
   position: absolute;
   background-color: #FFF;
   left: 0;
   bottom: 0;
   z-index: 10;
-  .d-left{
+
+  .d-left {
     width: 50%;
-    .estimate-total{
+
+    .estimate-total {
       font-size: 14px;
       padding-bottom: 4px;
-      .total{
+
+      .total {
         font-size: 16px;
         color: #F00;
       }
-      .detail{
+
+      .detail {
         color: #1684FC;
         padding-left: 16px;
         cursor: pointer;
       }
     }
   }
-  .send-btn{
+
+  .send-btn {
     width: 120px;
     height: 40px;
     line-height: 40px;
     margin-left: 16px;
     border-radius: 8px;
-    background: linear-gradient(129.2deg, rgba(22,132,252,1) 9.81%,rgba(93,167,249,1) 97.4%);
+    background: linear-gradient(129.2deg, rgba(22, 132, 252, 1) 9.81%, rgba(93, 167, 249, 1) 97.4%);
     color: rgba(255, 255, 255, 100);
     font-size: 14px;
     text-align: center;
     box-shadow: 0px 2px 6px 0px rgba(93, 167, 249, 100);
     cursor: pointer;
   }
-  .stopBtn{
+
+  .stopBtn {
     opacity: 0.7;
   }
-  .btn-box{
+
+  .btn-box {
     width: 50%;
     display: flex;
     justify-content: flex-end;
     align-items: center;
   }
 }
-.space{
+
+.space {
   height: 60px;
   width: 100%;
   margin-top: 16px;

+ 14 - 3
src/views/oms/B2BOrder/components/carpoolModal.vue

@@ -1,5 +1,6 @@
 <template>
-  <el-drawer v-loading="load" :title="'订单发货(共' + data.length + '单)'" :visible.sync="drawer" :direction="direction" size="50%">
+  <el-drawer v-loading="load" :title="'订单发货(共' + data.length + '单)'" :visible.sync="drawer" :direction="direction"
+    size="50%">
     <div class="content">
       <div class="order-cont" v-if="data && data[0]">
         <div class="cont-left">
@@ -13,7 +14,7 @@
         <!-- <i class="el-icon-arrow-right"></i> -->
       </div>
       <deliveryGoodsInfo :hideOrderCode="true" :sendState="true" @editState="editState" @editResult="editResult"
-        ref="info" />
+        @emptyInventory="emptyInventory" ref="info" />
       <!-- <deliveryPrice v-if="priceData && priceData.length > 0" :data="priceData" :currentValue="currentPrice" @prichChange="prichChange" /> -->
     </div>
     <div class="space"></div>
@@ -41,6 +42,7 @@ import api from '@/api/currency'
 import Format from '@/benyun/utils/dateFormat'
 @Component({ components: { DeliveryGoodsInfo, DeliveryPrice } })
 export default class CarpoolModal extends Vue {
+  isEmptyInventory: boolean = false;
   drawer = false;
   direction = 'rtl'
   checked = false;
@@ -99,6 +101,7 @@ export default class CarpoolModal extends Vue {
             tmsGoodsCode: i.skuId,
             // omsOrderItemSkuId:i.itemId,
             tmsQuantity: Number(i.qty) ? Number(i.qty) : 0,
+            remainAmount: 0,
             tmsGoodsTotalPrice: total,
             name: i.name,
             price: i.price,
@@ -180,6 +183,9 @@ export default class CarpoolModal extends Vue {
     })
   }
   btn() {
+    if (this.isEmptyInventory) {
+      this.$message('订单商品暂无库存');
+    }
     // if(this.stopHandle){
     //   this.$message('库存不足!')
     //   return
@@ -282,6 +288,10 @@ export default class CarpoolModal extends Vue {
   editState(v: boolean) {
     this.drawer = v
   }
+
+  emptyInventory(v: boolean) {
+    this.isEmptyInventory = v;
+  }
 }
 </script>
 
@@ -404,4 +414,5 @@ export default class CarpoolModal extends Vue {
   height: 60px;
   width: 100%;
   margin-top: 16px;
-}</style>
+}
+</style>

+ 273 - 225
src/views/oms/B2BOrder/components/deliveryGoodsInfo.vue

@@ -130,11 +130,11 @@
       <div class="info-row">
         <div class="info-col col-width">
           <span class="label">期望送达时间:</span>
-          <span class="time">{{value.tmsArrivalDate}}</span>
+          <span class="time">{{ value.tmsArrivalDate }}</span>
         </div>
         <div class="info-col col-width">
           <span class="label">期望提货时间:</span>
-          <span class="time">{{value.tmsDeliveryDate}}</span>
+          <span class="time">{{ value.tmsDeliveryDate }}</span>
         </div>
       </div>
     </div>
@@ -144,17 +144,12 @@
         <div class="g-cont">
           <div class="g-total">
             <span class="name-label">重量合计(kg):</span>
-            <span class="total-num">{{totalWeight}}</span>
+            <span class="total-num">{{ totalWeight }}</span>
           </div>
         </div>
       </div>
       <div class="table">
-        <vxe-table
-          border
-          size="mini"
-          align="center"
-          header-cell-class-name="header-cell"
-          :data="value.subItem">
+        <vxe-table border size="mini" align="center" header-cell-class-name="header-cell" :data="value.subItem">
           <vxe-column field="barCode" title="商品条码" width="130"></vxe-column>
           <vxe-column field="name" title="物料名称" width="260">
             <template #default="{ row }">
@@ -165,11 +160,13 @@
           <vxe-column field="weight" title="重量(g)"></vxe-column>
           <vxe-column field="price" title="单价"></vxe-column>
           <vxe-column field="tmsQuantity" title="数量"></vxe-column>
+          <vxe-column field="remainAmount" title="库存"></vxe-column>
           <vxe-column field="tmsGoodsTotalPrice" title="小计"></vxe-column>
         </vxe-table>
       </div>
     </div>
-    <vxe-modal v-model="showModal" id="deliverInfoEdit" width="900" height="80%" @show="show" @hide="hide" title="编辑" resize show-zoom transfer show-footer>
+    <vxe-modal v-model="showModal" id="deliverInfoEdit" width="900" height="80%" @show="show" @hide="hide" title="编辑"
+      resize show-zoom transfer show-footer>
       <by-form :propConfig="config" v-if="showModal" ref="form" @formChange="formChange" />
       <template #footer>
         <div class="btn">
@@ -183,44 +180,47 @@
 
 <script lang="ts">
 import { Component, Prop, Vue, Watch } from "vue-property-decorator";
-import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
+import { add, multiply, subtract, divide } from '@/benyun/utils/accuracy'
+import api from "@/api/currency";
 @Component
 export default class DeliveryGoodsInfo extends Vue {
   @Prop()
-  hideOrderCode?:Boolean
+  hideOrderCode?: Boolean
   @Prop()
-  sendState?:Boolean
+  sendState?: Boolean
   @Prop()
-  readOnly?:Boolean
+  readOnly?: Boolean
 
-  data:Array<any>=[];
-  value:any={};
-  showModal=false;
-  totalWeight:any=0;
-  config:any={
-    attr:{
-      size:'small',
-      labelWidth:'120px',
-      rules:{
+  data: Array<any> = [];
+  value: any = {};
+  //是否通报库存不足
+  isEmitInventory: Boolean = false;
+  showModal = false;
+  totalWeight: any = 0;
+  config: any = {
+    attr: {
+      size: 'small',
+      labelWidth: '120px',
+      rules: {
         // orderType:[{
         //   required: true, message: '请选择订单类型!', trigger: 'change'
         // }],
-        tmsBusinessMan:[
+        tmsBusinessMan: [
           { required: true, message: '业务员不能为空!', trigger: 'blur' },
           { min: 0, max: 10, message: '业务员名字不能超过10个字符!', trigger: 'blur' }
         ],
-        tmsBusinessPhone:[{
+        tmsBusinessPhone: [{
           required: true, message: '业务员手机不能为空!', trigger: 'blur'
-        },{
+        }, {
           validator: this.validatePhone, trigger: 'blur'
         }],
-        tmsShipmentConsignor:[{
+        tmsShipmentConsignor: [{
           required: true, message: '发货人不能为空!', trigger: 'blur'
         }],
-        tmsShipmentContacts:[{
+        tmsShipmentContacts: [{
           required: true, message: '发货人电话不能为空!', trigger: 'blur'
-        },{
-          validator: this.validatePhone, trigger: 'blur' 
+        }, {
+          validator: this.validatePhone, trigger: 'blur'
         }],
         // tmsShipmentProvince:[{
         //   required: true, message: '请选择发货地址!', trigger: 'change'
@@ -228,27 +228,27 @@ export default class DeliveryGoodsInfo extends Vue {
         // tmsShipmentAddress:[{
         //   required: true, message: '发货地址不能为空!', trigger: 'blur'
         // }],
-        tmsUnloadingConsignor:[{
+        tmsUnloadingConsignor: [{
           required: true, message: '收货人不能为空!', trigger: 'blur'
         }],
-        tmsUnloadingContacts:[{
+        tmsUnloadingContacts: [{
           required: true, message: '收货人电话不能为空!', trigger: 'blur'
-        },{
-          validator: this.validatePhone, trigger: 'blur' 
+        }, {
+          validator: this.validatePhone, trigger: 'blur'
         }],
-        tmsUnloadingProvince:[{
+        tmsUnloadingProvince: [{
           required: true, message: '请选择收货地址!', trigger: 'change'
         }],
-        tmsUnloadingAddress:[{
+        tmsUnloadingAddress: [{
           required: true, message: '收货地址不能为空!', trigger: 'blur'
         }],
-        storeHouseId:[{
+        storeHouseId: [{
           required: true, message: '请选择仓库!', trigger: 'change'
         }],
-        tmsArrivalDate:[{
+        tmsArrivalDate: [{
           required: true, message: '期望送达时间不能为空!', trigger: 'blur'
         }],
-        tmsDeliveryDate:[{
+        tmsDeliveryDate: [{
           required: true, message: '期望提货时间不能为空!', trigger: 'blur'
         }],
         // tmsTransportMethod: [{
@@ -259,7 +259,7 @@ export default class DeliveryGoodsInfo extends Vue {
         }]
       }
     },
-    columns:[
+    columns: [
       // [
       //   {
       //   label:'订单类型',
@@ -280,57 +280,57 @@ export default class DeliveryGoodsInfo extends Vue {
       // }
       // ],
       [{
-        label:'业务员',
-        prop:'tmsBusinessMan',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+        label: '业务员',
+        prop: 'tmsBusinessMan',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
-      },{
-        label:'业务员手机',
-        prop:'tmsBusinessPhone',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+      }, {
+        label: '业务员手机',
+        prop: 'tmsBusinessPhone',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
       }],
       [{
-        label:'仓库',
-        prop:'storeHouseId',
-        component:'warehouse',
-        compConfig:{
-          attr:{
-            placeholder:'请选择仓库',
-            clearable:true,
-            defaultIndex:0,
-            retConfig:{
-              tmsShipmentConsignor:'shipper',
-              tmsShipmentContacts:'shipperPhone',
+        label: '仓库',
+        prop: 'storeHouseId',
+        component: 'warehouse',
+        compConfig: {
+          attr: {
+            placeholder: '请选择仓库',
+            clearable: true,
+            defaultIndex: 0,
+            retConfig: {
+              tmsShipmentConsignor: 'shipper',
+              tmsShipmentContacts: 'shipperPhone',
               tmsShipmentProvince: 'province',
-              tmsShipmentProvinceNo:'provinceCode',
+              tmsShipmentProvinceNo: 'provinceCode',
               tmsShipmentCity: 'city',
               tmsShipmentCityNo: 'cityCode',
               tmsShipmentRegion: 'region',
               tmsShipmentRegionNo: 'regionCode',
               tmsShipmentStreetNo: 'streetCode',
               tmsShipmentStreet: 'street',
-              tmsShipmentAddress:'address',
+              tmsShipmentAddress: 'address',
               storeHouseId: 'id',
               storeHouseName: 'name'
             }
           }
         }
-      },{
-        span:12,
-        label:'出库方式',
-        prop:'wmsSendType',
-        component:'by-select',
-        compConfig:{
-          attr:{
+      }, {
+        span: 12,
+        label: '出库方式',
+        prop: 'wmsSendType',
+        component: 'by-select',
+        compConfig: {
+          attr: {
             // clearable:true,
             data: [
               // {
@@ -338,8 +338,8 @@ export default class DeliveryGoodsInfo extends Vue {
               //   value:'YKCK'
               // },
               {
-                label:'B2B出库',
-                value:'B2BCK'
+                label: 'B2B出库',
+                value: 'B2BCK'
               },
               // {
               //   label:'B2C出库',
@@ -349,43 +349,43 @@ export default class DeliveryGoodsInfo extends Vue {
           }
         }
       }
-      // ,{
-      //   label:'运输方式',
-      //   prop:'tmsTransportMethod',
-      //   component:'by-select',
-      //   compConfig:{
-      //     attr:{
-      //       clearable:true,
-      //       data: [{
-      //         label:'整车',
-      //         value:'整车'
-      //       },{
-      //         label:'零担',
-      //         value:'零担'
-      //       },{
-      //         label:'短驳',
-      //         value:'短驳'
-      //       }]
-      //     }
-      //   }
-      // }
+        // ,{
+        //   label:'运输方式',
+        //   prop:'tmsTransportMethod',
+        //   component:'by-select',
+        //   compConfig:{
+        //     attr:{
+        //       clearable:true,
+        //       data: [{
+        //         label:'整车',
+        //         value:'整车'
+        //       },{
+        //         label:'零担',
+        //         value:'零担'
+        //       },{
+        //         label:'短驳',
+        //         value:'短驳'
+        //       }]
+        //     }
+        //   }
+        // }
       ],
       [{
-        label:'发货人',
-        prop:'tmsShipmentConsignor',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+        label: '发货人',
+        prop: 'tmsShipmentConsignor',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
-      },{
-        label:'发货人电话',
-        prop:'tmsShipmentContacts',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+      }, {
+        label: '发货人电话',
+        prop: 'tmsShipmentContacts',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
       }],
@@ -426,105 +426,136 @@ export default class DeliveryGoodsInfo extends Vue {
       //   }
       // }],
       [{
-        label:'收货人',
-        prop:'tmsUnloadingConsignor',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+        label: '收货人',
+        prop: 'tmsUnloadingConsignor',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
-      },{
-        label:'收货人电话',
-        prop:'tmsUnloadingContacts',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+      }, {
+        label: '收货人电话',
+        prop: 'tmsUnloadingContacts',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
       }],
       [{
-        labelWidth:'120px',
-        label:'收货地址选择',
-        prop:'tmsUnloadingProvince',
-        component:'by-area',
-        compConfig:{
-          attr:{
-            province:'tmsUnloadingProvince', //省
-            provinceCode:'tmsUnloadingProvinceNo', //省编码
-            city:'tmsUnloadingCity',   //市
-            cityCode:'tmsUnloadingCityNo',  //市编码
-            county:'tmsUnloadingRegion',  //县/区
-            countyCode:'tmsUnloadingRegionNo',   //县/区编码
-            townCode:'tmsUnloadingStreetNo',
-            town:'tmsUnloadingStreet'
+        labelWidth: '120px',
+        label: '收货地址选择',
+        prop: 'tmsUnloadingProvince',
+        component: 'by-area',
+        compConfig: {
+          attr: {
+            province: 'tmsUnloadingProvince', //省
+            provinceCode: 'tmsUnloadingProvinceNo', //省编码
+            city: 'tmsUnloadingCity',   //市
+            cityCode: 'tmsUnloadingCityNo',  //市编码
+            county: 'tmsUnloadingRegion',  //县/区
+            countyCode: 'tmsUnloadingRegionNo',   //县/区编码
+            townCode: 'tmsUnloadingStreetNo',
+            town: 'tmsUnloadingStreet'
           }
         }
       }],
       [{
-        label:'收货人地址',
-        prop:'tmsUnloadingAddress',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+        label: '收货人地址',
+        prop: 'tmsUnloadingAddress',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
       }],
       [{
-        label:'期望送达时间',
-        prop:'tmsArrivalDate',
-        component:'byDatePicker',
-        compConfig:{
-          attr:{
-            clearable:true,
-            type:'datetime'
+        label: '期望送达时间',
+        prop: 'tmsArrivalDate',
+        component: 'byDatePicker',
+        compConfig: {
+          attr: {
+            clearable: true,
+            type: 'datetime'
           }
         }
-      },{
-        label:'期望提货时间',
-        prop:'tmsDeliveryDate',
-        component:'byDatePicker',
-        compConfig:{
-          attr:{
-            clearable:true,
-            type:'datetime'
+      }, {
+        label: '期望提货时间',
+        prop: 'tmsDeliveryDate',
+        component: 'byDatePicker',
+        compConfig: {
+          attr: {
+            clearable: true,
+            type: 'datetime'
           }
         }
       }],
       [{
-        label:'备注',
-        prop:'tmsRemark',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+        label: '备注',
+        prop: 'tmsRemark',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
       }]
     ]
   }
-  validatePhone(rule:any, value:any, callback:any){
+  validatePhone(rule: any, value: any, callback: any) {
     if (value) {
-      if(!/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(value)) {
-        callback(new Error('手机号格式不正确!'));                                                                                                             
-      }else{
+      if (!/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(value)) {
+        callback(new Error('手机号格式不正确!'));
+      } else {
         callback();
       }
-      
+
     } else {
       callback();
     }
   }
-  setValue(v:any){
+
+  //获得库存
+  async getInventory() {
+    let items: any = [];
+    for (const item of this.value.subItem) {
+      items.push(item.barCode)
+    }
+    if (this.value.subItem.length) {
+      const res = await api.getJZJInventory({ wareHouseCode: '', items: items })
+      if (res.data.code != 200) {
+        this.$emit('emptyInventory', true);
+        return;
+      }
+      //将获得的库存设置到this.value.subItem的remainAmount中
+      for (let i = 0; i < this.value.subItem.length; i++) {
+        for (let j = 0; j < res.data.items.length; j++) {
+          if (this.value.subItem[i].barCode == res.data.items[j].barCode) {
+            this.value.subItem[i].remainAmount = res.data.items[j].remainAmount
+          }
+        }
+        if (Number(this.value.subItem[0].remainAmount) <= 0) {
+          //库存不足
+          this.$emit('emptyInventory', true);
+        }
+      }
+
+    }
+  }
+
+
+  setValue(v: any) {
     this.value = v ? v : {};
     this.value.wmsSendType = 'B2BCK'
     this.totalWeight = 0;
-    if(v.weight){
-      this.totalWeight = divide(v.weight,1000)?.toFixed(3)
+    if (v.weight) {
+      this.totalWeight = divide(v.weight, 1000)?.toFixed(3)
     }
-    
+    this.getInventory();
+
     // this.totalWeight = divide(v.weight,1000);
     // if(this.value.subItem && this.value.subItem.length > 0){
     //   for(const item of this.value.subItem){
@@ -536,35 +567,35 @@ export default class DeliveryGoodsInfo extends Vue {
     //   this.totalWeight = divide(this.totalWeight,1000);
     // }
   }
-  hide(){
-    this.$emit('editState',true)
+  hide() {
+    this.$emit('editState', true)
   }
-  show(){
+  show() {
     // this.value.tmsBusinessMan = (this as any).$store.getters.userInfo.userName;
     // this.value.tmsBusinessPhone = (this as any).$store.getters.userInfo.phonenumber;
-    this.$nextTick(()=>{
-      if(this.$refs.form){
+    this.$nextTick(() => {
+      if (this.$refs.form) {
         (this.$refs.form as any).clearValue();
         (this.$refs.form as any).setValue(this.value);
       }
     })
   }
-  edit(){
+  edit() {
     this.showModal = true;
-    this.$emit('editState',false)
+    this.$emit('editState', false)
   }
-  formChange(parames:any){
+  formChange(parames: any) {
     let data = (this.$refs.form as any).getValue();
-    if(data['tmsArrivalDate'] && data['tmsDeliveryDate']){
-      if(data['tmsArrivalDate'] > data['tmsDeliveryDate']){
+    if (data['tmsArrivalDate'] && data['tmsDeliveryDate']) {
+      if (data['tmsArrivalDate'] > data['tmsDeliveryDate']) {
         this.$message({
-          message:'期望送达时间不能大于期望提货时间',
-          type:'warning'
+          message: '期望送达时间不能大于期望提货时间',
+          type: 'warning'
         })
-        if(parames.code == 'tmsArrivalDate'){
+        if (parames.code == 'tmsArrivalDate') {
           data['tmsArrivalDate'] = ''
         }
-        if(parames.code == 'tmsDeliveryDate'){
+        if (parames.code == 'tmsDeliveryDate') {
           data['tmsDeliveryDate'] = ''
         }
         // (this.$refs.form as any).clearValue();
@@ -573,127 +604,144 @@ export default class DeliveryGoodsInfo extends Vue {
     }
   }
   btn() {
-    if(this.$refs.form){
-      (this.$refs.form as any).validate().then(()=>{
+    if (this.$refs.form) {
+      (this.$refs.form as any).validate().then(() => {
         this.value = (this.$refs.form as any).getValue();
-        if(!this.value.tmsShipmentCity){
+        if (!this.value.tmsShipmentCity) {
           this.$message({
-            message:'请选择发货城市!',
-            type:'warning'
+            message: '请选择发货城市!',
+            type: 'warning'
           })
           return
         }
-        if(!this.value.tmsShipmentRegion){
+        if (!this.value.tmsShipmentRegion) {
           this.$message({
-            message:'请选择发货区/县!',
-            type:'warning'
+            message: '请选择发货区/县!',
+            type: 'warning'
           })
           return
         }
-        if(!this.value.tmsUnloadingCity){
+        if (!this.value.tmsUnloadingCity) {
           this.$message({
-            message:'请选择收货城市!',
-            type:'warning'
+            message: '请选择收货城市!',
+            type: 'warning'
           })
           return
         }
-        if(!this.value.tmsUnloadingRegion){
+        if (!this.value.tmsUnloadingRegion) {
           this.$message({
-            message:'请选择收货区/县!',
-            type:'warning'
+            message: '请选择收货区/县!',
+            type: 'warning'
           })
           return
         }
         this.showModal = false;
-        this.$emit('editState',true);
-        this.$emit('editResult',this.value);
-      }).catch(()=>{})
+        this.$emit('editState', true);
+        this.$emit('editResult', this.value);
+      }).catch(() => { })
     }
   }
 }
 </script>
 <style lang="scss" scoped>
-.info{
+.info {
   width: 100%;
-  .edit{
+
+  .edit {
     width: 100%;
     display: flex;
     justify-content: flex-end;
     padding-bottom: 8px;
-    span{
+
+    span {
       color: rgb(0, 119, 255);
       font-size: 14px;
       cursor: pointer;
     }
   }
-  .g-box{
+
+  .g-box {
     width: 100%;
-    background-color: rgba(160,205,255,0.22);
+    background-color: rgba(160, 205, 255, 0.22);
     margin-bottom: 16px;
-    padding:16px;
+    padding: 16px;
     box-sizing: border-box;
-    .info-row{
+
+    .info-row {
       width: 100%;
       display: flex;
       padding-bottom: 16px;
-      .info-col{
+
+      .info-col {
         width: 100%;
         overflow: hidden;
         text-overflow: ellipsis;
         white-space: nowrap;
-        span{
+
+        span {
           font-size: 14px;
         }
-        .label{
+
+        .label {
           color: #666;
         }
-        .time{
+
+        .time {
           color: #F00;
         }
       }
-      .col-width{
+
+      .col-width {
         width: 50%;
       }
     }
-    .info-row:last-child{
+
+    .info-row:last-child {
       padding: 0;
     }
-    .goods-top{
+
+    .goods-top {
       padding-bottom: 8px;
       width: 100%;
       display: flex;
       align-items: center;
       justify-content: space-between;
-      .g-label{
+
+      .g-label {
         font-size: 14px;
       }
-      .g-cont{
+
+      .g-cont {
         width: 60%;
         display: flex;
         align-items: center;
         justify-content: flex-end;
-        .g-total{
+
+        .g-total {
           padding-left: 8px;
           font-size: 12px;
-          .name-label{
+
+          .name-label {
             color: #999;
           }
         }
       }
     }
-    .table{
+
+    .table {
       width: 100%;
     }
   }
-  .btn{
+
+  .btn {
     width: 100%;
     display: flex;
     justify-content: flex-end;
-  } 
+  }
 }
 </style>
 <style lang="scss">
-.header-cell{
-  background-color: rgba(160,205,255,0.48);
+.header-cell {
+  background-color: rgba(160, 205, 255, 0.48);
 }
 </style>

+ 290 - 237
src/views/oms/B2BOrder/components/expressDeliveryModal.vue

@@ -1,10 +1,5 @@
 <template>
-  <el-drawer
-    v-loading="load"
-    title="快递发货"
-    :visible.sync="drawer"
-    :direction="direction"
-    size="50%">
+  <el-drawer v-loading="load" title="快递发货" :visible.sync="drawer" :direction="direction" size="50%">
     <div class="content">
       <div class="info">
         <div class="edit">
@@ -50,17 +45,12 @@
             <div class="g-cont">
               <div class="g-total">
                 <span class="name-label">重量合计(kg):</span>
-                <span class="total-num">{{totalWeight}}</span>
+                <span class="total-num">{{ totalWeight }}</span>
               </div>
             </div>
           </div>
           <div class="table">
-            <vxe-table
-              border
-              size="mini"
-              align="center"
-              header-cell-class-name="header-cell"
-              :data="value.subItem">
+            <vxe-table border size="mini" align="center" header-cell-class-name="header-cell" :data="value.subItem">
               <vxe-column field="barCode" title="商品条码" width="130"></vxe-column>
               <vxe-column field="name" title="物料名称" width="260">
                 <template #default="{ row }">
@@ -71,12 +61,14 @@
               <vxe-column field="weight" title="重量"></vxe-column>
               <vxe-column field="price" title="单价"></vxe-column>
               <vxe-column field="tmsQuantity" title="数量"></vxe-column>
+              <vxe-column field="remainAmount" title="库存"></vxe-column>
               <vxe-column field="tmsGoodsTotalPrice" title="小计"></vxe-column>
             </vxe-table>
           </div>
         </div>
       </div>
-      <vxe-modal v-model="showModal" id="deliverInfoEdit" width="700" height="70%" @show="show" @hide="hide" title="编辑" resize show-zoom transfer show-footer>
+      <vxe-modal v-model="showModal" id="deliverInfoEdit" width="700" height="70%" @show="show" @hide="hide" title="编辑"
+        resize show-zoom transfer show-footer>
         <by-form :propConfig="config" v-if="showModal" ref="form" />
         <template #footer>
           <div class="btn">
@@ -103,69 +95,69 @@
 
 <script lang="ts">
 import { Component, Prop, Vue, Watch } from "vue-property-decorator";
-import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
-import { getInventoryByStoreHouseIdAndSkuids,express } from  '@/api/delivery'
+import { add, multiply, subtract, divide } from '@/benyun/utils/accuracy'
+import { getInventoryByStoreHouseIdAndSkuids, express } from '@/api/delivery'
 import api from '@/api/currency'
-@Component({components:{}})
+@Component({ components: {} })
 export default class ExpressDeliveryModal extends Vue {
-  drawer=false;
-  direction='rtl';
-  load=false;
-  checked=false;
-  stopHandle=false;
-  data:Array<any>=[]
-  totalWeight:any=0;
-  value:any = {}
-  showModal=false;
-  config:any={
-    attr:{
-      size:'small',
-      labelWidth:'120px',
-      rules:{
-        tmsBusinessMan:[{
+  drawer = false;
+  direction = 'rtl';
+  load = false;
+  checked = false;
+  stopHandle = false;
+  data: Array<any> = []
+  totalWeight: any = 0;
+  value: any = {}
+  showModal = false;
+  config: any = {
+    attr: {
+      size: 'small',
+      labelWidth: '120px',
+      rules: {
+        tmsBusinessMan: [{
           required: true, message: '业务员不能为空!', trigger: 'blur'
-        },{ min: 0, max: 10, message: '业务员名字不能超过10个字符!', trigger: 'blur' }],
-        tmsBusinessPhone:[{
+        }, { min: 0, max: 10, message: '业务员名字不能超过10个字符!', trigger: 'blur' }],
+        tmsBusinessPhone: [{
           required: true, message: '业务员手机不能为空!', trigger: 'blur'
-        },{
+        }, {
           validator: this.validatePhone, trigger: 'blur'
         }],
-        storeHouseId:[{
+        storeHouseId: [{
           required: true, message: '请选择仓库!', trigger: 'change'
         }]
       }
     },
-    columns:[
+    columns: [
       [{
-        label:'业务员',
-        prop:'tmsBusinessMan',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+        label: '业务员',
+        prop: 'tmsBusinessMan',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
       }],
       [{
-        label:'业务员手机',
-        prop:'tmsBusinessPhone',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+        label: '业务员手机',
+        prop: 'tmsBusinessPhone',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
       }],
       [{
-        label:'仓库',
-        prop:'storeHouseId',
-        component:'warehouse',
-        compConfig:{
-          attr:{
-            defaultIndex:0,
-            placeholder:'请选择仓库',
-            clearable:true,
-            retConfig:{
+        label: '仓库',
+        prop: 'storeHouseId',
+        component: 'warehouse',
+        compConfig: {
+          attr: {
+            defaultIndex: 0,
+            placeholder: '请选择仓库',
+            clearable: true,
+            retConfig: {
               storeHouseId: 'id',
               storeHouseName: 'name'
             }
@@ -173,153 +165,176 @@ export default class ExpressDeliveryModal extends Vue {
         }
       }],
       [{
-        label:'物流',
-        prop:'wmsLogisticsCode',
-        component:'by-select',
-        compConfig:{
-          attr:{
-            clearable:true,
-            retConfig:{
+        label: '物流',
+        prop: 'wmsLogisticsCode',
+        component: 'by-select',
+        compConfig: {
+          attr: {
+            clearable: true,
+            retConfig: {
               value: 'wmsLogisticsCode',
               label: 'wmsLogisticsName'
             },
             data: [{
-              value:'EMS',
-              label:'EMS'
-            },{
-              value:'YTO',
-              label:'圆通'
-            },{
-              value:'STO',
-              label:'申通'
-            },{
-              value:'SF',
-              label:'顺丰'
-            },{
-              value:'YUNDA',
-              label:'韵达'
-            },{
-              value:'ZTO',
-              label:'中通'
-            },{
-              value:'ANE',
-              label:'安能'
-            },{
-              value:'DBWL',
-              label:'德邦物流'
-            },{
-              value:'UC',
-              label:'优速'
-            },{
-              value:'POSTB',
-              label:'邮政小包'
-            },{
-              value:'DBKD',
-              label:'德邦快递'
-            },{
-              value:'FENGWANG',
-              label:'丰网速运'
-            },{
-              value:'KYE',
-              label:'跨越物流'
-            },{
-              value:'ZTKY',
-              label:'中通快运'
-            },{
-              value:'JT',
-              label:'极兔'
-            },{
-              value:'JD',
-              label:'京东'
-            },{
-              value:'JGSD',
-              label:'京广速递'
-            },{
-              value:'XNEXPRESS',
-              label:'虚拟快递'
+              value: 'EMS',
+              label: 'EMS'
+            }, {
+              value: 'YTO',
+              label: '圆通'
+            }, {
+              value: 'STO',
+              label: '申通'
+            }, {
+              value: 'SF',
+              label: '顺丰'
+            }, {
+              value: 'YUNDA',
+              label: '韵达'
+            }, {
+              value: 'ZTO',
+              label: '中通'
+            }, {
+              value: 'ANE',
+              label: '安能'
+            }, {
+              value: 'DBWL',
+              label: '德邦物流'
+            }, {
+              value: 'UC',
+              label: '优速'
+            }, {
+              value: 'POSTB',
+              label: '邮政小包'
+            }, {
+              value: 'DBKD',
+              label: '德邦快递'
+            }, {
+              value: 'FENGWANG',
+              label: '丰网速运'
+            }, {
+              value: 'KYE',
+              label: '跨越物流'
+            }, {
+              value: 'ZTKY',
+              label: '中通快运'
+            }, {
+              value: 'JT',
+              label: '极兔'
+            }, {
+              value: 'JD',
+              label: '京东'
+            }, {
+              value: 'JGSD',
+              label: '京广速递'
+            }, {
+              value: 'XNEXPRESS',
+              label: '虚拟快递'
             }]
           }
         }
       }],
       [{
-        label:'备注',
-        prop:'wmsRemark',
-        component:'by-input',
-        compConfig:{
-          attr:{
-            clearable:true
+        label: '备注',
+        prop: 'wmsRemark',
+        component: 'by-input',
+        compConfig: {
+          attr: {
+            clearable: true
           }
         }
       }]
     ]
   }
-  validatePhone(rule:any, value:any, callback:any){
+  validatePhone(rule: any, value: any, callback: any) {
     if (value) {
-      if(!/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(value)) {
-        callback(new Error('手机号格式不正确!'));                                                                                                             
-      }else{
+      if (!/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(value)) {
+        callback(new Error('手机号格式不正确!'));
+      } else {
         callback();
       }
-      
+
     } else {
       callback();
     }
   }
-  setShow(v:boolean){
-    this.drawer=v;
+  setShow(v: boolean) {
+    this.drawer = v;
   }
-  setValue(data:Array<any>){
-    this.data =data;
-    this.value={};
+  setValue(data: Array<any>) {
+    this.data = data;
+    this.value = {};
     this.value.tmsBusinessMan = (this as any).$store.getters.userInfo.nickName;
     this.value.tmsBusinessPhone = (this as any).$store.getters.userInfo.phonenumber;
-    this.value.subItem=[];
+    this.value.subItem = [];
     this.checked = false;
-    const requestId =  new Date().getTime() + this.getUuid();
+    const requestId = new Date().getTime() + this.getUuid();
     this.value.requestId = requestId;
     this.totalWeight = 0;
-    for(let item of data){     
-      if(item.items){
-        for(const i of item.items){
-          let total:any = 0;
-          if(Number(i.qty) && Number(i.price) && i.isGift !== 1){
-            total = multiply(Number(i.qty),Number(i.price))
+    for (let item of data) {
+      if (item.items) {
+        for (const i of item.items) {
+          let total: any = 0;
+          if (Number(i.qty) && Number(i.price) && i.isGift !== 1) {
+            total = multiply(Number(i.qty), Number(i.price))
           }
-          if(Number(i.weight)){
+          if (Number(i.weight)) {
             this.totalWeight = Number(add(this.totalWeight, Number(i.weight)))
           }
           this.value.subItem.push({
-            requestId:requestId,
-            omsOrderId:item.id,
-            omsOrderItemId:i.itemId,
-            tmsGoodsModel:i.styleId,
-            tmsGoodsCode:i.skuId,
-            isGift:i.isGift,
-            barCode:i.barCode,
-            tmsQuantity:Number(i.qty)?Number(i.qty):0,
-            tmsGoodsTotalPrice:total,
-            name:i.name,
-            price:i.isGift === 1 ? 0 : i.price,
-            weight:i.weight
+            requestId: requestId,
+            omsOrderId: item.id,
+            omsOrderItemId: i.itemId,
+            tmsGoodsModel: i.styleId,
+            tmsGoodsCode: i.skuId,
+            isGift: i.isGift,
+            barCode: i.barCode,
+            tmsQuantity: Number(i.qty) ? Number(i.qty) : 0,
+            remainAmount: 0,
+            tmsGoodsTotalPrice: total,
+            name: i.name,
+            price: i.isGift === 1 ? 0 : i.price,
+            weight: i.weight
           })
         }
       }
     }
-    if(this.totalWeight){
-      this.totalWeight = divide(this.totalWeight,1000)?.toFixed(3)
+    if (this.totalWeight) {
+      this.totalWeight = divide(this.totalWeight, 1000)?.toFixed(3)
     }
     this.loadWarehouse()
+    this.getInventory();
     // this.$nextTick(() => {
     //   this.edit()
     // })
   }
+  async getInventory() {
+    let items: any = [];
+    for (const item of this.value.subItem) {
+      items.push(item.barCode)
+    }
+    if (this.value.subItem.length) {
+      const res = await api.getJZJInventory({ wareHouseCode: '', items: items })
+      if (res.data.code != 200) {
+        return;
+      }
+      //将获得的库存设置到this.value.subItem的remainAmount中
+      for (let i = 0; i < this.value.subItem.length; i++) {
+        for (let j = 0; j < res.data.items.length; j++) {
+          if (this.value.subItem[i].barCode == res.data.items[j].barCode) {
+            this.value.subItem[i].remainAmount = res.data.items[j].remainAmount
+          }
+        }
+      }
+
+    }
+  }
   loadWarehouse() {
     api.pageList({
       pageNo: 1,
       pageSize: 1000
     }, 'maindataStorehouse').then((res: any) => {
       let warehouseData = res.data.records;
-      if(warehouseData.length > 0){
+      if (warehouseData.length > 0) {
         // this.value.tmsShipmentConsignor=warehouseData[0].shipper;
         // this.value.tmsShipmentContacts=warehouseData[0].shipperPhone;
         // this.value.tmsShipmentProvince= warehouseData[0].province;
@@ -331,81 +346,94 @@ export default class ExpressDeliveryModal extends Vue {
         // this.value.tmsShipmentStreetNo= warehouseData[0].streetCode;
         // this.value.tmsShipmentStreet= warehouseData[0].street;
         // this.value.tmsShipmentAddress=warehouseData[0].address;
-        this.value.storeHouseId= warehouseData[0].id;
-        this.value.storeHouseName= warehouseData[0].name;
+        this.value.storeHouseId = warehouseData[0].id;
+        this.value.storeHouseName = warehouseData[0].name;
         this.$forceUpdate()
       }
-    }).catch(() => {})
+    }).catch(() => { })
   }
-  getUuid(){
+  getUuid() {
     return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
   }
-  btnEdit(){
-    if(this.$refs.form){
-      (this.$refs.form as any).validate().then(()=>{
+  btnEdit() {
+    if (this.$refs.form) {
+      (this.$refs.form as any).validate().then(() => {
         this.value = (this.$refs.form as any).getValue();
         this.showModal = false;
         // this.getStoreCount(this.value);
-      }).catch(() => {})
+      }).catch(() => { })
     }
-    
+
   }
-  hide(){
+  hide() {
     this.drawer = true;
   }
   //查库存
-  getStoreCount(item:any){
-    let params:any={};
+  getStoreCount(item: any) {
+    let params: any = {};
     params.storeHouseId = item.storeHouseId;
-    params.skuIds=[]
-    if(item.subItem){
-      for(const i of item.subItem){
-        if(params.skuIds.indexOf(i.omsOrderItemId) == -1){
+    params.skuIds = []
+    if (item.subItem) {
+      for (const i of item.subItem) {
+        if (params.skuIds.indexOf(i.omsOrderItemId) == -1) {
           params.skuIds.push(i.omsOrderItemId)
         }
       }
     }
     this.load = true;
-    getInventoryByStoreHouseIdAndSkuids(params).then((res:any) => {
+    getInventoryByStoreHouseIdAndSkuids(params).then((res: any) => {
       this.load = false;
-      let m='';
-      for(const i of item.subItem){
-        for(const d of res.data){
+      let m = '';
+      for (const i of item.subItem) {
+        for (const d of res.data) {
           let s = Number(d.inventory) - Number(d.useInventory) - Number(i.tmsQuantity);
-          if(i.omsOrderItemId == d.skuid && s < 0){
-            m = m ? m + ',' + i.name : i.name;          
-          }else{
+          if (i.omsOrderItemId == d.skuid && s < 0) {
+            m = m ? m + ',' + i.name : i.name;
+          } else {
             d.inventory = subtract(d.inventory, i.tmsQuantity);
           }
         }
       }
-      if(m){
+      if (m) {
         this.$message({
-          message:'商品“'+m+'”库存不足!',
-          type:'error'
+          message: '商品“' + m + '”库存不足!',
+          type: 'error'
         })
         this.stopHandle = true;
         return
       }
-    }).catch(()=>{
+    }).catch(() => {
       this.load = false;
     })
   }
-  show(){
-    
-    this.$nextTick(()=>{
-      if(this.$refs.form){
+  show() {
+
+    this.$nextTick(() => {
+      if (this.$refs.form) {
         (this.$refs.form as any).clearValue();
         (this.$refs.form as any).setValue(this.value);
       }
     })
   }
-  edit(){
+  edit() {
     this.showModal = true;
     this.drawer = false;
   }
-  
+  //判断库存是否充足
+  checkInventory() {
+    let m = '';
+    for (const item of this.value.subItem) {
+      if (item.remainAmount <= 0) {
+        return false;
+      }
+    }
+    return true;
+  }
+
   btn() {
+    if (!this.checkInventory()) {
+      this.$message('订单商品暂无库存');
+    }
     // if(this.stopHandle){
     //   this.$message('库存不足!')
     //   return
@@ -414,38 +442,38 @@ export default class ExpressDeliveryModal extends Vue {
     //   this.$message('请阅读并同意运单协议!')
     //   return
     // }
-    let params:any=(this as any).$lodash.cloneDeep(this.value);
-    params.omsOrderIds=[]
-    for(const item of this.data){
+    let params: any = (this as any).$lodash.cloneDeep(this.value);
+    params.omsOrderIds = []
+    for (const item of this.data) {
       params.omsOrderIds.push(item.id);
     }
-    params.tmsMaterials=[];
-    if(this.value.subItem){
-      let skuIds:Array<any>=[];
-      for(const item of this.value.subItem){
-        if(skuIds.indexOf(item.omsOrderItemId) == -1){
+    params.tmsMaterials = [];
+    if (this.value.subItem) {
+      let skuIds: Array<any> = [];
+      for (const item of this.value.subItem) {
+        if (skuIds.indexOf(item.omsOrderItemId) == -1) {
           skuIds.push(item.omsOrderItemId);
           params.tmsMaterials.push({
-            storeHouseId:this.value.storeHouseId,
-            materialSkuId:item.omsOrderItemId
+            storeHouseId: this.value.storeHouseId,
+            materialSkuId: item.omsOrderItemId
           })
         }
-        
+
       }
     }
     delete params.subItem;
     this.load = true;
-    express(params).then((res:any) => {
+    express(params).then((res: any) => {
       this.load = false;
-      if(res.code == 200){
+      if (res.code == 200) {
         this.$message({
-          message:'订单发货成功!',
-          type:'success'
+          message: '订单发货成功!',
+          type: 'success'
         })
         this.$emit('handleSuccess');
-        this.drawer=false;
+        this.drawer = false;
       }
-    }).catch(()=>{  
+    }).catch(() => {
       this.load = false;
     })
   }
@@ -453,91 +481,110 @@ export default class ExpressDeliveryModal extends Vue {
 </script>
 
 <style lang="scss" scoped>
-.content{
+.content {
   width: 100%;
   box-sizing: border-box;
   padding: 0 16px;
   background-color: #FFF;
-  .info{
+
+  .info {
     width: 100%;
-    .edit{
+
+    .edit {
       width: 100%;
       display: flex;
       justify-content: flex-end;
       padding-bottom: 8px;
-      span{
+
+      span {
         color: rgb(0, 119, 255);
         font-size: 14px;
         cursor: pointer;
       }
     }
-    .g-box{
+
+    .g-box {
       width: 100%;
-      background-color: rgba(160,205,255,0.22);
+      background-color: rgba(160, 205, 255, 0.22);
       margin-bottom: 16px;
-      padding:16px;
+      padding: 16px;
       box-sizing: border-box;
-      .info-row{
+
+      .info-row {
         width: 100%;
         display: flex;
         padding-bottom: 16px;
-        .info-col{
+
+        .info-col {
           width: 100%;
           overflow: hidden;
           text-overflow: ellipsis;
           white-space: nowrap;
-          span{
+
+          span {
             font-size: 14px;
           }
-          .label{
+
+          .label {
             color: #666;
           }
-          .time{
+
+          .time {
             color: #F00;
           }
         }
-        .col-width{
+
+        .col-width {
           width: 50%;
         }
       }
-      .info-row:last-child{
+
+      .info-row:last-child {
         padding: 0;
       }
-      .goods-top{
+
+      .goods-top {
         padding-bottom: 8px;
         width: 100%;
         display: flex;
         align-items: center;
         justify-content: space-between;
-        .g-label{
+
+        .g-label {
           font-size: 14px;
         }
-        .g-cont{
+
+        .g-cont {
           width: 60%;
           display: flex;
           align-items: center;
           justify-content: flex-end;
-          .g-total{
+
+          .g-total {
             padding-left: 8px;
             font-size: 12px;
-            .name-label{
+
+            .name-label {
               color: #999;
             }
           }
         }
       }
-      .table{
+
+      .table {
         width: 100%;
       }
     }
-    .btn{
+
+    .btn {
       width: 100%;
       display: flex;
       justify-content: flex-end;
     }
   }
 }
-.deli-footer{
+
+.deli-footer {
   height: 60px;
   width: 100%;
   padding: 0 16px;
@@ -551,28 +598,33 @@ export default class ExpressDeliveryModal extends Vue {
   left: 0;
   bottom: 0;
   z-index: 10;
-  .d-left{
+
+  .d-left {
     width: 70%;
-    .estimate-total{
+
+    .estimate-total {
       font-size: 14px;
       padding-bottom: 4px;
-      .total{
+
+      .total {
         font-size: 16px;
         color: #F00;
       }
-      .detail{
+
+      .detail {
         color: #1684FC;
         padding-left: 16px;
         cursor: pointer;
       }
     }
   }
-  .send-btn{
+
+  .send-btn {
     width: 120px;
     height: 40px;
     line-height: 40px;
     border-radius: 8px;
-    background: linear-gradient(129.2deg, rgba(22,132,252,1) 9.81%,rgba(93,167,249,1) 97.4%);
+    background: linear-gradient(129.2deg, rgba(22, 132, 252, 1) 9.81%, rgba(93, 167, 249, 1) 97.4%);
     color: rgba(255, 255, 255, 100);
     font-size: 14px;
     text-align: center;
@@ -580,7 +632,8 @@ export default class ExpressDeliveryModal extends Vue {
     cursor: pointer;
   }
 }
-.space{
+
+.space {
   height: 60px;
   width: 100%;
   margin-top: 16px;

+ 5 - 2
src/views/oms/B2BOrder/components/orderTable.vue

@@ -62,9 +62,12 @@
         {{ getFromText(row.operationFlag) }}
       </template>
     </vxe-column>
-    <vxe-column field="orderTimeout" title="待处理时长" width="110">
+    <vxe-column field="orderTimeout" title="待处理时长" width="180">
       <template #default="{ row }">
-        <span v-if="row.isOrderTimeout" style="color:red">{{ row.orderTimeout }}</span>
+        <span v-if="row.isOrderTimeout" style="color:red">
+          <el-tag type="danger">已超时</el-tag>
+          {{ row.orderTimeout }}
+        </span>
         <span v-else="row.isOrderTimeout">{{ row.orderTimeout }}</span>
       </template>
     </vxe-column>

+ 3 - 1
src/views/oms/B2BOrder/index.vue

@@ -1041,9 +1041,11 @@ export default class Order extends Vue {
   handleAutoAudit(v) {
     autoAudit(v).then((res: any) => {
       (this as any).$message({
-        message: res.msg ? res.msg : '提交成功',
+        message: '提交成功',
         type: 'success'
       });
+      //本地缓存
+      localStorage.setItem('autoAudit', JSON.stringify(v));
     })
   }