hailu
2024-11-08 fc01b15fd9563a7256ece58921656cc86fb7d695
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
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
<template>
    <div id="" style="padding:6px;">
        <el-card style="margin-bottom:6px;">
            <el-form :model="queryParams" ref="queryForm" :inline="true">
                <el-form-item label="状态" prop="status">
                    <el-select v-model="state" placeholder="菜单状态" size="mini">
                        <el-option label="全部" :value="-1" />
                        <el-option label="未派单" :value="0" />
                        <el-option label="已派单" :value="1" />
                        <el-option label="已接单" :value="2" />
                        <el-option label="已完成" :value="3" />
                    </el-select>
                </el-form-item>
                <el-form-item label="超时" prop="level">
                    <el-select v-model="timeOutSelect" placeholder="超时查询" size="mini">
                        <el-option label="全部" :value="0" />
                        <el-option label="接单超时" :value="1" />
                        <el-option label="结单超时" :value="2" />
                    </el-select>
                </el-form-item>
                <el-form-item label="等级" prop="level">
                    <el-select v-model="level" placeholder="菜单状态" :disabled="erectoListLevel.length == 0" size="mini">
                        <el-option label="本级" :value="0" />
                        <el-option label="下级" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item v-if="level == 1 && erectoListLevel.length > 0" label="下级联营商" prop="nextlevel">
                    <el-select v-model="nextlevel" placeholder="菜单状态" size="mini">
                        <el-option v-for="item in erectoListLevel" :label="item.dept.deptName" :value="item.userId" />
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="changePage(1)">搜索</el-button>
                </el-form-item>
                <el-form-item v-if="roleKey == 'tenant' || roleKey == 'tenanthelper'">
                    <el-button size="mini" type="primary" icon="el-icon-message-solid"
                        @click="openTimeOutModal">超时配置</el-button></el-form-item>
                <el-form-item style="float: right;" v-if="roleKey !== 'admin'">
                    <el-button type="primary" v-hasPermi="['iot:device:add']" plain icon="el-icon-plus" size="mini"
                        @click="openAZModal">新增</el-button>
                </el-form-item>
            </el-form>
            <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection" fixed width="55">
                </el-table-column>
                <!-- <el-table-column label="基本信息"> -->
                <el-table-column prop="id" label="编号" width="60">
                </el-table-column>
                <el-table-column label="维修信息">
                    <el-table-column prop="device" label="设备名称" width="120">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.device && scope.row.device.deviceName ? scope.row.device.deviceName : '--' }}
                            </div>
 
                        </template>
                    </el-table-column>
                    <el-table-column prop="erectoName" label="维修工人" width="120">
                    </el-table-column>
                    <el-table-column prop="erectoPhone" label="联系电话" width="120">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.erectoPhone ? scope.row.erectoPhone : '--' }}
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="appointmentTime" label="预约时间" width="150">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.appointmentTime ? scope.row.appointmentTime : '--' }}
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="description" label="故障描述">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.description ? scope.row.description : '--' }}
                            </div>
                        </template>
                    </el-table-column>
 
                </el-table-column>
                <el-table-column label="订单状态" prop="state" width="120">
                    <template slot-scope="scope">
                        <div v-if="scope.row.state == 0">
                            未派单
                        </div>
                        <div v-if="scope.row.state == 1">
                            已派单
                        </div>
                        <div v-if="scope.row.state == 2">
                            已接单
                        </div>
                        <div v-if="scope.row.state == 3">
                            已完成
                        </div>
                        <div v-if="scope.row.receiveTimeoutFlag == 1">
                            <el-tag size="mini" effect="dark" type="danger">接单超时</el-tag>
                        </div>
                        <div v-if="scope.row.finishTimeoutFlag == 1">
                            <el-tag size="mini" effect="dark" type="warning"
                                style="background-color: #007AAE;border-color: #007AAE !important;">结单超时</el-tag>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="用户信息">
                    <el-table-column prop="userName" label="用户姓名" width="120">
                    </el-table-column>
                    <el-table-column prop="userPhone" label="用户电话" width="120">
                    </el-table-column>
                    <el-table-column prop="address" label="维修地址">
                    </el-table-column>
                </el-table-column>
                <!-- <el-table-column label="评价信息">
                    <el-table-column prop="score" label="评分" width="120">
                    </el-table-column>
                    <el-table-column prop="evaluate" label="评价" minWidth="120">
                    </el-table-column>
                </el-table-column> -->
 
                <el-table-column label="操作" fixed="right" align="center" width="150" class-name="small-padding fixed-width"
                    v-if="roleKey !== 'admin'">
                    <template slot-scope="scope">
                        <div style="display: flex;justify-content: space-around;">
                            <el-button v-if="scope.row.state != 3" size="small" type="primary" style="padding:5px;"
                                icon="el-icon-edit" v-hasPermi="['iot:device:edit']"
                                @click="editModal(scope.row)">修改</el-button>
                            <el-button v-if="scope.row.state == 0" size="small" type="danger" style="padding:5px;"
                                icon="el-icon-delete" v-hasPermi="['iot:device:remove']"
                                @click="delModal(scope.row)">删除</el-button>
                            <el-button v-if="scope.row.state == 1 && scope.row.erectoName == nickName" size="small"
                                type="success" style="padding:5px;" icon="el-icon-odometer"
                                @click="JDModal(scope.row)">接单</el-button>
                            <el-button v-if="scope.row.state == 2 && scope.row.erectoName == nickName" size="small"
                                type="success" style="padding:5px;" icon="el-icon-check"
                                @click="jdModal(scope.row)">结单</el-button>
                            <el-button v-if="scope.row.state == 3" size="small" type="success" style="padding:5px;"
                                icon="el-icon-view" @click="viewModal(scope.row)">查看</el-button>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="操作" fixed="right" align="center" width="150" class-name="small-padding fixed-width"
                    v-if="roleKey == 'admin'">
                    <template slot-scope="scope">
                        <div style="display: flex;justify-content: space-around;">
                            <el-button v-if="scope.row.state == 3" size="small" type="success" style="padding:5px;"
                                icon="el-icon-view" @click="viewModal(scope.row)">查看</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination background :current-page="pageIndex" @current-change="changePage" :page-size="pageSize"
                layout="prev, pager, next" :total="total" style="margin-top: 12px;">
            </el-pagination>
 
        </el-card>
 
        <el-dialog :title="title" :visible.sync="AZModal">
            <div class="azmodal">
                <el-form :model="form" :rules="rules" ref="form">
                    <el-form-item label="设备" :label-width="formLabelWidth" prop="deviceId">
                        <el-select v-model="form.deviceId" filterable placeholder="请选择" :disabled="title == '修改维修单' || view">
                            <el-option v-for="item in deviceList" :label="item.serialNumber"
                                :value="item.deviceId"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="维修工人" :label-width="formLabelWidth" prop="erectoId">
                        <el-select v-model="form.erectoId" placeholder="请选择"
                            :disabled="form.state > 1 || roleKey == 'tenantservice'">
                            <el-option v-for="item in erectoList" :label="item.nickName" :value="item.userId"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="订单状态" :label-width="formLabelWidth" prop="state">
                        <el-radio-group v-model="form.state" disabled>
                            <el-radio :label="0">未指派</el-radio>
                            <el-radio :label="1">已派单</el-radio>
                            <el-radio :label="2">已接单</el-radio>
                            <el-radio :label="3">已完成</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="用户姓名" :label-width="formLabelWidth" prop="userName">
                        <el-input v-model="form.userName" autocomplete="off" :disabled="view"></el-input>
                    </el-form-item>
                    <el-form-item label="用户电话" :label-width="formLabelWidth" prop="userPhone">
                        <el-input v-model="form.userPhone" autocomplete="off" :disabled="view"></el-input>
                    </el-form-item>
                    <el-form-item label="维修地址" :label-width="formLabelWidth" prop="address">
                        <el-input v-model="form.address" autocomplete="off" :disabled="view"></el-input>
                    </el-form-item>
                    <el-form-item label="预约时间" :label-width="formLabelWidth">
                        <el-date-picker v-model="form.appointmentTime" type="datetime" placeholder="选择日期时间" :disabled="view"
                            value-format="yyyy-MM-dd HH:mm:ss">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="故障描述" :label-width="formLabelWidth" prop="description">
                        <el-input type="textarea" v-model="form.description" :disabled="view"></el-input>
                    </el-form-item>
                    <el-form-item label="维修证明" v-if="view" :label-width="formLabelWidth">
                        <img :src="form.imgUrl" alt="">
                    </el-form-item>
                    <el-form-item label="上传图片" v-if="form.state == 3 && !view" :label-width="formLabelWidth">
                        <el-upload ref="uploadImg" action="#" :on-change="handleChange" list-type="picture-card"
                            :multiple="false" :auto-upload="false" :on-preview="handlePictureCardPreview" :limit="1"
                            :on-exceed="exceed" :on-remove="handleRemove">
                            <i class="el-icon-plus"></i>
                        </el-upload>
                        <el-dialog :visible.sync="dialogVisible">
                            <img width="100%" :src="dialogImageUrl" alt="">
                        </el-dialog>
                    </el-form-item>
                    <el-form-item label="用户评分" v-if="form.isRate" :label-width="formLabelWidth">
                        <el-rate disabled v-model="form.score" style="padding-top: 8px;"></el-rate>
                    </el-form-item>
                    <el-form-item label="用户评价" v-if="form.isRate" :label-width="formLabelWidth">
                        <el-input type="textarea" disabled v-model="form.evaluate" :disabled="view"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button @click="AZModal = false" :disabled="view">取 消</el-button>
                <el-button type="primary" @click="submitForm('form')" :disabled="view">确 定</el-button>
            </div>
        </el-dialog>
        <el-dialog title="删除数据" :visible.sync="deleteModal" width="30%">
            <span>是否删除该条数据</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="deleteModal = false">取 消</el-button>
                <el-button type="primary" @click="delDate">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="接单" :visible.sync="acceptModal" width="30%">
            <span>是否确认接单?此操作不可恢复!</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="acceptModal = false">取 消</el-button>
                <el-button type="primary" @click="add">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="超时配置" :visible.sync="timeOutModal">
            <el-form :model="timeForm" :rules="timeRules" ref="timeForm">
                <el-form-item label="派单接单超时间隔(单位:分钟)" :label-width="timeformLabelWidth" prop="ReceiveTimeout">
                    <el-input v-model="timeForm.ReceiveTimeout" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="接单完成超时间隔(单位:分钟)" :label-width="timeformLabelWidth" prop="FinishTimeout">
                    <el-input v-model="timeForm.FinishTimeout" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="timeOutModal = false" size="mini">取 消</el-button>
                <el-button type="primary" @click="submitTimeForm('timeForm')" size="mini">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>
 
<script>
import request from '@/utils/request'
export default {
    data() {
        return {
            timeOutSelect: 0,
            timeForm: {
                ReceiveTimeout: 0,
                FinishTimeout: 0,
            },
            timeRules: {
                ReceiveTimeout: [
                    { required: true, message: "派单接单超时间隔不能为空", trigger: "blur" }
                ],
                FinishTimeout: [
                    { required: true, message: "接单完成超时间隔不能为空", trigger: "blur" }
                ],
            },
            timeOutModal: false,
            nextlevel: 0,
            level: 0,
            nickName: localStorage.getItem('nickName'),
            acceptModal: false,
            acceptDateParams: {},
            title: '创建维修单',
            deleteModal: false,
            pageIndex: 1,
            pageSize: 10,
            total: 0,
            searchName: '',
            queryParams: {
                WXBody: '未派单',
                PDBody: '未派单'
            },
            WXBodyType: [{ label: '全部工单', value: '全部工单' }, { label: '未派单', value: '未派单' }, { label: 'num1', value: 'num1' }],
            rules: {
                deviceId: [
                    { required: true, message: '请选择设备', trigger: 'change' }
                ],
                erectoId: [
                    { required: true, message: "请选择维修工", trigger: "change" }
                ],
                userName: [
                    { required: true, message: "用户姓名不能为空", trigger: "blur" }
                ],
                userPhone: [
                    { required: true, trigger: "blur", message: "请输入您的手机号码" },
                    { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式不正确', trigger: 'blur' }
                ],
                address: [
                    { required: true, message: "维修地址不能为空", trigger: "blur" }
                ],
                description: [
                    { required: true, message: "故障描述不能为空", trigger: "blur" }
                ],
            },
            form: {},
            tableData: [
            ],
            timeformLabelWidth: '215px',
            formLabelWidth: '120px',
            AZModal: false,
            deviceList: [],
            state: -1,
            id: 0,
            erectoList: [],
            erectoListLevel: [],
            roleKey: localStorage.getItem('roleKey'),
            dialogImageUrl: '',
            dialogVisible: false,
            view: false,
            delDeviceId: 0
 
        }
    },
 
    mounted() {
        this.getList();
        this.getErectoList()
        this.getErectoListLevel()
    },
    methods: {
        submitTimeForm() {
            this.$refs['timeForm'].validate((valid) => {
                if (valid) {
                    this.editTimeOut()
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        editTimeOut() {
            let data = {
                receiveTimeout: this.timeForm.ReceiveTimeout,
                finishTimeout: this.timeForm.FinishTimeout,
                orderType: 2,
                userId: localStorage.getItem('userID')
            }
            request({
                url: `/iot/deviceOrder/updatetimeout`,
                method: "put",
                params: data,
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.$message({
                        message: '修改成功',
                        type: 'success'
                    });
                    this.timeOutModal = false
                } else {
                    this.$message({
                        message: '修改失败',
                        type: 'error'
                    });
                }
            }).catch((res) => {
                this.$message({
                    message: '修改失败',
                    type: 'error'
                });
            })
 
        },
        getTimeOut() {
            let data = {
                orderType: 2,
                userId: localStorage.getItem('userID')
            }
            request({
                url: `/iot/deviceOrder/selecttimeout`,
                method: "get",
                params: data,
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.timeForm.ReceiveTimeout = res.data.receiveTimeout
                    this.timeForm.FinishTimeout = res.data.finishTimeout
                } else {
                    this.timeForm.ReceiveTimeout = 0
                    this.timeForm.FinishTimeout = 0
                }
            }).catch((res) => {
                this.timeForm.ReceiveTimeout = 0
                this.timeForm.FinishTimeout = 0
                return false
            })
        },
        openTimeOutModal() {
            this.getTimeOut()
            this.timeOutModal = true
 
        },
        exceed(e) {
            console.log(e);
            this.$message({
                message: '图片最多上传一张',
                type: 'error'
            });
        },
        handleRemove(file, fileList) {
            this.form.imgUrl = ''
            console.log(file, fileList);
        },
        handleChange(file) {
            console.log(file);
            if (file.size > 1024 * 1024 * 2) {
                this.$refs.uploadImg.uploadFiles.length = 0;
                this.$message({
                    message: '图片大小不能超过2M,请重新上传',
                    type: 'error'
                });
                return false
            }
            this.dialogImageUrl = file.url;
            let formData = new FormData();
            formData.append('avatarfile', file.raw);
            formData.append('orderType', 2);
            request({
                url: '/iot/deviceOrder/Repair/profile/avatar',
                method: "post",
                data: formData
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.$message({
                        message: '上传成功',
                        type: 'success'
                    });
                    this.form.imgUrl = 'https://puyue.yhupai.com/prod-api' + res.imgUrl
                } else {
                    this.$message({
                        message: '上传失败',
                        type: 'error'
                    });
                }
            }).catch((res) => {
                this.$message({
                    message: '上传失败',
                    type: 'error'
                });
            })
        },
        handlePictureCardPreview(file) {
            this.dialogImageUrl = file.url;
            this.dialogVisible = true;
        },
        getErectoList() {
            let data = {
                pageNum: 1,
                pageSize: 10000,
                deptId: localStorage.getItem('deptId'),
                isAuthentication: 1,
            }
            request({
                url: '/system/user/list',
                method: "get",
                params: data
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.erectoList = res.rows
                    this.erectoList.unshift({
                        nickName: '未指派',
                        userId: -1
                    })
                } else {
                    this.erectoList = []
                }
            }).catch((res) => {
                this.erectoList = []
            })
        },
        getErectoListLevel() {
            this.erectoListLevel = []
            let data = {
                pageNum: 1,
                pageSize: 10000,
                deptId: localStorage.getItem('deptId'),
                // isAuthentication: 1,
                roleKey: 'tenanthelper',
            }
            request({
                url: '/system/user/list',
                method: "get",
                params: data
            }).then((res) => {
                console.log(res);
                if (res.code == 200 && res.rows.length > 0) {
                    this.erectoListLevel = res.rows
                    this.nextlevel = res.rows[0].userId
                } else {
                    this.erectoListLevel = []
                }
            }).catch((res) => {
                this.erectoListLevel = []
            })
        },
        // 获取设备列表
        getDeviceList() {
            let data = {
                repairFlag: 0,
                // installFlag:1
            }
            request({
                url: '/iot/device/shortListRepair',
                method: "get",
                params: data
            }).then((res) => {
                if (res.code == 200) {
                    this.deviceList = res.rows
                } else {
                    this.deviceList = []
                }
            }).catch((res) => {
                this.deviceList = []
            })
        },
        // 获取维修列表
        getList() {
            this.tableData = []
            let data = {
                pageNum: this.pageIndex,
                pageSize: this.pageSize,
                state: this.state,
                orderType: 2,
            }
            if (this.timeOutSelect == 0) {
            } else if (this.timeOutSelect == 1) {
                data.receiveTimeoutFlag = 1
            } else if (this.timeOutSelect == 2) {
                data.finishTimeoutFlag = 1
            }
            if (this.roleKey == 'tenantservice') {
                data.createUserId = 0
                data.erectoId = localStorage.getItem('userID')
            }
            if (this.roleKey == 'admin') {
                data.createUserId = 0;
                data.erectoId = 0;
            }
            if (this.roleKey == 'tenant' || this.roleKey == 'tenanthelper') {
                data.createUserId = localStorage.getItem('userID');
                data.erectoId = 0;
            }
            if (this.level == 1) { //当选择下级时
                data.createUserId = this.nextlevel
            }
            request({
                url: '/iot/deviceOrder/list',
                method: "get",
                params: data
            }).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.rows
                    this.total = res.total
                } else {
                    this.tableData = []
                    this.total = 0
                }
            }).catch((res) => {
                this.tableData = []
                this.total = 0
            })
        },
        handleSelectionChange(e) {
            console.log(1, e);
        },
        filterHandlerBody(e) {
            console.log(2, e);
        },
        filterHandlerStatus(e) {
            console.log(3, e);
        },
        changePage(e) {
            this.pageIndex = e
            this.getList()
 
        },
        openAZModal() {
            this.getDeviceList();
            this.form = {
                deviceId: undefined,
                address: '',//地址
                appointmentTime: '',//预约时间
                description: '',//故障描述
                erectoId: -1,//维修工
                userName: '', //用户信息,联系人
                userPhone: '',//用户信息联系电话
                erectoName: '未指派',
                state: 0,
                erectoPhone: '',
            }
            this.title = '创建维修单'
            this.AZModal = true
        },
        submitForm() {
            this.$refs['form'].validate((valid) => {
                if (valid) {
                    this.add()
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        add() {
            // let userId=undefined
            console.log(this.erectoList);
            for (let i = 0; i < this.erectoList.length; i++) {
                if (this.form.erectoId == this.erectoList[i].userId) {
                    this.form.erectoName = this.erectoList[i].nickName
                    this.form.erectoPhone = this.erectoList[i].phonenumber
                    // userId=this.erectoList[i].userId
                }
            }
            console.log(this.form);
            let data = {
                deviceId: this.form.deviceId,
                erectoId: this.form.erectoId,
                erectoName: this.form.erectoName,
                userName: this.form.userName,
                userPhone: this.form.userPhone,
                address: this.form.address,
                appointmentTime: this.form.appointmentTime,
                description: this.form.description,
                state: this.form.state,
                orderType: '2',
                repairFlag: 1,
                erectoPhone: this.form.erectoPhone,
                // userId:userId
            }
            if (this.form.receiveTime) {
                data.receiveTime = this.form.receiveTime
            }
 
            console.log(data)
            if (this.title == '修改维修单') {
                data.id = this.id
 
                if (this.form.state == 3) {
                    if (!this.form.imgUrl) {
                        this.$message({
                            message: '请上传图片',
                            type: 'error'
                        });
                        return
                    }
                    data.imgUrl = this.form.imgUrl
                }
                request({
                    url: '/iot/deviceOrder',
                    method: "put",
                    data: data
                }).then((res) => {
                    console.log(res);
                    if (res.code == 200) {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                        this.acceptModal = false
 
                    } else {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                        this.acceptModal = false
 
                    }
                }).catch((res) => {
                    this.state = -1
                    this.pageIndex = 1
                    this.getList()
                    this.AZModal = false
                    this.acceptModal = false
 
                })
 
            } else {
 
                request({
                    url: '/iot/deviceOrder',
                    method: "post",
                    data: data
                }).then((res) => {
                    if (res.code == 200) {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
 
                    } else {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                    }
                }).catch((res) => {
                    this.state = -1
                    this.pageIndex = 1
                    this.getList()
                    this.AZModal = false
                })
            }
 
        },
        editModal(item) {
            this.title = '修改维修单'
            this.form = item
            this.form = JSON.parse(JSON.stringify(item))
            this.deviceList = [{ deviceName: item.device.deviceName, serialNumber: item.device.serialNumber, deviceId: item.device.deviceId }]
            console.log(this.form);
            this.view = false
            this.AZModal = true
            this.id = item.id
        },
        delModal(item) {
            this.id = item.id
            this.delDeviceId = item.deviceId
            this.deleteModal = true
        },
        delDate() {
            let that = this
            let data = {
                id: that.id,
                deviceId: that.delDeviceId
            }
            request({
                url: `/iot/deviceOrder/${that.id}/${that.delDeviceId}`,
                method: "DELETE",
                // data: data
            }).then((res) => {
                if (res.code == 200) {
                    that.pageIndex = 1
                    that.getList()
                    that.deleteModal = false
                } else {
                    that.pageIndex = 1
                    that.getList()
                    that.deleteModal = false
                }
 
            }).catch((res) => {
                that.pageIndex = 1
                that.getList()
                that.deleteModal = false
            })
        },
        JDModal(item) {
            if (!item.appointmentTime) {
                this.$message({
                    message: '请和客户确认预约时间并录入系统再接单!',
                    type: 'error'
                });
                return false
            }
            this.title = '修改维修单'
            this.form = JSON.parse(JSON.stringify(item))
            this.form.state = 2
            this.deviceList = [{ deviceName: item.device.deviceName, serialNumber: item.device.serialNumber, deviceId: item.device.deviceId }]
            this.id = item.id
            this.view = false
            this.form.receiveTime = this.formatNow()
            this.acceptModal = true
        },
        jdModal(item) {
            this.title = '修改维修单'
            this.form = JSON.parse(JSON.stringify(item))
            this.form.state = 3
            this.deviceList = [{ deviceName: item.device.deviceName, serialNumber: item.device.serialNumber, deviceId: item.device.deviceId }]
            this.id = item.id
            this.view = false
            this.AZModal = true
        },
        formatNow() {
            let now = new Date();
            let year = now.getFullYear();
            let month = (now.getMonth() + 1).toString().padStart(2, '0');  // 注意:月份是从 0 开始的,所以需要 +1
            let day = now.getDate().toString().padStart(2, '0');
            let hour = now.getHours().toString().padStart(2, '0');
            let minute = now.getMinutes().toString().padStart(2, '0');
            let second = now.getSeconds().toString().padStart(2, '0');
            let millisecond = now.getMilliseconds().toString().padStart(3, '0');
            return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
        },
        // 结单查看
        viewModal(item) {
            this.title = '查看维修单'
            this.form = JSON.parse(JSON.stringify(item))
            this.form.erectoId = this.form.erectoName
            this.deviceList = [{deviceName: item.device.deviceName, serialNumber: item.device.serialNumber, deviceId: item.device.deviceId }]
            console.log(this.erectoList);
            this.id = item.id
            this.view = true
            // this.form.receiveTime = this.formatNow()
            this.AZModal = true
        },
    },
    watch: {
        'form.erectoId': {
            handler(newVal, oldVal) {
                if (this.form.state < 2) {
                    if (newVal && newVal == -1) {
                        this.form.state = 0
                    } else {
                        this.form.state = 1
                    }
                }
 
            },
            deep: true,
        },
    }
}
</script>
<style lang="scss" scoped>
.title {
    display: flex;
}
 
.el-select .el-input {
    width: 130px;
}
 
.input-with-select .el-input-group__prepend {
    background-color: #fff;
}
.azmodal {
    max-height: 600px;
    overflow-y: auto !important;
}
</style>