reporting.vue
7.03 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
<template>
<view class="fs-p30">
<tui-form ref="form" :showMessage="false">
<view class="fs-radius__sm">
<tui-input placeholder="请选择" label="养护街道" v-model="formData.streetName" disabled @click="pickerOpen(1)"></tui-input>
<tui-input placeholder="请选择" label="养护道路" v-model="formData.roadName" disabled @click="pickerOpen(2)"></tui-input>
<tui-input placeholder="请选择" label="养护组长" v-model="formData.leaderUserName" disabled @click="pickerOpen(3)"></tui-input>
<tui-input placeholder="请选择" label="具体位置" v-model="formData.lonLatAddress" disabled @click="openMap()"></tui-input>
<tui-input placeholder="请选择" label="问题来源" v-model="formData.problemSourceName" disabled @click="pickerOpen(4)"></tui-input>
<tui-form-item label="紧急程度" :bottomBorder="false">
<tui-radio-group v-model="formData.pressingType">
<view class="fs-flex">
<tui-label margin="0 0 0 30rpx" v-for="(item,index) in pressingTypeList">
<tui-radio :checked="item.checked" :value="item.value"></tui-radio>
<text class="fs-ml16">{{item.name}}</text>
</tui-label>
</view>
</tui-radio-group>
</tui-form-item>
</view>
<tui-white-space></tui-white-space>
<tui-textarea :radius="20" placeholder="请输入问题描述" isCounter :size="28" :maxlength="100" v-model="formData.remark"></tui-textarea>
<tui-white-space></tui-white-space>
<tui-tab :tabs="tabList" scroll bold :leftGap="30" @change="tabChange"></tui-tab>
<tui-white-space></tui-white-space>
<tui-upload v-show="currentIndex == 0" background="#fff" :width="210" :radius="10" :height="210" delColor="#333" custom :serverUrl="serverURL" :header="{'Authorization': userToken}" :limit="3" @complete="complete($event, 'imgs')">
<text class="fs-size__28 fs-color__subtitle fs-weight__400">问题图片</text>
</tui-upload>
<tui-upload v-show="currentIndex == 1" background="#fff" :width="210" :radius="10" :height="210" delColor="#333" custom :serverUrl="serverURL" :header="{'Authorization': userToken}" :limit="3" @complete="complete($event, 'streetImgList')">
<text class="fs-size__28 fs-color__subtitle fs-weight__400">街景图片</text>
</tui-upload>
<tui-upload v-show="currentIndex == 2" background="#fff" :width="210" :radius="10" :height="210" delColor="#333" custom :serverUrl="serverURL" :header="{'Authorization': userToken}" :limit="3" @complete="complete($event, 'longRangeImgList')">
<text class="fs-size__28 fs-color__subtitle fs-weight__400">远景图片</text>
</tui-upload>
</tui-form>
<view class="fs-mt60 fs-flex__center fs-safe__area">
<tui-button shape="circle" width="600rpx" height="80rpx" shadow :loading="isLoading" :disabled="isLoading" @click="onSubmit">提 交</tui-button>
</view>
<tui-picker :show="pickerShow" radius :pickerData="pickerList[pickerType]" textField="name" valueField="id" @hide="pickerHide" @change="pickerChange"></tui-picker>
</view>
</template>
<script>
import { uploadURL } from '@/config/app'
import { apiCaseAdd, apiStreetList, apiRoadListByStreetId, apiLeaderList } from '@/api/work'
import { apiTypeList } from '@/api/app'
const rules = [
{
name: "streetName",
rule: ["required"],
msg: ["请选择养护街道"]
},
{
name: "roadName",
rule: ["required"],
msg: ["请选择养护道路"]
},
{
name: "leaderUserName",
rule: ["required"],
msg: ["请选择养护组长"]
},
{
name: "problemSourceName",
rule: ["required"],
msg: ["请选择问题来源"]
},
{
name: "lonLatAddress",
rule: ["required"],
msg: ["请选择具体位置"]
},
{
name: "remark",
rule: ["required"],
msg: ["请输入问题描述"]
}
]
export default {
data() {
return {
formData: {
streetId: 0,
streetName: '',
roadId: 0,
roadName: '',
leaderUserId: 0,
leaderUserName: '',
remark: '',
imgs: [],
pressingType: 3,
streetImgList: [],
longRangeImgList: [],
latLonType: 1,
lat: 0,
lon: 0,
lonLatAddress: '',
problemSourceId: 0,
problemSourceName: ''
},
pickerList: [],
isLoading: false,
pickerShow: false,
pickerType: 0,
pressingTypeList: [
{value:1, name:'特急'},
{value:2, name:'紧急'},
{value:3, name:'一般', checked:true}
],
serverURL: uploadURL,
currentIndex: 0,
tabList: ['问题图片', '街景图片', '远景图片'],
}
},
onLoad() {
this.getStreetList()
this.getLeaderList()
this.getTypeList()
},
methods: {
// 获取街道列表
getStreetList() {
apiStreetList().then(res => {
this.pickerList[1] = res.data
})
},
// 获取道路列表
getRoadList(streetId) {
apiRoadListByStreetId({data:{stree_id:streetId}}).then(res => {
this.formData.roadId = ''
this.formData.roadName = ''
this.pickerList[2] = res.data
})
},
// 获取组长列表
getLeaderList() {
apiLeaderList().then(res => {
res.data.forEach(item => {item.id = item.userId})
this.pickerList[3] = res.data
})
},
// 获取问题来源列表
getTypeList() {
apiTypeList({data:{dict_type: 'problem_source'}}).then(res => {
res.data.forEach(item => {
item.id = item.value
item.name = item.label
})
this.pickerList[4] = res.data
})
},
// 打开选择框
pickerOpen(type) {
this.pickerShow = true
this.pickerType = type
},
// 关闭选择框
pickerHide() {
this.pickerShow = false
},
// 选择选择框
pickerChange(event) {
switch (this.pickerType) {
case 1:
this.formData.streetId = event.id
this.formData.streetName = event.name
this.formData.roadId = 0
this.formData.roadName = ''
// 查询道路列表
this.getRoadList(event.id)
break
case 2:
this.formData.roadId = event.id
this.formData.roadName = event.name
break
case 3:
this.formData.leaderUserId = event.id
this.formData.leaderUserName = event.name
break
case 4:
this.formData.problemSourceId = event.id
this.formData.problemSourceName = event.name
break
}
},
// 上传完成
complete(e, type) {
if (e.status == 1) this.formData[type] = e.imgArr
},
// 提交
onSubmit() {
this.$refs.form.validate(this.formData, rules).then(res => {
if (!res.isPass) {
uni.$tui.toast(res.errorMsg)
return
}
if (!this.formData.imgs.length || !this.formData.streetImgList.length || !this.formData.longRangeImgList.length) {
uni.$tui.toast('请上传图片')
return
}
this.isLoading = true
apiCaseAdd({data:{...this.formData}}).then(res => {
uni.$tui.toast('提交成功')
setTimeout(() => { uni.navigateBack() }, 1500)
}).finally(() => {
this.isLoading = false
})
})
},
// 选择位置
openMap() {
var that = this
uni.chooseLocation({
success: function (res) {
that.formData.lat = res.latitude
that.formData.lon = res.longitude
that.formData.lonLatAddress = res.address
}
})
},
// 选项卡
tabChange(event) {
this.currentIndex = event.index
},
}
}
</script>
<style lang="scss" scoped>
</style>