647556386
2 天以前 2f8fc989f339a936b01092caebd4c46e6109da1b
¼ª°²PDA/pages/stash/TakeStockOrder.vue
@@ -6,16 +6,34 @@
         </view>
      </u-sticky>
      <uni-list :border="true">
         <uni-list-item direction="column" clickable @click="groupClick(item.orderNo)" link
            :to="page+item.orderNo+'&warehouseId='+warehouseId+'&id='+item.id" v-for="item in allReceivingOrders"
            :key="item.orderNo">
         <uni-list-item
            direction="column"
            clickable
            @click="groupClick(item.orderNo)"
            link
            :to="`${page}${item.orderNo}&warehouseId=${warehouseId}&id=${item.id}`"
            v-for="item in allReceivingOrders"
            :key="item.orderNo"
         >
            <template v-slot:body>
               <uni-group margin-top="20">
                  <view style="line-height: 17px;color: #596671;font-size: 14px;text-align: center;display: flex;justify-content: space-between;">
                  <view style="line-height: 17px;color: #596671;font-size: 14px;display: flex;justify-content: space-between;">
                     ç›˜ç‚¹å•号&nbsp;&nbsp;{{item.orderNo}} 
                  </view>
                  <view style="line-height: 17px;color: #596671;font-size: 14px;text-align: center;display: flex;justify-content: space-between;">
                  <view style="line-height: 17px;color: #596671;font-size: 14px;display: flex;justify-content: space-between;">
                     åˆ›å»ºæ—¶é—´&nbsp;&nbsp;{{item.createDate}} 
                  </view>
                  <!-- æ‰˜ç›˜ç¼–号展示区域 -->
                  <view style="line-height: 17px;color: #596671;font-size: 14px;margin-top: 10rpx;">
                     éœ€ç›˜ç‚¹ç›˜å·ï¼š
                     <view style="display: inline-flex;flex-wrap: wrap;margin-left: 10rpx;">
                        <text
                           style="display: inline-block;background-color: #f5f5f5;padding: 2rpx 10rpx;border-radius: 4rpx;margin: 0 5rpx 5rpx 0;"
                           v-for="(detail, index) in item.details"
                           :key="index">
                           {{detail.takePalletCode}} ,料号:{{detail.materielCode}}
                        </text>
                     </view>
                  </view>
                  <view
                     style="margin-top: 10rpx;display: flex;align-items: center; ">
@@ -26,9 +44,13 @@
               </uni-group>
            </template>
         </uni-list-item>
      </uni-list>
      <uni-load-more :status="status" v-if="loadVisible"></uni-load-more>
      <!-- åŠ è½½æ›´å¤šç»„ä»¶ -->
      <uni-load-more
         :status="status"
         :show-icon="true"
         v-if="allReceivingOrders.length > 0 || status === 'loading'"
      ></uni-load-more>
      <u-back-top :scroll-top="scrollTop" top="400"></u-back-top>
   </view>
@@ -40,95 +62,118 @@
      data() {
         return {
            page: "/pages/stash/TakeStock?orderNo=",
            loadVisible: false,
            searchValue: "",
            warehouseId: "",
            status: "more",
            status: "more", // åŠ è½½çŠ¶æ€ï¼šmore-可加载,loading-加载中,noMore-无更多
            allReceivingOrders: [],
            pageNo: 1,
            pageSize: 5, // å…³é”®ä¿®å¤ï¼šä¸ŽåŽç«¯ä¿æŒä¸€è‡´ï¼ˆæ¯é¡µ5条)
            scrollTop: 0,
            isLoaded:false
            isLoaded: false,
            isLoading: false, // é˜²æ­¢é‡å¤åŠ è½½çš„é”
            hasMore: true // æ˜¯å¦è¿˜æœ‰æ›´å¤šæ•°æ®
         }
      },
      onLoad(res) {
         this.warehouseId = res.warehouseId;
         this.isLoaded = true;
         this.getData();
         this.resetData(); // é‡ç½®æ•°æ®å¹¶åŠ è½½ç¬¬ä¸€é¡µ
      },
      onPageScroll(e) {
         this.scrollTop = e.scrollTop;
      },
      onShow() {
         if (this.isLoaded) {
            // ä»Žå…¶ä»–页面返回时刷新
            this.getData();
            this.resetData();
         }
      },
      onReachBottom() {
         this.pageNo += 1;
         this.getData();
         // ä¸‹æ‹‰åˆ°åº•部时加载更多
         if (this.hasMore && !this.isLoading) {
            this.pageNo += 1;
            this.getData();
         }
      },
      methods: {
         search(res) {
         // æœç´¢æ—¶é‡ç½®æ•°æ®
         search() {
            this.resetData();
         },
         // é‡ç½®æ•°æ®åˆ°åˆå§‹çŠ¶æ€
         resetData() {
            this.pageNo = 1;
            this.allReceivingOrders = [];
            this.hasMore = true;
            this.status = "more";
            this.getData();
         },
         groupClick() {
            // ç‚¹å‡»äº‹ä»¶å¤„理
         },
         // èŽ·å–æ•°æ®
         getData() {
            var postData = {
            if (this.isLoading || !this.hasMore) return;
            this.isLoading = true;
            this.status = "loading";
            const postData = {
               MainData: {
                  orderNo: this.searchValue,
                  pageNo: this.pageNo,
                  // åŽç«¯å›ºå®šæ¯é¡µ5条,这里可以不传递pageSize,保持与后端一致
                  warehouseId: this.warehouseId,
               },
            }
            this.$u.post('/api/TakeStockOrder/GetTakeStockOrders', postData).then((res) => {
               if (res.status) {
                  if (res.data.length > 0) {
                     if (this.searchValue == '') {
                        this.allReceivingOrders =res.data.map(i => ({
                        ...i,
                        takeStockStatus: TakeStockStatus.find(item => item.value == i
                           .takeStockStatus).label
                        }))
                        // this.allReceivingOrders = res.data;
                        if (this.allReceivingOrders.length > 3) {
                           this.loadVisible = true;
            this.$u.post('/api/TakeStockOrder/GetTakeStockOrders', postData)
               .then((res) => {
                  this.isLoading = false;
                  if (res.status) {
                     const processedData = res.data.map(item => ({
                        ...item,
                        takeStockStatus: TakeStockStatus.find(status => status.value === item.takeStockStatus)?.label || ''
                     }));
                     if (processedData.length > 0) {
                        if (this.pageNo === 1) {
                           this.allReceivingOrders = processedData;
                        } else {
                           this.loadVisible = false;
                           this.allReceivingOrders = [...this.allReceivingOrders, ...processedData];
                        }
                        // å…³é”®ä¿®å¤ï¼šæ ¹æ®åŽç«¯å®žé™…返回数量判断是否还有更多
                        // åŽç«¯å›ºå®šæ¯é¡µ5条,所以当返回5条时说明可能还有更多,少于5条则说明没有更多
                        this.hasMore = processedData.length === this.pageSize;
                        this.status = this.hasMore ? "more" : "noMore";
                     } else {
                        // this.allReceivingOrders = res.data;
                        if (postData.MainData.pageNo == 1) {
                        if (this.pageNo === 1) {
                           this.allReceivingOrders = [];
                        }
                        this.allReceivingOrders =res.data.map(i => ({
                        ...i,
                        takeStockStatus: TakeStockStatus.find(item => item.value == i
                           .takeStockStatus).label
                        }))
                        if (this.allReceivingOrders.length > 3) {
                           this.loadVisible = true;
                        } else {
                           this.loadVisible = false;
                        }
                        this.hasMore = false;
                        this.status = "noMore";
                     }
                  } else {
                     this.status = 'noMore';
                     //this.allReceivingOrders = [];
                     this.loadVisible = true;
                     this.status = this.pageNo > 1 ? "more" : "noMore";
                     this.$u.toast('数据加载失败,请重试');
                  }
               }
            })
               })
               .catch(() => {
                  this.isLoading = false;
                  this.status = this.pageNo > 1 ? "more" : "noMore";
                  this.$u.toast('网络错误,请检查网络');
               });
         }
      }
   }
</script>
<style lang="scss">
   /* æ ·å¼ä¿æŒä¸å˜ */
   @import '@/common/uni-ui.scss';
   page {