lyfO_o
2022-03-24 c251626c67a55dfa8305fd49a47a0a2aa00fc32f
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
<template>
    <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-form-item label="隐患级别:">
                <el-select v-model="dataForm.level"  placeholder="请选择" :disabled="isView">
                    <el-option
                        v-for="item in levels"
                        :key="item.key"
                        :label="item.value"
                        :value="item.key">
                    </el-option>
                </el-select>
            </el-form-item>
 
            <el-form-item label="整改措施:" >
                <el-input
                    style="width: 400px"
                    type="textarea"
                    :rows="3"
                    :disabled="isView"
                    placeholder="请输入内容"
                    v-model="dataForm.rectifymeasure">
                </el-input>
            </el-form-item>
 
            <el-form-item label="整改期限:" >
                <el-date-picker
                    v-model="dataForm.rectifydeadline"
                    type="datetime"
                    :disabled="isView"
                    format="yyyy-MM-dd HH:mm"
                    value-format="yyyy-MM-dd HH:mm"
                    placeholder="选择日期时间">
                </el-date-picker>
            </el-form-item>
 
            <el-form-item label="上报说明:" >
                <el-input
                    style="width: 400px"
                    type="textarea"
                    :rows="3"
                    :disabled="isView"
                    placeholder="请输入内容"
                    v-model="dataForm.createnote">
                </el-input>
            </el-form-item>
 
            <el-form-item label="上报图片:" v-if="!isView">
                <el-upload
                    ref="upload"
                    :action="baseUrl"
                    :auto-upload="false"
                    :headers="headers"
                    :on-change="handleChange"
                    name="file"
                    :file-list="fileList"
                    list-type="picture-card"
                    multiple
                >
                    <i class="el-icon-plus"></i>
                </el-upload>
 
            </el-form-item>
 
            <el-form-item label="上报图片:" v-if="isView && imgUrls.length > 0" >
                <el-image
                    class="upload-img"
                    v-for='item in imgUrls'
                    :key='item.id'
                    :src="item.url"
                    :preview-src-list="imgPreviewUrls"
                    style="width:100px;height: 100px;margin: 10px 10px 10px 2px;border-radius: 3px"
                >
                </el-image>
            </el-form-item>
 
            <el-form-item label="驳回整改说明:"  v-if="dataForm.status === '驳回待整改'">
                <el-input
                    style="width: 400px"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入内容"
                    :disabled="isView"
                    v-model="dataForm.rectifynote">
                </el-input>
            </el-form-item>
 
            <el-form-item label="驳回整改图片:"  v-if="dataForm.status === '驳回待整改'">
                <el-image
                    class="upload-img"
                    v-for='item in imgUrls2'
                    :key='item.id'
                    :src="item.url"
                    :disabled="isView"
                    :preview-src-list="imgPreviewUrls2"
                    style="width:100px;height: 100px;margin: 10px 15px 10px 2px;border-radius: 3px"
                >
                </el-image>
            </el-form-item>
 
            <el-form-item label="驳回原因:"  v-if="dataForm.status === '驳回待整改'">
                <el-input
                    style="width: 400px"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入内容"
                    :disabled="isView"
                    v-model="dataForm.rejectnote">
                </el-input>
            </el-form-item>
 
 
 
            <el-form-item label="整改说明:"  >
                <el-input
                    style="width: 400px"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入内容"
                    v-model="dataForm.note">
                </el-input>
            </el-form-item>
 
            <el-form-item label="整改图片:" >
                <el-upload
                    ref="upload"
                    :action="baseUrl"
                    :auto-upload="false"
                    :headers="headers"
                    :on-change="handleChange"
                    name="file"
                    :file-list="fileList"
                    list-type="picture-card"
                    multiple
                >
                    <i class="el-icon-plus"></i>
                </el-upload>
 
            </el-form-item>
 
        </el-form>
 
        <div style="margin-top: 20px;margin-left: 140px;"  class="dialog-footer" >
            <el-button @click="dialogFormVisible = false">取消</el-button>
            <el-button type="primary" @click="trigger2Submit()" :disabled="submiting">整改提交</el-button>
        </div>
 
    </el-dialog>
</template>
 
<script>
    import { hiddenDangerRectify } from '@/api/hiddenDanger';
    import { getToken} from "@/utils/auth";
 
    export default {
        name: "rectifyDialog",
        data(){
            return {
                dialogFormVisible:false,
                baseUrl: process.env.BASE_API + 'hiddenDanger/report',
                headers: {
                    'Authorization': getToken()
                },
                imgUrls:[],
                imgUrls2:[],
                imgPreviewUrls:[],
                imgPreviewUrls2:[],
                fileList:[],
                isView:false,
                submiting:false,
                dataFormRules:{},
                levels:[
                    {"key":"URGENT","value":"紧急"},
                    {"key":"COMMON","value":"一般"},
                ],
                dataForm: {
                    id:'',
                    note: '',
                    level:'',
                    rectifynote:'',
                    rectifydeadline:'',
                    rectifymeasure:'',
                    createnote: '',
                    rejectnote:'',
                },
            }
        },
        methods:{
            resetDataForm(){
               this.dataForm= {
                   id:'',
                   createnote: '',
                   note:'',
                   level:'',
                   rectifynote:'',
                   rectifydeadline:'',
                   rectifymeasure:'',
                   rejectnote:'',
                },
                 this.imgUrls =[]
                 this.imgPreviewUrls = []
            },
            show(row){
                this.resetDataForm();
                this.isView = true
                this.dataForm.id = row.id
                this.dataForm.level = row.level
                this.dataForm.status = row.status
                this.dataForm.createnote = row.createnote
                this.dataForm.rectifydeadline = row.rectifydeadline
                this.dataForm.rectifymeasure = row.rectifymeasure
                this.dataForm.rectifynote = row.rectifynote
                this.dataForm. rejectnote = row.rejectnote
                this.imgUrls = row.reportResources.map(item=>{return {url:process.env.IMG_API+item.url,name:item.id}})
                this.imgUrls2 = row.rectifyResources.map(item=>{return {url:process.env.IMG_API+item.url,name:item.id}})
                this.imgPreviewUrls = row.reportResources.map(item=>{ return process.env.IMG_API + item.url })
                this.imgPreviewUrls2 = row.rectifyResources.map(item=>{ return process.env.IMG_API + item.url })
                this.dialogFormVisible = true
            },
            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
                    })
            },
            handleChange(file, fileList) {
                this.fileList = fileList
            },
        }
    }
</script>
 
<style scoped>
 
</style>