Your Name
2022-08-16 aeaace1cf0c48cc9b2dffbc5d5ab9eb4ecfad4a1
pages/basics/putOnSale.vue
@@ -8,8 +8,8 @@
         </view>
         <view class="square-content">
            <view class="content-input">
               <input type="text" v-model="yyds" placeholder="扫码 / 输入" @input="find" :focus="focus">
               <uni-icons type="closeempty" size="20" color="#dadada"></uni-icons>
               <input type="text" v-model="locno" placeholder="扫码 / 输入" :focus="locnoFocus">
               <uni-icons v-show="locno" type="closeempty" size="20" color="#dadada" @click="remove('locno')"></uni-icons>
            </view>
         </view>
      </view>
@@ -21,17 +21,188 @@
         </view>
         <view class="square-content">
            <view class="content-input">
               <input type="text" v-model="yyds" placeholder="扫码 / 输入" @input="find" :focus="focus">
               <uni-icons type="closeempty" size="20" color="#dadada"></uni-icons>
               <input type="text" v-model="matnr" placeholder="扫码 / 输入" @input="findMat" :focus="matnrFocus">
               <uni-icons v-show="matnr" type="closeempty" size="20" color="#dadada" @click="remove('matnr')"></uni-icons>
            </view>
         </view>
      </view>
   </view>
      <!-- 商品列表表头 -->
      <view class="square-1">
         <view class="square-title">
            <view class="title-sign"><view class="sign"></view></view>
            <view class="title-text"><text>商品列表</text></view>
         </view>
      </view>
      <view class="square-none">
         <view class="v-show" v-show="matList.length == 0">暂无更多数据...</view>
      </view>
      <!-- 商品列表 -->
      <checkbox-group >
         <view v-for="(item,index) in matList" :key="index" class="data-list bg-false" :class="'bg-'+item.checked" >
            <view class="list-left">
               <view class="lists-item">No:{{listNum}}</view>
               <view class="lists-item">商品编码:{{item.matnr}}</view>
               <view class="lists-item">商品批号:{{item.batch}}</view>
               <view class="lists-item">上架数量:{{item.anfme}}</view>
            </view>
            <view class="list-right">
               <uni-icons type="trash" size="20" color="#a5a5a5" @click="removeItem(item,index)"></uni-icons>
            </view>
         </view>
      </checkbox-group>
      <!-- 底部按钮 -->
      <view class="footer flex justify-around">
         <!-- <label class="label-btn" style="width: 170rpx;">
            <checkbox :checked="check" @click="allChecked()">{{checkText}}</checkbox>
         </label>
         <label class="label-btn" style="width: 100rpx;">
            <text  @click="reChecked()">反选</text>
         </label> -->
         <label class="label-btn" style="width: 150rpx;">
            <button class="cu-btn" @click="resst()">重置</button>
         </label>
         <label class="label-btn">
            <button class="cu-btn bg-blue " @click="comb()">上架</button>
         </label>
      </view>
      <view>
         <!-- 提示信息弹窗 -->
         <uni-popup ref="message" type="message">
            <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
         </uni-popup>
      </view>
   
   </view>
</template>
<script>
    export default {
      data() {
          return {
            locno:'', // 库位号
            matnr:'', // 商品码
            locnoFocus:true,
            matnrFocus:true,
            matList:[], // 商品列表
            listLen:0,
            listNum:1,
            msgType: 'success',
            messageText: '这是一条成功提示',
         }
      },
      mounted(){
         const UIP = uni.getStorageSync('UIP');
         this.baseIP = UIP;
         const UPORT = uni.getStorageSync('UPORT');
         this.basePORT = UPORT
         const PROJ = uni.getStorageSync('UPROJ');
         this.baseUrl = PROJ
         this.getUrl()
      },
      methods:{
         // 获取url
         getUrl() {
            this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePORT + "/" +this.baseUrl
         },
         // 消息提示弹窗
         messageToggle(type) {
            this.msgType = type
            this.messageText = ''
            this.$refs.message.open()
         },
         // 清空input
         remove(e) {
            this[e] = ''
         },
         // 重置
         resst() {
            this.locno = ''
            this.matnr = ''
            this.matList = []
         },
         findMat() {
            let that = this
            uni.request({
                url: that.commonUrl + '/mat/auth',
                data: {
                  matnr:that.matnr
                },
                header: {
                  'token':uni.getStorageSync('token')
                },
               success(result) {
                  uni.vibrateShort();
                  let res = result.data
                  if (res.code === 200 && res.data) {
                     that.matData = res.data
                     that.matnr = ''
                     uni.navigateTo({
                        url: "matQuery",
                        events: {
                            // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                            matList: function(data) {
                              console.log(data)
                              that.matList.push(data.data)
                           },
                        },
                        success: function(res) {
                           // 通过eventChannel向被打开页面传送数据
                           res.eventChannel.emit('matData', { data: that.matData })
                        },
                     });
                  }
               }
            });
         },
         // 移除物料
         removeItem(item,index) {
            this.matList.splice(index,1)
            // this.listLen = this.matList.length
            this.messageToggle('success')
            this.messageText = '移除成功'
         },
         // 上架
         comb() {
            let that = this
            if(that.locno === '') {
               uni.showToast({title: '请添加库位码', icon: "none", position: 'top'});
               return;
            }
            if(that.matList.length === 0) {
               uni.showToast({title: '请添加商品', icon: "none", position: 'top'});
               return;
            }
            var combList = {}
            var matList = []
            combList['locno'] = that.locno
            combList['combMats'] = that.matList
            matList['matnr'] = that.matList
            console.log(JSON.stringify(combList))
            uni.request({
               url: that.commonUrl + '/mobile/mat/onSale/auth',
               data: {
                  combParam:JSON.stringify(combList)
               },
               header: { 'token':uni.getStorageSync('token') },
               method:'GET',
               success(result) {
                  console.log(result)
               }
            })
         }
      }
    }
</script>
<style>
   @import url(@/static/css/putOnSale.css);
</style>