Commit e35f0478e38d041fac09b3dd9afecbf6ed12a99b
1 parent
b94d3b58
fix: DEFECT-793 device location page not found data
Showing
1 changed file
with
39 additions
and
37 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 |