#
Junjie
2025-07-05 166b9c6d7517fbff3a400e07d47d1f33c8634c69
pages/basics/matQuery.vue
@@ -3,33 +3,50 @@
      <view>
         <view class="container">
            <view class="text-box">
               <view class="text-title"><text>商品编码</text></view>
               <view class="text-title"><text>品号</text></view>
               <view class="text-title"><text>{{matData.matnr}}</text></view>
            </view>
            <view class="text-box">
               <view class="text-title"><text>商品名称</text></view>
               <view class="text-title"><text>品名</text></view>
               <view class="text-title">{{matData.maktx}}</view>
            </view>
            <view class="text-box">
               <view class="text-title"><text>规格</text></view>
               <view class="text-title">{{matData.specs}}</view>
            </view>
            <!-- <view class="text-box">
               <view class="text-title"><text>工序</text></view>
               <view class="text-title">{{matData.sku}}</view>
            </view> -->
            <view class="text-box">
               <view class="text-title"><text>批号</text></view>
               <view class="text-title"><text>批次</text></view>
               <view class="text-title"><input type="text" v-model="matData.batch"></view>
            </view>
            <!-- <view class="text-box">
               <view class="text-title"><text>备注</text></view>
               <view class="text-title"><input type="text" v-model="matData.memo"></view>
            </view> -->
            <view class="text-box">
               <view class="text-title"><text>数量</text></view>
               <view class="text-title"><text>主数量</text></view>
               <view class="text-title">
                  <view>
                     <uni-number-box color="#747474"  @change="changeValue"/>
                     <uni-number-box v-model="matData.anfme" :value="matData.anfme" :max="99999999" color="#747474" @change="changeValue"/>
                  </view>
               </view>
            </view>
            <view class="text-box">
               <view class="text-title"><text>辅数量</text></view>
               <view class="text-title">
                  <view>
                     <uni-number-box v-model="matData.weight" :value="matData.weight" :max="99999999" color="#747474" @change="changeValue2"/>
                  </view>
               </view>
            </view>
         </view>
      </view>
      <view class="foot flex justify-center">
         <label for="">
         <label>
            <button class="cu-btn bg-blue" @click="back()">提取</button>
         </label>
      </view>
@@ -43,55 +60,59 @@
            matData: {
               matnr: null,
               maktx: null,
               specs: null,
               batch: null,
               anfme: 0
               anfme: null,
               anfme2: null,
               origin: null,
            },
            baseIP:'',
            basePORT:'',
         }
      },
      onLoad(option) {
         this.baseIP = option.baseIP
         this.basePORT = option.basePORT
         this.matData.matnr = option.matnr
         this.getMat()
         let that = this
         // #ifdef APP-NVUE
         const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
         // #endif
         // #ifndef APP-NVUE
         const eventChannel = this.getOpenerEventChannel();
         // #endif
         // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
         eventChannel.on('matData', function(data) {
         that.matData = data.data
         })
      },
      methods: {
         getMat() {
            let that = this
            uni.request({
               url: 'http://localhost:8081/jkwms/mat/auth',
                // url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mat/auth',
                data: {
                  matnr: that.matData.matnr
                },
                header: {
                  'token':uni.getStorageSync('token')
                },
               success(res) {
                  var res = res.data;
                  console.log(res);
                  if (res.code === 200) {
                     that.matData = res.data;
                  }
               }
            });
         },
         blur() {
            
         },
         focus() {
            
         },
         changeValue() {
         changeValue(value) {
            // this.matData.anfme = value
         },
         changeValue2(value) {
            let arr = this.matData.origin.split("/")
            let mainAnfme = value * parseFloat(arr[1]) * parseFloat(arr[0])
            let flooredNum = Math.floor(mainAnfme * 10000) / 10000; // 截断到小数点后4位
            this.matData.weight = value
            this.matData.anfme = flooredNum
         },
         back() {
            this.matData.anfme = 5.9
            uni.$emit('matData', this.matData);
            if (this.matData.anfme === 0) {
               uni.showToast({title: '请输入数量', icon: "none", position: 'top'});
               return;
            }
            console.log(this.matData);
            this.getOpenerEventChannel().emit('matList', {data: this.matData});
            uni.vibrateShort();
            uni.navigateBack({
               delta: 1
            })
         }
      }
@@ -110,36 +131,35 @@
      margin-top: 20rpx;
      margin-left: 10%;
      width: 80%;
      font-size: 36rpx;
      font-weight: 700;
      font-size: 32rpx;
      font-weight: 400;
      color: #434343;
      border-bottom: 1rpx solid #e8e8e8;
   }
   .text-box:last-child {
      border-bottom: none;
   }
   .text-box:last-child .text-title:last-child {
      display: flex;
      height: 100%;
      align-items: center;
   }
   .text-box .text-title {
      width: 30%;
      height: 100rpx;
      float: left;
      display: inline-block;
   }
   .text-box .text-value {
      width: 70%;
      padding: 0 20upx;
   }
   .text-box .text-title:last-child {
      display: inline-block;
      margin-left: 10%;
      width: 60%;
      margin-left: 5%;
      width: 65%;
      font-size: 30rpx;
      font-weight: 400;
      color: #747474;
      display: flex;
      align-items: center;
   }
   .text-box .text-title:last-child input {
      border-bottom: 1rpx solid #e8e8e8 ;
      width: 100%;
   }
   
   .foot {
      width: 100%;