repairReport.vue
7.84 KB
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
<template>
<view class="container">
<!-- <Navbar title="维修/报修" canBack></Navbar> -->
<u-navbar title="维修/报修" autoBack :safeAreaInsetTop="true" placeholder>
<view slot="right" @click="goToRepairPage">
我的报修
</view>
</u-navbar>
<view class="repairTypeCardCss">
<view class="text-lg margin-top">
报修类型 <text class="text-gray">(必填)</text>
</view>
<view class="flex">
<u-tag :text="item.name" v-for="(item,index) of repairList" :key="index" @click="tagCurrent = item.name"
class="margin-top-sm margin-right-sm" size="large" shape="circle"
:bgColor="tagCurrent==item.name?'#fdeee6':'#F4F4F4'"
:color="tagCurrent==item.name?'#ea5504':'#8B9197'" borderColor="#fff"></u-tag>
</view>
<view class="selectCss margin-top">
<uni-data-select placeholder="请选择问题小类" clear v-model="value" :localdata="range"
@change="change"></uni-data-select>
</view>
<view class="text-gray text-xs margin-top margin-bottom">
安全问题反馈后24小时受理,其他问题上午6:00~晚上22:00受理
</view>
</view>
<view class="problemDescriptionCardCss usuallyCard">
<view class="text-lg margin-top">
问题描述 <text class="text-gray">(必填)</text>
</view>
<view class="descCss margin-top">
<u--textarea v-model="model.desc" count maxlength="200" height="100"
placeholder="请按照一事一报原则上报问题,将问题情况和具体位置描述准确,更有利于解决。"></u--textarea>
</view>
<view class="uploadCss margin-top">
<view class="flex justify-start align-end">
<view class="">
<u-upload :fileList="fileList" uploadIcon="plus" @afterRead="afterRead" @delete="deletePic"
multiple :maxCount="5" :maxSize="maxSize * 1024 * 1024" @oversize="overSize"></u-upload>
</view>
<view class="margin-left-sm text-gray text-lg">
{{ fileList.length }}/5
</view>
</view>
</view>
</view>
<addAddress ref="addAds" :mode="'add'" :showMrDz="false" :formData="formData" @setInput="getAds"></addAddress>
<view class="submitBtnCss" @click="handleSubmit">
<u-button color="#EA5504">确认并提交</u-button>
</view>
</view>
</template>
<script>
import addAddress from '@/components/addAddress/addAddress.vue'
import {
mapState
} from 'vuex'
export default {
components: {
addAddress
},
computed: {
...mapState(["user"]),
},
props: {
},
data() {
return {
tagCurrent: '',
repairList: [{
name: '燃气泄漏'
},
{
name: '管道破裂'
},
{
name: '其他'
}
],
value: null,
fileList: [],
formData: {},
range: [{
value: "灶具、热水器故障",
text: "灶具、热水器故障"
},
{
value: "表接头漏气",
text: "表接头漏气"
},
{
value: "表后阀漏气",
text: "表后阀漏气"
},
{
value: "表后管接头漏气",
text: "表后管接头漏气"
},
{
value: "户外立管活接漏气",
text: "户外立管活接漏气"
},
{
value: "外挂表后阀漏气",
text: "外挂表后阀漏气"
},
],
model: {
desc: "",
name: '',
phone: '',
area: "",
stree: ""
},
actions: [{
name: '男',
},
{
name: '女',
},
{
name: '保密',
},
],
rules: {
'userInfo.name': {
type: 'string',
required: true,
message: '请填写姓名',
trigger: ['blur', 'change']
},
'userInfo.sex': {
type: 'string',
max: 1,
required: true,
message: '请选择男或女',
trigger: ['blur', 'change']
},
},
maxSize:10,
}
},
onLoad() {
this.formData = {
fLxr: this.user.fullname,
fLxrdh: this.user.account,
}
console.log('打印this.user', this.user, this.$store);
},
methods: {
change(e) {
console.log(e);
},
// 右上角快捷跳转报修工单
goToRepairPage(){
uni.navigateTo({
url:'/pages/mine/appList/repairWorkOrder/repairWorkOrder'
})
},
handleSubmit() {
if (!this.tagCurrent) {
uni.$u.toast('请选择报修类型');
return
}
if (!this.model.desc) {
if (this.fileList.length <= 0) {
uni.$u.toast('请输入问题描述');
return
}
}
let that = this;
// this.$modal.showLoading('获取当前定位中');
this.$refs.addAds.$refs.uForm.validate().then(async res => {
let photoList = this.fileList.map(item => JSON.parse(item.fileObj));
let wttp = JSON.stringify(photoList);
console.log('打印this.formData====', this.formData, this.user, photoList);
let hyID = this.user.hyId;
let params = {
bxlx: this.tagCurrent,
wtms: this.model.desc,
wttp: wttp,
xdxm: this.formData.fLxr,
hyyhid: hyID,
lxfs: this.formData.fLxrdh,
lxdzsf: this.formData.fLxrsf,
lxdzs: this.formData.fLxrs,
lxdzq: this.formData.fLxrq,
lxdzjd: this.formData.fLxrjd,
lxdzxxdz: this.formData.fLxrxxdz,
bxlxmx: this.value,
jd: this.formData.fJd,
wd: this.formData.fWd,
}
const result = await that.$api.repairOrderApi.createRepairOrder(params);
console.log("添加返回", result);
let {
code,
value,
message
} = result;
if (code === 200) {
console.log("添加成功", result);
uni.$u.toast(message);
setTimeout(() => {
uni.redirectTo({
url: '/pages/home/repairReportSuccess'
})
// if (that.qpid) {
// console.log("首次添加地址");
// uni.redirectTo({
// url: '/pages/home/repairReportSuccess'
// })
// } else {
// that.$goBack();
// }
}, 500)
}
}).catch(errors => {
// uni.$u.toast('校验失败')
})
},
// 组件传参
getAds(ads) {
const {
area,
...formData
} = ads;
this.formData = formData;
// console.log('获取地址', JSON.parse(JSON.stringify(this.formData)));
},
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
// 图片大小超出最大允许大小
overSize(e) {
uni.$u.toast(`上传图片大小不能超过${this.maxSize}MB!`)
},
// 新增图片
async afterRead(event) {
console.log('打印event', event);
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
// 上传案例,根据这个来修改
let file = event.file;
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: 'uploading',
message: '上传中'
})
});
for (let i = 0; i < lists.length; i++) {
const result = await this.$api.fileApi.uploadFile(file[i].url);
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: file[i].url,
fileObj: JSON.stringify(result)
}))
fileListLen++
}
},
}
}
</script>
<style lang="scss" scoped>
.container {
padding-bottom: 60px;
}
.repairTypeCardCss {
background: #fff;
border-radius: 15px;
margin: 10px;
padding: 10px 20px;
}
.problemDescriptionCardCss {
margin: 10px;
padding: 10px 20px;
}
.descCss .u-textarea {
background: #F8F9FD;
border-radius: 15px;
}
/deep/.selectCss .uni-select {
background: #F8F9FD;
height: 45px;
border-radius: 10px;
}
/deep/.uploadCss .u-upload__button {
background: #fff;
border: 2px dashed #f4f5f7;
margin: 0;
}
.submitBtnCss {
position: fixed;
background: #fff;
left: 0;
right: 0;
padding: 10px;
width: 100%;
bottom: 0px;
}
/deep/ .submitBtnCss .u-button {
border-radius: 10px;
}
</style>