Commit eec24cf864fb0efec0d9cab7c773b664ee2395ec
Merge branch 'ww' into 'main'
ix: DEFECT-793 device location page not found data See merge request huang/yun-teng-iot-front!372
Showing
2 changed files
with
44 additions
and
39 deletions
@@ -149,45 +149,47 @@ | @@ -149,45 +149,47 @@ | ||
149 | showSizeChanger: true, | 149 | showSizeChanger: true, |
150 | }, | 150 | }, |
151 | afterFetch: async (data: DeviceInfo[]) => { | 151 | afterFetch: async (data: DeviceInfo[]) => { |
152 | - const BMap = (window as any).BMap; | ||
153 | - unref(BMapInstance).clearOverlays(); | ||
154 | - const markerList: MarkerList[] = []; | ||
155 | - data.forEach((item) => { | ||
156 | - const { | ||
157 | - name, | ||
158 | - deviceState, | ||
159 | - deviceInfo: { longitude, latitude }, | ||
160 | - } = item; | ||
161 | - const point = new BMap.Point(longitude, latitude); | ||
162 | - const rivet = deviceState === 'INACTIVE' ? djx : deviceState === 'ONLINE' ? zx : lx; | ||
163 | - const myIcon = new BMap.Icon(rivet, new BMap.Size(20, 30)); | ||
164 | - const marker = new BMap.Marker(point, { icon: myIcon }); | ||
165 | - const label = new BMap.Label(name, { | ||
166 | - position: point, | ||
167 | - offset: new BMap.Size(-15, -45), | 152 | + Promise.resolve().then(() => { |
153 | + const BMap = (window as any).BMap; | ||
154 | + unref(BMapInstance).clearOverlays(); | ||
155 | + const markerList: MarkerList[] = []; | ||
156 | + data.forEach((item) => { | ||
157 | + const { | ||
158 | + name, | ||
159 | + deviceState, | ||
160 | + deviceInfo: { longitude, latitude }, | ||
161 | + } = item; | ||
162 | + const point = new BMap.Point(longitude, latitude); | ||
163 | + const rivet = deviceState === 'INACTIVE' ? djx : deviceState === 'ONLINE' ? zx : lx; | ||
164 | + const myIcon = new BMap.Icon(rivet, new BMap.Size(20, 30)); | ||
165 | + const marker = new BMap.Marker(point, { icon: myIcon }); | ||
166 | + const label = new BMap.Label(name, { | ||
167 | + position: point, | ||
168 | + offset: new BMap.Size(-15, -45), | ||
169 | + }); | ||
170 | + label.setStyle({ | ||
171 | + color: '#000', | ||
172 | + borderRadius: '5px', | ||
173 | + borderColor: '#ccc', | ||
174 | + padding: '5px', | ||
175 | + }); | ||
176 | + markerList.push({ ...item, marker, label }); | ||
168 | }); | 177 | }); |
169 | - label.setStyle({ | ||
170 | - color: '#000', | ||
171 | - borderRadius: '5px', | ||
172 | - borderColor: '#ccc', | ||
173 | - padding: '5px', | ||
174 | - }); | ||
175 | - markerList.push({ ...item, marker, label }); | ||
176 | - }); | ||
177 | - | ||
178 | - markerList.forEach((record) => { | ||
179 | - unref(BMapInstance).addOverlay(record.marker); | ||
180 | - unref(BMapInstance).addOverlay(record.label); | ||
181 | - const isAlarmStatus = !!record.alarmStatus; | ||
182 | - if (isAlarmStatus) { | ||
183 | - const alarmStatusClassName = 'device-status__alarm'; | ||
184 | - const className = record.marker.Ec.getAttribute('class'); | ||
185 | - record.marker.Ec.setAttribute('class', `${className} ${alarmStatusClassName}`); | ||
186 | - } | ||
187 | 178 | ||
188 | - //标注监听事件 | ||
189 | - record.marker.addEventListener('click', function () { | ||
190 | - createDeviceInfoWindow(record); | 179 | + markerList.forEach((record) => { |
180 | + unref(BMapInstance).addOverlay(record.marker); | ||
181 | + unref(BMapInstance).addOverlay(record.label); | ||
182 | + const isAlarmStatus = !!record.alarmStatus; | ||
183 | + if (isAlarmStatus) { | ||
184 | + const alarmStatusClassName = 'device-status__alarm'; | ||
185 | + const className = record.marker.Ec.getAttribute('class'); | ||
186 | + record.marker.Ec.setAttribute('class', `${className} ${alarmStatusClassName}`); | ||
187 | + } | ||
188 | + | ||
189 | + //标注监听事件 | ||
190 | + record.marker.addEventListener('click', function () { | ||
191 | + createDeviceInfoWindow(record); | ||
192 | + }); | ||
191 | }); | 193 | }); |
192 | }); | 194 | }); |
193 | 195 |
@@ -96,12 +96,15 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { | @@ -96,12 +96,15 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { | ||
96 | const messageList: SocketMessageItem[] = []; | 96 | const messageList: SocketMessageItem[] = []; |
97 | let cmdId = 0; | 97 | let cmdId = 0; |
98 | groupMapping.forEach((value, key) => { | 98 | groupMapping.forEach((value, key) => { |
99 | - const message = generateMessage(key, cmdId, value.map((item) => item.attribute).join(',')); | 99 | + const message = generateMessage( |
100 | + key, | ||
101 | + cmdId, | ||
102 | + Array.from(new Set(value.map((item) => item.attribute))).join(',') | ||
103 | + ); | ||
100 | messageList.push(message); | 104 | messageList.push(message); |
101 | setCmdId(cmdId, value); | 105 | setCmdId(cmdId, value); |
102 | cmdId++; | 106 | cmdId++; |
103 | }); | 107 | }); |
104 | - console.log(cmdIdMapping); | ||
105 | return messageList; | 108 | return messageList; |
106 | } | 109 | } |
107 | 110 |