#
whycq
2022-06-17 292c3ed952ff6eb9e5a44de1d41786702146c876
pages/basics/matOut.vue
@@ -9,7 +9,7 @@
            
            <view class="title" >出库口:</view>
            <view class="combox" >
               <uni-combox :candidates="candidates" placeholder="请选择出库站点" v-model="city"></uni-combox>
               <uni-combox :candidates="sites" placeholder="请选择出库站点" v-model="siteId" @click="staNoSelect()"></uni-combox>
            </view>
         </view>
      </form>
@@ -31,9 +31,10 @@
         </uni-table>
      </view>
      
      <view class="cu-bar foot justify-center input" style="height: 130rpx;">
         <view class="reset flex solid-bottom padding justify-center" >
            <button class="cu-btn bg-yellow main-btn margin-xs" style="width: 400rpx;">启动出库</button>
      <view class="cu-bar foot input" style="height: 130rpx;">
         <view class="flex solid-bottom padding justify-start">
            <button class="cu-btn bg-yellow main-btn margin-xs" style="width: 430rpx;" @click="outbound()">启动出库</button>
            <button class="cu-btn bg-grey main-btn margin-xs" @click="reset">重 置</button>
         </view>
      </view>
      
@@ -45,9 +46,9 @@
      data() {
         return {
            billNo: null,
            matData:[],
            candidates: ['北京', '南京', '东京', '武汉', '天津', '上海', '海口'],
            city: ''
            matData: [],
            sites: [],
            siteId: ''
         }
      },
      mounted(){
@@ -55,6 +56,7 @@
         this.baseIP = UIP;
         const UPORT = uni.getStorageSync('UPORT');
         this.basePORT = UPORT;
         this.staNoSelect();
      },
      methods: {
         searchBillNo() {
@@ -69,21 +71,88 @@
                  bill_no:that.billNo
               },
               success(result) {
                  let res = result.data
                  if (res.code === 200 ) {
                     that.matData = res.data.records
                     console.log(that.matData)
                  } else if (res.code === 403) {
                     uni.navigateBack({
                         delta: 1
                     })
                     that.staNoSelect()
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               },
            })
         },
         staNoSelect() {
            let that = this;
            uni.request({
               url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + "/available/take/site",
               header: {'token':uni.getStorageSync('token')},
               success(result) {
                  let res = result.data
                  if (res.code === 200 ) {
                     that.sites = [];
                     for (var i = 0; i < res.data.length; i++) {
                        that.sites.push(res.data[i].desc)
                     }
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            })
         },
         outbound() {
            let that = this
            if (that.matData.length === 0) {
               uni.showToast({title: "请先添加产品", icon: "none",position: 'top'})
            } else {
               if (that.siteId == '') {
                  uni.showToast({title: "请选择出库口", icon: "none",position: 'top'})
                  return;
               }
            };
            var staNo = that.siteId.substring(0,3)
            var locDetls = [];
            that.matData.forEach(function(elem) {
               locDetls.push({billNo:elem.billNo,seqNo:elem.seqNo, matNo: elem.matNo, count: elem.qty,});
            });
            let param = {
               outSite: 173,
               locDetls: locDetls
            }
            uni.request({
               url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + "/mat/out/start",
               header: {
                  'token':uni.getStorageSync('token')},
               data: JSON.stringify(param),
               method:"POST",
               success(result) {
                  if (result.data.code === 200) {
                     uni.showToast({title: result.data.msg, icon: "none",position: 'top'})
                     that.reset()
                  } else {
                     uni.showToast({title: result.data.msg, icon: "none",position: 'top'})
                  }
               }
            })
         },
         reset() {
            this.billNo = '';
            this.matData = [];
            this.siteId = '';
         }
      }
   }