whycq
2024-10-18 2b5bf2b63f6b8718a396f16f02c682f635744425
pages/phyz/order/orderCar.vue
@@ -1,6 +1,6 @@
<template>
   <view>
      <view class="list list-font-color shop-car" :class="orderDetl.color" v-for="orderDetl in orderCarList" >
      <view class="list list-font-color shop-car" :class="orderDetl.color" v-for="(orderDetl,index) in orderCarList" :key="index">
         <view class="list-left">
            <view class="detl-threeCode">{{orderDetl.threeCode}}</view>
            <view>主单号:{{orderDetl.orderNo}}</view>
@@ -9,7 +9,7 @@
            <view>总数量:{{orderDetl.anfme}}</view>
            <view>入库数量:{{orderDetl.pakinQty}}</view>
         </view>
         <view class="list-right" @click="chageDetl(orderDetl)">
         <view class="list-right" @click="chageDetl(index)">
            <uni-icons type="settings" size="25"  color="#fff"></uni-icons>
         </view>
      </view>
@@ -29,8 +29,29 @@
                  <uni-number-box :value="count" :step='1' :max="9999999" color="#747474" @change="changeValue" />
               </view>
               <view class="btn">
                  <view class="btn-left" @click="addClose">取消</view>
                  <view class="btn-right" @click="addConfirm()">添加</view>
                  <view class="btn-left" @click="remove()">移除物料</view>
                  <view class="btn-right" @click="changeCount()">修改数量</view>
               </view>
            </view>
         </uni-popup>
      </view>
      <!-- 弹窗 -->
      <view>
         <uni-popup ref="agvStart" type="dialog">
            <view class="popup">
               <!-- 标题 -->
               <view class="title">启动入库</view>
               <view class="popup-item">
                  <view class="popup-item-left">货架码:</view>
                  <view class="popup-item-right"><input type="text" v-model="barcode"></view>
               </view>
               <view class="popup-item">
                  <view class="popup-item-left">站点码:</view>
                  <view class="popup-item-right"><input type="text" v-model="agvDevp"></view>
               </view>
               <view class="btn">
                  <button class="btn-left" @click="agvStartClose()">取消</button>
                  <button class="btn-right" @click="agvStartConfirm()" :disabled="agvStartDis">入库</button>
               </view>
            </view>
         </uni-popup>
@@ -39,10 +60,16 @@
</template>
<script>
   // todo: 购物车优化,存储购物车内容,退出页面再进后购物车还在
   export default {
      data() {
         return {
            orderCarList: []
            orderCarList: [],
            count: 0,
            index: 0,
            barcode: '',
            agvDevp: '',
            agvStartDis: false
         }
      },
      onShow() {
@@ -58,9 +85,111 @@
         })
      },
      methods: {
         chageDetl() {
         chageDetl(index) {
            this.index = index
            this.count = this.orderCarList[index].pakinQty
            this.$refs.chageDetl.open()
         },
         // 修改数量
         changeCount() {
            if (this.count > this.orderCarList[this.index].anfme) {
               uni.showToast({ title: '数量不合法!', icon: "none", position: 'top' })
               return
            }
            this.orderCarList[this.index].pakinQty = this.count
            this.$forceUpdate() // 强制刷新
            this.$refs.chageDetl.close()
         },
         // 移除物料
         remove() {
            this.orderCarList.splice(this.index, 1)
            this.$refs.chageDetl.close()
         },
         changeValue(value) {
            this.count = value
         },
         agvStart() {
            this.$refs.agvStart.open()
         },
         agvStartClose() {
            this.barcode = ''
            this.agvDevp = ''
            this.$refs.agvStart.close()
         },
         agvStartConfirm() {
            this.barcode = this.barcode.replace(/\s+/g, '')
            this.agvDevp = this.agvDevp.replace(/\s+/g, '')
            let _this = this
            if (_this.barcode === '') {
               uni.showToast({ title: '货架码为空!', icon: "error", position: 'top' })
               return;
            }
            if (_this.agvDevp === '') {
               uni.showToast({ title: '站点码为空!', icon: "error", position: 'top' })
               return;
            }
            if (_this.orderCarList.length === 0) {
               uni.showToast({ title: '组托列表为空!', icon: "error", position: 'top' })
               return;
            }
            for (let k of _this.orderCarList) {
               if (k.pakinQty == 0) {
                  uni.showToast({ title: `${k.matnr}数量不能为 0 !`, icon: "error", position: 'top' })
                  return;
               }
            }
            let combMat = { orderNo:'', barcode: '', locNo: '', combMats: [] }
            let combMats = []
            for (let item of _this.orderCarList) {
               combMat.orderNo = item.orderNo
               combMat.barcode = _this.barcode
               combMat.locNo = _this.agvDevp
               combMat.combMats = []
               let combM = {csocode: item.threeCode,isoseq: item.deadTime,matnr: item.matnr,batch: item.batch,anfme: item.pakinQty,maktx: item.maktx,specs: item.specs,processSts: item.processSts}
               combMat.combMats.push(combM)
               combMats.push({...combMat})
            }
            this.comb(combMats)
            
         }
         },
         comb(combMats) {
            let _this = this;
            this.agvStartDis = true
            uni.request({
               url: _this.baseUrl + '/agvMobile/start/pakin/auth',
               data: JSON.stringify({
                  barcode: _this.barcode,
                  containerCode: _this.barcode,
                  devNo: _this.agvDevp,
                  combParams: combMats
               }),
               method: 'POST',
               header: {
                  'token': uni.getStorageSync('token')
               },
               success(result) {
                  var res = result.data
                  _this.agvStartDis = false
                  if (res.code === 200) {
                     _this.orderCarList = []
                     _this.$refs.agvStart.close()
                     uni.showToast({ title: '启动成功!', icon: "success", position: 'top' })
                     setTimeout(()=> {
                        _this.getOpenerEventChannel().emit('acceptDataFromOpenedPage', {data: 1});
                        uni.navigateBack({})
                     },1000)
                  } else if (res.code == 403) {
                     uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                     setTimeout(() => { uni.reLaunch({ url: '../../login/login' }); }, 1000);
                  } else {
                     uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                  }
               },
               fail(res) {
                  _this.agvStartDis = false
               }
            });
         },
      }
   }
</script>
@@ -129,7 +258,7 @@
      height: 100%;
      justify-content: center;
      align-items: center;
      color: #606266;
      color: #e2231a;
      border-right: 1px solid #DCDFE6;
   }
   .btn-right {