Your Name
2022-08-06 ca151ff4c1cdc4a029f13ac6da7d42e4f8147287
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
<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-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-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";
 
    export default {
        name: "rectifyDialog",
        data(){
            return {
                dialogFormVisible:false,
                baseUrl: process.env.BASE_API + 'hiddenDanger/report',
                headers: {
                    'Authorization': getToken()
                },
                userList:[],
                departmentList:[],
                rectifyTypeList: [
                    { id: 1, name: '即查即改' },
                    { id: 2, name: '限期整改' }
                ],
                imgPreviewUrls:[],
                imgPreviewUrls2:[],
                fileList:[],
                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
                },
                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
                }
 
            },
 
            submitRectify () {
                this.$refs['rectifyFormRef'].validate( async(valid) => {
                    if (valid) {
                        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'
                    })
                }
            },
 
            handleChange(file, fileList) {
                this.fileList = fileList
            },
        }
    }
</script>
 
<style scoped>
.basic_search{
    display:inline-block;
    padding-bottom: 10px;
}
.analyseUnit_input{
    width:90%;
}
.analyseUnit_box{
    width:200px;
}
</style>