From 2c6d91d758241e1f97fe2790d92b754ea2cc860c Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Thu, 28 Mar 2024 15:59:25 +0800 Subject: [PATCH] fix: 空气质量日报表显示 --- src/views/hotMap/index.vue | 188 +++++++++++++++++++++++++++++++++------------- 1 files changed, 133 insertions(+), 55 deletions(-) diff --git a/src/views/hotMap/index.vue b/src/views/hotMap/index.vue index f68d0a0..c20b9be 100644 --- a/src/views/hotMap/index.vue +++ b/src/views/hotMap/index.vue @@ -22,11 +22,10 @@ </el-radio-group> </el-form-item> <el-form-item> - <el-select + <!-- <el-select v-model="orgId" size="small" placeholder="���������" - disabled @change="regionData" > <el-option @@ -35,7 +34,15 @@ :label="item.name" :value="item.id" /> - </el-select> + </el-select> --> + <el-cascader + v-model="orgId" + size="small" + :options="orgData" + :props="props" + clearable + @change="regionData" + /> </el-form-item> <el-form-item> <el-radio-group @@ -78,7 +85,7 @@ class="buttomColorLine" /> <Main - v-if="dateTimes.length > 0&&formInline.city!==''" + v-if="dateTimes.length > 0" :options="options" :date-times="dateTimes" :date-type="formInline.dayType" @@ -89,7 +96,7 @@ </template> <script> -import dayjs from 'dayjs' +// import dayjs from 'dayjs' import _ from 'lodash' import selectHour from './components/selectHour.vue' import Main from './components/timeLinePlay.vue' @@ -102,11 +109,12 @@ heatmap: null, markerClusterer: null, orgData: [], - orgId: 71, + props: { checkStrictly: true, label: 'name', value: 'id', children: 'children' }, + orgId: [], city: '������', formInline: { - city: '���������', - cityCode: '210381', + city: '', + cityCode: '', dayType: 'hour', starTime: '', endTime: '', @@ -227,6 +235,7 @@ speed: 2 }, polygon: null, + districtSearch: null, dateTimes: [], activeItem: {}, markerList: [] @@ -251,39 +260,31 @@ }, 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) { - console.log('2222', this.map.getAllOverlays('marker')) - this.map.remove(this.markerList) - this.markerList = [] - // this.markerClusterer = null - } - this.getData(newVal.name) + }, deep: true } }, + created () { + }, mounted () { - let dataTime = dayjs().format('YYYY-MM-DD') + // let dataTime = dayjs().format('YYYY-MM-DD') this.getOrganizationId() - this.getData(`${dataTime} 00`) - this.$nextTick(() => { - this.initMap() - this.createHeatMap() - }) + // this.getData(`${dataTime} 00`) }, destroyed () { @@ -309,6 +310,9 @@ getDateFun (item) { console.log(item) this.activeItem = item + if (this.orgId.length > 0) { + this.getData(item.name) + } }, getPollutant (data) { this.selectSensor = _.find(this.sensorArr, { name: data }) @@ -321,24 +325,31 @@ }, // ��������������� initMap () { + let zoom = 10 + if (this.formInline.cityCode === '320900') { + zoom = this.formInline.areName === 'dafengqu' ? 15 : 13 + } var map = new AMap.Map('mapd', { resizeEnable: true, - zooms: [10, 10], - zoom: 10, + zoomEnable: false, + zoom: zoom }) this.map = map + map.on('click', function (e) { + console.log('e.lnglat.getLng() + ', ' + e.lnglat.getLat()', e.lnglat.getLng() + ',' + e.lnglat.getLat()) + }) this.init1() // let that = this }, 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 @@ -349,9 +360,45 @@ new AMap.LngLat(360, -90, true), new AMap.LngLat(360, 90, true) ] - var holes = result.districtList[0].boundaries var pathArray = [outer] - pathArray.push.apply(pathArray, holes) + let ycPoints = { + areas: [{ // ������1 + rejectTexture: true, // ������������������������������������ + path: [[ + [120.06316306, 33.41753995999999], + [120.2617243421, 33.41753995999999], + [120.2617243421, 33.308387182], + [120.06316306, 33.308387182], + [120.06316306, 33.41753995999999] + ]] + }] + } + + var holes = result.districtList[0].boundaries + console.log('that.formInline', that.formInline) + if (that.formInline.cityCode === '320900') { + // ������ + + that.map.setCenter([120.16, 33.36]) + if (that.formInline.areName === 'dafengqu') { + that.map.setCenter([120.435345, 33.203704]) + ycPoints = { + areas: [{ // ������1 + rejectTexture: true, // ������������������������������������ + path: [[ [120.41615942, 33.215693], + [120.45416756599998, 33.215693], + [120.45416756599998, 33.192137742599996], + [120.41615942000003, 33.19213774259998], + [120.41615942, 33.215693] ]] + }] + } + } + pathArray.push.apply(pathArray, ycPoints.areas[0].path) + } else { + pathArray.push.apply(pathArray, holes) + that.map.setCity(that.formInline.city) + } + // pathArray.push.apply(pathArray, holes) that.polygon = new AMap.Polygon({ pathL: pathArray, strokeColor: 'red', // ������������������ @@ -369,7 +416,7 @@ url: '/heatMap/query', method: 'get', params: { - id: this.orgId, + id: this.orgId[0], startTime: newVal, type: this.selectSensor.code, form: this.formInline.dayType @@ -380,16 +427,14 @@ if (this.heatmap === null) { this.createHeatMap() } - this.heatMapData = [] this.heatMapData = res.data - this.dataProcessing() + this.dataProcessing(this.heatMapData) this.heatmap.setDataSet({ data: this.heatMapData, max: this.selectSensor.maxNumber }) - console.log('000', this.selectSensor.maxNumber) - console.log('1111', this.heatmap.getDataSet()) } else { + this.map.remove(this.heatmap) this.heatmap = null } }) @@ -397,9 +442,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) { @@ -531,7 +578,18 @@ method: 'get' }) .then(res => { - this.orgData = res.data + this.orgData = res.data.map(item => { + if (item.id === 73) { + item.children = [{ + id: 'shiqu', + name: '������' + }, { + id: 'dafengqu', + name: '���������' + }] + } + return item + }) }) .catch(err => { console.log(err) @@ -539,10 +597,12 @@ }, createHeatMap () { let that = this + let radius = this.formInline.areName === 'shiqu' ? 100 : 100 + console.log('radius', radius) this.map.plugin(['AMap.Heatmap'], function () { // ���������heatmap������ that.heatmap = new AMap.Heatmap(that.map, { - radius: 100, // ������������ + radius: radius, // ������������ opacity: [0.5, 1], gradient: that.selectSensor.gradient }) @@ -552,9 +612,15 @@ onSubmit () { if (!!this.formInline.city && !!this.formInline.starTime && !!this.formInline.endTime) { // this.map.clearMap() + this.getDayListData() + + if (this.map) { + this.map.destroy() + } + this.initMap() + this.createHeatMap() this.getData(this.formInline.starTime) - // this.init1() // this.map.setZoom(12) } else { this.$message({ @@ -566,15 +632,27 @@ } }, regionData (id) { - let cityData = _.find(this.orgData, { id: id }) - this.formInline.city = cityData.areaName - this.formInline.cityCode = cityData.areaCode + console.log('id', id) + let cityData = _.find(this.orgData, { id: id[0] }) + if (id[0] === 73) { + if (id[1]) { + this.formInline.areName = id[1] + } + this.formInline.city = cityData.cityName + this.formInline.cityCode = String(cityData.cityCode) + } else { + this.formInline.city = cityData.areaName + this.formInline.cityCode = String(cityData.areaCode) + } }, selectHourData (data) { + console.log('ccccc', this.formInline) if (data) { this.formInline.starTime = data[0] this.formInline.endTime = data[1] - this.getDayListData() + if (this.formInline.city) { + this.getDayListData() + } } else { this.formInline.starTime = '' this.formInline.endTime = '' -- Gitblit v1.8.0