1
yangpeixing
2026-03-12 9181f3dce9e6f617b34fa80b7bb72bb490be788b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<template>
  <view>
    <u-sticky>
      <view style="background-color: #ffffff;">
        <uni-search-bar @confirm="search" v-model="searchValue" @input="handleSearchInput"></uni-search-bar>
      </view>
    </u-sticky>
 
    <!-- 移除了内部滚动容器,让页面自然滚动,所有数据都会显示 -->
    <uni-list :border="true">
      <uni-list-item
        direction="column"
        v-for="item in allReceivingOrders"
        :key="item.orderNo"
        clickable
        @click="groupClick(item.orderNo)"
        link
        :to="page + 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;">
              入库单号:&nbsp;&nbsp;{{ item.orderNo }}
            </view>
            <view style="margin-top: 10rpx;line-height: 17px;color: #596671;font-size: 14px;text-align: center;display: flex;justify-content: space-between;">
              创建人员:&nbsp;&nbsp;{{ item.creater }}
            </view>
            <view style="margin-top: 10rpx;line-height: 17px;color: #596671;font-size: 14px;text-align: center;display: flex;justify-content: space-between;">
              创建日期:&nbsp;&nbsp;{{ item.createDate }}
            </view>
            <view style="margin-top: 10rpx;line-height: 17px;color: #596671;font-size: 14px;text-align: center;display: flex;justify-content: left;">
              物料料号:&nbsp;&nbsp;
              <view class="container">
                <view v-for="(materielCode, index) in getUniqueMaterielCodes(item.details)" :key="index">
                  {{ materielCode }}
                  <u-line color="blue" v-if="index < getUniqueMaterielCodes(item.details).length - 1" />
                </view>
              </view>
            </view>
            <view style="margin-top: 10rpx;display: flex;align-items: center;">
              <view style="text-align: center;line-height: 40rpx;border-radius: 8rpx; width: 238rpx;height: 40rpx;font-size: 22rpx;background-color:rgba(22,127,247,0.18);color: #1F63FF;">
                订单状态:&nbsp;&nbsp;{{ item.InboundOrderStatus }}
              </view>
              <view style="text-align: center;line-height: 40rpx;border-radius: 8rpx; width: 158rpx;height: 40rpx;font-size: 22rpx;color: #F56C6C;">
                总量:&nbsp;&nbsp;{{ item.SumQty }}
              </view>
              <view style="text-align: center;line-height: 40rpx;border-radius: 8rpx; width: 158rpx;height: 40rpx;font-size: 22rpx;color: #F56C6C;">
                已入:&nbsp;&nbsp;{{ item.OverQty }}
              </view>
            </view>
          </uni-group>
        </template>
      </uni-list-item>
    </uni-list>
 
    <!-- 移除加载更多组件,因为不分页了 -->
    <!-- <uni-load-more :status="status" v-if="loadVisible && allReceivingOrders.length > 0"></uni-load-more> -->
 
    <!-- 空数据提示 -->
    <view v-if="allReceivingOrders.length === 0 && !isLoading" style="text-align: center; padding: 100rpx 0; color: #999;">
      暂无入库订单数据
    </view>
 
    <!-- 返回顶部按钮(可选) -->
    <u-back-top :scroll-top="scrollTop" top="400"></u-back-top>
  </view>
</template>
 
<script>
import { InboundOrderStatus } from '../../common/config.js';
 
export default {
  data() {
    return {
      page: '/pages/stash/raworderboxing?',
      searchValue: '',
      allReceivingOrders: [], // 显示在前端的数据(可能被搜索过滤)
      originalOrders: [], // 存储所有原始数据
      scrollTop: 0,
      warehouseId: '',
      isLoaded: false, // 是否从详情页返回
      isLoading: false, // 防止重复请求
    };
  },
  onLoad(res) {
    this.warehouseId = res.warehouseId;
    this.page = this.page + 'warehouseId=' + this.warehouseId + '&orderNo=';
    // 直接加载全部数据(不分页)
    this.getAllData();
  },
  onShow() {
    // 从详情页返回时,如果数据已被修改,可以重新加载
    if (this.isLoaded) {
      this.getAllData();
      this.isLoaded = false;
    }
  },
  onPageScroll(e) {
    this.scrollTop = e.scrollTop;
  },
  methods: {
    // 物料料号去重
    getUniqueMaterielCodes(details) {
      if (!details || !Array.isArray(details)) return [];
      return [...new Set(details.map(item => item.materielCode))];
    },
 
    // 搜索输入处理(前端筛选)
    handleSearchInput() {
      if (this.searchValue === '') {
        this.allReceivingOrders = [...this.originalOrders];
        return;
      }
      const searchText = this.searchValue.toLowerCase().trim();
      this.allReceivingOrders = this.originalOrders.filter(item => {
        if (item.orderNo && item.orderNo.toLowerCase().includes(searchText)) {
          return true;
        }
        if (item.details && item.details.length > 0) {
          return item.details.some(detail =>
            detail.materielCode && detail.materielCode.toLowerCase().includes(searchText)
          );
        }
        return false;
      });
    },
 
    search() {
      this.handleSearchInput();
    },
 
    groupClick() {
      this.isLoaded = true;
    },
 
    // 一次性获取所有数据(不分页)
    getAllData() {
      if (this.isLoading) return;
      this.isLoading = true;
 
      // 设置一个足够大的 pageSize 来获取所有数据(根据接口最大限制调整)
      const postData = {
        MainData: {
          warehouseId: this.warehouseId,
          orderNo: '',
          pageNo: 1,
          pageSize: 9999, // 假设接口支持这么大的分页
        },
      };
 
      this.$u
        .post('/api/InboundOrder/GetInboundOrders', postData)
        .then(res => {
          this.isLoading = false;
          if (res.status) {
            console.log(res.data);
            const newData = res.data.map(i => ({
              ...i,
              InboundOrderStatus: InboundOrderStatus.find(item => item.value == i.orderStatus)?.label || '未知状态',
              SumQty: i.details?.map(item => item.orderQuantity).reduce((prev, next) => prev + next, 0) || 0,
              OverQty: i.details?.map(item => item.overInQuantity).reduce((prev, next) => prev + next, 0) || 0,
            }));
 
            this.originalOrders = newData; // 直接替换,不分页追加
            // 根据搜索词过滤显示
            if (this.searchValue) {
              this.handleSearchInput();
            } else {
              this.allReceivingOrders = [...this.originalOrders];
            }
          } else {
            this.$u.toast('数据加载失败,请重试');
          }
        })
        .catch(err => {
          this.isLoading = false;
          this.$u.toast('网络异常,请检查网络');
        });
    },
  },
};
</script>
 
<style scoped>
.container {
  display: flex;
  flex-wrap: wrap;
  gap: 10rpx;
}
.container view {
  white-space: nowrap;
}
</style>