1
yangpeixing
2026-03-31 e9fbecd61a9ab8c5d906269150b6cdc8ca86dfdb
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<template>
    <view>
        <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem">
        </uni-segmented-control>
        <view class="content">
            <view v-if="current === 0" class="headerstyle">
                <view class="itemstyle">
                    <uni-forms label-width="180">
                        <uni-forms-item :label="label">
                        </uni-forms-item>
                        <uni-forms-item label="托盘条码:">
                            <uni-easyinput type="text" placeholder="请扫描托盘条码" ref='midInput' :focus="!focus"
                                v-model="barcode" @confirm="barcodeInput" />
                        </uni-forms-item>
                        <uni-forms-item label="内箱标签:">
                            <uni-easyinput type="text" placeholder="请扫描箱号(如BOX202510160019)" ref='midInput'
                                :focus="focus" v-model="materSn" @confirm="snInput" />
                        </uni-forms-item>
 
                        <uni-forms-item :label="Testlabel" v-if="Test">
                            <uni-easyinput type="text" :placeholder="Testplaceholder" ref='midInput'
                                v-model="Initiallife" />
                        </uni-forms-item>
 
                        <uni-forms-item>
                            <view style="display: flex;justify-content: space-around;margin-top: 2%;">
                                <button @click="reset" type="default" size="default"
                                    style="width: 160rpx;border: 1rpx solid #007aff;color: #007aff;">重置</button>
                                <button @click="submit" type="primary" size="default" style="width: 160rpx;">组盘</button>
                            </view>
                        </uni-forms-item>
                    </uni-forms>
                    <uni-list>
                        <uni-list-item direction="column" v-for="(item,index) in matInfos" :key="index">
                            <template v-slot:body>
                                <view class="uni-list-box">
                                    <uni-icons type="trash" size="22" style="position: absolute;right: 5%;"
                                        @click="deleteList(index)">
                                    </uni-icons>
                                    <view class="uni-content">
                                        <view class="uni-title-sub uni-ellipsis-2">箱号:{{item.boxNumber}}</view>
                                        <view class="uni-note">数量:{{item.quantity}}</view>
                                    </view>
                                </view>
                            </template>
                        </uni-list-item>
                    </uni-list>
                </view>
            </view>
            <view v-if="current === 1" class="headerstyle">
                <view class="itemstyle">
                    <uni-forms label-width="120">
                        <uni-forms-item label="托盘条码">
                            <uni-easyinput type="text" :focus="!addressFocus" v-model="inboundBarcode"
                                placeholder="请扫描托盘条码" ref='midInput' @confirm="inputChangebarcode" />
                        </uni-forms-item>
                        <uni-forms-item label="地址条码">
                            <uni-easyinput type="text" v-model="address" :disabled="addressdisabled"
                                placeholder="请扫描地址条码" ref='midInput' :focus="addressFocus" />
                        </uni-forms-item>
                        <uni-forms-item>
                            <button @click="inbound" type="primary" size="default" style="margin-top: 2%;">入库确认</button>
                        </uni-forms-item>
                    </uni-forms>
                </view>
            </view>
            <view v-if="current === 2" class="headerstyle">
                <view class="itemstyle">
                    <uni-list :border="true">
                        <uni-list-item direction="column" v-for="(item,index) in orderInfo" :key="index">
                            <template v-slot:body>
                                <view class="uni-list-box">
                                    <view class="uni-content">
                                        <view style="font-size: 18px;">单据号:{{orderNo}}</view>
                                        <view style="font-size: 18px;">物料编码:{{item.materielCode}}</view>
                                        <view>物料名称:{{item.materielName}}</view>
                                        <view style="font-size: 18px;">数量:{{item.orderQuantity}}</view>
                                        <view style="font-size: 18px;">组盘数量:{{item.receiptQuantity}}</view>
                                    </view>
                                </view>
                            </template>
                        </uni-list-item>
                    </uni-list>
                </view>
            </view>
            <view v-if="current === 3" class="headerstyle">
                <view class="itemstyle">
                    <uni-forms label-width="180">
                        <uni-forms-item label="内箱标签:">
                            <uni-easyinput type="text" placeholder="请扫描箱号(如BOX202510160019)" ref='midInput'
                                :focus="!pkfocus" v-model="pkmaterSn" @confirm="pksnInput" />
                        </uni-forms-item>
 
                        <uni-forms-item>
                            <view style="display: flex;justify-content: space-around;margin-top: 2%;">
                                <button @click="resetInPk" type="default" size="default"
                                    style="width: 160rpx;border: 1rpx solid #007aff;color: #007aff;">重置</button>
                                <button @click="pksubmit" type="primary" size="default"
                                    style="margin-top: 2%;">入平库</button>
                            </view>
                        </uni-forms-item>
 
                    </uni-forms>
                    <uni-list>
                        <uni-list-item direction="column" v-for="(item,index) in pkmatInfos" :key="index">
                            <template v-slot:body>
                                <view class="uni-list-box">
                                    <uni-icons type="trash" size="22" style="position: absolute;right: 5%;"
                                        @click="pkdeleteList(index)">
                                    </uni-icons>
                                    <view class="uni-content">
                                        <view class="uni-title-sub uni-ellipsis-2">箱号:{{item.boxNumber}}</view>
                                        <view class="uni-note">数量:{{item.quantity}}</view>
                                    </view>
                                </view>
                            </template>
                        </uni-list-item>
                    </uni-list>
                </view>
            </view>
        </view>
        <u-toast ref="uToast" />
    </view>
</template>
 
<script>
    const innerAudioContext = uni.createInnerAudioContext();
    export default {
        data() {
            return {
                items: ['组盘', '入库', '单据信息'],
                current: 0,
                matTotal: [],
                matInfos: [],
                orderNo: "",
                label: "",
                orderInfo: [],
                focus: false,
                pkfocus: false,
                barcode: "",
                materSn: "",
                Initiallife: 1000,
                sns: [],
                pksns: [],
                addressFocus: false,
                inboundBarcode: "",
                address: "",
                check: true,
                value: "",
                matInfo: [],
                value2: "",
                matTotals: [],
                warehouseId: "",
                Test: false,
                Testlabel: "",
                Testplaceholder: "",
                Testcheck: false,
                pkmaterSn: "",
                pkmatInfos: [],
                addressdisabled: false
            }
        },
        onShow() {},
        onLoad(res) {
            this.focus = false;
            this.addressFocus = false;
            this.orderNo = res.orderNo;
            this.warehouseId = res.warehouseId;
            this.label = "单据编号:" + this.orderNo;
            this.getData();
        },
        methods: {
            // 组盘页数量编辑校验
            handleQuantityChange(item) {
                item.quantity = item.quantity ? Math.max(1, parseInt(item.quantity)) : 1;
            },
            updateFocus() {
                this.$nextTick(() => {
                    this.materSn = '';
                    if (!this.focus) {
                        this.focus = true;
                    }
                });
            },
 
            barcodeFocus() {
                this.barcode = '';
                if (this.focus) {
                    this.focus = false;
                }
            },
 
 
            onClickItem(e) {
                this.focus = false;
                this.addressFocus = false;
                if (this.current !== e.currentIndex) {
                    this.current = e.currentIndex;
                    if (this.current == 2) {
                        this.getData();
                    }
                }
            },
 
            barcodeInput() {
                this.$nextTick(function(x) {
                    if (this.barcode.length > 0) {
                        this.focus = true;
                    }
                })
            },
 
            // 组盘页箱号扫描
            snInput() {
                this.$nextTick(() => {
                    if (!this.materSn) return;
 
                    // 延迟100ms确保扫码完成
                    setTimeout(() => {
                        this.focus = false;
                        let boxNumber = this.materSn.trim();
 
                        // 校验是否已扫描过
                        const isAlreadyScanned = this.sns.some(sn => sn === boxNumber);
                        if (isAlreadyScanned) {
                            this.$refs.uToast.show({
                                title: "该箱号已扫描,请勿重复扫描",
                                type: "warning"
                            });
                            this.materSn = "";
                            return;
                        }
 
                        // 简单校验箱号格式(以BOX开头)
                        if (!boxNumber.startsWith('BOX')) {
                            this.$refs.uToast.show({
                                title: "箱号格式错误,应以BOX开头",
                                type: "error"
                            });
                            this.materSn = "";
                            return;
                        }
 
                        // 添加箱号到列表
                        const boxData = {
                            boxNumber: boxNumber,
                            quantity: 1, // 默认数量为1
                            serialNumber: boxNumber // 箱号作为序列号
                        };
 
                        this.sns.push(boxNumber);
                        this.matInfos.push(boxData);
 
                        this.$refs.uToast.show({
                            title: "箱号添加成功",
                            type: "success"
                        });
 
                        this.materSn = "";
                        this.$nextTick(() => {
                            this.focus = true;
                        });
                    }, 100);
                })
            },
 
            inputChangebarcode() {
                this.addressFocus = false;
                this.$nextTick(function(x) {
                    if (this.inboundBarcode != '') {
                        this.addressFocus = true;
                    }
                })
            },
 
            deleteList(res) {
                this.matInfos.splice(res, 1);
                this.sns.splice(res, 1);
            },
 
            pkdeleteList(res) {
                this.pkmatInfos.splice(res, 1);
                this.pksns.splice(res, 1);
            },
 
            reset() {
                this.barcode = "";
                this.matInfos = [];
                this.sns = [];
                this.materSn = "";
                if (this.warehouseId != 6) {
                    this.Initiallife = 0;
                }
            },
 
            resetInPk() {
                this.pkmaterSn = "";
                this.pkfocus = false;
                this.pkmatInfos = [];
                this.pksns = [];
            },
 
            submit() {
                if (this.barcode == "") {
                    this.$refs.uToast.show({
                        title: "请扫描托盘条码",
                        type: 'error'
                    })
                    return;
                }
                if (this.matInfos.length == 0) {
                    this.$refs.uToast.show({
                        title: "请扫描箱号",
                        type: 'error'
                    })
                    return;
                }
                if (this.Test) {
                    if (!this.Testcheck) {
                        this.Testcheck = true;
                        if (this.warehouseId == 2) {
                            this.$refs.uToast.show({
                                title: "请确认数量",
                                type: 'error'
                            })
                        } else if (this.warehouseId == 6) {
                            this.$refs.uToast.show({
                                title: "请确认初始寿命",
                                type: 'error'
                            })
                        }
                        return;
                    }
                }
 
                // 使用箱号数据提交
                let submitSns = this.matInfos.map(item => ({
                    serialNumber: item.serialNumber,
                    quantity: item.quantity
                }));
 
 
 
                this.$u.post('/api/TakeStockOrderCP/TakeStockOrderCP', {
                    MainData: {
                        "palletCode": this.barcode,
                        "orderNo": this.orderNo,
                        "initiallife": this.Initiallife,
                        "warehouseId": this.warehouseId
                    },
                    DelKeys: submitSns
                }).then(res => {
                    this.Testcheck = false;
                    if (res.status) {
                        this.$refs.uToast.show({
                            title: "组盘成功",
                            type: "success"
                        })
                        this.focus = false;
                        this.barcode = "";
                        this.matInfos = [];
                        this.sns = [];
                        this.matTotal = [];
                        if (this.warehouseId != 6) {
                            this.Initiallife = "";
                        }
                    } else {
                        this.$refs.uToast.show({
                            title: res.message,
                            type: "error"
                        })
                    }
                })
            }
        }
    }
</script>
 
<style lang="scss">
    @import '@/common/uni-ui.scss';
 
    .content {
        display: flex;
        height: 150px;
    }
 
    .content-text {
        font-size: 14px;
        color: #666;
    }
 
    .itemstyle {
        margin-top: 30px;
        margin-left: 5%;
    }
 
    .headerstyle {
        width: 90%;
    }
</style>