1d73dc48
wuxw
继续晚上巡检功能
|
1
2
3
|
<template>
<el-dialog
:title="$t('editInspectionPoint.title')"
|
48ea9c43
wuxw
巡检开发完成
|
4
|
:visible.sync="dialogVisible"
|
1d73dc48
wuxw
继续晚上巡检功能
|
5
|
width="80%"
|
48ea9c43
wuxw
巡检开发完成
|
6
7
|
top="5vh"
@close="resetForm"
|
1d73dc48
wuxw
继续晚上巡检功能
|
8
|
>
|
48ea9c43
wuxw
巡检开发完成
|
9
10
11
12
13
14
15
|
<el-form
ref="editForm"
:model="editInspectionPointInfo"
:rules="rules"
label-width="120px"
label-position="right"
>
|
1d73dc48
wuxw
继续晚上巡检功能
|
16
17
|
<el-row :gutter="20">
<el-col :span="12">
|
48ea9c43
wuxw
巡检开发完成
|
18
|
<el-form-item :label="$t('editInspectionPoint.inspectionName')" prop="inspectionName">
|
1d73dc48
wuxw
继续晚上巡检功能
|
19
|
<el-input
|
48ea9c43
wuxw
巡检开发完成
|
20
21
22
23
|
v-model="editInspectionPointInfo.inspectionName"
:placeholder="$t('editInspectionPoint.placeholder.inspectionName')"
clearable
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
24
25
26
|
</el-form-item>
</el-col>
<el-col :span="12">
|
48ea9c43
wuxw
巡检开发完成
|
27
|
<el-form-item :label="$t('editInspectionPoint.pointObjType')" prop="pointObjType">
|
1d73dc48
wuxw
继续晚上巡检功能
|
28
|
<el-select
|
48ea9c43
wuxw
巡检开发完成
|
29
30
31
32
33
|
v-model="editInspectionPointInfo.pointObjType"
:placeholder="$t('editInspectionPoint.placeholder.pointObjType')"
style="width: 100%;"
@change="_pointObjTypeChange"
disabled
|
1d73dc48
wuxw
继续晚上巡检功能
|
34
|
>
|
48ea9c43
wuxw
巡检开发完成
|
35
36
37
38
|
<el-option
v-for="item in editInspectionPointInfo.pointObjTypes"
:key="item.statusCd"
:label="item.name"
|
1d73dc48
wuxw
继续晚上巡检功能
|
39
|
:value="item.statusCd"
|
48ea9c43
wuxw
巡检开发完成
|
40
|
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
41
42
43
44
|
</el-select>
</el-form-item>
</el-col>
</el-row>
|
48ea9c43
wuxw
巡检开发完成
|
45
|
|
1d73dc48
wuxw
继续晚上巡检功能
|
46
47
|
<el-row :gutter="20" v-if="editInspectionPointInfo.pointObjType === '2002'">
<el-col :span="12">
|
48ea9c43
wuxw
巡检开发完成
|
48
|
<el-form-item :label="$t('editInspectionPoint.pointObjName')" prop="pointObjName">
|
1d73dc48
wuxw
继续晚上巡检功能
|
49
|
<el-input
|
48ea9c43
wuxw
巡检开发完成
|
50
51
52
53
|
v-model="editInspectionPointInfo.pointObjName"
:placeholder="$t('editInspectionPoint.placeholder.pointObjName')"
clearable
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
54
55
56
|
</el-form-item>
</el-col>
</el-row>
|
48ea9c43
wuxw
巡检开发完成
|
57
|
|
1d73dc48
wuxw
继续晚上巡检功能
|
58
|
<el-row :gutter="20" v-if="editInspectionPointInfo.pointObjType === '1001'">
|
48ea9c43
wuxw
巡检开发完成
|
59
60
61
62
63
64
|
<el-col :span="24">
<el-form-item :label="$t('editInspectionPoint.machine')" prop="pointObjId">
<machine-select2
ref="machineSelect"
:parent-modal="true"
@notify="handleMachineSelect"
|
1d73dc48
wuxw
继续晚上巡检功能
|
65
66
67
68
|
/>
</el-form-item>
</el-col>
</el-row>
|
48ea9c43
wuxw
巡检开发完成
|
69
|
|
1d73dc48
wuxw
继续晚上巡检功能
|
70
71
|
<el-row :gutter="20">
<el-col :span="12">
|
48ea9c43
wuxw
巡检开发完成
|
72
|
<el-form-item :label="$t('editInspectionPoint.itemId')" prop="itemId">
|
1d73dc48
wuxw
继续晚上巡检功能
|
73
|
<el-select
|
48ea9c43
wuxw
巡检开发完成
|
74
75
76
|
v-model="editInspectionPointInfo.itemId"
:placeholder="$t('editInspectionPoint.placeholder.itemId')"
style="width: 100%;"
|
1d73dc48
wuxw
继续晚上巡检功能
|
77
|
>
|
48ea9c43
wuxw
巡检开发完成
|
78
79
80
81
|
<el-option
v-for="item in editInspectionPointInfo.items"
:key="item.itemId"
:label="item.itemName"
|
1d73dc48
wuxw
继续晚上巡检功能
|
82
|
:value="item.itemId"
|
48ea9c43
wuxw
巡检开发完成
|
83
|
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
84
85
86
87
|
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
|
48ea9c43
wuxw
巡检开发完成
|
88
|
<el-form-item :label="$t('editInspectionPoint.nfcCode')">
|
1d73dc48
wuxw
继续晚上巡检功能
|
89
|
<el-input
|
48ea9c43
wuxw
巡检开发完成
|
90
91
92
93
|
v-model="editInspectionPointInfo.nfcCode"
:placeholder="$t('editInspectionPoint.placeholder.nfcCode')"
clearable
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
94
95
96
|
</el-form-item>
</el-col>
</el-row>
|
48ea9c43
wuxw
巡检开发完成
|
97
|
|
1d73dc48
wuxw
继续晚上巡检功能
|
98
99
|
<el-row :gutter="20">
<el-col :span="12">
|
48ea9c43
wuxw
巡检开发完成
|
100
|
<el-form-item :label="$t('editInspectionPoint.lng')">
|
1d73dc48
wuxw
继续晚上巡检功能
|
101
|
<el-input
|
48ea9c43
wuxw
巡检开发完成
|
102
103
|
v-model="editInspectionPointInfo.lng"
:placeholder="$t('editInspectionPoint.placeholder.lng')"
|
1d73dc48
wuxw
继续晚上巡检功能
|
104
|
disabled
|
48ea9c43
wuxw
巡检开发完成
|
105
|
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
106
107
108
|
</el-form-item>
</el-col>
<el-col :span="12">
|
48ea9c43
wuxw
巡检开发完成
|
109
|
<el-form-item :label="$t('editInspectionPoint.lat')">
|
1d73dc48
wuxw
继续晚上巡检功能
|
110
|
<el-input
|
48ea9c43
wuxw
巡检开发完成
|
111
112
|
v-model="editInspectionPointInfo.lat"
:placeholder="$t('editInspectionPoint.placeholder.lat')"
|
1d73dc48
wuxw
继续晚上巡检功能
|
113
|
disabled
|
48ea9c43
wuxw
巡检开发完成
|
114
|
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
115
116
117
|
</el-form-item>
</el-col>
</el-row>
|
48ea9c43
wuxw
巡检开发完成
|
118
|
|
1d73dc48
wuxw
继续晚上巡检功能
|
119
|
<el-row :gutter="20">
|
48ea9c43
wuxw
巡检开发完成
|
120
|
<el-col :span="24">
|
1d73dc48
wuxw
继续晚上巡检功能
|
121
122
|
<el-form-item :label="$t('editInspectionPoint.remark')">
<el-input
|
48ea9c43
wuxw
巡检开发完成
|
123
|
v-model="editInspectionPointInfo.remark"
|
1d73dc48
wuxw
继续晚上巡检功能
|
124
|
type="textarea"
|
48ea9c43
wuxw
巡检开发完成
|
125
126
127
|
:rows="3"
:placeholder="$t('editInspectionPoint.placeholder.remark')"
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
128
129
130
|
</el-form-item>
</el-col>
</el-row>
|
48ea9c43
wuxw
巡检开发完成
|
131
132
|
<el-row :gutter="20">
|
1d73dc48
wuxw
继续晚上巡检功能
|
133
|
<el-col :span="24">
|
48ea9c43
wuxw
巡检开发完成
|
134
135
136
137
138
139
|
<select-map-pos
ref="mapSelector"
:element-id="'editInspectionPointMap'"
:init-data="editInspectionPointInfo"
@position-change="handlePositionChange"
/>
|
1d73dc48
wuxw
继续晚上巡检功能
|
140
141
142
|
</el-col>
</el-row>
</el-form>
|
48ea9c43
wuxw
巡检开发完成
|
143
144
145
146
147
|
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="updateInspectionPoint">{{ $t('common.save') }}</el-button>
</span>
|
1d73dc48
wuxw
继续晚上巡检功能
|
148
149
150
151
|
</el-dialog>
</template>
<script>
|
48ea9c43
wuxw
巡检开发完成
|
152
153
|
import { updateInspectionPoint } from '@/api/inspection/inspectionPointApi'
import { listInspectionItems } from '@/api/inspection/inspectionPointApi'
|
1d73dc48
wuxw
继续晚上巡检功能
|
154
|
import { getDict } from '@/api/community/communityApi'
|
48ea9c43
wuxw
巡检开发完成
|
155
156
157
|
import { getCommunityId } from '@/api/community/communityApi'
import MachineSelect2 from '@/components/inspection/machineSelect2'
import SelectMapPos from '@/components/inspection/selectMapPos'
|
1d73dc48
wuxw
继续晚上巡检功能
|
158
159
160
161
|
export default {
name: 'EditInspectionPoint',
components: {
|
48ea9c43
wuxw
巡检开发完成
|
162
163
|
MachineSelect2,
SelectMapPos
|
1d73dc48
wuxw
继续晚上巡检功能
|
164
165
166
|
},
data() {
return {
|
48ea9c43
wuxw
巡检开发完成
|
167
|
dialogVisible: false,
|
1d73dc48
wuxw
继续晚上巡检功能
|
168
169
|
editInspectionPointInfo: {
inspectionId: '',
|
48ea9c43
wuxw
巡检开发完成
|
170
|
inspectionName: '',
|
1d73dc48
wuxw
继续晚上巡检功能
|
171
172
173
174
|
pointObjId: '',
pointObjType: '',
pointObjTypes: [],
pointObjName: '',
|
1d73dc48
wuxw
继续晚上巡检功能
|
175
176
177
178
179
|
remark: '',
items: [],
itemId: '',
nfcCode: '',
lng: '',
|
48ea9c43
wuxw
巡检开发完成
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
lat: '',
communityId: ''
},
rules: {
inspectionName: [
{ required: true, message: this.$t('editInspectionPoint.rules.inspectionName'), trigger: 'blur' },
{ max: 100, message: this.$t('editInspectionPoint.rules.inspectionNameMax'), trigger: 'blur' }
],
pointObjType: [
{ required: true, message: this.$t('editInspectionPoint.rules.pointObjType'), trigger: 'change' }
],
pointObjName: [
{ required: true, message: this.$t('editInspectionPoint.rules.pointObjName'), trigger: 'blur' }
],
pointObjId: [
{ required: true, message: this.$t('editInspectionPoint.rules.pointObjId'), trigger: 'change' }
],
itemId: [
{ required: true, message: this.$t('editInspectionPoint.rules.itemId'), trigger: 'change' }
],
remark: [
{ max: 200, message: this.$t('editInspectionPoint.rules.remarkMax'), trigger: 'blur' }
]
|
1d73dc48
wuxw
继续晚上巡检功能
|
203
|
},
|
48ea9c43
wuxw
巡检开发完成
|
204
|
communityId: ''
|
1d73dc48
wuxw
继续晚上巡检功能
|
205
206
207
|
}
},
methods: {
|
48ea9c43
wuxw
巡检开发完成
|
208
209
|
open(inspectionPoint) {
this.dialogVisible = true
|
1d73dc48
wuxw
继续晚上巡检功能
|
210
211
|
this.resetForm()
|
48ea9c43
wuxw
巡检开发完成
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
this.$nextTick(() => {
this.getDictData()
this._listEditInspectionItems()
// 填充表单数据
Object.assign(this.editInspectionPointInfo, inspectionPoint)
// 设置设备选择器(如果是设备类型)
if (inspectionPoint.pointObjType === '1001') {
this.$nextTick(() => {
if (this.$refs.machineSelect) {
this.$refs.machineSelect.setMachine({
machineId: inspectionPoint.pointObjId,
machineName: inspectionPoint.pointObjName
})
}
})
}
})
},
async getDictData() {
|
1d73dc48
wuxw
继续晚上巡检功能
|
234
|
try {
|
48ea9c43
wuxw
巡检开发完成
|
235
236
|
const data = await getDict('inspection_point', 'point_obj_type')
this.editInspectionPointInfo.pointObjTypes = data
|
1d73dc48
wuxw
继续晚上巡检功能
|
237
238
239
|
} catch (error) {
console.error('获取字典数据失败:', error)
}
|
48ea9c43
wuxw
巡检开发完成
|
240
241
242
|
},
async _listEditInspectionItems() {
|
1d73dc48
wuxw
继续晚上巡检功能
|
243
|
try {
|
48ea9c43
wuxw
巡检开发完成
|
244
245
|
const params = {
communityId: this.communityId,
|
1d73dc48
wuxw
继续晚上巡检功能
|
246
247
|
page: 1,
row: 100
|
48ea9c43
wuxw
巡检开发完成
|
248
249
250
251
|
}
const response = await listInspectionItems(params)
this.editInspectionPointInfo.items = response.data
|
1d73dc48
wuxw
继续晚上巡检功能
|
252
|
} catch (error) {
|
48ea9c43
wuxw
巡检开发完成
|
253
|
console.error('获取巡检项目失败:', error)
|
1d73dc48
wuxw
继续晚上巡检功能
|
254
|
}
|
48ea9c43
wuxw
巡检开发完成
|
255
256
257
258
259
|
},
_pointObjTypeChange() {
this.editInspectionPointInfo.pointObjId = ''
this.editInspectionPointInfo.pointObjName = ''
|
1d73dc48
wuxw
继续晚上巡检功能
|
260
|
|
1d73dc48
wuxw
继续晚上巡检功能
|
261
|
if (this.editInspectionPointInfo.pointObjType === '1001') {
|
48ea9c43
wuxw
巡检开发完成
|
262
|
this.$refs.machineSelect.clearMachine()
|
1d73dc48
wuxw
继续晚上巡检功能
|
263
|
}
|
48ea9c43
wuxw
巡检开发完成
|
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
|
},
handleMachineSelect(data) {
if (data && data.machineId && data.machineName) {
this.editInspectionPointInfo.pointObjId = data.machineId
this.editInspectionPointInfo.pointObjName = data.machineName
}
},
handlePositionChange(position) {
this.editInspectionPointInfo.lat = position.lat
this.editInspectionPointInfo.lng = position.lng
},
updateInspectionPoint() {
this.$refs.editForm.validate(async valid => {
if (!valid) return
// 特殊验证
if (this.editInspectionPointInfo.pointObjType === '1001' && !this.editInspectionPointInfo.pointObjId) {
this.$message.error(this.$t('editInspectionPoint.rules.machineRequired'))
return
}
if (this.editInspectionPointInfo.pointObjType === '2002' && !this.editInspectionPointInfo.pointObjName) {
this.$message.error(this.$t('editInspectionPoint.rules.locationRequired'))
return
}
try {
this.editInspectionPointInfo.communityId = this.communityId
const response = await updateInspectionPoint(this.editInspectionPointInfo)
if (response.code === 0) {
this.$message.success(this.$t('editInspectionPoint.updateSuccess'))
this.dialogVisible = false
this.$emit('success')
} else {
this.$message.error(response.msg || this.$t('editInspectionPoint.updateFailed'))
}
} catch (error) {
console.error('更新巡检点失败:', error)
this.$message.error(this.$t('editInspectionPoint.updateFailed'))
}
|
1d73dc48
wuxw
继续晚上巡检功能
|
309
310
311
312
313
314
|
})
},
resetForm() {
this.editInspectionPointInfo = {
inspectionId: '',
|
48ea9c43
wuxw
巡检开发完成
|
315
|
inspectionName: '',
|
1d73dc48
wuxw
继续晚上巡检功能
|
316
317
|
pointObjId: '',
pointObjType: '',
|
1d73dc48
wuxw
继续晚上巡检功能
|
318
|
pointObjName: '',
|
1d73dc48
wuxw
继续晚上巡检功能
|
319
320
321
322
323
|
remark: '',
items: [],
itemId: '',
nfcCode: '',
lng: '',
|
48ea9c43
wuxw
巡检开发完成
|
324
325
|
lat: '',
communityId: ''
|
1d73dc48
wuxw
继续晚上巡检功能
|
326
327
|
}
|
48ea9c43
wuxw
巡检开发完成
|
328
329
|
if (this.$refs.editForm) {
this.$refs.editForm.resetFields()
|
1d73dc48
wuxw
继续晚上巡检功能
|
330
331
|
}
|
48ea9c43
wuxw
巡检开发完成
|
332
333
|
if (this.$refs.machineSelect) {
this.$refs.machineSelect.clearMachine()
|
1d73dc48
wuxw
继续晚上巡检功能
|
334
335
|
}
|
48ea9c43
wuxw
巡检开发完成
|
336
337
|
if (this.$refs.mapSelector) {
this.$refs.mapSelector.updatePosition(39.916527, 116.397128)
|
1d73dc48
wuxw
继续晚上巡检功能
|
338
|
}
|
1d73dc48
wuxw
继续晚上巡检功能
|
339
|
}
|
48ea9c43
wuxw
巡检开发完成
|
340
341
342
|
},
created() {
this.communityId = getCommunityId()
|
1d73dc48
wuxw
继续晚上巡检功能
|
343
344
345
|
}
}
</script>
|