Your Name
2022-08-25 6c6e0514283c7ff3016b845b600186b464e616c4
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
<template>
    <div>
        <el-dialog title="查看" :visible.sync="dialogFormVisible"
                   :modal-append-to-body="false" :close-on-click-modal="false" width="800px">
            <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="140px"
                     style="" element-loading-text="保存中...">
 
                <el-row :gutter="35">
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改内容说明" prop="rectifyDesc">
                            <el-input class="analyseUnit_input" type="textarea" :rows="2" v-model.trim="dataForm.rectifyDesc" readonly></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改类型" prop="rectifyType">
                            <el-select class="analyseUnit_input" v-model="dataForm.rectifyType" readonly>
                                <el-option v-for="item in rectifyTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改部门" prop="rectifyDepId">
                            <el-select v-model="dataForm.rectifyDepId" class="analyseUnit_input"  placeholder="请选择所属部门" clearable filterable>
                                <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-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改责任人" prop="liablePersonId">
                            <el-select class="analyseUnit_input" v-model="dataForm.liablePersonId" placeholder="请选择整改责任人" clearable filterable>
                                <el-option v-for="item in userList" :key="item.id" :label="item.realname" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
 
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改资金" prop="dangerResult">
                            <el-input class="analyseUnit_input" type="number" v-model="dataForm.cost" readonly> </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="隐患上报图" prop="img">
                            <el-image
                                class="upload-img img-wrapper"
                                v-for='item in fileOneList'
                                :key='item.$index'
                                :src="item"
                                :preview-src-list="fileOneList"
                            >
                            </el-image>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="隐患整改图" prop="img">
                            <el-image
                                class="upload-img img-wrapper"
                                v-for='item in fileTwoList'
                                :key='item.$index'
                                :src="item"
                                :preview-src-list="fileTwoList"
                            >
                            </el-image>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="隐患验收图" prop="img">
                            <el-image
                                class="upload-img img-wrapper"
                                v-for='item in fileThreeList'
                                :key='item.$index'
                                :src="item"
                                :preview-src-list="fileThreeList"
                            >
                            </el-image>
                        </el-form-item>
                    </el-col>
                </el-row>
 
            </el-form>
 
        </el-dialog>
        <el-dialog title="整改" :visible.sync="isShowRectifyDialog" :modal-append-to-body="false" :close-on-click-modal="false" width="600px">
            <el-form :model="rectifyForm" :rules="rectifyFormRules" ref="rectifyFormRef" size="default" label-width="120px">
                <el-row :gutter="35">
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改说明" prop="rectifyInfo">
                            <el-input class="analyseUnit_input" type="textarea" :rows="2" v-model.trim="rectifyForm.rectifyInfo" placeholder="请输入整改说明" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改时间" prop="applyTime">
                            <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" class="analyseUnit_input" v-model="rectifyForm.applyTime" placeholder="请选择整改时间" clearable> </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="隐患整改图" prop="img">
                            <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="dataForm.paths"
                                :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,file.$index)"
                                >
                                  <i class="el-icon-delete"></i>
                                </span>
                              </span>
                                </div>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div align="right" class="dialog-footer">
                    <el-button @click="isShowRectifyDialog = !isShowRectifyDialog" size="default">取 消</el-button>
                    <el-button type="primary" @click="submitRectify" size="default">确 定</el-button>
            </div>
        </el-dialog>
        <el-dialog title="延期" :visible.sync="isShowDelayDialog" width="600px">
            <el-form :model="delayForm" :rules="delayFormRules" ref="delayFormRef" size="default" label-width="120px">
                <el-row :gutter="35">
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="延期说明" prop="timeOutDesc">
                            <el-input class="analyseUnit_input" type="textarea" :rows="2" v-model.trim="delayForm.timeOutDesc" placeholder="请输入延期说明" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改期限" prop="rectifyTime">
                            <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" class="analyseUnit_input" v-model="delayForm.rectifyTime" placeholder="请选择整改期限" clearable> </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div align="right" class="dialog-footer">
                    <el-button @click="isShowDelayDialog = !isShowDelayDialog" size="default">取 消</el-button>
                    <el-button type="primary" @click="submitDelay" size="default">确 定</el-button>
            </div>
        </el-dialog>
    </div>
 
</template>
 
<script>
    import { hiddenDangerRectify } from '@/api/hiddenDanger';
    import { getToken} from "@/utils/auth";
    import {getDepartmentList} from "../../../../../../api/departmentManage";
    import {safetyInspectionItemName} from "../../../../../../api/safetySelfInspection";
    import {delayHiddenDangerReport, submitHiddenDangerReport} from "../../../../../../api/hiddenDanger";
    import Cookies from "_js-cookie@2.2.0@js-cookie";
 
    export default {
        name: "rectifyDialog",
        data(){
            return {
                disabled:false,
                dialogFormVisible:false,
                fileRoad:process.env.BASE_API + '/task/web/upload',
                uploadForm:{
                },
                header:{Authorization:''},
                userList:[],
                departmentList:[],
                rectifyTypeList: [
                    { id: 1, name: '即查即改' },
                    { id: 2, name: '限期整改' }
                ],
                imgPreviewUrls:[],
                imgPreviewUrls2:[],
                fileList:[],
                fileOneList:[],
                fileTwoList:[],
                fileThreeList:[],
                isView:false,
                submiting:false,
                dataFormRules:{},
                levels:[
                    {"key":"URGENT","value":"重大隐患"},
                    {"key":"COMMON","value":"一般隐患"},
                ],
                dataForm: {
                    rectifyType: null,
                    rectifyDepId: null,
                    liablePersonId: null,
                    rectifyTime: null,
                    cost: null,
                    rectifyDesc: null
                },
                isShowCheckInfoDialog: false,
                checkInfoForm: {
                    rectifyDepId: null,
                    liablePersonId: null
                },
                isShowDelayDialog: false,
                isShowRectifyDialog: false,
                rectifyForm: {
                    id: null,
                    dangerManagerId: null,
                    rectifyInfo: null,
                    applyTime: null,
                    rectifyImages:[]
                },
                delayForm: {
                    id: null,
                    dangerManagerId: null,
                    rectifyTime: null,
                    timeOutDesc: null
                },
                rectifyFormRules: {
                    rectifyInfo: [{ required: true, message: '请填写整改说明', trigger: 'blur' }],
                    applyTime: [{ required: true, message: '请选择整改时间', trigger: 'change' }]
                },
                delayFormRules: {
                    timeOutDesc: [{ required: true, message: '请填写延期说明', trigger: 'blur' }],
                    rectifyTime: [{ required: true, message: '请选择整改期限', trigger: 'change' }]
                }
            }
        },
        created(){
            this.getDepartmentData();
            this.getUser();
        },
        methods:{
            resetDataForm(){
               this.dataForm= {
                   id:'',
                   createnote: '',
                   note:'',
                   level:'',
                   rectifynote:'',
                   rectifydeadline:'',
                   rectifymeasure:'',
                   rejectnote:'',
                },
                 this.imgUrls =[]
                 this.imgPreviewUrls = []
            },
            showDialog(type,row){
                if (type === '延期') {
                    this.isShowDelayDialog = true;
                    const delayForm = JSON.parse(JSON.stringify(row));
                    this.delayForm.id = delayForm.id;
                    this.delayForm.dangerManagerId = delayForm.dangerManagerId;
                    this.delayForm.timeOutDesc = null;
                    this.delayForm.rectifyTime = null;
                }else if(type == '整改'){
                    this.isShowRectifyDialog = true;
                    const rectifyForm = JSON.parse(JSON.stringify(row));
                    this.rectifyForm.id = rectifyForm.id;
                    this.rectifyForm.dangerManagerId = rectifyForm.dangerManagerId;
                    this.rectifyForm.rectifyInfo = null;
                    this.rectifyForm.applyTime = null;
                }else{
                    this.dialogFormVisible = true
                    this.dataForm = row
                    debugger
                    this.fileOneList = row.reportImages.map(item => {
                        return  process.env.IMG_API + item
                    })
                    this.fileTwoList = row.rectifyImages.map(item => {
                        return  process.env.IMG_API + item
                    })
                    this.fileThreeList = row.acceptImages.map(item => {
                        return  process.env.IMG_API + item
                    })
                }
 
            },
 
            submitRectify () {
                this.$refs['rectifyFormRef'].validate( async(valid) => {
                    if (valid) {
                        this.rectifyForm.rectifyImages = this.fileList.map(item => {
                            return item.url.substring(process.env.IMG_API.length)
                        })
                        let res = await submitHiddenDangerReport(this.rectifyForm);
                        if (res.data.code === '200') {
                            this.$message({
                                type: 'success',
                                message: '整改提交成功',
                                duration: 2000
                            });
                            this.isShowRectifyDialog = false;
                            this.$emit('refreshRectify');
                        } else {
                            this.$message({
                                type: 'warning',
                                message: res.data.msg
                            });
                        }
                    } else {
                        this.$message({
                            type: 'warning',
                            message: '请完善基本信息'
                        });
                    }
                });
            },
 
            submitDelay() {
                this.$refs["delayFormRef"].validate(async (valid) => {
                    if (valid) {
                        let res = await delayHiddenDangerReport(this.delayForm);
                        if (res.data.code === '200') {
                            this.$message({
                                type: 'success',
                                message: '隐患延期成功',
                                duration: 2000
                            });
                            this.isShowDelayDialog = false;
                            this.$emit('refreshRectify');
                        } else {
                            this.$message({
                                type: 'warning',
                                message: res.data.msg
                            });
                        }
                    } else {
                        this.$message({
                            type: 'warning',
                            message: '请完善基本信息'
                        });
                    }
                });
            },
 
            trigger2Submit(){
                let formData = new FormData();
                formData.append('id',this.dataForm.id)
                formData.append('note',this.dataForm.note)
                this.fileList.forEach(file=>{
                    formData.append("files",file.raw)
                })
                this.submiting = true
                hiddenDangerRectify(formData)
                    .then(res=>{
                            if (res.data.code === '200') {
                                this.dialogFormVisible = false
                                this.$message({message: '操作成功', type: 'success'});
                                this.$emit("refresh")
                            }else{
                                this.$message({message: res.data.message, type: 'success'});
                            }
                            this.fileList = []
                    }
                )
                    .catch(err=>{
                        console.log(err)
                        this.$message({message: '接口错误', type: 'warning'});
                    })
                    .finally(()=>{
                        this.submiting = false
                    })
            },
 
            async getDepartmentData(){
                let res = await getDepartmentList({pageSize:1000,pageIndex:1})
                if(res.data.code === '200'){
                    this.departmentList = res.data.result.result
                }else{
                    this.$message({
                        message:res.data.message,
                        type:'warning'
                    })
                    if(res.data.code === '50001'){
                        this.riskSourceData = []
                    }
                }
            },
 
            async getUser(){
                let res = await safetyInspectionItemName()
                if(res.data.code === '200'){
                    this.userList = res.data.result
                }else{
                    this.$message({
                        message:res.data.message,
                        type:'warning'
                    })
                }
            },
 
            handleChangeFile(){
                this.header.Authorization = Cookies.get('token')
            },
            onFileSuccess(response){
                if(response.code === '200'){
                    this.fileList.push({url:process.env.IMG_API + response.result.path})
                    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;
            },
            showImg(file){
                window.open(file, '_blank')
            },
            handleRemove(file,value){
                return this.$confirm(`确定移除 ${ file.uid }?`,'提示',{
                    confirmButtonText:'确定',
                    cancelButtonText:'取消',
                    type:'warning',
                }).then(()=> {
                    this.fileList.splice(value,1)
                })
            },
        }
    }
</script>
 
<style scoped>
.basic_search{
    display:inline-block;
    padding-bottom: 10px;
}
.analyseUnit_input{
    width:90%;
}
.analyseUnit_box{
    width:200px;
}
 
.img-wrapper{
    width:100px;
    height: 100px;
    margin: 10px;
    border-radius: 2px
}
.img-wrapper:first-child{
    margin-left: unset !important;
}
 
</style>