skyouc
2024-12-21 c9c263dc43ad90f95f24a036cee9e6b47afb596c
pages/mat/matList.vue
@@ -1,229 +1,229 @@
<template>
   <view>
      <!-- 搜索框 -->
      <view class="search-bar">
         <uni-search-bar placeholder=" 扫码 / 输入" bgColor="#EEEEEE" @confirm="search" />
      </view>
      <scroll-view>
         <view class="tag-list" v-for="(item,i) in tagList" :key="i" @click="showTag(item.id)">
            <view class="tag">
               <view style="display: flex;">
                  <view class="wms-tag" :style="baColor" >分类</view>
               </view>
            </view>
            <view class="tag-item">{{item.name}}</view>
         </view>
      </scroll-view>
      <view>
         <view class="tag-list" v-for="(item,i) in matList" :key="i" @click="toPrint(item)">
            <view class="tag">
               <view style="display: flex;">
                  <view class="wms-tag" :style="baColor" >商品</view>
               </view>
            </view>
            <view class="tag-item">商品编号: {{item.matnr}}</view>
            <view class="tag-item">商品名称: {{item.maktx  ? item.maktx : '--'}}</view>
            <view class="tag-item">商品规格: {{item.specs  ? item.specs : '--'}}</view>
         </view>
      </view>
      <uni-load-more v-show="matList.length != 0" :status="status" :icon-size="16" :content-text="contentText" />
   </view>
</template>
<script>
   export default {
      data() {
         return {
            tagList: [],
            matList: [],
            reload: false,
            curr:1,
            tag: '分类',
            baColor: "background-color: #0081ff;",
            desc: '商品编号:',
            baseUrl: '',
            token: '',
            status: 'more',
            contentText: {
               contentdown: '上拉加载更多',
               contentrefresh: '加载中',
               contentnomore: '没有更多'
            },
            // 当前tagId
            tagIdNow: 1
         }
      },
      onReachBottom() {
         this.status = 'more';
         this.showMat(this.tagIdNow);
      },
      onLoad() {
         // 没啥用了
         let that = this
         // const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
         const eventChannel = this.getOpenerEventChannel();
         // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
         eventChannel.on('commonUrl', function(data) {
            that.commonUrl = data.commonUrl
         })
      },
      onShow() {
         this.baseUrl = uni.getStorageSync('baseUrl');
         this.token = uni.getStorageSync('token');
         this.showTag(1)
      },
      methods: {
         search() {
         },
         showTag(parentId) {
            let that = this
            uni.request({
                url: that.baseUrl + '/tag/list/pda/auth',
               header: {
                  'token':uni.getStorageSync('token'),
               },
                data: {
                  limit: 100000,
                  parentId: parentId
                },
               header: {
                  'token':uni.getStorageSync('token'),
               },
               success(result) {
                  that.tagList = null
                  that.matList = []
                  var res = result.data
                  if (res.code === 200) {
                     if (res.data != null && res.data.length > 0) {
                        that.tagList = res.data
                     } else {
                        that.showMat(parentId)
                     }
                     that.baColor = "background-color: #0081ff;"
                  } else if (res.code === 403 ) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
         showMat(tagId) {
            let that = this
            that.tagIdNow = tagId
            if (tagId == null || tagId == '' || tagId == undefined) {
               return;
            }
            // wms端 补接口
            // @RequestMapping(value = "/mat/list/pda/page/auth")
            // @ManagerAuth
            // public R pdaPageList(@RequestParam(required = true)Long tagId,
            //                 @RequestParam(defaultValue = "1")Integer curr,
            //                 @RequestParam(defaultValue = "10")Integer limit){
            //    EntityWrapper<Mat> wrapper = new EntityWrapper<>();
            //    wrapper.eq("tag_id", tagId);
            //    wrapper.orderBy("create_time", false);
            //    return R.ok().add(matService.selectPage(new Page<>(curr, limit), wrapper));
            // }
            uni.request({
                url: that.baseUrl + '/mat/list/pda/page/auth',
                data: {
                  curr:that.curr,
                  limit: 100,
                  tagId: tagId
                },
               method:"GET",
                header: {
                  'token':uni.getStorageSync('token'),
                },
               success(result) {
                  that.tagList = null
                  var res = result.data
                  if (res.code === 200) {
                     if (res.data.records != null && res.data.records.length > 0) {
                        let list = res.data.records
                        that.matList = that.reload ? list : that.matList.concat(list);
                        that.curr = that.curr + 1
                     }
                     if (res.data.records.length == 0) {
                        that.status = 'noMore'
                     }
                     that.baColor = "background-color: #1cbbb4;"
                  } else if (res.code === 403 ) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
         toPrint(item) {
            let that = this
            uni.navigateTo({
               url: "../print/print",
               success: function(res) {
                  // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                  res.eventChannel.emit('data', {
                     data: item
                  })
               },
               events: {
                  // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据  另外一个页面传过来的
                  acceptDataFromOpenedPage: function(data) {
                     that.matnr = data.data
                     that.findMat(that.matnr)
                  },
               },
            });
         }
      }
   }
</script>
<style>
   @import url('../../static/css/wms.css/wms.css');
   .tag-list {
      width: 94%;
      min-height: 160rpx;
      margin: 10px auto;
      background-color: #FFF;
      border-radius: 5px;
      box-shadow: 0 5upx 20upx rgba(0, 0, 0, 0.2);
   }
   .tag {
      display: flex;
      flex-direction: column;
      min-height: 80rpx;
      border-bottom: 1px solid #e2e2e2;
   }
   .wms-tag {
      min-width: 60rpx;
      margin-left: 50rpx;
      margin-top: 30rpx;
      color: #FFF;
      font-size: 14px;
      padding: 4rpx 12rpx;
   }
   .tag-item {
      width: 100%;
      min-height: 60rpx;
      line-height: 2;
      padding-left: 50rpx;
      color: #606266;
      font-size: 14px;
   }
<template>
   <view>
      <!-- 搜索框 -->
      <view class="search-bar">
         <uni-search-bar placeholder=" 扫码 / 输入" bgColor="#EEEEEE" @confirm="search" />
      </view>
      <scroll-view>
         <view class="tag-list" v-for="(item,i) in tagList" :key="i" @click="showTag(item.id)">
            <view class="tag">
               <view style="display: flex;">
                  <view class="wms-tag" :style="baColor" >分类</view>
               </view>
            </view>
            <view class="tag-item">{{item.name}}</view>
         </view>
      </scroll-view>
      <view>
         <view class="tag-list" v-for="(item,i) in matList" :key="i" @click="toPrint(item)">
            <view class="tag">
               <view style="display: flex;">
                  <view class="wms-tag" :style="baColor" >商品</view>
               </view>
            </view>
            <view class="tag-item">商品编号: {{item.matnr}}</view>
            <view class="tag-item">商品名称: {{item.maktx  ? item.maktx : '--'}}</view>
            <view class="tag-item">商品规格: {{item.specs  ? item.specs : '--'}}</view>
         </view>
      </view>
      <uni-load-more v-show="matList.length != 0" :status="status" :icon-size="16" :content-text="contentText" />
   </view>
</template>
<script>
   export default {
      data() {
         return {
            tagList: [],
            matList: [],
            reload: false,
            curr:1,
            tag: '分类',
            baColor: "background-color: #0081ff;",
            desc: '商品编号:',
            baseUrl: '',
            token: '',
            status: 'more',
            contentText: {
               contentdown: '上拉加载更多',
               contentrefresh: '加载中',
               contentnomore: '没有更多'
            },
            // 当前tagId
            tagIdNow: 1
         }
      },
      onReachBottom() {
         this.status = 'more';
         this.showMat(this.tagIdNow);
      },
      onLoad() {
         // 没啥用了
         let that = this
         // const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
         const eventChannel = this.getOpenerEventChannel();
         // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
         eventChannel.on('commonUrl', function(data) {
            that.commonUrl = data.commonUrl
         })
      },
      onShow() {
         this.baseUrl = uni.getStorageSync('baseUrl');
         this.token = uni.getStorageSync('token');
         this.showTag(1)
      },
      methods: {
         search() {
         },
         showTag(parentId) {
            let that = this
            uni.request({
                url: that.baseUrl + '/tag/list/pda/auth',
               header: {
                  'token':uni.getStorageSync('token'),
               },
                data: {
                  limit: 100000,
                  parentId: parentId
                },
               header: {
                  'token':uni.getStorageSync('token'),
               },
               success(result) {
                  that.tagList = null
                  that.matList = []
                  var res = result.data
                  if (res.code === 200) {
                     if (res.data != null && res.data.length > 0) {
                        that.tagList = res.data
                     } else {
                        that.showMat(parentId)
                     }
                     that.baColor = "background-color: #0081ff;"
                  } else if (res.code === 403 ) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
         showMat(tagId) {
            let that = this
            that.tagIdNow = tagId
            if (tagId == null || tagId == '' || tagId == undefined) {
               return;
            }
            // wms端 补接口
            // @RequestMapping(value = "/mat/list/pda/page/auth")
            // @ManagerAuth
            // public R pdaPageList(@RequestParam(required = true)Long tagId,
            //                 @RequestParam(defaultValue = "1")Integer curr,
            //                 @RequestParam(defaultValue = "10")Integer limit){
            //    EntityWrapper<Mat> wrapper = new EntityWrapper<>();
            //    wrapper.eq("tag_id", tagId);
            //    wrapper.orderBy("create_time", false);
            //    return R.ok().add(matService.selectPage(new Page<>(curr, limit), wrapper));
            // }
            uni.request({
                url: that.baseUrl + '/mat/list/pda/page/auth',
                data: {
                  curr:that.curr,
                  limit: 100,
                  tagId: tagId
                },
               method:"GET",
                header: {
                  'token':uni.getStorageSync('token'),
                },
               success(result) {
                  that.tagList = null
                  var res = result.data
                  if (res.code === 200) {
                     if (res.data.records != null && res.data.records.length > 0) {
                        let list = res.data.records
                        that.matList = that.reload ? list : that.matList.concat(list);
                        that.curr = that.curr + 1
                     }
                     if (res.data.records.length == 0) {
                        that.status = 'noMore'
                     }
                     that.baColor = "background-color: #1cbbb4;"
                  } else if (res.code === 403 ) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
               }
            });
         },
         toPrint(item) {
            let that = this
            uni.navigateTo({
               url: "../print/print",
               success: function(res) {
                  // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                  res.eventChannel.emit('data', {
                     data: item
                  })
               },
               events: {
                  // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据  另外一个页面传过来的
                  acceptDataFromOpenedPage: function(data) {
                     that.matnr = data.data
                     that.findMat(that.matnr)
                  },
               },
            });
         }
      }
   }
</script>
<style>
   @import url('../../static/css/wms.css/wms.css');
   .tag-list {
      width: 94%;
      min-height: 160rpx;
      margin: 10px auto;
      background-color: #FFF;
      border-radius: 5px;
      box-shadow: 0 5upx 20upx rgba(0, 0, 0, 0.2);
   }
   .tag {
      display: flex;
      flex-direction: column;
      min-height: 80rpx;
      border-bottom: 1px solid #e2e2e2;
   }
   .wms-tag {
      min-width: 60rpx;
      margin-left: 50rpx;
      margin-top: 30rpx;
      color: #FFF;
      font-size: 14px;
      padding: 4rpx 12rpx;
   }
   .tag-item {
      width: 100%;
      min-height: 60rpx;
      line-height: 2;
      padding-left: 50rpx;
      color: #606266;
      font-size: 14px;
   }
</style>