whyczyk
2021-09-14 391214149f8edfc2ce9ff995cf37f06e962fd946
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
<template>
    <div class="alarm-handle">
        <van-nav-bar
            title="告警处理"
            @click-left="$router.back()"
            left-arrow
            fixed
            safe-area-inset-top
            placeholder
        >
        </van-nav-bar>
        <div class="handleCon">
            <div class="textareaCon">
                <van-field
                    v-model="alarmInfo.description"
                    rows="2"
                    autosize
                    label="告警描述"
                    type="textarea"
                    placeholder="请输入告警描述…"
                    show-word-limit
                />
                <v-upload
                    :value="alarmInfo.imageBefore"
                    @valChange="beforeUploadChange"
                    :stationId="stationId"
                    afterOrBefore="before"
                    class="upload"
                >
                </v-upload>
            </div>
            <div class="textareaCon">
                <van-field
                    v-model="alarmInfo.workWay"
                    rows="2"
                    autosize
                    label="处理方法"
                    type="textarea"
                    placeholder="请输入处理方法…"
                    show-word-limit
                />
                <v-upload
                    :value="alarmInfo.imageAfter"
                    @valChange="afterUploadChange"
                    :stationId="stationId"
                    afterOrBefore="after"
                    class="upload"
                >
                </v-upload>
            </div>
            <div class="textareaCon">
                <van-field
                    v-model="alarmInfo.workSuggest"
                    rows="2"
                    autosize
                    label="意见建议"
                    type="textarea"
                    placeholder="请输入意见建议…"
                    show-word-limit
                />
            </div>
            <div class="btnCon">
                <div class="subBtn" @click="submit(1)">保存</div>
                <div class="subBtn" @click="submit(2)">提交</div>
            </div>
        </div>
    </div>
</template>
 
<script>
import vUpload from "@/components/v-upload.vue"
import { updateUserWork, serchByCondition } from "@/assets/js/api"
export default {
    components: {
        vUpload,
    },
    data() {
        return {
            stationId: 0,
            alarmInfo: {
                description: "",
                checkStatus: 0,
                createTime: null,
                endTime: null,
                imageAfter: "",
                imageBefore: "",
                managerId: 0,
                note: "",
                userId: sessionStorage.getItem("userId"),
                workId: 0,
                workSuggest: "",
                workWay: "",
            },
        }
    },
    mounted() {
        this.alarmInfo.workId = this.$route.query.id
        this.alarmInfo.managerId = this.$route.query.managerId
        this.$nextTick(() => {
            this.stationId = Number(this.$route.query.stationId)
        })
        let type = this.$route.query.type
        if (type == "edit") {
            this.loadHandle()
        }
    },
    methods: {
        beforeUploadChange(list) {
            this.alarmInfo.imageBefore = list
        },
        afterUploadChange(list) {
            this.alarmInfo.imageAfter = list
        },
        //查询告警处理详情
        loadHandle() {
            let postData = {
                workId: this.alarmInfo.workId,
            }
            serchByCondition(postData)
                .then((res) => {
                    let resData = JSON.parse(res.data.result)
                    if (resData.code == 1) {
                        this.alarmInfo = resData.data[resData.data.length - 1]
                    }
                })
                .catch((err) => {
                    console.log(err)
                })
        },
        //保存提交
        submit(checkStatus) {
            this.alarmInfo.checkStatus = checkStatus
            let endTime = this.$units.timeFormat(
                new Date().getTime,
                "yyyy-mm-dd hh:MM:ss"
            )
            this.alarmInfo.endTime = endTime
            if (this.alarmInfo.description == "") {
                this.$toast("请输入告警描述…")
                return
            }
            if (this.alarmInfo.imageBefore == "") {
                this.$toast("请上传处理前照片…")
                return
            }
            if (this.alarmInfo.workWay == "") {
                this.$toast("请输入处理方法…")
                return
            }
            if (this.alarmInfo.imageAfter == "") {
                this.$toast("请上传处理后照片…")
                return
            }
            updateUserWork(this.alarmInfo)
                .then((res) => {
                    let resData = JSON.parse(res.data.result)
                    if (resData.code == 1) {
                        this.$toast(resData.msg)
                        this.$router.back()
                    }
                })
                .catch((err) => {
                    console.log(err)
                })
        },
    },
}
</script>
 
<style scoped>
.alarm-handle {
    width: 100%;
    min-height: 100%;
    background: #f5f5f5;
}
 
.handleCon {
    padding: 24px;
}
 
.handleTitle {
    font-size: 28px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
}
 
.textareaCon {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0px 4px 20px 0px rgba(75, 136, 249, 0.2);
    margin-bottom: 24px;
}
 
.textareaCon /deep/ .van-cell {
    padding: 20px 0;
}
 
.textareaCon /deep/ .van-cell::after {
    display: none;
}
 
.upload {
    margin-top: 16px;
}
 
.btnCon {
    width: 100%;
    display: flex;
    align-items: center;
}
 
.btnCon .subBtn {
    flex: 1;
    height: 98px;
    background: #07c160;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    font-size: 36px;
    margin-top: 48px;
    margin-right: 24px;
}
 
.btnCon .subBtn:last-of-type {
    margin-right: 0;
    background: #4b88f9;
}
</style>