6ec243d6
wuxw
v1.9 点击提交后,成功提示没有...
|
1
|
<template>
|
b5dad34f
wuxw
巡检功能测试中
|
2
3
|
<el-dialog :title="$t('addInspectionPoint.title')" :visible.sync="dialogVisible" width="60%" top="5vh"
@close="resetForm">
|
b8ac379c
wuxw
v1.9 优化缴费页面扫码缴费
|
4
|
<el-form ref="addForm" :model="addInspectionPointInfo" class="text-left" :rules="rules" label-width="120px" label-position="right">
|
48ea9c43
wuxw
巡检开发完成
|
5
6
7
|
<el-row :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('addInspectionPoint.inspectionName')" prop="inspectionName">
|
b5dad34f
wuxw
巡检功能测试中
|
8
9
|
<el-input v-model="addInspectionPointInfo.inspectionName"
:placeholder="$t('addInspectionPoint.placeholder.inspectionName')" clearable />
|
48ea9c43
wuxw
巡检开发完成
|
10
11
12
13
|
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('addInspectionPoint.pointObjType')" prop="pointObjType">
|
b5dad34f
wuxw
巡检功能测试中
|
14
15
16
17
18
|
<el-select v-model="addInspectionPointInfo.pointObjType"
:placeholder="$t('addInspectionPoint.placeholder.pointObjType')" style="width: 100%;"
@change="_pointObjTypeChange">
<el-option v-for="item in addInspectionPointInfo.pointObjTypes" :key="item.statusCd" :label="item.name"
:value="item.statusCd" />
|
48ea9c43
wuxw
巡检开发完成
|
19
20
21
22
23
24
25
26
|
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20" v-if="addInspectionPointInfo.pointObjType === '2002'">
<el-col :span="12">
<el-form-item :label="$t('addInspectionPoint.pointObjName')" prop="pointObjName">
|
b5dad34f
wuxw
巡检功能测试中
|
27
28
|
<el-input v-model="addInspectionPointInfo.pointObjName"
:placeholder="$t('addInspectionPoint.placeholder.pointObjName')" clearable />
|
48ea9c43
wuxw
巡检开发完成
|
29
30
31
32
33
|
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20" v-if="addInspectionPointInfo.pointObjType === '1001'">
|
b8ac379c
wuxw
v1.9 优化缴费页面扫码缴费
|
34
|
<el-col :span="12">
|
48ea9c43
wuxw
巡检开发完成
|
35
|
<el-form-item :label="$t('addInspectionPoint.machine')" prop="pointObjId">
|
b5dad34f
wuxw
巡检功能测试中
|
36
|
<machine-select2 ref="machineSelect" :parent-modal="true" @notify="handleMachineSelect" />
|
48ea9c43
wuxw
巡检开发完成
|
37
38
39
40
41
42
43
44
|
<div class="tip-text">{{ $t('addInspectionPoint.tip.addMachine') }}</div>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('addInspectionPoint.itemId')" prop="itemId">
|
b5dad34f
wuxw
巡检功能测试中
|
45
46
|
<el-select v-model="addInspectionPointInfo.itemId"
:placeholder="$t('addInspectionPoint.placeholder.itemId')" style="width: 100%;">
|
829c544e
wuxw
优化代码
|
47
|
<el-option v-for="(item, index) in addInspectionPointInfo.items" :key="index" :label="item.itemName"
|
b5dad34f
wuxw
巡检功能测试中
|
48
|
:value="item.itemId" />
|
48ea9c43
wuxw
巡检开发完成
|
49
50
51
52
53
|
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('addInspectionPoint.nfcCode')">
|
b5dad34f
wuxw
巡检功能测试中
|
54
55
|
<el-input v-model="addInspectionPointInfo.nfcCode"
:placeholder="$t('addInspectionPoint.placeholder.nfcCode')" clearable />
|
48ea9c43
wuxw
巡检开发完成
|
56
57
58
59
60
61
62
|
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('addInspectionPoint.lng')">
|
b5dad34f
wuxw
巡检功能测试中
|
63
|
<el-input v-model="addInspectionPointInfo.lng" :placeholder="$t('addInspectionPoint.placeholder.lng')"
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
64
|
/>
|
48ea9c43
wuxw
巡检开发完成
|
65
66
67
68
|
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('addInspectionPoint.lat')">
|
b5dad34f
wuxw
巡检功能测试中
|
69
|
<el-input v-model="addInspectionPointInfo.lat" :placeholder="$t('addInspectionPoint.placeholder.lat')"
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
70
|
/>
|
48ea9c43
wuxw
巡检开发完成
|
71
72
73
74
75
76
77
|
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item :label="$t('addInspectionPoint.remark')">
|
b5dad34f
wuxw
巡检功能测试中
|
78
79
|
<el-input v-model="addInspectionPointInfo.remark" type="textarea" :rows="3"
:placeholder="$t('addInspectionPoint.placeholder.remark')" />
|
48ea9c43
wuxw
巡检开发完成
|
80
81
82
83
84
85
|
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
|
b5dad34f
wuxw
巡检功能测试中
|
86
|
<select-map-pos ref="selectMapPos" @position-change="handlePositionChange" />
|
48ea9c43
wuxw
巡检开发完成
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="saveInspectionPointInfo">{{ $t('common.save') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { saveInspectionPoint } from '@/api/inspection/inspectionPointApi'
import { listInspectionItems } from '@/api/inspection/inspectionPointApi'
import { getDict } from '@/api/community/communityApi'
import { getCommunityId } from '@/api/community/communityApi'
import MachineSelect2 from '@/components/inspection/machineSelect2'
|
b5dad34f
wuxw
巡检功能测试中
|
104
105
|
import SelectMapPos from '@/components/inspection/selectMapPos'
|
48ea9c43
wuxw
巡检开发完成
|
106
107
108
109
|
export default {
name: 'AddInspectionPoint',
components: {
|
b5dad34f
wuxw
巡检功能测试中
|
110
111
|
MachineSelect2,
SelectMapPos
|
48ea9c43
wuxw
巡检开发完成
|
112
113
114
115
116
117
|
},
data() {
return {
dialogVisible: false,
addInspectionPointInfo: {
inspectionName: '',
|
b5dad34f
wuxw
巡检功能测试中
|
118
|
pointObjId: '-1',
|
48ea9c43
wuxw
巡检开发完成
|
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
|
pointObjType: '',
pointObjTypes: [],
pointObjName: '',
remark: '',
items: [],
itemId: '',
nfcCode: '',
lng: '',
lat: '',
communityId: ''
},
rules: {
inspectionName: [
{ required: true, message: this.$t('addInspectionPoint.rules.inspectionName'), trigger: 'blur' },
{ max: 100, message: this.$t('addInspectionPoint.rules.inspectionNameMax'), trigger: 'blur' }
],
pointObjType: [
{ required: true, message: this.$t('addInspectionPoint.rules.pointObjType'), trigger: 'change' }
],
pointObjName: [
{ required: true, message: this.$t('addInspectionPoint.rules.pointObjName'), trigger: 'blur' }
],
pointObjId: [
{ required: true, message: this.$t('addInspectionPoint.rules.pointObjId'), trigger: 'change' }
],
itemId: [
{ required: true, message: this.$t('addInspectionPoint.rules.itemId'), trigger: 'change' }
],
remark: [
{ max: 200, message: this.$t('addInspectionPoint.rules.remarkMax'), trigger: 'blur' }
]
},
map: null,
marker: null,
communityId: ''
}
},
methods: {
open() {
this.dialogVisible = true
this.resetForm()
|
b8ac379c
wuxw
v1.9 优化缴费页面扫码缴费
|
160
|
this.getDictData()
|
829c544e
wuxw
优化代码
|
161
|
this._listAddInspectionItems()
|
b8ac379c
wuxw
v1.9 优化缴费页面扫码缴费
|
162
|
|
48ea9c43
wuxw
巡检开发完成
|
163
164
|
this.$nextTick(() => {
this.initMap()
|
48ea9c43
wuxw
巡检开发完成
|
165
166
|
})
},
|
b5dad34f
wuxw
巡检功能测试中
|
167
|
|
48ea9c43
wuxw
巡检开发完成
|
168
169
170
171
|
async getDictData() {
try {
const data = await getDict('inspection_point', 'point_obj_type')
this.addInspectionPointInfo.pointObjTypes = data
|
b8ac379c
wuxw
v1.9 优化缴费页面扫码缴费
|
172
|
console.log(this.addInspectionPointInfo.pointObjTypes)
|
48ea9c43
wuxw
巡检开发完成
|
173
174
175
176
|
} catch (error) {
console.error('获取字典数据失败:', error)
}
},
|
b5dad34f
wuxw
巡检功能测试中
|
177
|
|
48ea9c43
wuxw
巡检开发完成
|
178
179
180
181
182
183
184
|
async _listAddInspectionItems() {
try {
const params = {
communityId: this.communityId,
page: 1,
row: 100
}
|
b5dad34f
wuxw
巡检功能测试中
|
185
|
|
48ea9c43
wuxw
巡检开发完成
|
186
187
188
189
190
191
|
const response = await listInspectionItems(params)
this.addInspectionPointInfo.items = response.data
} catch (error) {
console.error('获取巡检项目失败:', error)
}
},
|
b5dad34f
wuxw
巡检功能测试中
|
192
|
|
48ea9c43
wuxw
巡检开发完成
|
193
194
|
initMap() {
// 这里简化了地图初始化,实际项目中需要根据地图API实现
|
b5dad34f
wuxw
巡检功能测试中
|
195
196
197
|
setTimeout(() => {
this.$refs.selectMapPos.initMap({})
}, 1000)
|
48ea9c43
wuxw
巡检开发完成
|
198
|
},
|
b5dad34f
wuxw
巡检功能测试中
|
199
|
|
48ea9c43
wuxw
巡检开发完成
|
200
201
202
|
_pointObjTypeChange() {
this.addInspectionPointInfo.pointObjId = ''
this.addInspectionPointInfo.pointObjName = ''
|
b5dad34f
wuxw
巡检功能测试中
|
203
|
|
48ea9c43
wuxw
巡检开发完成
|
204
|
if (this.addInspectionPointInfo.pointObjType === '1001') {
|
b8ac379c
wuxw
v1.9 优化缴费页面扫码缴费
|
205
206
207
|
setTimeout(() => {
this.$refs.machineSelect.searchMachines()
}, 500)
|
48ea9c43
wuxw
巡检开发完成
|
208
209
|
}
},
|
b5dad34f
wuxw
巡检功能测试中
|
210
|
|
48ea9c43
wuxw
巡检开发完成
|
211
212
213
214
215
216
|
handleMachineSelect(data) {
if (data && data.machineId && data.machineName) {
this.addInspectionPointInfo.pointObjId = data.machineId
this.addInspectionPointInfo.pointObjName = data.machineName
}
},
|
b5dad34f
wuxw
巡检功能测试中
|
217
|
|
48ea9c43
wuxw
巡检开发完成
|
218
219
220
|
saveInspectionPointInfo() {
this.$refs.addForm.validate(async valid => {
if (!valid) return
|
b5dad34f
wuxw
巡检功能测试中
|
221
222
223
|
if (this.addInspectionPointInfo.pointObjType == '2002') {
this.addInspectionPointInfo.pointObjId = '-1'
}
|
48ea9c43
wuxw
巡检开发完成
|
224
225
226
227
228
|
// 特殊验证
if (this.addInspectionPointInfo.pointObjType === '1001' && !this.addInspectionPointInfo.pointObjId) {
this.$message.error(this.$t('addInspectionPoint.rules.machineRequired'))
return
}
|
b5dad34f
wuxw
巡检功能测试中
|
229
|
|
48ea9c43
wuxw
巡检开发完成
|
230
231
232
233
|
if (this.addInspectionPointInfo.pointObjType === '2002' && !this.addInspectionPointInfo.pointObjName) {
this.$message.error(this.$t('addInspectionPoint.rules.locationRequired'))
return
}
|
b5dad34f
wuxw
巡检功能测试中
|
234
|
|
48ea9c43
wuxw
巡检开发完成
|
235
236
|
try {
this.addInspectionPointInfo.communityId = this.communityId
|
b5dad34f
wuxw
巡检功能测试中
|
237
|
|
48ea9c43
wuxw
巡检开发完成
|
238
|
const response = await saveInspectionPoint(this.addInspectionPointInfo)
|
b5dad34f
wuxw
巡检功能测试中
|
239
|
|
48ea9c43
wuxw
巡检开发完成
|
240
|
if (response.code === 0) {
|
6ec243d6
wuxw
v1.9 点击提交后,成功提示没有...
|
241
|
this.$message.success(this.$t('common.operationSuccess'))
|
48ea9c43
wuxw
巡检开发完成
|
242
243
244
245
246
247
248
249
250
251
252
|
this.dialogVisible = false
this.$emit('success')
} else {
this.$message.error(response.msg || this.$t('addInspectionPoint.saveFailed'))
}
} catch (error) {
console.error('保存巡检点失败:', error)
this.$message.error(this.$t('addInspectionPoint.saveFailed'))
}
})
},
|
b5dad34f
wuxw
巡检功能测试中
|
253
|
|
48ea9c43
wuxw
巡检开发完成
|
254
255
256
|
resetForm() {
this.addInspectionPointInfo = {
inspectionName: '',
|
b5dad34f
wuxw
巡检功能测试中
|
257
|
pointObjId: '-1',
|
48ea9c43
wuxw
巡检开发完成
|
258
259
260
261
262
263
264
265
266
267
|
pointObjType: '',
pointObjName: '',
remark: '',
items: [],
itemId: '',
nfcCode: '',
lng: '',
lat: '',
communityId: ''
}
|
b5dad34f
wuxw
巡检功能测试中
|
268
|
|
48ea9c43
wuxw
巡检开发完成
|
269
270
271
|
if (this.$refs.addForm) {
this.$refs.addForm.resetFields()
}
|
b5dad34f
wuxw
巡检功能测试中
|
272
|
|
b8ac379c
wuxw
v1.9 优化缴费页面扫码缴费
|
273
274
275
276
277
|
setTimeout(() => {
if (this.$refs.machineSelect) {
this.$refs.machineSelect.clearMachine()
}
}, 500)
|
b5dad34f
wuxw
巡检功能测试中
|
278
279
280
281
|
},
handlePositionChange(data) {
this.addInspectionPointInfo.lng = data.lng
this.addInspectionPointInfo.lat = data.lat
|
48ea9c43
wuxw
巡检开发完成
|
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
}
},
created() {
this.communityId = getCommunityId()
}
}
</script>
<style scoped>
.tip-text {
font-size: 12px;
color: #909399;
margin-top: 5px;
}
</style>
|