#
zhou zhou
5 天以前 1c6a21c92ce324333e15944cc581c57e3637b1cf
pages/listing/itemSelect.vue
@@ -2,12 +2,12 @@
   <view>
      <!-- 搜索框 -->
      <view class="search-bar">
         <uni-search-bar v-model="condition" placeholder=" 输入批次" bgColor="#EEEEEE"  />
         <uni-search-bar v-model="condition" placeholder=" 输入批次/编码/单号" bgColor="#EEEEEE"  @confirm="search()"/>
      </view>
      
       
      <view>
         <view class="padding-lr margin-top-sm">
         <view class="padding-lr margin-top-sm" style="padding-bottom: 120upx;">
            <block v-for="(item, index) in matList" :key="index">
               <view class="cu-list det menu sm-border margin-bottom-sm " :class="[item.selected === true &&'act']" @click="selectedItem(index)">
                  <view class="cu-bar bg-white solid-bottom " >
@@ -16,7 +16,7 @@
                           {{index+1}}
                        </view>
                        <view class="text-blue">
                           编码:
                           物料编码:
                           {{`${item.matnrCode}`}}
                        </view>
                     </view>
@@ -27,7 +27,13 @@
                  </view>
                  <view class="cu-item">
                     <view class="content">
                        <text class="text-black">ASN:</text>
                        <text class="text-black">物料名称:</text>
                        <text class="text-grey">{{ item.maktx }}</text>
                     </view>
                  </view>
                  <view class="cu-item">
                     <view class="content">
                        <text class="text-black">单据编号:</text>
                     </view>
                     <view class="action">
                        <text class="text-grey ">{{item.asnCode}}</text>
@@ -35,15 +41,15 @@
                  </view>
                  <view class="cu-item">
                     <view class="content">
                        <text class="text-black">物料条码:</text>
                        <text class="text-black">计划跟踪号:</text>
                     </view>
                     <view class="action">
                        <text class="text-grey ">{{item.trackCode}}</text>
                        <text class="text-grey ">{{item.platWorkCode}}</text>
                     </view>
                  </view>
                  <view class="cu-item">
                     <view class="content">
                        <text class="text-black">供应商批次:</text>
                        <text class="text-black">批次:</text>
                     </view>
                     <view class="action">
                        <text class="text-grey ">{{item.splrBatch}}</text>
@@ -51,52 +57,43 @@
                  </view>
                  <view class="cu-item">
                     <view class="content">
                        <text class="text-black">库存批次:</text>
                     </view>
                     <view class="action">
                        <text class="text-grey ">{{item.batch}}</text>
                     </view>
                  </view>
                  <!-- <view class="cu-item">
                     <view class="content">
                        <text class="text-black">平台行号: <text class="text-grey ">{{item.platformId}}</text></text>
                     </view>
                     <view class="content">
                        <text class="text-black">质检结果: <text class="text-grey ">{{item.inspect}}</text></text>
                     </view>
                  </view> -->
                  <view class="cu-item">
                     <view class="content">
                        <text class="text-black">库存单位: <text class="text-grey ">{{item.stockUnit}}</text></text>
                        <text class="text-black">单位: <text class="text-grey ">{{item.stockUnit}}</text></text>
                     </view>
                     <view class="content">
                        <text class="text-black">收货数量: <text class="text-grey ">{{item.anfme}}</text></text>
                     </view>
                     <view class="content">
                        <text class="text-black">已上架数量: <text
                              class="text-grey ">{{item.workQty + item.qty}}</text></text>
                     </view>
                  </view>
                  <view class="cu-item">
                     <view class="content">
                        <text class="text-black">可组盘数量: <text
                              class="text-grey ">{{item.anfme - item.workQty}}</text></text>
                              class="text-grey ">{{item.ableQty}}</text></text>
                     </view>                     
                  </view>
                  
               </view>
            </block>
            <!-- 空状态 -->
            <view class="empty-state" v-if="matList.length === 0 && !loading">
               <uni-icons type="search" size="60" color="#CCCCCC"></uni-icons>
               <text class="empty-text">暂无数据</text>
               <text class="empty-hint">下拉刷新试试</text>
            </view>
            <!-- 加载更多 -->
            <uni-load-more v-show="matList.length !== 0" :status="status" :icon-size="16" :content-text="contentText" />
         </view>
      </view>
      <view class="cu-bar btn-group foot">         
         <button class="cu-btn bg-blue shadow-blur" :disabled="repeatClick" @click="back">确定</button>
      </view>
      <!-- <uni-load-more v-show="matList.length != 0" :status="status" :icon-size="16" :content-text="contentText" /> -->
   </view>
</template>
<script>
   import {
      request
   } from '../../common/request.js'
   export default {
      data() {
         return {            
@@ -110,14 +107,32 @@
            selectedList:[],
            repeatClick: false,
            matnrCode:'',
            asnCode:''
            asnCode:'',
            // 分页相关
            curr: 1,
            pageSize: 5,
            loading: false,
            status: 'more',
            contentText: {
               contentdown: '上拉加载更多',
               contentrefresh: '加载中',
               contentnomore: '没有更多'
            },
            // 保存查询参数
            lastReq: null
         }
      },
      // onReachBottom() {
      //    this.status = 'more';
      //    this.showMat(this.tagIdNow);
      // },
      // 下拉刷新
      onPullDownRefresh() {
         this.refreshData();
      },
      // 上拉加载更多
      onReachBottom() {
         if (this.status !== 'noMore' && !this.loading) {
            this.status = 'loading';
            this.loadMoreData();
         }
      },
      onLoad() {
         // 没啥用了
         let that = this
@@ -126,8 +141,7 @@
         
         // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
         eventChannel.on('data', function(data) {
            console.log(data.item)
            that.matList = data.item
            that.getDet(data)
         })
      },
      onShow() {
@@ -136,6 +150,35 @@
         
      },
      methods: {
         // 刷新数据
         refreshData() {
            this.curr = 1;
            this.matList = [];
            this.status = 'more';
            if (this.lastReq) {
               this.getDet(this.lastReq, true);
            }
            uni.stopPullDownRefresh();
         },
         // 加载更多数据
         loadMoreData() {
            if (this.lastReq) {
               this.getDet(this.lastReq, false);
            }
         },
         search(){
            let req = {
               matnrCode: this.condition,
               asnCode: this.condition,
               code: this.condition,
               batch: this.condition
            }
            // 搜索时重置分页
            this.curr = 1;
            this.matList = [];
            this.status = 'more';
            this.getDet(req, true);
         },
         back() {
            for (var i = 0; i < this.matList.length; i++) {
               if(this.matList[i].selected === true){
@@ -155,28 +198,79 @@
               this.matList[index].selected = !this.matList[index].selected
            }            
         },
         async getDet() {
         async getDet(req, isRefresh = true) {
            let that = this;
            const {
               code,
               data,
               msg
            } = await request('/asnOrderItem/trackCode', {
               matnrCode: that.matnrCode,
               asnCode: that.asnCode
            }, "post")
            if (code === 200) {
               for (var i = 0; i < data.length; i++) {
                  data[i].receiptQty =0;
                  data[i].selected = false;
               }
               this.list = data
            } else {
            // 保存查询参数供刷新和加载更多使用
            this.lastReq = req;
            this.loading = true;
            if (isRefresh) {
               uni.showLoading({
                  title:'加载中...'
               })
            }
            try {
               const {
                  code,
                  data,
                  msg
               } = await request('/asnOrderItem/trackCode', {
                  matnrCode: req.matnrCode,
                  asnCode: req.asnCode,
                  code: req.code,
                  batch: req.batch,
                  curr: this.curr,
                  pageSize: this.pageSize
               }, "post")
               if (code === 200) {
                  let records = data.records || [];
                  let currentPage = data.current || 1;
                  let totalPages = data.pages || 1;
                  // 处理数据
                  for (var i = 0; i < records.length; i++) {
                     records[i].receiptQty = 0;
                     records[i].selected = false;
                  }
                  if (records.length > 0) {
                     if (isRefresh) {
                        this.matList = records;
                     } else {
                        this.matList = this.matList.concat(records);
                     }
                     this.curr = this.curr + 1;
                     // 判断是否还有更多数据
                     if (this.curr > totalPages) {
                        this.status = 'noMore';
                     } else {
                        this.status = 'more';
                     }
                  } else {
                     if (isRefresh) {
                        this.matList = [];
                     }
                     this.status = 'noMore';
                  }
               } else {
                  uni.showToast({
                     title: msg,
                     icon: "none",
                     position: 'top'
                  })
               }
            } catch (err) {
               uni.showToast({
                  title: msg,
                  title: '网络请求失败',
                  icon: "none",
                  position: 'top'
               })
            } finally {
               this.loading = false;
               uni.hideLoading();
               uni.stopPullDownRefresh();
            }
         },
         
@@ -213,5 +307,26 @@
      display: flex;
      min-height: 80upx;
      align-items: center;
   }
   }
   /* 空状态 */
   .empty-state {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 120rpx 0;
   }
   .empty-text {
      font-size: 30rpx;
      color: #909399;
      margin-top: 30rpx;
   }
   .empty-hint {
      font-size: 24rpx;
      color: #c0c4cc;
      margin-top: 12rpx;
   }
</style>