<template>
  <div class="ZTGlobal" style="width: 100%; padding: 1rem 1rem 0rem 1rem; color: white">
    <el-row :gutter="10">
      <el-col :span="24">
        基于三亚市控制性详细规划数据和2020年《三亚市国有建设用地土地定级与基准地价》编制成果，实现指定范围内国有建设用地的基准地价预估。
        <el-link type="primary" @click="jzdjsmShow">更多>></el-link>
      </el-col>
    </el-row>
    <el-row :gutter="10">
      <el-col :span="24">
        <el-tabs v-model="activeName" style="height: 100%" @tab-click="handleClick" v-loading="loading"
          element-loading-text="正在分析....." element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.8)">
          <el-tab-pane label="基准地价分析" name="first">
            <el-form ref="ruleForm" :model="form" :rules="rules" label-width="90px">
              <el-form-item label="项目名称" size="mini" prop="ProjectName">
                <el-col :span="20">
                  <el-input size="mini" v-model="form.ProjectName"></el-input>
                </el-col>
              </el-form-item>
              <!-- <el-form-item label="项目类型" size="mini" prop="ProjectType">
                <el-col :span="20">
                  <el-input size="mini" v-model="form.ProjectType"></el-input>
                </el-col>
              </el-form-item> -->
              <el-form-item label="选址范围" size="mini" prop="ProjectScope">
                <el-col :span="20">
                  <input @change="handleUpload" type="file" style="display:none" id="fileInput" accept=".zip"></input>
                  <el-button type="primary" @click="inputGeometry">导入</el-button>
                  <!-- <el-button type="primary">导入范围</el-button> -->
                  <el-button type="primary" @click="getProjectScope">绘制
                  </el-button>
                  <el-button type="primary" @click="resetForm('ruleForm')">清除
                  </el-button>
                </el-col>
              </el-form-item>
              <el-form-item label="建设单位" size="mini" prop="ConstructionUnit">
                <el-col :span="20">
                  <el-input size="mini" v-model="form.ConstructionUnit"></el-input>
                </el-col>
              </el-form-item>
            </el-form>
            <div class="SaveCenter">
              <el-button type="primary" @click="submitForm('ruleForm')">开始分析</el-button>
              <el-button @click="resetForm('ruleForm')">重置</el-button>
            </div>
          </el-tab-pane>
          <el-tab-pane label="分析记录" name="second">
            <el-row :gutter="10">
              <el-col :span="8">
                <el-input size="mini" placeholder="请输入项目名称" v-model="input3" class="input-with-select">
                </el-input>
              </el-col>
              <el-col :span="12">
                <el-date-picker size="mini" v-model="datevalue" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
                  range-separator="" start-placeholder="开始日期" end-placeholder="结束日期">
                </el-date-picker>
              </el-col>
              <el-col :span="4">
                <el-button size="mini" icon="el-icon-search" @click="getBenchmarkLandPriceList()"></el-button>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-row :gutter="10" v-for="itemModel in BenchmarkLandPriceList" :key="itemModel.id">
                  <el-col :span="24">
                    <el-card shadow="hover" class="card_body_style hover_style">
                      <el-row>
                        <el-col :span="24">
                          {{ itemModel.ProjectName }}
                        </el-col>
                      </el-row>
                      <el-row>
                        <el-col :span="24">
                          {{ itemModel.analysisDate }}
                        </el-col>
                      </el-row>
                      <el-row>
                        <el-col :span="8">
                          <el-button v-if="itemModel.AnalysisStatus == '完成'" size="mini" type="primary">{{
                            itemModel.AnalysisStatus }}</el-button>
                          <el-button v-if="itemModel.AnalysisStatus == '正在分析'" size="mini" type="success">{{
                            itemModel.AnalysisStatus }}</el-button>
                          <el-button v-if="itemModel.AnalysisStatus == '异常'" size="mini" type="danger">{{
                            itemModel.AnalysisStatus }}</el-button>
                        </el-col>
                        <el-col :span="12">
                           <div ><!--style="float: right" -->
                            <!-- <el-button size="mini" type="default">日志</el-button> -->
                            <el-button size="mini" type="default"
                              @click="openAnalyzeResults(itemModel.id)">结果</el-button>
                            <el-button size="mini" type="default" @click="handleGetBG(itemModel.id)">报告</el-button>
                          </div>
                        </el-col>
                        <el-col :span="4">
                          <el-button size="mini" type="warning"
                            @click="deleteAnalyzeResults(itemModel.id)">删除</el-button>
                        </el-col>
                      </el-row>
                    </el-card>
                  </el-col>
                </el-row>
                <el-pagination :hide-on-single-page="true" style="color: white" @size-change="handleSizeChange"
                  @current-change="handleCurrentChange" :page-size="queryParams.pageSize" layout="prev, pager, next"
                  :total="queryParams.total">
                </el-pagination>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="分析结果" name="third">
            <jzdjfxsmjg v-if="iSjzdjfxsmjgShow" :info="{ BenchmarkLandPrice: BenchmarkLandPriceinfo }"></jzdjfxsmjg>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { v4 as uuidv4 } from "uuid";
import moment from "moment";
import jzdjfxsmInfo from "./jzdjfxsmInfo.vue";
import jzdjfxsmjg from "./jzdjfxsmjg.vue";
import BenchmarkLandPrice from "./BenchmarkLandPrice.js";
import {
  cartesian3ToWGS84,
  mapQuery,
  mapanalyze,
  flatten,
  mercator2lonLat,
  undergroundMode,
} from "@/utils/MapHelper/MapHelper.js";
import {
  booleanContains,
  area,
  intersect,
  polygon,
  point,
  midpoint,
  difference,
} from "@turf/turf";
import { getJZDJWord, listBenchmarkLandPrices, addBenchmarkLandPrices, updateBenchmarkLandPrices, addZtBenchmarkLandPriceResults, getBenchmarkLandPrices, listZtBenchmarkLandPriceResults, getAnalyseResult, delBenchmarkLandPrices } from "@/api/zt/ztApi.js";
let handlerPolygon; var polygonEntity = null;
export default {
  data() {
    return {
      landUseNatureRelation: window.landUseNatureRelation,
      tooltip: createTooltip(document.body),
      /**
       * tabs 标签
       */
      activeName: "first",
      //绘制事件
      // handlerPolygon: null,
      iSjzdjfxsmjgShow: false,
      BenchmarkLandPriceinfo: null,
      form: {
        id: "",
        ProjectScope: [],
        ProjectName: "",
        ProjectType: "",
        ConstructionUnit: "",
        // ztBenchmarkLandPriceResultsList: []
      },
      input3: "",
      datevalue: [],
      // datevalue:[moment().add(-1, 'days').startOf("day").format('YYYY-MM-DD HH:mm:ss'),moment().endOf("day").format('YYYY-MM-DD HH:mm:ss')],
      rules: {
        ProjectName: [
          { required: true, message: "请输入项目名称", trigger: "blur" },
        ],
        ProjectScope: [
          { required: true, message: "请添加项目范围", trigger: "blur" },
        ],
        ProjectType: [
          { required: true, message: "请选择土地用途", trigger: "blur" },
        ],
      },
      BenchmarkLandPriceList: [],
      LayerData: {
        GHDKData: [],
      },
      queryParams: {
        total: 0,
        pageNum: 1,
        pageSize: 10,
      },
      loading: false
    };
  },
  components: {
    jzdjfxsmjg
  },
  mounted() {
    this.init();
  },
  methods: {
    async init() {
      var date = new Date()
      this.form.ProjectName = "基准地价分析_" + this.formatDateTime(date)
      this.form.ConstructionUnit = "建设单位"

      await this.getBenchmarkLandPriceList();
    },
    //页大小触发
    handleSizeChange(val) {
      this.queryParams.pageSize = val;
      this.queryParams.pageNum = 1;
      this.getBenchmarkLandPriceList();
    },
    //跳转页触发
    handleCurrentChange(val) {
      this.queryParams.pageNum = val;
      this.getBenchmarkLandPriceList();
    },
    /**
     * 获取基准地价信息
     */
    async getBenchmarkLandPriceList() {
      debugger
      let BenchmarkLandPrices = await listBenchmarkLandPrices({
        params: {
          beginTime: this.datevalue ? this.datevalue[0] : '',
          endTime: this.datevalue ? this.datevalue[1] : ''
        },
        ProjectName: this.input3,
        ...this.queryParams
      });
      this.queryParams.total = BenchmarkLandPrices.total;
      this.BenchmarkLandPriceList = BenchmarkLandPrices.rows;
      // this.BenchmarkLandPriceList = window.BenchmarkLandPriceList;

    },
    formatDateTime(date) {
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? ('0' + m) : m;
      var d = date.getDate();
      d = d < 10 ? ('0' + d) : d;
      var h = date.getHours();
      h = h < 10 ? ('0' + h) : h;
      var minute = date.getMinutes();
      minute = minute < 10 ? ('0' + minute) : minute;
      var second = date.getSeconds();
      second = second < 10 ? ('0' + second) : second;
      return y.toString() + m.toString() + d.toString() + h.toString() + minute.toString() + second.toString();
    },
    /**
     * tas切换
     * @param {String} tab
     * @param {Object} event
     */
    handleClick(tab, event) {
      if (this.activeName == "third") {
        this.iSjzdjfxsmjgShow = true;
      } else {
        this.iSjzdjfxsmjgShow = false;
      }

    },

    /**
     *基准地价说明
     */
    jzdjsmShow() {
      var that = this;
      if (that.layerid) that.$layer.close(that.layerid);
      var width = "40rem";
      var height = "30rem";

      that.layerid = that.$layer.iframe({
        content: {
          content: jzdjfxsmInfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: {}, //props
        },

        area: [width.toString(), height.toString()],
        title: "基准地价分析说明",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          // alert("关闭iframe");
        },
      });
    },
    /**
     * 绘制范围
     */
    getProjectScope() {
      let that = this;
      this.clearScope();
      handlerPolygon = new Cesium.DrawHandler(
        viewer,
        Cesium.DrawMode.Polygon,
        Cesium.ClampMode.Space
      );
      handlerPolygon.activate();
      handlerPolygon.activeEvt.addEventListener(function (isActive) {
        if (isActive == true) {
          // viewer.enableCursorStyle = false;
          // viewer._element.style.cursor = "";
          document.body.classList.add("drawCur");
        } else {
          // viewer.enableCursorStyle = true;
          document.body.classList.remove("drawCur");
        }
      });
      handlerPolygon.movingEvt.addEventListener((windowPosition) => {
        that.tooltip.showAt(
          windowPosition,
          "<p>点击鼠标左键开始绘制分析区域</p>"
        );
      });
      handlerPolygon.drawEvt.addEventListener((result) => {

        handlerPolygon.polygon.show = true;
        handlerPolygon.polyline.show = false;
        debugger
        handlerPolygon.polygon.polygon.material.color = Cesium.Color.WHITE.withAlpha(0.3);
        handlerPolygon.polygon.polygon.outline = true;
        handlerPolygon.polygon.polygon.outlineColor = Cesium.Color.RED;
        handlerPolygon.polygon.polygon.outlineWidth = 2.0;
        that.tooltip.setVisible(false);
        var polygon = result.object;
        if (!polygon) {
          return;
        }
        let points = [];
        let positions = polygon.positions;
        //遍历多边形，取出所有点
        for (var i = 0, len = positions.length; i < len; i++) {
          let xyz = cartesian3ToWGS84(positions[i]);
          points.push({ x: xyz.lng, y: xyz.lat, z: xyz.alt });
        }
        if (points.length > 0) {
          if (points[0] != points[points.length - 1]) {
            points.push(points[0]);
          }
        }
        that.form.ProjectScope = points;
        // if (this.calculateBooleanContains(positions)) {
        //   that.form.ProjectScope = points;
        // } else {
        //   this.$message.error("请在规划地块范围内选择范围");
        // }
      });
    },
    submitForm(formName) {
      let that = this;
      that.loading = true;
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          var area = await that.getRegionArea() / 666.66;
          if (area > 3000) {
            this.clear();
            that.loading = false;
            that.$alert("项目范围不要超过3000亩,请重新输入项目范围", "警告");
            return false;
          }
          that.form.id = uuidv4();
          that.form.analysisDate = moment(new Date()).format(
            "YYYY-MM-DD HH:mm:ss"
          );
          that.form.AnalysisStatus = "正在分析";
          // window.BenchmarkLandPriceList.push(
          //   JSON.parse(JSON.stringify(that.form))
          // );
          that.form.ProjectScope = JSON.stringify(that.form.ProjectScope);
          var rownum = await addBenchmarkLandPrices(that.form);
          debugger
          if (rownum.code == 200) {

            debugger
            let data = JSON.parse(JSON.stringify(that.form));
            // let response = await getAnalyseResult(data);
            BenchmarkLandPrice.calculateLandPrice(data, true, async function (response) {
              that.loading = false;
              if (response) {
                response.id = uuidv4();
                response.BenchmarkLandPriceid = data.id;
                data.AnalysisStatus = "完成";
                var urownum = await updateBenchmarkLandPrices({ id: data.id, AnalysisStatus: data.AnalysisStatus });
                if (urownum.code == 200) {
                  debugger
                  await addZtBenchmarkLandPriceResults(response);
                }
                await that.openAnalyzeResults(data.id);
              } else {
                that.$message.error("分析异常");
                data.AnalysisStatus = "异常";
                var urownum = await updateBenchmarkLandPrices({ id: data.id, AnalysisStatus: data.AnalysisStatus });
              }
              that.resetForm(formName);
              that.init();
            });
            that.init();
            that.$message({
              message: "开始分析",
              type: "success",
            });
          } else {
            that.loading = false;
            this.$message.error("项目保存失败");
          }
        } else {
          that.loading = false;
          return false;
        }
      });
    },
    resetForm(formName) {
      debugger
      this.clear();
      this.$refs[formName].resetFields();
      var date = new Date();
      this.form.ProjectName = "基准地价分析_" + this.formatDateTime(date);
      this.form.ConstructionUnit = "建设单位";
    },
    /**
     * 点击导入范围
     */
    inputGeometry() {
      var element = document.getElementById('fileInput')
      // debugger
      // document.getElementsByClassName("el-upload__input")= ""
      if (element)
        element.click();

    },
    handleUpload(event) {
      this.clearScope();
      debugger

      // let fileName = document.getElementsByClassName("el-upload__input")[0].value
      let fileName = event.target.files[0];
      var size = fileName.size
      if (size > 512 * 1024) {
        {
          this.$message("文件大小超限，请重新输入!");
          event.target.value = ''
          return
        }
      }
      let reader = new FileReader();
      var geojson;
      var that = this

      reader.readAsArrayBuffer(fileName);
      reader.onload = function (e) {
        debugger;
        let res = e.target.result; //ArrayBuffer
        shp(res)
          .then(function (res) {
            debugger
            // self.addGeometry(res)
            geojson = res;
            console.log(geojson);
            that.addGeometry(geojson)
          })
          .catch(function (e) {
            console.log(e);
          });
        event.target.value = ''
      };
      // this.parsingZip();
    },
    /**
 * 导入范围添加图形
 */
    addGeometry(geojson) {
      var that = this;
      debugger
      var coordinates = geojson.features[0].geometry.coordinates;
      var box = geojson.features[0].geometry.bbox;
      var centerX = (box[0] + box[2]) / 2;
      var centerY = (box[1] + box[3]) / 2;
      var positions = [];
      that.form.ProjectScope = [];
      for (var i = 0; i < coordinates.length; i++) {
        var coor = coordinates[i];
        if (coor && coor.length > 0) {
          for (var j = 0; j < coor.length; j++) {
            that.form.ProjectScope.push({ x: coor[j][0], y: coor[j][1] })
            positions.push(coor[j][0])
            positions.push(coor[j][1])
          }
        }
      }
      viewer.entities.removeById('polygon');
      polygonEntity = new Cesium.Entity({
        id: 'polygon',

        position: Cesium.Cartesian3.fromDegreesArray([
          centerX,
          centerY,
        ]),
        // classificationType: ClassificationType.TERRAIN,
        polygon: {
          hierarchy: new Cesium.PolygonHierarchy(
            new Cesium.Cartesian3.fromDegreesArray(positions)
          ),
          // positions: new Cesium.Cartesian3.fromDegreesArray(positions),
          material: Cesium.Color.WHITE.withAlpha(0.3),
          outline: true,
          outlineColor: Cesium.Color.RED,
          outlineWidth: 2.0,
        },
      });

      viewer.entities.add(polygonEntity);
      viewer.flyTo(polygonEntity)
    },
    //范围面积
    async getRegionArea() {
      debugger
      var points1 = this.form.ProjectScope;
      var parts1 = [];
      var poly1;
      for (var i = 0; i < points1.length; i++) {
        parts1.push([points1[i].x, points1[i].y]);
      }
      poly1 = polygon([parts1]);
      var textarea = area(poly1) * window.earthRadius;
return textarea;
      // let sd = { point2Ds: JSON.stringify(points1), unit: 'METER', prjCoordSys: { epsgcode: 4326 } };
      // let data = await mapanalyze(window.supermapIServerUrl + '/iserver/services/geometry/restjsr/v1/geometry/area.rjson', sd);
      // if (data) {
      //   return data.area;
      // } else {
      //   return 0
      // }

    },

    /**
     * 删除基准地价分析结果
     * @param BenchmarkLandPriceid 基准地价id
     */
    async deleteAnalyzeResults(BenchmarkLandPriceid) {
      let data = await delBenchmarkLandPrices(BenchmarkLandPriceid);
      if (data.code == 200) {
        this.$message({
          message: "删除成功",
          type: "success",
        });
      }
      this.init();
    },
    /**
     *  打开分析结果弹窗
     * @param BenchmarkLandPrice 基准地价信息
     */
    async openAnalyzeResults(BenchmarkLandPriceid) {
      debugger

      this.BenchmarkLandPriceinfo = (await getBenchmarkLandPrices(BenchmarkLandPriceid)).data;
      this.BenchmarkLandPriceinfo.ztBenchmarkLandPriceResultsList = (await listZtBenchmarkLandPriceResults({ BenchmarkLandPriceid: this.BenchmarkLandPriceinfo.id })).rows;
      this.iSjzdjfxsmjgShow = true;
      this.activeName = "third";


      // debugger
      // if (this.FXJGInfolayerid) {
      //   this.$layer.close(this.FXJGInfolayerid);
      // }
      // let that = this;
      // let w = document.body.offsetWidth;
      // let h = document.body.offsetHeight;
      // //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      // //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      // let left = w - 480 + 480 / 2;
      // let top = 830 / 2 + 60;
      // this.FXJGInfolayerid = this.$layer.iframe({
      //   content: {
      //     content: jzdjfxsmjg, //传递的组件对象
      //     parent: this, //当前的vue对象
      //     data: { info: { BenchmarkLandPrice } }, //props
      //   },
      //   offset: [left, top], //left top
      //   area: ["480px", "830px"], //宽 高
      //   title: "分析结果",
      //   maxmin: false,
      //   shade: false, //是否显示遮罩
      //   shadeClose: false, //点击遮罩是否关闭
      //   cancel: () => {
      //     // this.init();
      //   },
      // });
    },
    //切换用地类型时加载用地规划图层
    handleChange() {
      this.clear();
      if (this.form.ProjectType) {
        this.getGHDK(this.form.ProjectType);
      }
    },
    /**
     * 查询区域内规划地块
     * @param ProjectType
     */
    async getGHDK(ProjectType) {
      let that = this;
      //查询规划地块
      let layer = flatten(window.layerTree).find(
        (item) => item.core == "003006"
      );
      let sql = "";
      let landUseNatureRelation = flatten(window.landUseNatureRelation).find(
        (c) => c.tdyt == ProjectType
      );
      landUseNatureRelation.GHDKType.forEach((Type, i) => {
        if (i == 0) {
          sql += " KZXXGYDDM like '" + Type.ydxzdl + "%' ";
        } else {
          sql += "|| KZXXGYDDM like '" + Type.ydxzdl + "%' ";
        }
      });
      if (sql == "") {
        this.$message.error("当前土地用途类型未配置，请联系管理员");
        return;
      }
      let queryByGeometryParameters = {
        getFeatureMode: "SQL",
        datasetNames: [
          layer.date_server.datasourcename +
          ":" +
          layer.date_server.datasetname,
        ],
        queryParameter: {
          attributeFilter: sql,
        },
        hasGeometry: "true",
        maxFeatures: 99999999,
      };
      let e = await mapQuery(
        layer.date_server.url + "/featureResults.json?returnContent=true",
        queryByGeometryParameters
      );
      if (e && e.totalCount > 0) {
        e.features.forEach((feature) => {
          let featureData = {
            id: uuidv4(),
            layerInfo: layer,
            data: [],
            geometry: feature.geometry,
          };

          feature.fieldNames.forEach((fieldName, i) => {
            let Field = e.datasetInfos
              ? e.datasetInfos[0].fieldInfos.find(
                (c) =>
                  c.name &&
                  c.name.toUpperCase() == fieldName.toUpperCase() &&
                  c.name.toUpperCase().indexOf("SM") == -1
              )
              : null;
            if (Field) {
              featureData.data.push({
                label: fieldName,
                labelCN: Field ? Field.caption : fieldName,
                value: e.features[0].fieldValues[i],
              });
            }
          });

          let point3ds = [];
          let pointholes = [];
          let startindex = 0;
          for (
            let index = 0;
            index < featureData.geometry.parts.length;
            index++
          ) {
            let thisps = [];
            const endindex = startindex + featureData.geometry.parts[index];
            let geometryPoints = featureData.geometry.points.slice(
              startindex,
              endindex
            );
            for (
              let pointindex = 0;
              pointindex < geometryPoints.length;
              pointindex++
            ) {
              const point = geometryPoints[pointindex];
              thisps.push(point.x);
              thisps.push(point.y);
            }
            if (featureData.geometry.partTopo[index] === 1) {
              point3ds.push(Cesium.Cartesian3.fromDegreesArray(thisps));
            } else {
              pointholes.push(Cesium.Cartesian3.fromDegreesArray(thisps));
            }

            startindex = endindex;
          }

          if (point3ds.length > 0 && pointholes.length > 0) {
            let holes = [];
            pointholes.forEach((hole) => {
              holes.push({ positions: hole });
            });

            var orangePolygon1 = viewer.entities.add({
              id: "GHDK-" + featureData.id,
              polygon: {
                hierarchy: {
                  // Cesium.PolygonHierarchy
                  positions: point3ds[0],
                  holes: holes, // Cesium.PolygonHierarchy 数组
                },
                material: Cesium.Color.RED.withAlpha(0.4),
                outline: true,
                outlineColor: Cesium.Color.BLACK,
                outlineWidth: 2.0,
              },
            });
          } else if (point3ds.length > 0) {
            var orangePolygon1 = viewer.entities.add({
              id: "GHDK-" + featureData.id,
              polygon: {
                hierarchy: point3ds[0],
                material: Cesium.Color.RED.withAlpha(0.4),
                outline: true,
                outlineColor: Cesium.Color.BLACK,
                outlineWidth: 2.0,
              },
            });
          }

          that.LayerData.GHDKData.push(featureData);
        });
      }
    },
    async handleGetBG(id) {


      var item = (
        await listZtBenchmarkLandPriceResults({
          BenchmarkLandPriceid: id,
        })
      ).rows;
      if (item.length > 0) {
        await getJZDJWord(item[0]);
      }

    },
    // /**
    //  * 与已有的规划地块比较看是否包含
    //  * @param points
    //  */
    // calculateBooleanContains(points) {
    //   let DataPs = points.map((item) => {
    //     let xyz = cartesian3ToWGS84(item);
    //     return [xyz.lng, xyz.lat];
    //   });
    //   if (DataPs.length > 0) {
    //     if (
    //       JSON.stringify(DataPs[0]) != JSON.stringify(DataPs[DataPs.length - 1])
    //     ) {
    //       DataPs.push(DataPs[0]);
    //     }
    //     //绘制的图形边界
    //     let polygonPs = polygon([DataPs]);
    //     //规划地块的范围
    //     for (let index = 0; index < this.LayerData.GHDKData.length; index++) {
    //       const geometry = this.LayerData.GHDKData[index].geometry;

    //       let point3ds = [];
    //       let pointholes = [];
    //       let startindex = 0;
    //       for (let index = 0; index < geometry.parts.length; index++) {
    //         let thisps = [];
    //         const endindex = startindex + geometry.parts[index];
    //         let geometryPoints = geometry.points.slice(startindex, endindex);
    //         for (
    //           let pointindex = 0;
    //           pointindex < geometryPoints.length;
    //           pointindex++
    //         ) {
    //           const point = geometryPoints[pointindex];
    //           thisps.push([point.x, point.y]);
    //         }
    //         if (geometry.partTopo[index] === 1) {
    //           point3ds.push(thisps);
    //         } else {
    //           pointholes.push(thisps);
    //         }

    //         startindex = endindex;
    //       }

    //       // 主多边形
    //       var mainPolygon = polygon(point3ds);

    //       // 岛洞多边形
    //       var holePolygon = polygon(pointholes);

    //       // 计算差集 得到有导洞的图形
    //       var getdifference = difference(mainPolygon, holePolygon);
    //       let areaPs = booleanContains(getdifference, polygonPs);
    //       if (areaPs) {
    //         return true;
    //       }
    //     }
    //     return false;
    //   } else {
    //     return false;
    //   }
    // },

    clearGHDK() {
      //删除规划地块图层
      for (let index = 0; index < this.LayerData.GHDKData.length; index++) {
        const element = this.LayerData.GHDKData[index];
        viewer.entities.removeById("GHDK-" + element.id);
      }
      this.LayerData.GHDKData = [];
    },
    clearScope() {
      if (polygonEntity) {
        viewer.entities.remove(polygonEntity)
      }
      if (handlerPolygon) {
        handlerPolygon.clear();
        handlerPolygon.deactivate();
        handlerPolygon = null;
      }
      this.tooltip.setVisible(false);
    },
    clear() {
      this.clearScope();
      this.clearGHDK();
    },
  },
  beforeDestroy() {
    this.clear();
  },
};
</script>
<style lang="scss">
@import "@/../../zt.scss";
</style>
<style scoped>
.el-date-editor--daterange.el-input__inner {
  width: auto;
  background-color: rgba(4, 28, 50, 0.5);
  border: 1px solid rgba(15, 122, 200, 0.4);
}

.card_body_style {
  border: 1px dashed #02a7f0;
}

.hover_style:hover {
  border: 1px solid #02a7f0;
}

.con-col {
  display: flex;
  flex-flow: column nowrap;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
}
</style>
