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
474
475
476
477
478
479
480
481
482
483
484
485
<template>
    <el-dialog :title="title" :visible.sync="dialogFormVisible"  :close-on-click-modal="false" width="50%">
        <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="140px" style="" element-loading-text="保存中...">
            <el-row :gutter="25">
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
                    <el-form-item label="隐患描述" prop="dangerDesc">
                        <el-input class="analyseUnit_input" v-model.trim="dataForm.dangerDesc" placeholder="请输入隐患情况描述" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
                    <el-form-item label="隐患名称" prop="dangerCode">
                        <el-input class="analyseUnit_input" v-model.trim="dataForm.dangerCode" placeholder="请输入隐患名称" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
                    <el-form-item label="隐患所属部门" prop="depId">
                        <el-select v-model="dataForm.depId" class="analyseUnit_input" placeholder="请选择所属部门">
                            <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="12" class="mb20">
                    <el-form-item label="生产装置" prop="produceDeviceId">
                        <el-select class="analyseUnit_input" v-model="dataForm.produceDeviceId" placeholder="请输入生产装置" clearable filterable @change="changeUnit">
                            <el-option v-for="item in allProduceDeviceData" :key="item.id" :label="item.produceDeviceName" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
                    <el-form-item label="风险分析单元" prop="riskUnitId">
                        <el-select class="analyseUnit_input" v-model.trim="dataForm.riskUnitId" placeholder="请输入风险分析单元" clearable filterable>
                            <el-option v-for="item in safetyRiskUnitData" :key="item.id" :label="item.riskUnitName" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
                    <el-form-item label="隐患来源" prop="dangerSource">
                        <el-select class="analyseUnit_input" v-model="dataForm.dangerSource" placeholder="请选择隐患来源" clearable filterable>
                            <el-option v-for="item in dangerSourceList" :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="12" class="mb20">
                    <el-form-item label="隐患等级" prop="dangerLevel">
                        <el-select class="analyseUnit_input" v-model="dataForm.dangerLevel" placeholder="请选择隐患等级" clearable filterable>
                            <el-option v-for="item in dangerLevelList" :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="12" class="mb20">
                    <el-form-item label="隐患类型" prop="dangerType">
                        <el-select class="analyseUnit_input" v-model="dataForm.dangerType" placeholder="请选择隐患类型" clearable filterable>
                            <el-option v-for="item in dangerTypeList" :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="12" class="mb20">
                    <el-form-item label="隐患可能后果" prop="dangerResult">
                        <el-select class="analyseUnit_input" v-model="dataForm.dangerResult" placeholder="请选择隐患可能后果" clearable filterable>
                            <el-option v-for="item in dangerResultList" :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="12">
                    <el-form-item label="隐患产生原因" prop="dangerReason">
                        <el-input class="analyseUnit_input" type="textarea" :rows="2" style="padding-bottom: 10px" v-model.trim="dataForm.dangerReason" placeholder="请输入隐患产生原因"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
                    <el-form-item label="整改类型" prop="rectifyType">
                        <el-select class="analyseUnit_input" v-model="dataForm.rectifyType" placeholder="请选择整改类型" clearable filterable>
                            <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="12" 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="dataForm.rectifyTime" placeholder="请选择整改期限" clearable> </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
                    <el-form-item label="整改部门" prop="rectifyDepId">
                        <el-select v-model="dataForm.rectifyDepId" class="analyseUnit_input"  @change="changeExec" 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="12" 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 execUidList" :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="12" class="mb20">
                    <el-form-item label="整改资金" prop="cost">
                        <el-input class="analyseUnit_input" type="number" v-model="dataForm.cost" placeholder="请选择整改资金"> </el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
                    <el-form-item label="整改措施" prop="rectifyDesc">
                        <el-input class="analyseUnit_input" type="textarea" :rows="2" style="padding-bottom: 10px" v-model.trim="dataForm.rectifyDesc" placeholder="请输入整改措施"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                    <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" v-if="!isView">
            <el-button @click="dialogFormVisible = false">取消</el-button>
            <el-button type="primary" @click="trigger2Submit" :disabled="submiting">上报</el-button>
        </div>
        <person-select ref="selectPerson" @setPerson="selectSetValue" ></person-select>
    </el-dialog>
</template>
 
<script>
    import personSelect from './personSelect'
    import { hiddenDangerReport } from '@/api/hiddenDanger';
    import {getToken} from "@/utils/auth";
    import {modHiddenDangerReport} from "../../../../../../api/hiddenDanger";
    import Cookies from "_js-cookie@2.2.0@js-cookie";
    export default {
        name: "reportDialog",
        data(){
            return {
                disabled:false,
                title:'',
                fileRoad:process.env.BASE_API + '/task/web/upload',
                uploadForm:{
                },
                header:{Authorization:''},
                submiting:false,
                departmentList: [],
                userList: [],
                execUidList:[],
                allProduceDeviceData: [],
                allSafetyRiskUnitData: [],
                safetyRiskUnitData: [],
                dangerLevelList: [
                    { id: 1, name: '一般隐患' },
                    { id: 2, name: '重大隐患' }
                ],
                dangerSourceList: [
                    { id: 1, name: '日常排查' },
                    { id: 2, name: '综合性排查' },
                    { id: 3, name: '专业性排查' },
                    { id: 4, name: '季节性排查' },
                    { id: 5, name: '重点时段及节假日前排查' },
                    { id: 6, name: '事故类比排查' },
                    { id: 7, name: '复产复工前排查' },
                    { id: 8, name: '外聘专家诊断式排查' },
                    { id: 9, name: '管控措施失效' },
                    { id: 10, name: '其他' }
                ],
                dangerResultList: [
                    { id: 1, name: '无' },
                    { id: 2, name: '轻伤' },
                    { id: 3, name: '重伤' },
                    { id: 4, name: '死亡' }
                ],
                dangerTypeList: [
                    { id: 1, name: '安全' },
                    { id: 2, name: '工艺' },
                    { id: 3, name: '电气' },
                    { id: 4, name: '仪表' },
                    { id: 5, name: '消防' },
                    { id: 6, name: '总图' },
                    { id: 7, name: '设备' },
                    { id: 8, name: '其他' }
                ],
                rectifyTypeList: [
                    { id: 1, name: '即查即改' },
                    { id: 2, name: '限期整改' }
                ],
                pickerOptions:{
                    disabledDate(now){
                        return now.getTime() < new Date(new Date().toLocaleDateString()).getTime()
                    }
                },
                fileList: [],
                dataForm: {
                    dangerDesc: null,
                    dangerCode: null,
                    depId: null,
                    produceDeviceId: null,
                    riskUnitId: null,
                    dangerSource: null,
                    dangerLevel: null,
                    dangerType: null,
                    dangerReason: null,
                    dangerResult: null,
                    rectifyType: null,
                    rectifyDepId: null,
                    liablePersonId: null,
                    rectifyTime: null,
                    cost: null,
                    rectifyDesc: null,
                    reportImage:[]
                },
                dataFormRules:{
                    dangerDesc: [{ required: true, message: '请填写隐患情况描述', trigger: 'blur' }],
                    dangerCode: [{ required: true, message: '请填写隐患名称', trigger: 'blur' }],
                    depId: [{ required: true, message: '请选择隐患所属部门', trigger: 'change' }],
                    produceDeviceId: [{ required: true, message: '请选择生产装置', trigger: 'change' }],
                    riskUnitId: [{ required: true, message: '请选择风险分析单元', trigger: 'change' }],
                    dangerSource: [{ required: true, message: '请选择隐患来源', trigger: 'change' }],
                    dangerLevel: [{ required: true, message: '请选择隐患等级', trigger: 'change' }],
                    dangerType: [{ required: true, message: '请选择隐患类型', trigger: 'change' }],
                    dangerReason: [{ required: true, message: '请填写隐患产生原因分析', trigger: 'blur' }],
                    dangerResult: [{ required: true, message: '请选择隐患可能后果', trigger: 'change' }],
                    rectifyType: [{ required: true, message: '请选择整改类型', trigger: 'change' }],
                    rectifyDepId: [{ required: true, message: '请选择整改单位', trigger: 'change' }],
                    liablePersonId: [{ required: true, message: '请选择整改责任人', trigger: 'change' }],
                    rectifyTime: [{ required: true, message: '请选择整改期限', trigger: 'change' }],
                    cost: [{ required: true, message: '请选择整改资金', trigger: 'blur' }],
                    rectifyDesc: [{ required: true, message: '请填写整改内容', trigger: 'blur' }]
                },
                dialogFormVisible: false,
                isView:false,
            }
        },
        components:{
            personSelect,
        },
        methods:{
            resetDataForm(){
                this.dataForm = {
                    dangerDesc: null,
                    dangerCode: null,
                    depId: null,
                    produceDeviceId: null,
                    riskUnitId: null,
                    dangerSource: null,
                    dangerLevel: null,
                    dangerType: null,
                    dangerReason: null,
                    dangerResult: null,
                    rectifyType: null,
                    rectifyDepId: null,
                    liablePersonId: null,
                    rectifyTime: null,
                    cost: null,
                    rectifyDesc: null
                }
            },
            show(type, value, userList,departmentList, allProduceDeviceData, allSafetyRiskUnitData){
                this.title = type
                this.dialogFormVisible = true
                this.userList = JSON.parse(JSON.stringify(userList))
                this.departmentList = departmentList;
                this.allProduceDeviceData = JSON.parse(JSON.stringify(allProduceDeviceData));
                this.allSafetyRiskUnitData = allSafetyRiskUnitData;
                if(type === '新增'){
                    this.dataForm = {
                        dangerDesc: null,
                        dangerCode: null,
                        depId: null,
                        produceDeviceId: null,
                        riskUnitId: null,
                        dangerSource: null,
                        dangerLevel: null,
                        dangerType: null,
                        dangerReason: null,
                        dangerResult: null,
                        rectifyType: null,
                        rectifyDepId: null,
                        liablePersonId: null,
                        rectifyTime: null,
                        cost: null,
                        rectifyDesc: null,
                        reportImages:[]
                    }
                }else if(type === '修改'){
                    console.log(value)
                    for( let key in this.dataForm){
                        this.dataForm[key] = JSON.parse(JSON.stringify(value))[key]
                    }
                    this.dataForm.id = JSON.parse(JSON.stringify(value)).id
                    this.fileList = value.reportImages.map(item => {
                        return {
                            url : process.env.IMG_API + item
                        }
                    })
                }
 
            },
            trigger2Submit(){
                this.$refs["dataForm"].validate(valid =>{
                    if(valid){
                        this.dataForm.reportImages = this.fileList.map(item => {
                            return item.url.substring(process.env.IMG_API.length)
                        })
                        if(this.title === '新增'){
                            this.submiting = true
                            hiddenDangerReport(this.dataForm).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: 'warning'
                                    });
                                }
                            }).catch(err=>{
                                console.log(err)
                                this.$message({
                                    message: "接口错误,请联系管理员",
                                    type: 'warning'
                                });
                            }).finally(()=>{
                                this.submiting = false
                            })
                        }else{
                            this.submiting = true
                            modHiddenDangerReport(this.dataForm).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: 'warning'
                                    });
                                }
                            }).catch(err=>{
                                console.log(err)
                                this.$message({
                                    message: "接口错误,请联系管理员",
                                    type: 'warning'
                                });
                            }).finally(()=>{
                                this.submiting = false
                            })
                        }
 
                    }else{
                        this.$message({
                            type:'warning',
                            message:'请完善基本信息'
                        })
                    }
                })
            },
 
            changeUnit() {
                this.dataForm.riskUnitId = null;
                this.safetyRiskUnitData = this.allSafetyRiskUnitData.filter((item) => item.produceDeviceId === this.dataForm.produceDeviceId);
            },
 
            changeExec(){
                if(this.dataForm.rectifyDepId === '') {
                    this.execUidList = []
                }
                this.dataForm.liablePersonId = ''
                this.execUidList = this.userList.filter ( item => item.department === this.dataForm.rectifyDepId)
            },
 
            showPersonSelect(){
                this.$refs.selectPerson.show();
            },
            selectSetValue(row){
                this.dataForm.rectifier = row.realname
                this.dataForm.rectifierid = row.id
            },
 
 
            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;
}
    .el-picker-panel__footer .el-button--text.el-picker-panel__link-btn {
        display: none;
    }
</style>