#
whycq
2024-03-19 cd45d9d2347927933e51c2d81cf77b430c6a68c0
pages/tzsk/AGV/AGVPick.vue
@@ -2,31 +2,80 @@
   <view>
      <view class="code">
         <view class="item">
            <view class="code-decs">楼号:</view>
            <uni-combox :candidates="floorList" placeholder="请选择楼号" v-model="floor" @input="getFloor"></uni-combox>
            <view class="code-decs">采购单号:</view>
            <input type="text" placeholder=" 扫码 / 输入" v-model="orderNo" :focus="orderNoFocus"
               @input="findOrder()">
         </view>
         <view class="item">
            <view class="code-decs">暂存位:</view>
            <input type="text" placeholder=" 扫码 / 输入" v-model="stationCode" :focus="stationCodeFocus"
               @input="stationCodeInput()">
            <view class="code-decs">料箱码:</view>
            <input type="text" placeholder=" 扫码 / 输入" v-model="barcode" :focus="barcodeFocus"
               @input="barcodeInput()">
         </view>
      </view>
      <view class="mat-list-title">
         <view style="-webkit-flex: 1;flex: 1;"></view>
         <view style="-webkit-flex: 1;flex: 1;">站点列表</view>
         <view style="-webkit-flex: 1;flex: 1;"><button size="mini" @click="selectAll()">{{btnText}}</button></view>
         商品列表
      </view>
      <scroll-view>
         <view class="list" v-for="(item,i) in dataList" :key="i" :class="'bg-'+item.color">
            <view class="aside">
               <checkbox :value="item.matnr" :checked="item.checked" @click="set(i)"/>
            </view>
            <view class="list-left" style="display: flex;justify-content: center;">
               {{item.devNo}}
         <view class="list" v-for="(item,i) in dataList" :key="i">
            <view class="list-left">
               <view class="list-left-item">
                  <view class="desc">No:</view>
                  <view class="left-item">{{i + 1}}</view>
               </view>
               <!-- <view class="list-left-item">
                  <view class="desc">箱码:</view>
                  <view class="left-item">
                     <input type="text" v-model="item.containerCode">
                     <uni-tag :text="item.containerCode" type="primary"></uni-tag>
                  </view>
               </view> -->
               <view class="list-left-item">
                  <view class="desc">销售单号:</view>
                  <view class="left-item">
                     <input type="text" v-model="item.csocode">
                     <!-- <uni-tag :text="item.containerCode" type="primary"></uni-tag> -->
                  </view>
               </view>
               <view class="list-left-item">
                  <view class="desc">订单行号:</view>
                  <view class="left-item">
                     <input type="text" v-model="item.isoseq">
                     <!-- <uni-tag :text="item.containerCode" type="primary"></uni-tag> -->
                  </view>
               </view>
               <view class="list-left-item">
                  <view class="desc">料号:</view>
                  <view class="left-item">
                     <uni-tag :text="item.matnr" type="primary"></uni-tag>
                  </view>
               </view>
               <view class="list-left-item">
                  <view class="desc">品名:</view>
                  <view class="left-item">{{item.maktx}}</view>
               </view>
               <view class="list-left-item">
                  <view class="desc">规格:</view>
                  <view class="left-item">{{item.specs}}</view>
               </view>
               <view class="list-left-item">
                  <view class="desc">批号:</view>
                  <view class="left-item">
                     <uni-tag :text="item.batch" type="warning"></uni-tag>
                  </view>
               </view>
               <!-- <view class="list-left-item">
                  <view class="desc">重量:</view>
                  <view class="left-item">
                     <uni-tag :text="item.weight" type="warning"></uni-tag>
                  </view>
               </view> -->
               <view class="list-left-item">
                  <view class="desc">数量:</view>
                  <view class="left-item">{{item.anfme}}</view>
               </view>
            </view>
            <view class="list-right">
               <!-- <uni-icons type="compose" color="#9add8b" size="24" @click="revise(item,i)"></uni-icons> -->
               <uni-icons type="compose" color="#9add8b" size="24" @click="revise(item,i)"></uni-icons>
               <uni-icons type="trash" color="#f58a8a" size="24" @click="remove(item,i,'warn')"></uni-icons>
            </view>
         </view>
@@ -34,8 +83,7 @@
      <!-- 底部操作按钮 -->
      <view class="buttom">
         <button size="mini" @click="reset('warn')">重置</button>
         <button size="mini" type="primary" @click="containerMove()">容器离场</button>
         <button size="mini" type="primary" @click="containerPick()">盘点 / 拣货</button>
         <button size="mini" type="primary" @click="combConfirm('warn')">组托</button>
      </view>
      <!-- 弹窗 -->
      <!-- 修改数量 -->
@@ -45,20 +93,20 @@
               <!-- 标题 -->
               <view class="title">修改</view>
               <view class="popup-item">
                  <view class="popup-item-left">编码:</view>
                  <view class="popup-item-left">料号:</view>
                  <view class="popup-item-right">
                     <input type="text" v-model="matnr" disabled="true"
                        style="background-color: #f7f7f7;padding: 0;color: #d5d5d5;">
                  </view>
               </view>
               <!-- <view class="popup-item">
               <view class="popup-item">
                  <view class="popup-item-left">批号:</view>
                  <view class="popup-item-right"><input type="text" v-model="batch"></view>
               </view> -->
               <view class="popup-item">
               </view>
               <!-- <view class="popup-item">
                  <view class="popup-item-left">重量:</view>
                  <view class="popup-item-right"><input type="text" v-model="weight"></view>
               </view>
               </view> -->
               <view class="popup-item">
                  <view class="popup-item-left">数量:</view>
                  <view class="popup-item-right" style="border: none;justify-content: center;">
@@ -86,7 +134,7 @@
            <uni-popup-message :type="msgType1" :message="messageText" :duration="2000"></uni-popup-message>
         </uni-popup>
      </view>
      <!-- 确认启动 -->
      <!-- 确认组托 -->
      <view>
         <uni-popup ref="combConfirm" type="dialog">
            <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" :title="title" :content="content"
@@ -100,6 +148,10 @@
               @confirm="resetConfirm" @close="resetClose"></uni-popup-dialog>
         </uni-popup>
      </view>
      <view class="keyboard" :class="hidebg" mode="aspectFit" @click="hideKeyboard">
         <image src="@/static/img/keyboard1.png" style="height: 70%;width: 70%;"></image>
      </view>
   </view>
</template>
@@ -110,12 +162,8 @@
            baseUrl: '',
            token: '',
            barcode: '',
            stationCode: '',
            stationCodeFocus: true,
            dataList: [
               // {matnr:'12321321',devNo:'rk123123',color:'red'},
               // {matnr:'12321321',devNo:'rk123123',color:'white'},
               ],
            orderNo: '',
            dataList: [],
            count: 0,
            rowNum: '',
            matnr: '',
@@ -126,137 +174,117 @@
            messageText: '',
            title: '',
            content: '',
            barcodeFocus: true,
            orderNoFocus: true,
            barcodeFocus: false,
            matFocus: false,
            matData: '',
            removeNum: 0,
            floorList: [1,3],
            floor: "",
            devNo: [],
            btnText: '全选',
            tempOrderInfo: {csocode: '',isoseq: ''},
            hide: true,
            hidebg: 'kb-bgtr'
         }
      },
      onLoad() {
         // #ifdef APP
         setInterval(()=>{
            if (this.hide) {
               uni.hideKeyboard()
            } else {
            }
         },20)
         // #endif
      },
      onBackPress() {
         this.hide = false
      },
      onShow() {
         this.baseUrl = uni.getStorageSync('baseUrl');
         this.token = uni.getStorageSync('token');
      },
      methods: {
         stationCodeInput() {
            setTimeout(() => {
               var len = this.stationCode.length
               if (len != 15) {
                  this.stationCode = ''
                  this.stationCodeFocus = true
                  uni.showToast({
                     title: '暂存码有误请重试',
                     icon: "none",
                     position: 'top'
                  });
                  return;
               }
               this.pushDevNo()
               this.stationCodeFocuss()
            }, 200)
         },
         pushDevNo() {
            var devNo = {"devNo":this.stationCode}
            if (this.dataList.length == 0) {
               this.dataList.push(devNo)
               return
            }
            var flag = false
            for(var i = 0; i < this.dataList.length; i++ ) {
               if (this.dataList[i].devNo == devNo.devNo) {
                  this.messageText = "站点重复"
                  this.messageToggle('warn')
                  return
               } else {
                  flag = true
               }
            }
            if(flag) {
               this.dataList.push(devNo)
            }
         },
         stationCodeFocuss() {
            let that = this;
            this.stationCode = ''
            that.stationCodeFocus = false;
            setTimeout(() => {
               that.stationCodeFocus = true;
            }, 100);
         },
         getChecked() {
            var checkedList = []
            for(var i = 0; i < this.dataList.length; i++) {
               var t = !this.dataList[i].checked
               if (this.dataList[i].checked) {
                  checkedList.push(this.dataList[i])
               }
            }
            this.dataList = checkedList
         },
         set(i) {
            var ck = this.dataList[i].checked
            this.dataList[i].checked = ck ? false:true
         },
         selectAll() {
            if (this.btnText == '全选') {
               for (let i in this.dataList) {
                  this.$set(this.dataList[i],'checked',true)
                  this.btnText = '取消'
               }
         hideKeyboard() {
            this.hide = this.hide ? false : true
            if (this.hide) {
               this.hidebg = 'kb-bgtr'
            } else {
               for (let i in this.dataList) {
                  var ck = this.dataList[i].checked
                  this.dataList[i].checked = false
                  this.btnText = '全选'
               }
               this.hidebg = 'kb-bgfa'
            }
         },
         getFloor() {
         // 根据订单号返回商品详情
         findOrder() {
            let that = this
            if (this.floor == '') {
               return
            }
            that.tempOrderInfo.csocode = ''
            that.tempOrderInfo.isoseq = ''
            uni.request({
               url: that.baseUrl + '/agvMobile/getBasDevp/auth',
               url: that.baseUrl + '/mobile/order/search/orderNo/auth',
               header: {'token': uni.getStorageSync('token')},
               data: {
                  floor: that.floor
                  orderNo: that.orderNo
               },
               header: {
                  'token': uni.getStorageSync('token')
               },
               method: 'POST',
               success(res) {
                  res = res.data
                  for(var i = 0; i < res.data.length; i++) {
                     if (res.data[i].locSts === 'F') {
                        // res.data[i]["color"] = "red"
                        that.dataList.push(res.data[i])
                  console.log(res);
                  if (res.code === 200) {
                     if(res.data && res.data[0].combMats) {
                        for (let i = 0; i < res.data[0].combMats.length; i++) {
                           that.checkMat(res.data[0].combMats[i])
                        }
                        that.orderNoFocus = false
                        setTimeout(() => {
                           that.barcodeFocus = true
                        }, 10);
                     } else {
                        // uni.showToast({
                        //    title: that.orderNo + '请检查订单号是否正确',
                        //    icon: "none",
                        //    position: 'top'
                        // })
                     }
                  } 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'
                     })
                  }
               }
            });
            })
         },
         messageToggle(type) {
            this.msgType1 = type
            this.$refs.message.open()
         },
         // barcode input 事件
         barcodeInput() {
         orderNoInput() {
            // 不设置定时器 会出现扫入的字符串不全
            setTimeout(() => {
               var len = this.barcode.length
               if (len != 8) {
               var len = this.orderNo.length
               this.barcodeFocuss()
            }, 200)
         },
         barcodeInput() {
            // 不设置定时器 会出现扫入的字符串不全
            if (this.barcode.split('_')[1]) {
               this.barcode = this.barcode.split('_')[1]
            }
            // this.barcode = this.barcode.split('_')[1]
            setTimeout(() => {
               let len = this.barcode.length
               if (len != 10) {
                  uni.showToast({
                     title: '托盘码有误请重试',
                     title: '料箱码有误请重试',
                     icon: "none",
                     position: 'top'
                  });
@@ -286,14 +314,17 @@
         // 搜索物料
         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: {
                  matnr: that.matnr
               },
               header: {
                  'token': uni.getStorageSync('token')
               },
               data: { matnr: that.matnr },
               header: { 'token': uni.getStorageSync('token') },
               success(result) {
                  result = result.data
                  if (result.code === 200 && result.data) {
@@ -301,16 +332,19 @@
                     that.matnr = ''
                     that.matData['batch'] = ''
                     uni.navigateTo({
                        url: "../mat/matSelected",
                        url: "../../mat/matSelected",
                        // 通过eventChannel向被打开页面传送数据
                        success: function(res) {
                           res.eventChannel.emit('mat', {
                              data: result.data
                              data: result.data,
                              // tempOrderInfo: that.tempOrderInfo
                           })
                        },
                        // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                        events: {
                           matList: function(data) {
                              data.data['csocode'] = ''
                              data.data['isoseq'] = ''
                              that.checkMat(data.data)
                              that.focuss()
                           },
@@ -342,7 +376,7 @@
         selectMat() {
            let that = this
            uni.navigateTo({
               url: "../mat/matQuery",
               url: "../../mat/matQuery",
               success: function(res) {
                  // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                  res.eventChannel.emit('commonUrl', {
@@ -441,25 +475,47 @@
         combConfirm(type) {
            this.msgType = type
            this.title = '警告'
            this.content = '是否现在启动!'
            this.content = '是否现在组托!'
            this.$refs.combConfirm.open()
         },
         combClose() {
            this.$refs.combConfirm.close()
         },
         comb() {
            this.devNo = []
            uni.vibrateShort();
            let that = this;
            for (var i = 0; i < this.dataList.length; i++) {
               if (this.dataList[i].checked) {
                  this.devNo.push(this.dataList[i].devNo)
            if (that.barcode === '') {
               this.messageText = "请扫描托盘条码"
               this.messageToggle('error')
               return;
            }
            if (that.dataList.length === 0) {
               this.messageText = "请添加商品列表"
               this.messageToggle('error')
               return;
            }
            // if (that.dataList.length > 1) {
            //    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;
               }
            }
            console.log(that.dataList);
            console.log(that.barcode);
            console.log(that.orderNo);
            // return
            uni.request({
               url: that.baseUrl + '/agvMobile/pakin/auth',
               url: that.baseUrl + '/agvMobile/comb/auth',
               data: JSON.stringify({
                  devNo: that.devNo
                  orderNo: that.orderNo,
                  barcode: that.barcode,
                  combMats: that.dataList
               }),
               method: 'POST',
               header: {
@@ -468,9 +524,15 @@
               success(result) {
                  var res = result.data
                  if (res.code === 200) {
                     that.resst();
                     that.messageText = "启动成功"
                     that.dataList = []
                     that.findOrder()
                     // that.resst();
                     that.barcode = ''
                     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')
@@ -495,8 +557,8 @@
         // 确认重置
         resetConfirm() {
            this.dataList = []
            this.stationCode = ''
            this.floor = ''
            this.barcode = ''
            this.orderNo = ''
            this.messageText = "重置完成"
            this.messageToggle('success')
         },
@@ -508,8 +570,7 @@
         resst() {
            this.dataList = []
            this.barcode = ''
            this.stationCode = ''
            this.floor = ''
            this.orderNo = ''
            this.barcodeFocuss()
         },
      }
@@ -519,28 +580,25 @@
<style>
   @import url('../../../static/css/wms.css/wms.css');
   .bg-red {
      background-color: #e54d42;
      color: #ffffff;
   .keyboard{
      width: 40px;height: 40px;background-size: 100%;position: absolute;z-index: 99;
         top: 5px;right: 5px; border-radius: 50%;
         display: flex;align-items: center;justify-content: center;
   }
   .bg-white {
      background-color: #ffffff;
      color: #666666;
   .kb-bgtr {
      background-color: #55557f;
   }
   .kb-bgfa {
      background-color: #00aeec;
   }
   .list:first-child {
      margin-top: 360rpx;
   }
   .aside {
      width: 100rpx;
      /* background-color: #303133; */
      display: flex;
      align-items: center;
      justify-content: center;
      margin-top: 340rpx;
   }
   .code {
      width: 100%;
      position: fixed;
      min-height: 100rpx;
      min-height: 140rpx;
      background-color: #FFF;
      z-index: 10;
   }
@@ -548,7 +606,7 @@
   .item {
      display: flex;
      align-items: center;
      height: 100rpx;
      height: 70rpx;
      margin-left: 20rpx;
      border-bottom: 1px solid #DCDFE6;
   }
@@ -564,7 +622,6 @@
   }
   .code-decs {
      width: 20vw;
      font-size: 18px;
      color: #303133;
   }
@@ -575,16 +632,15 @@
   }
   .mat-list-title {
      display: flex;
      align-items: center;
      height: 80rpx;
      line-height: 80rpx;
      width: 100%;
      background-color: white;
      position: fixed;
      margin-top: 200rpx;
      margin-top: 140rpx;
      z-index: 9;
      /* border-top: 1px solid #DCDFE6; */
      text-align: center;
      box-shadow: 0px 0px 30px 0px rgba(0, 0, 0, 0.5);
      box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.5);
   }
</style>