#
whycq
2022-10-17 4ef4fea7f3e36342100d82061c40b00c45a18801
pages/basics/matSelect.vue
@@ -4,7 +4,7 @@
         <view class="search-box">
            <view class="search-area">
               <view class="search-icon"><uni-icons type="search" size="25" color="#a5a5a5"></uni-icons></view>
               <input type="text" v-model="condition" placeholder="请输入商品编码 / 名称"/>
               <input type="text" @focus="searchFoucs" @blur="serchBlur" v-model="condition" placeholder="请输入商品编码 / 名称"/>
               <view class="close-icon" @click="reset()"><uni-icons type="closeempty" size="25" color="#a5a5a5"></uni-icons></view>
            </view>
            <view class="search-btn"><button @click="search(condition)" class="cu-btn bg-blue">搜索</button></view>
@@ -30,11 +30,23 @@
                     <view class="cu-tag bg-cyan ">商品</view>
                  </view>
                  <view class="matnr"><text style="width: 400rpx;">{{item.matnr}}</text></view>
                  <view class="matnr"><text style="width: 400rpx;">{{item.maktx}}</text></view>
                  <view class="matnr"><text style="width: 400rpx;">{{item.specs}}</text></view>
               </view>
            </label>
         </checkbox-group>
      </scroll-view>
      <view v-if="reList.length > 0" >
         <scroll-view scroll-y  class="record" v-if="recordShow">
            <view class="record-data" v-for="(item,index) in reList" :key="index" >
               <text style="margin-right: 10rpx;" @click="choseMatnr(item)">{{item}}</text>
               <view style="height: 50rpx;display: inline-block;" @click="removeRecord(index)">
                  <uni-icons type="closeempty" size="15" color="#a5a5a5"></uni-icons>
               </view>
            </view>
         </scroll-view>
      </view>
      </view>
</template>
@@ -42,13 +54,12 @@
   export default {
      data() {
         return {
            commonUrl:null,
            condition:null,
            tag: [],
            data: [],
            baseHttp:'http://',
            baseIP:'',
            basePORT:'',
            baseUrl:'/jkwms'
            reList: [],
            recordShow: false,
         }
      },
      onLoad() {
@@ -57,13 +68,31 @@
         const eventChannel = this.getOpenerEventChannel();
         
         // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
         eventChannel.on('acceptDataFromOpenerPage', function(data) {
            that.baseIP = data.baseIP
            that.basePORT = data.basePORT
         eventChannel.on('commonUrl', function(data) {
            that.commonUrl = data.commonUrl
            that.showTag(1)
         })
      },
      methods: {
         removeRecord(index) {
            this.reList.splice(index,1)
            uni.setStorageSync('recordList',this.reList)
         },
         choseMatnr(matnr) {
            this.condition = matnr
         },
         searchFoucs() {
            var reL = uni.getStorageSync('recordList')
            if (reL.length == 0) {
               reL = []
            }
            this.reList = reL
            this.recordShow = true
         },
         serchBlur() {
            // this.recordShow = false
         },
         checkbox() {
            
         },
@@ -72,7 +101,10 @@
            uni.vibrateShort();
         },
         search(condition) {
            this.recordShow = false
            let that = this
            // that.reList.push(that.condition)
            // uni.setStorageSync('recordList',that.reList)
            that.tag = null
            that.data = null
            uni.vibrateShort();
@@ -81,7 +113,7 @@
            });
            uni.request({
               // url: "http://localhost:8081/jkwms/tag/list/pda/auth",
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mat/search/pda/auth',
                url: that.commonUrl + '/mat/search/pda/auth',
                data: {
                  condition: condition
                },
@@ -94,6 +126,18 @@
                  var res = result.data
                  if (res.code === 200 ) {
                     that.data = res.data
                     if (that.reList.length == 0) {
                        that.reList.push(that.condition)
                        uni.setStorageSync('recordList',that.reList)
                        return
                     }
                     for(var i = 0;i < that.reList.length;i++) {
                        if (that.reList[i] == that.condition) {
                           that.reList.splice(i,1)
                        }
                     }
                     that.reList.unshift(that.condition)
                     uni.setStorageSync('recordList',that.reList)
                  } else if (res.code == 403) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
@@ -109,19 +153,21 @@
         },
         showTag(parentId) {
            let that = this
            uni.vibrateShort();
            uni.showLoading();
            uni.request({
               // url: "http://localhost:8081/jkwms/tag/list/pda/auth",
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/tag/list/pda/auth',
                url: that.commonUrl + '/tag/list/pda/auth',
               header: {
                  'token':uni.getStorageSync('token'),
               },
                data: {
                  limit: 100000,
                  parentId: parentId
                },
               method:"GET",
                header: {
               header: {
                  'token':uni.getStorageSync('token'),
                },
               },
               success(result) {
                  uni.hideLoading();
                  that.tag = null
                  that.data = null
                  var res = result.data
@@ -141,18 +187,18 @@
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
         showMat(tagId) {
            uni.vibrateShort();
            uni.showLoading();
            let that = this
            if (tagId == null || tagId == '' || tagId == undefined) {
               return;
            }
            uni.request({
               // url: "http://localhost:8081/jkwms/mat/list/pda/auth",
                url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mat/list/pda/auth',
                url: that.commonUrl + '/mat/list/pda/auth',
                data: {
                  tagId: tagId
                },
@@ -161,11 +207,13 @@
                  'token':uni.getStorageSync('token'),
                },
               success(result) {
                  uni.hideLoading();
                  that.tag = null
                  var res = result.data
                  if (res.code === 200) {
                     if (res.data != null && res.data.length > 0) {
                        that.data = res.data
                     } else {
                        // that.tagId = parentId
                     }
@@ -179,6 +227,7 @@
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
@@ -195,6 +244,36 @@
</script>
<style>
   .record-data {
      height: 60rpx;
      background-color: #FFF;
      line-height: 60rpx;
      padding-left: 20rpx;
      padding-right: 20rpx;
      margin-left: 20rpx;
      margin-top: 10rpx;
      display: inline-block;
      border-radius: 20rpx;
      text-align: center;
   }
   .record-data:last-child {
      margin-bottom: 10rpx;
   }
   .record {
      z-index: 11;
      display: flex;
      flex-direction: column;
      flex-wrap: wrap;
      position: absolute;
      top:94rpx;
      /* #ifdef APP-PLUS */
      top: 94rpx;
      /* #endif */
      width: 100%;
      min-height: 80rpx;
      max-height: 600rpx;
      background-color: #6f6f6f;
   }
   .matnr {
      margin-left: 60rpx;
      margin-top: 20rpx;