spring
4 天以前 435881d494e2be4ba5ce8bfccb02d6ef49e07314
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
<template>
    <view class="page">
      <view class="warehouse-materialreturn-bg"/>
      <u-navbar title="扫码退料" :background="background" :border-bottom="false" :title-bold="true" title-color="#000" back-icon-color="#000"/>
      <view class="warehouse-materialreturn-param">
                <view class="warehouse-materialreturn-param-view">
                    <view class="warehouse-materialreturn-param-item">
                        <view class="warehouse-materialreturn-param-item-left">
                          <text class="item-one">工作站</text>
                        </view>
                        <view class="warehouse-materialreturn-param-item-right">
                           <text class="item-one" @click="toWorkstation">{{tailHandle.workstationName}}</text>
                       <view class="scan" style="margin-right: 24rpx;" @click="goScan">
                       </view>
                           <u-icon name="arrow-right" color="#687792" size="28" @click="toWorkstation"></u-icon>
                        </view>
                    </view>
                </view>
      </view>
      <view class="materialreturn-index-body-title">
          <view>
              <u-line style="border:5rpx solid #264DE9" length="33rpx"  direction="col" color="#264DE9" :hair-line="false"></u-line>
          </view>
          <view class="title-label">机台物料</view>
      </view>
      <view class="wrap"> 
        <scroll-view class="warehouse-materialreturn-scroll-list" scroll-y="true">    
          <u-cell-group class="warehouse-materialreturn-scroll-list-group" :border="false">
                <div class="tip" style="text-align:center;" v-if="list.length==0">-暂无物料-</div>
                <view class="content" v-for="(item, index) in list" :key="item.id" :index="index" @click="selectRow(item)">
                    <view class="content-header">
                            <view class="header-item">
                                <view class="content-header-icon-one"></view>
                                <view class="content-header-title">{{ item.partBatchNo }}</view>
                            </view>
                            <view class="header-item">
                                <view class="content-header-icon-two"></view>
                                <view class="content-header-title-ne">{{ item.partName }}</view>
                            </view>
                            <view :class="[item.isSelected?'header-item-toolbar-selected':'header-item-toolbar-unselected']">
                                
                            </view>
                        </view>
                        <view class="content-body">
                            <view class="row-list">
                                <view class="_label">
                                    零件编号:
                                </view>
                                <view class="_content">
                                    {{ item.partNo }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    erp批 号:
                                </view>
                                <view class="_content">
                                    {{ item.ifsBatchNo }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    可用数量:
                                </view>
                                <view class="_content">
                                    <text class="_content-text">{{ item.availableStockQuantity+'('+item.unit+')' }}</text>
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label s1">
                                    退料数量:
                                </view>
                                <view class="_content _input">
                                    <u-input placeholder="请输入退料数量" v-model="item.returnValue" type="digit"></u-input>
                                    <view class="edit_icon"></view>
                                </view>
                            </view>
                        </view>
                </view>
                </u-cell-group>
            </scroll-view>
            
        <view class="materialReturn-form-footer">
            <u-button class="btn" type="primary" @click="goSubmit">退回</u-button>
        </view>
        <scan></scan>    
        <u-modal v-model="showConfirm" :title="''" content="是否确认将尾料扣除,此操作不可逆!"  @confirm="confirm" :show-cancel-button="true">
            <view class="slot-content">
                <view @click="showPicker=true" style="padding: 20rpx;">
                    <view>
                        <text style="margin-right: 20rpx;">退料库位</text>
                        <text style="color: #e6db74;">{{active}}</text>
                    </view>
                </view>
            </view>
        </u-modal>
                <u-picker v-model="showPicker" mode="selector" :range="arr" range-key="locName" @confirm="confirmPicker"></u-picker>
    </view>
    </view>
</template>
<script>
    import scan from "@/components/scan/scan.vue";
    import content_bg from '@/static/custom/materialReturn/backBg.png'
    export default {
        components: {
            scan
        },
        data() {
            return {
                background:{
                    backgroundImage: `url(${content_bg})`,
                    backgroundAttachment: 'fixed',
                    backgroundSize: '100% auto',
                    backgroundRepeat: 'no-repeat',
                },
                showPicker:false,
                tailHandle:{
                    workstationId: null,
                    workstationNo: null,
                    workstationName: null
                },    
                list:[{partNo:'88.118.1/A0138298',partName:'地铁及轨道用软电缆和软线 /1000V 1×35 A0',partBatchNo:'231115000002N',ifsBatchNo:'231115000002N',availableStockQuantity:56.3,unit:'米',returnValue:56.6},
                   {partNo:'BS-1704',partName:'三层共挤输液用膜',partBatchNo:'231115000002N',ifsBatchNo:'231115000002N',availableStockQuantity:72.3,unit:'米',returnValue:84},
                   {partNo:'BS-1704',partName:'三层共挤输液用膜',partBatchNo:'231115000002N',ifsBatchNo:'231115000002N',availableStockQuantity:72.3,unit:'米',returnValue:84}
                ],
                showConfirm:false,
                arr:[],
                active:'点击选择库位',
                obj:{}
            };
        },
        onLoad() {
        
        },
        onShow() {
            let that = this        
            uni.$off('scan') // 每次进来先 移除全局自定义事件监听器
            uni.$on('scan', function(data) {
                //扫码成功后的回调,你可以写自己的逻辑代码在这里
                console.log('扫码结果:', data.code);
                // console.log(data.code.replace(/\n/g,'').replace(/\s*/g,''))
                // console.log('扫码结果1:', JSON.parse(data.code.replace(/\n/g,"").replace(/\s*/g,'')));
                                
                that.loadList(data.code);
                that.$forceUpdate();
            })
        },
        onNavigationBarButtonTap(e) {
            this.goScan()
        },
        methods: {
            confirmPicker(val) {
                this.obj = {}
                this.active = this.arr[val[0]].locName
                this.obj = this.arr[val[0]]
            },
            goScan(){
                 //let scanresult={"part_no":"88.118.1/A0044193","package_code":"TP092022101200001","unit_meas":"跦","wdr":"*","lot_batch_no":"*","qty_arrived":12}
                 //this.scanHandle(JSON.stringify(scanresult))
                
                uni.scanCode({
                    scanType: ['qrCode'],
                    success: res => {
                        try {
                            console.log('扫码结果:', res);
                            this.scanHandle(res.result)
                        } catch (e) {}
                    }
                });
            },
            //根据机台号,查询机台信息,再查询物料信息
            scanHandle(workstationNo){
                if(workstationNo!=''){
                    this.$u.api.pigxFeed.fetchWorkstationList({workstationNo:workstationNo}).then(resp => {
                        
                        if (!resp.data.records || resp.data.records.length == 0) {
                            this.$u.toast('【'+workstationNo+'】,未查询到机台信息')
                        }else{
                            let workstationList=resp.data.records
                            let scanWorkstationInfo=workstationList[0]
                            this.tailHandle.workstationId = scanWorkstationInfo.id
                            this.tailHandle.workstationNo = scanWorkstationInfo.workstationNo
                            this.tailHandle.workstationName = scanWorkstationInfo.name
                            this.list=[]
                            this.$u.api.returnMaterial.getFeedingStockByWorkstationNo({workstationNo:scanWorkstationInfo.workstationNo}).then(res => {
                                                   let reList = []                       
                                                   reList = res.data;    
                                                   if(reList.length!=0)
                                                    {
                                                        // 按可用数量排个序
                                                        reList.sort(this.compare('availableStockQuantity'))
                                                        reList.forEach((item)=>{
                                                            this.list.push({
                                                                locationId:item.locationId,
                                                                locNo:item.locNo,
                                                                partBatchNo:item.partBatchNo,
                                                                partId:item.partId,
                                                                partNo:item.partNo,
                                                                partName:item.partName,
                                                                availableStockQuantity:item.availableStockQuantity,
                                                                unit:item.unit,
                                                                ifsBatchNo:item.ifsBatchNo,
                                                                id:item.id,
                                                                systemNo:item.systemNo,
                                                                isSelected:false
                                                            })
                                                        })
                                                    }
                            })
                        }                                
                    })
                }else{
                    this.$u.toast('未扫描到机台号')
                }
            },
            selectRow(stock){
                stock.isSelected=!stock.isSelected    
                if(stock.isSelected) {
                    stock.returnValue = stock.availableStockQuantity
                } else {
                    stock.returnValue = ''
                }
                /*this.list.forEach((item,index)=>{
                    if(item.id ==stock.id){
                        this.list.splice(index,1)
                        return;
                    }
                })*/
                //if(stock.isSelected){
                    //展示在列表最上方
                //    this.list.unshift(stock)
                //}else{
                    //展示在列表最下方
                //    this.list.push(stock)
                //}
                
            },
            setWorkstation(workstation) {
                this.list=[]
                this.tailHandle.workstationId = workstation.id
                this.tailHandle.workstationNo = workstation.workstationNo
                this.tailHandle.workstationName = workstation.name
                this.$u.api.returnMaterial.getFeedingStockByWorkstationNo({workstationNo:workstation.workstationNo}).then(res => {
                                       let reList = []                       
                                       reList = res.data;    
                                       if(reList.length!=0)
                                        {
                                            // 按可用数量排个序
                                            reList.sort(this.compare('availableStockQuantity'))
                                            reList.forEach((item)=>{
                                                this.list.push({
                                                    locationId:item.locationId,
                                                    locNo:item.locNo,
                                                    partBatchNo:item.partBatchNo,
                                                    partId:item.partId,
                                                    partNo:item.partNo,
                                                    partName:item.partName,
                                                    availableStockQuantity:item.availableStockQuantity,
                                                    unit:item.unit,
                                                    ifsBatchNo:item.ifsBatchNo,
                                                    id:item.id,
                                                    systemNo:item.systemNo,
                                                    isSelected:false
                                                })
                                            })
                                        }
                });
            },
            toWorkstation() {
                uni.navigateTo({
                    url: '/pages/product/tailHandle/workstationList'
                })
            },
            loadList(sanCode) {
                let that = this
                if(sanCode!="")
                {
                    //根据扫入的字符串信息,判断扫的是条形码,还是二维码
                    let snNo
                    if (sanCode.indexOf('sn_no') != -1) {
                        // 二维码
                        const scanContentJson = JSON.parse(
                            sanCode.replace(/\n/g, '').replace(/\s*/g, '')
                        )
                        snNo=scanContentJson.sn_no
                        
                    } else {
                        // 条形码
                        snNo = sanCode                                            
                    }                   
                    //根据sn号选中物料
                    let exsitMaterial=this.list.find((item)=>{
                        return item.partBatchNo==snNo
                    })
                    if(exsitMaterial){
                        exsitMaterial.isSelected=true
                        /*this.list.forEach((item,index)=>{
                            if(item.id ==exsitMaterial.id){
                                this.list.splice(index,1)
                                return;
                            }
                        })*/
                        //展示在列表最上方
                        //this.list.unshift(exsitMaterial)
                        
                    }
                }            
            },
            goSubmit(){
                let stockIds = []
                this.list.forEach((item) => {
                    if(item.isSelected){
                        stockIds.push(item)
                    }
                })
                if(stockIds.length>0){
                    this.showConfirm=true
                    this.$u.api.returnMaterial.getReturnLocations({workstationId:this.tailHandle.workstationId}).then((res) => {
                        console.log(res);
                        console.log(stockIds);
                        this.arr = res.data
                    })
                } else {
                    this.$u.toast('请选择需发放的物料!')
                }
            },
            confirm(){
                let stockIds = []
                if(this.active === '点击选择库位') {
                    this.$u.toast('请选择库位')
                    this.showConfirm = true
                } else {
                    this.list.forEach((item) => {
                        if(item.isSelected){
                            stockIds.push({
                                id:item.id,
                                partBatchNo:item.partBatchNo,
                                partId:item.partId,
                                returnLocationId:this.obj.id,
                                returnQuantity:item.returnValue,
                                systemNo:item.systemNo,
                                workstationId:this.tailHandle.workstationId
                            })
                        }
                    })
                    if(stockIds.length>0){
                        this.$u.api.returnMaterial.returnMaterial(stockIds).then(res => {
                            let reData = res.data;
                            this.$u.toast('退料成功!')
                            this.getWorkstationMaterial(this.tailHandle.workstationNo)
                        })    
                    }
                }
            },
            getWorkstationMaterial(workstationNo){
                this.list=[]
                this.$u.api.returnMaterial.getFeedingStockByWorkstationNo({workstationNo:workstationNo}).then(res => {
                                       let reList = []                       
                                       reList = res.data;    
                                       if(reList.length!=0)
                                        {
                                            // 按可用数量排个序
                                            reList.sort(this.compare('availableStockQuantity'))
                                            reList.forEach((item)=>{
                                                this.list.push({
                                                    locationId:item.locationId,
                                                    locNo:item.locNo,
                                                    partBatchNo:item.partBatchNo,
                                                    partId:item.partId,
                                                    partNo:item.partNo,
                                                    partName:item.partName,
                                                    availableStockQuantity:item.availableStockQuantity,
                                                    unit:item.unit,
                                                    ifsBatchNo:item.ifsBatchNo,
                                                    id:item.id,
                                                    systemNo:item.systemNo,
                                                    isSelected:false
                                                })
                                            })
                                        }
                });
            },
            compare(pro){
                return function(obj1, obj2) {
                    const val1 = obj1[pro]
                    const val2 = obj2[pro]
                    if (val2 < val1) {
                      // 正序
                      return 1
                    } else if (val2 > val1) {
                      return -1
                    } else {
                      return 0
                    }
                  }
            }
        }
    };
</script>
<style lang="scss" scoped>    
    .warehouse-materialreturn-bg{
        background-color: #F6F9FF;
        background-image: url('~@/static/custom/materialReturn/backBg.png');
        // background: linear-gradient(180deg,rgba(206,227,254,1),rgba(206,227,254,1) 20%,rgba(206,227,254,0.5) 40%,rgba(206,227,254,0.25) 60%,rgba(206,227,254,0.08) 80%,rgba(206,227,254,0));
        padding: 0 20rpx;
        background-attachment: fixed;
        background-size: 100% auto;
        background-repeat: no-repeat;
        position: fixed;
        top: 0;
        bottom: 0;
        width: 100%;
        z-index: -1;
    }
    
    .warehouse-materialreturn-param{
        padding: 50rpx 30rpx 0rpx 30rpx;
        .warehouse-materialreturn-param-view{
            height: 100rpx;
            background: rgba(255,255,255,0.61);
            box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(110,120,135,0.09);
            border-radius: 10rpx;
            padding:0rpx 23rpx;
            margin-bottom: 30rpx;
            .warehouse-materialreturn-param-item{
                height: 100rpx;
                border: 1px solid #ADC8E4;
                line-height: 100rpx;
                display:flex;
                justify-content: space-between;
                border: none;
                .warehouse-materialreturn-param-item-left{
                    .item-one{
                        font-size: 30rpx;
                        color: #4F4F4F;
                    }
                }
                .warehouse-materialreturn-param-item-right{
                    display: flex;
                    align-items: center;
                    .item-one{
                        font-size: 30rpx;
                        color: #333333;
                        margin-right: 6rpx;
                    }
                    .item-two{
                        font-size: 30rpx;
                        color: #A6B4CC;
                        margin-right: 6rpx;
                    }
                    .item-three{
                        font-size: 30rpx;
                        color: #214DED;
                        margin-right: 6rpx;
                    }
                    .scan{
                        background-image: url('~@/static/custom/materialReturn/scan.png');
                        background-size: 100% auto;
                        background-repeat: no-repeat;
                        height:32rpx;
                        width:32rpx;
                    }
                }
            }
            .param-extra{
                border-bottom: 1px solid #E8EBEE;
            }
        }
    }
    
    .materialreturn-index-body-title{
        padding: 0rpx 30rpx 0rpx 30rpx;
        margin-bottom: 32rpx;
        display: flex;
        flex-direction: row;
        align-items: center;
        .title-label{
            margin-left: 14rpx;
            font-size: 34rpx;
            font-weight: bold;
            color: #283E65;
        }
    }
    
    .wrap .warehouse-materialreturn-scroll-list{
        height:calc(100vh - var(--window-top) - var(--window-bottom) - 494rpx);
        width:100%;
    }
    
    .warehouse-materialreturn-scroll-list-group{
        ::v-deep .u-cell-item-box {
            background-color:rgba(250,252,255,0.36) !important;
            padding:0rpx 30rpx ;
        }
        .content {
            font-size: 12px;
            background-color: #FFFFFF;
            box-sizing: border-box;
            border-radius: 10rpx;
            margin: 0rpx 0rpx 24rpx;
            height: 382rpx;
            padding: 10rpx 20rpx;
            box-shadow:0rpx 6rpx 12rpx 2rpx rgba(127, 127, 127, 0.1) !important;
            position:relative;
            .content-header{
                .header-item{
                    height: 50rpx;
                    display: flex;
                    align-items:center;
                    .content-header-icon-one{
                        background-image: url('~@/static/custom/materialReturn/label-icon-1.png');
                        background-size: 100% auto;
                        background-repeat: no-repeat;
                        height:28rpx;
                        width:28rpx;
                    }
                    .content-header-icon-two{
                        background-image: url('~@/static/custom/materialReturn/label-icon-2.png');
                        background-size: 100% auto;
                        background-repeat: no-repeat;
                        height:28rpx;
                        width:28rpx;
                    }
                    .content-header-title{
                        margin-left: 11rpx;
                        font-size: 26rpx;
                        font-weight: bold;
                        color: #333333;
                    }
                    .content-header-title-ne{
                        margin-left: 11rpx;
                        font-size: 26rpx;
                        color: #333333;
                    }
                }
                .header-item-toolbar-selected{
                    position: absolute;
                    background-image: url('~@/static/custom/materialReturn/selected-btn-1.png');
                    background-size: 100% auto;
                    background-repeat: no-repeat;
                    height:50rpx;
                    width:50rpx;
                    right:20rpx;
                    top:12rpx;
                    display: flex;
                    justify-content: flex-end;
                    padding-top: 10rpx;
                    padding-right: 18rpx;
                }
                .header-item-toolbar-unselected{
                    position: absolute;
                    background-image: url('~@/static/custom/materialReturn/unselected-btn-1.png');
                    background-size: 100% auto;
                    background-repeat: no-repeat;
                    height:50rpx;
                    width:50rpx;
                    right:20rpx;
                    top:12rpx;
                    display: flex;
                    justify-content: flex-end;
                    padding-top: 10rpx;
                    padding-right: 18rpx;
                }
            }
            
            .content-body{
                height:250rpx;
                background: #F5F9FF;
                border-radius: 10rpx;
                padding: 25rpx 23rpx;
                .row-list {
                    height: 50rpx;
                    display: flex;
                    flex-direction: row;
                    padding: 0px;
                    align-items: center;
                    justify-content: space-between;
                }
                .row-list ._label {
                    display: flex;
                    color: #666666;
                    font-size:26rpx;
                    align-items: center;
                    width: 170rpx;
                }
                
                .row-list ._content {
                    text-align: right;
                    color: #909399;
                    font-size: 24rpx;
                    ._content-text{
                        color:#214ded;
                    }
                }
                .row-list ._input {
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    border-bottom: 1px solid #4FA0FF;
                    height: 56rpx;
                    .edit_icon{
                        background-image: url('~@/static/custom/materialReturn/icon_edit.png');
                        background-size: 100% auto;
                        background-repeat: no-repeat;
                        height:26rpx;
                        width:26rpx;
                    }
                    ::v-deep .uni-input-input{
                        color:#D35651;
                    }
                }
                
                .row-list .s1 {
                    display: flex;
                    color: #214DED;
                    font-size:26rpx;
                    align-items: center;
                    width: 170rpx;
                }
            }
        }
    }
    
    .materialReturn-form-footer{
        display: flex;
        margin-top: 10rpx;
        margin-bottom: 10rpx;
        margin-left: 20rpx;
        margin-right: 20rpx;
        padding-bottom: 14rpx;
        .btn {
          flex: 1;
          margin: 10rpx;
          background: #214DED;
          box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(4,49,212,0.3);
          font-weight: bold;
          color: #FEFEFE;
          font-family: PingFang SC;
        }
    }
</style>