schangxiang@126.com
2025-09-17 c0e20b1b0f1298cdc0af0037d60e74d51e364501
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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
<template>
    <view style="padding-bottom:100px">
        <cu-custom bgColor="bg-white" :isBack="true">
            <block slot="backText">
            </block>
            <block slot="content">推荐库位</block>
        </cu-custom>
        <view class="flex justify-end align-center padding_right30rpx padding_top12rpx">
            <text class="fontSize12rpx"> 操作人:{{operator}} </text>
        </view>
    <!--     <view class="text-bold width fontSize32rpx" style="padding: 10rpx 10rpx;background-color: #d6d6d6;">
            <view class="flex justify-between align-center">
                <text class="width23 padding10">入库单号</text>
                <text>{{putCode}}</text>
            </view>
        </view> -->
        <u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
 
            <u-row  class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                <u-col span="12">
                    <u-form-item label="物料编号:"  style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
                        <u-input v-model="warehouse.materialCode" ref="materialRef" placeholder="请扫码录入" @focus="warehouse.materialCode = ''"  @blur="getMaterialDetails"  style="font-weight: bolder;margin-left: 15rpx;"
                         class="width padding_left25rpx">
                        </u-input>
                    </u-form-item>
                </u-col>
 
                <!-- <u-col span="2"  @tap="containerFocus" >
                    <br/>
                    <span class="fontSize15rpx">推荐</span>
                    <u-icon name="arrow-right"  size="14" class="fontSize15rpx"></u-icon>
                </u-col> -->
                <!-- <u-col span="2">
                    <button-modal :cleaningShow='true' allTitle='全部取消' cleaningTitle='确认组盘' @allsubmit="reset" @submit='submit' />
                </u-col> -->
            </u-row>
            <!-- <u-row class="border_bottom  padding10" style="background-color: #fff;">
                <u-col span="10">
                    <u-form-item  label="库位编号:" prop="containerCode" required style="font-size: 16px;font-weight: bold;padding: 0;">
                        <u-input :focus="curFoucus" v-model.trim="warehouse.containerCode" @confirm="containerBlur"   placeholder="请扫码录入" style="font-weight: bolder;margin-left: 15rpx;" class="width padding_left25rpx">
                        </u-input>
                    </u-form-item>
                </u-col>
            </u-row> -->
        
            
        </u-form>
        <modal-code :rescode='rescode' :resmessage='resmessage' ref="resmodal" />
        <view style="margin-bottom: 200rpx;">
 
            <view v-for="(item, eindex) in singlist" :key="item.code" style="width: 100vw;display: flex;">
                <u-swipe-action :show="item.show" :index="eindex" @click="longpress"
                 @open="open" @close='close' :options="options" style="margin-bottom: 10rpx;width: 100vw;">
                    <view class="title-wrap fontSize32rpx background_fff padding15" :class="Number(item.quantity) > 0 ? 'bg_item' : '' " style="width: 100vw;">
                        <u-row>
                            <u-col span="1">
                                <text class="flex justify-center align-center" style="background-color: #f18202;color: #fff;border-radius: 50vh;width: 20px;height: 20px;">
                                    {{eindex+1}}
                                </text>
                            </u-col>
                            <u-col span="10">
                                <text class="color_f18202">
                                    {{item.code}}--{{item.batchNo}} 
                                </text>
                            </u-col>
                        </u-row>
 
                        <u-row style="margin-top: 20rpx;">
                            <u-col span="9">
                                <text class="el_batchNo">
                                    SAP位置:{{item.sap_Location}}
                                </text>
                            </u-col>
                            <!-- <u-col span="3">
                                <input class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx" v-model="item.quantity"
                                 type="number"   @blur="changeNum(item)" @click="clicki(item)" :min="1" placeholder="请输入组盘数量" /> 
                                
                            </u-col> -->
                        </u-row>
                    </view>
                </u-swipe-action>
            </view>
        </view>
        <u-popup v-model="detailshow" border-radius="14" @close="detailshow=false" mode="bottom">
            <view class="pop ">
                <h2 class="text_align_center padding_bottom18 padding15">物料信息</h2>
                <view class="line flex justify-between">
                    <text class="text-gray">物料编号</text>
                    <text>{{materlist.code}}</text>
                </view>
        
                <view class="line flex justify-between">
                    <text class="text-gray">物料名称</text>
                    <text>{{materlist.name}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">物料类型</text>
                    <text>{{materlist.materialTypeName}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">物料规格</text>
                    <text>{{materlist.specificationModel}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">长(mm)</text>
                    <text>{{materlist.long}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">宽(mm)</text>
                    <text>{{materlist.width}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">高(mm)</text>
                    <text>{{materlist.high}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">重量(kg)</text>
                    <text>{{materlist.weight}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">单位</text>
                    <text>{{materlist.unit}}</text>
                </view>
            </view>
        </u-popup> 
 
        <button-modal :cleaningShow='true' allTitle='全部取消' cleaningTitle='确认' @allsubmit="reset" @submit='containerFocus'/>
 
 
        <!-- <button-modal :cleaningShow='true' allTitle='全部取消' cleaningTitle='去入库' @allsubmit="reset" @submit='submit'/> -->
 
        <u-select v-model="containerVisible" :list="containerList" @confirm="containerConfirm"></u-select>
 
    </view>
</template>
<script>
    import ButtonModal from '../../components/buttonModal.vue'
    import ModalCode from '../../components/ModalCode.vue'
    import {getOrderNo,addGroupDisk,getMaterialList, getContainDetail, getContainerRecord ,getRecommendList} from '../../api/putIn/artificial.js'
    import {getDate} from '../../utils/dateTime.js'
    import {getAttrValue} from '../../utils/tool.js'
    export default {
        data() {
            return {
                curFoucus:true,//自动聚焦 【Editby shaocx,2022-11-23】
                rescode: 0,
                resmessage: "",
                putCode: '', //容器二维码
                detailshow: false,
                operator: '',
                focu: false, //清空按钮隐显
                focuM: false, //物料隐显按钮
                Datetime: getDate(),
                singlist: [], //物料详情
                options: [{
                        text: '详情',
                        style: {
                            backgroundColor: '#fc9f35'
                        }
                    }
                    // {
                    //     text: '删除',
                    //     style: {
                    //         backgroundColor: '#fc4b4b'
                    //     }
                    // }
                ],
                materlist: {},
                warehouse: {
                    containerCode: '',
                    materialCode: '',
                    gridNumber: 1,
                    useNumber: 0,
                    exitNumber: 0,
                },
                sap_location:'',
                gridable: true,
                gridFocus: false,
                detailable: false,
                batchNo: '', //扫码到的当前物料的批次
                warehouseRules: {
                    containerCode: [{
                        required: true,
                        message: '库位编号不能为空',
                        trigger: 'blur'
                    }],
                    // gridNumber: [{required: true,message: '栅格总数不能为空',trigger: 'blur'}],
                    // exitNumber:[{required: true,message: '本次占用数量不能为空',trigger: 'blur'}],
                    materialCode: [{
                        required: true,
                        message: '物料编号不能为空',
                        trigger: 'blur'
                    }]
                },
                orderType: 1,
                containerVisible: false,
                containerList: [],
 
                
            };
        },
        components: {
            ButtonModal,
            ModalCode
        },
        onLoad(option) {
            
        },
        onReady() {
            this.$refs.warehouseRef.setRules(this.warehouseRules)
        },
        mounted() {
            this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
            // this.getOrderNo()
        },
        computed: {
            containerCode(){
                return this.warehouse.containerCode
            }
        },
        watch:{
            containerCode(val){
                if(!val) {
                    this.detailable = false;
                    this.warehouse.exitNumber = 0
                }
            },
            singlist(val) {
                this.warehouse.exitNumber = val.length
            }
        },
        methods: {
            gridBtnClick() {
                this.gridable = !this.gridable
                if(!this.gridable) {
                    this.$nextTick(() => {
                        this.gridFocus = true;
                    })
                }else {
                    this.$nextTick(() => {
                        this.gridFocus = false;
                    })
                }
            },
            //库位编号点击
            containerClick() {
                uni.scanCode({
                    scanType: ['barCode','qrCode'],
                    autoDecodeCharset: true,
                    success:(res) => {
                        this.warehouse.containerCode = res.result
                        this.containerBlur()
                    },
                    fail:(err) => {
                        this.rescode = 400
                        this.resmessage = `扫描失败${err}`
                        this.$refs.resmodal.show = true
                    }
                })
            },
            //容器失焦事件
            containerBlur(){
                Promise.all([this.getContainerRecord(), this.getContainerData()])
            },
            //获取当前容器下组盘记录
            getContainerRecord(){
                //每次查询置空材料列表
                this.singlist = [];
                if(this.warehouse.containerCode == '') {
                    // this.rescode = 400
                    // this.resmessage = `库位编号不能为空`
                    // this.$refs.resmodal.show = true
                    return
                }
                getContainerRecord({
                    'containerCode':this.warehouse.containerCode
                }).then(res => {
                    if(Array.isArray(res.data) && res.data.length > 0) {
                        if(res.data[0].orderNo){
                            this.putCode = res.data[0].orderNo;
                        }
                        const recordArr = res.data.reduce((curr,item)=>{
                            curr.push({
                                code: item.materialCode,
                                batchNo:item.batchNo,
                                quantity:item.quantity,
                                materialName:item.materialName,
                                materialTypeName:item.materialTypeName,
                                specificationModel:item.specificationModel,
                                show: false
                            })
                            return curr
                        },[])
                        this.singlist.push(...recordArr)
                    }
                })
                
            },
            //获取容器的信息
            getContainerData() {
                if(this.warehouse.containerCode.length < 5) {
                    return
                }
                getContainDetail(this.warehouse.containerCode).then(res => {
                    const result = res.data.rows;
                    if(Array.isArray(result) && result.length == 1) {
                        this.detailable = true;
                        this.warehouse.gridNumber = res.data.rows[0].gridNumber;
                        this.warehouse.useNumber = res.data.rows[0].useNumber;
                    }
                    
                })
            },
            //检查容器栅格数
            checkGrid() {
                if(parseInt(this.warehouse.gridNumber) < parseInt(this.warehouse.useNumber) + parseInt(this.warehouse.exitNumber)) {
                    this.rescode = 400
                    this.resmessage = '栅格总数不能小于已用数量加上本次占用数量'
                    this.$refs.resmodal.show = true
                }
            },
            //检查本地使用数
            checkExit() {
                if(parseInt(this.warehouse.exitNumber) > parseInt(this.warehouse.gridNumber)) {
                    this.rescode = 400
                    this.resmessage = '本次占用数量不能大于栅格总数'
                    this.$refs.resmodal.show = true
                }
            },
            //物料编码点击
            materialClick() {
                // uni.scanCode({
                //     scanType: ['barCode','qrCode'],
                //     autoDecodeCharset: true,
                //     success:(res) => {
                //         this.warehouse.materialCode = getAttrValue(res.result,'PARTSNUMBER')
                //         this.batchNo = getAttrValue(res.result,'LOTNO')
                    
                        
                //         this.getMaterialDetails()
                //     },
                //     fail:(err) => {
                //         this.rescode = 400
                //         this.resmessage = `扫描失败${err}`
                //         this.$refs.resmodal.show = true
                //     }
                // })
            },
            //入库单号
            getOrderNo() {
                getOrderNo().then((res) => {
                    if (res.code == 200) {
                        this.putCode = res.data
                    } else {
                        this.$refs.resmodal.show = true
                    }
                })
            },
            //物料查询
            getMaterialDetails() {
                
                if(!this.warehouse.materialCode) {
                    // uni.showModal({
                    //     title: '提示',
                    //     content: '物料编号不能为空',
                    //     showCancel: false
                    // })
                    return 
                }
                
                if(this.warehouse.materialCode.length > 50) {
                    this.batchNo = getAttrValue(this.warehouse.materialCode,'LOTNO')
                    let quantity = getAttrValue(this.warehouse.materialCode,'QUANTITY')
                    this.sap_location = getAttrValue(this.warehouse.materialCode,'SAP') || ''
                    if(quantity == '' || Number(quantity) <= 0) {
                        // this.rescode = 400
                        // this.resmessage = '标签中无收货数量'
                        // this.$refs.resmodal.show = true
                        // return 
                        quantity = 0
                    }
 
                    
                    //扫描的物料是否有批次
                    if(!this.batchNo) {
                        this.rescode = 400
                        this.resmessage = '无批次'
                        this.$refs.resmodal.show = true
                        return
                    }
                    this.warehouse.materialCode = getAttrValue(this.warehouse.materialCode,'PARTSNUMBER')
 
                    this.singlist = [
                        {
                            'code':this.warehouse.materialCode,
                            'batchNo':this.batchNo,
                            'sap_Location':this.sap_location,
                        }
                    ]
                    // if(this.singlist.length > 0) {
                    //     //判断当次扫描的物料是否已存在同批次
                    //     let index = this.singlist.findIndex(item => item.code == this.warehouse.materialCode  && item.batchNo == this.batchNo)
                    //     //置顶
                    //     if(index > -1) {
                    //         //同批次的物料数量做累加
                    //         this.singlist[index].quantity = Number(Number(this.singlist[index].quantity) + Number(quantity)).toFixed(3);
                    //         this.singlist.unshift(...this.singlist.splice(index,1))
                    //         return
                    //     }
                    // }
                    return
                    // debug
                    getMaterialList({
                        Code:this.warehouse.materialCode,
                        'Sap_Location':sap_location,
                        PageNo:1,
                        PageSize:10
                    }).then((res) => {
                        if (res.code == 200) {
                            if (res.data.rows.length == 0) {
                                this.rescode = 400
                                this.resmessage = '无此物料'
                                this.$refs.resmodal.show = true
                                return
                            }else {
                                res.data.rows.map(item => {
                                    item.batchNo = this.batchNo
                                    item.sap_Location = sap_location
                                    item.quantity = quantity
                                    item.show = false
                                    return item;
                                })
                                this.singlist.unshift(...res.data.rows)
                            }
                        } else {
                            this.resmessage = res.message
                            this.rescode = res.code
                            this.$refs.resmodal.show = true
                        }
                    })
                }
            },
            //删除详情
            longpress(index, eindex) {
                this.singlist[index].cardNum = true
                if (eindex == 1) {
                    this.singlist.splice(index, 1)
                } else {
                    this.materlist = this.singlist[index]
                    this.detailshow = true
                }
 
            },
            //编辑状态样式
            dc(e) {
                e.cardNum = true
                this.$forceUpdate()
            },
            //卡片选中
            clicki(e) {
                e.cardNum = true
                this.$forceUpdate()
            },
            // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
            open(index) {
                // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
                // 原本为'false',再次设置为'false'会无效
                this.singlist[index].cardNum = true;
                this.$forceUpdate()
                this.singlist[index].show = true;
                this.singlist.map((val, idx) => {
                    if (index != idx) this.singlist[idx].show = false;
                })
            },
            close(index) {
                this.singlist[index].show = false;
                this.singlist[index].cardNum = false;
                this.$forceUpdate()
            },
            //改变组盘数量
            changeNum(val) {
                val.cardNum = false
                if(!val.quantity) {
                    uni.showModal({
                        title: '提示',
                        content: '组盘数量不能为空',
                        showCancel: false
                    })
                }
                // val.quantity = Number(val.quantity.toString().match(/^\d+(?:\.\d{0,2})?/)) // 保留两位小数
                if(val.quantity <0) {
                    uni.showModal({
                        title: '提示',
                        content: '组盘数量必须大于0',
                        showCancel: false
                    })
                }
            },
            //全部取消
            reset() {
                this.singlist = [];
                this.batchNo = '';
                this.sap_location = '';
                this.warehouse.materialCode = '';
                this.$refs.warehouseRef.resetFields();
                this.$forceUpdate()
            },
            //重置页面信息
            rest() {
                this.warehouse.containerCode = ''
                this.warehouse.materialCode = ''
                this.singlist.forEach(item => {
                    item.quantity = ''
                })
                this.singlist = []
                // this.getOrderNo()
            },
            //确认
            submit() {
                // 跳转到登录
                uni.redirectTo({
                        url: '/pages/artificial/artificial?wareContainerCode='+ this.warehouse.materialCode
                    })
                // this.$refs.warehouseRef.setRules(this.warehouseRules)
                // console.log(this.orderType,'333')
                // this.$refs.warehouseRef.validate(valid => {
                //     if (valid) {
                //         if(parseInt(this.warehouse.gridNumber) <= 0 || parseInt(this.warehouse.useNumber) < 0) {
                //             this.rescode = 400
                //             this.resmessage = '栅格总数不能小于等于0'
                //             this.$refs.resmodal.show = true
                //             return
                //         }
                        
                //         if(parseInt(this.warehouse.useNumber) > parseInt(this.warehouse.gridNumber)) {
                //             this.rescode = 400
                //             this.resmessage = '本次使用数不能大于栅格总数'
                //             this.$refs.resmodal.show = true
                //             return
                //         }
                //         //物料详情
                //         let matatilDetails = this.singlist.reduce((curr,item) => {
                //             curr.push({
                //                 createdTime: this.Datetime,
                //                 updatedTime: this.Datetime,
                //                 createdUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                //                 createdUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                //                 updatedUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                //                 updatedUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                //                 wareMaterialCode: item.code,
                //                 batchNo:item.batchNo,
                //                 price:item.price,
                //                 completeQuantity: item.quantity,
                //                 quantity: item.quantity,
                //                 sap_Location:item.sap_Location || ''
                //             })
                //             return curr;
                //         },[])
                        
                //         //请求参数
                //         let params = {
                //             createdTime: this.Datetime,
                //             updatedTime: this.Datetime,
                //             createdUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                //             createdUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                //             updatedUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                //             updatedUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                //             orderNo: this.putCode,
                //             orderType: this.orderType,
                //             wareContainerCode: this.warehouse.containerCode,
                //             gridNumber: parseInt(this.warehouse.gridNumber),
                //             useNumber: parseInt(this.warehouse.exitNumber),
                //             warehousOrderDetails: matatilDetails
                //         }
                        
                //         uni.showModal({
                //             title: '提示',
                //             content: '是否确认入库?' ,
                //             showCancel: true,
                //             cancelColor: '#333333',
                //             success: (res => {
                //                 if (res.confirm) {
                //                     addGroupDisk(params).then(res => {
                //                         this.rescode = res.code
                //                         this.resmessage = res.message
                //                         this.$refs.resmodal.show = true
                //                         this.rest()
                //                     })
                //                 } else if (res.cancel) {
                                
                //                 }
                //             })
                //         });
 
                        
                    
                //     }
                // })
            },
            //获取推荐
            containerFocus() {
                // //debugger
                if(this.warehouse.materialCode==''){
                    return
                }
                getRecommendList({
                    'wareMaterialCode':this.warehouse.materialCode,
                    'barNo':this.batchNo,
                    'sap_Location':this.sap_location
                    }).then(res => {
                    this.containerList = res.data.reduce((curr,item) => {
                        curr.push({
                            label: item,
                            value: item
                        })
                        return curr;
                    },[])
                    this.containerVisible = true;
                })
            },
            //容器选择
            containerConfirm(context){
                this.warehouse.OrderNo = context[0].value
                if(context[0].value==''){
                    return
                }
                uni.redirectTo({
                    url: '/pages/artificial/artificial?wareContainerCode='+ context[0].value
                })
            }
        }
    }
</script>
<style lang="scss" scoped>
    .el_batchNo {
        padding: 10rpx 0 10rpx 45rpx;
        color: #808080;
    }
    .bg_item {
           background: #FFEBCD !important;
    }
</style>