Commit 1dc4b8ec77fa5f86d7215f348a8c9a9daea7be15
Merge branch 'ft' into 'main_dev'
fix(src/packages): 修改设备分布地图和3d地图,返回图标问题 See merge request yunteng/thingskit-view!135
Showing
6 changed files
with
128 additions
and
51 deletions
@@ -43,6 +43,9 @@ export const option = { | @@ -43,6 +43,9 @@ export const option = { | ||
43 | iconDistanceTop: 20, | 43 | iconDistanceTop: 20, |
44 | drillingIn: false, | 44 | drillingIn: false, |
45 | dataset: dataMaps, | 45 | dataset: dataMaps, |
46 | + saveClickRegion: { | ||
47 | + level: '' | ||
48 | + }, | ||
46 | mapRegion: { | 49 | mapRegion: { |
47 | adcode: 'china', | 50 | adcode: 'china', |
48 | showHainanIsLands: true, | 51 | showHainanIsLands: true, |
@@ -41,7 +41,7 @@ const toolBoxOption = ref({ | @@ -41,7 +41,7 @@ const toolBoxOption = ref({ | ||
41 | top: 20, | 41 | top: 20, |
42 | feature: { | 42 | feature: { |
43 | myFullButton: { | 43 | myFullButton: { |
44 | - show: true, | 44 | + show: false, |
45 | title: '返回', | 45 | title: '返回', |
46 | icon: iconStr.value, | 46 | icon: iconStr.value, |
47 | iconStyle: { | 47 | iconStyle: { |
@@ -55,8 +55,34 @@ const toolBoxOption = ref({ | @@ -55,8 +55,34 @@ const toolBoxOption = ref({ | ||
55 | watch( | 55 | watch( |
56 | () => props.chartConfig.option, | 56 | () => props.chartConfig.option, |
57 | newData => { | 57 | newData => { |
58 | - const { iconColor, drillingIn, iconDistanceRight, iconDistanceTop } = newData | ||
59 | - toolBoxOption.value.feature.myFullButton.show = drillingIn | 58 | + const { iconColor, drillingIn, iconDistanceRight, iconDistanceTop, mapRegion } = newData |
59 | + if (drillingIn && !newData.saveClickRegion.level) { | ||
60 | + toolBoxOption.value.feature.myFullButton.show = !drillingIn | ||
61 | + } else if ( | ||
62 | + drillingIn && | ||
63 | + newData.saveClickRegion.level === areaEnum.PROVINCE && | ||
64 | + mapRegion.saveSelect.levelStr === areaEnum.COUNTRY | ||
65 | + ) { | ||
66 | + toolBoxOption.value.feature.myFullButton.show = drillingIn | ||
67 | + } else if ( | ||
68 | + drillingIn && | ||
69 | + newData.saveClickRegion.level === areaEnum.COUNTRY && | ||
70 | + mapRegion.saveSelect.levelStr === areaEnum.COUNTRY | ||
71 | + ) { | ||
72 | + toolBoxOption.value.feature.myFullButton.show = !drillingIn | ||
73 | + } else if ( | ||
74 | + drillingIn && | ||
75 | + newData.saveClickRegion.level === areaEnum.CITY && | ||
76 | + mapRegion.saveSelect.levelStr === areaEnum.PROVINCE | ||
77 | + ) { | ||
78 | + toolBoxOption.value.feature.myFullButton.show = drillingIn | ||
79 | + } else if ( | ||
80 | + drillingIn && | ||
81 | + newData.saveClickRegion.level === areaEnum.PROVINCE && | ||
82 | + mapRegion.saveSelect.levelStr === areaEnum.PROVINCE | ||
83 | + ) { | ||
84 | + toolBoxOption.value.feature.myFullButton.show = !drillingIn | ||
85 | + } | ||
60 | toolBoxOption.value.feature.myFullButton.iconStyle.color = iconColor | 86 | toolBoxOption.value.feature.myFullButton.iconStyle.color = iconColor |
61 | toolBoxOption.value.right = iconDistanceRight | 87 | toolBoxOption.value.right = iconDistanceRight |
62 | toolBoxOption.value.top = iconDistanceTop | 88 | toolBoxOption.value.top = iconDistanceTop |
@@ -89,6 +115,7 @@ const watchAdcode = async () => { | @@ -89,6 +115,7 @@ const watchAdcode = async () => { | ||
89 | } | 115 | } |
90 | const exist = await getGeojson(saveAdcode) | 116 | const exist = await getGeojson(saveAdcode) |
91 | const adcode = saveAdcode === 100000 ? 'china' : saveAdcode | 117 | const adcode = saveAdcode === 100000 ? 'china' : saveAdcode |
118 | + props.chartConfig.option.saveClickRegion.level = saveLevelStr.level | ||
92 | if (exist) { | 119 | if (exist) { |
93 | //fix解决点击下钻返回后页面为空问题 | 120 | //fix解决点击下钻返回后页面为空问题 |
94 | props.chartConfig.option.mapRegion.adcode = adcode | 121 | props.chartConfig.option.mapRegion.adcode = adcode |
@@ -114,6 +141,7 @@ const handleMap3DClick = async (params: Recordable) => { | @@ -114,6 +141,7 @@ const handleMap3DClick = async (params: Recordable) => { | ||
114 | if (level === 'DISTRICT') return | 141 | if (level === 'DISTRICT') return |
115 | if (String(adcode).startsWith('15') && level === areaEnum.CITY) return | 142 | if (String(adcode).startsWith('15') && level === areaEnum.CITY) return |
116 | props.chartConfig.option.mapRegion.adcode = adcode | 143 | props.chartConfig.option.mapRegion.adcode = adcode |
144 | + props.chartConfig.option.saveClickRegion.level = level | ||
117 | saveLevelStr.level = level | 145 | saveLevelStr.level = level |
118 | handleDataPoint(adcode) | 146 | handleDataPoint(adcode) |
119 | saveHistoryParent.value.push({ | 147 | saveHistoryParent.value.push({ |
@@ -215,8 +243,18 @@ onMounted(() => { | @@ -215,8 +243,18 @@ onMounted(() => { | ||
215 | const handleDataPoint = (newData: string | number) => { | 243 | const handleDataPoint = (newData: string | number) => { |
216 | if (newData === 'china') { | 244 | if (newData === 'china') { |
217 | props.chartConfig.option.dataset = dataMaps | 245 | props.chartConfig.option.dataset = dataMaps |
246 | + props.chartConfig.option.series.forEach((item: Recordable) => { | ||
247 | + if (item.type === 'scatter3D') { | ||
248 | + item.data = dataMaps | ||
249 | + } | ||
250 | + }) | ||
218 | } else { | 251 | } else { |
219 | props.chartConfig.option.dataset = dataMaps.filter((item: dataPointI) => item.adcode === newData) | 252 | props.chartConfig.option.dataset = dataMaps.filter((item: dataPointI) => item.adcode === newData) |
253 | + props.chartConfig.option.series.forEach((item: Recordable) => { | ||
254 | + if (item.type === 'scatter3D') { | ||
255 | + item.data = dataMaps.filter((item: dataPointI) => item.adcode === newData) | ||
256 | + } | ||
257 | + }) | ||
220 | } | 258 | } |
221 | } | 259 | } |
222 | 260 |
@@ -241,7 +241,8 @@ const MarkerOptions = [ | @@ -241,7 +241,8 @@ const MarkerOptions = [ | ||
241 | } | 241 | } |
242 | ] | 242 | ] |
243 | 243 | ||
244 | -/**通用函数封装 */ | 244 | +const iconMarkerValue = ref<string | null>('1.png') |
245 | + | ||
245 | const isHref = (url: string) => { | 246 | const isHref = (url: string) => { |
246 | try { | 247 | try { |
247 | new URL(url) | 248 | new URL(url) |
@@ -250,26 +251,8 @@ const isHref = (url: string) => { | @@ -250,26 +251,8 @@ const isHref = (url: string) => { | ||
250 | return false | 251 | return false |
251 | } | 252 | } |
252 | } | 253 | } |
253 | -const renderCommonOption = (option: SelectOption, src: string) => { | ||
254 | - return h(NSpace, { justify: 'space-between', style: 'padding: 0 15px; height: 28px; line-height: 28px;' }, () => [ | ||
255 | - h(NImage, { | ||
256 | - width: 25, | ||
257 | - src, | ||
258 | - previewDisabled: true, | ||
259 | - style: { height: '25px' } | ||
260 | - } as Recordable), | ||
261 | - h(NEllipsis, null, () => option.label) | ||
262 | - ]) | ||
263 | -} | ||
264 | -const getImagePath = (path: string, name: string) => { | ||
265 | - return isHref(name) ? name : new URL(`${path}/${name}`, import.meta.url).href | ||
266 | -} | ||
267 | -/** */ | ||
268 | - | ||
269 | -/** 图标选择 */ | ||
270 | -const iconMarkerValue = ref<string | null>('1.png') | ||
271 | 254 | ||
272 | -// import.meta.glob 这里没有封装,不能通过传值传进去 | 255 | +// import.meta.glob 这个不能封装,必须是字符串,不能通过传值传进去 |
273 | const iconMarkerOptions = computed(() => { | 256 | const iconMarkerOptions = computed(() => { |
274 | const pathList = import.meta.glob('./images/marker/*') | 257 | const pathList = import.meta.glob('./images/marker/*') |
275 | return Object.keys(pathList).map(item => { | 258 | return Object.keys(pathList).map(item => { |
@@ -277,55 +260,76 @@ const iconMarkerOptions = computed(() => { | @@ -277,55 +260,76 @@ const iconMarkerOptions = computed(() => { | ||
277 | return { | 260 | return { |
278 | label: imgName, | 261 | label: imgName, |
279 | value: imgName | 262 | value: imgName |
280 | - } | 263 | + } as SelectOption |
281 | }) | 264 | }) |
282 | }) | 265 | }) |
283 | // | 266 | // |
284 | 267 | ||
285 | -const getMarkerImagePath = (name: string) => getImagePath('./images/marker', name) | 268 | +const getMarkerImagePath = (name: string) => { |
269 | + return isHref(name) ? name : new URL(`./images/marker/${name}`, import.meta.url).href | ||
270 | +} | ||
286 | 271 | ||
287 | -const renderOption = (option: SelectOption) => renderCommonOption(option, getMarkerImagePath(option.value as string)) | 272 | +const renderOption = (option: SelectOption) => { |
273 | + return h(NSpace, { justify: 'space-between', style: 'padding: 0 15px; height: 28px; line-height: 28px;' }, () => [ | ||
274 | + h(NImage, { | ||
275 | + width: 25, | ||
276 | + src: getMarkerImagePath(option.value as string), | ||
277 | + previewDisabled: true, | ||
278 | + style: { height: '25px' } | ||
279 | + } as Recordable), | ||
280 | + h(NEllipsis, null, () => option.label) | ||
281 | + ]) | ||
282 | +} | ||
288 | 283 | ||
289 | const selectHandle = (value: string) => { | 284 | const selectHandle = (value: string) => { |
290 | iconMarkerValue.value = value | 285 | iconMarkerValue.value = value |
291 | props.optionData.mapOptions.iconMarker = getMarkerImagePath(value) | 286 | props.optionData.mapOptions.iconMarker = getMarkerImagePath(value) |
292 | } | 287 | } |
293 | -/** */ | ||
294 | 288 | ||
295 | -/** 弹窗选择 */ | ||
296 | const mapSelectBorderValue = ref<string | null>('border01.png') | 289 | const mapSelectBorderValue = ref<string | null>('border01.png') |
297 | 290 | ||
298 | const needBorder = ['border01.png', 'border02.png', 'border03.png', 'border05.png', 'border07.png'] | 291 | const needBorder = ['border01.png', 'border02.png', 'border03.png', 'border05.png', 'border07.png'] |
299 | 292 | ||
300 | -// import.meta.glob 这里没有封装,不能通过传值传进去 | 293 | +// import.meta.glob 这个不能封装,必须是字符串,不能通过传值传进去 |
301 | const mapBorderOptions = computed(() => { | 294 | const mapBorderOptions = computed(() => { |
302 | const pathList = import.meta.glob('../../../../../../assets/images/chart/decorates/*') | 295 | const pathList = import.meta.glob('../../../../../../assets/images/chart/decorates/*') |
303 | return Object.keys(pathList) | 296 | return Object.keys(pathList) |
304 | .map(item => { | 297 | .map(item => { |
305 | const imgName = item.split('/').at(-1) as string | 298 | const imgName = item.split('/').at(-1) as string |
306 | - if (!needBorder.includes(imgName)) return | ||
307 | - return { | ||
308 | - label: imgName, | ||
309 | - value: imgName | ||
310 | - } as SelectOption | 299 | + if (needBorder.includes(imgName)) { |
300 | + return { | ||
301 | + label: imgName, | ||
302 | + value: imgName | ||
303 | + } as SelectOption | ||
304 | + } | ||
311 | }) | 305 | }) |
312 | .filter(Boolean) as SelectOption[] | 306 | .filter(Boolean) as SelectOption[] |
313 | }) | 307 | }) |
314 | // | 308 | // |
315 | 309 | ||
316 | -const getMapBorderImagePath = (name: string) => getImagePath('../../../../../../assets/images/chart/decorates', name) | 310 | +const getMapBorderImagePath = (name: string) => { |
311 | + return isHref(name) ? name : new URL(`../../../../../../assets/images/chart/decorates/${name}`, import.meta.url).href | ||
312 | +} | ||
317 | 313 | ||
318 | -const renderMapBorderOption = (option: SelectOption) => | ||
319 | - renderCommonOption(option, getMapBorderImagePath(option.value as string)) | 314 | +const renderMapBorderOption = (option: SelectOption) => { |
315 | + return h(NSpace, { justify: 'space-between', style: 'padding: 0 15px; height: 28px; line-height: 28px;' }, () => [ | ||
316 | + h(NImage, { | ||
317 | + width: 25, | ||
318 | + src: getMapBorderImagePath(option.value as string), | ||
319 | + previewDisabled: true, | ||
320 | + style: { height: '25px' } | ||
321 | + } as Recordable), | ||
322 | + h(NEllipsis, null, () => option.label) | ||
323 | + ]) | ||
324 | +} | ||
320 | 325 | ||
321 | const selectMapBorderHandle = (value: string) => { | 326 | const selectMapBorderHandle = (value: string) => { |
322 | mapSelectBorderValue.value = value | 327 | mapSelectBorderValue.value = value |
323 | const toLowerValue = value.toLocaleLowerCase() | 328 | const toLowerValue = value.toLocaleLowerCase() |
324 | ;(props.optionData.mapOptions.mpBorderConfig as BaseSelectBorderIF) = { | 329 | ;(props.optionData.mapOptions.mpBorderConfig as BaseSelectBorderIF) = { |
325 | - value: toLowerValue[0]?.toUpperCase() + toLowerValue?.substring(1)?.split('.')[0] | ||
326 | - } //这里首字母转大写,动态引入时匹配对应目录也是大写字母开头,即components\Decorates\Borders\Border01 | 330 | + value: toLowerValue[0]?.toUpperCase() + toLowerValue?.substr(1)?.split('.')[0] |
331 | + } | ||
327 | } | 332 | } |
328 | -/** */ | ||
329 | 333 | ||
330 | onMounted(() => { | 334 | onMounted(() => { |
331 | iconMarkerValue.value = props.optionData.mapOptions.iconMarker?.split('/')?.at(-1) as string | 335 | iconMarkerValue.value = props.optionData.mapOptions.iconMarker?.split('/')?.at(-1) as string |
@@ -8,7 +8,7 @@ export const OverrideMapAmapConfig: ConfigType = { | @@ -8,7 +8,7 @@ export const OverrideMapAmapConfig: ConfigType = { | ||
8 | key, | 8 | key, |
9 | chartKey, | 9 | chartKey, |
10 | conKey, | 10 | conKey, |
11 | - title: '高德地图', | 11 | + title: '设备分布', |
12 | category: ChatCategoryEnum.MAP, | 12 | category: ChatCategoryEnum.MAP, |
13 | categoryName: ChatCategoryEnumName.MAP, | 13 | categoryName: ChatCategoryEnumName.MAP, |
14 | package: PackagesCategoryEnum.CHARTS, | 14 | package: PackagesCategoryEnum.CHARTS, |
@@ -7,11 +7,11 @@ import dataJson from './data.json' | @@ -7,11 +7,11 @@ import dataJson from './data.json' | ||
7 | 7 | ||
8 | //省市区枚举 | 8 | //省市区枚举 |
9 | export const enum areaEnum { | 9 | export const enum areaEnum { |
10 | - PROVINCE = 'PROVINCE',//省份 | ||
11 | - CITY = 'CITY',//城市 | ||
12 | - COUNTY = 'COUNTY',//县 | ||
13 | - COUNTRY = 'COUNTRY',//国家 | ||
14 | - TOWN = 'TOWN'//镇 | 10 | + PROVINCE = 'PROVINCE', //省份 |
11 | + CITY = 'CITY', //城市 | ||
12 | + COUNTY = 'COUNTY', //县 | ||
13 | + COUNTRY = 'COUNTRY', //国家 | ||
14 | + TOWN = 'TOWN' //镇 | ||
15 | } | 15 | } |
16 | export const includes = [] | 16 | export const includes = [] |
17 | 17 | ||
@@ -22,6 +22,9 @@ export const option = { | @@ -22,6 +22,9 @@ export const option = { | ||
22 | iconDistanceTop: 20, | 22 | iconDistanceTop: 20, |
23 | drillingIn: false, | 23 | drillingIn: false, |
24 | dataset: dataJson, | 24 | dataset: dataJson, |
25 | + saveClickRegion: { | ||
26 | + level: '' | ||
27 | + }, | ||
25 | mapRegion: { | 28 | mapRegion: { |
26 | adcode: 'china', | 29 | adcode: 'china', |
27 | showHainanIsLands: true, | 30 | showHainanIsLands: true, |
@@ -74,7 +74,7 @@ const toolBoxOption = ref({ | @@ -74,7 +74,7 @@ const toolBoxOption = ref({ | ||
74 | top: 20, | 74 | top: 20, |
75 | feature: { | 75 | feature: { |
76 | myFullButton: { | 76 | myFullButton: { |
77 | - show: true, | 77 | + show: false, |
78 | title: '返回', | 78 | title: '返回', |
79 | icon: iconStr.value, | 79 | icon: iconStr.value, |
80 | iconStyle: { | 80 | iconStyle: { |
@@ -88,22 +88,49 @@ const toolBoxOption = ref({ | @@ -88,22 +88,49 @@ const toolBoxOption = ref({ | ||
88 | watch( | 88 | watch( |
89 | () => props.chartConfig.option, | 89 | () => props.chartConfig.option, |
90 | newData => { | 90 | newData => { |
91 | - const { iconColor, drillingIn, iconDistanceRight, iconDistanceTop } = newData | ||
92 | - toolBoxOption.value.feature.myFullButton.show = drillingIn | 91 | + const { iconColor, drillingIn, iconDistanceRight, iconDistanceTop, mapRegion } = newData |
92 | + if (drillingIn && !newData.saveClickRegion.level) { | ||
93 | + toolBoxOption.value.feature.myFullButton.show = !drillingIn | ||
94 | + } else if ( | ||
95 | + drillingIn && | ||
96 | + newData.saveClickRegion.level === areaEnum.PROVINCE && | ||
97 | + mapRegion.saveSelect.levelStr === areaEnum.COUNTRY | ||
98 | + ) { | ||
99 | + toolBoxOption.value.feature.myFullButton.show = drillingIn | ||
100 | + } else if ( | ||
101 | + drillingIn && | ||
102 | + newData.saveClickRegion.level === areaEnum.COUNTRY && | ||
103 | + mapRegion.saveSelect.levelStr === areaEnum.COUNTRY | ||
104 | + ) { | ||
105 | + toolBoxOption.value.feature.myFullButton.show = !drillingIn | ||
106 | + } else if ( | ||
107 | + drillingIn && | ||
108 | + newData.saveClickRegion.level === areaEnum.CITY && | ||
109 | + mapRegion.saveSelect.levelStr === areaEnum.PROVINCE | ||
110 | + ) { | ||
111 | + toolBoxOption.value.feature.myFullButton.show = drillingIn | ||
112 | + } else if ( | ||
113 | + drillingIn && | ||
114 | + newData.saveClickRegion.level === areaEnum.PROVINCE && | ||
115 | + mapRegion.saveSelect.levelStr === areaEnum.PROVINCE | ||
116 | + ) { | ||
117 | + toolBoxOption.value.feature.myFullButton.show = !drillingIn | ||
118 | + } | ||
93 | toolBoxOption.value.feature.myFullButton.iconStyle.color = iconColor | 119 | toolBoxOption.value.feature.myFullButton.iconStyle.color = iconColor |
94 | toolBoxOption.value.right = iconDistanceRight | 120 | toolBoxOption.value.right = iconDistanceRight |
95 | toolBoxOption.value.top = iconDistanceTop | 121 | toolBoxOption.value.top = iconDistanceTop |
122 | + vEchartsSetOption() | ||
96 | }, | 123 | }, |
97 | { | 124 | { |
98 | - deep: true | 125 | + deep: true, |
99 | } | 126 | } |
100 | ) | 127 | ) |
101 | - | ||
102 | props.chartConfig.option = { | 128 | props.chartConfig.option = { |
103 | ...props.chartConfig.option, | 129 | ...props.chartConfig.option, |
104 | ...{ toolbox: toolBoxOption.value } | 130 | ...{ toolbox: toolBoxOption.value } |
105 | } | 131 | } |
106 | 132 | ||
133 | + | ||
107 | //地图点击返回 adcode=100000,名字必须是china | 134 | //地图点击返回 adcode=100000,名字必须是china |
108 | const watchAdcode = async () => { | 135 | const watchAdcode = async () => { |
109 | if (props.chartConfig.option.drillingIn) { | 136 | if (props.chartConfig.option.drillingIn) { |
@@ -121,6 +148,7 @@ const watchAdcode = async () => { | @@ -121,6 +148,7 @@ const watchAdcode = async () => { | ||
121 | } | 148 | } |
122 | await getGeojson(saveAdcode) | 149 | await getGeojson(saveAdcode) |
123 | const adcode = saveAdcode === 100000 ? 'china' : saveAdcode | 150 | const adcode = saveAdcode === 100000 ? 'china' : saveAdcode |
151 | + props.chartConfig.option.saveClickRegion.level = saveLevelStr.level | ||
124 | props.chartConfig.option.geo.map = adcode | 152 | props.chartConfig.option.geo.map = adcode |
125 | props.chartConfig.option.series.forEach((item: any) => { | 153 | props.chartConfig.option.series.forEach((item: any) => { |
126 | if (item.type === 'map') item.map = adcode | 154 | if (item.type === 'map') item.map = adcode |
@@ -324,6 +352,7 @@ const handleVChartClick = async (params: any) => { | @@ -324,6 +352,7 @@ const handleVChartClick = async (params: any) => { | ||
324 | if (level === 'DISTRICT') return | 352 | if (level === 'DISTRICT') return |
325 | if (String(adcode).startsWith('15') && level === areaEnum.CITY) return | 353 | if (String(adcode).startsWith('15') && level === areaEnum.CITY) return |
326 | props.chartConfig.option.mapRegion.adcode = adcode | 354 | props.chartConfig.option.mapRegion.adcode = adcode |
355 | + props.chartConfig.option.saveClickRegion.level = level | ||
327 | saveLevelStr.level = level | 356 | saveLevelStr.level = level |
328 | handleDataPoint(adcode) | 357 | handleDataPoint(adcode) |
329 | saveHistoryParent.value.push({ | 358 | saveHistoryParent.value.push({ |