接入地图了
This commit is contained in:
		@@ -8,6 +8,7 @@ import ChargingPercent from "./comps/chargingPercent.vue";
 | 
				
			|||||||
import AiEchart from "dui/packages/tools/AiEchart.vue";
 | 
					import AiEchart from "dui/packages/tools/AiEchart.vue";
 | 
				
			||||||
import NavTabs from "./comps/navTabs.vue";
 | 
					import NavTabs from "./comps/navTabs.vue";
 | 
				
			||||||
import AiEchartMap from "dui/packages/tools/AiEchartMap.vue";
 | 
					import AiEchartMap from "dui/packages/tools/AiEchartMap.vue";
 | 
				
			||||||
 | 
					import weiyang from "./weiyang.json";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const handlePercent = v => parseFloat(isNaN(v) ? 0 : v.toFixed(2))
 | 
					const handlePercent = v => parseFloat(isNaN(v) ? 0 : v.toFixed(2))
 | 
				
			||||||
const calcComparePercent = (v = 1, target = 1) => {
 | 
					const calcComparePercent = (v = 1, target = 1) => {
 | 
				
			||||||
@@ -157,6 +158,7 @@ export default {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  data() {
 | 
					  data() {
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
 | 
					      weiyang,
 | 
				
			||||||
      areaId: "",
 | 
					      areaId: "",
 | 
				
			||||||
      integralOrderType: "",
 | 
					      integralOrderType: "",
 | 
				
			||||||
      sta: {},
 | 
					      sta: {},
 | 
				
			||||||
@@ -217,6 +219,36 @@ export default {
 | 
				
			|||||||
    workorderFinishedPercent: v => handlePercent(v.sta.workOrderCountFinish / v.sta.workOrderCount * 100),
 | 
					    workorderFinishedPercent: v => handlePercent(v.sta.workOrderCountFinish / v.sta.workOrderCount * 100),
 | 
				
			||||||
    spDistributionTotal: v => v.chartData.spDistribution?.reduce((a, b) => a + b.c, 0) || 0,
 | 
					    spDistributionTotal: v => v.chartData.spDistribution?.reduce((a, b) => a + b.c, 0) || 0,
 | 
				
			||||||
    wotDistributionTotal: v => v.chartData.wotDistribution?.reduce((a, b) => a + b.c, 0) || 0,
 | 
					    wotDistributionTotal: v => v.chartData.wotDistribution?.reduce((a, b) => a + b.c, 0) || 0,
 | 
				
			||||||
 | 
					    mapData: v => {
 | 
				
			||||||
 | 
					      const scatters = v.weiyang.features.map(e => {
 | 
				
			||||||
 | 
					        const {name, unique_id, geo_wkt = ""} = e.properties
 | 
				
			||||||
 | 
					        return {name, areaId: unique_id + "000", value: [...geo_wkt.match(/[.\d]+/g)]}
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					      return {
 | 
				
			||||||
 | 
					        geo: {label: {show: false}},
 | 
				
			||||||
 | 
					        series: {
 | 
				
			||||||
 | 
					          type: 'effectScatter', coordinateSystem: 'geo', itemStyle: {color: '#4DF6FF'},
 | 
				
			||||||
 | 
					          select: {itemStyle: {color: '#FFC800'}},
 | 
				
			||||||
 | 
					          data: scatters, label: {
 | 
				
			||||||
 | 
					            position: 'bottom', color: '#fff', fontSize: 12,
 | 
				
			||||||
 | 
					            show: true, formatter: params => {
 | 
				
			||||||
 | 
					              return params.name
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        tooltip: {
 | 
				
			||||||
 | 
					          position: 'top',
 | 
				
			||||||
 | 
					          backgroundColor: "rgba(11,42,64,0.6)", textStyle: {color: '#fff'}, formatter: params => {
 | 
				
			||||||
 | 
					            const {name,areaId} = params.data
 | 
				
			||||||
 | 
					            const item = v.chartData.mapInfo.find(e => e.areaId == areaId)||{}
 | 
				
			||||||
 | 
					            return `<div style="width: 144px;padding: 0 4px">
 | 
				
			||||||
 | 
					<b class="mar-b8 font-16">${name}</b>
 | 
				
			||||||
 | 
					${["mapResidentCount", "mapResidentGroupCount", "mapWorkOrderCount"].map(prop => `<div class="flex" style="line-height: 22px;">
 | 
				
			||||||
 | 
					<span class="fill" style="color:#99B5D2">${v.getLabel(prop)}</span> ${item[prop] || 0}</div>`).join("")}</div>`
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  watch: {
 | 
					  watch: {
 | 
				
			||||||
    integralOrderType() {
 | 
					    integralOrderType() {
 | 
				
			||||||
@@ -286,6 +318,11 @@ export default {
 | 
				
			|||||||
            if (res?.data) {
 | 
					            if (res?.data) {
 | 
				
			||||||
              this.$set(this.chartData, "wotDistribution", res.data)
 | 
					              this.$set(this.chartData, "wotDistribution", res.data)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					          }),
 | 
				
			||||||
 | 
					          http.post("/app/wyDiy/mapInfo", null, {params: {areaId}}).then(res => {
 | 
				
			||||||
 | 
					            if (res?.data) {
 | 
				
			||||||
 | 
					              this.$set(this.chartData, "mapInfo", res.data)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
          })
 | 
					          })
 | 
				
			||||||
        ])
 | 
					        ])
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -417,7 +454,7 @@ export default {
 | 
				
			|||||||
      <sub-header class="e" title="五条工作链">
 | 
					      <sub-header class="e" title="五条工作链">
 | 
				
			||||||
        <ai-echart :ops="chart.workChain" :data="chartData.workChain"/>
 | 
					        <ai-echart :ops="chart.workChain" :data="chartData.workChain"/>
 | 
				
			||||||
      </sub-header>
 | 
					      </sub-header>
 | 
				
			||||||
      <ai-echart-map class="f"/>
 | 
					      <ai-echart-map :geo-json="weiyang" class="f" :ops="mapData"/>
 | 
				
			||||||
      <sub-header class="g" title="工单分类">
 | 
					      <sub-header class="g" title="工单分类">
 | 
				
			||||||
        <div class="flex column normal" style="height: 100%">
 | 
					        <div class="flex column normal" style="height: 100%">
 | 
				
			||||||
          <ai-echart class="wotDistribution" :ops="chart.wotDistribution" :data="chartData.wotDistribution">
 | 
					          <ai-echart class="wotDistribution" :ops="chart.wotDistribution" :data="chartData.wotDistribution">
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								project/biaopin/dv/weiyang/weiyang.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								project/biaopin/dv/weiyang/weiyang.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -12,7 +12,7 @@ import "../../lib/cdn/turf.min.js";
 | 
				
			|||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: 'AiEchartMap',
 | 
					  name: 'AiEchartMap',
 | 
				
			||||||
  props: {
 | 
					  props: {
 | 
				
			||||||
    geoJson: String,
 | 
					    geoJson: {type: [String, Object]},
 | 
				
			||||||
    data: Array,
 | 
					    data: Array,
 | 
				
			||||||
    ops: Object
 | 
					    ops: Object
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
@@ -60,9 +60,13 @@ export default {
 | 
				
			|||||||
      })
 | 
					      })
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    loadLibs() {
 | 
					    loadLibs() {
 | 
				
			||||||
      return Promise.all([
 | 
					      let getGeo
 | 
				
			||||||
        this.getData(this.geoJson).then(res => this.geo = res?.data)
 | 
					      if (typeof this.geoJson === 'string') {
 | 
				
			||||||
      ])
 | 
					        getGeo = this.getData(this.geoJson).then(res => this.geo = res?.data)
 | 
				
			||||||
 | 
					      } else if (typeof this.geoJson === 'object') {
 | 
				
			||||||
 | 
					        getGeo = Promise.resolve(this.geo = this.$copy(this.geoJson))
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      return Promise.all([getGeo])
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    initChart() {
 | 
					    initChart() {
 | 
				
			||||||
      const {echarts, turf} = window
 | 
					      const {echarts, turf} = window
 | 
				
			||||||
@@ -77,7 +81,6 @@ export default {
 | 
				
			|||||||
        boundary.properties = {...boundary.properties}
 | 
					        boundary.properties = {...boundary.properties}
 | 
				
			||||||
        boundary.properties.name = "boundary"
 | 
					        boundary.properties.name = "boundary"
 | 
				
			||||||
        geoJson.features.unshift(boundary)
 | 
					        geoJson.features.unshift(boundary)
 | 
				
			||||||
        console.log(geoJson)
 | 
					 | 
				
			||||||
        echarts.registerMap('customMap', geoJson)
 | 
					        echarts.registerMap('customMap', geoJson)
 | 
				
			||||||
        const option = {
 | 
					        const option = {
 | 
				
			||||||
          geo: {
 | 
					          geo: {
 | 
				
			||||||
@@ -94,14 +97,26 @@ export default {
 | 
				
			|||||||
              }
 | 
					              }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          series: [
 | 
					 | 
				
			||||||
            {type: 'scatter', coordinateSystem: 'geo', itemStyle: {color: '#66FFFF'}},
 | 
					 | 
				
			||||||
            {type: 'effectScatter', coordinateSystem: 'geo', itemStyle: {color: '#FFD15C'}}
 | 
					 | 
				
			||||||
          ],
 | 
					 | 
				
			||||||
          ...this.ops
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        const assign = (target, source) => {
 | 
				
			||||||
 | 
					          Object.entries(source).forEach(([key, value]) => {
 | 
				
			||||||
 | 
					            if (typeof value === 'object') {
 | 
				
			||||||
 | 
					              if (target[key] && typeof target[key] === 'object') {
 | 
				
			||||||
 | 
					                assign(target[key], value)
 | 
				
			||||||
 | 
					              } else {
 | 
				
			||||||
 | 
					                target[key] = value
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					              target[key] = value
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          })
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        assign(option, this.ops)
 | 
				
			||||||
        this.chart.setOption(option)
 | 
					        this.chart.setOption(option)
 | 
				
			||||||
      }).finally(() => this.chart.hideLoading())
 | 
					      }).finally(() => {
 | 
				
			||||||
 | 
					        this.$emit('map', this.chart)
 | 
				
			||||||
 | 
					        this.chart.hideLoading()
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    getData(url = `https://geo.datav.aliyun.com/areas_v3/bound/geojson?code=${this.user.info.areaId?.substring(0, 6)}`) {
 | 
					    getData(url = `https://geo.datav.aliyun.com/areas_v3/bound/geojson?code=${this.user.info.areaId?.substring(0, 6)}`) {
 | 
				
			||||||
      return http.post(`/app/appdvcpconfig/apiForward?url=${encodeURIComponent(url)}`)
 | 
					      return http.post(`/app/appdvcpconfig/apiForward?url=${encodeURIComponent(url)}`)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user