quanyawei
2024-02-05 570084e543239f927d37bdbfa1594d086ccc873e
fix:bug修复
1 files modified
81 ■■■■■ changed files
src/views/hotMap/index.vue 81 ●●●●● patch | view | raw | blame | history
src/views/hotMap/index.vue
@@ -26,7 +26,6 @@
            v-model="orgId"
            size="small"
            placeholder="请选择"
            disabled
            @change="regionData"
          >
            <el-option
@@ -102,11 +101,11 @@
      heatmap: null,
      markerClusterer: null,
      orgData: [],
      orgId: 71,
      orgId: null,
      city: '苏州',
      formInline: {
        city: '海城市',
        cityCode: '210381',
        city: '',
        cityCode: '',
        dayType: 'hour',
        starTime: '',
        endTime: '',
@@ -227,6 +226,7 @@
        speed: 2
      },
      polygon: null,
      districtSearch: null,
      dateTimes: [],
      activeItem: {},
      markerList: []
@@ -251,18 +251,18 @@
      },
      deep: true
    },
    'formInline.city': {
      handler: function (newVal, oldVal) {
        console.log('newVal', newVal === '')
        if (newVal !== '') {
          this.init1()
          if (!!this.formInline.starTime && !!this.formInline.endTime) {
            this.onSubmit()
          }
        }
      },
      deep: true
    },
    // 'formInline.city': {
    //   handler: function (newVal, oldVal) {
    //     console.log('newVal', newVal === '')
    //     if (newVal !== '') {
    //       this.init1()
    //       if (!!this.formInline.starTime && !!this.formInline.endTime) {
    //         this.onSubmit()
    //       }
    //     }
    //   },
    //   deep: true
    // },
    activeItem: {
      handler (newVal, oldVal) {
        if (this.markerList.length > 0) {
@@ -276,14 +276,12 @@
      deep: true
    }
  },
  created () {
  },
  mounted () {
    let dataTime = dayjs().format('YYYY-MM-DD')
    this.getOrganizationId()
    this.getData(`${dataTime} 00`)
    this.$nextTick(() => {
      this.initMap()
      this.createHeatMap()
    })
  },
  destroyed () {
@@ -323,7 +321,7 @@
    initMap () {
      var map = new AMap.Map('mapd', {
        resizeEnable: true,
        zooms: [10, 10],
        zooms: [1, 10],
        zoom: 10,
      })
      this.map = map
@@ -333,12 +331,13 @@
    init1 () { // 区域遮盖
      var that = this
      this.map.setCity(this.formInline.city)
      console.log('海城', this.formInline.cityCode)
      if (that.polygon) {
        that.map.remove(that.polygon)
        that.map.remove(that.districtSearch)
        that.polygon = null
        that.districtSearch = null
      }
      console.log('that.polygon', that.polygon)
      AMap.plugin('AMap.DistrictSearch', function () {
      this.districtSearch = AMap.plugin('AMap.DistrictSearch', function () {
        new AMap.DistrictSearch({
          extensions: 'all',
          subdistrict: 0
@@ -382,7 +381,7 @@
            }
            this.heatMapData = []
            this.heatMapData = res.data
            this.dataProcessing()
            this.dataProcessing(this.heatMapData)
            this.heatmap.setDataSet({
              data: this.heatMapData,
              max: this.selectSensor.maxNumber
@@ -397,9 +396,11 @@
          console.log(err)
        })
    },
    dataProcessing () {
    dataProcessing (heatMapData) {
      // 获取最大值
      const max = this.heatMapData.reduce((prev, current) => (prev.count > current.count ? prev : current)).count
      console.log('this.heatMapData', this.heatMapData)
      const max = heatMapData.reduce((prev, current) => (prev.count > current.count ? prev : current)).count
      // so2
      if (this.selectSensor.code === 'a21026') {
        if (max > 150 && max <= 475) {
@@ -532,6 +533,14 @@
      })
        .then(res => {
          this.orgData = res.data
          let cityData = _.find(this.orgData, { id: this.orgId })
          if (this.orgId === 73) {
            this.formInline.city = cityData.cityName
            this.formInline.cityCode = String(cityData.cityCode)
          } else {
            this.formInline.city = cityData.areaName
            this.formInline.cityCode = String(cityData.areaCode)
          }
        })
        .catch(err => {
          console.log(err)
@@ -554,7 +563,13 @@
        // this.map.clearMap()
        this.getDayListData()
        this.getData(this.formInline.starTime)
        // this.init1()
        this.$nextTick(() => {
          if (this.map) {
            this.map.destroy()
          }
          this.initMap()
          this.createHeatMap()
        })
        // this.map.setZoom(12)
      } else {
        this.$message({
@@ -567,8 +582,14 @@
    },
    regionData (id) {
      let cityData = _.find(this.orgData, { id: id })
      this.formInline.city = cityData.areaName
      this.formInline.cityCode = cityData.areaCode
      if (id === 73) {
        this.formInline.city = cityData.cityName
        this.formInline.cityCode = String(cityData.cityCode)
      } else {
        this.formInline.city = cityData.areaName
        this.formInline.cityCode = String(cityData.areaCode)
      }
      console.log('cityData', cityData)
    },
    selectHourData (data) {
      if (data) {