48ea9c43
wuxw
巡检开发完成
|
1
|
<template>
|
b5dad34f
wuxw
巡检功能测试中
|
2
3
4
|
<el-dialog :title="$t('addInspectionPoint.title')" :visible.sync="dialogVisible" width="60%" top="5vh"
@close="resetForm">
<el-form ref="addForm" :model="addInspectionPointInfo" :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
34
35
|
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20" v-if="addInspectionPointInfo.pointObjType === '1001'">
<el-col :span="24">
<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
47
48
|
<el-select v-model="addInspectionPointInfo.itemId"
:placeholder="$t('addInspectionPoint.placeholder.itemId')" style="width: 100%;">
<el-option v-for="item in addInspectionPointInfo.items" :key="item.itemId" :label="item.itemName"
: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
64
|
<el-input v-model="addInspectionPointInfo.lng" :placeholder="$t('addInspectionPoint.placeholder.lng')"
disabled />
|
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
70
|
<el-input v-model="addInspectionPointInfo.lat" :placeholder="$t('addInspectionPoint.placeholder.lat')"
disabled />
|
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
160
161
162
163
164
165
|
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()
this.$nextTick(() => {
this.initMap()
this.getDictData()
this._listAddInspectionItems()
})
},
|
b5dad34f
wuxw
巡检功能测试中
|
166
|
|
48ea9c43
wuxw
巡检开发完成
|
167
168
169
170
171
172
173
174
|
async getDictData() {
try {
const data = await getDict('inspection_point', 'point_obj_type')
this.addInspectionPointInfo.pointObjTypes = data
} catch (error) {
console.error('获取字典数据失败:', error)
}
},
|
b5dad34f
wuxw
巡检功能测试中
|
175
|
|
48ea9c43
wuxw
巡检开发完成
|
176
177
178
179
180
181
182
|
async _listAddInspectionItems() {
try {
const params = {
communityId: this.communityId,
page: 1,
row: 100
}
|
b5dad34f
wuxw
巡检功能测试中
|
183
|
|
48ea9c43
wuxw
巡检开发完成
|
184
185
186
187
188
189
|
const response = await listInspectionItems(params)
this.addInspectionPointInfo.items = response.data
} catch (error) {
console.error('获取巡检项目失败:', error)
}
},
|
b5dad34f
wuxw
巡检功能测试中
|
190
|
|
48ea9c43
wuxw
巡检开发完成
|
191
192
|
initMap() {
// 这里简化了地图初始化,实际项目中需要根据地图API实现
|
b5dad34f
wuxw
巡检功能测试中
|
193
194
195
|
setTimeout(() => {
this.$refs.selectMapPos.initMap({})
}, 1000)
|
48ea9c43
wuxw
巡检开发完成
|
196
|
},
|
b5dad34f
wuxw
巡检功能测试中
|
197
|
|
48ea9c43
wuxw
巡检开发完成
|
198
199
200
|
_pointObjTypeChange() {
this.addInspectionPointInfo.pointObjId = ''
this.addInspectionPointInfo.pointObjName = ''
|
b5dad34f
wuxw
巡检功能测试中
|
201
|
|
48ea9c43
wuxw
巡检开发完成
|
202
203
204
205
|
if (this.addInspectionPointInfo.pointObjType === '1001') {
this.$refs.machineSelect.clearMachine()
}
},
|
b5dad34f
wuxw
巡检功能测试中
|
206
|
|
48ea9c43
wuxw
巡检开发完成
|
207
208
209
210
211
212
|
handleMachineSelect(data) {
if (data && data.machineId && data.machineName) {
this.addInspectionPointInfo.pointObjId = data.machineId
this.addInspectionPointInfo.pointObjName = data.machineName
}
},
|
b5dad34f
wuxw
巡检功能测试中
|
213
|
|
48ea9c43
wuxw
巡检开发完成
|
214
215
216
|
saveInspectionPointInfo() {
this.$refs.addForm.validate(async valid => {
if (!valid) return
|
b5dad34f
wuxw
巡检功能测试中
|
217
218
219
|
if (this.addInspectionPointInfo.pointObjType == '2002') {
this.addInspectionPointInfo.pointObjId = '-1'
}
|
48ea9c43
wuxw
巡检开发完成
|
220
221
222
223
224
|
// 特殊验证
if (this.addInspectionPointInfo.pointObjType === '1001' && !this.addInspectionPointInfo.pointObjId) {
this.$message.error(this.$t('addInspectionPoint.rules.machineRequired'))
return
}
|
b5dad34f
wuxw
巡检功能测试中
|
225
|
|
48ea9c43
wuxw
巡检开发完成
|
226
227
228
229
|
if (this.addInspectionPointInfo.pointObjType === '2002' && !this.addInspectionPointInfo.pointObjName) {
this.$message.error(this.$t('addInspectionPoint.rules.locationRequired'))
return
}
|
b5dad34f
wuxw
巡检功能测试中
|
230
|
|
48ea9c43
wuxw
巡检开发完成
|
231
232
|
try {
this.addInspectionPointInfo.communityId = this.communityId
|
b5dad34f
wuxw
巡检功能测试中
|
233
|
|
48ea9c43
wuxw
巡检开发完成
|
234
|
const response = await saveInspectionPoint(this.addInspectionPointInfo)
|
b5dad34f
wuxw
巡检功能测试中
|
235
|
|
48ea9c43
wuxw
巡检开发完成
|
236
237
238
239
240
241
242
243
244
245
246
247
248
|
if (response.code === 0) {
this.$message.success(this.$t('addInspectionPoint.saveSuccess'))
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
巡检功能测试中
|
249
|
|
48ea9c43
wuxw
巡检开发完成
|
250
251
252
|
resetForm() {
this.addInspectionPointInfo = {
inspectionName: '',
|
b5dad34f
wuxw
巡检功能测试中
|
253
|
pointObjId: '-1',
|
48ea9c43
wuxw
巡检开发完成
|
254
255
256
257
258
259
260
261
262
263
|
pointObjType: '',
pointObjName: '',
remark: '',
items: [],
itemId: '',
nfcCode: '',
lng: '',
lat: '',
communityId: ''
}
|
b5dad34f
wuxw
巡检功能测试中
|
264
|
|
48ea9c43
wuxw
巡检开发完成
|
265
266
267
|
if (this.$refs.addForm) {
this.$refs.addForm.resetFields()
}
|
b5dad34f
wuxw
巡检功能测试中
|
268
|
|
48ea9c43
wuxw
巡检开发完成
|
269
270
271
|
if (this.$refs.machineSelect) {
this.$refs.machineSelect.clearMachine()
}
|
b5dad34f
wuxw
巡检功能测试中
|
272
273
274
275
|
},
handlePositionChange(data) {
this.addInspectionPointInfo.lng = data.lng
this.addInspectionPointInfo.lat = data.lat
|
48ea9c43
wuxw
巡检开发完成
|
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
}
},
created() {
this.communityId = getCommunityId()
}
}
</script>
<style scoped>
.tip-text {
font-size: 12px;
color: #909399;
margin-top: 5px;
}
</style>
|