wtt
2025-11-20 de32eaefeb995ce67a638ca82bc6760075af2eb5
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
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
<template>
    <view>
        <view class="form">
            <view class="form-item">
                <view class="title">单据号:</view>
                <view class="righton">
                    <input name="HBillNo" disabled v-model="hform.HBillNo" placeholder="请输入单据号" />
                </view>
            </view>
            <view class="form-item">
                <view class="title">单据日期:</view>
                <view class="righton">
                    <input name="HDate" disabled v-model="hform.HDate" placeholder="请选择" />
                </view>
            </view>
            <view class="form-item">
                <view class="title">内部单据号:</view>
                <view class="right">
                    <input name="HInnerBillNo" v-model="hform.HInnerBillNo" placeholder="请输入内部单据号" />
                </view>
            </view>
            
            <view class="tab_area"></view>
            
            <view class="form-item">
                <view class="title"><text>*</text>设备:</view>
                <view class="right" style="width: 380rpx;">
                    <input name="HEquipName" disabled v-model="hform.HEquipName" placeholder="请扫描设备" />
                </view>
                <uni-icons type="scan" style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;font-weight: 500;" size="20" @click="toScanCode"></uni-icons>
            </view>
            <view class="form-item">
                <view class="title"><text>*</text>负责人:</view>
                <view class="right">
                    <uni-combox :candidates="arrayEmpName" placeholder="请选择负责人" v-model="hform.HManagerName" @input="HManagerNameChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title"><text>*</text>维修人:</view>
                <view class="right">
                    <uni-combox :candidates="arrayEmpName" placeholder="请选择维修人" v-model="hform.HEmpName" @input="HEmpNameChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title"><text>*</text>维修开始:</view>
                <view class="right">
<!--                     <uni-datetime-picker v-model="hform.HRepairBeginDate">
                        <input name="HRepairBeginDate" disabled v-model="hform.HRepairBeginDate" placeholder="请选择维修开始时间" />
                    </uni-datetime-picker> -->
                    <picker mode="date" v-model="hform.HRepairBeginDate" @change="HBeginDateChange">
                        <input name="HRepairBeginDate" disabled v-model="hform.HRepairBeginDate" placeholder="请选择维修开始日期" />
                    </picker>
                </view>
            </view>
            <view class="form-item">
                <view class="title"><text>*</text>维修结束:</view>
                <view class="right">
<!--                     <uni-datetime-picker v-model="hform.HRepairEndDate">
                        <input name="HRepairEndDate" disabled v-model="hform.HRepairEndDate" placeholder="请选择维修结束时间" />
                    </uni-datetime-picker> -->
                    <picker mode="date" v-model="hform.HRepairEndDate" @change="HEndDateChange">
                        <input name="HRepairEndDate" disabled v-model="hform.HRepairEndDate" placeholder="请选择维修结束日期" />
                    </picker>
                </view>
            </view>
            <view class="form-item">
                <view class="title"><text>*</text>维修项目:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHRepair" placeholder="请选择维修项目" v-model="hform.HRepairName" @input="HRepairChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title"><text>*</text>维修部门:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHDeptName" placeholder="请选择维修部门" v-model="hform.HDeptName" @input="HDeptNameChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">计划工时:</view>
                <view class="right">
                    <input type="number" name="HPlanTimes" v-model="hform.HPlanTimes" placeholder="请输入计划维修工时" />
                </view>
            </view>
            <view class="form-item">
                <view class="title"><text>*</text>实际工时:</view>
                <view class="right">
                    <input type="number" name="HTimes" v-model="hform.HTimes" placeholder="请输入实际维修工时" />
                </view>
            </view>
            <view class="form-item">
                <view class="title">时间单位:</view>
                <radio-group name="HCycleUnit" style="padding: 8rpx 0;">
                    <label @tap="hform.HCycleUnit = '小时'">
                        <radio v-model="hform.HCycleUnit" :checked="hform.HCycleUnit == '小时'" style="transform:scale(0.8); margin-left: 50rpx;"/>小时
                    </label>
                    <label @tap="hform.HCycleUnit = '天'">
                        <radio v-model="hform.HCycleUnit" :checked="hform.HCycleUnit == '天'" style="transform:scale(0.8); margin-left: 40rpx;"/>天
                    </label>
                </radio-group>
            </view>
            <view class="form-item">
                <view class="title">源单类型:</view>
                <radio-group name="HMainSourceBillType" style="padding: 8rpx 0;">
                    <label @tap="hform.HMainSourceBillType = '设备维修登记单'">
                        <radio v-model="hform.HMainSourceBillType" :checked="hform.HMainSourceBillType == '设备维修登记单'" style="transform:scale(0.8);"/>设备维修登记单
                    </label>
                    <label @tap="hform.HMainSourceBillType = '手工录入'">
                        <radio v-model="hform.HMainSourceBillType" :checked="hform.HMainSourceBillType == '手工录入'" style="transform:scale(0.8); margin-left: 10rpx;"/>手工录入
                    </label>
                </radio-group>
            </view>
            <view class="form-item">
                <view class="title">选单号:</view>
                <view class="right" style="width: 380rpx;" @tap="showGz = true">
                    <input disabled v-model="hform.HMainSourceBillNo" placeholder="请选择故障单号" />
                </view>
                <uni-icons type="list" style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;font-weight: 500;" size="20" @click="showGz = true"></uni-icons>
            </view>
            <view class="form-item">
                <view class="title">维修内容:</view>
                <view class="right">
                    <textarea name="HRepairContent" v-model="hform.HRepairContent" auto-height placeholder="请输入具体维修内容"></textarea>
                </view>
            </view>
            <view class="form-item">
                <view class="title">维修要求:</view>
                <view class="right">
                    <textarea name="HExplanation" v-model="hform.HExplanation" auto-height placeholder="请输入具体维修要求"></textarea>
                </view>
            </view>
            <view class="form-item">
                <view class="title">备注:</view>
                <view class="right">
                    <textarea name="HRemark" v-model="hform.HRemark" auto-height placeholder="请输入备注"></textarea>
                </view>
            </view>
            
            <view class="form-item">
                <view class="tip"><text>*</text>注:  请点击下方绿色新增按钮添加维修信息(必填)</view>
            </view>
            
            <view class="bottom-btn">
                <button class="btn-a" size="mini" @tap="submit">提交</button>
                <button class="btn-b" size="mini" @tap="showMask = true">新增</button>
                <button class="btn-c" size="mini" @tap="goBack">退出</button>
            </view>
        </view>
        
        <gz @gzData="getGzData" @close="closeMask" v-if="showGz"></gz>
        <form1 :form1List='form1List' @hformList='hformList' v-if="showMask"></form1>
    </view>
</template>
<script>
    import getDateTime from '@/utils/getdateTime.js';
    import gz from './gz_table.vue';
    import form1 from './form1.vue';
    export default {
        components: {
            gz,
            form1
        },
        data() {
            return {
                serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API',
                arrayHDeptName:[],//部门
                HDeptNameList:[],
                arrayEmpName:[],//维修人/负责人
                EmpNameList:[],
                arrayHRepair:[],//维修项目
                HRepairList:[],
                showGz: false,
                
                hform:{
                    HInterID:0,
                    HBillNo:'',
                    HDate:getDateTime.dateTimeStr('y-m-d'),
                    HInnerBillNo:'',
                    
                    HEquipName:'',
                    HEquipID:'',
                    HManagerName:'',
                    HManagerID:'',
                    HEmpName:'',
                    HEmpID:'',
                    HRepairBeginDate:'',
                    HRepairEndDate:'',
                    HRepairName:'',
                    HRepairID:'',
                    HDeptName:'',
                    HDeptID:'',
                    HPlanTimes:'',
                    HTimes:'',
                    HCycleUnit:'小时',
                    HMainSourceBillType:'设备维修登记单',
                    HMainSourceBillNo:'',
                    HMainSourceInterID:'',
                    HMainSourceEntryID:'',
                    HRepairContent:'',
                    HExplanation:'',
                    HRemark:'',
                },
                
                showMask:false,
                form1List:[],
            }
        },
        onLoad(e) {
            // this.getEditData(424)
            if(e.hmainid){
                this.isEdit = true
                this.getEditData(e.hmainid)
            }else{
                this.getNewData()
            }
            this.getHDeptList()
            this.getEmpList()
            this.getHRepairList()
        },
        methods: {
            //扫码
            toScanCode(){
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
                mpaasScanModule.mpaasScan({
                    'hideAlbum': true,
                    'timeoutInterval':'10', //超时时间
                    'timeoutText':'未识别到二维码' //超时提醒            
                },(ret) => {
                    console.log(ret.resp_result)
                    uni.request({
                        url: this.serverUrl + '/Gy_EquipFileMain/Gy_MouldFileBillBarCodeInfo', 
                        data: { HBarCode: ret.resp_result },
                        success: (res) => {
                            console.log(res.data);
                            if(res.data.count == 1){
                                var data = res.data.list[0][0]
                                this.hform.HEquipID = data.hmainid
                                this.hform.HEquipName = data.设备名称
                            }
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        },
                        fail: (res) => {
                            console.log(res);
                            uni.showToast({
                                title:'接口请求失败',
                                icon:'none'
                            })
                        },
                    });
                })
            },
            //维修开始选择
            HBeginDateChange(e){
                console.log(e.detail.value)
                this.hform.HRepairBeginDate = e.detail.value
            },
            //维修结束选择
            HEndDateChange(e){
                console.log(e.detail.value)
                this.hform.HRepairEndDate = e.detail.value
            },
            
            //获取部门数据
            getHDeptList(){
                uni.request({
                    url: this.serverUrl + '/PublicPageMethod/DeptList', 
                    data: { sWhere: "where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + uni.getStorageSync('OrganizationID') + "" },
                    success: (res) => {
                        if(res.data.count == 1){
                            this.HDeptNameList = res.data.data
                            for(var i=0;i<res.data.data.length;i++){
                                this.arrayHDeptName[i] = res.data.data[i].HName
                            }
                            this.$forceUpdate();
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            //选择部门
            HDeptNameChange(e){
                for(var i=0;i<this.HDeptNameList.length;i++){
                    if(this.HDeptNameList[i].HName == e){
                        this.hform.HDeptID = this.HDeptNameList[i].HItemID
                    }
                }
            },
            //获取维修人/负责人数据
            getEmpList(){
                uni.request({
                    url: this.serverUrl + '/PublicPageMethod/UserList', 
                    data: { sWhere: '' },
                    success: (res) => {
                        if(res.data.count == 1){
                            this.EmpNameList = res.data.data
                            for(var i=0;i<res.data.data.length;i++){
                                this.arrayEmpName[i] = res.data.data[i].HName
                            }
                            this.$forceUpdate();
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            //选择维修人
            HEmpNameChange(e){
                for(var i=0;i<this.EmpNameList.length;i++){
                    if(this.EmpNameList[i].HName == e){
                        this.hform.HEmpID = this.EmpNameList[i].HItemID
                    }
                }
            },
            //选择负责人
            HManagerNameChange(e){
                for(var i=0;i<this.EmpNameList.length;i++){
                    if(this.EmpNameList[i].HName == e){
                        this.hform.HManagerID = this.EmpNameList[i].HItemID
                    }
                }
            },
            //获取维修项目数据
            getHRepairList(){
                uni.request({
                    url: this.serverUrl + '/PublicPageMethod/RepairItemList', 
                    data: { sWhere: '' },
                    success: (res) => {
                        if(res.data.count == 1){
                            this.HRepairList = res.data.data
                            for(var i=0;i<res.data.data.length;i++){
                                this.arrayHRepair[i] = res.data.data[i].HName
                            }
                            this.$forceUpdate();
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            //选择维修项目
            HRepairChange(e){
                for(var i=0;i<this.HRepairList.length;i++){
                    if(this.HRepairList[i].HName == e){
                        this.hform.HRepairID = this.HRepairList[i].HItemID
                    }
                }
            },
            
 
            //选择故障登记单
            getGzData(e){
                console.log(e)
                this.hform.HMainSourceBillNo = e.HMainSourceBillNo
                this.hform.HMainSourceInterID = e.HMainSourceInterID
                this.hform.HMainSourceEntryID = e.HMainSourceEntryID
                this.showGz = false
            },
            closeMask(e){
                this.showGz = false
            },
            
            hformList(e){
                console.log(e)
                this.form1List = e
                this.showMask = false
            },
            
            //编辑
            getEditData(hmainid){
                //主表
                uni.request({
                    url: this.serverUrl + '/Sb_EqpRepairWorkBill/Sb_EqpRepairWorkBillListCheckDetai', 
                    data: { HID: hmainid },
                    success: (res) => {
                        console.log(1,res.data.data.h_v_Sb_EquipRepairWorkBill_Edit);
                        if(res.data.code == 1){
                            var data = res.data.data.h_v_Sb_EquipRepairWorkBill_Edit[0]
                            this.hform = {
                                HInterID:hmainid,
                                HBillNo:data.单据号,
                                HDate:data.日期.substr(0,10),
                                HInnerBillNo:data.内部单据号,
                                
                                HEquipName:data.设备名称,
                                HEquipID:data.HEquipID,
                                HManagerName:data.负责人,
                                HManagerID:data.HManagerID,
                                HEmpName:data.维修人,
                                HEmpID:data.HEmpID,
                                HRepairBeginDate:data.维修开始日期.substr(0,10),
                                HRepairEndDate:data.维修结束日期.substr(0,10),
                                HRepairName:data.维修项目,
                                HRepairID:data.HRepairID,
                                HDeptName:data.部门名称,
                                HDeptID:data.HDeptID,
                                HPlanTimes:data.计划维修工时,
                                HTimes:data.实际维修工时 ,
                                HCycleUnit:data.时间单位,
                                HMainSourceBillType:data.HMainSourceBillType,
                                HMainSourceBillNo:data.HMainSourceBillNo,
                                HMainSourceInterID:data.HMainSourceInterID,
                                HMainSourceEntryID:data.HMainSourceEntryID,
                                HRepairContent:data.维修内容,
                                HExplanation:data.维修要求,
                                HRemark:data.表头备注,
                            }
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
                //子表
                uni.request({
                    url: this.serverUrl + '/Sb_EqpRepairWorkBill/Sb_EqpRepairWorkBillListProjectDetai', 
                    data: { HInterID: hmainid },
                    success: (res) => {
                        console.log(2,res.data.list);
                        if(res.data.count == 1){
                            this.form1List = res.data.list
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            //新增
            getNewData(){
                uni.request({
                    url: this.serverUrl + '/Web/GetMAXNum', 
                    data: { HBillType: '3910' },
                    success: (res) => {
                        console.log(res.data)
                        if(res.data.count == 1){
                            this.hform.HInterID = 0
                            this.hform.HBillNo = res.data.data[0].HBillNo
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            submit() {
                if(!this.hform.HEquipID){
                    uni.showToast({
                        title:'请扫描设备',
                        icon:'none'
                    })
                }else if(!this.hform.HManagerID){
                    uni.showToast({
                        title:'请选择负责人',
                        icon:'none'
                    })
                }else if(!this.hform.HEmpID){
                    uni.showToast({
                        title:'请选择维修人',
                        icon:'none'
                    })
                }else if(!this.hform.HRepairBeginDate){
                    uni.showToast({
                        title:'请选择维修开始时间',
                        icon:'none'
                    })
                }else if(!this.hform.HRepairEndDate){
                    uni.showToast({
                        title:'请选择维修结束时间',
                        icon:'none'
                    })
                }else if(!this.hform.HRepairID){
                    uni.showToast({
                        title:'请选择维修项目',
                        icon:'none'
                    })
                }else if(!this.hform.HDeptID){
                    uni.showToast({
                        title:'请选择维修部门',
                        icon:'none'
                    })
                }else if(!this.hform.HTimes){
                    uni.showToast({
                        title:'请选择实际工时',
                        icon:'none'
                    })
                }else if(this.form1List.length == 0){
                    uni.showToast({
                        title:'请新增维修信息,维修信息不可为空',
                        icon:'none'
                    })
                }else{
                    uni.showLoading({
                        title:'请稍候'
                    })
                    var sMainStr = JSON.stringify(this.hform);
                    var sSubStr = JSON.stringify(this.form1List);
                    var sMainSub = sMainStr + ';' + sSubStr + ";" + uni.getStorageSync('HUserName');
                    // console.log(sMainSub);
                    uni.request({
                        url: this.serverUrl + '/Sb_EqpRepairWorkBill/SaveGetEqpRepairWorkBillWebList',
                        method:'POST',
                        dataType:"json",
                        data:{ msg: sMainSub },
                        success: (res) => {
                            // console.log(1,res);
                            uni.hideLoading()
                            if(res.data.count == 1){
                                let pages = getCurrentPages();
                                let prePage = pages[pages.length - 2]; 
                                prePage.$vm.getList()
                                setTimeout(()=>{
                                    uni.navigateBack()
                                },1000)
                            }
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        },
                        fail: (res) => {
                            console.log(res);
                            uni.showToast({
                                title:'接口请求失败',
                                icon:'none'
                            })
                        },
                    });
                }
            },
            goBack(){
                uni.navigateBack()
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .form{
        width: 650rpx;
        margin: 20rpx auto;
        padding-bottom: 240rpx;
    }
    .tab_area{
        width: 100%;
        height: 50rpx;
    }
    .form-item{
        display: flex;
        align-items: center;
        font-size: 30rpx;
        padding: 6rpx 0;
        .title{
            width: 180rpx;
        }
        .right{
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #acacac;
        }
        .righton{
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #e4e4e4;
            background-color: #e4e4e4;
        }
        text{
            color: red;
            font-weight: bold;
        }
        input{
            width: 100%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
        }
        textarea{
            width: 98%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
        }
        .tip{
            color: #da9100;
            margin-top: 20rpx;
        }
 
    }
    
    .bottom-btn{
        width: 100%;
        // height: 120rpx;
        position: fixed;
        bottom: 0;
        left: 0;
        background-color: #fff;
        box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
        padding: 30rpx 40rpx 40rpx 40rpx;
        button{
            border-radius: 50rpx;
            width: 180rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
        }
        .btn-a{
            background-color: #3A78FF;
            color: #fff;
        }
        .btn-b{
            background-color: #41a863;
            color: #fff;
            margin-left: 30rpx;
        }
        .btn-c{
            background-color: #acacac;
            color: #fff;
            position: absolute;
            right: 120rpx;
        }
    }
</style>