Files
Agriculture-front-end/src/views/meteorological/remoteSense/freeze/Freeze.vue
2024-05-30 09:20:30 +08:00

3547 lines
119 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="fatherDiv">
<div class="centerBox">
<div style="width: 100%; height: 100%" id="cesiumContainer"></div>
<div class="rightWra">
<div class="tool" @click="Back()">
<img src="@/assets/images/fh.png" />
<span>返回</span>
</div>
<div class="tabar">
<div :class="tabrFlag ? 'tabarS' : ''" @click="tabRightWra(true)">黄岛区</div>
<div :class="!tabrFlag ? 'tabarS' : ''" @click="tabRightWra(false)">行政区</div>
</div>
<div v-show="tabrFlag" class="leftTop">
<div class="title">
<div
style="
width: 3px;
height: 19px;
opacity: 1;
background: rgba(100, 195, 164, 1);
margin-right: 12px;
"
></div>
<span>各冷冻等级面积统计</span>
<p @click="Deta()">
下载 &nbsp;
<img
src="@/assets/icons/svg/downloads.svg"
style="width: 14px; height: 14px; cursor: pointer"
/>
</p>
</div>
<div ref="areaDiv" class="areaDiv"></div>
</div>
<div v-show="tabrFlag" class="leftbottom">
<div class="title">
<div
style="
width: 3px;
height: 19px;
opacity: 1;
background: rgba(100, 195, 164, 1);
margin-right: 12px;
"
></div>
<span>各冷冻等级面积占比</span>
<p @click="Deta2()">
下载 &nbsp;
<img
src="@/assets/icons/svg/downloads.svg"
style="width: 14px; height: 14px; cursor: pointer"
/>
</p>
</div>
<div ref="typesofDiv" class="typesofDiv"></div>
<div class="tableDiv">
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="date" label="类型" />
<el-table-column prop="name" label="面积(亩)" />
<el-table-column prop="address" label="占比" />
</el-table>
</div>
</div>
<div v-show="!tabrFlag" class="rightTop">
<div class="title">
<div
style="
width: 3px;
height: 19px;
opacity: 1;
background: rgba(100, 195, 164, 1);
margin-right: 12px;
"
></div>
<span>各冷冻等级面积统计-高标准农田</span>
<p @click="Deta3()" v-if="limits">
下载 &nbsp;
<img
src="@/assets/icons/svg/downloads.svg"
style="width: 14px; height: 14px; cursor: pointer"
/>
</p>
</div>
<div v-show="limits" ref="farmlandDiv" class="farmlandDiv"></div>
<div v-if="!limits">
<img src="@/assets/images/qx.png" />
</div>
</div>
<div v-show="!tabrFlag" class="rightbottom">
<div class="title">
<div
style="
width: 3px;
height: 19px;
opacity: 1;
background: rgba(100, 195, 164, 1);
margin-right: 12px;
"
></div>
<span>各冷冻等级面积统计-行政区划</span>
<p @click="Deta4()">
下载 &nbsp;
<img
src="@/assets/icons/svg/downloads.svg"
style="width: 14px; height: 14px; cursor: pointer"
/>
</p>
</div>
<el-select
v-if="limits"
popper-class="select_city"
v-model="value"
placeholder="全部"
>
<el-option
v-for="item in Township.arr"
:key="item.streetCode"
:label="item.streetName"
:value="item.streetCode"
/>
</el-select>
<div ref="ASdivisionDiv" class="ASdivision"></div>
</div>
<div class="rightFoldDiv" @click="rightFoldClick()">
<el-tooltip
:disabled="!rightWraFlag"
hide-after="0"
:show-arrow="false"
show-after="200"
class="box-item"
effect="dark"
content="收起"
placement="top"
>
<el-icon v-if="rightWraFlag">
<img src="@/assets/images/shouhuis.png" />
</el-icon>
</el-tooltip>
<el-tooltip
:disabled="rightWraFlag"
hide-after="0"
:show-arrow="false"
show-after="200"
class="box-item"
effect="dark"
content="展开"
placement="top"
>
<el-icon v-if="!rightWraFlag">
<img src="@/assets/images/zhankaiss.png" />
</el-icon>
</el-tooltip>
</div>
</div>
<div class="bottom_center">
<TimeLine
v-if="dataSource.length > 0"
:dataSource="dataSource"
@dataHandle="handleData"
:allCount="allCount"
@getcurrentPage="getcurrentPage"
/>
</div>
<div class="tool">
<span><img src="@/assets/images/LAYER.png" alt="" /></span>
<span><img src="@/assets/images/amplify.png" alt="" /></span>
<span><img src="@/assets/images/reduce.png" alt="" /></span>
<span><img src="@/assets/images/measure.png" alt="" /></span>
<span><img src="@/assets/images/face.png" alt="" /></span>
<span><img src="@/assets/images/position.png" alt="" /></span>
</div>
<el-collapse class="legend" accordion>
<el-collapse-item name="1">
<template #title>图例</template>
<div class="mt-4">
<el-checkbox-group v-model="checkList" @change="change">
<el-checkbox
v-for="(value, item, key) in dic"
:key="key"
:v-model="value.disabled"
:disabled="value.disabled"
:label="item"
>
<span
:style="{
background: value.color,
border: `1px solid ${value.color}`,
width: `10px`,
height: `10px`,
display: `flex`,
'margin-right': `5px`,
}"
></span>
{{ item }}
</el-checkbox>
</el-checkbox-group>
</div>
</el-collapse-item>
</el-collapse>
<div id="popup" class="ol-popup">
<div class="pophead" style="width: 100%">
<div
id="popup-title"
style="
font-size: 20px;
font-weight: 400;
letter-spacing: 1px;
line-height: 42px;
padding-left: 20px;
border-radius: 8px;
margin: 20px;
background: rgba(100, 195, 164, 0.05);
"
></div>
<a href="#" id="popup-closer" class="ol-popup-closer"></a>
</div>
<div id="popup-content" style="padding: 10px">
<div class="perform" v-for="(item, index) in alterArr" :key="index">
<div class="perform_children">
<div class="label">{{ item.type }}:</div>
<span>{{ Number(item.area).toFixed(2) }}()</span>
</div>
</div>
</div>
<div id="popup-pagination"></div>
</div>
<div id="pop">
<div v-for="(item, index) in townZuowu.label" :key="index">
<div>{{ item.crop }}</div>
<div>{{ item.Shape_Area }} </div>
</div>
<div v-if="townZuowu.XZQMC">
<div>村名</div>
<div>{{ townZuowu.XZQMC }}</div>
</div>
</div>
<el-button v-if="flag" class="back_button" @click="back()">返回</el-button>
</div>
<div class="tabulation">
<div class="searchDiv">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="时间:">
<el-select
popper-class="selectCity"
v-model="formInline.time"
placeholder="请选择"
>
<el-option
v-for="(item, index) in timeArr"
:key="index"
:label="Zitem"
:value="item"
/>
</el-select>
</el-form-item>
<el-form-item label="统计方式:">
<el-select
popper-class="selectCity"
v-model="formInline.statistical"
placeholder="请选择"
>
<el-option label="镇级" value="镇" />
<el-option label="村级" value="村" />
<el-option v-if="limits" label="高标准农田" value="高标准农田" />
</el-select>
</el-form-item>
<el-form-item label="冷冻等级">
<el-select
v-model="formInline.droughtRating"
popper-class="selectCity"
placeholder="请选择"
>
<el-option label="全部" value="" />
<el-option label="无冻害" value="无冻害" />
<el-option label="轻度冻害" value="轻度冻害" />
<el-option label="中度冻害" value="中度冻害" />
<el-option label="重度冻害" value="重度冻害" />
</el-select>
</el-form-item>
<el-form-item label="面积(亩)>">
<el-input-number v-model="num" :min="0" @change="handleChange" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
<el-button plain @click="resetForm" :disabled="!SwitchFlag ? true : false">
重置
</el-button>
<el-button v-if="!operate" type="primary" text @click="dowcity">
<img src="@/assets/images/dow.png" alt="" />
下载
</el-button>
</el-form-item>
</el-form>
<div class="modeDiv" @click="SwitchMode">
<div :class="SwitchFlag ? 'Selected' : ''">表格模式</div>
<div :class="SwitchFlag ? '' : 'Selecteds'">图表模式</div>
</div>
</div>
<div v-show="SwitchFlag" class="tableBox">
<div class="tableBorder">
<el-table
:data="amount"
:header-cell-style="{ 'text-align': 'center' }"
style="width: 100%"
highlight-current-row
header-row-class-name="tabth"
v-if="!operate"
>
<el-table-column align="center" prop="合计" width="80" />
<el-table-column
v-for="(item, index) in tableItem"
:key="index"
:prop="item.value"
:label="index == 0 ? item.lable : item.lable + '(亩)'"
align="center"
/>
<el-table-column prop="address" v-if="operate" align="center" label="操作">
<template #default="scope">
<span
style="color: rgba(67, 181, 143, 1); cursor: pointer"
@click="download(scope.row)"
>
下载
</span>
</template>
</el-table-column>
</el-table>
</div>
<el-table
:data="tableNewData"
:header-cell-style="{ 'text-align': 'center' }"
height="70%"
highlight-current-row
header-row-class-name="tabth"
>
<el-table-column
type="index"
width="80"
align="center"
label="序号"
:index="Nindex"
/>
<el-table-column
v-for="(item, index) in tableItem"
:key="index"
:prop="item.value"
:label="index == 0 ? item.lable : item.lable + '(亩)'"
align="center"
/>
<el-table-column prop="address" v-if="operate" align="center" label="操作">
<template #default="scope">
<span
style="color: rgba(67, 181, 143, 1); cursor: pointer"
@click="download(scope.row)"
>
下载
</span>
</template>
</el-table-column>
</el-table>
<div class="example-pagination-block">
{{ insectarr.length }}
<el-pagination
background
layout="prev, pager, next"
:total="insectarr.length"
:current-page="currentPage"
:page-size="pageSize"
@current-change="handleCurrentChange"
/>
</div>
</div>
<div v-show="!SwitchFlag" class="chartMode">
<div ref="chartModeDiv" class="chartModeDiv"></div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, onMounted, inject, reactive, watch } from 'vue';
import * as echarts from 'echarts';
import TimeLine from '@/components/TimeLine/TimeLine.vue';
// import * as turf from '@turf/turf';
import { useEcharts } from '@/hooks/useEcharts';
import {
getstatisticsOfTheArea,
getproportionOfArea,
geteachFreezingGradeArea,
getTownship,
getadministrative,
getfreezeWarningYear,
getfreezeWarning,
getvillageChun,
} from '@/api/meteorological/remoteSense/freeze.js';
import axios from 'axios';
import 'echarts-gl';
import { downLoadFile } from '@/utils/download.js';
import * as xlsx from 'xlsx'; // Vue3 版本
import { useRouter } from 'vue-router';
import elementResizeDetectorMaker from 'element-resize-detector';
const router = useRouter();
let viewer = ref(null);
const areaDiv = ref(null);
const typesofDiv = ref(null);
const farmlandDiv = ref(null);
const ProgressBarDiv = ref(null);
const ASdivisionDiv = ref(null);
const value = ref('370211');
value.value = window.localStorage.getItem('divisions');
const leftProgressBarDiv = ref(null);
let Township = reactive({ arr: [], brr: [], crr: [] }); //街道
const clickInfoMap = ref({});
const formLandRef = ref([]);
const flag = ref(false);
let leftWraFlag = ref(false);
let rightWraFlag = ref(false);
const checkList = ref(['false']);
let checkListdata = ref([]);
let areacharData = reactive({ lable: [], value: [] }); //冷冻等级面积
let typesofData = ref([]); //面积统计
let totalArea = ref(0); //总面积
let currentPage = ref(1); //当前页
let pageSize = ref(12); //每页条数
const insectarr = ref([]);
const num = ref(0);
let timeArr = ref([]); //年数组
let tableItem = ref([]);
let operate = ref(true);
let tableNewData = ref([]);
const chartModeDiv = ref(null);
let SwitchFlag = ref(true);
let layers = ref(null); //村
let dataSource = ref([]);
let oldDatas = ref('');
let paramCode = ref('');
let alterArr = ref([]);
let Tabtime = ref(1);
let allCount = ref([]);
let currentPageS = ref('');
let pageSizeS = ref(5);
let TimeArr = ref([]);
let tabrFlag = ref(true);
let limits = window.localStorage.getItem('divisions').length > 6 ? false : true;
let code =
window.localStorage.getItem('deptName') == '青岛西海岸新区'
? '黄岛区'
: window.localStorage.getItem('deptName');
let amount = ref([
{
无冻害: 0,
轻度冻害: 0,
中度冻害: 0,
重度冻害: 0,
},
]);
//搜索
let formInline = ref({
time: '',
statistical: '镇',
droughtRating: '',
area: num.value,
});
let highStandard = [
'2019年高标准农田片区1',
'2019年高标准农田片区2',
'2019年高标准农田片区3',
'2019年高标准农田片区4',
'2020年高标准农田片区',
'2021年高标准农田片区',
'2022年高标准农田片区1',
'2022年高标准农田片区2',
'2022年高标准农田片区3',
'2022年高标准农田片区4',
'2022年高标准农田片区5',
'2022年高标准农田片区6',
'2022年高标准农田片区7',
];
let highStandarditem = {
无冻害: [],
轻度冻害: [],
中度冻害: [],
重度冻害: [],
};
let dic = ref({
无冻害: { color: 'rgba(32, 242, 255, 1)', disabled: false },
轻度冻害: { color: 'rgba(255, 255, 0, 1)', disabled: false },
中度冻害: { color: 'rgba(255, 168, 8, 1)', disabled: false },
重度冻害: { color: 'rgba(224, 13, 15, 1)', disabled: false },
});
// 图层字典
let layersDic = {
无冻害: {
setOf: '2022-12-20-lengdong',
name: 'T2022_12_20_wudonghai',
},
轻度冻害: {
setOf: '2022-12-20-lengdong',
name: 'T2022_12_20_qingdudonghai',
},
中度冻害: {
setOf: '2022-12-20-lengdong',
name: 'T2022_12_20_medium_donghai',
},
重度冻害: {
setOf: '2022-12-20-lengdong',
name: 'T2022_12_20_serious_donghai',
},
};
watch(
() => value.value,
() => {
selectTab();
}
);
watch(
() => oldDatas.value,
(val, oldVal) => {
value.value = window.localStorage.getItem('divisions');
getstatisticsOfTheAreas(value.value, oldDatas.value.name); //冷冻等级面积统计
getproportionOfAreas(value.value, oldDatas.value.name); //冷冻等级面积占比
geteachFreezingGradeAreas(oldDatas.value.name); //高标准农田冷冻等级面积统计
if (limits) {
getTownships(value.value, oldDatas.value.name); //镇
} else {
getadministratives(value.value, oldDatas.value.name);
}
let str = oldDatas.value.name;
let str1 = str.replace(/-/g, '_');
layersDic = {
无冻害: {
setOf: `${oldDatas.value.name}-lengdong`,
name: `T${str1}_wudonghai`,
},
轻度冻害: {
setOf: `${oldDatas.value.name}-lengdong`,
name: `T${str1}_qingdudonghai`,
},
中度冻害: {
setOf: `${oldDatas.value.name}-lengdong`,
name: `T${str1}_medium_donghai`,
},
重度冻害: {
setOf: `${oldDatas.value.name}-lengdong`,
name: `T${str1}_serious_donghai`,
},
};
}
);
//行政区划数据
var data = {
title: [],
};
let dd = {
无冻害: [],
轻度冻害: [],
中度冻害: [],
重度冻害: [],
};
let areatext = '8383894';
//表格数据
let tableData = ref([]);
let TypeTime = {
大豆: [1100, 1395, 1948, 2203, 3402, 1860, 2934, 2490, 2323],
小麦: [1283, 2883, 2939, 1233, 1992, 1928, 3949, 1929, 3434],
地瓜: [1823, 1948, 1928, 2294, 2302, 3903, 3493, 2323, 2545],
花生: [2374, 1934, 3943, 3493, 2083, 1928, 2984, 3279, 1739],
};
// 组件挂载完成后执行
onMounted(() => {
initonMounted();
});
function initonMounted() {
theTimes(); //年
//地图
initmap();
showDaChangArea();
areachar();
typesof();
ASdivision();
alter();
for (const key in dic.value) {
if (dic.value[key].disabled !== true) {
checkListdata.value.push(key);
}
}
checkList.value = checkListdata.value;
let leftWra = document.querySelector('.leftWra');
leftWra ? (leftWra.style.transform = 'translate(-107%,0)') : '';
let rightWra = document.querySelector('.rightWra');
rightWra.style.transform = 'translate(101%,0)';
localStorage.setItem(router.currentRoute.value.path, true);
}
onUpdated(() => {
if (localStorage.getItem(router.currentRoute.value.path) == 'false') {
document.querySelector('.mode').style.display = 'block';
document.querySelector('.mode').innerText = '地图模式';
window.document.querySelector('#screenfull').style.display = 'none';
} else {
document.querySelector('.mode').style.display = 'block';
document.querySelector('.mode').innerText = '列表模式';
window.document.querySelector('#screenfull').style.display = 'block';
}
});
/*-------------地图------------------------*/
let container = ref(null);
let content = ref(null);
let popupCloser = ref(null);
let overlay = ref(null);
let map = ref(null);
function initmap() {
map = new ol.Map({
target: 'cesiumContainer',
controls: [],
view: new ol.View({
center: [119.86763411957472, 35.88435182141938],
zoom: 11,
// 设置最大缩放级别
maxZoom: 16.5,
projection: 'EPSG:4326',
}),
layers: [
new ol.layer.Tile({
source: new ol.source.XYZ({
url: `${serverAPI.tiandituLayers}`,
projection: serverAPI.flag ? 'EPSG:4326' : 'EPSG:3857',
}),
preload: 20, // 设置预加载的瓦片数这里是预加载当前级别和2个级别更低的瓦片
}),
//注记
// new ol.layer.Tile({
// source: new ol.source.Tianditu({
// layerType: 'img',
// isLabel: true,
// key: '1d109683f4d84198e37a38c442d68311',
// }),
// }),
],
});
//滚轮控制村级矢量
map.on('moveend', function (e) {
var zoom = map.getView().getZoom(); //获取当前地图的缩放级别
if (zoom >= 13) {
layers.setVisible(true); //显示图层
} else {
layers.setVisible(false);
}
});
map.on('singleclick', function (e) {
var coodinate = e.coordinate;
if (limits) {
var lon = coodinate[0];
var lat = coodinate[1];
var view = map.getView();
var zoom = map.getView().getZoom();
view.animate({
center: [lon, lat],
duration: 1000,
});
let tabFlag = false;
let arr = ['CJQY3702112019WGS84', 'XJQY3702112019WGS84'];
arr.forEach(item => {
map.getLayers()
.getArray()
.forEach((ite, index) => {
if (item == ite.A.name) {
tabFlag = true;
return;
}
});
});
if (tabFlag) {
if (zoom >= 13) {
QueryData(
e,
'CJQY3702112019WGS84@huangdaoqu_bianjie',
`${serverAPI.geoserverUrl}/map-huangdaoqu_bianjie/rest/maps/CJQY3702112019WGS84%40huangdaoqu_bianjie`,
'村'
);
} else {
QueryData(
e,
'XJQY3702112019WGS84@huangdaoqu_bianjie',
`${serverAPI.geoserverUrl}/map-huangdaoqu_bianjie/rest/maps/XJQY3702112019WGS84%40huangdaoqu_bianjie`,
'镇'
);
}
} else {
let url = `${serverAPI.geoserverUrl}/data-2019-2022gaobiaozhunnongtian/rest/data`;
let sqlParam = new ol.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: 'T2019_2022高标准农田片区@2019-2022gaobiaozhunnongtian',
attributeFilter: `DKMC = '${paramCode.value}'`,
},
datasetNames: ['2019-2022gaobiaozhunnongtian:T2019_2022高标准农田片区'],
});
new ol.supermap.FeatureService(url).getFeaturesBySQL(
sqlParam,
function (serviceResult) {
let geojson = new ol.format.GeoJSON().readFeatures(
serviceResult.result.features
);
let selectFeatureSource = new ol.source.Vector();
selectFeatureSource.addFeatures(geojson);
let vectorQuery = new ol.layer.Vector({
source: selectFeatureSource,
});
let features = vectorQuery.getSource().getFeatures();
for (var i = 0; i < features.length; i++) {
let polygon = features[i].getGeometry();
if (polygon.intersectsCoordinate(coodinate)) {
QueryData(
e,
'T2019_2022高标准农田片区@2019-2022gaobiaozhunnongtian',
`${serverAPI.geoserverUrl}/map-2019-2022gaobiaozhunnongtian/rest/maps/T2019_2022%E9%AB%98%E6%A0%87%E5%87%86%E5%86%9C%E7%94%B0%E7%89%87%E5%8C%BA@2019-2022gaobiaozhunnongtian`,
'高标准'
);
}
}
}
);
}
} else {
let url = `${serverAPI.geoserverUrl}/data-huangdaoqu_bianjie/rest/data`;
let sqlParam = new ol.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: 'XJQY3702112019WGS84@huangdaoqu_bianjie',
attributeFilter: `XJQYMC = '${code}'`,
},
datasetNames: ['huangdaoqu_bianjie:XJQY3702112019WGS84'],
});
new ol.supermap.FeatureService(url).getFeaturesBySQL(
sqlParam,
function (serviceResult) {
let geojson = new ol.format.GeoJSON().readFeatures(
serviceResult.result.features
);
let selectFeatureSource = new ol.source.Vector();
selectFeatureSource.addFeatures(geojson);
let vectorQuery = new ol.layer.Vector({
source: selectFeatureSource,
});
let features = vectorQuery.getSource().getFeatures();
for (var i = 0; i < features.length; i++) {
let polygon = features[i].getGeometry();
if (polygon.intersectsCoordinate(coodinate)) {
var lon = coodinate[0];
var lat = coodinate[1];
var view = map.getView();
var zoom = map.getView().getZoom();
view.animate({
center: [lon, lat],
duration: 1000,
});
if (zoom >= 13) {
QueryData(
e,
'CJQY3702112019WGS84@huangdaoqu_bianjie',
`${serverAPI.geoserverUrl}/map-huangdaoqu_bianjie/rest/maps/CJQY3702112019WGS84%40huangdaoqu_bianjie`,
'村'
);
} else {
QueryData(
e,
'XJQY3702112019WGS84@huangdaoqu_bianjie',
`${serverAPI.geoserverUrl}/map-huangdaoqu_bianjie/rest/maps/XJQY3702112019WGS84%40huangdaoqu_bianjie`,
'镇'
);
}
}
}
}
);
}
});
SQLSearch(code);
}
onUpdated(() => {
// 获取父元素和地图容器
var parentElement = document.querySelector('.centerBox');
var mapContainer = document.getElementById('cesiumContainer');
// 监听父元素大小变化
var resizeObserver = new ResizeObserver(function (entries) {
entries.forEach(function (entry) {
// 获取父元素的新大小
var newWidth = entry.contentRect.width;
var newHeight = entry.contentRect.height;
// 调整地图容器的大小
mapContainer.style.width = newWidth + 'px';
mapContainer.style.height = newHeight + 'px';
// 重新渲染地图
map.updateSize();
});
});
// 开始监听父元素大小变化
resizeObserver.observe(parentElement);
});
function QueryData(e, name, url, item) {
var point = new ol.geom.Point(e.coordinate);
var param = new ol.supermap.QueryByGeometryParameters({
queryParams: {
name: name,
},
geometry: point,
});
let newDataZh = [];
let titleDiv = document.querySelector('#popup-title');
let layergaoliang = ref(null);
let layerzhezhao = ref(null);
new ol.supermap.QueryService(url).queryByGeometry(param, function (data) {
let name = '';
layerzhezhao = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'zhezhao');
map.removeLayer(layerzhezhao);
if (item == '镇' && data.result.recordsets[0].features.features[0].properties.XJQYDM) {
let code = data.result.recordsets[0].features.features[0].properties.XJQYDM;
value.value = code;
let arr = [];
getTownship({ divisions: '370211', yearMonth: oldDatas.value.name }).then(res => {
res.data.forEach(item => {
if (item.streetCode == code) {
name = item.streetName;
arr.push(item);
}
// alterArr.value = arr;
});
let brr = [];
brr.push(arr[1]);
brr.push(arr[0]);
brr.push(arr[2]);
brr.push(arr[3]);
alterArr.value = brr;
alter();
});
} else if (
item == '村' &&
data.result.recordsets[0].features.features[0].properties.CJQYDM
) {
let code = data.result.recordsets[0].features.features[0].properties.CJQYDM;
let arr = [];
getvillageChun({ divisions: code, yearMonth: oldDatas.value.name }).then(res => {
res.data.forEach(item => {
arr.push(item);
});
name = res.data[0].streetName;
alterArr.value = arr;
alter();
});
} else if (
item == '高标准' &&
data.result.recordsets[0].features.features[0].properties.DKMC
) {
let code = data.result.recordsets[0].features.features[0].properties.DKMC;
let arr = [];
geteachFreezingGradeArea({ divisions: '370211', yearMonth: oldDatas.value.name }).then(
res => {
res.data.forEach(item => {
if (item.region == code) {
arr.push(item);
}
});
arr.forEach(item => {
item.type = item.level;
});
alterArr.value = arr;
name = code;
alter('gao');
}
);
}
function alter() {
if (data.result.currentCount > 0) {
if (data.result.recordsets[0].features) {
overlay.setPosition(point.flatCoordinates);
titleDiv.innerHTML = name;
}
layergaoliang = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'dianjigaoliang');
map.removeLayer(layergaoliang);
var llll = new ol.format.GeoJSON().readFeatures(data.result.recordsets[0].features);
newDataZh = data.result.recordsets[0].features.features[0].geometry.coordinates;
addConver(data.result.recordsets[0].features.features[0].geometry.coordinates);
var selectFeatureSource = new ol.source.Vector();
selectFeatureSource.addFeatures(llll);
const style = new ol.style.Style({
// fill: new ol.style.Fill({
// color: 'rgba(255, 219, 113, 0.3)',
// }),
stroke: new ol.style.Stroke({
color: 'rgba(255, 219, 113, 1.0)',
// lineDash: [10, 10],
width: 5,
}),
});
var vectorQuery = new ol.layer.Vector({
id: 'dianjigaoliang',
source: selectFeatureSource,
zIndex: 9999,
});
vectorQuery.setStyle(style);
map.addLayer(vectorQuery);
}
}
});
popupCloser.addEventListener('click', function () {
layerzhezhao = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'zhezhao');
map.removeLayer(layerzhezhao);
erase(newDataZh);
value.value = window.localStorage.getItem('divisions');
layergaoliang = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'dianjigaoliang');
map.removeLayer(layergaoliang);
overlay.setPosition(undefined);
});
}
const alter = () => {
container = document.getElementById('popup');
//拿到弹出框内容元素
content = document.getElementById('popup-content');
//拿到弹出框关闭元素
popupCloser = document.getElementById('popup-closer');
//创建弹出框容器
overlay = new ol.Overlay({
element: document.getElementById('popup'), // 弹框容器的id
positioning: 'bottom-center',
stopEvent: true,
offset: [0, -10],
});
map.addOverlay(overlay);
};
//创建蒙层,凸显黄岛区域
function showDaChangArea() {
axios.get('/json/huangdao.json').then(({ data }) => {
const fts = new ol.format.GeoJSON().readFeatures(data);
const ft = fts[0];
// addConver(ft.getGeometry().getCoordinates(), 'huandao');
});
}
//添加遮罩
function addConver(data, name, color, index) {
let source = new ol.source.Vector();
var converLayer = new ol.layer.Vector({
id: name ? name : 'zhezhao',
source: source,
zIndex: index ? index : 50,
style: new ol.style.Style({
fill: new ol.style.Fill({
color: color ? color : 'rgba( 105, 105, 105, 0.9)',
}),
}),
});
const converGeom = erase(data);
const convertFt = new ol.Feature({
geometry: converGeom,
});
converLayer.getSource().addFeature(convertFt);
map.addLayer(converLayer);
}
//擦除操作,生产遮罩范围
function erase(data) {
const extent = [-180, -90, 180, 90];
const polygonRing = ol.geom.Polygon.fromExtent(extent);
const coords = data;
coords.forEach(coord => {
const linearRing = new ol.geom.LinearRing(coord[0]);
polygonRing.appendLinearRing(linearRing);
});
return polygonRing;
}
//权限地图
function SQLSearch(name) {
let names = '';
let url = '';
let setName = '';
let setOf = '';
let quyu = '';
url = `${serverAPI.geoserverUrl}/data-huangdaoqu_bianjie/rest/data`;
names = name;
setName = 'XJQY3702112019WGS84';
setOf = 'huangdaoqu_bianjie';
quyu = 'XJQYMC';
//SQL查询模糊查询
// var url = 'http://192.168.0.113:8090/iserver/services/data-liangquhuadingWGS84/rest/data';
var sqlParam = new ol.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: `${setName}@${setOf}`,
attributeFilter: `${quyu} like '%${names}%'`,
},
datasetNames: [`${setOf}:${setName}`],
});
new ol.supermap.FeatureService(url).getFeaturesBySQL(sqlParam, function (serviceResult) {
if (serviceResult.result.featureCount != 0) {
var layerzhezhao = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'zhezhao');
map.removeLayer(layerzhezhao);
var layergaoliang = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'dianjigaoliang');
map.removeLayer(layergaoliang);
var geojson = new ol.format.GeoJSON().readFeatures(serviceResult.result.features);
addConver(
serviceResult.result.features.features[0].geometry.coordinates,
'qu',
'rgba( 105, 105, 105, 1)',
9999
);
var selectFeatureSource = new ol.source.Vector();
selectFeatureSource.addFeatures(geojson);
//设置图层高亮样式
const style = new ol.style.Style({
// fill: new ol.style.Fill({
// color: 'rgba(0, 255, 0, 0.1)',
// }),
stroke: new ol.style.Stroke({
color: 'rgba(85, 255, 255, 1.0)',
// lineDash: [10, 10],
width: 2,
}),
});
var vectorQuery = new ol.layer.Vector({
id: 'dianjigaoliang',
source: selectFeatureSource,
});
vectorQuery.setStyle(style);
map.addLayer(vectorQuery);
map.getView().fit(selectFeatureSource.getExtent());
}
});
}
const cun = () => {
layers = new ol.layer.Tile({
source: new ol.source.TileSuperMapRest({
url:
serverAPI.geoserverUrl +
`/map-huangdaoqu_bianjie/rest/maps/CJQY3702112019WGS84%40huangdaoqu_bianjie`,
cacheEnabled: false,
}),
name: 'CJQY3702112019WGS84',
projection: 'EPSG:4326', //3857
zIndex: 9999,
});
map.addLayer(layers);
};
const zhen = () => {
var layer = new ol.layer.Tile({
source: new ol.source.TileSuperMapRest({
url:
serverAPI.geoserverUrl +
`/map-huangdaoqu_bianjie/rest/maps/XJQY3702112019WGS84%40huangdaoqu_bianjie`,
cacheEnabled: false,
}),
name: 'XJQY3702112019WGS84',
projection: 'EPSG:4326', //3857
zIndex: 9999,
});
map.addLayer(layer);
};
const addwms = name => {
let layer = new ol.layer.Tile({
source: new ol.source.TileSuperMapRest({
// url: 'http://36.134.44.75:8090/iserver/services/map-huangdaoqu_village/rest/maps/huangdaoqu_village@huangdaoqu_village',
url: serverAPI.geoserverUrl + `/map-${name.setOf}/rest/maps/${name.name}@${name.setOf}`,
//rasterfunction: new SuperMap.NDVIParameter({ redIndex: 0, nirIndex: 2 }),
cacheEnabled: false,
}),
name: name.name,
projection: 'EPSG:4326', //3857
});
map.addLayer(layer);
};
let nums = 0;
const change = () => {
Tabtime.value = 0;
};
// 农作物
watch(
() => checkList.value,
(val, oldVal) => {
if (val.length >= oldVal.length && Tabtime.value < 1) {
// 挑选出增多的数据
const newData = val.filter(item => {
const index = oldVal.findIndex(it => it === item);
if (index < 0) {
return item;
}
});
newData.forEach(item => {
if (layersDic[item]) {
addwms(layersDic[item]);
}
});
} else if (val.length < oldVal.length) {
// 挑选出减少的数据
const newData = oldVal.filter(item => {
const index = val.findIndex(it => it === item);
if (index < 0) {
return item;
}
});
newData.forEach(item => {
if (layersDic[item]) {
// 假设要删除的图层为 layerToRemove
var index = map.getLayers().getArray().indexOf(layersDic[item].name);
map.getLayers()
.getArray()
.forEach((ite, index) => {
if (ite.A.name) {
if (ite.A.name == layersDic[item].name) {
map.getLayers().removeAt(index);
}
}
});
}
});
newData.forEach(item => {
if (layersDic[item]) {
// 假设要删除的图层为 layerToRemove
var index = map.getLayers().getArray().indexOf(layersDic[item].name);
map.getLayers()
.getArray()
.forEach((ite, index) => {
if (ite.A.name) {
if (ite.A.name == layersDic[item].name) {
map.getLayers().removeAt(index);
}
}
});
}
});
}
nums++;
if (nums == 1) {
cun(); //添加村
zhen(); //添加镇
}
}
);
let townZuowu = ref({ label: [] }); //镇的作物
const tabRightWra = flag => {
tabrFlag.value = flag;
if (flag) {
areachar();
typesof();
} else {
farmland();
ASdivision();
}
};
//折叠
function leftFoldClick() {
leftWraFlag.value = !leftWraFlag.value;
if (leftWraFlag.value) {
let leftWra = document.querySelector('.leftWra');
leftWra ? (leftWra.style.transform = 'translate(0,0)') : '';
} else {
let leftWra = document.querySelector('.leftWra');
leftWra ? (leftWra.style.transform = 'translate(-107%,0)') : '';
}
}
function rightFoldClick() {
rightWraFlag.value = !rightWraFlag.value;
if (rightWraFlag.value) {
let rightWra = document.querySelector('.rightWra');
rightWra.style.transform = 'translate(0,0)';
} else {
let rightWra = document.querySelector('.rightWra');
rightWra.style.transform = 'translate(101%,0)';
}
}
const handleChange = value => {
formInline.value.area = value;
};
const onSubmit = () => {
let arr = [];
let brr = [];
currentPage.value = 1;
getfreezeWarning({
yearMonth: formInline.value.time,
statistical: formInline.value.statistical,
droughtRating: formInline.value.droughtRating,
area: formInline.value.area,
}).then(res => {
let data = [];
let newData = [];
tableItem.value = [
{
lable: '',
value: 'region',
},
{
lable: '无冻害',
value: '无冻害',
},
{
lable: '轻度冻害',
value: '轻度冻害',
},
{
lable: '中度冻害',
value: '中度冻害',
},
{
lable: '重度冻害',
value: '重度冻害',
},
];
res.data.forEach(item => {
if (arr.indexOf(item.region) == -1) {
arr.push(item.region);
}
});
arr.forEach(item => {
brr.push(
Object.create(null, {
regio: {
value: item,
},
})
);
});
brr.forEach(item => {
res.data.map(i => {
if (item.regio === i.region) {
item['region'] = i.region;
item[i.level] = Number(i.area).toFixed(2);
}
});
});
operate.value = false;
insectarr.value = brr.sort((a, b) => {
return a.region.length - b.region.length;
});
tableNewData.value = brr.slice(
(currentPage.value - 1) * pageSize.value,
(currentPage.value - 1) * pageSize.value + pageSize.value
);
amount.value[0]['无冻害'] = 0;
amount.value[0]['轻度冻害'] = 0;
amount.value[0]['中度冻害'] = 0;
amount.value[0]['重度冻害'] = 0;
amount.value[0]['region'] = '合计';
brr.forEach(item => {
item.无冻害
? (amount.value[0]['无冻害'] +=
Number(item.无冻害) !== NaN ? Number(item.无冻害) : 0)
: 0;
item.轻度冻害
? (amount.value[0]['轻度冻害'] +=
Number(item.轻度冻害) !== NaN ? Number(item.轻度冻害) : 0)
: 0;
item.中度冻害
? (amount.value[0]['中度冻害'] +=
Number(item.中度冻害) !== NaN ? Number(item.中度冻害) : 0)
: 0;
item.重度冻害
? (amount.value[0]['重度冻害'] +=
Number(item.重度冻害) !== NaN ? Number(item.重度冻害) : 0)
: 0;
});
for (const key in amount.value[0]) {
if (amount.value[0][key] !== '合计') {
amount.value[0][key] = amount.value[0][key].toFixed(2);
}
}
const statInfo = chartModeDiv.value; // 获取图表元素
statInfo.style.width = window.innerWidth - 100 + 'px'; //初始化echarts图表宽度
statInfo.style.height = window.innerHeight - 100 + 'px';
const myChart = echarts.init(statInfo);
// 设置宽度自适应
window.addEventListener('resize', () => {
statInfo.style.width = window.innerWidth - 200 + 'px';
statInfo.style.height = window.innerHeight - 200 + 'px';
myChart.resize();
});
chartModes();
});
};
//列表模式模式切换
const SwitchMode = () => {
SwitchFlag.value = !SwitchFlag.value;
const statInfo = chartModeDiv.value; // 获取图表元素
statInfo.style.width = window.innerWidth - 200 + 'px'; //初始化echarts图表宽度
statInfo.style.height = window.innerHeight - 200 + 'px';
const myChart = echarts.init(statInfo);
// 设置宽度自适应
window.addEventListener('resize', () => {
statInfo.style.width = window.innerWidth - 200 + 'px';
statInfo.style.height = window.innerHeight - 200 + 'px';
myChart.resize();
});
chartModes();
};
const dowcity = () => {
let arr = JSON.parse(JSON.stringify(amount.value[0]));
arr.region = '合计';
insectarr.value.push(arr);
exportExcel(insectarr.value, '冷冻面积统计表', 'Sheet1');
};
const resetForm = () => {
(formInline.value.time = timeArr.value[timeArr.value.length - 1]),
(formInline.value.statistical = '镇'),
(formInline.value.droughtRating = ''),
(formInline.value.area = 0),
(num.value = 1),
(operate.value = true);
onSubmit();
};
/*------------------接口--------------------*/
const getcurrentPage = params => {
dataSource.value = TimeArr.value.slice(
(params - 1) * pageSizeS.value,
params * pageSizeS.value
);
};
//列表模式-年
const theTimes = () => {
getfreezeWarningYear().then(res => {
oldDatas.value = { name: res.data[res.data.length - 1] };
timeArr.value = res.data;
let arr = [];
res.data.forEach(item => {
arr.push({ name: item });
});
TimeArr.value = arr;
allCount.value = Math.ceil(TimeArr.value.length / 5); //总页数
currentPageS = Math.ceil(arr.length / 5); //当前页
dataSource.value = TimeArr.value.slice(
(currentPageS - 1) * pageSizeS.value,
currentPageS * pageSizeS.value
);
formInline.value.time = res.data[res.data.length - 1];
onSubmit();
let str = oldDatas.value.name;
let str1 = str.replace(/-/g, '_');
layersDic = {
无冻害: {
setOf: `${oldDatas.value.name}-lengdong`,
name: `T${str1}_wudonghai`,
},
轻度冻害: {
setOf: `${oldDatas.value.name}-lengdong`,
name: `T${str1}_qingdudonghai`,
},
中度冻害: {
setOf: `${oldDatas.value.name}-lengdong`,
name: `T${str1}_medium_donghai`,
},
重度冻害: {
setOf: `${oldDatas.value.name}-lengdong`,
name: `T${str1}_serious_donghai`,
},
};
});
};
//冷冻等级面积统计
const getstatisticsOfTheAreas = (city, time) => {
getstatisticsOfTheArea({ divisions: city, yearMonth: time }).then(res => {
areacharData.lable = [];
areacharData.value = [];
res.data.forEach(item => {
areacharData.lable.push(item.level);
areacharData.value.push(item.area);
});
areachar();
});
};
//冷冻等级面积占比
const getproportionOfAreas = (city, time) => {
let tableArr = ref([]);
getproportionOfArea({ divisions: city, yearMonth: time }).then(res => {
typesofData = ref([]);
totalArea = ref(0);
res.data.forEach(item => {
totalArea.value += Number(item.area);
typesofData.value.push({
name: item.level,
value: Number(item.area).toFixed(2),
});
tableArr.value.push({
date: item.level,
name: `${Number(item.area).toFixed(2)}`,
address: `${(item.percentage * 100).toFixed(2)}%`,
});
});
tableData.value = tableArr.value;
typesof();
});
};
//高标准农田冷冻等级面积统计
const geteachFreezingGradeAreas = time => {
geteachFreezingGradeArea({ yearMonth: time }).then(res => {
highStandarditem = {
无冻害: [],
轻度冻害: [],
中度冻害: [],
重度冻害: [],
};
highStandard.forEach((item, index) => {
let town = res.data.map(i => {
if (item === i.region) {
return i;
}
});
Object.keys(highStandarditem).forEach(it => {
let num = 0;
const index = town.findIndex(a => {
if (a && a.level === it) {
num = a.area;
}
return a && a.level === it;
});
if (index > -1) {
highStandarditem[it].push(num);
} else {
highStandarditem[it].push(0);
}
});
});
if (res.data.length > 0) {
farmland();
}
});
};
//镇
const getTownships = (city, time) => {
dd = {
无冻害: [],
轻度冻害: [],
中度冻害: [],
重度冻害: [],
};
getTownship({ divisions: city, yearMonth: time }).then(res => {
Township.brr = res.data;
Township.arr = res.data.sort((a, b) => {
return a.streetName.length - b.streetName.length;
});
Township.arr.unshift({
streetCode: '370211',
streetName: '全部',
});
let crr = [];
let drr = [];
Township.arr.forEach(item => {
if (crr.indexOf(item.streetName) == -1) {
crr.push(item.streetName);
drr.push({
streetName: item.streetName,
streetCode: item.streetCode,
});
}
});
Township.arr = drr;
let arr = [...res.data];
let brr = [];
arr.splice(0, 1);
arr.forEach(item => {
if (brr.indexOf(item.streetName) == -1) {
brr.push(item.streetName);
}
});
data.title = [...Object.values(brr)];
data.title.forEach((item, index) => {
let town = res.data.map(i => {
if (item === i.streetName) {
return i;
}
});
Object.keys(dd).forEach(it => {
const index = town.findIndex(a => a && a.type === it && a.area > 0);
if (index > -1) {
dd[it].push(1);
} else {
dd[it].push(null);
}
});
});
ASdivision();
});
};
//村
const getadministratives = (city, time) => {
dd = {
无冻害: [],
轻度冻害: [],
中度冻害: [],
重度冻害: [],
};
getadministrative({ divisions: city, yearMonth: time }).then(res => {
Township.brr = res.data;
let arr = [...res.data];
let brr = [];
arr.splice(0, 1);
arr.forEach(item => {
if (brr.indexOf(item.streetName) == -1) {
brr.push(item.streetName);
}
});
data.title = [...Object.values(brr)];
data.title.forEach((item, index) => {
let town = res.data.map(i => {
if (item === i.streetName) {
return i;
}
});
Object.keys(dd).forEach(it => {
const index = town.findIndex(a => a && a.type === it && a.area > 0);
if (index > -1) {
dd[it].push(1);
} else {
dd[it].push(null);
}
});
});
ASdivision();
});
};
function SQLData(name) {
let names = '';
let url = '';
let setName = '';
let setOf = '';
let quyu = '';
url = `${serverAPI.geoserverUrl}/data-2019-2022gaobiaozhunnongtian/rest/data`;
names = name;
setName = 'T2019_2022高标准农田片区';
setOf = '2019-2022gaobiaozhunnongtian';
quyu = 'DKMC';
//SQL查询模糊查询
// var url = 'http://192.168.0.113:8090/iserver/services/data-liangquhuadingWGS84/rest/data';
var sqlParam = new ol.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: `${setName}@${setOf}`,
attributeFilter: `${quyu} like '%${names}%'`,
},
datasetNames: [`${setOf}:${setName}`],
});
new ol.supermap.FeatureService(url).getFeaturesBySQL(sqlParam, function (serviceResult) {
if (serviceResult.result.featureCount != 0) {
var layerzhezhao = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'zhezhao');
map.removeLayer(layerzhezhao);
var layergaoliangs = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'dianjigaoliang');
map.removeLayer(layergaoliangs);
var layergaoliangss = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'gbz');
map.removeLayer(layergaoliangss);
var layergaoliang = map
.getLayers()
.getArray()
.find(layer => layer.get('id') === 'dianjigaoliangs');
map.removeLayer(layergaoliang);
var geojson = new ol.format.GeoJSON().readFeatures(serviceResult.result.features);
addConver(
serviceResult.result.features.features[0].geometry.coordinates,
'gbz',
'rgba( 105, 105, 105, 1)',
9999
);
var selectFeatureSource = new ol.source.Vector();
selectFeatureSource.addFeatures(geojson);
//设置图层高亮样式
const style = new ol.style.Style({
// fill: new ol.style.Fill({
// color: 'rgba(0, 255, 0, 0.1)',
// }),
stroke: new ol.style.Stroke({
color: 'rgba(85, 255, 255, 1.0)',
// lineDash: [10, 10],
width: 2,
}),
});
var vectorQuery = new ol.layer.Vector({
id: 'dianjigaoliang',
source: selectFeatureSource,
});
vectorQuery.setStyle(style);
map.addLayer(vectorQuery);
map.getView().fit(selectFeatureSource.getExtent());
}
});
}
let Back = () => {
document.querySelector('.tool').style.display = 'none';
cun();
layers.setVisible(false);
zhen();
let arr = [
'2019-2022gaobiaozhunnongtian',
'gbz',
'dianjigaoliang',
'dianjigaoliangs',
'gao',
'zhezhao',
];
arr.forEach(item => {
map.getLayers()
.getArray()
.forEach((ite, index) => {
if (ite.A.name == item || ite.A.id == item) {
map.getLayers().removeAt(index);
}
});
});
// let layerzhezhao = map
// .getLayers()
// .getArray()
// .find(layer => layer.get('id') === 'zhezhao');
// map.removeLayer(layerzhezhao);
// let layerzhezhaos = map
// .getLayers()
// .getArray()
// .find(layer => layer.get('id') === 'gbz');
// map.removeLayer(layerzhezhaos);
// var layergaoliang = map
// .getLayers()
// .getArray()
// .find(layer => layer.get('id') === 'dianjigaoliang');
// map.removeLayer(layergaoliang);
// var layergaoliang = map
// .getLayers()
// .getArray()
// .find(layer => layer.get('id') === 'dianjigaoliangs');
// map.removeLayer(layergaoliang);
var view = map.getView();
view.animate({
center: ['119.88661841637813', '35.85667692242919'], // 设置新的地图中心点坐标
duration: 1000, // 动画过渡时间
zoom: 11, // 设置新的地图缩放级别
});
};
const selectTab = () => {
if (value.value == '370211') {
getstatisticsOfTheAreas(value.value, oldDatas.value.name); //冷冻等级面积统计
getproportionOfAreas(value.value, oldDatas.value.name);
getTownships(value.value, oldDatas.value.name); //更新镇的数据
} else {
getstatisticsOfTheAreas(value.value, oldDatas.value.name); //冷冻等级面积统计
getproportionOfAreas(value.value, oldDatas.value.name);
getadministratives(value.value, oldDatas.value.name);
}
};
//下载
/*---------------------------*/
const Deta = item => {
getstatisticsOfTheArea({
divisions: value.value,
yearMonth: oldDatas.value.name,
whetherToDownload: true,
}).then(res => {
downLoadFile(res.data[res.data.length - 1].downloadPath);
});
};
const Deta2 = item => {
getproportionOfArea({
divisions: value.value,
yearMonth: oldDatas.value.name,
whetherToDownload: true,
}).then(res => {
downLoadFile(res.data[res.data.length - 1].downloadPath);
});
};
const Deta3 = item => {
geteachFreezingGradeArea({
divisions: value.value,
yearMonth: oldDatas.value.name,
whetherToDownload: false,
}).then(res => {
let arr = [];
let brr = [];
res.data.forEach(item => {
if (arr.indexOf(item.region) == -1) {
arr.push(item.region);
}
});
arr.forEach(item => {
brr.push(
Object.create(null, {
regio: {
value: item,
},
})
);
});
brr.forEach(item => {
res.data.map(i => {
if (item.regio === i.region) {
item['region'] = i.region;
item[i.level] = Number(i.area).toFixed(2);
}
});
});
exportExcel(brr, '各冷冻面积统计-高标准农田', 'Sheet1');
});
};
const Deta4 = item => {
if (value.value === '370211') {
getTownship({ divisions: value.value, yearMonth: oldDatas.value.name }).then(res => {
let arr = [];
let brr = [];
res.data.forEach(item => {
if (arr.indexOf(item.streetName) == -1) {
arr.push(item.streetName);
}
});
arr.forEach(item => {
brr.push(
Object.create(null, {
regio: {
value: item,
},
})
);
});
brr.forEach(item => {
res.data.map(i => {
if (item.regio === i.streetName) {
item['region'] = i.streetName;
item[i.type] = Number(i.area).toFixed(2);
}
});
});
brr = brr.sort((a, b) => {
return a.region.length - b.region.length;
});
exportExcel(brr, '各冷冻面积统计-行政区划', '行政区划');
});
} else {
getadministrative({
divisions: value.value,
yearMonth: oldDatas.value.name,
whetherToDownload: false,
}).then(res => {
let arr = [];
let brr = [];
res.data.forEach(item => {
if (arr.indexOf(item.streetName) == -1) {
arr.push(item.streetName);
}
});
arr.forEach(item => {
brr.push(
Object.create(null, {
regio: {
value: item,
},
})
);
});
brr.forEach(item => {
res.data.map(i => {
if (item.regio === i.streetName) {
item['region'] = i.streetName;
item[i.type] = Number(i.area).toFixed(2);
}
});
});
exportExcel(brr, '各冷冻面积统计-行政区划', 'Sheet1');
});
}
};
//表头数据切换 ----------前端生成excel
const changeTableHead = (tableData, fieldName) => {
const list = tableData.map(item => {
const obj = {};
for (const k in item) {
if (fieldName[k] == '区域名称') {
obj[fieldName[k]] = item[k];
}
}
for (const k in item) {
if (fieldName[k] == '无冻害(亩)') {
obj[fieldName[k]] = item[k];
}
}
for (const k in item) {
if (fieldName[k] == '轻度冻害(亩)') {
obj[fieldName[k]] = item[k];
}
}
for (const k in item) {
if (fieldName[k] == '中度冻害(亩)') {
obj[fieldName[k]] = item[k];
}
}
for (const k in item) {
if (fieldName[k] == '重度冻害(亩)') {
obj[fieldName[k]] = item[k];
}
}
return obj;
});
return list;
};
const exportExcel = (tableData, fileName = '用户列表', pageName = 'Sheet1') => {
let fieldNameObj = {
region: '区域名称',
无冻害: '无冻害(亩)',
轻度冻害: '轻度冻害(亩)',
中度冻害: '中度冻害(亩)',
重度冻害: '重度冻害(亩)',
};
const list = changeTableHead(tableData, fieldNameObj);
// 创建工作表
const data = xlsx.utils.json_to_sheet(list);
// 创建工作簿
const wb = xlsx.utils.book_new();
// 将工作表放入工作簿中
xlsx.utils.book_append_sheet(wb, data, pageName);
// 生成文件并下载
xlsx.writeFile(wb, `${fileName}.xlsx`);
};
const handleData = oldData => {
for (const key in layersDic) {
map.getLayers()
.getArray()
.forEach((ite, index) => {
if (ite.A.name) {
if (layersDic[key].name == ite.A.name) {
map.getLayers().removeAt(index);
}
}
});
}
Tabtime.value += 1;
checkListdata.value = [];
let arr = [];
for (const key in layersDic) {
map.getLayers()
.getArray()
.forEach((ite, index) => {
if (ite.A.name == layersDic[key].name) {
map.getLayers().removeAt(index);
}
});
}
oldDatas.value = oldData;
getstatisticsOfTheArea({ divisions: '370211', yearMonth: oldDatas.value.name }).then(res => {
res.data.forEach(item => {
if (Number(item.area) > 1) {
dic.value[item.level].disabled = false;
} else {
dic.value[item.level].disabled = true;
}
arr = dic;
});
for (const key in arr.value) {
if (arr.value[key].disabled !== true) {
checkListdata.value.push(key);
}
}
checkList.value = checkListdata.value;
checkList.value.forEach(item => {
addwms(layersDic[item]);
});
});
};
/*-------------echarts--------------*/
function areachar() {
const areaDivIntance = echarts.init(areaDiv.value);
var option = {
textStyle: {
fontSize: 0,
},
grid: {
top: '15%',
left: '5%',
right: '5%',
bottom: '10%',
containLabel: true,
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
legend: {
show: true,
top: '5%',
data: ['面积'],
right: '5%',
icon: 'rect',
textStyle: {
fontSize: 14, //字体大小
color: 'rgba(153, 153, 153, 1)', //字体颜色
},
},
xAxis: {
nameTextStyle: {
color: 'rgba(153, 153, 153, 1)',
padding: [0, 0, -10, 0],
fontSize: 14,
},
axisLabel: {
color: 'rgba(153, 153, 153, 1)',
fontWeight: 400,
fontFamily: 'SourceHanSansCN-Regular, SourceHanSansCN',
fontSize: 14,
},
axisTick: {
lineStyle: {
color: '#0B1535',
width: 1,
},
show: false,
},
splitLine: {
show: false,
},
axisLine: {
lineStyle: {
color: '#384267',
width: 1,
type: 'dashed',
},
show: true,
},
data: areacharData.lable,
type: 'category',
},
yAxis: {
name: '面积(亩)',
nameTextStyle: {
color: 'rgba(153, 153, 153, 1)',
fontSize: 14,
},
type: 'value',
axisLabel: {
color: 'rgba(153, 153, 153, 1)',
},
splitLine: {
lineStyle: {
type: 'dashed',
},
},
minInterval: 1,
axisLine: {
show: false,
},
axisTick: {
show: false,
},
},
series: [
{
data: areacharData.value,
name: '面积',
type: 'bar',
barMaxWidth: 'auto',
barWidth: 35,
itemStyle: {
color: {
x: 0,
y: 0,
x2: 0,
y2: 1,
type: 'linear',
global: false,
colorStops: [
{
offset: 0,
color: 'rgba(33, 156, 249, 1)',
},
{
offset: 1,
color: 'rgba(110, 191, 251, 1)',
},
],
},
},
label: {
normal: {
show: false,
fontSize: 14,
color: '#ffffff',
position: 'top',
},
},
},
],
};
option && areaDivIntance.setOption(option);
let erd = elementResizeDetectorMaker();
erd.listenTo(areaDiv.value, () => {
nextTick(() => {
areaDivIntance.resize();
});
});
}
function typesof() {
const typesofDivIntance = echarts.init(typesofDiv.value);
var data = typesofData.value;
let option = {
color: [
'rgba(9, 187, 222, 0.8)',
'rgba(255, 235, 59, 0.8)',
'rgba(234, 165, 93, 0.8)',
'rgba(224, 13, 15, 1)',
'#585247',
'#7F6AAD',
'#009D85',
'rgba(250,250,250,0.3)',
],
title: {
text: '总面积',
subtext: `${(totalArea.value / 10000).toFixed(2)}万亩`,
textStyle: {
color: 'rgba(51, 51, 51, 1)',
fontSize: 14,
// align: 'center'
},
subtextStyle: {
fontSize: 14,
color: ['#ff9d19'],
},
x: 'center',
y: 'center',
},
grid: {
top: 0,
},
legend: {
orient: 'vertical',
top: 'middle',
right: '2%',
textStyle: {
color: 'rgba(51, 51, 51, 1)',
fontSize: 14,
},
icon: 'roundRect',
data: data,
},
tooltip: {
//提示框组件
trigger: 'item', //item数据项图形触发主要在散点图饼图等无类目轴的图表中使用。
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: 'shadow', // 默认为直线,可选为:'line' | 'shadow'
},
formatter: '{a} <br/>{b} : {c} <br/>百分比 : {d}%', //{a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)
},
series: [
// 主要展示层的
{
radius: ['50%', '71%'],
center: ['50%', '50%'],
type: 'pie',
label: {
normal: {
show: false,
},
},
labelLine: {
normal: {
show: false,
},
},
name: '各冷冻等级面积占比',
data: data,
},
// 边框的设置
{
radius: ['50%', '54%'],
center: ['50%', '50%'],
type: 'pie',
label: {
normal: {
show: false,
},
emphasis: {
show: false,
},
},
labelLine: {
normal: {
show: false,
},
emphasis: {
show: false,
},
},
animation: false,
tooltip: {
show: false,
},
data: [
{
value: 1,
itemStyle: {
color: 'rgba(250,250,250,0.3)',
},
},
],
},
],
};
useEcharts(typesofDivIntance, option);
let erd = elementResizeDetectorMaker();
erd.listenTo(typesofDiv.value, () => {
nextTick(() => {
typesofDivIntance.resize();
});
});
}
function farmland() {
const farmlandDivIntance = echarts.init(farmlandDiv.value);
let option = {
title: {
text: '',
subtext: '',
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
// legend: {
// icon: 'circle',
// left: 'center',
// top: '5',
// show: true,
// },
grid: {
top: '15%',
left: '5%',
right: '5%',
bottom: '10%',
containLabel: true,
},
xAxis: {
type: 'category',
data: highStandard,
axisLine: {
lineStyle: {
color: 'rgba(153, 153, 153, 1)',
width: 1,
type: 'solid',
},
},
axisLabel: {
color: 'rgba(153, 153, 153, 1)',
fontWeight: 400,
fontFamily: 'SourceHanSansCN-Regular, SourceHanSansCN',
fontSize: 14,
},
},
yAxis: {
name: '面积(亩)',
nameTextStyle: {
color: 'rgba(153, 153, 153, 1)',
fontSize: 14,
},
type: 'value',
axisLabel: {
color: 'rgba(153, 153, 153, 1)',
},
splitLine: {
lineStyle: {
type: 'solid',
color: 'rgba(153, 153, 153, 1)',
},
},
minInterval: 1,
axisLine: {
show: false,
},
axisTick: {
show: false,
},
},
series: [
{
name: '无冻害',
type: 'bar',
barWidth: 14,
stack: '数量',
data: highStandarditem['无冻害'],
itemStyle: {
normal: {
borderWidth: 1,
//颜色渐变
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(9, 187, 222, 0.8)',
},
{
offset: 1,
color: 'rgba(9, 187, 222, 0.8)',
},
]),
},
},
},
{
name: '轻度冻害',
type: 'bar',
barWidth: 14,
stack: '数量',
data: highStandarditem['轻度冻害'],
itemStyle: {
normal: {
borderWidth: 1,
//颜色渐变
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(255, 235, 59, 0.8)',
},
{
offset: 1,
color: 'rgba(255, 235, 59, 0.8)',
},
]),
},
},
},
{
name: '中度冻害',
type: 'bar',
barWidth: 14,
stack: '数量',
data: highStandarditem['中度冻害'],
itemStyle: {
normal: {
borderWidth: 1,
//颜色渐变
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(234, 165, 93, 0.8)',
},
{
offset: 1,
color: 'rgba(234, 165, 93, 0.8)',
},
]),
},
},
},
{
name: '重度冻害',
type: 'bar',
barWidth: 14,
stack: '数量',
data: highStandarditem['重度冻害'],
itemStyle: {
normal: {
borderWidth: 1,
//颜色渐变
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(224, 13, 15, 1)',
},
{
offset: 1,
color: 'rgba(224, 13, 15, 1)',
},
]),
},
},
},
],
};
farmlandDivIntance.on('click', function (param) {
//验证是否是域名
var domain = window.location.host;
var rule = /^(([-\u4E00-\u9FA5a-z0-9]{1,63})\.)+([\u4E00-\u9FA5a-z]{2,63})\.?$/;
if (!rule.test(domain)) {
document.querySelector('.tool').style.display = 'block';
paramCode.value = param.name;
let arr = ['XJQY3702112019WGS84', 'CJQY3702112019WGS84'];
SQLData(param.name);
arr.forEach(item => {
map.getLayers()
.getArray()
.forEach((ite, index) => {
if (ite.A.name == item) {
map.getLayers().removeAt(index);
}
});
});
var popups = document.querySelectorAll('.alerDiv');
for (var i = 0; i < popups.length; i++) {
var popup = popups[i];
// popup.parentNode.removeChild(popup);
popup.style.display = 'none';
}
let arrs = ['2019-2022gaobiaozhunnongtian', 'gbz', 'dianjigaoliang', 'dianjigaoliangs'];
arrs.forEach(item => {
map.getLayers()
.getArray()
.forEach((ite, index) => {
if (ite.A.name == item || ite.A.id == item) {
map.getLayers().removeAt(index);
}
});
});
layers = new ol.layer.Tile({
source: new ol.source.TileSuperMapRest({
url: `${serverAPI.geoserverUrl}/map-2019-2022gaobiaozhunnongtian/rest/maps/T2019_2022%E9%AB%98%E6%A0%87%E5%87%86%E5%86%9C%E7%94%B0%E7%89%87%E5%8C%BA@2019-2022gaobiaozhunnongtian`,
//rasterfunction: new SuperMap.NDVIParameter({ redIndex: 0, nirIndex: 2 }),
cacheEnabled: false,
}),
name: '2019-2022gaobiaozhunnongtian',
projection: 'EPSG:4326', //3857
zIndex: 9999,
});
map.addLayer(layers);
}
});
option && farmlandDivIntance.setOption(option, { notMerge: true, grid: { bottom: 20 } });
useEcharts(farmlandDivIntance, option);
let erd = elementResizeDetectorMaker();
erd.listenTo(farmlandDiv.value, () => {
nextTick(() => {
farmlandDivIntance.resize();
});
});
}
function chartModes() {
const ASdivisionDivIntance = echarts.init(chartModeDiv.value);
let arr = [];
let 无冻害 = [];
let 轻度冻害 = [];
let 中度冻害 = [];
let 重度冻害 = [];
insectarr.value.forEach(item => {
arr.push(item.region);
item.无冻害 !== undefined ? 无冻害.push(item.无冻害) : 无冻害.push(0);
item.中度冻害 !== undefined ? 中度冻害.push(item.中度冻害) : 中度冻害.push(0);
item.重度冻害 !== undefined ? 重度冻害.push(item.重度冻害) : 重度冻害.push(0);
item.轻度冻害 !== undefined ? 轻度冻害.push(item.轻度冻害) : 轻度冻害.push(0);
});
let ends = (10 / arr.length) * 100;
let option = {
tooltip: {
trigger: 'axis',
formatter: function (params) {
let tipStr = params[0].axisValueLabel + '</br>';
let totalNum = 0;
for (let i = 0; i < params.length; i++) {
totalNum += params[i].value;
if (params[i].seriesName !== '合计') {
tipStr += params[i].seriesName + '' + params[i].value + '</br>';
}
}
for (let i = 0; i < params.length; i++) {
totalNum += Number(params[i].value);
if (params[i].seriesName === '合计') {
tipStr += '合计:' + totalNum;
}
}
return tipStr;
},
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: 'shadow', // 默认为直线,可选为:'line' | 'shadow'
},
},
dataZoom: [
{
type: 'slider',
width: '40%',
top: '90%',
zoomLock: true, //禁止拉伸
start: 0,
end: ends,
showDataShadow: false,
showDetail: false,
fillerColor: 'rgba(64, 158, 255)',
borderRadius: '50%',
moveHandleSize: 0,
moveHandleStyle: {},
left: '30%',
height: 12,
handleSize: '80%',
handleIcon: 'path://M512,512m-448,0a448,448,0,1,0,896,0a448,448,0,1,0,-896,0Z',
handleStyle: {
borderWidth: 0,
color: 'rgba(64, 158, 255)',
},
},
{
type: 'inside',
},
],
legend: {
top: 5,
left: 10,
icon: 'rect',
itemWidth: 4, // 图例图表宽度
itemHeight: 12, // 图例图标高度
data: [],
},
grid: {
left: '3%',
right: '10%',
bottom: '15%',
top: '5%',
containLabel: true,
},
xAxis: {
type: 'category',
name: '区域',
axisLabel: {
fontSize: 12,
interval: 0,
rotate: 0,
},
axisLine: {
lineStyle: {
// color: '#cbeaf6', // x坐标轴线颜色
},
},
data: arr,
},
yAxis: [
{
type: 'value',
name: '面积(亩)',
axisLabel: {
color: '#cbeaf6', // 坐标轴label文字颜色
},
axisLine: {
lineStyle: {
// color: '#cbeaf6', // y坐标轴线颜色
},
},
splitLine: {
// 网格线
lineStyle: {
// type: 'dashed', // 设置网格线类型 dotted虚线 solid:实线
// color: '#395367',
},
show: true, // 隐藏或显示
},
},
],
series: [
{
name: '无冻害',
type: 'bar',
barWidth: 13,
stack: '分类',
itemStyle: {
color: 'rgba(32, 242, 255, 1)',
},
data: 无冻害,
},
{
name: '轻度冻害',
type: 'bar',
barWidth: 13,
stack: '分类',
itemStyle: {
color: 'rgba(255, 255, 0, 1)',
},
data: 轻度冻害,
},
{
name: '中度冻害',
type: 'bar',
barWidth: 13,
stack: '分类',
itemStyle: {
color: 'rgba(255, 168, 8, 1)',
},
data: 中度冻害,
},
{
name: '重度冻害',
type: 'bar',
barWidth: 13,
stack: '分类',
itemStyle: {
color: 'rgba(224, 13, 15, 1)',
},
data: 重度冻害,
},
],
};
var series = option.series;
var tooltip = option.tooltip;
// 提示框自定义内容包括总合及文字
function formatFun(params) {
let tipStr = params[0].axisValueLabel + '</br>'; // 初始化提示框文字默认当前轴名称并换行
let totalNum = 0; // 用于存储当前列总数
// params为当前柱状图数组数量 遍历求和并添加类目labelvalue
for (let i = 0; i < params.length; i++) {
if (params[i].seriesName !== '合计') {
const dotHtml = `<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${params[i].color}"></span>`;
totalNum += params[i].value;
tipStr += dotHtml + params[i].seriesName + '' + params[i].value + '</br>';
}
}
// 添加最后的合计行 数据为每列总合
for (let i = 0; i < params.length; i++) {
if (params[i].seriesName === '合计') {
tipStr += '合计:' + totalNum;
}
}
return tipStr;
}
tooltip.formatter = formatFun;
// 指定函数计算总合
function fun(params) {
var dataSum = 0;
for (var i = 0; i < series.length; i++) {
dataSum += series[i].data[params.dataIndex];
}
return dataSum;
}
// 加载页面时候替换最后一个series的formatter
// series[series.length - 1].label.normal.formatter = fun;
useEcharts(ASdivisionDivIntance, option);
}
//每页条数
const handleCurrentChange = val => {
currentPage.value = val;
tableNewData.value = insectarr.value.slice(
(currentPage.value - 1) * pageSize.value,
(currentPage.value - 1) * pageSize.value + pageSize.value
);
};
const Nindex = index => {
// 当前页数 - 1 * 每页数据条数 + 1
const page = currentPage.value; // 当前页码
const pagesize = pageSize.value; // 每页条数
return index + 1 + (page - 1) * pagesize;
};
//返回
function back() {
getTownships('370211');
delete townZuowu.value.XZQMC;
deleteEntityByName('townLine');
deleteEntityByName('villageLine');
removeWms(['gbznt'], true);
removeWms(['aaa']);
value.value = '370211';
selectTab();
if (flag.value === '1') {
addWms('huangdaoqu_town', 'huangdaoqu_town');
}
viewer.camera.flyTo({
destination: Cesium.Rectangle.fromDegrees(119.5091, 35.5671, 120.3285, 36.1455),
duration: 2,
});
flag.value = false;
}
function ASdivision() {
const ASdivisionDivIntance = echarts.init(ASdivisionDiv.value);
var option = {
// 设置图表的位置
grid: {
bottom: '8%',
left: '10%',
right: '6%',
top: '12%',
containLabel: true,
},
tooltip: {
formatter: function (params) {
// 自定义悬浮文字的格式params.value 为当前柱状图的数值
let a = 0;
Township.brr.forEach(item => {
if (item.type == params.seriesName && item.streetName == params.name) {
a = Number(item.area).toFixed(2);
}
});
return (
params.seriesName +
'<span style="font-size: 14px; color: #f00;">' +
a +
'</span>' +
'亩'
);
},
},
dataZoom: [
{
type: 'slider',
show: false,
zoomLock: true, //禁止拉伸
width: 8,
yAxisIndex: [0],
bottom: 30,
top: 20,
right: 10,
startValue: 0,
endValue: 4,
handleIcon:
'M-292,322.2c-3.2,0-6.4-0.6-9.3-1.9c-2.9-1.2-5.4-2.9-7.6-5.1s-3.9-4.8-5.1-7.6c-1.3-3-1.9-6.1-1.9-9.3c0-3.2,0.6-6.4,1.9-9.3c1.2-2.9,2.9-5.4,5.1-7.6s4.8-3.9,7.6-5.1c3-1.3,6.1-1.9,9.3-1.9c3.2,0,6.4,0.6,9.3,1.9c2.9,1.2,5.4,2.9,7.6,5.1s3.9,4.8,5.1,7.6c1.3,3,1.9,6.1,1.9,9.3c0,3.2-0.6,6.4-1.9,9.3c-1.2,2.9-2.9,5.4-5.1,7.6s-4.8,3.9-7.6,5.1C-285.6,321.5-288.8,322.2-292,322.2z',
handleSize: '100%',
handleStyle: {
color: '#DBDBDB',
height: '100%',
},
backgroundColor: 'transparent',
fillerColor: '#DBDBDB',
textStyle: {
color: 'transparent',
},
dataBackground: {
lineStyle: {
color: 'transparent',
},
areaStyle: {
color: 'transparent',
},
},
borderColor: 'transparent',
},
{
type: 'inside',
id: 'insideY',
yAxisIndex: 0,
start: 0,
end: 50,
zoomOnMouseWheel: false,
moveOnMouseMove: true,
moveOnMouseWheel: true,
},
],
// X轴
xAxis: {
type: 'value', // 坐标轴类型, 'value' 数值轴,适用于连续数据
// 坐标轴刻度
axisTick: {
show: false, // 是否显示坐标轴刻度 默认显示
},
// 坐标轴轴线
axisLine: {
// 是否显示坐标轴轴线 默认显示
show: false, // 是否显示坐标轴轴线 默认显示
},
// 坐标轴在图表区域中的分隔线
splitLine: {
show: false, // 是否显示分隔线。默认数值轴显示
},
// 坐标轴刻度标签
axisLabel: {
show: false, // 是否显示刻度标签 默认显示
},
},
// Y轴
yAxis: [
// 左侧Y轴
{
// 坐标轴类型, 'category' 类目轴,适用于离散的类目数据
// 为该类型时必须通过 data 设置类目数据
type: 'category',
// 坐标轴刻度
axisTick: {
show: false, // 是否显示坐标轴刻度 默认显示
},
// 坐标轴轴线
axisLine: {
// 是否显示坐标轴轴线 默认显示
show: false, // 是否显示坐标轴轴线 默认显示
lineStyle: {
// 坐标轴线线的颜色
color: '#cdd3ee',
},
},
// 坐标轴在图表区域中的分隔线
splitLine: {
show: false, // 是否显示分隔线。默认数值轴显示
},
// 坐标轴刻度标签
axisLabel: {
show: true, // 是否显示刻度标签 默认显示
fontSize: 12, // 文字的字体大小
color: 'rgba(51, 51, 51, 1)', // 刻度标签文字的颜色
// 使用字符串模板,模板变量为刻度默认标签 {value}
formatter: '{value}',
},
// 类目数据在类目轴type: 'category')中有效
data: data.title,
inverse: true,
},
],
// 系列列表
series: [
{
type: 'bar', // 系列类型
name: '无冻害', // 系列名称, 用于tooltip的显示, legend 的图例筛选
// 数据堆叠同个类目轴上系列配置相同的stack值后后一个系列的值会在前一个系列的值上相加
stack: '总量',
barMaxWidth: 30, // 柱条的最大宽度,不设时自适应
// 图形上的文本标签
label: {
show: false,
position: '无冻害',
textStyle: {
fontSize: 12,
fontWeight: 'bolder',
color: 'rgba(255,255,255,1)',
},
},
// 图形样式
itemStyle: {
barBorderRadius: [0, 0, 0, 0],
barBorderRadius: [0, 0, 0, 0], //
// borderWidth: 1, // 设置边框宽度
// borderColor: 'rgba(4, 247, 227, 0.8)', // 设置边框颜色
color: {
colorStops: [
{
offset: 0,
color: 'rgba(32, 242, 255, 1)', // 0% 处的颜色
},
{
offset: 1,
color: 'rgba(32, 242, 255, 1)', // 100% 处的颜色
},
],
},
},
data: dd.无冻害, // 系列中的数据内容数组
},
{
type: 'bar', // 系列类型
name: '轻度冻害', // 系列名称, 用于tooltip的显示, legend 的图例筛选
// 数据堆叠同个类目轴上系列配置相同的stack值后后一个系列的值会在前一个系列的值上相加
stack: '总量',
barMaxWidth: 30, // 柱条的最大宽度,不设时自适应
// 图形上的文本标签
label: {
show: false,
position: 'inside',
formatter: '轻度冻害',
textStyle: {
fontSize: 12,
fontWeight: 'bolder',
color: 'rgba(255,255,255,1)',
},
},
// 图形样式
itemStyle: {
barBorderRadius: [0, 0, 0, 0], //
// borderWidth: 1, // 设置边框宽度
// borderColor: 'rgba(143, 186, 243, 0.8)', // 设置边框颜色
color: {
colorStops: [
{
offset: 0,
color: 'rgba(255, 255, 0, 1)', // 0% 处的颜色
},
{
offset: 1,
color: 'rgba(255, 255, 0, 1)', // 100% 处的颜色
},
],
},
},
data: dd.轻度冻害, // 系列中的数据内容数组
},
{
type: 'bar', // 系列类型
name: '中度冻害', // 系列名称, 用于tooltip的显示, legend 的图例筛选
// 数据堆叠同个类目轴上系列配置相同的stack值后后一个系列的值会在前一个系列的值上相加
stack: '总量',
barMaxWidth: 30, // 柱条的最大宽度,不设时自适应
// 图形上的文本标签
label: {
show: false,
position: 'inside',
formatter: '中度冻害',
textStyle: {
fontSize: 12,
fontWeight: 'bolder',
color: 'rgba(255,255,255,1)',
},
},
// 图形样式
itemStyle: {
barBorderRadius: [0, 0, 0, 0],
barBorderRadius: [0, 0, 0, 0], //
// borderWidth: 1, // 设置边框宽度
// borderColor: 'rgba(4, 247, 227, 0.9)', // 设置边框颜色
color: {
colorStops: [
{
offset: 0,
color: 'rgba(255, 168, 8, 1)', // 0% 处的颜色
},
{
offset: 1,
color: 'rgba(255, 168, 8, 1)', // 100% 处的颜色
},
],
},
},
data: dd.中度冻害, // 系列中的数据内容数组
},
{
type: 'bar', // 系列类型
name: '重度冻害', // 系列名称, 用于tooltip的显示, legend 的图例筛选
// 数据堆叠同个类目轴上系列配置相同的stack值后后一个系列的值会在前一个系列的值上相加
stack: '总量',
barMaxWidth: 30, // 柱条的最大宽度,不设时自适应
// 图形上的文本标签
label: {
show: false,
position: 'inside',
formatter: '重度冻害',
textStyle: {
fontSize: 12,
fontWeight: 'bolder',
color: 'rgba(255,255,255,1)',
},
},
// 图形样式
itemStyle: {
barBorderRadius: [0, 0, 0, 0],
barBorderRadius: [0, 0, 0, 0], //
// borderWidth: 1, // 设置边框宽度
// borderColor: 'rgba(33, 187, 251, 0.8)', // 设置边框颜色
color: {
colorStops: [
{
offset: 0,
color: 'rgba(224, 13, 15, 1)', // 0% 处的颜色
},
{
offset: 1,
color: 'rgba(224, 13, 15, 1)', // 100% 处的颜色
},
],
},
},
data: dd.重度冻害, // 系列中的数据内容数组
},
],
};
// option && ASdivisionDivIntance.setOption(option, true);
useEcharts(ASdivisionDivIntance, option);
let erd = elementResizeDetectorMaker();
erd.listenTo(ASdivisionDiv.value, () => {
nextTick(() => {
ASdivisionDivIntance.resize();
});
});
}
</script>
<style lang="scss" scoped>
$height: calc(100vh - 100px);
.fatherDiv,
.tabulation,
.centerBox {
width: 100%;
height: 100%;
.imgrotate {
transform: rotate(180deg);
}
.title {
width: 90%;
margin: 15px;
height: 37px;
border-radius: 3px 3px, 0px, 0px;
background: linear-gradient(90deg, rgba(208, 245, 233, 1) 0%, rgba(255, 255, 255, 1) 100%);
font-size: 18px;
font-weight: 700;
line-height: 37px;
padding-left: 16px;
display: flex;
align-items: center;
cursor: pointer;
span {
width: 80%;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
font-size: 16px;
font-weight: 700;
color: rgba(51, 51, 51, 1);
background-clip: text;
-webkit-background-clip: text;
}
p {
width: 79px;
height: 25px;
border-radius: 20px;
font-size: 14px;
border-radius: 4px;
background: rgba(100, 195, 164, 1);
display: flex;
color: rgba(255, 255, 255, 1);
justify-content: center;
align-items: center;
}
}
}
.tabulation {
display: none;
padding: 20px;
.tableBox {
padding: 0 10px;
.tableBorder {
border-radius: 8px;
margin-bottom: 10px;
.el-table--fit {
border-radius: 8px;
border: 2px solid rgba(100, 195, 164, 0.8);
box-shadow: 0px 3px 9px 0px rgba(100, 195, 164, 0.25),
0px 1px 2px 0px rgba(100, 195, 164, 0.8);
}
}
:deep(
.el-table .el-table__header-wrapper th,
.el-table .el-table__fixed-header-wrapper th
) {
color: rgba(0, 0, 0, 1);
}
height: 84%;
:deep(.el-table__inner-wrapper) {
height: 96% !important;
}
.example-pagination-block {
display: flex;
align-items: center;
justify-content: flex-end;
}
:deep(.tabth) {
background-color: rgba(247, 247, 247, 1);
}
}
.chartMode {
width: 100%;
height: 85%;
.chartModeDiv {
width: 100%;
height: 100%;
padding: 10px;
}
}
.searchDiv {
display: flex;
:deep(.el-input__wrapper) {
width: 130px;
}
.dow {
float: right;
margin-right: 10px;
}
.modeDiv {
width: 234px;
height: 26px;
opacity: 1;
border-radius: 8px;
display: flex;
justify-content: flex-start;
align-items: center;
text-align: center;
font-size: 14px;
// font-weight: 400;
border: 1px solid #ccc;
cursor: pointer;
div {
flex: 1;
height: 100%;
border-radius: 8px;
line-height: 26px;
}
.Selected {
background: rgba(100, 195, 164, 1);
border-radius: 8px 0px 0px 8px;
color: rgba(255, 255, 255, 1);
}
.Selecteds {
background: rgba(100, 195, 164, 1);
border-radius: 0px 8px 8px 0px;
color: rgba(255, 255, 255, 1);
}
}
}
}
.rightWra {
position: absolute;
top: 0px;
right: 0px;
width: 23%;
height: calc(100vh - 97px);
opacity: 1;
display: flex;
flex-direction: column;
align-items: center;
background: rgba(255, 255, 255, 1);
box-shadow: -6px 0px 8px rgba(0, 0, 0, 0.1), 0px 0px 3px rgba(0, 0, 0, 0.09),
0px 0px 6px rgba(0, 0, 0, 0.06), 0px 0px 9px rgba(0, 0, 0, 0.03);
transition: transform 1s;
.tabar {
width: 90%;
margin: 15px 15px 0 15px;
height: 34px;
display: flex;
padding: 0 15px;
justify-content: space-around;
div {
width: 45%;
line-height: 34px;
text-align: center;
background: rgba(255, 255, 255, 1);
border: 1px solid rgba(100, 195, 164, 1);
font-size: 14px;
font-weight: 400;
letter-spacing: 0px;
color: rgba(100, 195, 164, 1);
border-radius: 4px;
cursor: pointer;
}
.tabarS {
background: rgba(100, 195, 164, 1);
border: 1px solid rgba(100, 195, 164, 1);
color: rgba(255, 255, 255, 1);
}
}
.rightFoldDiv {
width: 28px;
height: 30px;
position: absolute;
left: 0;
top: 50%;
transform: translate(-100%, -50%);
font-size: 30px;
color: #ccc;
cursor: pointer;
}
.leftTop {
width: 100%;
display: flex;
flex-direction: column;
height: calc(40% - 25px);
.areaDiv {
width: 100%;
height: calc(100% - 67px);
opacity: 1;
display: flex;
padding: 1px;
justify-content: center;
}
.ProgressBar {
width: 100%;
height: 9px;
opacity: 1;
}
}
.leftbottom {
width: 100%;
height: calc(60% - 25px);
opacity: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
.typesofDiv {
width: 100%;
height: calc(50% - 33px);
opacity: 1;
display: flex;
padding: 1px;
justify-content: center;
}
.tableDiv {
background: rgba(255, 255, 255, 0.05);
display: flex;
justify-content: center;
width: 85%;
flex-direction: column;
color: rgba(51, 51, 51, 1);
height: calc(50% - 33px);
:deep(.el-table__header-wrapper) {
background-color: rgba(100, 195, 164, 0.2);
}
:deep(tbody) {
background-color: rgba(243, 253, 250, 1);
}
:deep(.el-table tr) {
background-color: transparent;
}
:deep(.el-table) {
--el-table-border-color: none;
color: rgba(51, 51, 51, 1);
}
:deep(th) {
color: rgba(63, 161, 128, 1) !important;
font-size: 14px;
font-weight: 700;
}
:deep(.el-table--enable-row-hover .el-table__body tr:hover > td.el-table__cell) {
background-color: revert;
}
.Crops {
display: flex;
width: 100%;
margin-bottom: 10px;
font-size: 14px;
font-weight: 400;
height: 31px;
flex-direction: row;
align-items: center;
justify-content: space-around;
opacity: 1;
background: linear-gradient(
90deg,
rgba(21, 173, 148, 0.1) 0%,
rgba(21, 173, 148, 0) 100%
);
div {
display: flex;
align-items: center;
}
}
.el-checkbox-group {
display: flex;
flex-direction: column;
}
:deep(.ones) {
width: 100%;
height: 171;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
--el-table-tr-bg-color: null;
--el-table-border-color: null;
font-size: 14px;
font-weight: 400;
letter-spacing: 0px;
line-height: 0px;
color: rgba(255, 255, 255, 1);
}
}
}
.rightTop {
width: 100%;
height: calc(50% - 25px);
opacity: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
.farmlandDiv {
width: 100%;
height: calc(100% - 67px);
opacity: 1;
display: flex;
justify-content: center;
}
.ProgressBar {
width: 100%;
height: 9px;
opacity: 1;
}
}
.rightbottom {
width: 100%;
height: calc(50% - 25px);
opacity: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
.el-select {
width: 80%;
font-size: 14px;
color: #333;
background: rgba(255, 255, 255, 1);
border: 1px solid rgba(228, 231, 237, 1);
:deep(.el-input__wrapper) {
background-color: transparent;
box-shadow: none;
}
}
.ASdivision {
width: 100%;
height: calc(100% - 100px);
opacity: 1;
display: flex;
justify-content: center;
}
}
}
.legend {
position: absolute;
right: 25%;
bottom: 60px;
width: 129px;
border-radius: 4px;
background: rgba(255, 255, 255, 1);
// height: 50px;
:deep(.el-collapse-item__header) {
border-radius: 4px;
color: rgba(51, 51, 51, 1);
font-size: 14px;
font-weight: 400;
text-align: center;
padding: 0 30px;
.el-icon {
color: rgba(100, 195, 164, 1);
}
}
--el-collapse-content-bg-color {
background: rgba(2, 31, 26, 0.6);
}
:deep(.el-collapse-item__content) {
padding: 0 10px;
padding-bottom: 10px;
}
--el-collapse-border-color: none;
--el-collapse-content-bg-color: none;
// opacity: 1;
// border-radius: 4px;
// background: rgba(2, 31, 26, 0.6);
// display: flex;
// flex-direction: column;
// justify-content: flex-start;
// align-items: center;
// padding: 10px 10px 10px 10px;
p {
margin: 10px;
font-size: 14px;
font-weight: 400;
letter-spacing: 0px;
line-height: 0px;
color: rgba(255, 255, 255, 1);
text-align: center;
}
.mt-4 {
.el-checkbox {
height: 30px;
width: 100%;
margin-bottom: 2px;
padding-left: 10px;
font-size: 14px;
font-weight: 400;
letter-spacing: 0px;
line-height: 0px;
// color: rgba(255, 255, 255, 1);
text-align: left;
}
}
// :deep(.el-checkbox__label) {
// color: #fff;
// }
:deep(.el-checkbox__label) {
display: flex;
align-items: center;
}
}
.bottom_center {
position: absolute;
// left: calc(400px + 20px + 8vw);
left: -2%;
right: 0;
margin: auto;
width: 570px;
min-width: 380px;
bottom: 5%;
height: 75px;
opacity: 1;
border-radius: 5px;
background: rgba(2, 31, 26, 0.6);
border: 1px solid rgba(4, 153, 153, 1);
}
.tool {
position: absolute;
left: -95px;
top: 0;
width: 90px;
height: 28px;
opacity: 1;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
display: none;
background: url('@/assets/images/bg.png') no-repeat;
padding: 0 5px;
font-size: 14px;
cursor: pointer;
span {
float: right;
line-height: 28px;
margin-right: 20px;
color: rgba(255, 255, 255, 1);
}
}
/*设置弹出框样式*/
.ol-popup {
position: absolute;
// background-color: #eeeeee;
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
// padding: 15px;
border-radius: 10px;
// border: 1px solid #cccccc;
bottom: 12px;
left: -50px;
min-width: 280px;
}
.ol-popup:after,
.ol-popup:before {
top: 100%;
border: solid transparent;
content: ' ';
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.ol-popup:after {
border-top-color: #eeeeee;
border-width: 10px;
left: 48px;
margin-left: -10px;
}
.ol-popup:before {
border-top-color: #cccccc;
border-width: 11px;
left: 48px;
margin-left: -11px;
}
.ol-popup-closer {
text-decoration: none;
position: absolute;
top: 25px;
right: 30px;
color: rgba(100, 195, 164, 1) !important;
}
.ol-popup-closer:after {
content: '✖';
font-size: 18px;
}
#popup {
border-radius: 8px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 3px 6px -4px rgba(0, 0, 0, 0.12), 0px 6px 16px rgba(0, 0, 0, 0.08),
0px 9px 28px 8px rgba(0, 0, 0, 0.05);
.pophead {
background-repeat: no-repeat;
height: 42px;
opacity: 1;
border-radius: 8px;
color: rgba(100, 195, 164, 1);
}
#popup-content {
width: 460px;
height: 175px;
opacity: 1;
display: flex;
flex-wrap: wrap;
// align-items: center;
// justify-content: space-between;
.perform {
width: 50%;
display: flex;
justify-content: flex-end;
align-items: center;
}
.perform_children {
height: 28px;
line-height: 28px;
font-size: 14px;
padding-left: 18px;
display: flex;
justify-content: flex-end;
padding-right: 25px;
.label {
color: rgba(63, 161, 128, 1);
}
span {
color: rgba(51, 51, 51, 1);
display: block;
min-width: 100px;
background: rgba(100, 195, 164, 0.1);
box-shadow: inset 0px 1px 1px rgba(100, 195, 164, 0.5);
text-align: center;
}
}
}
}
#pop {
border-radius: 5px;
background: rgba(2, 31, 26, 1);
display: none;
// justify-content: flex-start;
// align-items: flex-end;
padding: 30px 8px 20px 8px;
.cancel {
position: absolute;
right: 10px;
top: 5px;
color: rgba(255, 255, 255, 1);
cursor: pointer;
}
& > div {
display: flex;
margin-bottom: 10px;
& > div:nth-child(1) {
font-weight: 400;
letter-spacing: 0px;
color: rgba(255, 255, 255, 1);
// margin-top: 20px;
line-height: 24px;
margin-right: 10px;
}
& > div:nth-child(2) {
color: rgba(255, 255, 255, 1);
width: 129px;
height: 24px;
opacity: 1;
border-radius: 2px;
background: rgba(217, 231, 255, 0.2);
display: flex;
justify-content: center;
align-items: center;
padding: 2px 10px 2px 10px;
// margin-top: 20px;
}
}
}
.back_button {
position: absolute;
right: 30%;
top: 20px;
}
</style>
<style lang="scss">
.select_city {
background: #fff;
}
.el-select__popper {
border: none !important;
background: transparent !important;
}
.el-popper {
border: none !important;
background: #fff !important;
color: black !important;
}
.el-popper__arrow::before {
display: none;
}
.selectCity {
background: #fff;
border: 1px solid #ccc;
}
</style>