Your Name
2022-05-24 d9edcf2fa95e62bf9bbac6253a695c1151780e7b
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
<template>
    <div class="app-container">
        <el-dialog title="巡检记录详情" :visible.sync="inspectionRecordFormVisible"  append-to-body :close-on-click-modal="false" width="40%">
            <el-form ref="inspectionRecordForm" :model="inspectionRecordForm" label-position="right" label-width="120px" readonly>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="任务名称" prop="title">
                            <el-input v-model="inspectionRecordForm.title" class="analyseUnit_input" readonly>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="检查类型" prop="type">
                            <el-select v-model="inspectionRecordForm.type" class="analyseUnit_input" readonly>
                                <el-option
                                v-for="item in typeList"
                                :key=item.id
                                :label=item.name
                                :value=item.id
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="检查类型" prop="execUname">
                            <el-input v-model="inspectionRecordForm.execUname" class="analyseUnit_input" readonly>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="任务状态" prop="status">
                            <el-select v-model="inspectionRecordForm.status" class="analyseUnit_input" readonly>
                                <el-option
                                    v-for="item in statusList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="巡检开始时间" prop="expTime">
                            <el-date-picker v-model="inspectionRecordForm.expTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="巡检开始时间" class="analyseUnit_input" readonly></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="巡检结束时间" prop="endTime">
                            <el-date-picker v-model="inspectionRecordForm.endTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="巡检结束时间" class="analyseUnit_input" readonly></el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="巡检提交时间" prop="execTime">
                               <el-date-picker v-model="inspectionRecordForm.execTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="巡检提交时间" class="analyseUnit_input" readonly></el-date-picker>
                        </el-form-item>
                    </el-col>
 
                </el-row>
            </el-form>
        </el-dialog>
        <el-dialog :title="titleDetail"  :visible.sync="inspectionRecordDetailFormVisible"  append-to-body :close-on-click-modal="false" width="500px">
            <el-form ref="inspectionRecordDetailForm" :rules="inspectionRecordDetailFormRules" :model="inspectionRecordDetailForm" label-position="right" label-width="120px">
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="巡检结果" prop="result">
                            <el-select v-model="inspectionRecordDetailForm.result" :disabled="ifShow" class="input" @change="ifNormal = (inspectionRecordDetailForm.result === 2 ? true : false)">
                                <el-option
                                v-for="item in resultList"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <div v-if="ifNormal">
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="异常通知部门" prop="noticeDepId">
                                <el-select v-model="inspectionRecordDetailForm.noticeDepId" filterable clearable class="input" @change="changeDepartment('notice')" :disabled="ifShow">
                                    <el-option
                                        v-for="item in departmentList"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.department"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="异常通知人员" prop="noticeUid">
                                <el-select v-model="inspectionRecordDetailForm.noticeUid" clearable filterable :disabled="ifShow" class="input">
                                    <el-option
                                        v-for="item in noticeUserList"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.realname"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="整改时间" prop="fixTime">
                                <el-date-picker placeholder="选择时间" v-model="inspectionRecordDetailForm.fixTime" class="input" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" :disabled="ifShow"></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="异常整改部门" prop="fixDepId">
                                <el-select v-model="inspectionRecordDetailForm.fixDepId" filterable clearable class="input" :disabled="ifShow" @change="changeDepartment('fix')">
                                    <el-option
                                        v-for="item in departmentList"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.department"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row >
                        <el-col :span="24">
                            <el-form-item label="整改人" prop="fixUid">
                                <el-select v-model="inspectionRecordDetailForm.fixUid" clearable filterable :disabled="ifShow" class="input">
                                    <el-option
                                        v-for="item in fixUserList"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.realname"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="巡检结果备注" prop="info">
                                <el-input type="textarea" :rows="3" v-model="inspectionRecordDetailForm.info" :disabled="ifShow" class="input">
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="上报图片" prop="imgInfoList">
                                <el-upload
                                    accept=".pdf,.jpg,.png"
                                    :action="fileRoad"
                                    class="upload-demo"
                                    ref="upload"
                                    :headers="header"
                                    :data="uploadForm"
                                    list-type="picture-card"
                                    :file-list="fileList"
                                    v-model="inspectionRecordDetailForm.imgInfoList"
                                    :on-change="handleChangeFile"
                                    :on-success="onFileSuccess"
                                    :multiple="false"
                                    :auto-upload="true">
                                    <i slot="default" class="el-icon-plus"></i>
                                    <div slot="file" slot-scope="{file}">
                                        <img
                                            class="el-upload-list__item-thumbnail"
                                            :src="file.url" alt=""
                                        >
                                        <span class="el-upload-list__item-actions">
                                <span
                                    class="el-upload-list__item-preview"
                                    @click="handleFile(file)"
                                >
                                  <i class="el-icon-zoom-in"></i>
                                </span>
                                <span
                                    v-if="!disabled"
                                    class="el-upload-list__item-delete"
                                    @click="handleRemove(file,'one')"
                                >
                                  <i class="el-icon-delete"></i>
                                </span>
                              </span>
                                    </div>
                                </el-upload>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div v-if="ifLook">
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="异常通知部门" prop="noticeDepId">
                                <el-select v-model="inspectionRecordDetailForm.problem.noticeDepId" filterable clearable class="input" @change="changeDepartment('notice')" readonly>
                                    <el-option
                                        v-for="item in departmentList"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.department"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="异常通知人员" prop="noticeUid">
                                <el-select v-model="inspectionRecordDetailForm.problem.noticeUid" clearable filterable readonly class="input">
                                    <el-option
                                        v-for="item in noticeUserList"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.realname"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="整改时间" prop="fixTime">
                                <el-date-picker placeholder="选择时间" v-model="inspectionRecordDetailForm.problem.fixTime" class="input" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" readonly></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="异常整改部门" prop="fixDepId">
                                <el-select v-model="inspectionRecordDetailForm.problem.fixDepId" filterable clearable class="input" readonly>
                                    <el-option
                                        v-for="item in departmentList"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.department"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row >
                        <el-col :span="24">
                            <el-form-item label="整改人" prop="fixUid">
                                <el-select v-model="inspectionRecordDetailForm.problem.fixUid" clearable filterable readonly class="input">
                                    <el-option
                                        v-for="item in fixUserList"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.realname"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="巡检结果备注" prop="info" >
                                <el-input type="textarea" :rows="3" v-model="inspectionRecordDetailForm.problem.info" aria-readonly="true" class="input">
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="上报图片" prop="imgInfoList">
                                <el-upload
                                    accept=".pdf,.jpg,.png"
                                    :action="fileRoad"
                                    class="upload-demo"
                                    ref="upload"
                                    :headers="header"
                                    :data="uploadForm"
                                    list-type="picture-card"
                                    :file-list="fileList"
                                    v-model="inspectionRecordDetailForm.imgInfoList"
                                    :on-change="handleChangeFile"
                                    :on-success="onFileSuccess"
                                    :auto-upload="true">
                                    <i slot="default" class="el-icon-plus"></i>
                                    <div slot="file" slot-scope="{file}">
                                        <img
                                            class="el-upload-list__item-thumbnail"
                                            :src="file.url" alt=""
                                        >
                                        <span class="el-upload-list__item-actions">
                                <span
                                    class="el-upload-list__item-preview"
                                    @click="handleFile(file)"
                                >
                                  <i class="el-icon-zoom-in"></i>
                                </span>
                                <span
                                    v-if="!disabled"
                                    class="el-upload-list__item-delete"
                                    @click="handleRemove(file,'one')"
                                >
                                  <i class="el-icon-delete"></i>
                                </span>
                              </span>
                                    </div>
                                </el-upload>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div  style="text-align: center" v-show="ifConfirm">
                    <el-button @click="inspectionRecordDetailFormVisible = false">取消</el-button>
                    <el-button type="primary" @click="submitInspectionRecordDetail()">确认</el-button>
                </div>
            </el-form>
        </el-dialog>
        <el-dialog :visible.sync="dialogVisible" :append-to-body="true">
            <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>
    </div>
</template>
 
<script>
    import Cookies from "js-cookie";
    import {submitUnitOne} from "../../../../../api/inspectionTask";
 
    export default {
        name: "detail",
        data(){
            const validateImg = (rule, value, callback) => {
                if (!this.inspectionRecordDetailForm.img) {
                    callback(new Error('请上传图片'))
                } else {
                    callback()
                }
            }
            return{
                fileRoad:process.env.BASE_API + '/task/web/upload',
                uploadForm:{
                },
                disabled:false,
                header:{Authorization:''},
                dialogImageUrl:false,
                dialogVisible:false,
                titleDetail:'',
                inspectionRecordForm:{
 
                },
                inspectionRecordFormVisible:false,
                inspectionRecordDetailForm:{
                    execUid: null,
                    fixTime: null,
                    fixUid: null,
                    imgInfoList: [],
                    info: null,
                    noticeUid: null,
                    result: null,
                    taskId: null,
                    unitId: null,
                    fixDepId:null,
                    noticeDepId:null,
                },
                inspectionRecordDetailFormRules:{
                    img: [{ required: true, validator: validateImg, trigger: 'blur' }],
                    result: [{ required: true, message: '巡检结果不能为空', trigger: 'blur' }],
                    noticeUid: [{ required: true, message: '异常通知人员不能为空', trigger: 'change' }],
                    fixTime: [{ required: true, message: '整改时间不能为空', trigger: 'change' }],
                    fixUid: [{ required: true, message: '描整改人员不能为空', trigger: 'change' }],
                    info: [{ required: true, message: '巡检结果备注不能为空', trigger: 'blur' }],
                    fixDepId: [{ required: true, message: '异常整改部门不能为空', trigger: 'blur' }],
                    noticeDepId: [{ required: true, message: '异常通知部门不能为空', trigger: 'blur' }],
                },
                inspectionRecordDetailFormVisible:false,
                ifShow:true,
                ifNormal:false,
                ifLook:false,
                ifConfirm:false,
                userList:[],
                noticeUserList:[],
                fixUserList:[],
                departmentList:[],
                fileList:[],
                resultList:[{id:0,name:'未巡检'},{id:1,name:'正常'},{id:2,name:'异常'}],
                typeList:[{id:1,name:'日常检查'},{id:2,name:'周期检查'}],
                statusList:[{id:1,name:'待巡检'},{id:2,name:'巡检中'},{id:3,name:'已完成'},{id:4,name:'超时未巡检'},{id:5,name:'已取消'}],
            }
        },
        components:{
 
        },
        methods:{
            showInspectionRecordForm(value) {
                this.inspectionRecordFormVisible = true
                this.inspectionRecordForm = JSON.parse(JSON.stringify(value))
            },
            showInspectionRecordDetailForm(value,type,userList,departmentList) {
                this.inspectionRecordDetailFormVisible = true
                this.$nextTick(() =>{
                    this.$refs["inspectionRecordDetailForm"].clearValidate()
                })
                this.userList = userList
                this.departmentList = departmentList
                if(type === '查看'){
                    this.titleDetail = '查看单元上报'
                    this.ifNormal = false
                    this.ifLook = true
                    this.ifConfirm = false
                    this.inspectionRecordDetailForm = JSON.parse(JSON.stringify(value))
                    if(this.inspectionRecordDetailForm.problem.imageInfoList === null){
                        this.fileList = []
                    }else{
                        this.fileList = this.inspectionRecordDetailForm.problem.imageInfoList.map( item => { return { url : process.env.IMG_API + item.imgPath}})
                    }
                }else{
                    this.titleDetail = '巡检单元上报'
                    this.ifShow = false
                    this.ifNormal = false
                    this.ifLook = false
                    this.ifConfirm = true
                    this.inspectionRecordDetailForm = {
                        execUid: Cookies.get('userId'),
                        fixTime: null,
                        fixUid: null,
                        imgInfoList: [],
                        info: null,
                        noticeUid: null,
                        result: null,
                        fixDepId:null,
                        noticeDepId:null,
                        taskId: value.taskId,
                        unitId: value.id
                    }
                }
            },
            submitInspectionRecordDetail() {
                if(this.ifNormal === false){
                    this.inspectionRecordDetailForm.noticeUid = null
                    this.inspectionRecordDetailForm.fixTime = null
                    this.inspectionRecordDetailForm.fixUid = null
                    this.inspectionRecordDetailForm.info = null
                    this.inspectionRecordDetailForm.imgInfoList = []
                    this.inspectionRecordDetailForm.noticeDepId = null
                    this.inspectionRecordDetailForm.fixDepId = null
                }
                this.$refs["inspectionRecordDetailForm"].validate((valid) =>{
                    if(valid){
                        if(this.inspectionRecordDetailForm.result === 0){
                            this.$message({
                                type:'warning',
                                message:'请选择正确的巡检结果'
                            })
                            return
                        }
                        this.inspectionRecordDetailForm.imgInfoList = this.inspectionRecordDetailForm.imgInfoList.map(item =>{ return { imagePath:item.imagePath}})
                        submitUnitOne(this.inspectionRecordDetailForm).then( res =>{
                            if(res.data.code === '200'){
                                this.inspectionRecordDetailFormVisible = false
                                this.$emit('getList')
                                this.$message({
                                    type:'success',
                                    message:'上报成功',
                                    duration:2000,
                                    title:'成功'
                                })
 
                            }else{
                                this.$message({
                                    message:res.data.message,
                                    type:'warning'
                                })
                            }
                        })
                    }else{
                        this.$message({
                            message:'请完善基本信息',
                            type:'warning'
                        })
                    }
                })
            },
            changeDepartment(type){
              if(type === 'notice'){
                  if(this.inspectionRecordDetailForm.noticeDepId === ''){
                      this.noticeUserList = []
                  }else{
                      let department = this.departmentList.find(item => item.id === this.inspectionRecordDetailForm.noticeDepId).department
                      this.noticeUserList = this.userList.filter ( item => item.department === department)
                  }
              }else{
                  if(this.inspectionRecordDetailForm.fixDepId === ''){
                      this.fixUserList = []
                  }else{
                      let department = this.departmentList.find(item => item.id === this.inspectionRecordDetailForm.fixDepId).department
                      this.fixUserList = this.userList.filter ( item => item.department === department)
                  }
              }
            },
            handleChangeFile(){
                this.header.Authorization = Cookies.get('token')
            },
            onFileSuccess(response){
                if(response.code === '200'){
                    this.inspectionRecordDetailForm.imgInfoList.push({imagePath:response.result.path,name:response.result.name,})
                    this.fileList.push({url:process.env.IMG_API + response.result.path,name:response.result.name,})
                    this.$notify({
                        type:'success',
                        duration:2000,
                        message:'上传成功',
                        title:'成功',
                    })
                }else{
                    this.$message({
                        message:res.data.message,
                        type:'warning'
                    })
                }
            },
            handleFile(file){
                this.dialogImageUrl = file.url;
                this.dialogVisible = true;
            },
            handleRemove(file){
                return this.$confirm(`确定移除 ${ file.name }?`,'提示',{
                    confirmButtonText:'确定',
                    cancelButtonText:'取消',
                    type:'warning',
                }).then(()=> {
                    this.inspectionRecordDetailForm.imgInfoList.splice(this.inspectionRecordDetailForm.imgInfoList.findIndex(item =>item.name === file.name),1)
                    this.fileList.splice(this.inspectionRecordDetailForm.imgInfoList.findIndex(item =>item.name === file.name),1)
                })
            },
        }
    }
</script>
 
<style scoped>
/deep/.filter-container{
    padding-left: 0px !important;
}
    .analyseUnit_input{
        width:200px;
    }
    .input{
        width:300px;
    }
</style>