LSH
2022-09-23 1e7de5b9103999800062f1e6b18d94fd93f3ef06
pages/basics/putOnSale.vue
@@ -9,7 +9,7 @@
         <view class="square-content">
            <view class="content-input">
               <input type="text" v-model="locno" placeholder="扫码 / 输入" :focus="locnoFocus">
               <uni-icons type="closeempty" size="20" color="#dadada"></uni-icons>
               <uni-icons v-show="locno" type="closeempty" size="20" color="#dadada" @click="remove('locno')"></uni-icons>
            </view>
         </view>
      </view>
@@ -17,15 +17,32 @@
      <view class="square-2">
         <view class="square-title">
            <view class="title-sign"><view class="sign"></view></view>
            <view class="title-text"><text>检索商品</text></view>
         </view>
         <view class="square-content">
            <view class="content-input-btn">
               <input v-model="matnr" type="text" placeholder="扫码 / 输入" @input="findMat()"
               :focus="matnrFocus" placeholder-style="line-height:  85rpx;">
               <uni-icons v-show="matnr" type="closeempty" size="20" color="#dadada" @click="remove('matnr')"></uni-icons>
            </view>
            <view class="content-btn">
               <button class="cu-btn bg-blue pda-btn" @click="selectMat()">+提取</button>
            </view>
         </view>
      </view>
      <!-- <view class="square-2">
         <view class="square-title">
            <view class="title-sign"><view class="sign"></view></view>
            <view class="title-text"><text>商品码</text></view>
         </view>
         <view class="square-content">
            <view class="content-input">
               <input type="text" v-model="matnr" placeholder="扫码 / 输入" @input="findMat" :focus="matnrFocus">
               <uni-icons type="closeempty" size="20" color="#dadada"></uni-icons>
               <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">
@@ -39,7 +56,7 @@
      </view>
      
      <!-- 商品列表 -->
      <checkbox-group >
      <!-- <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>
@@ -48,7 +65,27 @@
               <view class="lists-item">上架数量:{{item.anfme}}</view>
            </view>
            <view class="list-right">
               <uni-icons type="trash" size="20" color="#a5a5a5" @click="remove(item,index)"></uni-icons>
               <uni-icons type="trash" size="20" color="#a5a5a5" @click="removeItem(item,index)"></uni-icons>
            </view>
         </view>
      </checkbox-group> -->
      <checkbox-group>
         <view v-for="(item,index) in matList" :key="index" class="data-list bg-false" :class="'bg-'+item.checked" >
            <view class="data-list-left">
               <!-- <view>
                  <checkbox :value="item.id+''" :checked="item.checked" style="display: block;" />
               </view> -->
               <view class="matnr"><text style="width: 400rpx;">编码:{{item.matnr}}</text></view>
               <view><text style="width: 400rpx;">品名:{{item.maktx}}</text></view>
               <view><text style="width: 400rpx;">批号:{{item.batch}}</text></view>
               <view>
                  <text style="width: 400rpx;">数量:{{item.anfme}}</text>
               </view>
            </view>
            <view class="data-list-right">
               <label><uni-icons type="compose" size="20" color="#a5a5a5" @click="revise(item,index)"></uni-icons></label>
               <label><uni-icons type="trash" size="25" color="#a5a5a5" @click="remove(item,index)"></uni-icons></label>
            </view>
         </view>
      </checkbox-group>
@@ -69,8 +106,33 @@
            <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>
   
      <!-- 弹窗 -->
      <!-- 修改数量 -->
      <uni-popup ref="revise" background-color="#fff">
         <view class="revise-box">
            <view class="revise-box-top">
               <view class="color-block-blue"></view>
               <text class="title">修改数量</text>
            </view>
            <view class="changeBox">
               <view class="num-box">
                  <uni-number-box :value="count" :max="9999" color="#747474"  @change="changeValue"/>
               </view>
            </view>
            <view class="revise-box-buttom">
               <view>
                  <button class="cu-btn bg-blue" @click="confirm()">确认</button>
               </view>
            </view>
         </view>
      </uni-popup>
   </view>
</template>
@@ -78,14 +140,17 @@
    export default {
      data() {
          return {
            locno:null, // 库位号
            locno:'', // 库位号
            matnr:'', // 商品码
            locnoFocus:true,
            matnrFocus:true,
            matList:[], // 商品列表
            listLen:0,
            listNum:1
            listNum:1,
            msgType: 'success',
            messageText: '这是一条成功提示',
            count:'',
            rowNum:'',
         }
      },
      mounted(){
@@ -93,15 +158,35 @@
         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.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mat/auth',
                url: that.commonUrl + '/mat/auth',
                data: {
                  matnr:that.matnr
                },
@@ -119,8 +204,8 @@
                        events: {
                            // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                            matList: function(data) {
                              console.log(data)
                              that.matList.push(data.data)
                              console.log(that.matList)
                           },
                        },
                        success: function(res) {
@@ -134,26 +219,77 @@
            });
            
         },
         // .
         // 移除物料
         removeItem(item,index) {
            this.matList.splice(index,1)
            // this.listLen = this.matList.length
            this.messageToggle('success')
            this.messageText = '移除成功'
         },
         // 上架
         comb() {
            let that = this
            var combList = []
            combList['locno'] = that.locno
            combList['combMats'] = that.matList
            console.log(combList)
            return;
            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 combMats = []
            var combParam = {}
            combParam['locno'] = that.locno
            combParam['combMats'] = that.matList
            uni.request({
               url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mat/auth',
               data: {
                  combParam:that.matList
               },
               header: { 'token':uni.getStorageSync('token') },
               url: that.commonUrl + '/mobile/mat/onSale/auth',
               data: JSON.stringify(combParam),
               header: { 'token':uni.getStorageSync('token'),},
               method:'POST',
               success(result) {
                  console.log(result)
               }
            })
         }
         },
         // 提取商品
         selectMat() {
            let that = this
            uni.vibrateShort();
            uni.navigateTo({
               url: "matSelect",
               events: {
                   // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据  另外一个页面传过来的
                   acceptDataFromOpenedPage: function(data) {
                     that.matnr = data.data
                     that.findMat(that.matnr)
                   },
               },
               success: function(res) {
                   // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                   res.eventChannel.emit('commonUrl', {commonUrl:that.commonUrl })
               },
            });
            that.matnr = ''
         },
         revise(item,index) {
            this.count = this.matList[index].anfme
            this.rowNum = index
            this.eject()
         },
         eject(type) {
            this.type = type
            // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
            this.$refs.revise.open(type)
         },
         changeValue(value) {
            this.count = value
         },
         confirm() {
            this.matList[this.rowNum].anfme = this.count
            this.$refs.revise.close()
            this.$forceUpdate() // 强制刷新
         },
         
      }
    }