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
<template>
    <el-dialog title="验收" :visible.sync="isShowCheckDialog" width="600px">
        <el-form :model="checkForm" :rules="checkFormRules" ref="checkFormRef" 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="checkAcceptDesc">
                        <el-input class="input-add" type="textarea" :rows="2" v-model.trim="checkForm.checkAcceptDesc" 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="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="isShowCheckDialog = !isShowCheckDialog" size="default">取 消</el-button>
                    <el-button type="primary" @click="submitCheck" size="default">确 定</el-button>
        </div>
    </el-dialog>
</template>
 
 
<script>
    import { hiddenDangerAccept,hiddenDangerReject} from '@/api/hiddenDanger';
    import { getToken} from "@/utils/auth";
    import {checkHiddenDangerReport, submitHiddenDangerReport} from "../../../../../../api/hiddenDanger";
    import Cookies from "_js-cookie@2.2.0@js-cookie";
 
    export default {
        name: "acceptDialog",
        data(){
            return {
                disabled:false,
                fileRoad:process.env.BASE_API + '/task/web/upload',
                uploadForm:{
                },
                header:{Authorization:''},
                imgUrls:[],
                imgUrls2:[],
                fileList:[],
                imgPreviewUrls:[],
                imgPreviewUrls2:[],
                isView:false,
                isReject:false,
                submiting:false,
                levels:[
                    {"key":"URGENT","value":"重大隐患"},
                    {"key":"COMMON","value":"一般隐患"},
                ],
                dataForm: {
                    id:'',
                    note: '',
                    level:'',
                    rejectnote:'',
                },
                dialogFormVisible: false,
                dialogStatus:'',
                dataFormRules: {},
                checkTypeList: [],
                rectifyTypeList: [
                    { id: 1, name: '即查即改' },
                    { id: 2, name: '限期整改' }
                ],
                departmentList: [],
                userList: [],
                isShowCheckDialog: false,
                isShowCheckInfoDialog: false,
                checkForm: {
                    id: null,
                    dangerManagerId: null,
                    checkAcceptDesc: null
                },
                checkInfoForm: {
                    rectifyDepId: null,
                    liablePersonId: null,
                    acceptImages:[]
                },
                checkFormRules: {
                    checkAcceptDesc: [{ required: true, message: '请填写整改说明', trigger: 'blur' }]
                }
            }
        },
        methods:{
            showDialog(row){
                this.isShowCheckDialog = true;
                const checkForm = JSON.parse(JSON.stringify(row));
                this.checkForm.id = checkForm.id;
                this.checkForm.dangerManagerId = checkForm.dangerManagerId;
            },
 
            submitCheck() {
                this.$refs['checkFormRef'].validate(async (valid) => {
                    if (valid) {
                        this.checkForm.acceptImages = this.fileList.map(item => {
                            return item.url.substring(process.env.IMG_API.length)
                        })
                        let res = await checkHiddenDangerReport(this.checkForm);
                        if (res.data.code === '200') {
                            this.$message({
                                type: 'success',
                                message: '验收成功',
                                duration: 2000
                            });
                            this.isShowCheckDialog = false;
                            this.$emit('refreshCheck');
                        } else {
                            this.$message({
                                type: 'warning',
                                message: res.data.message
                            });
                        }
                    } else {
                        this.$message({
                            type: 'warning',
                            message: '请完善基本信息'
                        });
                    }
                });
            },
 
            rejectSubmit(){
                let params = {}
                params['id'] = this.dataForm.id
                params['rejectnote'] = this.dataForm.rectifynote
                this.submit(params,hiddenDangerReject)
            },
 
            submit(params,func){
                this.submiting = true
                func(params)
                    .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
                    })
            },
            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>
 
</style>