spring
4 天以前 f26f29d84e0a68831a6af14dab3eec5500496d2e
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
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
<template>
    <view class="page">
        <view class="production-index-bg" />
        <u-navbar title="产出" :background="background" :border-bottom="false" :title-bold="true" title-color="#000"
            back-icon-color="#000" />
        <view class="wrap">
            <view class="content">
                <view class="content-body">
                    <view class="content-body-item param-extra" v-if="info.type!='group'">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">生产人员:</text>
                        </view>
                        <view class="content-body-item-right">
                            <wu-button shape="circle" size="small" type="primary" @click="toDutyPerson">
                                点击选择
                            </wu-button>
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">零件编号:</text>
                        </view>
                        <view class="content-body-item-right">
                            <text class="_text">{{ info.partNo }}</text>
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">零件名称:</text>
                        </view>
                        <view class="content-body-item-right">
                            <text class="_text">{{ info.partName }}</text>
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">SN号:</text>
                        </view>
                        <view class="content-body-item-right">
                            <text class="_text">{{ info.outBatchNo }}</text>
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">载具编号:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text u-input" v-model="info.reelNumber" placeholder="请填写" />
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">产出套数:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text" type="number" v-model="info.disNumber" placeholder-style="color:#F76260" placeholder="请填写(必填)" />
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">每套产量:</text>
                        </view>
                        <view class="content-body-item-right">
                            <text class="_text">{{ info.productQty }}</text>
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">起始数量:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text" type="number" v-model="info.startMeterMark" placeholder-style="color:#F76260" placeholder="请填写(必填)" @blur="startMeterBlur" />
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">截止数量:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text" type="number" v-model="info.endMeterMark" placeholder-style="color:#F76260" placeholder="请填写(必填)" @blur="endMeterBlur" />
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">计量单位:</text>
                        </view>
                        <view class="content-body-item-right">
                            <text class="_text">{{info.unit}}</text>
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">生产说明:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text" v-model="info.segmentDesc" placeholder="请填写" />
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">报废数量:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text" v-model="info.scrapQty" placeholder="请填写" />
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">载具重量:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text" v-model="info.reelWeight" placeholder="请填写" />
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">产出毛重:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text" v-model="info.grossWeight" placeholder="请填写" />
                        </view>
                    </view>
                    <view class="content-body-item param-extra">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">生产人员:</text>
                        </view>
                        <view class="content-body-item-right">
                            <text class="_text">{{ info.staffName }}</text>
                        </view>
                    </view>
                    <view class="content-body-item">
                        <view class="content-body-item-left">
                            <text class="slot-box slot-text">备注说明:</text>
                        </view>
                        <view class="content-body-item-right">
                            <input class="_text" v-model="info.mainRemark" placeholder="请填写" />
                        </view>
                    </view>
                </view>
                <view class="bottom">
                    <view class="bottom-btn">
                        <wu-button :custom-style="customStyleOne" size="normal" @click="onCancel">
                            取消
                        </wu-button>
                    </view>
                    <view class="bottom-btn">
                        <wu-button :custom-style="customStyleTwo" size="normal" @click="onSubmit">
                            确定
                        </wu-button>
                    </view>
                </view>
                <!-- </form> -->
            </view>
        </view>
    </view>
</template>
<script>
    import content_bg from '@/static/custom/product/productBg.png'
 
    export default {
        components: {},
        computed: {
            customStyleOne() {
                return {
                    color: '#666666',
                    background: '#FFFFFF',
                    width: '350rpx'
                }
            },
            customStyleTwo() {
                return {
                    color: '#FFFFFF',
                    background: '#234EED',
                    width: '350rpx'
                }
            },
        },
        data() {
            return {
                background: {
                    backgroundImage: `url(${content_bg})`,
                    backgroundAttachment: 'fixed',
                    backgroundSize: '100% auto',
                    backgroundRepeat: 'no-repeat',
                },
                info: {
                    partId: null,
                    partNo: null,
                    partName: null,
                    outBatchNo: null,
                    reelNumber: null,
                    disNumber: 1,
                    productQty: null,
                    startMeterMark: 0,
                    endMeterMark: null,
                    unit: null,
                    segmentDesc: null,
                    scrapQty: null,
                    reelWeight: null,
                    grossWeight: null,
                    staffName: null,
                    mainRemark: null,
                    productStaffIds: [],
                    productStaffs: [],
                    workstationId: null,
                    operationTaskId: null,
                    dutyRecordId: null,
                },
                dutyForm: [],
                personInitList: [],
                personBoardList: [],
                products: [],
            };
        },
        onLoad(option) {
            if (option.params) {
                const params = JSON.parse(decodeURIComponent(option.params));
                this.info.partId = params.partId;
                this.info.partNo = params.partNo;
                this.info.partName = params.partName;
                this.info.unit = params.unit;
                this.info.workstationId = params.workstationId;
                this.info.operationTaskId = params.operationTaskId;
                this.info.dutyRecordId = params.dutyRecordId;
                this.info.type = params.type;
 
                //获取当班人员
                this.getPerson()
            }
        },
        onShow() {
 
        },
        methods: {
            onCancel() {
                // 返回上一页
                uni.navigateBack({
                    delta: 1
                })
            },
            async getPerson() {
                let queryParam = {
                    id: this.info.workstationId
                }
 
                let queryUserParam = {
                    id: this.info.dutyRecordId
                }
 
                let resUser = await this.$u.api.outputRegister.getPersonByDutyRecordId(queryUserParam)
 
                let userList = resUser.data
                if (userList.length > 0) {
                    this.personInitList = []
                    this.$set(this.info, 'staffName', "");
                    let staffName = ""
                    userList.map((item, index) => {
 
                        if (index == userList.length - 1) {
                            staffName = staffName + item.staffName
                        } else {
                            staffName = staffName + item.staffName + ","
                        }
 
                        let data = {
                            staffId: item.staffId,
                            staffName: item.staffName,
                            staffNo: item.staffNo,
                            checked: false
                        }
 
                        this.personInitList.push(data)
                    });
 
                    //type:shift  按班组  person 按人员
                    if (this.info.type == "group") {
                        this.personBoardList = this.personInitList
                        this.$set(this.info, 'staffName', staffName);
                    } else {
                        this.personBoardList = []
                        this.$set(this.info, 'staffName', "");
                    }
                }
            },
            setProducts() {
                let productStaffs = []
                let productStaffIds = []
                let newProduct = {}
                this.products = []
                //type:group  按班组  person 按人员
                if (this.info.type == "group") {
                    // 按班组报工,一条记录
                    let staffName = ''
                    let staffNo = ''
                    for (let i = 0; i < this.personBoardList.length; i++) {
                        staffName += this.personBoardList[i].staffName + ','
                        staffNo += this.personBoardList[i].staffNo + ','
                        productStaffs.push(this.personBoardList[i].staffNo)
                        productStaffIds.push(this.personBoardList[i].staffId)
                    }
 
                    staffName = staffName.substring(0, staffName.length - 1)
                    staffNo = staffNo.substring(0, staffNo.length - 1)
 
                    newProduct = {}
                    newProduct.staffName = staffName
                    newProduct.staffNo = staffNo
                    newProduct.productNo = null
                    newProduct.partId = this.info.partId
                    newProduct.partNo = this.info.partNo
                    newProduct.partName = this.info.partName
                    newProduct.outBatchNo = null
                    newProduct.disNumber = this.info.disNumber
                    newProduct.productQty = 0
                    newProduct.sproductQty = 0
                    newProduct.ifsBatchNo = null
                    newProduct.unit = this.info.unit
                    newProduct.productStaffs = productStaffs
                    newProduct.productStaffIds = productStaffIds
                    newProduct.status = false
                    newProduct.systemNo = null
                    newProduct.date = this.info.date
                    newProduct.dutyRecordId = this.info.dutyRecordId
                    newProduct.startMeterMark = this.info.startMeterMark
                    newProduct.endMeterMark = this.info.endMeterMark
                    newProduct.scrapQty = this.info.scrapQty
                    newProduct.segmentDesc = this.info.segmentDesc
                    newProduct.remark = null
                    newProduct.outBatchNo = null
                    newProduct.reelNumber = this.info.reelNumber
                    this.products.push(newProduct)
 
                } else {
                    let newProduct
                    for (let i = 0; i < this.personBoardList.length; i++) {
                        newProduct = {}
                        productStaffs = []
                        productStaffIds = []
                        productStaffIds.push(this.personBoardList[i].staffId)
                        productStaffs.push(this.personBoardList[i].staffNo)
                        newProduct.staffName = this.personBoardList[i].staffName
                        newProduct.staffNo = this.personBoardList[i].staffNo
                        newProduct.productNo = null
                        newProduct.partId = this.info.partId
                        newProduct.partNo = this.info.partNo
                        newProduct.partName = this.info.partName
                        newProduct.outBatchNo = null
                        newProduct.disNumber = this.info.disNumber
                        newProduct.productQty = 0
                        newProduct.sproductQty = 0
                        newProduct.unit = this.info.unit
                        newProduct.productStaffs = productStaffs
                        newProduct.productStaffIds = productStaffIds
                        newProduct.status = true
                        newProduct.systemNo = null
                        newProduct.date = this.info.date
                        newProduct.dutyRecordId = this.info.dutyRecordId
                        newProduct.startMeterMark = this.info.startMeterMark
                        newProduct.endMeterMark = this.info.endMeterMark
                        newProduct.reelNumber = this.info.reelNumber
                        newProduct.ifsBatchNo = null
                        newProduct.scrapQty = this.info.scrapQty
                        newProduct.segmentDesc = this.info.segmentDesc
                        newProduct.remark = null
                        this.products.push(newProduct)
                    }
                }
            },
            async onSubmit() {
                                
                // 生产人员
                if (this.info.staffName==""||this.info.staffName==undefined||this.info.staffName==null) {
                
                    this.$u.toast('生产人员不能为空')
                    return
                }
                
                //设置工单信息
                this.setProducts();
            
                for (let i = 0; i < this.products.length; i++) {
            
                    // 盘数校验
                    if (!this.isPositiveIntegerNumber(this.products[i].disNumber)) {
            
                        this.$u.toast('第' + (i + 1) + '行,【盘数】请输入正整数!')
                        return
                    }
                    // 起始米标校验
                    if (!this.isNumber(this.products[i].startMeterMark)) {
                        this.$u.toast('第' + (i + 1) + '行,【起始米标】请输入非负数,小数位最多4位!')
                        return
                    }
                    // 截止米标校验
                    if (!this.isNumber(this.products[i].endMeterMark)) {
                        this.$u.toast('第' + (i + 1) + '行,【截止米标】请输入非负数,小数位最多4位!')
                        return
                    }
                    // 截止米标需大于开始米标
                    if (
                        Number(this.products[i].endMeterMark) <
                        Number(this.products[i].startMeterMark)
                    ) {
                        this.$u.toast('第' + (i + 1) + '行,【截止米标】需大于【起始米标】')
                        return
                    }
                }
            
                // 当前是产出的新增
                const list = []
                for (let i = 0; i < this.products.length; i++) {
                    let productVo = {}
                    productVo.isChangeShift = false
                    productVo.id = null
                    productVo.workstationId = this.info.workstationId
                    productVo.operationTaskId = this.info.operationTaskId
                    productVo.discsNumber = this.products[i].disNumber
                    let productOuts = []
                    let productOut = {}
                    productOut.workstationId = this.info.workstationId
                    productOut.operationTaskId = this.info.operationTaskId
                    productOut.partId = this.products[i].partId
                    productOut.disNumber = this.products[i].disNumber
                    productOut.productQty = this.products[i].productQty
                    productOut.sproductQty = this.products[i].sproductQty
                    productOut.productStaffs = this.products[i].productStaffs
                    productOut.productStaffIds = this.products[i].productStaffIds
                    productOut.outBatchNo = this.products[i].outBatchNo
                    productOut.status = this.products[i].status
                    productOut.dutyRecordId = this.products[i].dutyRecordId
                    productOut.startMeterMark = this.products[i].startMeterMark
                    productOut.endMeterMark = this.products[i].endMeterMark
            
                    productOut.outBatchNo = this.products[i].outBatchNo
                    productOut.reelNumber = this.products[i].reelNumber
                    productOut.ifsBatchNo = this.products[i].ifsBatchNo
                    productOut.scrapQty = this.products[i].scrapQty
                    productOut.segmentDesc = this.products[i].segmentDesc
                    productOut.remark = this.products[i].remark
            
                    productOuts.push(productOut)
                    productVo.productOutputList = productOuts
                    list.push(productVo)
                }                
            
                let res = await this.$u.api.outputRegister.batchSaveProductMain(list)
                let that = this
            
                if (res.code == 0) {
                    uni.showModal({
                        title: '提示',
                        content: '提交成功',
                        showCancel: false,
                        success: function() {
                            that.refreshLastPage()
                        }
                    })
            
                } else {
                    uni.showModal({
                        title: '提示',
                        content: '提交失败',
                        showCancel: false,
                        success: function() {}
                    })
                }
            },
            isNumber(value) {
                var reg = /^[0-9]+(.[0-9]{1,4})?$/
                if (
                    value == undefined ||
                    value == null ||
                    value === '' ||
                    value.trim === ''
                ) {
                    return false
             } else {
                    if (!reg.test(value)) {
                        return false
                    } else {
                        return true
                    }
                }
            },
            isPositiveIntegerNumber(value) {
                var reg = /^[1-9]\d*$/
                if (
                    value == undefined ||
                    value == null ||
                    value === '' ||
                    value.trim === ''
                ) {
                    return false
                } else {
                    if (!reg.test(value)) {
                        return false
                    } else {
                        return true
                    }
                }
            },
            startMeterBlur(obj) {
                if ((this.info.startMeterMark != "" ) && (this.info.endMeterMark!= "")) {
                    let qty = parseFloat(this.info.endMeterMark) - parseFloat(this.info.startMeterMark)
                    qty = parseFloat(qty.toFixed(4))
                    this.$set(this.info, 'productQty', qty);
                }    
            },
            endMeterBlur(obj) {    
                if ((this.info.startMeterMark != "" ) && (this.info.endMeterMark!= "")) {
                    let qty = parseFloat(this.info.endMeterMark) - parseFloat(this.info.startMeterMark)
                    qty = parseFloat(qty.toFixed(4))
                    this.$set(this.info, 'productQty', qty);
                }
            },
            toDutyPerson() {
                if (this.personInitList.length > 0) {
                    uni.navigateTo({
                        url: '/pages/product/outputRegister/dutyPersonList?item=' + encodeURIComponent(JSON
                            .stringify(this.personInitList))
                    })
                }
            },
            setProductPerson(userList) {
                //type:group  按班组  person 按人员
                if (this.info.type == "person") {
                    //过滤掉选中的人员信息
                    userList = userList.filter(item => item.checked == true)
                    this.personBoardList = []
                    this.$set(this.info, 'staffName', "");
                    // this.personBoardList = userList
                    if (userList.length > 0) {
                        let staffName = ""
                        userList.map((item, index) => {
            
                            if (index == userList.length - 1) {
                                staffName = staffName + item.staffName
                            } else {
                                staffName = staffName + item.staffName + ","
                            }
            
                            let data = {
                                staffId: item.staffId,
                                staffName: item.staffName,
                                staffNo: item.staffNo,
                                checked: item.checked
                            }
            
                            this.personBoardList.push(data)
                        });
                        this.$set(this.info, 'staffName', staffName);
                    }
                }
            },
            //刷新上一个页面
            refreshLastPage() {
                // 告知 A.vue 更新数据
                // 获取页面栈
                let pages = getCurrentPages()
            
                // 获取上一页栈
                let prevPage = pages[pages.length - 2]
            
                // 触发上一页 upData 函数(并携带参数)
                prevPage.$vm.refreshTrackingRecord()
            
                // 返回上一页
                uni.navigateBack({
                    delta: 1
                })
            }
        }
    };
</script>
<style lang="scss" scoped>
    .production-index-bg {
        background-color: #F6F9FF;
        background-image: url('~@/static/custom/product/productBg.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;
    }
 
    .content {
        font-size: 12px;
        background-color: rgba(250, 252, 255, 0.36);
        box-sizing: border-box;
        border-radius: 10rpx;
        margin: 0rpx 0rpx 24rpx;
        height: calc(100vh - var(--window-top) - var(--window-bottom) - 334rpx);
        padding: 10rpx 20rpx;
        box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(127, 127, 127, 0.1) !important;
        position: relative;
 
        .content-body {
            margin-top: 20rpx;
            background-color: white;
            // height: 1030rpx;
 
            .content-body-title {
                font-size: 35rpx;
                font-weight: bolder;
                color: #1D2541;
            }
 
            .content-body-item {
                // height: 90rpx;
                border: 1px solid #ADC8E4;
                line-height: 100rpx;
                display: flex;
                justify-content: space-between;
                border: none;
                margin: 0rpx 40rpx;
                align-items: center;
 
                .content-body-item-left {
                    line-height: 100rpx;
                    
                    
                    .slot-box {
                        font-size: 32rpx;
                    }
                }
 
                .content-body-item-right {
                    width: 400rpx;
                    line-height: 30rpx;
                    text-align: right;
                    ._text {
                        font-size: 26rpx;
                    }
                }
            }
 
            .param-extra {
                border-bottom: 1px solid #D5D5D5;
            }
        }
 
        .content-footer {
            margin-top: 30rpx;
            display: flex;
            justify-content: flex-end;
 
            .footer-button {
                margin-right: 35rpx;
            }
        }
 
        .bottom {
            display: flex;
            justify-content: space-between;
            height: 100rpx;
            margin-top: 30rpx;
        }
    }
</style>