<template>
    <div class="fatherDiv">
        <div class="centerBox">
            <div style="width: 100%; height: 100%" id="cesiumContainer"></div>
            <div class="leftWra">
                <div class="leftTop">
                    <div class="title">
                        <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 ref="leftProgressBarDiv" class="ProgressBar"></div>
                </div>
                <div class="leftbottom">
                    <div class="title">
                        <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 class="leftFoldDiv" @click="leftFoldClick()">
                    <el-tooltip
                        class="box-item"
                        :show-arrow="false"
                        :disabled="leftWraFlag"
                        hide-after="0"
                        show-after="200"
                        effect="dark"
                        content="展开"
                        placement="top"
                    >
                        <img v-if="!leftWraFlag" src="@/assets/images/close1.png" alt="" />
                    </el-tooltip>
                    <el-tooltip
                        :disabled="!leftWraFlag"
                        :show-arrow="false"
                        class="box-item"
                        show-after="200"
                        hide-after="0"
                        effect="dark"
                        content="收起"
                        placement="top"
                    >
                        <img
                            class="imgrotate"
                            v-if="leftWraFlag"
                            src="@/assets/images/close1.png"
                            alt=""
                        />
                    </el-tooltip>
                </div>
            </div>
            <div class="rightWra">
                <div class="rightTop">
                    <div class="title">
                        <span>各冷冻等级面积统计-高标准农田</span>
                        <p @click="Deta3()">
                            下载 &nbsp;
                            <img
                                src="@/assets/icons/svg/downloads.svg"
                                style="width: 14px; height: 14px; cursor: pointer"
                            />
                        </p>
                    </div>
                    <div ref="farmlandDiv" class="farmlandDiv"></div>
                    <!-- <div ref="ProgressBarDiv" class="ProgressBar"></div> -->
                </div>
                <div class="rightbottom">
                    <div class="title">
                        <span>各冷冻等级面积统计-行政区划</span>
                        <p @click="Deta4()">
                            下载 &nbsp;
                            <img
                                src="@/assets/icons/svg/downloads.svg"
                                style="width: 14px; height: 14px; cursor: pointer"
                            />
                        </p>
                    </div>
                    <el-select
                        popper-class="select_city"
                        @change="selectTab(item)"
                        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"
                        :show-arrow="false"
                        hide-after="0"
                        show-after="200"
                        class="box-item"
                        effect="dark"
                        content="收起"
                        placement="top"
                    >
                        <img v-if="rightWraFlag" src="@/assets/images/close1.png" alt="" />
                    </el-tooltip>
                    <el-tooltip
                        :disabled="rightWraFlag"
                        :show-arrow="false"
                        hide-after="0"
                        show-after="200"
                        class="box-item"
                        effect="dark"
                        content="展开"
                        placement="top"
                    >
                        <img
                            class="imgrotate"
                            v-if="!rightWraFlag"
                            src="@/assets/images/close1.png"
                            alt=""
                        />
                    </el-tooltip>
                </div>
            </div>

            <div class="bottom_center">
                <TimeLine />
            </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"
                                :style="{
                                    backgroundColor: value.color,
                                    border: `1px solid value.color`,
                                    width: `100%`,
                                }"
                                :v-model="value.disabled"
                                :disabled="value.disabled"
                                :label="item"
                            />
                        </el-checkbox-group>
                    </div>
                </el-collapse-item>
            </el-collapse>
            <div id="popup" class="ol-popup">
                <div class="pophead" style="width: 100%; height: 20px">
                    <div
                        id="popup-title"
                        style="
                            font: bold 15px sans-serif;
                            align: left;
                            position: absolute;
                            /* top: 5px; */
                            left: 17px;
                            color: #fff;
                        "
                    ></div>
                    <a
                        href="#"
                        id="popup-closer"
                        class="ol-popup-closer"
                        style="color: #8e908c"
                    ></a>
                </div>
                <div id="popup-content" style="padding: 10px">
                    <div v-for="(item, index) in alterArr" :key="index">
                        <p>
                            <span>{{ item.type }}</span>
                            :
                            <span>{{ Number(item.area).toFixed(2) }}(亩)</span>
                        </p>
                    </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 class="cancel" @click="hiddenOverlayChart">X</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 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="1" @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 { getarea, getvillage, getareas, dow } from '@/api/crops/classify.js';
import {
    getstatisticsOfTheArea,
    getproportionOfArea,
    geteachFreezingGradeArea,
    getTownship,
    getadministrative,
    getgarrison,
    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';

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');
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(1);
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 regionName = ref('');
let alterArr = ref([]);
let amount = ref([
    {
        无冻害: 0,
        轻度冻害: 0,
        中度冻害: 0,
        重度冻害: 0,
    },
]);
//搜索
let formInline = ref({
    time: '',
    statistical: '镇',
    droughtRating: '',
    area: num.value,
});
let highStandard = [
    '高标准农田1.0',
    '高标准农田2.0',
    '高标准农田3.0',
    '高标准农田4.0',
    '高标准农田5.0',
    '高标准农田6.0',
    '高标准农田7.0',
];
let highStandarditem = {
    无冻害: [],
    轻度冻害: [],
    中度冻害: [],
    重度冻害: [],
};
let dic = {
    无冻害: { 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();
    }
);
//行政区划数据
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() {
    getstatisticsOfTheAreas('370211'); //冷冻等级面积统计
    getproportionOfAreas('370211'); //冷冻等级面积占比
    geteachFreezingGradeAreas(); //高标准农田冷冻等级面积统计
    getTownships('370211'); //镇
    theTimes(); //年

    //地图
    initmap();
    areachar();
    typesof();
    farmland();
    // ProgressBar();
    ASdivision();
    getFarmland();
    alter();
    for (const key in dic) {
        if (dic[key].disabled !== true) {
            console.log(key);
            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(107%,0)';
    localStorage.setItem(router.currentRoute.value.path, true);
}
onUpdated(() => {
    console.log(localStorage.getItem(router.currentRoute.value.path));
    if (localStorage.getItem(router.currentRoute.value.path) == 'false') {
        document.querySelector('.mode').innerText = '地图模式';
        window.document.querySelector('#screenfull').style.display = 'none';
    } else {
        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: ol.control
            .defaults({
                attributionOptions: {
                    collapsed: true,
                },
            })
            .extend([new ol.supermap.control.Logo(), new ol.control.ScaleLine()]),
        view: new ol.View({
            center: [119.86763411957472, 35.88435182141938],
            zoom: 11,
            projection: 'EPSG:4326',
        }),
        layers: [
            new ol.layer.Tile({
                source: new ol.source.Tianditu({
                    layerType: 'img',
                    key: '1d109683f4d84198e37a38c442d68311',
                }),
            }),
            //注记
            // 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;
        var lon = coodinate[0];
        var lat = coodinate[1];
        var view = map.getView();
        var zoom = map.getView().getZoom();
        console.log(lon, lat);
        view.animate({
            center: [lon, lat],
            duration: 1000,
        });
        if (zoom >= 13) {
            QueryData(
                e,
                'huangdaoqu_village@huangdaoqu_bianjie',
                'http://36.134.44.75:8090/iserver/services/map-huangdaoqu_bianjie/rest/maps/huangdaoqu_village@huangdaoqu_bianjie',
                '村'
            );
        } else {
            QueryData(
                e,
                'huangdaoqu_town@huangdaoqu_bianjie',
                'http://36.134.44.75:8090/iserver/services/map-huangdaoqu_bianjie/rest/maps/huangdaoqu_town@huangdaoqu_bianjie',
                '镇'
            );
        }
    });
}
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;
            getTownships();
            let arr = [];
            Township.brr.forEach(item => {
                console.log(item);
                if (item.streetCode == code) {
                    name = item.streetName;
                    arr.push(item);
                }
                alterArr.value = arr;
            });
            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 }).then(res => {
                console.log(res.data);
                res.data.forEach(item => {
                    console.log(item);
                    arr.push(item);
                });
                name = res.data[0].streetName;
                alterArr.value = arr;
                alter();
            });
        }
        function alter() {
            if (data.result.currentCount > 0) {
                console.log(data.result.recordsets[0].features);
                if (data.result.recordsets[0].features) {
                    overlay.setPosition(point.flatCoordinates);
                    console.log(name);
                    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 = '370211';
        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 addConver(data) {
    let source = new ol.source.Vector();
    var converLayer = new ol.layer.Vector({
        id: 'zhezhao',
        source: source,
        style: new ol.style.Style({
            fill: new ol.style.Fill({
                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) {
    console.log(data);
    const extent = [-180, -90, 180, 90];
    const polygonRing = ol.geom.Polygon.fromExtent(extent);
    const coords = data;
    console.log(coords);
    coords.forEach(coord => {
        const linearRing = new ol.geom.LinearRing(coord[0]);
        polygonRing.appendLinearRing(linearRing);
    });
    return polygonRing;
}
const cun = () => {
    layers = new ol.layer.Tile({
        source: new ol.source.TileSuperMapRest({
            url: 'http://36.134.44.75:8090/iserver/services/map-huangdaoqu_bianjie/rest/maps/huangdaoqu_village@huangdaoqu_bianjie',
            //rasterfunction: new SuperMap.NDVIParameter({ redIndex: 0, nirIndex: 2 }),
            cacheEnabled: false,
        }),
        name: 'huangdaoqu_village',
        projection: 'EPSG:4326', //3857
        zIndex: 9999,
    });
    map.addLayer(layers);
    // var layersArray = map.getLayers();
    // layersArray.insertAt(999, layers);
};
const zhen = () => {
    var layer = new ol.layer.Tile({
        source: new ol.source.TileSuperMapRest({
            url: 'http://36.134.44.75:8090/iserver/services/map-huangdaoqu_bianjie/rest/maps/huangdaoqu_town@huangdaoqu_bianjie',
            //rasterfunction: new SuperMap.NDVIParameter({ redIndex: 0, nirIndex: 2 }),
            cacheEnabled: false,
        }),
        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);
};

function getFarmland() {
    axios({
        url:
            serverAPI.geoserverUrl +
            '/shuzisannong/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=shuzisannong%3Afarmland&maxFeatures=50&outputFormat=application%2Fjson',
        method: 'get',
    })
        .then(res => {
            console.log('农田：', res);
            formLandRef.value = res.data.features;
        })
        .catch(err => {});
}
let nums = 0;
// 农作物
watch(
    () => checkList.value,
    (val, oldVal) => {
        if (val.length > oldVal.length) {
            // 挑选出增多的数据
            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]) {
                    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: [] }); //镇的作物

//折叠

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(107%,0)';
    }
}
const handleChange = value => {
    formInline.value.area = value;
};
const onSubmit = () => {
    let arr = [];
    let brr = [];
    currentPage.value = 1;
    getfreezeWarning({
        time: formInline.value.time,
        statistical: formInline.value.statistical,
        droughtRating: formInline.value.droughtRating,
        area: formInline.value.area,
    }).then(res => {
        console.log(res.data);
        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]) {
            console.log(amount.value[0][key]);
            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[0]),
        (formInline.value.statistical = '镇'),
        (formInline.value.droughtRating = ''),
        (formInline.value.area = 1),
        (operate.value = true);
    onSubmit();
};
/*------------------接口--------------------*/
//列表模式-年
const theTimes = () => {
    getfreezeWarningYear().then(res => {
        timeArr.value = res.data;
        formInline.value.time = res.data[0];
        onSubmit();
    });
};

//冷冻等级面积统计
const getstatisticsOfTheAreas = city => {
    areacharData.lable = [];
    areacharData.value = [];
    getstatisticsOfTheArea({ divisions: city }).then(res => {
        console.log(areacharData.lable, areacharData.value);
        res.data.forEach(item => {
            areacharData.lable.push(item.level);
            areacharData.value.push(item.area);
        });
        areachar();
    });
};

//冷冻等级面积占比
const getproportionOfAreas = city => {
    typesofData = ref([]);
    tableData = ref([]);
    totalArea = ref(0);
    getproportionOfArea({ divisions: city }).then(res => {
        res.data.forEach(item => {
            totalArea.value += Number(item.area);
            typesofData.value.push({
                name: item.level,
                value: Number(item.area).toFixed(2),
            });
            tableData.value.push({
                date: item.level,
                name: `${Number(item.area).toFixed(2)}`,
                address: `${(item.percentage * 100).toFixed(2)}%`,
            });
        });
        console.log(typesofData.value);
        typesof();
    });
};

//高标准农田冷冻等级面积统计
const geteachFreezingGradeAreas = () => {
    geteachFreezingGradeArea().then(res => {
        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);
                }
            });
        });
        farmland();
    });
};

//镇
const getTownships = city => {
    dd = {
        无冻害: [],
        轻度冻害: [],
        中度冻害: [],
        重度冻害: [],
    };
    getTownship({ divisions: city }).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;
        console.log(Township.arr);
        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 => {
    dd = {
        无冻害: [],
        轻度冻害: [],
        中度冻害: [],
        重度冻害: [],
    };
    getadministrative({ divisions: city }).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();
    });
};

const selectTab = () => {
    if (value.value == '370211') {
        getstatisticsOfTheAreas(value.value); //冷冻等级面积统计
        getproportionOfAreas(value.value);
        getTownships(); //更新镇的数据
        ASdivision();
        areachar();
        typesof();
    } else {
        getstatisticsOfTheAreas(value.value); //冷冻等级面积统计
        getproportionOfAreas(value.value);
        getadministratives(value.value);
        ASdivision();
        areachar();
        typesof();
    }

    // let arr = [...Township.arr];
    // console.log('arr:', arr);
    // arr.forEach(item => {
    //     if (item.properties.XZDM == value.value) {
    //         viewer.camera.flyTo({
    //             destination: Cesium.Rectangle.fromDegrees(
    //                 item.bbox[0],
    //                 item.bbox[1],
    //                 item.bbox[2],
    //                 item.bbox[3]
    //             ),
    //             duration: 2,
    //         });
    //     }
    //     let arr = [...Township.brr];
    //     let brr = [];
    //     // console.log(Township.brr);
    //     arr.forEach(item => {
    //         if (item.properties.XZDM == value.value) {
    //             brr.push(item.properties.XZQMC);
    //         }
    //     });
    //     // console.log(brr);
    //     data.title = [...Object.values(brr)];
    // });
    let town = [...Township.arr];
    // const townData = town.find(item => item.properties.XZDM === value.value);
    // if (townData) {
    //     // 移除镇高亮
    //     deleteEntityByName('townLine');
    //     // 高亮镇边界
    //     addBoundaryHandle(townData.geometry.coordinates, 'townLine', 'yellow');
    // }
    // 移除以前村
    // removeWms(['aaa']);
    // // 添加村
    // addvillage(`XZDM=${value.value}`, 'aaa');
    // getarea({ time: '2023-04-26', subregion: '1', parent: '黄岛区' }).then(res => {
    //     let arr = [];
    //     res.data.map((item, index) => {
    //         if (item.region == townData.properties.XZMC) {
    //             arr.push({
    //                 crop: item.type,
    //                 Shape_Area: item.area,
    //             });
    //         }
    //     });
    //     townZuowu.value = {
    //         label: arr,
    //     };
    //     console.log();
    //     console.log(arr);
    //     showOverlayChart({ x: 642, y: 312 });
    // });
};

//下载
/*---------------------------*/
const Deta = item => {
    getstatisticsOfTheArea({ divisions: value.value, whetherToDownload: true }).then(res => {
        downLoadFile(res.data[res.data.length - 1].downloadPath);
    });
};
const Deta2 = item => {
    getproportionOfArea({ divisions: value.value, whetherToDownload: true }).then(res => {
        downLoadFile(res.data[res.data.length - 1].downloadPath);
    });
};
const Deta3 = item => {
    geteachFreezingGradeArea({ divisions: value.value, 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 }).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, 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];
            }
        }
        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`);
};

/*-------------echarts--------------*/
function areachar() {
    const areaDivIntance = echarts.init(areaDiv.value);
    console.log(areacharData.lable);
    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(255, 255, 255, 0.7)', //字体颜色
            },
        },
        xAxis: {
            nameTextStyle: {
                color: '#c0c3cd',
                padding: [0, 0, -10, 0],
                fontSize: 14,
            },
            axisLabel: {
                color: 'rgba(255, 255, 255, 0.7)',
                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(255, 255, 255, 0.8)',
                fontSize: 14,
            },
            type: 'value',
            axisLabel: {
                color: 'rgba(255,255,255,0.7)',
            },
            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(45, 204, 177, 1)',
                            },
                            {
                                offset: 1,
                                color: 'rgba(71, 179, 161, 0)',
                            },
                        ],
                    },
                },
                label: {
                    normal: {
                        show: false,
                        fontSize: 14,
                        color: '#ffffff',
                        position: 'top',
                    },
                },
            },
        ],
    };

    option && areaDivIntance.setOption(option);

    window.addEventListener('resize', function () {
        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: '#f2f2f2',
                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: '#f2f2f2',
                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)',
                        },
                    },
                ],
            },
            {
                name: '外边框',
                type: 'pie',
                clockWise: false, //顺时加载
                hoverAnimation: false, //鼠标移入变大
                center: ['50%', '50%'],
                radius: ['85%', '85%'],
                label: {
                    normal: {
                        show: false,
                    },
                },
                data: [
                    {
                        value: 9,
                        name: '',
                        itemStyle: {
                            normal: {
                                borderWidth: 2,
                                borderColor: '#0b5263',
                            },
                        },
                    },
                ],
            },
        ],
    };

    useEcharts(typesofDivIntance, option);
}

function farmland() {
    const farmlandDivIntance = echarts.init(farmlandDiv.value);
    console.log(dd);
    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(255, 255, 255, 0.3)',
                    width: 1,
                    type: 'solid',
                },
                axisLabel: {
                    color: 'rgba(255, 255, 255, 0.7)',
                    fontWeight: 400,
                    fontFamily: 'SourceHanSansCN-Regular, SourceHanSansCN',
                    fontSize: 14,
                },
            },
        },
        yAxis: {
            name: '面积(亩)',
            nameTextStyle: {
                color: 'rgba(255, 255, 255, 0.8)',
                fontSize: 14,
            },
            type: 'value',
            axisLabel: {
                color: 'rgba(255, 255, 255, 0.7)',
            },
            splitLine: {
                lineStyle: {
                    type: 'solid',
                    color: 'rgba(255, 255, 255, 0.3)',
                },
            },
            minInterval: 1,
            axisLine: {
                show: false,
            },
            axisTick: {
                show: false,
            },
        },
        series: [
            {
                name: '无冻害',
                type: 'bar',
                barWidth: 14,
                stack: '数量',
                data: highStandarditem['无冻害'],
                itemStyle: {
                    normal: {
                        borderWidth: 1,
                        borderColor: 'rgba(32, 242, 255, 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,
                        borderColor: 'rgba(255, 255, 0, 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,
                        borderColor: 'rgba(255, 168, 8, 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,
                        borderColor: 'rgba(215, 25, 28, 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 (params) {
        console.log(params.name);
    });
    // farmlandDivIntance.on('click', param => ChartClick(param));
    option && farmlandDivIntance.setOption(option, { notMerge: true, grid: { bottom: 20 } });
    useEcharts(farmlandDivIntance, option);
}
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(255, 141, 26, 1)',
                },
                data: 无冻害,
            },
            {
                name: '轻度冻害',
                type: 'bar',
                barWidth: 13,
                stack: '分类',
                itemStyle: {
                    color: 'rgba(255, 255, 26, 1)',
                },
                data: 轻度冻害,
            },
            {
                name: '中度冻害',
                type: 'bar',
                barWidth: 13,
                stack: '分类',
                itemStyle: {
                    color: 'rgba(255, 201, 148, 1)',
                },
                data: 中度冻害,
            },
            {
                name: '重度冻害',
                type: 'bar',
                barWidth: 13,
                stack: '分类',
                itemStyle: {
                    color: 'rgba(255, 84, 84, 1)',
                },
                data: 重度冻害,
            },
        ],
    };

    var series = option.series;
    var tooltip = option.tooltip;
    // 提示框自定义内容包括总合及文字
    function formatFun(params) {
        // console.log('params====>', params)
        let tipStr = params[0].axisValueLabel + '</br>'; // 初始化提示框文字默认当前轴名称并换行
        let totalNum = 0; // 用于存储当前列总数
        // params为当前柱状图数组数量 遍历求和并添加类目label：value
        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') {
        console.log(flag.value);
        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;
    hiddenOverlayChart();
}
function ASdivision() {
    const ASdivisionDivIntance = echarts.init(ASdivisionDiv.value);
    console.log(dd);
    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(255, 255, 255, 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 fenleiRef = ref({});

// 地图移动时弹窗跟随
function infoWindowPostRender() {
    // let viewer = viewers.value;
    if (clickInfoMap.value.lon && clickInfoMap.value.lat) {
        //经纬度转为世界坐标
        const gisPosition = Cesium.Cartesian3.fromDegrees(
            Number(clickInfoMap.value.lon),
            Number(clickInfoMap.value.lat),
            0
        ); //转化为屏幕坐标
        var windowPosition = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
            viewer.scene,
            gisPosition
        );

        if (Cesium.defined(windowPosition)) {
            const pop = document.getElementById('popup');
            if (pop) {
                pop.style.top = windowPosition.y - 10 + 'px';
                pop.style.left = windowPosition.x + 10 + 'px';
            }
        }
    }
}

// 隐藏弹窗
function hiddenOverlayChart() {
    const pop = document.getElementById('popup');
    if (pop) {
        pop.style.display = 'none'; // 清除监听事件
    }
    viewer.scene.postRender.removeEventListener(infoWindowPostRender);
    deleteEntityByName('townLine');
    value.value = '370211';
    getstatisticsOfTheAreas(value.value); //冷冻等级面积统计
    getproportionOfAreas(value.value);
    getadministratives(value.value);
    getTownships('370211'); //镇
    areachar();
    typesof();
}
//显示弹窗
function showOverlayChart(position) {
    const pop = document.getElementById('popup');
    if (pop) {
        pop.style.display = 'block';
        pop.style.position = 'absolute';
        pop.style.top = position.y - 10 + 'px';
        pop.style.left = position.x + 10 + 'px';
        pop.style.zIndex = 99;
    }
}

/*-------------------------------------------------------------------------------------------*/
</script>

<style lang="scss" scoped>
$height: calc(100vh - 100px);
.fatherDiv,
.tabulation,
.centerBox {
    width: 100%;
    height: 100%;

    .imgrotate {
        transform: rotate(180deg);
    }

    .title {
        width: 100%;
        height: 45px;
        background: url('@/assets/images/title.png');
        background-repeat: no-repeat;
        background-size: 110% 100%;
        color: #fff;
        font-size: 18px;
        font-weight: 700;
        line-height: 45px;
        padding-left: 46px;
        display: flex;
        cursor: pointer;
        align-items: center;
        justify-content: space-between;

        span {
            width: 80%;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            background: linear-gradient(
                180deg,
                rgba(255, 255, 255, 1) 33.33%,
                rgba(41, 255, 219, 1) 100%
            );
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        p {
            width: 79px;
            height: 25px;
            border-radius: 20px;
            font-size: 14px;
            background: linear-gradient(
                180deg,
                rgba(16, 111, 111, 1) 0%,
                rgba(47, 214, 214, 1) 100%
            );
            border: 1.5px solid rgba(23, 194, 180, 1);
            display: flex;
            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: 100px;
        }
        .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);
            }
        }
    }
}

.leftWra {
    position: absolute;
    top: 10px;
    left: 20px;
    height: $height;
    width: 23%;
    background: rgba(2, 31, 26, 0.85);
    box-shadow: inset 0px 0px 15px 6px rgba(41, 255, 255, 0.5);
    transition: transform 1s;

    .leftFoldDiv {
        width: 30px;
        height: 30px;
        position: absolute;
        right: -14%;
        top: 50%;
        transform: translate(-50%, -50%);
        font-size: 30px;
        color: #ccc;
    }

    .leftTop {
        width: 100%;
        display: flex;
        flex-direction: column;
        height: 40%;
        .areaDiv {
            width: 100%;
            height: 100%;
            opacity: 1;
            display: flex;
            padding: 1px;
            justify-content: center;
        }

        .ProgressBar {
            width: 100%;
            height: 9px;
            opacity: 1;
        }
    }

    .leftbottom {
        width: 100%;
        height: 59%;
        opacity: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding-top: 13px;

        .typesofDiv {
            width: 100%;
            height: 40%;
            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;
            padding: 5px 10px 5px 10px;
            color: rgba(255, 255, 255, 1);
            height: 45%;
            :deep(.el-table tr) {
                background-color: transparent;
            }
            :deep(.el-table) {
                --el-table-border-color: none;
                color: rgba(255, 255, 255, 1);
            }
            :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);
            }
        }
    }
}

.rightWra {
    position: absolute;
    top: 10px;
    right: 20px;
    width: 23%;
    height: $height;
    opacity: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(2, 31, 26, 0.85);
    box-shadow: inset 0px 0px 15px 6px rgba(41, 255, 255, 0.5);
    transition: transform 1s;

    .rightFoldDiv {
        width: 30px;
        height: 30px;
        position: absolute;
        left: -8%;
        top: 50%;
        transform: translate(0, -50%);
        font-size: 30px;
        color: #ccc;
    }

    .rightTop {
        width: 100%;
        height: 40%;
        opacity: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;

        .farmlandDiv {
            width: 100%;
            height: 340px;
            opacity: 1;
            display: flex;
            justify-content: center;
        }

        .ProgressBar {
            width: 100%;
            height: 9px;
            opacity: 1;
        }
    }

    .rightbottom {
        width: 100%;
        height: 59%;
        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(22, 94, 102, 1);
            border: 1px solid rgba(4, 153, 153, 1) !important;
            margin-top: 20px;

            :deep(.el-input__wrapper) {
                background-color: transparent;
                box-shadow: none;
            }

            :deep(.el-input__inner) {
                color: rgba(255, 255, 255, 0.7);
            }
        }

        .ASdivision {
            width: 100%;
            height: 100%;
            opacity: 1;
            display: flex;
            justify-content: center;
        }
    }
}

.legend {
    position: absolute;
    right: 25%;
    bottom: 7%;
    width: 129px;
    border: 1px solid rgba(4, 153, 153, 1);

    // height: 50px;
    :deep(.el-collapse-item__header) {
        background: rgba(2, 31, 26, 0.6);
        color: rgba(255, 255, 255, 1);
        text-align: center;
        padding: 0 30px;
        font-size: 14px;
    }

    --el-collapse-content-bg-color {
        background: rgba(2, 31, 26, 0.6);
    }

    :deep(.el-collapse-item__content) {
        background: rgba(2, 31, 26, 0.6);
        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: black;
    }
}

.bottom_center {
    position: absolute;
    // left: calc(400px + 20px + 8vw);
    left: -2%;
    right: 0;
    margin: auto;
    width: calc(100% - (400px * 2) - (10vw * 2));
    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;
    right: 30%;
    top: 8%;
    width: 30px;
    height: 280px;
    opacity: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    display: none;
}

/*设置弹出框样式*/
.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: 2px;
    right: 8px;
}
.ol-popup-closer:after {
    content: '✖';
}
#popup {
    border-radius: 5px;
    background: rgba(2, 31, 26, 1);
    // display: none;
    // justify-content: flex-start;
    // align-items: flex-end;
    padding: 30px 8px 20px 8px;
    color: #fff;
    box-shadow: inset 0px 0px 15px 6px rgba(41, 255, 255, 0.5);
    border: rgba(41, 255, 255, 1);
}

#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;
}

:deep(.el-select__popper.el-popper) {
}
</style>
<style lang="scss">
.select_city {
    background: rgba(2, 31, 26, 0.85);
    box-shadow: inset 0px 0px 15px 6px rgba(41, 255, 255, 0.5);

    .el-select-dropdown__item.hover {
        background: rgba(2, 31, 26, 0.95);
        box-shadow: inset 0px 0px 15px 6px rgba(41, 255, 255, 0.7);
    }

    .el-select-dropdown__item {
        color: #fff;
    }
}

.el-select__popper {
    border: none !important;
    background: transparent !important;
}

.el-popper__arrow::before {
    display: none;
}
.selectCity {
    background: #fff;
}
</style>
