pages/AGV/AGVPakin.vue
@@ -2,9 +2,9 @@
   <view>
      <view class="code">
         <view class="item">
            <view class="code-decs">订单号:</view>
            <input type="text" placeholder=" 扫码 / 输入" v-model="orderNo" :focus="orderNoFocus"
               @input="orderNoInput()">
            <view class="code-decs">站点号:</view>
            <input type="text" placeholder=" 扫码 / 输入" v-model="rsta" :focus="rstaFocus"
               @input="rstaInput()">
         </view>
         <view class="item">
            <view class="code-decs">托盘码:</view>
@@ -19,6 +19,17 @@
               <text style="text-align: right;color: #409EFF;" @click="selectMat()">提取+</text>
               <uni-icons type="right" color="#c1c1c1"></uni-icons>
            </view>
         </view>
         <view class="item">
         <view class="code-decs" style="width: 25vw;">大小托盘:</view>
         <radio-group @change="isFullPlt">
            <label>
               <radio :checked="ck1" style="transform: scale(0.7)"/><text>小托盘</text>
            </label>
            <label>
               <radio :checked="ck2" style="margin-left: 50rpx;transform: scale(0.7);"/><text>大托盘</text>
            </label>
         </radio-group>
         </view>
      </view>
      <view class="mat-list-title">
@@ -69,9 +80,10 @@
         </view>
      </scroll-view>
      <!-- 底部操作按钮 -->
      <view class="buttom">
         <button size="mini" @click="reset('warn')">重置</button>
      <view class="buttom">、
         <button size="mini" type="primary" @click="combConfirm('warn')">组托</button>
         <button size="mini" @click="reset('warn')">重置</button>
         <button size="mini" type="primary" @click="combConfirmAndFillEmptyPallets('warn')">组托并补空托盘</button>
      </view>
      <!-- 弹窗 -->
      <!-- 修改数量 -->
@@ -129,6 +141,13 @@
               @confirm="comb" @close="combClose"></uni-popup-dialog>
         </uni-popup>
      </view>
      <view>
         <uni-popup ref="combConfirmAndFillEmptyPallets" type="dialog">
            <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" :title="title" :content="content"
               @confirm="combAndFillEmptyPallets" @close="combClose"></uni-popup-dialog>
         </uni-popup>
      </view>
      <!-- 确认重置 -->
      <view>
         <uni-popup ref="resetConfirm" type="dialog">
@@ -146,7 +165,7 @@
            baseUrl: '',
            token: '',
            barcode: '',
            orderNo: '',
            rsta: '',
            dataList: [],
            count: 0,
            rowNum: '',
@@ -160,9 +179,12 @@
            content: '',
            barcodeFocus: true,
            matFocus: false,
            orderNoFocus: false,
            rstaFocus: false,
            matData: '',
            removeNum: 0,
            ck1: true,
            ck2: false,
            fullPlt: '1'
         }
      },
      onLoad() {
@@ -173,15 +195,26 @@
         this.token = uni.getStorageSync('token');
      },
      methods: {
         // 大小托盘
         isFullPlt() {
            var temp = this.ck1
            this.ck1 = this.ck2
            this.ck2 = temp
            if (this.ck1) {
               this.fullPlt = '1'
            } else {
               this.fullPlt = '2'
            }
         },
         messageToggle(type) {
            this.msgType1 = type
            this.$refs.message.open()
         },
         // barcode input 事件
         orderNoInput() {
         rstaInput() {
            // 不设置定时器 会出现扫入的字符串不全
            setTimeout(() => {
               var len = this.orderNo.length
               var len = this.rsta.length
               this.barcodeFocuss()
            }, 200)
         },
@@ -189,7 +222,7 @@
            // 不设置定时器 会出现扫入的字符串不全
            setTimeout(() => {
               var len = this.barcode.length
               if (len != 10) {
               if (len != 8) {
                  uni.showToast({
                     title: '托盘码有误请重试',
                     icon: "none",
@@ -219,15 +252,8 @@
            }, 100);
         },
         // 搜索物料
         findMat() {
            findMat() {
            let that = this
            // 判断物料长度是否为1
            if (that.dataList.length >= 1) {
               this.messageText = "只能添加一种物料"
               this.messageToggle('warn')
               that.matnr = ''
               return
            }
            uni.request({
               url: that.baseUrl + '/mat/auth',
               data: {
@@ -247,8 +273,10 @@
                        // 通过eventChannel向被打开页面传送数据
                        success: function(res) {
                           res.eventChannel.emit('mat', {
                              data: result.data
                           })
                           console.log(res);
                        },
                        // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                        events: {
@@ -322,12 +350,13 @@
                        add = true
                     }
                     
                  } else {
                     // 相同物料相同批号 数量累加
                     this.dataList[i].anfme += mat.anfme
                     this.$forceUpdate() // 强制刷新
                     add = false
                  }
                  }
                  // else {
                  //    // 相同物料相同批号 数量累加
                  //    this.dataList[i].anfme += mat.anfme
                  //    this.$forceUpdate() // 强制刷新
                  //    add = false
                  // }
               }
            }
            if (add) {
@@ -386,10 +415,17 @@
            this.content = '是否现在组托!'
            this.$refs.combConfirm.open()
         },
         combConfirmAndFillEmptyPallets(type) {
            this.msgType = type
            this.title = '警告'
            this.content = '是否现在组托并补空板!'
            this.$refs.combConfirmAndFillEmptyPallets.open()
         },
         combClose() {
            this.$refs.combConfirm.close()
         },
         comb() {
            console.log("普通组托")
            uni.vibrateShort();
            let that = this;
            if (that.barcode === '') {
@@ -410,9 +446,69 @@
               }
            }
            uni.request({
               url: that.baseUrl + '/agvMobile/comb/auth',
               url: that.baseUrl + '/mobile/comb/auth',
               data: JSON.stringify({
                  orderNo: that.orderNo,
                  beBatch : 1,
                  barcodeSize: '0',
                  rsta: that.rsta,
                  barcode: that.barcode,
                  combMats: that.dataList
               }),
               method: 'POST',
               header: {
                  'token': uni.getStorageSync('token')
               },
               success(result) {
                  var res = result.data
                  if (res.code === 200) {
                     that.resst();
                     that.messageText = "组托成功"
                     that.messageToggle('success')
                     const innerAudioContext = uni.createInnerAudioContext();
                     innerAudioContext.src = '/static/music/pakinOk.mp3';
                     innerAudioContext.play()
                  } else if (res.code == 403) {
                     that.messageText = res.msg
                     that.messageToggle('error')
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     that.messageText = res.msg
                     that.messageToggle('error')
                  }
               }
            });
         },
         //组托并补空托盘
         combAndFillEmptyPallets() {
            uni.vibrateShort();
            let that = this;
            if (that.barcode === '') {
               this.messageText = "请扫描托盘条码"
               this.messageToggle('error')
               return;
            }
            if (that.dataList.length === 0) {
               this.messageText = "请添加商品列表"
               this.messageToggle('error')
               return;
            }
            for (var i = 0; i < that.dataList.length; i++) {
               if (that.dataList[i].anfme == 0 || that.dataList[i].anfme == '') {
                  this.messageText = that.dataList[i].matnr + '组托数量不能为0'
                  this.messageToggle('error')
                  return;
               }
            }
            uni.request({
               url: that.baseUrl + '/mobile/comb/auth',
               data: JSON.stringify({
                  beBatch : 1,
                  barcodeSize : this.fullPlt,
                  rsta: that.rsta,
                  barcode: that.barcode,
                  combMats: that.dataList
               }),