Commit b5dad34f47264032bdcac24ed3e42ad2c5a48c24

Authored by wuxw
1 parent 72de60dc

巡检功能测试中

src/components/inspection/AddInspectionItem.vue
1 1 <template>
2   - <el-dialog
3   - :title="$t('inspectionItemManage.addTitle')"
4   - :visible.sync="visible"
5   - width="50%"
6   - @close="handleClose"
7   - >
  2 + <el-dialog :title="$t('inspectionItemManage.addTitle')" :visible.sync="visible" width="40%" @close="handleClose">
8 3 <el-form ref="form" :model="formData" :rules="rules" label-width="120px">
9 4 <el-form-item :label="$t('inspectionItemManage.itemNameLabel')" prop="itemName">
10   - <el-input
11   - v-model="formData.itemName"
12   - :placeholder="$t('inspectionItemManage.requiredItem')"
13   - />
  5 + <el-input v-model="formData.itemName" :placeholder="$t('inspectionItemManage.requiredItem')" />
14 6 </el-form-item>
15 7 <el-form-item :label="$t('inspectionItemManage.remarkLabel')" prop="remark">
16   - <el-input
17   - v-model="formData.remark"
18   - type="textarea"
19   - :rows="4"
20   - :placeholder="$t('inspectionItemManage.requiredRemark')"
21   - />
  8 + <el-input v-model="formData.remark" type="textarea" :rows="4"
  9 + :placeholder="$t('inspectionItemManage.requiredRemark')" />
22 10 </el-form-item>
23 11 </el-form>
24   -
  12 +
25 13 <span slot="footer" class="dialog-footer">
26 14 <el-button @click="visible = false">
27 15 {{ $t('inspectionItemManage.cancel') }}
... ...
src/components/inspection/addInspectionPoint.vue
1 1 <template>
2   - <el-dialog
3   - :title="$t('addInspectionPoint.title')"
4   - :visible.sync="dialogVisible"
5   - width="80%"
6   - top="5vh"
7   - @close="resetForm"
8   - >
9   - <el-form
10   - ref="addForm"
11   - :model="addInspectionPointInfo"
12   - :rules="rules"
13   - label-width="120px"
14   - label-position="right"
15   - >
  2 + <el-dialog :title="$t('addInspectionPoint.title')" :visible.sync="dialogVisible" width="60%" top="5vh"
  3 + @close="resetForm">
  4 + <el-form ref="addForm" :model="addInspectionPointInfo" :rules="rules" label-width="120px" label-position="right">
16 5 <el-row :gutter="20">
17 6 <el-col :span="12">
18 7 <el-form-item :label="$t('addInspectionPoint.inspectionName')" prop="inspectionName">
19   - <el-input
20   - v-model="addInspectionPointInfo.inspectionName"
21   - :placeholder="$t('addInspectionPoint.placeholder.inspectionName')"
22   - clearable
23   - />
  8 + <el-input v-model="addInspectionPointInfo.inspectionName"
  9 + :placeholder="$t('addInspectionPoint.placeholder.inspectionName')" clearable />
24 10 </el-form-item>
25 11 </el-col>
26 12 <el-col :span="12">
27 13 <el-form-item :label="$t('addInspectionPoint.pointObjType')" prop="pointObjType">
28   - <el-select
29   - v-model="addInspectionPointInfo.pointObjType"
30   - :placeholder="$t('addInspectionPoint.placeholder.pointObjType')"
31   - style="width: 100%;"
32   - @change="_pointObjTypeChange"
33   - >
34   - <el-option
35   - v-for="item in addInspectionPointInfo.pointObjTypes"
36   - :key="item.statusCd"
37   - :label="item.name"
38   - :value="item.statusCd"
39   - />
  14 + <el-select v-model="addInspectionPointInfo.pointObjType"
  15 + :placeholder="$t('addInspectionPoint.placeholder.pointObjType')" style="width: 100%;"
  16 + @change="_pointObjTypeChange">
  17 + <el-option v-for="item in addInspectionPointInfo.pointObjTypes" :key="item.statusCd" :label="item.name"
  18 + :value="item.statusCd" />
40 19 </el-select>
41 20 </el-form-item>
42 21 </el-col>
... ... @@ -45,11 +24,8 @@
45 24 <el-row :gutter="20" v-if="addInspectionPointInfo.pointObjType === '2002'">
46 25 <el-col :span="12">
47 26 <el-form-item :label="$t('addInspectionPoint.pointObjName')" prop="pointObjName">
48   - <el-input
49   - v-model="addInspectionPointInfo.pointObjName"
50   - :placeholder="$t('addInspectionPoint.placeholder.pointObjName')"
51   - clearable
52   - />
  27 + <el-input v-model="addInspectionPointInfo.pointObjName"
  28 + :placeholder="$t('addInspectionPoint.placeholder.pointObjName')" clearable />
53 29 </el-form-item>
54 30 </el-col>
55 31 </el-row>
... ... @@ -57,11 +33,7 @@
57 33 <el-row :gutter="20" v-if="addInspectionPointInfo.pointObjType === '1001'">
58 34 <el-col :span="24">
59 35 <el-form-item :label="$t('addInspectionPoint.machine')" prop="pointObjId">
60   - <machine-select2
61   - ref="machineSelect"
62   - :parent-modal="true"
63   - @notify="handleMachineSelect"
64   - />
  36 + <machine-select2 ref="machineSelect" :parent-modal="true" @notify="handleMachineSelect" />
65 37 <div class="tip-text">{{ $t('addInspectionPoint.tip.addMachine') }}</div>
66 38 </el-form-item>
67 39 </el-col>
... ... @@ -70,27 +42,17 @@
70 42 <el-row :gutter="20">
71 43 <el-col :span="12">
72 44 <el-form-item :label="$t('addInspectionPoint.itemId')" prop="itemId">
73   - <el-select
74   - v-model="addInspectionPointInfo.itemId"
75   - :placeholder="$t('addInspectionPoint.placeholder.itemId')"
76   - style="width: 100%;"
77   - >
78   - <el-option
79   - v-for="item in addInspectionPointInfo.items"
80   - :key="item.itemId"
81   - :label="item.itemName"
82   - :value="item.itemId"
83   - />
  45 + <el-select v-model="addInspectionPointInfo.itemId"
  46 + :placeholder="$t('addInspectionPoint.placeholder.itemId')" style="width: 100%;">
  47 + <el-option v-for="item in addInspectionPointInfo.items" :key="item.itemId" :label="item.itemName"
  48 + :value="item.itemId" />
84 49 </el-select>
85 50 </el-form-item>
86 51 </el-col>
87 52 <el-col :span="12">
88 53 <el-form-item :label="$t('addInspectionPoint.nfcCode')">
89   - <el-input
90   - v-model="addInspectionPointInfo.nfcCode"
91   - :placeholder="$t('addInspectionPoint.placeholder.nfcCode')"
92   - clearable
93   - />
  54 + <el-input v-model="addInspectionPointInfo.nfcCode"
  55 + :placeholder="$t('addInspectionPoint.placeholder.nfcCode')" clearable />
94 56 </el-form-item>
95 57 </el-col>
96 58 </el-row>
... ... @@ -98,20 +60,14 @@
98 60 <el-row :gutter="20">
99 61 <el-col :span="12">
100 62 <el-form-item :label="$t('addInspectionPoint.lng')">
101   - <el-input
102   - v-model="addInspectionPointInfo.lng"
103   - :placeholder="$t('addInspectionPoint.placeholder.lng')"
104   - disabled
105   - />
  63 + <el-input v-model="addInspectionPointInfo.lng" :placeholder="$t('addInspectionPoint.placeholder.lng')"
  64 + disabled />
106 65 </el-form-item>
107 66 </el-col>
108 67 <el-col :span="12">
109 68 <el-form-item :label="$t('addInspectionPoint.lat')">
110   - <el-input
111   - v-model="addInspectionPointInfo.lat"
112   - :placeholder="$t('addInspectionPoint.placeholder.lat')"
113   - disabled
114   - />
  69 + <el-input v-model="addInspectionPointInfo.lat" :placeholder="$t('addInspectionPoint.placeholder.lat')"
  70 + disabled />
115 71 </el-form-item>
116 72 </el-col>
117 73 </el-row>
... ... @@ -119,19 +75,15 @@
119 75 <el-row :gutter="20">
120 76 <el-col :span="24">
121 77 <el-form-item :label="$t('addInspectionPoint.remark')">
122   - <el-input
123   - v-model="addInspectionPointInfo.remark"
124   - type="textarea"
125   - :rows="3"
126   - :placeholder="$t('addInspectionPoint.placeholder.remark')"
127   - />
  78 + <el-input v-model="addInspectionPointInfo.remark" type="textarea" :rows="3"
  79 + :placeholder="$t('addInspectionPoint.placeholder.remark')" />
128 80 </el-form-item>
129 81 </el-col>
130 82 </el-row>
131 83  
132 84 <el-row :gutter="20">
133 85 <el-col :span="24">
134   - <div id="addInspectionPointMap" style="width: 100%; height: 300px;"></div>
  86 + <select-map-pos ref="selectMapPos" @position-change="handlePositionChange" />
135 87 </el-col>
136 88 </el-row>
137 89 </el-form>
... ... @@ -149,18 +101,21 @@ import { listInspectionItems } from &#39;@/api/inspection/inspectionPointApi&#39;
149 101 import { getDict } from '@/api/community/communityApi'
150 102 import { getCommunityId } from '@/api/community/communityApi'
151 103 import MachineSelect2 from '@/components/inspection/machineSelect2'
  104 +import SelectMapPos from '@/components/inspection/selectMapPos'
  105 +
152 106  
153 107 export default {
154 108 name: 'AddInspectionPoint',
155 109 components: {
156   - MachineSelect2
  110 + MachineSelect2,
  111 + SelectMapPos
157 112 },
158 113 data() {
159 114 return {
160 115 dialogVisible: false,
161 116 addInspectionPointInfo: {
162 117 inspectionName: '',
163   - pointObjId: '',
  118 + pointObjId: '-1',
164 119 pointObjType: '',
165 120 pointObjTypes: [],
166 121 pointObjName: '',
... ... @@ -208,7 +163,7 @@ export default {
208 163 this._listAddInspectionItems()
209 164 })
210 165 },
211   -
  166 +
212 167 async getDictData() {
213 168 try {
214 169 const data = await getDict('inspection_point', 'point_obj_type')
... ... @@ -217,7 +172,7 @@ export default {
217 172 console.error('获取字典数据失败:', error)
218 173 }
219 174 },
220   -
  175 +
221 176 async _listAddInspectionItems() {
222 177 try {
223 178 const params = {
... ... @@ -225,55 +180,59 @@ export default {
225 180 page: 1,
226 181 row: 100
227 182 }
228   -
  183 +
229 184 const response = await listInspectionItems(params)
230 185 this.addInspectionPointInfo.items = response.data
231 186 } catch (error) {
232 187 console.error('获取巡检项目失败:', error)
233 188 }
234 189 },
235   -
  190 +
236 191 initMap() {
237 192 // 这里简化了地图初始化,实际项目中需要根据地图API实现
238   - console.log('初始化地图...')
  193 + setTimeout(() => {
  194 + this.$refs.selectMapPos.initMap({})
  195 + }, 1000)
239 196 },
240   -
  197 +
241 198 _pointObjTypeChange() {
242 199 this.addInspectionPointInfo.pointObjId = ''
243 200 this.addInspectionPointInfo.pointObjName = ''
244   -
  201 +
245 202 if (this.addInspectionPointInfo.pointObjType === '1001') {
246 203 this.$refs.machineSelect.clearMachine()
247 204 }
248 205 },
249   -
  206 +
250 207 handleMachineSelect(data) {
251 208 if (data && data.machineId && data.machineName) {
252 209 this.addInspectionPointInfo.pointObjId = data.machineId
253 210 this.addInspectionPointInfo.pointObjName = data.machineName
254 211 }
255 212 },
256   -
  213 +
257 214 saveInspectionPointInfo() {
258 215 this.$refs.addForm.validate(async valid => {
259 216 if (!valid) return
260   -
  217 + if (this.addInspectionPointInfo.pointObjType == '2002') {
  218 + this.addInspectionPointInfo.pointObjId = '-1'
  219 + }
261 220 // 特殊验证
262 221 if (this.addInspectionPointInfo.pointObjType === '1001' && !this.addInspectionPointInfo.pointObjId) {
263 222 this.$message.error(this.$t('addInspectionPoint.rules.machineRequired'))
264 223 return
265 224 }
266   -
  225 +
267 226 if (this.addInspectionPointInfo.pointObjType === '2002' && !this.addInspectionPointInfo.pointObjName) {
268 227 this.$message.error(this.$t('addInspectionPoint.rules.locationRequired'))
269 228 return
270 229 }
271   -
  230 +
272 231 try {
273 232 this.addInspectionPointInfo.communityId = this.communityId
274   -
  233 +
275 234 const response = await saveInspectionPoint(this.addInspectionPointInfo)
276   -
  235 +
277 236 if (response.code === 0) {
278 237 this.$message.success(this.$t('addInspectionPoint.saveSuccess'))
279 238 this.dialogVisible = false
... ... @@ -287,11 +246,11 @@ export default {
287 246 }
288 247 })
289 248 },
290   -
  249 +
291 250 resetForm() {
292 251 this.addInspectionPointInfo = {
293 252 inspectionName: '',
294   - pointObjId: '',
  253 + pointObjId: '-1',
295 254 pointObjType: '',
296 255 pointObjName: '',
297 256 remark: '',
... ... @@ -302,14 +261,18 @@ export default {
302 261 lat: '',
303 262 communityId: ''
304 263 }
305   -
  264 +
306 265 if (this.$refs.addForm) {
307 266 this.$refs.addForm.resetFields()
308 267 }
309   -
  268 +
310 269 if (this.$refs.machineSelect) {
311 270 this.$refs.machineSelect.clearMachine()
312 271 }
  272 + },
  273 + handlePositionChange(data) {
  274 + this.addInspectionPointInfo.lng = data.lng
  275 + this.addInspectionPointInfo.lat = data.lat
313 276 }
314 277 },
315 278 created() {
... ...
src/components/inspection/editInspectionPoint.vue
1 1 <template>
2   - <el-dialog
3   - :title="$t('editInspectionPoint.title')"
4   - :visible.sync="dialogVisible"
5   - width="80%"
6   - top="5vh"
7   - @close="resetForm"
8   - >
9   - <el-form
10   - ref="editForm"
11   - :model="editInspectionPointInfo"
12   - :rules="rules"
13   - label-width="120px"
14   - label-position="right"
15   - >
  2 + <el-dialog :title="$t('editInspectionPoint.title')" :visible.sync="dialogVisible" width="60%" top="5vh"
  3 + @close="resetForm">
  4 + <el-form ref="editForm" :model="editInspectionPointInfo" :rules="rules" label-width="120px" label-position="right">
16 5 <el-row :gutter="20">
17 6 <el-col :span="12">
18 7 <el-form-item :label="$t('editInspectionPoint.inspectionName')" prop="inspectionName">
19   - <el-input
20   - v-model="editInspectionPointInfo.inspectionName"
21   - :placeholder="$t('editInspectionPoint.placeholder.inspectionName')"
22   - clearable
23   - />
  8 + <el-input v-model="editInspectionPointInfo.inspectionName"
  9 + :placeholder="$t('editInspectionPoint.placeholder.inspectionName')" clearable />
24 10 </el-form-item>
25 11 </el-col>
26 12 <el-col :span="12">
27 13 <el-form-item :label="$t('editInspectionPoint.pointObjType')" prop="pointObjType">
28   - <el-select
29   - v-model="editInspectionPointInfo.pointObjType"
30   - :placeholder="$t('editInspectionPoint.placeholder.pointObjType')"
31   - style="width: 100%;"
32   - @change="_pointObjTypeChange"
33   - disabled
34   - >
35   - <el-option
36   - v-for="item in editInspectionPointInfo.pointObjTypes"
37   - :key="item.statusCd"
38   - :label="item.name"
39   - :value="item.statusCd"
40   - />
  14 + <el-select v-model="editInspectionPointInfo.pointObjType"
  15 + :placeholder="$t('editInspectionPoint.placeholder.pointObjType')" style="width: 100%;"
  16 + @change="_pointObjTypeChange" disabled>
  17 + <el-option v-for="item in editInspectionPointInfo.pointObjTypes" :key="item.statusCd" :label="item.name"
  18 + :value="item.statusCd" />
41 19 </el-select>
42 20 </el-form-item>
43 21 </el-col>
... ... @@ -46,11 +24,8 @@
46 24 <el-row :gutter="20" v-if="editInspectionPointInfo.pointObjType === '2002'">
47 25 <el-col :span="12">
48 26 <el-form-item :label="$t('editInspectionPoint.pointObjName')" prop="pointObjName">
49   - <el-input
50   - v-model="editInspectionPointInfo.pointObjName"
51   - :placeholder="$t('editInspectionPoint.placeholder.pointObjName')"
52   - clearable
53   - />
  27 + <el-input v-model="editInspectionPointInfo.pointObjName"
  28 + :placeholder="$t('editInspectionPoint.placeholder.pointObjName')" clearable />
54 29 </el-form-item>
55 30 </el-col>
56 31 </el-row>
... ... @@ -58,11 +33,7 @@
58 33 <el-row :gutter="20" v-if="editInspectionPointInfo.pointObjType === '1001'">
59 34 <el-col :span="24">
60 35 <el-form-item :label="$t('editInspectionPoint.machine')" prop="pointObjId">
61   - <machine-select2
62   - ref="machineSelect"
63   - :parent-modal="true"
64   - @notify="handleMachineSelect"
65   - />
  36 + <machine-select2 ref="machineSelect" :parent-modal="true" @notify="handleMachineSelect" />
66 37 </el-form-item>
67 38 </el-col>
68 39 </el-row>
... ... @@ -70,27 +41,17 @@
70 41 <el-row :gutter="20">
71 42 <el-col :span="12">
72 43 <el-form-item :label="$t('editInspectionPoint.itemId')" prop="itemId">
73   - <el-select
74   - v-model="editInspectionPointInfo.itemId"
75   - :placeholder="$t('editInspectionPoint.placeholder.itemId')"
76   - style="width: 100%;"
77   - >
78   - <el-option
79   - v-for="item in editInspectionPointInfo.items"
80   - :key="item.itemId"
81   - :label="item.itemName"
82   - :value="item.itemId"
83   - />
  44 + <el-select v-model="editInspectionPointInfo.itemId"
  45 + :placeholder="$t('editInspectionPoint.placeholder.itemId')" style="width: 100%;">
  46 + <el-option v-for="item in editInspectionPointInfo.items" :key="item.itemId" :label="item.itemName"
  47 + :value="item.itemId" />
84 48 </el-select>
85 49 </el-form-item>
86 50 </el-col>
87 51 <el-col :span="12">
88 52 <el-form-item :label="$t('editInspectionPoint.nfcCode')">
89   - <el-input
90   - v-model="editInspectionPointInfo.nfcCode"
91   - :placeholder="$t('editInspectionPoint.placeholder.nfcCode')"
92   - clearable
93   - />
  53 + <el-input v-model="editInspectionPointInfo.nfcCode"
  54 + :placeholder="$t('editInspectionPoint.placeholder.nfcCode')" clearable />
94 55 </el-form-item>
95 56 </el-col>
96 57 </el-row>
... ... @@ -98,20 +59,14 @@
98 59 <el-row :gutter="20">
99 60 <el-col :span="12">
100 61 <el-form-item :label="$t('editInspectionPoint.lng')">
101   - <el-input
102   - v-model="editInspectionPointInfo.lng"
103   - :placeholder="$t('editInspectionPoint.placeholder.lng')"
104   - disabled
105   - />
  62 + <el-input v-model="editInspectionPointInfo.lng" :placeholder="$t('editInspectionPoint.placeholder.lng')"
  63 + disabled />
106 64 </el-form-item>
107 65 </el-col>
108 66 <el-col :span="12">
109 67 <el-form-item :label="$t('editInspectionPoint.lat')">
110   - <el-input
111   - v-model="editInspectionPointInfo.lat"
112   - :placeholder="$t('editInspectionPoint.placeholder.lat')"
113   - disabled
114   - />
  68 + <el-input v-model="editInspectionPointInfo.lat" :placeholder="$t('editInspectionPoint.placeholder.lat')"
  69 + disabled />
115 70 </el-form-item>
116 71 </el-col>
117 72 </el-row>
... ... @@ -119,24 +74,16 @@
119 74 <el-row :gutter="20">
120 75 <el-col :span="24">
121 76 <el-form-item :label="$t('editInspectionPoint.remark')">
122   - <el-input
123   - v-model="editInspectionPointInfo.remark"
124   - type="textarea"
125   - :rows="3"
126   - :placeholder="$t('editInspectionPoint.placeholder.remark')"
127   - />
  77 + <el-input v-model="editInspectionPointInfo.remark" type="textarea" :rows="3"
  78 + :placeholder="$t('editInspectionPoint.placeholder.remark')" />
128 79 </el-form-item>
129 80 </el-col>
130 81 </el-row>
131 82  
132 83 <el-row :gutter="20">
133 84 <el-col :span="24">
134   - <select-map-pos
135   - ref="mapSelector"
136   - :element-id="'editInspectionPointMap'"
137   - :init-data="editInspectionPointInfo"
138   - @position-change="handlePositionChange"
139   - />
  85 + <select-map-pos ref="selectMapPos" @position-change="handlePositionChange" />
  86 +
140 87 </el-col>
141 88 </el-row>
142 89 </el-form>
... ... @@ -208,14 +155,14 @@ export default {
208 155 open(inspectionPoint) {
209 156 this.dialogVisible = true
210 157 this.resetForm()
211   -
  158 +
212 159 this.$nextTick(() => {
213 160 this.getDictData()
214 161 this._listEditInspectionItems()
215   -
  162 +
216 163 // 填充表单数据
217 164 Object.assign(this.editInspectionPointInfo, inspectionPoint)
218   -
  165 +
219 166 // 设置设备选择器(如果是设备类型)
220 167 if (inspectionPoint.pointObjType === '1001') {
221 168 this.$nextTick(() => {
... ... @@ -228,8 +175,11 @@ export default {
228 175 })
229 176 }
230 177 })
  178 + setTimeout(() => {
  179 + this.$refs.selectMapPos.initMap({})
  180 + }, 1000)
231 181 },
232   -
  182 +
233 183 async getDictData() {
234 184 try {
235 185 const data = await getDict('inspection_point', 'point_obj_type')
... ... @@ -238,7 +188,7 @@ export default {
238 188 console.error('获取字典数据失败:', error)
239 189 }
240 190 },
241   -
  191 +
242 192 async _listEditInspectionItems() {
243 193 try {
244 194 const params = {
... ... @@ -246,55 +196,55 @@ export default {
246 196 page: 1,
247 197 row: 100
248 198 }
249   -
  199 +
250 200 const response = await listInspectionItems(params)
251 201 this.editInspectionPointInfo.items = response.data
252 202 } catch (error) {
253 203 console.error('获取巡检项目失败:', error)
254 204 }
255 205 },
256   -
  206 +
257 207 _pointObjTypeChange() {
258 208 this.editInspectionPointInfo.pointObjId = ''
259 209 this.editInspectionPointInfo.pointObjName = ''
260   -
  210 +
261 211 if (this.editInspectionPointInfo.pointObjType === '1001') {
262 212 this.$refs.machineSelect.clearMachine()
263 213 }
264 214 },
265   -
  215 +
266 216 handleMachineSelect(data) {
267 217 if (data && data.machineId && data.machineName) {
268 218 this.editInspectionPointInfo.pointObjId = data.machineId
269 219 this.editInspectionPointInfo.pointObjName = data.machineName
270 220 }
271 221 },
272   -
  222 +
273 223 handlePositionChange(position) {
274 224 this.editInspectionPointInfo.lat = position.lat
275 225 this.editInspectionPointInfo.lng = position.lng
276 226 },
277   -
  227 +
278 228 updateInspectionPoint() {
279 229 this.$refs.editForm.validate(async valid => {
280 230 if (!valid) return
281   -
  231 +
282 232 // 特殊验证
283 233 if (this.editInspectionPointInfo.pointObjType === '1001' && !this.editInspectionPointInfo.pointObjId) {
284 234 this.$message.error(this.$t('editInspectionPoint.rules.machineRequired'))
285 235 return
286 236 }
287   -
  237 +
288 238 if (this.editInspectionPointInfo.pointObjType === '2002' && !this.editInspectionPointInfo.pointObjName) {
289 239 this.$message.error(this.$t('editInspectionPoint.rules.locationRequired'))
290 240 return
291 241 }
292   -
  242 +
293 243 try {
294 244 this.editInspectionPointInfo.communityId = this.communityId
295   -
  245 +
296 246 const response = await updateInspectionPoint(this.editInspectionPointInfo)
297   -
  247 +
298 248 if (response.code === 0) {
299 249 this.$message.success(this.$t('editInspectionPoint.updateSuccess'))
300 250 this.dialogVisible = false
... ... @@ -308,7 +258,7 @@ export default {
308 258 }
309 259 })
310 260 },
311   -
  261 +
312 262 resetForm() {
313 263 this.editInspectionPointInfo = {
314 264 inspectionId: '',
... ... @@ -324,15 +274,15 @@ export default {
324 274 lat: '',
325 275 communityId: ''
326 276 }
327   -
  277 +
328 278 if (this.$refs.editForm) {
329 279 this.$refs.editForm.resetFields()
330 280 }
331   -
  281 +
332 282 if (this.$refs.machineSelect) {
333 283 this.$refs.machineSelect.clearMachine()
334 284 }
335   -
  285 +
336 286 if (this.$refs.mapSelector) {
337 287 this.$refs.mapSelector.updatePosition(39.916527, 116.397128)
338 288 }
... ...
src/components/inspection/selectMapPos.vue
1 1 <template>
2 2 <div class="select-map-pos-container">
3   - <div :id="elementId" style="width: 100%; height: 100%;"></div>
  3 + <div id="selectMap" style="width: 100%; height: 100%;"></div>
4 4 </div>
5 5 </template>
6 6  
... ... @@ -19,76 +19,89 @@ export default {
19 19 default: () => ({})
20 20 }
21 21 },
  22 +
22 23 data() {
23 24 return {
24 25 map: null,
25 26 marker: null,
26   - communityId: ''
  27 + communityId: '',
  28 + mapData: {
  29 + lat: 0,
  30 + lng: 0
  31 + }
27 32 }
28 33 },
29 34 mounted() {
30 35 this.communityId = getCommunityId()
31   - this.$nextTick(() => {
32   - this.initMap(this.initData)
33   - })
  36 +
34 37 },
35 38 methods: {
36   - initMap(data) {
  39 + initMap(_data) {
37 40 // 清除现有地图
38   - if (this.map) {
39   - this.map.destroy()
40   - this.map = null
41   - this.marker = null
42   - }
43   -
44   - // 设置默认中心点
45   - let center = new TMap.LatLng(39.916527, 116.397128)
46   - let zoom = 13
47   -
48   - // 如果有初始数据,使用初始位置
49   - if (data.lat && data.lng) {
50   - center = new TMap.LatLng(data.lat, data.lng)
51   - zoom = 16
  41 + let _lng = 116.397128;
  42 + let _lat = 39.916527;
  43 +
  44 + if (_data.lng) {
  45 + _lng = _data.lng;
52 46 }
53 47  
54   - let TMap = window.TMap
55   -
56   - // 创建地图实例
57   - this.map = new TMap.Map(document.getElementById(this.elementId), {
58   - center: center,
59   - zoom: zoom,
60   - baseMap: {
61   - type: 'vector',
62   - features: ['base', 'building2d', 'point']
  48 + if (_data.lat) {
  49 + _lat = _data.lat;
  50 + }
  51 + try {
  52 + if (this.map) {
  53 + this.map.destroy();
63 54 }
64   - })
65   -
66   - // 添加初始标记(如果有)
67   - if (data.lat && data.lng) {
68   - this.addMarker(new TMap.LatLng(data.lat, data.lng))
  55 + } catch (e) {
  56 + console.log(e)
69 57 }
70   -
71   - // 添加点击事件
72   - this.map.on('click', this.handleMapClick)
73   - },
74   -
75   - handleMapClick(event) {
76   - // 更新标记位置
77   - this.addMarker(event.latLng)
78   -
79   - // 通知父组件位置变化
80   - this.$emit('position-change', {
81   - lat: event.latLng.lat,
82   - lng: event.latLng.lng
83   - })
  58 +
  59 +
  60 + let addMap = new window.TMap.Map('selectMap', {
  61 + center: new window.TMap.LatLng(_lat, _lng),
  62 + zoom: 13
  63 + });
  64 + // $that.addMapInfo.addMap = addMap;
  65 + let marker;
  66 + //添加监听事件 获取鼠标点击事件
  67 + let _this = this
  68 + addMap.on('click', function (event) {
  69 + console.log(event)
  70 + if (!marker) {
  71 + marker = new window.TMap.MultiMarker({
  72 + styleId: "marker",
  73 + position: event.latLng,
  74 + map: addMap,
  75 + id: "1",
  76 + });
  77 + }
  78 + console.log(event)
  79 + //marker.setPosition(event.latLng);
  80 + _this.$emit('position-change', {
  81 + lat: event.latLng.lat,
  82 + lng: event.latLng.lng
  83 + })
  84 +
  85 + marker.updateGeometries([
  86 + {
  87 + "styleId": "marker",
  88 + "id": "1",
  89 + "position": event.latLng,
  90 + }
  91 + ])
  92 + });
  93 + //为地图注册click事件获取鼠标点击出的经纬度坐标
  94 +
  95 + this.map = addMap;
84 96 },
85   -
  97 +
  98 +
86 99 addMarker(position) {
87 100 // 清除现有标记
88 101 if (this.marker) {
89 102 this.marker.setMap(null)
90 103 }
91   -
  104 +
92 105 // 创建新标记
93 106 let TMap = window.TMap
94 107  
... ... @@ -108,34 +121,19 @@ export default {
108 121 position: position
109 122 }]
110 123 })
111   -
  124 +
112 125 // 移动地图中心到标记位置
113 126 this.map.setCenter(position)
114 127 this.map.setZoom(16)
115 128 },
116   -
  129 +
117 130 updatePosition(lat, lng) {
118 131 if (!this.map) return
119   - let TMap = window.TMap
120 132  
121   - const position = new TMap.LatLng(lat, lng)
  133 + const position = new window.TMap.LatLng(lat, lng)
122 134 this.addMarker(position)
123 135 }
124 136 },
125   - watch: {
126   - initData: {
127   - deep: true,
128   - handler(newVal) {
129   - if (newVal.element && newVal.element !== this.elementId) {
130   - this.elementId = newVal.element
131   - }
132   -
133   - if (this.map) {
134   - this.initMap(newVal)
135   - }
136   - }
137   - }
138   - },
139 137 beforeDestroy() {
140 138 // 组件销毁时清除地图实例
141 139 if (this.map) {
... ...
src/views/dev/mappingList.vue
1 1 <template>
2   - <div class="mapping-container">
  2 + <div class="mapping-container ">
3 3 <div class="menu-group-wrapper">
4 4 <div class="group-content">
5 5 <el-menu :default-active="searchForm.domain" class="group-menu" @select="handleDomain">
... ... @@ -179,7 +179,7 @@ export default {
179 179  
180 180 <style lang="scss" scoped>
181 181 .mapping-container {
182   - padding: 0;
  182 + padding: 15px;
183 183 margin: 0;
184 184 display: flex;
185 185 background-color: #f0f2f5;
... ...
src/views/inspection/inspectionPointList.vue
... ... @@ -8,10 +8,10 @@
8 8 <el-input :placeholder="$t('inspectionPoint.placeholder.inspectionName')"
9 9 v-model="inspectionPointInfo.conditions.inspectionName" clearable />
10 10 </div>
11   - <el-button type="primary" class="margin-left-xs" size="small" @click="_queryInspectionPointMethod()">
  11 + <el-button type="text" class="margin-left-xs" size="small" @click="_queryInspectionPointMethod()">
12 12 {{ $t('common.search') }}
13 13 </el-button>
14   - <el-button type="primary" class="margin-left-xs" size="small" @click="_openAddInspectionPointModal()">
  14 + <el-button type="text" class="margin-left-xs" size="small" @click="_openAddInspectionPointModal()">
15 15 {{ $t('common.add') }}
16 16 </el-button>
17 17 </div>
... ... @@ -118,10 +118,10 @@
118 118 </el-col>
119 119 </el-row>
120 120 <!-- 模态框组件 -->
121   - <add-inspection-point ref="addInspectionPoint" />
122   - <edit-inspection-point ref="editInspectionPoint" />
123   - <delete-inspection-point ref="deleteInspectionPoint" />
124   - <inspection-point-qr-code ref="inspectionPointQrCode" />
  121 + <add-inspection-point ref="addInspectionPoint" @success="_listInspectionPoints"/>
  122 + <edit-inspection-point ref="editInspectionPoint" @success="_listInspectionPoints"/>
  123 + <delete-inspection-point ref="deleteInspectionPoint" @success="_listInspectionPoints"/>
  124 + <inspection-point-qr-code ref="inspectionPointQrCode" @success="_listInspectionPoints"/>
125 125 </div>
126 126 </template>
127 127  
... ... @@ -257,9 +257,7 @@ export default {
257 257 }
258 258  
259 259 .vc-org {
260   - border: 1px solid #ebeef5;
261   - border-radius: 4px;
262   - padding: 10px;
  260 + padding: 5px;
263 261 max-height: 600px;
264 262 overflow-y: auto;
265 263 }
... ... @@ -285,8 +283,8 @@ export default {
285 283 }
286 284  
287 285 .point-list li.active {
288   - background-color: #ecf5ff;
289   - color: #409eff;
  286 + background-color: #409eff;
  287 + color: #ecf5ff;
290 288 font-weight: bold;
291 289 }
292 290  
... ... @@ -301,6 +299,5 @@ export default {
301 299 .col-form-label {
302 300 display: inline-block;
303 301 margin-right: 10px;
304   - font-weight: bold;
305 302 }
306 303 </style>
307 304 \ No newline at end of file
... ...