zhanghua
2024-03-31 2abaf1a68cc38303724d7aa74d2d3ed81af6466f
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
<template>
    <div class="arrive">
        <div class="arrive-title">到达现场情况</div>
        <div class="arrive-form">
            <el-form
                ref="arriveForm"
                label-width="160px"
                :model="arrive"
                :rules="arriveRules"
                autoComplete="on"
            >
                <!-- 到达时间 -->
                <el-form-item label="到达时间:" prop="arrivalTime">
                    <el-date-picker
                        v-model="arrive.arrivalTime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        type="datetime"
                        placeholder="选择到达时间"
                    >
                    </el-date-picker>
                </el-form-item>
                <!-- 到达地址 -->
                <el-form-item label="到达地址:" prop="arrivalAddress">
                    <el-input
                        v-model="arrive.arrivalAddress"
                        placeholder="请输入地址"
                    ></el-input>
                </el-form-item>
                <!-- 现场情况说明 -->
                <el-form-item label="现场情况说明:" prop="situationExplain">
                    <el-input
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 4 }"
                        maxlength="200"
                        show-word-limit
                        v-model="arrive.situationExplain"
                        placeholder="请输入情况说明,限制200字以内"
                    ></el-input>
                </el-form-item>
                <!-- 信访回复说明 -->
                <el-form-item label="信访回复说明:" prop="replyExplain">
                    <el-input
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 4 }"
                        maxlength="200"
                        show-word-limit
                        v-model="arrive.replyExplain"
                        placeholder="请输入回访说明,限制200字以内"
                    ></el-input>
                </el-form-item>
                <!-- 现场情况照片 -->
                <el-form-item label="现场情况照片:" prop="situationPic">
                    <div class="upImg">
                        <MyUpload
                            :picture-list="arrive.situationPic"
                            @setPictureUrl="setPicUrl"
                            @delPictureUrl="delPicUrl"
                        ></MyUpload>
                        <div class="tip">
                            {{ arrive.situationPic.length }} / 4
                        </div>
                    </div>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>
<script>
import MyUpload from "@/components/myUpload"
import { deepClone } from "@/utils/helper";
import { FILE_ORIGINAL_PATH } from "@/utils";
export default {
    components: {
        MyUpload
    },
    props: {
        arriveData: {
            type: Object,
            default: () => null
        }
    },
    data() {
        const checkTime = (rule, value, callback) => {
            if (value) {
                callback()
            } else {
                callback(new Error('到达时间不能为空'));
            }
        }
        const checkAddress = (rule, value, callback) => {
            if (value) {
                callback()
            } else {
                callback(new Error('到达地址不能为空'));
            }
        }
        const checkSit = (rule, value, callback) => {
            if (value) {
                callback()
            } else {
                callback(new Error('现场情况说明不能为空'));
            }
        }
        const checkSitPic = (rule, value, callback) => {
            if (value.length !== 0) {
                callback()
            } else {
                callback(new Error('请上传现场情况照片'));
            }
        }
        return {
            arrive: {
                situationPic: [],
            },
            arriveRules: {
                arrivalTime: [
                    { trigger: 'blur', validator: checkTime }
                ],
                arrivalAddress: [
                    { trigger: 'blur', validator: checkAddress }
                ],
                situationExplain: [
                    { trigger: 'blur', validator: checkSit }
                ],
                situationPic: [
                    { trigger: 'blur', validator: checkSitPic }
                ],
            },
            fileList: [],
        }
    },
    created() {
        if (this.arriveData) {
            this.arrive = deepClone(this.arriveData);
            this.arrive.situationPic = this.arriveData.situationPic.split(',');
        }
    },
    methods: {
        handleSuccess(res, file, filelist) {
            const baseUrl = '';
            if (this.arrive.situationPic.length < 4) {
                this.arrive.situationPic.push(baseUrl + res.data.url1)
            }
        },
        getToken() {
            const token = sessionStorage.getItem('token');
            const tokenHead = sessionStorage.getItem('tokenHead');
            if (token && tokenHead) {
                return { Authorization: tokenHead + token }
            }
        },
        // 获取arrive对象
        backData() {
            const { arrive } = this;
            this.$emit('getArrive', { arrive });
        },
        // 删除图片
        handleRemove(index) {
            this.arrive.situationPic.splice(index, 1);
        },
        // 设置上传成功之后的图片地址
        setPicUrl({ url }) {
            const baseUrl = '';
            if (this.arrive.situationPic.length < 4) {
 
                this.arrive.situationPic.push(FILE_ORIGINAL_PATH + url)
            }
        },
        //删除图片
        delPicUrl({ url }) {
            const baseUrl = '';
            this.arrive.situationPic.splice(this.arrive.situationPic.indexOf(baseUrl + url), 1);
        }
    }
}
</script>
<style lang="scss" scoped>
.arrive-title {
    line-height: 60px;
    font-weight: 650;
    font-size: 20px;
    width: 160px;
    padding-right: 12px;
    text-align: right;
    color: #4b9bb7;
}
 
.upImg {
    display: flex;
    overflow: auto;
    .tip {
        position: absolute;
        bottom: 0;
        right: 0;
    }
 
    .img-list {
        height: 60px;
        position: relative;
        display: flex;
 
        img {
            width: 60px;
            height: 60px;
            margin-right: 10px;
        }
 
        .img {
            height: 60px;
            position: relative;
        }
 
        .myicon {
            position: absolute;
            top: 0px;
            right: 0px;
            color: #4b9bb7;
        }
    }
}
 
.upload {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background-color: #fbfdff;
    border-radius: 4px;
}
 
// ::v-deep .el-textarea__inner {
//     // background-color: #09152f;
//     border: 1px solid #17324c;
// }
 
// ::v-deep .el-input__count {
//     // background-color: #09152f;
// }
 
// ::v-deep .el-form-item__label {
//     color: #4b9bb7;
// }
</style>