Commit 5850144dc0c5abfbec268aba6359078e42754194

Authored by fengwotao
1 parent e128aa24

fix(src/packages): 修改设备分布地图和3d地图,返回图标问题

@@ -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
@@ -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({