Showing
16 changed files
with
58 additions
and
72 deletions
... | ... | @@ -81,8 +81,8 @@ |
81 | 81 | size="small" |
82 | 82 | placeholder="请选择您要使用的图标" |
83 | 83 | style="width: 250px" |
84 | - :value="typeMarkerValue" | |
85 | - :options="typeMarkerOptions" | |
84 | + :value="iconMarkerValue" | |
85 | + :options="iconMarkerOptions" | |
86 | 86 | :render-label="renderOption" |
87 | 87 | clearable |
88 | 88 | filterable |
... | ... | @@ -92,16 +92,6 @@ |
92 | 92 | </setting-item-box> |
93 | 93 | <setting-item-box name="弹窗选择" v-if="optionData.mapOptions.mapMarkerType === MarkerEnum.MARKER"> |
94 | 94 | <setting-item name="弹窗选择"> |
95 | - <!-- <NSelect | |
96 | - size="small" | |
97 | - placeholder="请选择您要使用的弹窗" | |
98 | - style="width: 250px" | |
99 | - :value="mapSelectBorderValue" | |
100 | - :options="mapSelectBorderOption.option" | |
101 | - @update:value="mapSelectBorderHandle" | |
102 | - clearable | |
103 | - filterable | |
104 | - /> --> | |
105 | 95 | <NSelect |
106 | 96 | size="small" |
107 | 97 | placeholder="请选择您要使用的弹窗" |
... | ... | @@ -119,7 +109,7 @@ |
119 | 109 | </template> |
120 | 110 | |
121 | 111 | <script setup lang="ts"> |
122 | -import { PropType, ref, computed, h, onMounted, reactive } from 'vue' | |
112 | +import { PropType, ref, computed, h, onMounted } from 'vue' | |
123 | 113 | import { option, MarkerEnum, ThemeEnum, LangEnum, ViewModeEnum, FeaturesEnum } from './config' |
124 | 114 | import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' |
125 | 115 | import { NEllipsis, NImage, NSelect, NSpace, SelectOption } from 'naive-ui' |
... | ... | @@ -234,7 +224,7 @@ const featuresOptions = [ |
234 | 224 | const MarkerOptions = [ |
235 | 225 | // { |
236 | 226 | // value: MarkerEnum.CIRCLE_MARKER, |
237 | - // label: '圆形标点' | |
227 | + // label: '圆形标点' //在地图里点击无效,所以注释,有需要自行打开即可 | |
238 | 228 | // }, |
239 | 229 | { |
240 | 230 | value: MarkerEnum.MARKER, |
... | ... | @@ -246,17 +236,7 @@ const MarkerOptions = [ |
246 | 236 | } |
247 | 237 | ] |
248 | 238 | |
249 | -onMounted(() => { | |
250 | - props.optionData.mapOptions.typeMarker = getMarkerImagePath(props.optionData.mapOptions.typeMarker || 'position1.png') | |
251 | - typeMarkerValue.value = props.optionData.mapOptions.typeMarker || 'position1.png' | |
252 | - mapSelectBorderValue.value = | |
253 | - `${props.optionData.mapOptions.mpBorderConfig.value.toLocaleLowerCase()}.png` || 'border01.png' | |
254 | -}) | |
255 | - | |
256 | -const typeMarkerValue = ref<string | null>('position1.png') | |
257 | - | |
258 | -const mapSelectBorderValue = ref<string | null>('border01.png') | |
259 | - | |
239 | +/**通用函数封装 */ | |
260 | 240 | const isHref = (url: string) => { |
261 | 241 | try { |
262 | 242 | new URL(url) |
... | ... | @@ -265,81 +245,87 @@ const isHref = (url: string) => { |
265 | 245 | return false |
266 | 246 | } |
267 | 247 | } |
248 | +const renderCommonOption = (option: SelectOption, src: string) => { | |
249 | + return h(NSpace, { justify: 'space-between', style: 'padding: 0 15px; height: 28px; line-height: 28px;' }, () => [ | |
250 | + h(NImage, { | |
251 | + width: 25, | |
252 | + src, | |
253 | + previewDisabled: true, | |
254 | + style: { height: '25px' } | |
255 | + } as Recordable), | |
256 | + h(NEllipsis, null, () => option.label) | |
257 | + ]) | |
258 | +} | |
259 | +const getImagePath = (path: string, name: string) => { | |
260 | + return isHref(name) ? name : new URL(`${path}/${name}`, import.meta.url).href | |
261 | +} | |
262 | +/** */ | |
268 | 263 | |
269 | -// import.meta.glob 这个不能封装,必须是字符串,不能通过传值传进去 | |
270 | -const typeMarkerOptions = computed(() => { | |
264 | +/** 图标选择 */ | |
265 | +const iconMarkerValue = ref<string | null>('1.png') | |
266 | + | |
267 | +// import.meta.glob 这里没有封装,不能通过传值传进去 | |
268 | +const iconMarkerOptions = computed(() => { | |
271 | 269 | const pathList = import.meta.glob('./images/marker/*') |
272 | 270 | return Object.keys(pathList).map(item => { |
273 | 271 | const imgName = item.split('/').at(-1) |
274 | 272 | return { |
275 | 273 | label: imgName, |
276 | 274 | value: imgName |
277 | - } as SelectOption | |
275 | + } | |
278 | 276 | }) |
279 | 277 | }) |
280 | 278 | // |
281 | 279 | |
282 | -const getMarkerImagePath = (name: string) => { | |
283 | - return isHref(name) ? name : new URL(`./images/marker/${name}`, import.meta.url).href | |
284 | -} | |
280 | +const getMarkerImagePath = (name: string) => getImagePath('./images/marker', name) | |
285 | 281 | |
286 | -const renderOption = (option: SelectOption) => { | |
287 | - return h(NSpace, { justify: 'space-between', style: 'padding: 0 15px; height: 28px; line-height: 28px;' }, () => [ | |
288 | - h(NImage, { | |
289 | - width: 25, | |
290 | - src: getMarkerImagePath(option.value as string), | |
291 | - previewDisabled: true, | |
292 | - style: { height: '25px' } | |
293 | - } as Recordable), | |
294 | - h(NEllipsis, null, () => option.label) | |
295 | - ]) | |
296 | -} | |
282 | +const renderOption = (option: SelectOption) => renderCommonOption(option, getMarkerImagePath(option.value as string)) | |
297 | 283 | |
298 | 284 | const selectHandle = (value: string) => { |
299 | - typeMarkerValue.value = value | |
300 | - props.optionData.mapOptions.typeMarker = getMarkerImagePath(value) | |
285 | + iconMarkerValue.value = value | |
286 | + props.optionData.mapOptions.iconMarker = getMarkerImagePath(value) | |
301 | 287 | } |
288 | +/** */ | |
289 | + | |
290 | +/** 弹窗选择 */ | |
291 | +const mapSelectBorderValue = ref<string | null>('border01.png') | |
302 | 292 | |
303 | 293 | const needBorder = ['border01.png', 'border02.png', 'border03.png', 'border05.png', 'border07.png'] |
304 | 294 | |
305 | -// import.meta.glob 这个不能封装,必须是字符串,不能通过传值传进去 | |
295 | +// import.meta.glob 这里没有封装,不能通过传值传进去 | |
306 | 296 | const mapBorderOptions = computed(() => { |
307 | 297 | const pathList = import.meta.glob('../../../../../../assets/images/chart/decorates/*') |
308 | 298 | return Object.keys(pathList) |
309 | 299 | .map(item => { |
310 | 300 | const imgName = item.split('/').at(-1) as string |
311 | - if (needBorder.includes(imgName)) { | |
312 | - return { | |
313 | - label: imgName, | |
314 | - value: imgName | |
315 | - } as SelectOption | |
316 | - } | |
301 | + if (!needBorder.includes(imgName)) return | |
302 | + return { | |
303 | + label: imgName, | |
304 | + value: imgName | |
305 | + } as SelectOption | |
317 | 306 | }) |
318 | 307 | .filter(Boolean) as SelectOption[] |
319 | 308 | }) |
320 | 309 | // |
321 | 310 | |
322 | -const getMapBorderImagePath = (name: string) => { | |
323 | - return isHref(name) ? name : new URL(`../../../../../../assets/images/chart/decorates/${name}`, import.meta.url).href | |
324 | -} | |
311 | +const getMapBorderImagePath = (name: string) => getImagePath('../../../../../../assets/images/chart/decorates', name) | |
325 | 312 | |
326 | -const renderMapBorderOption = (option: SelectOption) => { | |
327 | - return h(NSpace, { justify: 'space-between', style: 'padding: 0 15px; height: 28px; line-height: 28px;' }, () => [ | |
328 | - h(NImage, { | |
329 | - width: 25, | |
330 | - src: getMapBorderImagePath(option.value as string), | |
331 | - previewDisabled: true, | |
332 | - style: { height: '25px' } | |
333 | - } as Recordable), | |
334 | - h(NEllipsis, null, () => option.label) | |
335 | - ]) | |
336 | -} | |
313 | +const renderMapBorderOption = (option: SelectOption) => | |
314 | + renderCommonOption(option, getMapBorderImagePath(option.value as string)) | |
337 | 315 | |
338 | 316 | const selectMapBorderHandle = (value: string) => { |
339 | 317 | mapSelectBorderValue.value = value |
340 | 318 | const toLowerValue = value.toLocaleLowerCase() |
341 | 319 | ;(props.optionData.mapOptions.mpBorderConfig as BaseSelectBorderIF) = { |
342 | - value: toLowerValue[0]?.toUpperCase() + toLowerValue?.substr(1)?.split('.')[0] | |
343 | - } | |
320 | + value: toLowerValue[0]?.toUpperCase() + toLowerValue?.substring(1)?.split('.')[0] | |
321 | + } //这里首字母转大写,动态引入时匹配对应目录也是大写字母开头,即components\Decorates\Borders\Border01 | |
344 | 322 | } |
323 | +/** */ | |
324 | + | |
325 | +onMounted(() => { | |
326 | + iconMarkerValue.value = props.optionData.mapOptions.iconMarker?.split('/')?.at(-1) as string | |
327 | + props.optionData.mapOptions.iconMarker = getMarkerImagePath(iconMarkerValue.value) | |
328 | + mapSelectBorderValue.value = `${props.optionData.mapOptions.mpBorderConfig.value?.toLocaleLowerCase()}.png` | |
329 | + props.optionData.mapOptions.mpBorderConfig.value = getMarkerImagePath(mapSelectBorderValue.value) | |
330 | +}) | |
345 | 331 | </script> | ... | ... |
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/1.png
renamed from
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position1.png
1.24 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/2.png
renamed from
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position2.png
1.4 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/3.png
renamed from
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position3.png
904 Bytes
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/4.png
renamed from
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position4.png
1.02 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/5.png
renamed from
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position5.png
970 Bytes
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position10.png
deleted
100644 → 0
1.2 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position11.png
deleted
100644 → 0
1.12 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position12.png
deleted
100644 → 0
1.93 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position13.png
deleted
100644 → 0
1.43 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position6.png
deleted
100644 → 0
1.51 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position7.png
deleted
100644 → 0
1.3 KB
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position8.png
deleted
100644 → 0
897 Bytes
src/packages/components/external/Charts/Maps/OverrideMapAmap/images/marker/position9.png
deleted
100644 → 0
1.61 KB
... | ... | @@ -16,7 +16,7 @@ import { isArray } from '@/utils' |
16 | 16 | import djh from './images/djh.png' |
17 | 17 | import online from './images/online.png' |
18 | 18 | import lx1 from './images/lx1.png' |
19 | -import positionImg from './images/marker/position1.png' | |
19 | +import positionImg from './images/marker/1.png' | |
20 | 20 | import { getDeviceActiveTime, getDeviceList } from '@/api/external/common/index' |
21 | 21 | import dayjs from 'dayjs' |
22 | 22 | import SearchBox from './components/SearchBox.vue' |
... | ... | @@ -46,7 +46,7 @@ let { |
46 | 46 | pitch, |
47 | 47 | skyColor, |
48 | 48 | marker, |
49 | - typeMarker, | |
49 | + iconMarker, | |
50 | 50 | mpBorderConfig |
51 | 51 | } = toRefs(props.chartConfig.option.mapOptions) |
52 | 52 | |
... | ... | @@ -104,7 +104,7 @@ const createInfoWindow = async (extraInfo: dataExtraInfoType) => { |
104 | 104 | const res = await getDeviceActiveTime(tbDeviceId) //查询设备最后离线时间 |
105 | 105 | let { lastUpdateTs } = res[0] |
106 | 106 | const lastUpdateFormatTs = dayjs(lastUpdateTs).format('YYYY-MM-DD HH:mm:ss') |
107 | - //render方式渲染小组件里的边框组件 | |
107 | + //以render方式渲染小组件里的边框组件 | |
108 | 108 | const BorderInstance = await import(`../../../../Decorates/Borders/${mpBorderConfig.value.value}/index.vue`) |
109 | 109 | const config = await import(`../../../../Decorates/Borders/${mpBorderConfig.value.value}/config.ts`) |
110 | 110 | const BorderConfigInstance = new config.default() |
... | ... | @@ -201,7 +201,7 @@ const dataHandle = (newData: dataJsonType) => { |
201 | 201 | const markerInstance = new AMapIns.Marker({ |
202 | 202 | position: [markerItem.position[0], markerItem.position[1]], |
203 | 203 | offset: new AMapIns.Pixel(-13, -30), |
204 | - icon: typeMarker.value || positionImg | |
204 | + icon: iconMarker.value || positionImg | |
205 | 205 | }) |
206 | 206 | // markers.push(markerInstance) 原作者这种方式添加,属于JS API 1.4.8版本的 |
207 | 207 | // markerInstance.setMap(mapIns) | ... | ... |