#
whycq
2022-02-24 c8dc3d4f33e7548e2d02ba14e9cb770afda5df2b
pages/basics/stockCheck.vue
@@ -1,6 +1,12 @@
<template>
   <view>
      <view class="cu-form-group margin-top">
         <view class="title">托盘码</view>
         <input v-model="billNo" placeholder="扫码 / 输入" name="input" @input="findCode()" focus>
         <button v-model="matBtn" class="cu-btn bg-yellow" @click="toggle('right')"><text>+补充</text></button>
      </view>
      <!-- <view class="cu-form-group margin-top">
         <view>
            出库口
         </view>
@@ -12,7 +18,7 @@
         <view>
            <button v-model="matBtn" class="cu-btn bg-yellow" @click="toggle('right')"><text>+补充</text></button>
         </view>
      </view>
      </view> -->
      <view class="margin-top">
         <uni-table border stripe emptyText="暂无更多数据">
            <uni-tr>
@@ -65,7 +71,7 @@
                     <text class="title">数量</text>
                     <uni-number-box @change="countDom" v-model="count" />
                  </view>
                  <button class="cu-btn bg-yellow pda-btn2" @click="confirm">提取</button>
                  <button class="cu-btn bg-yellow pda-btn2" @click="confirm">补充</button>
                  
            </view>
         </uni-popup>
@@ -74,6 +80,16 @@
         <!-- 提示信息弹窗 -->
         <uni-popup ref="message" type="message">
            <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
         </uni-popup>
      </view>
      <view>
         <!-- 输入框示例 -->
         <uni-popup ref="inputDialog" type="dialog">
            <uni-popup-dialog ref="inputClose" mode="input" title="组托数量"
               placeholder="请输入组托数量" @confirm="dialogInputConfirm">
                  <uni-number-box :min="minCount" :max="maxCount" v-model="value" />
            </uni-popup-dialog>
         </uni-popup>
      </view>
   </view>
@@ -85,11 +101,9 @@
         return {
            msgType: '',
            messageText: '',
            index: 0,
            array: [],
            matBtn:'',
            souceData:[], // 初始化表格数据记录
            locDetlData:[],
            souceData:[],
            locDetlData:[], // 表格数据
            matNo:'',
            matName:'',
            specs:'',
@@ -103,27 +117,17 @@
            checkList:[],
            sourceList:[],
            minCount:0,
            maxCount:1,
            billNo:'',
            matData:[],
            rowNum:'',
            value:'',
         }
      },
      mounted(){
         // 获取IP端口
         const UIP = uni.getStorageSync('UIP');
         this.baseIP = UIP
         // 获取出库口
         let that = this
         uni.request({
            url: that.baseHttp + that.baseIP + that.baseUrl + "/available/take/check/site",
            header: {
               'token':uni.getStorageSync('token')
            },
            method: 'POST',
            async: false,
            success(res){
               if(res.data.code === 200){
                  that.array = res.data.data
               }
            }
         })
      },
      methods: {
         // 提示窗口
@@ -132,40 +136,44 @@
            this.messageText = '提取失败'
            this.$refs.message.open()
         },
         // 出库口:180等
         bindPickerChange: function(e) {
         // 根据托盘码查询
         findCode() {
            let that = this
            that.index = e.detail.value
            that.outlet = that.array[that.index]
            if (that.billNo.length === 0 || that.billNo.length !== 8) {
               return
            }
            let barCode = that.billNo
            // 赋值前清空表格
            that.locDetlData = [] // 初始化表格数据
            uni.request({
               url: that.baseHttp + that.baseIP + that.baseUrl + "/mobile/check/queryMatFromDevNo?devNo=" + that.outlet,
               url: that.baseHttp + that.baseIP + that.baseUrl + "/mobile/check/queryMatFromBarCode?barCode=" + barCode,
               header: {
                  'content-type':'application/x-www-form-urlencoded',
                  'token':uni.getStorageSync('token')
               },
               data: {
                  barCode: barCode
               },
               method:'GET',
               async:false,
               success(res){
                  if(res.data.code === 200){
                     console.log(1)
               success(res) {
                  console.log(res)
                  if (res.data.code === 200) {
                     that.locDetlData = res.data.data
                     if(res.data.data && res.data.data.length > 0){
                     if (res.data.data && res.data.data.length > 0) {
                        res.data.data.map(function(item){
                           that.souceData.push(item)
                           console.log(that.souceData)
                        })
                     }
                  } else if (res.data.code = 403){
                  } else if (res.data.code === 403) {
                     uni.navigateBack({
                         delta: 1
                     })
                  } else {
                     this.messageToggle('error')
                     this.messageText = res.data.msg
                     that.messageToggle('error')
                     that.messageText = res.data.msg
                  }
               }
            })
         },
         // 点击补充的弹窗
         toggle(type) {
@@ -218,12 +226,6 @@
               }
            })
         },
         // 删除
         remove(index,item){
            this.matData.splice(index,1)
            this.messageToggle('success')
            this.messageText = '删除成功'
         },
         // 弹窗 确认补充
         confirm(){
            let that = this
@@ -237,36 +239,30 @@
         },
         // 修改数量
         conf(){
            let that = this
            let data = {
               matNo:that.matNo,
               matName:that.matName,
               count:that.count
            }
            for (var j = 0; j < that.locDetlData.length; j++) {
                if (matNo === that.locDetlData[j].matNo && locNo === that.locDetlData[j].locNo) {
                    if (that.count < that.minCount) {
                        that.messageToggle('error')
                        that.messageText = '数量必须大于0'
                        return;
                    }
                    that.locDetlData[j].count = Number(that.count);
                }
            }
            that.messageToggle('success')
            that.messageText = '修改成功'
            this.$refs.inputDialog.open()
            this.maxCount = item.count
            this.rowNum = index
            this.value = this.maxCount
         },
         // 修改数量弹窗
         dialogInputConfirm() {
            this.locDetlData[this.rowNum].count = this.value
            this.messageToggle('success')
            this.messageText = '修改成功'
         },
         // 移除物料
         remove(index,item){
            this.matData.splice(index,1)
            this.locDetlData.splice(index,1)
            this.messageToggle('success')
            this.messageText = '删除成功'
         },
         // 补充的数据添加到总数据中
         addTableData(data){
            let that = this
            console.log(data.matNo.length)
            if(data.matNo.length === 0){
               that.messageToggle('error')
               that.messageText = '提取失败'
               that.messageText = '补充失败'
               return
            }
            var toPush = true
@@ -287,25 +283,10 @@
            this.$refs.popup.close()
            
         },
         initTableData(data){
            for(var i=0;i<data.length;i++){
               var toPush =true
               for(var j = 0; j<this.locDetlDate.length;j++){
                  if (data[i].matNo === this.locDetlData[j].matNo && data[i].locNo === this.locDetlData[j].locNo) {
                     toPush = false;
                  }
               }
               if(toPush){
                  this.locDetlDate.push(data[i])
               }
            }
         },
         // 重置
         reset(){
            this.array = []
            this.locDetlData = [];
            this.checkList = []
            this.sourceList = []
            this.billNo = ''
            this.addTableData()
         },
         check(){
            if(this.souceData.length === 0) {