whycq
2024-06-06 c48093016b1511ce8b33ffb49062a3bf7a1aed16
pages/phyz/wrkMast/wrkDetl.vue
@@ -1,5 +1,23 @@
<template>
   <view>
      <view class="code">
         <!-- <uni-search-bar :focus="matFocus" v-model="matnr"  @input="matInput()" ma
            maxlength="500" ancel="cancel" @clear="clear" placeholder="输入 / 扫描商品">
         </uni-search-bar> -->
      </view>
      <view class="list" v-for="(item,i) in dataList">
         <view class="list-left">
            <view>编号:{{item.matnr}}</view>
            <view>名称:{{item.maktx}}</view>
            <view>规格:{{item.specs}}</view>
            <view>批号:{{item.batch}}</view>
            <view class="list-anfme">数量:{{item.anfme}}</view>
            <view class="list-qty-1" v-if="item.anfme > item.qty">作业数量:{{item.qty}}</view>
            <view class="list-qty-2" v-if="item.anfme <= item.qty">作业数量:{{item.qty}}</view>
         </view>
      </view>
      <view style="height: 100rpx;"></view>
      
   </view>
</template>
@@ -8,15 +26,175 @@
   export default {
      data() {
         return {
            baseUrl: '',
            token: '',
            orderId: '',
            matFocus: true,
            matnr: '',
            checck: true,
            dataList: [],
            oldDataList: [],
            newDataList: [],
            allCheck: false,
            allCheckBtnTitle: '全选',
         }
      },
      methods: {
      onLoad() {
         let that = this
         this.baseUrl = uni.getStorageSync('baseUrl');
         this.token = uni.getStorageSync('token');
         // const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
         const eventChannel = this.getOpenerEventChannel();
         
         // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
         eventChannel.on('item', function(data) {
            console.log(data);
            that.orderId = data.item
            console.log(data.item.id);
            uni.setNavigationBarTitle({
               title: `工作号-${data.item}`,
            })
            that.getOrderDetl(data.item)
         })
      },
      onShow() {
         if (this.dataList.length > 0) {
            this.oldDataList = [...this.dataList]
         }
         // this.getOrderDetl(this.orderId)
      },
      methods: {
         // 订单明细
         getOrderDetl(id) {
            let _this = this
            console.log(id);
            uni.request({
               url: `${_this.baseUrl}/agv/wrkDetl/list/auth`,
               header: {'token': uni.getStorageSync('token')},
               data: {
                  curr: 1,
                  limit: 1000,
                  wrk_no: id
               },
               method: 'GET',
               success(res) {
                  res = res.data
                  console.log(res);
                  if (res.code === 200) {
                     _this.dataList = res.data.records
                     _this.oldDataList = [..._this.dataList]
                  }
               }
            })
         },
         matInput() {
            let count = 0
            let sign = 0
            if (this.oldDataList.length > 0) {
               this.dataList = [...this.oldDataList]
            }
            this.newDataList = []
            for (let k in this.dataList) {
               if (!this.dataList[k].matnr.includes(this.matnr)) {
                  count++;
               } else {
                  this.newDataList.push(this.dataList[k])
               }
            }
            if (this.matnr != '') {
               for (let j in this.dataList) {
                  if (!this.dataList[j].maktx.includes(this.matnr)) {
                  } else {
                     for (let i in this.newDataList) {
                        if (this.newDataList[i].matnr ==  this.dataList[j].matnr) {
                           sign++
                        }
                     }
                     if (sign == 0) {
                        this.newDataList.push(this.dataList[j])
                     }
                  }
               }
            }
            this.dataList = this.newDataList
         },
         checkboxChange(e) {
            let items = this.dataList,
            values = e.orderNo;
            if (e.checked) {
               this.$set(e,'checked',false)
            } else {
               if (e.anfme == e.qty) {
                  this.$set(e,'checked',false)
               } else {
                  this.$set(e,'checked',true)
               }
            }
         },
         allChecked() {
            if (this.allCheck) {
               this.allCheck = false
               this.allCheckBtnTitle = '全选'
            } else {
               this.allCheck = true
               this.allCheckBtnTitle = '取消'
            }
            for (let item of this.dataList) {
               if (this.allCheck) {
                  if (item.anfme == item.qty) {
                     this.$set(item,'checked',false)
                  } else {
                     this.$set(item,'checked',true)
                  }
               } else {
                  this.$set(item,'checked',false)
               }
            }
         },
         clear() {
            this.matnr = ''
            this.dataList = [...this.oldDataList]
         },
         combConfirm(type) {
            let _this = this
            let combList = []
            for (let k of _this.dataList) {
               if (k.checked) {
                  combList.push(k)
               }
            }
            if (combList.length == 0) {
               uni.showToast({ title: '请选择组托商品', icon: "error", position: 'top'})
               return
            }
            uni.navigateTo({
               url: "../AGV/AGVPakin2",
               success: function(res) {
                  // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                  res.eventChannel.emit('mats', {
                     mats: combList
                  })
               },
            });
         },
      }
   }
</script>
<style>
</style>
   @import url('../../../static/css/common/order.css');
   .list-anfme {
      color: #0082ff;
      font-weight: bold;
   }
   .list-qty-1 {
      color: #33ba43;
      font-weight: bold;
   }
   .list-qty-2 {
      color: #e2231a;
      font-weight: bold;
   }
</style>