#
zhou zhou
18 小时以前 8d3ebc610d048289f8ca4d8bc86ac11208a60fef
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<template>
    <view class="page-container">
        <!-- 订单信息头部 -->
        <view class="order-header" v-if="orderItem">
            <view class="header-content">
                <view class="header-row">
                    <text class="header-label">物料编码</text>
                    <text class="header-value">{{orderItem.matnrCode}}</text>
                </view>
                <view class="header-row">
                    <text class="header-label">物料名称</text>
                    <text class="header-value">{{orderItem.maktx || '-'}}</text>
                </view>
                <view class="header-row">
                    <text class="header-label">总出库数量</text>
                    <text class="header-value highlight-white">{{orderItem.anfme || 0}}</text>
                </view>                
            </view>
        </view>
        
        <!-- 库位视图列表 -->
        <view class="padding-lr margin-top-sm">
            <block v-for="(item, index) in locList" :key="index">
                <view class="cu-list menu sm-border margin-bottom-sm">
                    <view class="cu-bar bg-white solid-bottom">
                        <view class="action">
                            <view class="index">{{index+1}}</view>
                            <view class="text-blue">
                                库位: {{item.locCode || '-'}}
                            </view>
                        </view>
                        <view class="action">
                            <text class="text-black">库存:</text>
                            <text class="text-blue margin-left-xs">{{item.anfme || 0}}</text>
                        </view>
                    </view>
                    <view class="cu-item">
                        <view class="content">
                            <text class="text-black">计划跟踪号:</text>
                            <text class="text-grey margin-left-xs">{{item.platWorkCode || '-'}}</text>
                        </view>                        
                    </view>
                    <view class="cu-item">
                        <view class="content">
                            <text class="text-black">批次:</text>
                            <text class="text-grey margin-left-xs">{{item.batch || '-'}}</text>
                        </view>                        
                    </view>
                    
                    <view class="cu-item">
                        <view class="content">
                            <text class="text-black">托盘:</text>
                            <text class="text-grey margin-left-xs">{{item.barcode || '-'}}</text>
                        </view>                        
                    </view>
                    <view class="cu-item">
                        <view class="content">
                            <text class="text-black">区域:</text>
                            <text class="text-grey margin-left-xs">{{item.wareArea || '-'}}</text>
                        </view>                        
                    </view>
 
                    <view class="cu-item" v-if="item.anfme">
                        <view class="content">
                            <text class="text-blue">出库数量:</text>                            
                        </view>
                        <view class="action">
                            <uni-number-box
                                :min="0"
                                :max="item.anfme"
                                :decimal="2"
                                :step="0.01"
                                v-model="item.outQty"
                            ></uni-number-box>
                        </view>                        
                    </view>
                    
                    <view class="cu-item" v-if="item.anfme">
                        <view class="content">
                            <text class="text-blue">出库站:</text>                            
                        </view>
                        <view class="action">                            
                            <input placeholder="请输入出库站点" v-model="item.outStaInput" @input="checkAgvStation(item)"></input>
                        </view>                
                    </view>
                    <view class="cu-item" v-if="item.anfme">
                        <view class="content">
                            <button
                                style="width: 100%;"
                                class="cu-btn bg-orange shadow-blur"
                                :disabled="repeatClick"
                                @click="confirmOut(item)"
                            >
                                确定出库
                            </button>
                        </view>
                                    
                    </view>
                </view>
            </block>
        </view>
        
        <!-- 空状态 -->
        <view class="empty-state" v-if="locList.length === 0 && !loading">
            <uni-icons type="info" size="60" color="#CCCCCC"></uni-icons>
            <text class="empty-text">暂无库位数据</text>
        </view>
        
        <!-- 统计信息 -->
        <view class="stats-bar" v-if="locList.length > 0">
            <view class="stats-item">
                <text class="stats-value">{{locList.length}}</text>
                <text class="stats-label">库位数</text>
            </view>
            <view class="stats-divider"></view>
            <view class="stats-item">
                <text class="stats-value">{{totalQty}}</text>
                <text class="stats-label">总库存</text>
            </view>
        </view>
    </view>
</template>
 
<script>
    import { request } from '@/common/request.js'
    export default {
        data() {
            return {
                orderItem: null,
                locList: [],
                loading: false,
                repeatClick:false
            }
        },
        computed: {
            // 计算总库存数量
            totalQty() {
                return this.locList.reduce((sum, item) => sum + (item.anfme || 0), 0);
            }
        },
        onLoad() {
            let that = this;
            const eventChannel = this.getOpenerEventChannel();
            if (eventChannel) {
                eventChannel.on('orderItem', function(data) {
                    that.orderItem = data.item;
                    that.getOutLocView(that.orderItem);
                });
            }
        },
        methods: {
            async checkAgvStation(item) {
                const that = this
                if (item.outStaInput === '' || item.outStaInput === null) {
                    uni.showToast({
                        title: '容器码为空',
                        icon: 'none',
                        position: 'top'
                    })
                    return
                }
                const { code, data, msg } = await request('/check/agvStation', {
                    transferStationNo: item.outStaInput
                })
                if (code === 200) {
                    item.agvStationName = data.stationName
                } else {
                    uni.showToast({
                        title: msg,
                        icon: 'none',
                        position: 'top'
                    })
                    setTimeout(function () {
                        item.agvStationName = ''
                        item.outStaInput = ''
                    }, 200)
                }
            },
            confirmOut(item){
                if (item.agvStationName === '' || item.agvStationName === null || item.agvStationName === undefined) {
                    uni.showToast({
                        title: '出库站为空',
                        icon: 'none',
                        position: 'top'
                    })
                    return
                }
                if (item.outQty === 0 || item.outQty === null) {
                    uni.showToast({
                        title: '出库数量不能为0',
                        icon: 'none',
                        position: 'top'
                    })
                    return
                }
                this.submitConfirm(item)
            },
            async submitConfirm(item){
                this.repeatClick = true
                try {
                    const requestData = {
                        itemId: item.id,
                        outQty: item.outQty,
                        outSta: item.agvStationName
                    }
                    const { code, data, msg } = await request(
                        '/orderOut/getOutLocRun',
                        requestData
                    )
                    if (code === 200) {
                        uni.showToast({
                            title: '出库成功'
                        })                        
                        this.isconfirm = false
                        this.getOutLocView(this.orderItem);
                    } else {
                        uni.showToast({
                            title: msg,
                            icon: 'none',
                            position: 'top'
                        })
                    }
                } finally {
                    // 无论请求成功还是失败,都释放按钮锁定
                    this.repeatClick = false
                }
            },
            // 获取出库库位视图
            async getOutLocView(item) {
                if (!item) return;
                this.loading = true;
                try {
                    const res = await request('/orderOut/getOutLocView', {
                        orderItemId: item.id                        
                    }, 'POST', true);
                    
                    if (res.code === 200) {
                        this.locList = res.data || [];
                    } 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' });
                    }
                } catch (err) {
                    // request.js 已经处理了错误提示
                } finally {
                    this.loading = false;
                }
            }
        }
    }
</script>
 
<style>
    /* 引入公共样式 */
    @import url('@/static/css/common.scss');
 
    .page-container {
        padding-bottom: 120rpx;
    }
    
    /* 订单头部 */
    .order-header {
        background: linear-gradient(135deg, #0081ff 0%, #1890ff 100%);
        padding: 16rpx 20rpx;
    }
    
    .header-content {
        background: rgba(255, 255, 255, 0.15);
        border-radius: 10rpx;
        padding: 12rpx 16rpx;
    }
    
    .header-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4rpx 0;
    }
    
    .header-label {
        font-size: 24rpx;
        color: rgba(255, 255, 255, 0.7);
    }
    
    .header-value {
        font-size: 26rpx;
        color: #ffffff;
        font-weight: 500;
    }
    
    .header-value.highlight-white {
        color: #ffeb3b;
        font-weight: 600;
    }
    
    .index {
        border: 1px solid #e54d42;
        color: #e54d42;
        border-radius: 50%;
        display: block;
        width: 50rpx;
        height: 50rpx;
        line-height: 48rpx;
        text-align: center;
        margin-right: 20rpx;
        font-size: 30rpx;
    }
 
    .act .index {
        background: #0081ff;
    }
 
    .act {
        box-shadow: 0 0 10upx rgba(0, 129, 255, 0.6);
    }
 
    /* 空状态 */
    .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 60rpx 0;
    }
    
    .empty-text {
        margin-top: 20rpx;
        font-size: 28rpx;
        color: #909399;
    }
    
    /* 统计栏 */
    .stats-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        align-items: center;
        justify-content: space-around;
        background: #ffffff;
        padding: 16rpx 0;
        box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.06);
    }
    
    .stats-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        flex: 1;
    }
    
    .stats-value {
        font-size: 32rpx;
        color: #303133;
        font-weight: 600;
    }
    
    .stats-label {
        font-size: 20rpx;
        color: #909399;
        margin-top: 4rpx;
    }
    
    .stats-divider {
        width: 1rpx;
        height: 50rpx;
        background: #e8e8e8;
    }
</style>