<template>
  <div
    class="ZTGlobal"
    style="width: 100%; padding: 1rem 1rem 0rem 1rem; color: white"
  >
    <el-row :gutter="10">
      <el-col :span="12">
        <el-input
          size="mini"
          placeholder="请输入项目名称"
          v-model="input3"
          class="input-with-select"
          clearable
        >
          <el-button
            slot="append"
            icon="el-icon-search"
            @click="getProjectInfos"
          ></el-button>
        </el-input>
      </el-col>
      <el-col :span="5" :offset="6">
        <el-button
          size="mini"
          type="primary"
          plain
          @click="openaddProjectInfo()"
          >新增项目</el-button
        >
        <!-- <el-button size="mini" type="primary" plain>导入项目</el-button> -->
      </el-col>
    </el-row>
    <el-row
      :gutter="10"
      v-loading="loading"
      element-loading-text="数据加载中"
      element-loading-spinner="el-icon-loading"
      element-loading-background="rgba(0, 0, 0, 0.8)"
    >
      <el-col :span="24">
        <el-tabs v-model="activeName" style="height: 100%">
          <el-tab-pane label="未上会项目" name="未上会项目">
            <el-collapse accordion @change="handleChangeXM">
              <el-collapse-item
                v-for="item in wsh"
                :key="item.id"
                :name="item.id"
              >
                <template slot="title">
                  {{ item.projectname }}({{
                    getConstructionModel(item).length
                  }}个)
                  <el-tooltip
                    class="item"
                    effect="dark"
                    content="项目详情"
                    placement="top-start"
                  >
                    <i
                      style="padding-left: 10px"
                      class="el-icon-info"
                      @click.stop="openProjectInfo(item)"
                    ></i>
                  </el-tooltip>
                  <el-tooltip
                    class="item"
                    effect="dark"
                    content="项目修改"
                    placement="top-start"
                  >
                    <i
                      style="padding-left: 10px"
                      class="el-icon-edit"
                      @click.stop="openaddProjectInfo(item)"
                    ></i>
                  </el-tooltip>

                  <el-tooltip
                    class="item"
                    effect="dark"
                    content="删除项目"
                    placement="top-start"
                  >
                    <i
                      style="padding-left: 10px"
                      class="el-icon-delete"
                      @click.stop="deleteProject(item.id)"
                    ></i>
                  </el-tooltip>
                </template>

                <el-row :gutter="10">
                  <el-col :span="24">
                    <el-button
                      style="margin-left: 10px"
                      size="mini"
                      type="default"
                      plain
                      @click="openAddConstructionModelInfo(item)"
                      >导入模型</el-button
                    >
                    <el-button
                      size="mini"
                      type="default"
                      plain
                      @click="ModelComparison(item)"
                      >模型对比</el-button
                    >
                    <el-button
                      size="mini"
                      type="default"
                      plain
                      @click="setStrategy(item)"
                      >选定方案</el-button
                    >
                  </el-col>
                </el-row>

                <el-row
                  :gutter="10"
                  v-for="itemModel in getConstructionModel(item)"
                  :key="itemModel.id"
                >
                  <el-col :span="24">
                    <div
                      class="checkedState"
                      :ref="'Model' + itemModel.id"
                      @click="SelectConstructionModelHendle(itemModel)"
                    >
                      <div class="status ce" style="display: none">
                        <div class="icon"></div>
                        <div class="txts ce">待选定</div>
                      </div>
                      <el-card
                        shadow="hover"
                        class="card_body_style hover_style"
                      >
                        <el-row>
                          <el-col :span="24">
                            <el-checkbox
                              @click.stop.native=""
                              v-model="itemModel.checked"
                              :key="'itemModelChecked' + itemModel.id"
                              >{{ itemModel.modelname }}</el-checkbox
                            >
                          </el-col>
                        </el-row>
                        <el-row>
                          <el-col :span="24">
                            {{
                              itemModel.creationtime
                                ? itemModel.creationtime.substring(0, 10)
                                : ""
                            }}
                          </el-col>
                        </el-row>
                        <el-row>
                          <el-col :span="6">
                            <div
                              class="con-col hover_style"
                              style="cursor: pointer"
                              @click.stop="openConstructionModel(itemModel)"
                            >
                              <i
                                style="font-size: 2rem"
                                class="el-icon-s-operation"
                                @click.stop="openConstructionModel(itemModel)"
                              ></i>
                              <a @click.stop="openConstructionModel(itemModel)"
                                >详情</a
                              >
                            </div>
                          </el-col>
                          <el-col :span="6">
                            <div
                              class="con-col hover_style"
                              style="cursor: pointer"
                              @click.stop="positionModel(itemModel)"
                            >
                              <i
                                style="font-size: 2rem"
                                class="el-icon-location-outline"
                                @click.stop="positionModel(itemModel)"
                              ></i>
                              <a @click.stop="positionModel(itemModel)">定位</a>
                            </div>
                          </el-col>
                          <el-col :span="6">
                            <div
                              class="con-col hover_style"
                              style="cursor: pointer"
                              @click.stop="openAnalyzeList(itemModel)"
                            >
                              <i
                                style="font-size: 2rem"
                                class="el-icon-share"
                                @click.stop="openAnalyzeList(itemModel)"
                              ></i>
                              <a @click.stop="openAnalyzeList(itemModel)"
                                >分析</a
                              >
                            </div>
                          </el-col>
                          <el-col :span="6">
                            <div
                              class="con-col hover_style"
                              style="cursor: pointer"
                              @click.stop="removeConstructionmodel(itemModel)"
                            >
                              <i
                                style="font-size: 2rem"
                                class="el-icon-delete"
                                @click.stop="removeConstructionmodel(itemModel)"
                              ></i>
                              <a>删除</a>
                            </div>
                          </el-col>
                        </el-row>
                        <el-row
                          :ref="itemModel.id + 'AnalyzeList'"
                          class="none"
                        >
                          <el-row :gutter="24">
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="normAnalysis(item, itemModel)"
                                >指标分析
                              </el-button>
                            </el-col>
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="openskylineAnalysis(itemModel)"
                                >天际线分析</el-button
                              >
                            </el-col>
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="openSunlightAnalysis(itemModel)"
                                >日照分析</el-button
                              >
                            </el-col>
                          </el-row>
                          <el-row :gutter="24">
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="KGAnalysis(itemModel)"
                                >控规分析
                              </el-button>
                            </el-col>

                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="CheckPark(itemModel, true)"
                                >车位审核
                              </el-button>
                            </el-col>
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="RSAnalysis(itemModel)"
                                >人视分析
                              </el-button>
                            </el-col>
                            <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="DistrictAnalysis(itemModel)"
                                >区位分析
                              </el-button>
                            </el-col> -->
                            <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="limitHeightAnalysis(itemModel)"
                                >限高分析
                              </el-button>
                            </el-col> -->
                            <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="trafficAnalysis(itemModel)"
                                >交通分析
                              </el-button>
                            </el-col> -->
                          </el-row>
                          <el-row :gutter="24">
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="undergroundModeAnalysis()"
                                >地下分析
                              </el-button>
                            </el-col>
                            <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="backLineAnalysis(itemModel)"
                                >建筑退线
                              </el-button>
                            </el-col> -->
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="occupyAnalysis(itemModel)"
                                >占压分析
                              </el-button>
                            </el-col>
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="ArchitecturalAnalysis(itemModel)"
                                >建筑风貌
                              </el-button>
                            </el-col>
                          </el-row>
                          <el-row :gutter="24">
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="
                                  BuildingStretchingAnalysis(itemModel)
                                "
                                >楼体拉伸
                              </el-button>
                            </el-col>
                            <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="openNightscapeAnalysis(itemModel)"
                                >夜景分析</el-button
                              >
                            </el-col>
                          </el-row>
                          <el-row :gutter="24">
                            <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="PlanningAnalysis(itemModel)"
                                >规划情况
                              </el-button>
                            </el-col> -->
                          </el-row>
                        </el-row>
                      </el-card>
                    </div>
                  </el-col>
                </el-row>
              </el-collapse-item>
            </el-collapse>

            <el-pagination
              :hide-on-single-page="true"
              style="color: white"
              @size-change="wshhandleSizeChange"
              @current-change="wshhandleCurrentChange"
              :page-size="wshqueryParams.pageSize"
              layout="prev, pager, next"
              :total="wshqueryParams.total"
            >
            </el-pagination>
          </el-tab-pane>
          <el-tab-pane label="已上会项目" name="已上会项目">
            <el-collapse accordion>
              <el-collapse-item
                v-for="item in ysh"
                :key="item.id"
                :name="item.id"
              >
                <template slot="title">
                  {{ item.projectname }}({{
                    getConstructionModel(item).length
                  }}个)<i
                    style="padding-left: 10px"
                    class="header-icon el-icon-info"
                    @click.stop="openProjectInfo(item)"
                  ></i>
                </template>
                <div>
                  <el-row :gutter="10">
                    <el-col :span="24">
                      <el-button
                        size="mini"
                        type="primary"
                        plain
                        @click="ModelComparison(item)"
                        >模型对比</el-button
                      >
                      <!-- <el-button
                        style="margin-left: 10px"
                        size="mini"
                        type="primary"
                        plain
                        >模型注册</el-button
                      > -->
                    </el-col>
                  </el-row>

                  <el-row
                    :gutter="10"
                    v-for="itemModel in getConstructionModel(item)"
                    :key="itemModel.id"
                  >
                    <el-col :span="24">
                      <div class="checkedState" :ref="'Model' + itemModel.id">
                        <div
                          class="status ce"
                          :style="{
                            display: itemModel.selectionStatus
                              ? 'block'
                              : 'none',
                          }"
                        >
                          <div class="icon"></div>
                          <div class="txts ce">已选定</div>
                        </div>
                        <el-card
                          shadow="hover"
                          class="card_body_style hover_style"
                        >
                          <el-row>
                            <el-col :span="24">
                              <el-checkbox
                                @click.stop.native=""
                                v-model="itemModel.checked"
                                :key="'itemModelChecked' + itemModel.id"
                                >{{ itemModel.modelname }}</el-checkbox
                              >
                            </el-col>
                          </el-row>
                          <el-row>
                            <el-col :span="24">
                              {{
                                itemModel.creationtime
                                  ? itemModel.creationtime.substring(0, 10)
                                  : ""
                              }}
                            </el-col>
                          </el-row>
                          <el-row>
                            <el-col :span="6">
                              <div
                                class="con-col hover_style"
                                style="cursor: pointer"
                                @click.stop="openConstructionModel(itemModel)"
                              >
                                <i
                                  style="font-size: 2rem"
                                  class="el-icon-s-operation"
                                  @click.stop="openConstructionModel(itemModel)"
                                ></i>
                                <a
                                  @click.stop="openConstructionModel(itemModel)"
                                  >详情</a
                                >
                              </div>
                            </el-col>
                            <el-col :span="6">
                              <div
                                class="con-col hover_style"
                                style="cursor: pointer"
                                @click.stop="positionModel(itemModel)"
                              >
                                <i
                                  style="font-size: 2rem"
                                  class="el-icon-location-outline"
                                  @click.stop="positionModel(itemModel)"
                                ></i>
                                <a @click.stop="positionModel(itemModel)"
                                  >定位</a
                                >
                              </div>
                            </el-col>
                            <el-col :span="6">
                              <div
                                class="con-col hover_style"
                                style="cursor: pointer"
                                @click.stop="openAnalyzeList(itemModel)"
                              >
                                <i
                                  style="font-size: 2rem"
                                  class="el-icon-share"
                                  @click.stop="openAnalyzeList(itemModel)"
                                ></i>
                                <a @click.stop="openAnalyzeList(itemModel)"
                                  >分析</a
                                >
                              </div>
                            </el-col>
                            <el-col :span="6">
                              <div
                                class="con-col hover_style"
                                style="cursor: pointer"
                                @click.stop="removeConstructionmodel(itemModel)"
                              >
                                <i
                                  style="font-size: 2rem"
                                  class="el-icon-delete"
                                  @click.stop="
                                    removeConstructionmodel(itemModel)
                                  "
                                ></i>
                                <a>删除</a>
                              </div>
                            </el-col>
                          </el-row>
                          <el-row
                            :ref="itemModel.id + 'AnalyzeList'"
                            class="none"
                          >
                            <el-row :gutter="24">
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="normAnalysis(item, itemModel)"
                                  >指标分析
                                </el-button>
                              </el-col>
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="openskylineAnalysis(itemModel)"
                                  >天际线分析</el-button
                                >
                              </el-col>
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="openSunlightAnalysis(itemModel)"
                                  >日照分析</el-button
                                >
                              </el-col>
                            </el-row>
                            <el-row :gutter="24">
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="KGAnalysis(itemModel)"
                                  >控规分析
                                </el-button>
                              </el-col>

                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="CheckPark(itemModel, true)"
                                  >车位审核
                                </el-button>
                              </el-col>
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="RSAnalysis(itemModel)"
                                  >人视分析
                                </el-button>
                              </el-col>
                              <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="DistrictAnalysis(itemModel)"
                                >区位分析
                              </el-button>
                            </el-col> -->
                              <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="limitHeightAnalysis(itemModel)"
                                >限高分析
                              </el-button>
                            </el-col> -->
                              <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="trafficAnalysis(itemModel)"
                                >交通分析
                              </el-button>
                            </el-col> -->
                            </el-row>
                            <el-row :gutter="24">
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="undergroundModeAnalysis()"
                                  >地下分析
                                </el-button>
                              </el-col>
                              <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="backLineAnalysis(itemModel)"
                                >建筑退线
                              </el-button>
                            </el-col> -->
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="occupyAnalysis(itemModel)"
                                  >占压分析
                                </el-button>
                              </el-col>
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="ArchitecturalAnalysis(itemModel)"
                                  >建筑风貌
                                </el-button>
                              </el-col>
                            </el-row>
                            <el-row :gutter="24">
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="
                                    BuildingStretchingAnalysis(itemModel)
                                  "
                                  >楼体拉伸
                                </el-button>
                              </el-col>
                              <el-col :span="8">
                                <el-button
                                  type="primary"
                                  size="mini"
                                  @click.stop="
                                    openNightscapeAnalysis(itemModel)
                                  "
                                  >夜景分析</el-button
                                >
                              </el-col>
                            </el-row>
                            <el-row :gutter="24">
                              <!-- <el-col :span="8">
                              <el-button
                                type="primary"
                                size="mini"
                                @click.stop="PlanningAnalysis(itemModel)"
                                >规划情况
                              </el-button>
                            </el-col> -->
                            </el-row>
                          </el-row>
                        </el-card>
                      </div>
                    </el-col>
                  </el-row>
                </div>
              </el-collapse-item>
            </el-collapse>
            <el-pagination
              :hide-on-single-page="true"
              style="color: white"
              @size-change="yshhandleSizeChange"
              @current-change="yshhandleCurrentChange"
              :page-size="yshqueryParams.pageSize"
              layout="prev, pager, next"
              :total="yshqueryParams.total"
            >
            </el-pagination>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  cartesian3ToWGS84,
  mapQuery,
  flatten,
  mercator2lonLat,
  undergroundMode,
} from "@/utils/MapHelper/MapHelper.js";
import { v4 as uuidv4 } from "uuid";
import { isFunction, flatMap, values } from "lodash-es";
import {
  booleanContains,
  area,
  intersect,
  polygon,
  point,
  midpoint,
  difference,
} from "@turf/turf";
import NightscapeAnalysis from "@/views/ConstructionApplication3D/NightscapeAnalysis/NightscapeAnalysis.vue";
import addProjectInfo from "@/views/ConstructionApplication3D/projectInfo/addProjectInfo.vue";
import projectInfo from "@/views/ConstructionApplication3D/projectInfo/projectInfo.vue";
import skylineAnalysis from "@/views/ConstructionApplication3D/skylineAnalysis/skylineAnalysis.vue";
import SunlightAnalysis from "@/views/ConstructionApplication3D/SunlightAnalysis/SunlightAnalysis.vue";
// import SunlightAnalysis from "@/views/ConstructionApplication3D/SunlightAnalysis/SunlightTImesAnalysis.vue";
import ConstructionModelInfo from "@/views/ConstructionApplication3D/ConstructionModelInfo/ConstructionModelInfo.vue";
import addConstructionModelInfo from "@/views/ConstructionApplication3D/ConstructionModelInfo/addConstructionModelInfo.vue";
import PlanningPlotInfo from "@/views/ConstructionApplication3D/PlanningPlot/PlanningPlotInfo.vue";
import HighLimitAnalysis from "@/views/ConstructionApplication3D/HighLimitAnalysis/HighLimitAnalysis.vue";
import backLineAnalysisinfo from "@/views/ConstructionApplication3D/backLineAnalysis/backLineAnalysisinfo.vue";
import ZYAnalysisinfo from "@/views/ConstructionApplication3D/ZYAnalysisinfo/ZYAnalysisinfo.vue";
import ZBFXAnalysisinfo from "@/views/ConstructionApplication3D/ZBFXAnalysisinfo/ZBFXAnalysisinfo.vue";
import MXDBinfo from "@/views/ConstructionApplication3D/MXDBinfo/MXDBinfo.vue";
import ArchitecturaAnalysis from "@/views/ConstructionApplication3D/ArchitecturaAnalysis/ArchitecturaAnalysis.vue";
import RSAnalysis from "@/views/ConstructionApplication3D/RSAnalysis/RSAnalysis.vue";
import BuildingStretchingAnalysis from "@/views/ConstructionApplication3D/BuildingStretchingAnalysis/BuildingStretchingAnalysis.vue";
import parkResult from "@/views/ConstructionApplication3D/parkCheck/parkResult.vue";
import clipboxByEditor from "@/views/ConstructionApplication3D/clipboxByEditor/clipboxByEditor.vue";
import ghqk from "./ghqk.js";
import CheckParkAnalyse from "./CheckParkAnalyse.js";
import Popup from "../Popup.js";
import {
  listProjectinformation,
  delConstructionmodel,
  updateConstructionmodel,
  updateProjectinformation,
  delProjectinformation,
} from "@/api/zt/ztApi.js";
var popupBoxs = [];
export default {
  name: "constructionApplication3D",
  data() {
    return {
      input3: "",
      activeName: "未上会项目",
      ysh: [],
      wsh: [],
      WaitingSelectionModel: null,
      //点击查询用地红线事件
      handler: null,
      //点查entities事件
      getEntitiesHandler: null,
      tooltip: createTooltip(document.body),
      //模型数据数组
      layerDataList: [],
      //模型图层数组
      layerList: [],
      // 规划地块数组
      LandPlanningList: [],
      //道路数组
      DLlayerDatas: [],
      //地下模式状态
      underground: false,
      //建筑退线数组
      JZTXlayerDatas: [],
      //地类图斑数组
      DLTBlayerDatas: [],
      //多模型对比获取到的【id:uuidv4(),模型信息，模型图层数组，模型数据数组】
      modelsload: [],
      loading: false,
      constructionmodel: [],
      yshqueryParams: {
        total: 0,
        pageNum: 1,
        pageSize: 10,
      },
      wshqueryParams: {
        total: 0,
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  props: {
    info: {
      type: Object,
      default: () => {
        return {};
      },
    },
    layerid: {
      type: String,
      default: "",
    },
    lydata: {
      type: Object,
      default: () => {
        return {};
      },
    },
    lyoption: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  computed: {},
  mounted() {
    // this.constructionmodel = window.constructionmodel;
    this.initEntitiesHandler();
    this.init();
  },
  methods: {
    async init() {
      await this.wshinit();
      await this.yshinit();
    },
    async wshinit() {
      this.wsh = await this.getshProjectinformations("0", this.wshqueryParams);
    },
    async yshinit() {
      this.ysh = await this.getshProjectinformations("1", this.yshqueryParams);
    },
    //页大小触发
    wshhandleSizeChange(val) {
      this.wshqueryParams.pageSize = val;
      this.wshqueryParams.pageNum = 1;
      this.wshinit();
    },
    //跳转页触发
    wshhandleCurrentChange(val) {
      this.wshqueryParams.pageNum = val;
      this.wshinit();
    },
    //页大小触发
    yshhandleSizeChange(val) {
      this.yshqueryParams.pageSize = val;
      this.yshqueryParams.pageNum = 1;
      this.yshinit();
    },
    //跳转页触发
    yshhandleCurrentChange(val) {
      this.yshqueryParams.pageNum = val;
      this.yshinit();
    },

    /**
     * 查询过滤
     */
    getProjectInfos() {
      //先清空当前视图
      scene.multiViewportMode = Cesium.MultiViewportMode.NONE;
      this.qxyp();
      this.removeModel();
      this.removeAll();
      undergroundMode(false);
      //过滤
      this.init();
    },
    /**
     * //获取项目进度
     * @param meetingprogress
     */
    async getshProjectinformations(meetingprogress, queryParams) {
      let Projectinformations = await listProjectinformation({
        meetingprogress: meetingprogress,
        projectname: this.input3,
        ...queryParams,
      });
      queryParams.total = Projectinformations.total;
      return Projectinformations.rows;
      // let Projectinformations = window.projectinformation.filter(
      //   (c) => c.meetingprogress == meetingprogress
      // );
      // return Projectinformations;
    },
    //获取项目模型信息
    getConstructionModel(Projectinfo) {
      return Projectinfo.ztConstructionmodelList;
    },

    /**
     * //选定方案
     * @param projectin 方案信息
     */
    setStrategy(projectin) {
      if (this.WaitingSelectionModel) {
        this.$layer.confirm("确认该项目已上会？", async (layerid) => {
          projectin.meetingprogress = "1";
          this.WaitingSelectionModel.selectionStatus = true;
          let Projectinfoistrue = await updateProjectinformation({
            id: projectin.id,
            meetingprogress: "1",
          });
          if (Projectinfoistrue.code == 200) {
            let ismodeltrue = await updateConstructionmodel({
              id: this.WaitingSelectionModel.id,
              selectionStatus: this.WaitingSelectionModel.selectionStatus,
            });
            if (ismodeltrue.code == 200) {
              this.$message({
                message: ismodeltrue.msg,
                type: "success",
              });
              this.getProjectInfos();
              this.$layer.close(layerid);
            }
          }
        });
      } else {
        this.$message({
          message: "请先选中待上会模型方案",
          type: "warning",
        });
      }
    },

    //分析列表显隐
    async openAnalyzeList(itemModel) {
      this.SelectConstructionModelHendle(itemModel);
      debugger;
      for (let key in this.$refs) {
        if (key.includes("AnalyzeList")) {
          if (key == itemModel.id + "AnalyzeList") {
            var classList = this.$refs[key][0].$el.classList;
            classList.toggle("none");
          } else {
            var classList = this.$refs[key][0].$el.classList;
            classList.add("none");
          }
        }
      }

      // const classList =
      //   this.$refs[itemModel.id + "AnalyzeList"][0].$el.classList;
      // classList.toggle("none");
    },

    //切换项目
    handleChangeXM(val) {
      // closAndChangeXM(val);
      // 清除待选模型
      this.WaitingSelectionModel = null;
      // 清除其他选定样式
      for (let key in this.$refs) {
        if (key.indexOf("Model") !== -1) {
          let item = this.$refs[key][0];
          if (item) {
            item.childNodes.forEach((Citem) => {
              if (
                Citem.className &&
                Citem.className.indexOf("status ce") !== -1
              ) {
                Citem.style.display = "none";
              }
            });
          }
        }
        if (key.indexOf("AnalyzeList") !== -1) {
          let itemfx = this.$refs[key][0];
          if (itemfx) {
            itemfx.$el.classList.add("none");
          }
        }
      }
    },

    /**
     * //打开切换项目时关闭并初始化新项目必要图层
     * @param xmid
     */
    closAndChangeXM(xmid) {
      //清空之前打开的项目信息等
      //打开新项目图层
    },

    //选中报建模型
    SelectConstructionModelHendle(Minfo) {
      debugger;
      if (this.WaitingSelectionModel != Minfo) {
        this.removeModel();
        this.WaitingSelectionModel = null;
        this.removeAll();
        debugger;

        var wshData = this.wsh.find((c) => c.id == Minfo.projectinformationid);
        if (wshData && wshData.meetingprogress != "1") {
          // 清除其他选定样式
          for (let key in this.$refs) {
            if (key.indexOf("Model") !== -1) {
              let item = this.$refs[key][0];
              item.childNodes.forEach((Citem) => {
                if (
                  Citem.className &&
                  Citem.className.indexOf("status ce") !== -1
                ) {
                  Citem.style.display = "none";
                }
              });
            }
          }
          // 添加当前选定样式及待选模型
          this.$refs["Model" + Minfo.id][0].childNodes.forEach((item) => {
            if (item.className && item.className.indexOf("status ce") !== -1) {
              item.style.display = "block";
            }
          });
        }
        this.WaitingSelectionModel = Minfo;
        //添加模型
        this.addModel(Minfo);
      }
    },
    //添加项目模型
    openAddConstructionModelInfo(info) {
      if (this.AddConstructionModelInfolayerid) {
        this.$layer.close(this.AddConstructionModelInfolayerid);
      }
      this.AddConstructionModelInfolayerid = this.$layer.iframe({
        content: {
          content: addConstructionModelInfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info }, //props
        },

        area: ["30rem", "40rem"], //宽 高
        title: "添加项目模型详情",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: async () => {
          //关闭事件
          debugger;
          // this.wsh = await this.getshProjectinformations("0");
          this.wshinit();
        },
      });
    },
    // 添加项目信息
    openaddProjectInfo(item) {
      if (this.addProjectInfolayerid) {
        this.$layer.close(this.addProjectInfolayerid);
      }
      this.addProjectInfolayerid = this.$layer.iframe({
        content: {
          content: addProjectInfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info: item }, //props
        },

        area: ["30rem", "38rem"], //宽 高
        title: item != null ? "修改项目详情" : "添加项目详情",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: async () => {
          //关闭事件
          debugger;
          // this.wsh = await this.getshProjectinformations("0");
          this.wshinit();
        },
      });
    },
    //删除报建模型
    async removeConstructionmodel(Minfo) {
      this.$layer.confirm("确认删除该报建模型？", async (layerid) => {
        let istrue = await delConstructionmodel(Minfo.id);
        if (istrue.code == 200) {
          this.$message({
            message: istrue.msg,
            type: "success",
          });
          this.getProjectInfos();
          this.$layer.close(layerid);
        }
      });
    },

    //删除项目
    async deleteProject(id) {
      this.$layer.confirm("确认删除该项目？", async (layerid) => {
        let istrue = await delProjectinformation(id);
        if (istrue.code == 200) {
          this.$message({
            message: istrue.msg,
            type: "success",
          });
          this.getProjectInfos();
          this.$layer.close(layerid);
        }
      });
    },

    //打开项目信息弹窗
    openProjectInfo(info) {
      if (this.ProjectInfolayerid) {
        this.$layer.close(this.ProjectInfolayerid);
      }
      let w = document.body.offsetWidth;
      let h = document.body.offsetHeight;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      let left = 430 / 2 + 556;
      let top = 430 / 2 + 60;
      this.ProjectInfolayerid = this.$layer.iframe({
        content: {
          content: projectInfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "430px"], //宽 高
        title: "项目详情",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          // alert("关闭iframe");
        },
      });
    },
    // 打开模型信息弹窗
    openConstructionModel(info) {
      if (this.ConstructionModellayerid) {
        this.$layer.close(this.ConstructionModellayerid);
      }
      let w = document.body.offsetWidth;
      let h = document.body.offsetHeight;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      let left = 430 / 2 + 556;
      let top = 430 / 2 + 60;
      let layerid = this.$layer.iframe({
        content: {
          content: ConstructionModelInfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "430px"], //宽 高
        title: "模型详情",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          // alert("关闭iframe");
        },
      });
    },
    //打开夜景分析弹窗
    openNightscapeAnalysis(info) {
      let w = document.body.offsetWidth;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      let left = w - 430 + 430 / 2;
      let top = 550 / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: NightscapeAnalysis, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "550px"],
        title: "夜景分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          // alert("关闭iframe");
        },
      });
    },
    //打开天际线分析弹窗
    openskylineAnalysis(info) {
      let w = document.body.offsetWidth;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      let left = w - 430 + 430 / 2;
      let top = 550 / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: skylineAnalysis, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info }, //props
        },
        offset: [left, top], //left top
        area: ["300px", "450px"],
        title: "天际线分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          // alert("关闭iframe");
        },
      });
    },
    //打开日照分析弹窗
    openSunlightAnalysis(info) {
      let w = document.body.offsetWidth;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      let left = w - 430 + 430 / 2;
      let top = 550 / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: SunlightAnalysis, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "600px"],
        title: "日照分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          // alert("关闭iframe");
        },
      });
    },

    //添加模型
    async addModel(Minfo) {
      await this.yp([Minfo]);
      var modelLayer = scene.open(Minfo.url);
      let that = this;
      that.layerDataList = [];
      Cesium.when(modelLayer, async function (layers) {
        layers.forEach((layer) => {
          viewer.flyTo(layer);
          layer.shadowType = 2;
          that.layerList.push(layer.name);
        });

        //获取模型信息
        let queryBySQLParameters = {
          getFeatureMode: "SQL",
          datasetNames: [Minfo.datasourcename + ":" + Minfo.datasetname],
          queryParameter: {
            attributeFilter: "1=1",
          },
          hasGeometry: true,
        };
        let e = await mapQuery(
          Minfo.dataurl + "/featureResults.json?returnContent=true",
          queryBySQLParameters
        );
        if (e) {
          e.features.forEach((feature) => {
            let layerData = { 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()
                  )
                : null;
              if (Field) {
                layerData.data.push({
                  label: fieldName,
                  labelCN: Field ? Field.caption : fieldName,
                  value: feature.fieldValues[i],
                });
              }
            });
            that.layerDataList.push(layerData);
          });
        }

        that.layerDataList.forEach((layerData) => {
          // 添加模型楼号
          let SMID = layerData.data.find((c) => c.label == "SMID").value;
          let HEIGHT = layerData.data.find((c) => c.label == "HEIGHT").value;
          let x = layerData.geometry.center.x;
          let y = layerData.geometry.center.y;
          let z = Number(HEIGHT) + 29.7;

          let BUILDNO = "";
          if (layerData.data.find((c) => c.label == "BUILDNO")) {
            BUILDNO = layerData.data.find((c) => c.label == "BUILDNO").value;
          }

          var BoxIndex = popupBoxs.findIndex(
            (c) => c.element.id == "MXLH-" + SMID
          );
          if (BoxIndex > -1) {
            popupBoxs[BoxIndex].destroy();
            popupBoxs.splice(BoxIndex, 1);
          }

          let dom = document.createElement("div");
          dom.id = "MXLH-" + SMID;
          dom.style.position = "absolute";
          dom.style.width = "0";
          dom.style.height = "0";
          // dom.style.color = "rgba(2, 23, 44, 0.8)";
          // dom.style.backgroundColor = "rgba(2, 23, 44, 0.8)";
          dom.style.fontSize = "1.4rem";
          let domContent = document.createElement("div");
          domContent.style.position = "absolute";
          domContent.style.borderRadius = "5px";
          // domContent.style.border = "1px solid rgba(7, 131, 250, 0.3)";
          // domContent.style.backgroundColor = "rgba(2, 23, 44, 0.7)";
          domContent.style.bottom = "0px";
          domContent.style.left = "0px";
          domContent.style.whiteSpace = "nowrap";
          domContent.style.color = "rgba(83, 249, 255,1)";
          // domContent.style.padding = "8px 12px";
          domContent.style.transform = "translate(-50%, 0%)";

          domContent.innerHTML = BUILDNO;
          dom.appendChild(domContent);

          var popupBox = new Popup({
            viewer: viewer,
            element: dom,
            pixelOffset: new Cesium.Cartesian2(0, 0),
            translucencyByDistance: new Cesium.NearFarScalar(0, 1, 50000, 1),
            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
              0,
              51000
            ),
            position: Cesium.Cartesian3.fromDegrees(x, y, z),
          });

          popupBox.show();
          popupBoxs.push(popupBox);

          // if (viewer.entities.getById("MXLH-" + SMID)) {
          //   viewer.entities.removeById("MXLH-" + SMID);
          // }
          // let label = viewer.entities.add({
          //   id: "MXLH-" + SMID,
          //   // name: "MXLH-" + SMID,
          //   //点
          //   position: Cesium.Cartesian3.fromDegrees(x, y, z),
          //   label: {
          //     text: BUILDNO, //描述内容
          //     font: "20px Sans-Serif", //字体大小 类型
          //     fillColor: new Cesium.Color(83 / 255, 249 / 255, 255 / 255, 1), //颜色
          //     outlineColor: Cesium.Color.GOLD,
          //     style: Cesium.LabelStyle.CENTER_LABEL,
          //     // 垂直位置
          //     verticalOrigin: Cesium.VerticalOrigin.BUTTON,
          //     // 中心位置
          //     pixelOffset: new Cesium.Cartesian2(0, -10),
          //     //设置背景颜色透明
          //     backgroundColor: new Cesium.Color(
          //       35 / 255,
          //       55 / 255,
          //       75 / 255,
          //       0
          //     ),
          //     //打开背景  打开背景 （不会被线段覆盖）
          //     showBackground: true,
          //     heightReference: Cesium.HeightReference.NONE,
          //   },
          // });
        });
      });
    },
    //添加多个模型
    async addModels(Minfos, completed) {
      await this.yp(Minfos);
      debugger;
      let models = [];
      Minfos.forEach((element) => {
        var modelLayer = scene.open(element.url);
        models.push(modelLayer);
      });
      // 为每个 Promise 添加 .catch() 处理程序
      const modifiedPromises = models.map((promise) => {
        return promise.otherwise((error) => {
          // 在这里处理错误，例如记录日志或执行其他操作

          // 返回一个默认值或空值，以便 Cesium.when.all 可以继续处理其他 Promise
          return null; // 或者其他默认值
        });
      });

      let that = this;

      Cesium.when
        .all(modifiedPromises, async function (modelLayers) {
          debugger;
          for (let index = 0; index < modelLayers.length; index++) {
            let modelData = {
              id: uuidv4(),
              Minfo: null,
              layers: [],
              layerDataList: [],
            };
            const Minfo = Minfos[index];
            modelData.Minfo = Minfo;
            const layer = modelLayers[index];

            if (layer) {
              layer.forEach((element) => {
                // element.shadowType = 2;
                //不同视口显隐
                for (let n = 0; n < modelLayers.length; n++) {
                  if (index == n) {
                    element.setVisibleInViewport(n, true);
                  } else {
                    element.setVisibleInViewport(n, false);
                  }
                }

                modelData.layers.push(element.name);
              });
              //获取模型信息
              let queryBySQLParameters = {
                getFeatureMode: "SQL",
                datasetNames: [Minfo.datasourcename + ":" + Minfo.datasetname],
                queryParameter: {
                  attributeFilter: "1=1",
                },
                hasGeometry: true,
              };
              let e = await mapQuery(
                Minfo.dataurl + "/featureResults.json?returnContent=true",
                queryBySQLParameters
              );
              e.features.forEach((feature) => {
                let layerData = { 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()
                      )
                    : null;
                  if (Field) {
                    layerData.data.push({
                      label: fieldName,
                      labelCN: Field ? Field.caption : fieldName,
                      value: feature.fieldValues[i],
                    });
                  }
                });
                modelData.layerDataList.push(layerData);
              });

              // modelData.layerDataList.forEach((layerData) => {
              //   // 添加模型楼号
              //   let SMID = layerData.data.find((c) => c.label == "SMID").value;
              //   let x = layerData.geometry.position.x;
              //   let y = layerData.geometry.position.y;
              //   let z =
              //     layerData.geometry.boundingBox.upper.z -
              //     layerData.geometry.boundingBox.lower.z;
              //   let BUILDNO = layerData.data.find(
              //     (c) => c.label == "BUILDNO"
              //   ).value;
              //   if (
              //     viewer.entities.getById("MXLH-" + modelData.id + "-" + SMID)
              //   ) {
              //     viewer.entities.removeById(
              //       "MXLH-" + modelData.id + "-" + SMID
              //     );
              //   }
              //   let labeltext = viewer.entities.add({
              //     id: "MXLH-" + modelData.id + "-" + SMID,
              //     //点
              //     position: Cesium.Cartesian3.fromDegrees(x, y, z),
              //     label: {
              //       text: BUILDNO, //描述内容
              //       font: "20px Sans-Serif", //字体大小 类型
              //       fillColor: new Cesium.Color(
              //         83 / 255,
              //         249 / 255,
              //         255 / 255,
              //         1
              //       ), //颜色
              //       outlineColor: Cesium.Color.GOLD,
              //       style: Cesium.LabelStyle.CENTER_LABEL,
              //       // 垂直位置
              //       verticalOrigin: Cesium.VerticalOrigin.BUTTON,
              //       // 中心位置
              //       pixelOffset: new Cesium.Cartesian2(0, -10),
              //       //设置背景颜色透明
              //       backgroundColor: new Cesium.Color(
              //         35 / 255,
              //         55 / 255,
              //         75 / 255,
              //         0
              //       ),
              //       //打开背景  打开背景 （不会被线段覆盖）
              //       showBackground: true,
              //       heightReference: Cesium.HeightReference.NONE ,
              //     },
              //   });

              // });
              that.modelsload.push(modelData);
            } else {
              that.loading = false;
              scene.multiViewportMode = Cesium.MultiViewportMode.NONE;
              that.removeModel();
              that.$message({
                message: "模型：" + Minfo.modelname + "加载失败，请检查服务",
                type: "warning",
              });
              for (let index = 0; index < modelLayers.length; index++) {
                const layer = modelLayers[index];
                if (layer) {
                  layer.forEach((element) => {
                    scene.layers.remove(element.name);
                  });
                }
              }
              return;
            }
          }
          if (completed && isFunction(completed)) {
            completed();
          }
        })
        .otherwise(function (error) {
          debugger;
          that.loading = false;
          that.$message({
            message: "加载失败，请联系管理员",
            type: "warning",
          });
          scene.multiViewportMode = Cesium.MultiViewportMode.NONE;
          that.removeModel();
          scene.layers.removeAll();
        });
    },
    //删除模型图层
    removeModel() {
      // this.qxyp();
      this.layerList.forEach((element) => {
        scene.layers.remove(element);
      });
      this.layerList = [];

      for (let index = popupBoxs.length - 1; index >= 0; index--) {
        const popupBox = popupBoxs[index];
        if (popupBox.element.id.includes("MXLH-")) {
          popupBox.destroy();
          popupBoxs.splice(index, 1);
        }
      }
      // this.layerDataList.forEach((element) => {
      //   let SMID = element.data.find((c) => c.label == "SMID").value;
      //   viewer.entities.removeById("MXLH-" + SMID);
      // });
      this.layerDataList = [];

      //清除多模型图层，数据
      this.modelsload.forEach((model) => {
        model.layers.forEach((element) => {
          scene.layers.remove(element);
        });

        // model.layerDataList.forEach((layerData) => {
        //   let SMID = layerData.data.find((c) => c.label == "SMID").value;
        //   viewer.entities.removeById("MXLH-" + model.id + "-" + SMID);
        // });
      });
      this.modelsload = [];
    },
    //定位模型
    async positionModel(Minfo) {
      if (this.WaitingSelectionModel == Minfo && this.layerList.length > 0) {
        this.layerList.forEach((element, i) => {
          let layer = scene.layers.find(element);
          viewer.flyTo(layer);
        });
      } else {
        this.SelectConstructionModelHendle(Minfo);
      }
    },
    //模型对比按钮
    ModelComparison(info) {
      let that = this;
      if (this.modelsload.length > 0) {
        scene.multiViewportMode = Cesium.MultiViewportMode.NONE;
        this.removeModel();
        return;
      }
      this.loading = true;
      let modeinfos = this.getConstructionModel(info);
      let checkedModeinfos = [];
      modeinfos.forEach((modeinfo) => {
        if (modeinfo.checked) {
          checkedModeinfos.push(modeinfo);
        }
      });
      if (checkedModeinfos.length > 0 && checkedModeinfos.length < 5) {
        switch (checkedModeinfos.length) {
          case 1:
            scene.multiViewportMode = Cesium.MultiViewportMode.NONE;
            break;
          case 2:
            scene.multiViewportMode = Cesium.MultiViewportMode.HORIZONTAL;
            break;
          case 3:
            scene.multiViewportMode =
              Cesium.MultiViewportMode.VerticalTrisection;
            break;
          case 4:
            scene.multiViewportMode = Cesium.MultiViewportMode.SEVEN_DIVISIONS;
            break;
          default:
            scene.multiViewportMode = Cesium.MultiViewportMode.NONE;
            break;
        }
        this.removeModel();
        //加载模型
        this.addModels(checkedModeinfos, function () {
          that.openMXDBInfo();
          that.loading = false;
        });
      } else if (checkedModeinfos.length >= 5) {
        this.loading = false;
        this.$message({
          message: "不能多于4个模型。",
          type: "warning",
        });
      } else {
        this.loading = false;
        this.$message({
          message: "请点击复选框，选中至少一个模型进行对比。",
          type: "warning",
        });
      }
    },
    // 获取规划地块
    getGuiHuaDiKuai(completed) {
      if (this.LandPlanningList.length > 0 || this.handler != null) {
        this.removeAll();
      }

      let that = this;
      this.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
      this.handler.setInputAction((evt) => {
        that.tooltip.showAt(
          evt.endPosition,
          `<p>点击地图，选择要分析的点位坐标,右键取消</p>`
        );
      }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
      this.handler.setInputAction((evt) => {
        that.removeEventHandler();
      }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
      this.handler.setInputAction(async function (movement) {
        that.tooltip.setVisible(false);
        //拾取图层
        let pick = scene.pickPosition(movement.position);

        let xy = cartesian3ToWGS84(pick);

        //查询用地红线
        let layer = flatten(window.layerTree).find(
          (item) => item.core == "003006"
        );

        let queryByIDParameters = {
          getFeatureMode: "BUFFER",
          datasetNames: [
            layer.date_server.datasourcename +
              ":" +
              layer.date_server.datasetname,
          ],
          geometry: {
            parts: [1],
            points: [{ y: xy.lat, x: xy.lng }],
            type: "POINT",
          },
          bufferDistance: 0.000005,
          hasGeometry: true,
        };
        let e = await mapQuery(
          layer.date_server.url + "/featureResults.json?returnContent=true",
          queryByIDParameters
        );
        if (e && e.totalCount > 0) {
          let GHYDlayerData = {
            id: uuidv4(),
            layerInfo: layer,
            data: [],
            geometry: e.features[0].geometry,
          };

          e.features[0].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) {
              GHYDlayerData.data.push({
                label: fieldName,
                labelCN: Field ? Field.caption : fieldName,
                value: e.features[0].fieldValues[i],
              });
            }
          });

          let ps = [];
          for (
            let index = 0;
            index < GHYDlayerData.geometry.points.length;
            index++
          ) {
            const element = GHYDlayerData.geometry.points[index];
            ps.push(element.x);
            ps.push(element.y);
          }
          //获取地块编码
          // let SMID = GHYDlayerData.data.find((c) => c.label == "SMID").value;
          let DKBM = GHYDlayerData.data.find((c) => c.label == "DKBM").value;
          let YDMJ = GHYDlayerData.data.find((c) => c.label == "YDMJ").value;
          const line = viewer.entities.add({
            id: "ydhxl-" + GHYDlayerData.id,
            polyline: {
              positions: Cesium.Cartesian3.fromDegreesArray(ps),
              width: 5,
              material: Cesium.Color.RED,
              clampToGround: true,
            },
          });
          //生成点
          const point = viewer.entities.add({
            id: "ydhxp-" + GHYDlayerData.id,
            //点
            position: Cesium.Cartesian3.fromDegrees(ps[0], ps[1]),
            label: {
              text: DKBM + "  " + YDMJ + "㎡", //描述内容
              font: "30px Sans-Serif", //字体大小 类型
              fillColor: Cesium.Color.RED, //颜色
              outlineColor: Cesium.Color.GOLD,
              style: Cesium.LabelStyle.CENTER_LABEL,
              // 垂直位置
              verticalOrigin: Cesium.VerticalOrigin.BUTTON,
              // 中心位置
              pixelOffset: new Cesium.Cartesian2(0, -10),
              //设置背景颜色透明
              backgroundColor: new Cesium.Color(0.0, 0.0, 0.0, 0.0),
              //打开背景  打开背景 （不会被线段覆盖）
              showBackground: true,
              heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
              clampToS3M: true,
            },
          });
          that.LandPlanningList.push(GHYDlayerData);
        }

        that.removeEventHandler();
        if (completed && isFunction(completed)) {
          completed();
        }
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
    },

    //控规分析
    KGAnalysis(Minfo) {
      let that = this;
      this.getGuiHuaDiKuai(function () {
        that.getBufferTraffic();
        that.getbackLine(Minfo);
      });
    },
    //区位分析
    DistrictAnalysis() {
      this.getGuiHuaDiKuai();
    },
    /**
     * 限高分析
     * @param Minfo  报建模型信息
     */
    limitHeightAnalysis(Minfo) {
      let that = this;
      this.getGuiHuaDiKuai(function () {
        that.HighLimit(Minfo);
      });
    },
    // 生成限高
    async HighLimit(Minfo) {
      let that = this;
      let JZXGD = 0;
      let DKBM = [];

      if (that.LandPlanningList.length > 0) {
        let ps = [];
        for (
          let LandPlanningListindex = 0;
          LandPlanningListindex < that.LandPlanningList.length;
          LandPlanningListindex++
        ) {
          const GHYDlayerData = that.LandPlanningList[LandPlanningListindex];

          let bm = GHYDlayerData.data.find((c) => c.label == "DKBM");
          if (bm && bm.value) {
            DKBM.push(bm.value);
          }
          //基础高度（地形高度）加入地形后可删除
          let jcgd = 0;
          //获取模型信息
          let queryBySQLParameters = {
            getFeatureMode: "SQL",
            datasetNames: [Minfo.datasourcename + ":项目范围"],
            queryParameter: {
              attributeFilter: " DKBM = '" + bm.value + "'",
            },
            hasGeometry: true,
          };
          let e = await mapQuery(
            Minfo.dataurl + "/featureResults.json?returnContent=true",
            queryBySQLParameters
          );

          if (e && e.totalCount > 0) {
            e.features.forEach((feature) => {
              feature.fieldNames.forEach((fieldName, i) => {
                if (
                  fieldName == "BASEH" &&
                  Number(feature.fieldValues[i]) > jcgd
                ) {
                  jcgd = Number(feature.fieldValues[i]);
                }
              });
            });
          }
          ps = [];
          for (
            let index = 0;
            index < GHYDlayerData.geometry.points.length;
            index++
          ) {
            const element = GHYDlayerData.geometry.points[index];
            ps.push(element.x);
            ps.push(element.y);
          }
          JZXGD = Number(
            GHYDlayerData.data.find((c) => c.label == "JZXGD").value
          );
          let entity = viewer.entities.add({
            id: "polygonA",
            polygon: {
              hierarchy: Cesium.Cartesian3.fromDegreesArray(ps),
              height: JZXGD + jcgd || 0,
              material: new Cesium.Color(1, 1, 0.2, 0.5),
              outline: true,
              outlineColor: Cesium.Color.RED,
              clampToGround: true,
            },
          });
          debugger;

          let dom = document.createElement("div");
          dom.id = "JZXGD-A";
          dom.style.position = "absolute";
          dom.style.width = "0";
          dom.style.height = "0";
          // dom.style.color = "rgba(2, 23, 44, 0.8)";
          // dom.style.backgroundColor = "rgba(2, 23, 44, 0.8)";
          dom.style.fontSize = "1rem";

          let domContent = document.createElement("div");
          domContent.style.position = "absolute";
          domContent.style.borderRadius = "5px";
          domContent.style.border = "1px solid rgba(7, 131, 250, 0.3)";
          domContent.style.backgroundColor = "rgba(2, 23, 44, 0.7)";
          domContent.style.bottom = "0px";
          domContent.style.left = "0px";
          domContent.style.whiteSpace = "nowrap";
          domContent.style.color = "red";
          // domContent.style.padding = "8px 12px";
          domContent.style.transform = "translate(-50%, 0%)";

          domContent.innerHTML = "限高上限：" + JZXGD + "米";
          dom.appendChild(domContent);

          var popupBox = new Popup({
            viewer: viewer,
            element: dom,
            pixelOffset: new Cesium.Cartesian2(0, 0),
            translucencyByDistance: new Cesium.NearFarScalar(0, 1, 50000, 1),
            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
              0,
              51000
            ),
            position: Cesium.Cartesian3.fromDegrees(ps[0], ps[1], JZXGD + jcgd),
          });

          popupBox.show();
          popupBoxs.push(popupBox);

          // let label = viewer.entities.add({
          //   id: "JZXGD-A",
          //   //点
          //   position: Cesium.Cartesian3.fromDegrees(ps[0], ps[1], JZXGD + jcgd),
          //   label: {
          //     text: "限高上限：" + JZXGD + "米", //描述内容
          //     // font: "20px Sans-Serif", //字体大小 类型
          //     fillColor: Cesium.Color.RED, //颜色
          //     // outlineColor: Cesium.Color.GOLD,
          //     // style: Cesium.LabelStyle.CENTER_LABEL,
          //     // // 垂直位置
          //     // verticalOrigin: Cesium.VerticalOrigin.BUTTON,
          //     // // 中心位置
          //     // pixelOffset: new Cesium.Cartesian2(0, -10),
          //     // //设置背景颜色透明
          //     // backgroundColor: new Cesium.Color(0.0, 0.0, 0.0, 0.0),
          //     // //打开背景  打开背景 （不会被线段覆盖）
          //     // showBackground: true,
          //     heightReference: Cesium.HeightReference.NONE,
          //   },
          // });
          // that.layerList.forEach((layer) => {
          //   debugger;
          //   var hyp = new Cesium.HypsometricSetting();

          //   //创建分层设色对象   设置最大/最小可见高度   颜色表  显示模式   透明度及线宽
          //   var colorTable = new Cesium.ColorTable();
          //   colorTable.insert(999, new Cesium.Color(1, 0, 0));
          //   colorTable.insert(JZXGD, new Cesium.Color(1, 0, 0));
          //   hyp.MaxVisibleValue = 999;
          //   hyp.MinVisibleValue = JZXGD;

          //   hyp.ColorTable = colorTable;
          //   hyp.DisplayMode = Cesium.HypsometricSettingEnum.DisplayMode.FACE;
          //   hyp.Opacity = 0.5;

          //   hyp.LineInterval = 10.0;

          //   //设置图层分层设色属性
          //   layer.hypsometricSetting = {
          //     hypsometricSetting: hyp,
          //     CoverageArea: ps,
          //     analysisMode:
          //       Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_REGION,
          //   };
          // });

          that.layerDataList.forEach((layerData) => {
            let LANDNO = layerData.data.find((c) => c.label == "LANDNO").value;

            if (bm.value == LANDNO) {
              let SMID = layerData.data.find((c) => c.label == "SMID").value;
              let Height = layerData.data.find(
                (c) => c.label == "HEIGHT"
              ).value;
              // let x = layerData.geometry.boundingBox.upper.x;
              // let y = layerData.geometry.boundingBox.upper.y;
              // let z =
              //   layerData.geometry.boundingBox.upper.z -
              //   layerData.geometry.boundingBox.lower.z;
              let x = layerData.geometry.center.x;
              let y = layerData.geometry.center.y;
              let z = Number(Height);

              // if (viewer.entities.getById("JZXG-" + SMID)) {
              //   viewer.entities.removeById("JZXG-" + SMID);
              // }
              debugger;

              var BoxIndex = popupBoxs.findIndex(
                (c) => c.element.id == "JZXG-" + SMID
              );
              if (BoxIndex > -1) {
                popupBoxs[BoxIndex].destroy();
                popupBoxs.splice(BoxIndex, 1);
              }

              let cg = this.calculateHighLimit(Height, JZXGD);
              if (cg > 0) {
                debugger;

                let dom = document.createElement("div");
                dom.id = "JZXG-" + SMID;
                dom.style.position = "absolute";
                dom.style.width = "0";
                dom.style.height = "0";
                // dom.style.color = "rgba(2, 23, 44, 0.8)";
                // dom.style.backgroundColor = "rgba(2, 23, 44, 0.8)";
                dom.style.fontSize = "1rem";

                let domContent = document.createElement("div");
                domContent.style.position = "absolute";
                domContent.style.borderRadius = "5px";
                domContent.style.border = "1px solid rgba(7, 131, 250, 0.3)";
                domContent.style.backgroundColor = "rgba(2, 23, 44, 0.7)";
                domContent.style.bottom = "0px";
                domContent.style.left = "0px";
                domContent.style.whiteSpace = "nowrap";
                domContent.style.color = "white";
                // domContent.style.padding = "8px 12px";
                domContent.style.transform = "translate(-50%, 0%)";

                domContent.innerHTML = "超高：" + cg + "米";
                dom.appendChild(domContent);

                var popupBox = new Popup({
                  viewer: viewer,
                  element: dom,
                  pixelOffset: new Cesium.Cartesian2(0, 0),
                  translucencyByDistance: new Cesium.NearFarScalar(
                    0,
                    1,
                    50000,
                    1
                  ),
                  distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
                    0,
                    51000
                  ),
                  position: Cesium.Cartesian3.fromDegrees(x, y, z + jcgd + 3),
                });

                popupBox.show();
                popupBoxs.push(popupBox);

                // let label = viewer.entities.add({
                //   id: "JZXG-" + SMID,
                //   //点
                //   position: Cesium.Cartesian3.fromDegrees(x, y, z + jcgd + 6),
                //   label: {
                //     text: "超高：" + cg + "米", //描述内容
                //     font: "14px", //字体大小 类型
                //     fillColor: new Cesium.Color(
                //       255 / 255,
                //       255 / 255,
                //       255 / 255,
                //       1
                //     ), //颜色
                //     // outlineColor: Cesium.Color.GOLD,
                //     // // style: Cesium.LabelStyle.CENTER_LABEL,
                //     // // 垂直位置
                //     // verticalOrigin: Cesium.VerticalOrigin.BUTTON,
                //     // // 中心位置
                //     // pixelOffset: new Cesium.Cartesian2(0, -10),
                //     //设置背景颜色透明
                //     backgroundColor: new Cesium.Color(
                //       0 / 255,
                //       0 / 255,
                //       0 / 255,
                //       0.6
                //     ),
                //     //打开背景  打开背景 （不会被线段覆盖）
                //     // showBackground: true,
                //     heightReference: Cesium.HeightReference.NONE,
                //   },
                // });
              }
            }
          });
        }
      }
      // this.openXGFXInfo(that.layerDataList, JZXGD, DKBM);
    },
    /**
     * // 计算超高距离
     * @param Height 建筑高度
     * @param JZXGD 限高上限
     */
    calculateHighLimit(Height, JZXGD) {
      let sd = Height - JZXGD;
      return sd.toFixed(2);
    },
    /**
     * 交通分析
     */
    trafficAnalysis() {
      let that = this;
      this.getGuiHuaDiKuai(function () {
        that.getBufferTraffic();
      });
    },
    /**
     * 查询200米范围内的道路
     */
    async getBufferTraffic() {
      let that = this;
      let geo = this.LandPlanningList[0].geometry;

      // let geo = {
      //   id: 0,
      //   style: null,
      //   parts: geometry.parts,
      //   points: geometry.points,
      //   type: "REGION",
      //   prjCoordSys: {
      //     epsgCode: null,
      //   },
      // };

      // 加载道路红线
      //道路红线
      let layer = flatten(window.layerTree).find(
        (item) => item.core == "005006"
      );
      if (layer && layer.date_server.url) {
        let queryByGeometryParameters = {
          getFeatureMode: "BUFFER",
          datasetNames: [
            layer.date_server.datasourcename +
              ":" +
              layer.date_server.datasetname,
          ],
          geometry: geo,
          bufferDistance: 0.002,
          hasGeometry: "true",
        };
        let e = await mapQuery(
          layer.date_server.url + "/featureResults.json?returnContent=true",
          queryByGeometryParameters
        );

        if (e && e.totalCount > 0) {
          e.features.forEach((feature) => {
            let DLlayerData = {
              id: uuidv4(),
              layerInfo: layer,
              data: [],
              geometry: feature.geometry,
              entities: [],
            };
            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) {
                DLlayerData.data.push({
                  label: fieldName,
                  labelCN: Field ? Field.caption : fieldName,
                  value: feature.fieldValues[i],
                });
              }
            });
            let ps = [];
            for (
              let index = 0;
              index < feature.geometry.points.length;
              index++
            ) {
              const element = feature.geometry.points[index];
              ps.push(element.x);
              ps.push(element.y);
            }
            //判断是否规划道路

            const line = viewer.entities.add({
              id: "DLX-" + DLlayerData.id,
              polyline: {
                positions: Cesium.Cartesian3.fromDegreesArray(ps),
                width: 5,
                material: Cesium.Color.GREENYELLOW,
                clampToGround: true,
              },
            });
            DLlayerData.entities.push(line.id);

            that.DLlayerDatas.push(DLlayerData);
          });
        }
      }

      // 加载道路中线
      layer = flatten(window.layerTree).find((item) => item.core == "005004");
      if (layer && layer.date_server.url) {
        let queryByGeometryParameters = {
          getFeatureMode: "BUFFER",
          datasetNames: [
            layer.date_server.datasourcename +
              ":" +
              layer.date_server.datasetname,
          ],
          geometry: geo,
          bufferDistance: 0.002,
          hasGeometry: "true",
        };
        let e = await mapQuery(
          layer.date_server.url + "/featureResults.json?returnContent=true",
          queryByGeometryParameters
        );

        if (e && e.totalCount > 0) {
          e.features.forEach((feature) => {
            let DLlayerData = {
              id: uuidv4(),
              layerInfo: layer,
              data: [],
              geometry: feature.geometry,
              entities: [],
            };
            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) {
                DLlayerData.data.push({
                  label: fieldName,
                  labelCN: Field ? Field.caption : fieldName,
                  value: feature.fieldValues[i],
                });
              }
            });
            let ps = [];
            for (
              let index = 0;
              index < feature.geometry.points.length;
              index++
            ) {
              const element = feature.geometry.points[index];
              ps.push(element.x);
              ps.push(element.y);
            }
            //判断是否规划道路

            let SSQK = DLlayerData.data.find((c) => c.label == "SSQK");
            if (SSQK && SSQK.value == "规划") {
              var line = viewer.entities.add({
                id: "DLX-" + DLlayerData.id,
                polyline: {
                  positions: Cesium.Cartesian3.fromDegreesArray(ps),
                  width: 4,
                  material: new Cesium.PolylineDashMaterialProperty({
                    color: Cesium.Color.CYAN,
                    clampToGround: true,
                  }),
                  clampToGround: true,
                },
              });
              DLlayerData.entities.push(line.id);
            } else {
              const line = viewer.entities.add({
                id: "DLX-" + DLlayerData.id,
                polyline: {
                  positions: Cesium.Cartesian3.fromDegreesArray(ps),
                  width: 5,
                  material: Cesium.Color.CYAN,
                  clampToGround: true,
                },
              });
              DLlayerData.entities.push(line.id);
            }

            that.DLlayerDatas.push(DLlayerData);
          });
        }
      }
      // 加载禁止开口线
      layer = flatten(window.layerTree).find((item) => item.core == "005005");
      if (layer && layer.date_server.url) {
        let queryByGeometryParameters = {
          getFeatureMode: "BUFFER",
          datasetNames: [
            layer.date_server.datasourcename +
              ":" +
              layer.date_server.datasetname,
          ],
          geometry: geo,
          bufferDistance: 0.002,
          hasGeometry: "true",
        };
        let e = await mapQuery(
          layer.date_server.url + "/featureResults.json?returnContent=true",
          queryByGeometryParameters
        );

        if (e && e.totalCount > 0) {
          e.features.forEach((feature) => {
            let DLlayerData = {
              id: uuidv4(),
              layerInfo: layer,
              data: [],
              geometry: feature.geometry,
              entities: [],
            };
            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) {
                DLlayerData.data.push({
                  label: fieldName,
                  labelCN: Field ? Field.caption : fieldName,
                  value: feature.fieldValues[i],
                });
              }
            });
            let ps = [];
            for (
              let index = 0;
              index < feature.geometry.points.length;
              index++
            ) {
              const element = feature.geometry.points[index];
              ps.push(element.x);
              ps.push(element.y);
            }

            const line = viewer.entities.add({
              id: "DLX-" + DLlayerData.id,
              polyline: {
                positions: Cesium.Cartesian3.fromDegreesArray(ps),
                width: 5,
                material: Cesium.Color.RED,
                clampToGround: true,
              },
            });

            DLlayerData.entities.push(line.id);
            that.DLlayerDatas.push(DLlayerData);
          });
        }
      }
    },

    //切换地下模式
    undergroundModeAnalysis() {
      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 - 340 + 340 / 2;
      let top = 340 / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: clipboxByEditor, //传递的组件对象
          parent: this, //当前的vue对象
          data: {}, //props
        },
        offset: [left, top], //left top
        area: ["340px", "180px"], //宽 高
        title: "地下分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
        },
      });
    },
    //建筑退线
    backLineAnalysis(Minfo) {
      let that = this;
      this.getGuiHuaDiKuai(function () {
        that.getbackLine(Minfo);
      });
    },
    // 绘制建筑退线面
    async getbackLine(Minfo) {
      let that = this;
      let DKBM = [];
      if (that.LandPlanningList.length > 0) {
        let layer = flatten(window.layerTree).find(
          (item) => item.core == "004004"
        );
        if (layer && layer.date_server && layer.date_server.url) {
          for (
            let GHYDindex = 0;
            GHYDindex < that.LandPlanningList.length;
            GHYDindex++
          ) {
            const GHYDlayerData = that.LandPlanningList[GHYDindex];
            let bm = GHYDlayerData.data.find((c) => c.label == "DKBM");
            if (bm && bm.value) {
              DKBM.push(bm.value);
            }

            //基础高度（地形高度）加入地形后可删除
            let jcgd = 0;
            //获取模型信息
            let queryBySQLParameters = {
              getFeatureMode: "SQL",
              datasetNames: [Minfo.datasourcename + ":项目范围"],
              queryParameter: {
                attributeFilter: " DKBM = '" + bm.value + "'",
              },
              hasGeometry: true,
            };
            let exmfw = await mapQuery(
              Minfo.dataurl + "/featureResults.json?returnContent=true",
              queryBySQLParameters
            );

            if (exmfw && exmfw.totalCount > 0) {
              exmfw.features.forEach((feature) => {
                feature.fieldNames.forEach((fieldName, i) => {
                  if (
                    fieldName == "BASEH" &&
                    Number(feature.fieldValues[i]) > jcgd
                  ) {
                    jcgd = Number(feature.fieldValues[i]);
                  }
                });
              });
            }

            let queryByGeometryParameters = {
              getFeatureMode: "SQL",
              datasetNames: [
                layer.date_server.datasourcename +
                  ":" +
                  layer.date_server.datasetname,
              ],
              queryParameter: {
                attributeFilter: "DKBM = '" + bm.value + "'",
              },
              hasGeometry: "true",
            };
            let e = await mapQuery(
              layer.date_server.url + "/featureResults.json?returnContent=true",
              queryByGeometryParameters
            );

            if (e && e.totalCount > 0) {
              e.features.forEach((feature) => {
                let JZTXlayerData = {
                  id: uuidv4(),
                  layerInfo: layer,
                  data: [],
                  geometry: feature.geometry,
                  // entities: [],
                };
                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) {
                    JZTXlayerData.data.push({
                      label: fieldName,
                      labelCN: Field ? Field.caption : fieldName,
                      value: feature.fieldValues[i],
                    });
                  }
                });
                let ps = [];
                for (
                  let index = 0;
                  index < feature.geometry.points.length;
                  index++
                ) {
                  const element = feature.geometry.points[index];
                  ps.push(element.x);
                  ps.push(element.y);
                  ps.push(0);
                }
                debugger;

                //限高高度
                let xg = 87.4;
                let xgdata = GHYDlayerData.data.find((c) => c.label == "JZXGD");
                if (xgdata && xgdata.value) {
                  xg = Number(xgdata.value);
                }

                //添加建筑退线线
                var orangePolygon1 = viewer.entities.add({
                  id: "JZTXQ-" + JZTXlayerData.id,

                  polygon: {
                    hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights(ps),
                    extrudedHeight: xg + jcgd,
                    perPositionHeight: true,
                    material: Cesium.Color.CHARTREUSE.withAlpha(0.1),
                    outline: true,
                    outlineColor: Cesium.Color.MEDIUMSPRINGGREEN,
                    outlineWidth: 1.0,
                  },
                });
                // JZTXlayerData.entities.push(orangePolygon1);
                that.JZTXlayerDatas.push(JZTXlayerData);
              });
            }
          }
        }
      }
      this.openJZXGInfo(that.layerDataList, that.JZTXlayerDatas, Minfo, DKBM);
    },
    //占压分析
    occupyAnalysis(Minfo) {
      let that = this;
      this.getGuiHuaDiKuai(function () {
        that.getoccupy(Minfo);
      });
    },
    /**
     * 获取用地用海分类统一颜色
     */
    getLandColor(name) {
      var color = "rgb(172,255,207)";
      window.colorList.forEach((element) => {
        if (element.name.indexOf(name) > -1) color = element.color;
      });
      return color;
    },
    /**
     * 获取占压交集
     * @param Minfo
     */
    async getoccupy(Minfo) {
      let that = this;
      if (that.LandPlanningList.length > 0) {
        let layer = flatten(window.layerTree).find(
          (item) => item.core == "002002"
        );
        if (layer && layer.date_server && layer.date_server.url) {
          for (
            let GHYDindex = 0;
            GHYDindex < that.LandPlanningList.length;
            GHYDindex++
          ) {
            const GHYDlayerData = that.LandPlanningList[GHYDindex];
            let queryByGeometryParameters = {
              getFeatureMode: "SPATIAL",
              datasetNames: [
                layer.date_server.datasourcename +
                  ":" +
                  layer.date_server.datasetname,
              ],
              geometry: GHYDlayerData.geometry,
              spatialQueryMode: "INTERSECT",
              hasGeometry: "true",
            };
            let e = await mapQuery(
              layer.date_server.url + "/featureResults.json?returnContent=true",
              queryByGeometryParameters
            );
            if (e && e.totalCount > 0) {
              e.features.forEach((feature) => {
                let DLTBlayerData = {
                  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) {
                    DLTBlayerData.data.push({
                      label: fieldName,
                      labelCN: Field ? Field.caption : fieldName,
                      value: feature.fieldValues[i],
                    });
                  }
                });
                let ps = [];
                for (
                  let index = 0;
                  index < feature.geometry.points.length;
                  index++
                ) {
                  const element = feature.geometry.points[index];
                  ps.push(element.x);
                  ps.push(element.y);
                }
                let DLLX = DLTBlayerData.data.find(
                  (c) => c.label == "DLMC"
                ).value;
                let col = Cesium.Color.fromCssColorString(
                  that.getLandColor(DLLX)
                );

                //添加地类图斑
                var orangePolygon1 = viewer.entities.add({
                  id: "DLTB-" + DLTBlayerData.id,
                  polygon: {
                    hierarchy: Cesium.Cartesian3.fromDegreesArray(ps),
                    // perPositionHeight: true,
                    material: col,
                    outline: true,
                    outlineColor: Cesium.Color.BLACK,
                    outlineWidth: 2.0,
                  },
                });
                const point = viewer.entities.add({
                  id: "DLTBlable-" + DLTBlayerData.id,
                  //点
                  position: Cesium.Cartesian3.fromDegrees(
                    DLTBlayerData.geometry.center.x,
                    DLTBlayerData.geometry.center.y
                  ),
                  label: {
                    text: DLLX, //描述内容
                    fillColor: Cesium.Color.WHITE,
                    font: "40px Calibri",
                    scale: 0.5,
                    fillStyle: Cesium.LabelStyle.FILL,
                    // 垂直位置
                    verticalOrigin: Cesium.VerticalOrigin.BUTTON,
                    // 中心位置
                    pixelOffset: new Cesium.Cartesian2(0, -10),
                    //设置背景颜色透明
                    backgroundColor: new Cesium.Color(0.0, 0.0, 0.0, 0.8),
                    //打开背景  打开背景 （不会被线段覆盖）
                    showBackground: true,
                    heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                    clampToS3M: true,
                  },
                });
                that.DLTBlayerDatas.push(DLTBlayerData);
              });
            }
          }
        }
      }
      this.openDLTBInfo(that.LandPlanningList, that.DLTBlayerDatas, Minfo);
    },

    /**
     * 指标分析
     * @param Minfo
     */
    normAnalysis(info, Minfo) {
      let that = this;
      if (!info.plotnumber) {
        that.$message({
          message: "请现在项目信息中补全项目地块编码",
          type: "warning",
        });
        return;
      }
      this.getGuiHuaDiKuai(function () {
        for (let index = 0; index < that.LandPlanningList.length; index++) {
          const LandPlanning = that.LandPlanningList[index];
          let DKBM = LandPlanning.data.find((c) => c.label == "DKBM")
            ? LandPlanning.data.find((c) => c.label == "DKBM").value
            : "";
          let plotnumbers = info.plotnumber.split(",");
          let isInclude = plotnumbers.some((element) => element.includes(DKBM));
          if (!isInclude || !DKBM) {
            that.$message({
              message: "请选择项目内的地块进行查询",
              type: "warning",
            });
            return;
          }
        }
        that.HighLimit(Minfo);
        that.getnorm(Minfo);
      });
    },

    /**
     * 获取指标
     * @param Minfo
     */
    async getnorm(Minfo) {
      debugger;
      //组装指标对象
      let tableDataList = [];
      for (let index = 0; index < this.LandPlanningList.length; index++) {
        const LandPlanning = this.LandPlanningList[index];
        let KG_Data = {},
          TJFA_Data = {},
          FA_Data = {};
        KG_Data.DKBM = LandPlanning.data.find((c) => c.label == "DKBM")
          ? LandPlanning.data.find((c) => c.label == "DKBM").value
          : "";
        KG_Data.YDMJ = LandPlanning.data.find((c) => c.label == "YDMJ")
          ? LandPlanning.data.find((c) => c.label == "YDMJ").value
          : "";
        KG_Data.JZMJ = LandPlanning.data.find((c) => c.label == "JZMJ")
          ? LandPlanning.data.find((c) => c.label == "JZMJ").value
          : "";
        // KG_Data.JZMJ = "";
        KG_Data.JDMJ = LandPlanning.data.find((c) => c.label == "JDMJ")
          ? LandPlanning.data.find((c) => c.label == "JDMJ").value
          : "";
        // KG_Data.JRJZMJ = LandPlanning.data.find((c) => c.label == "JRJZMJ")
        //   ? LandPlanning.data.find((c) => c.label == "JRJZMJ").value
        //   : "";
        KG_Data.RJLD = LandPlanning.data.find((c) => c.label == "RJLD")
          ? LandPlanning.data.find((c) => c.label == "RJLD").value
          : "";
        KG_Data.RJLX = LandPlanning.data.find((c) => c.label == "RJLX")
          ? LandPlanning.data.find((c) => c.label == "RJLX").value
          : "";
        KG_Data.JZMDD = LandPlanning.data.find((c) => c.label == "JZMDD")
          ? LandPlanning.data.find((c) => c.label == "JZMDD").value
          : "";
        KG_Data.JZMDX = LandPlanning.data.find((c) => c.label == "JZMDX")
          ? LandPlanning.data.find((c) => c.label == "JZMDX").value
          : "";
        KG_Data.JZXGD = LandPlanning.data.find((c) => c.label == "JZXGD")
          ? LandPlanning.data.find((c) => c.label == "JZXGD").value
          : "";
        KG_Data.JZXGX = LandPlanning.data.find((c) => c.label == "JZXGX")
          ? LandPlanning.data.find((c) => c.label == "JZXGX").value
          : "";
        KG_Data.JRJZMJD = "";
        KG_Data.JRJZMJX = "";

        if (Minfo.dataurl && Minfo.datasourcename) {
          //获取项目范围数据数据
          let queryByGeometryParameters = {
            getFeatureMode: "SQL",
            datasetNames: [Minfo.datasourcename + ":项目范围"],
            queryParameter: {
              attributeFilter: "DKBM = '" + KG_Data.DKBM + "'",
            },
            hasGeometry: "true",
          };
          let e = await mapQuery(
            Minfo.dataurl + "/featureResults.json?returnContent=true",
            queryByGeometryParameters
          );

          //项目用地总面积
          let xmzmj = 0;
          if (e && e.totalCount > 0) {
            e.features.forEach((feature) => {
              let DataPs = feature.geometry.points.map((item) => [
                item.x,
                item.y,
              ]);
              if (DataPs.length > 0) {
                if (DataPs[0] != DataPs[DataPs.length - 1]) {
                  DataPs.push(DataPs[0]);
                }
                let polygonPs = polygon([DataPs]);
                let areaPs = area(polygonPs);
                xmzmj += areaPs;
              }
            });
          }
          FA_Data.YDMJ = xmzmj;

          //基底面积查建筑轮廓数据
          FA_Data.JDMJ = 0;

          let queryByGeometryParameters2 = {
            getFeatureMode: "SQL",
            datasetNames: [Minfo.datasourcename + ":" + Minfo.datasetname],
            queryParameter: {
              attributeFilter: "LANDNO = '" + KG_Data.DKBM + "'",
            },
            hasGeometry: "true",
          };
          let e2 = await mapQuery(
            Minfo.dataurl + "/featureResults.json?returnContent=true",
            queryByGeometryParameters2
          );

          //建筑基底总面积
          let jzjdzmj = 0;
          //建筑总面积
          let jzzmj = 0;
          //地上建筑总面积
          let dsjzzmj = 0;
          //地下建筑总面积
          let dxjzzmj = 0;
          //最大建筑高度
          let maxJZGD = 0;
          if (e2 && e2.totalCount > 0) {
            e2.features.forEach((feature) => {
              let BUILDAREAIndex = feature.fieldNames.findIndex(
                (c) => c == "BUILDAREA"
              );
              if (BUILDAREAIndex) {
                let jzmj = feature.fieldValues[BUILDAREAIndex] || 0;
                if (Number(jzmj)) {
                  jzzmj += Number(jzmj);
                }
              }
              let TBUILDAREAIndex = feature.fieldNames.findIndex(
                (c) => c == "TBUILDAREA"
              );
              if (TBUILDAREAIndex) {
                let dsjzmj = feature.fieldValues[TBUILDAREAIndex] || 0;
                if (Number(dsjzmj)) {
                  dsjzzmj += Number(dsjzmj);
                }
              }
              let DBUILDAREAIndex = feature.fieldNames.findIndex(
                (c) => c == "DBUILDAREA"
              );
              if (DBUILDAREAIndex) {
                let dxjzmj = feature.fieldValues[DBUILDAREAIndex] || 0;
                if (Number(dxjzmj)) {
                  dxjzzmj += Number(dxjzmj);
                }
              }
              let HEIGHTIndex = feature.fieldNames.findIndex(
                (c) => c == "HEIGHT"
              );
              if (HEIGHTIndex) {
                let jzgd = feature.fieldValues[HEIGHTIndex] || 0;
                if (Number(jzgd) > maxJZGD) {
                  maxJZGD = Number(jzgd);
                }
              }

              let DataPs = feature.geometry.points.map((item) => [
                item.x,
                item.y,
              ]);
              if (DataPs.length > 0) {
                if (DataPs[0] != DataPs[DataPs.length - 1]) {
                  DataPs.push(DataPs[0]);
                }
                let polygonPs = polygon([DataPs]);
                let areaPs = area(polygonPs);
                jzjdzmj += areaPs;
              }
            });
          }
          FA_Data.JZMJ = Number(jzzmj);
          FA_Data.JZGD = Number(maxJZGD).toFixed(2);
          FA_Data.JDMJ = jzjdzmj;
          //计容建筑面积 为地上建筑总面积
          FA_Data.JRJZMJ = dsjzzmj;
          // 容积率 20240814改为使用建筑面积计算容积率
          // FA_Data.RJL = (FA_Data.JRJZMJ / FA_Data.YDMJ).toFixed(2);
          FA_Data.RJL = (FA_Data.JZMJ / FA_Data.YDMJ).toFixed(2);

          //建筑密度
          FA_Data.JZMD = (Number(FA_Data.JDMJ / FA_Data.YDMJ) * 100).toFixed(2);
        }
        tableDataList.push({ Minfo, KG_Data, FA_Data, TJFA_Data });
      }
      var result = await CheckParkAnalyse.buidAreaAndParksComputer(
        Minfo,
        false
      );
      if (result != null) {
        for (var i = 0; i < tableDataList.length; i++) {
          var item = tableDataList[i];

          var land = result.buildings.find(
            (t) => t.landNo == item.KG_Data.DKBM
          );
          if (land == null) continue;
          tableDataList[i].FA_Data.JZMJ = land.mj;
          tableDataList[i].FA_Data.JRJZMJ = land.jrmj;
          debugger;
          //20240814改为使用建筑面积计算容积率
          // tableDataList[i].FA_Data.RJL = (land.jrmj / item.FA_Data.YDMJ).toFixed(2);
          tableDataList[i].FA_Data.RJL = (
            (land.mj - land.dxjzmj) /
            item.FA_Data.YDMJ
          ).toFixed(2);
          //开发商提交的方案文档指标
          debugger;
          tableDataList[i].TJFA_Data.JZMJ = land.famj;
          tableDataList[i].TJFA_Data.JRJZMJ = land.fajrmj;
          tableDataList[i].infoData = land;
        }
      }
      this.openZBFXInfo([tableDataList]);
    },
    /**
     * 规划情况分析
     */
    async PlanningAnalysis(Minfo) {
      let that = this;
      this.getGuiHuaDiKuai(function () {
        if (that.LandPlanningList.length > 0) {
          ghqk.getPlanning(that.LandPlanningList, Minfo);
        } else {
          that.$message({
            message: "当前位置未找到规划地块，请选择其他位置。",
            type: "warning",
          });
        }
      });
    },
    /**
     * 建筑风貌分析
     */
    async ArchitecturalAnalysis(Minfo) {
      this.openArchitecturaInfo(
        this.layerDataList,
        this.LandPlanningList,
        Minfo
      );
    },
    /**
     * 人视分析
     */
    async RSAnalysis(Minfo) {
      this.openRSInfo();
    },
    /**
     * 车位审查
     */
    async CheckPark(Minfo, isJSPark) {
      var that = this;
      var result = await CheckParkAnalyse.buidAreaAndParksComputer(
        Minfo,
        isJSPark
      );
      // if (that.skylineAnalysislayerid) {
      //   that.$layer.close(that.skylineAnalysislayerid);
      // }
      let w = document.body.offsetWidth;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      var fontSize = document.body.style.fontSize;
      if ((fontSize = "")) fontSize = 14;
      else fontSize = parseInt(fontSize.replace("px", ""));
      let left = w - 400;
      let top = 550 / 2 + 60;
      // that.skylineAnalysislayerid =
      that.$layer.iframe({
        id: "BJTC",
        content: {
          content: parkResult, //传递的组件对象
          parent: that, //当前的vue对象
          data: { info: result }, //props
        },
        offset: [left, top], //left top
        area: ["40rem", "25rem"],
        title: "车位审查结果",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          // alert("关闭iframe");
        },
      });
    },

    /**
     * 楼体拉伸
     */
    BuildingStretchingAnalysis(Minfo) {
      let that = this;

      if (this.handler != null) {
        this.removeAll();
      }

      this.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
      this.handler.setInputAction((evt) => {
        that.tooltip.showAt(
          evt.endPosition,
          `<p>点击地图，选择要分析的楼体,右键取消</p>`
        );
      }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
      this.handler.setInputAction((evt) => {
        that.removeEventHandler();
      }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
      this.handler.setInputAction(async function (movement) {
        that.tooltip.setVisible(false);
        //拾取图层
        let pick = scene.pickPosition(movement.position);

        let xyz = cartesian3ToWGS84(pick);

        let layerDataList = that.layerDataList;
        let w = document.body.offsetWidth;
        let h = document.body.offsetHeight;
        //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
        //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
        let left = w - 430 + 430 / 2;
        let top = 430 / 2 + 60;
        that.$layer.iframe({
          id: "BJTC",
          content: {
            content: BuildingStretchingAnalysis, //传递的组件对象
            parent: that, //当前的vue对象
            data: { info: { Minfo, layerDataList, xyz } }, //props
          },
          offset: [left, top], //left top
          area: ["430px", "430px"], //宽 高
          title: "楼体拉伸",
          maxmin: false,
          shade: false, //是否显示遮罩
          shadeClose: false, //点击遮罩是否关闭
          cancel: () => {
            //关闭事件
          },
        });

        that.removeEventHandler();
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
    },
    // 删除限高
    removeHighLimit() {
      viewer.entities.removeById("polygonA");
      // viewer.entities.removeById("JZXGD-A");
      var BoxIndex = popupBoxs.findIndex((c) => c.element.id == "JZXGD-A");
      if (BoxIndex > -1) {
        popupBoxs[BoxIndex].destroy();
        popupBoxs.splice(BoxIndex, 1);
      }

      this.layerList.forEach((layerName) => {
        var hyp = new Cesium.HypsometricSetting();
        hyp.MaxVisibleValue = -1000;
        let layer = scene.layers.find(layerName);
        layer.hypsometricSetting = {
          hypsometricSetting: hyp,
          analysisMode:
            Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_ALL,
        };
      });

      for (let index = popupBoxs.length - 1; index >= 0; index--) {
        const popupBox = popupBoxs[index];
        if (popupBox.element.id.includes("JZXG-")) {
          popupBox.destroy();
          popupBoxs.splice(index, 1);
        }
      }
    },
    //取消左键事件
    removeEventHandler() {
      if (this.handler) {
        this.tooltip.setVisible(false);
        this.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
        this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
        this.handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
        this.handler.destroy();
        this.handler = null;
      }
    },

    //删除规划地块
    removeLandPlanningList() {
      for (let index = 0; index < this.LandPlanningList.length; index++) {
        const element = this.LandPlanningList[index];

        viewer.entities.removeById("ydhxp-" + element.id);
        viewer.entities.removeById("ydhxl-" + element.id);
      }
      this.LandPlanningList = [];
    },
    //删除道路线
    removeDLlayerDatasList() {
      for (let index = 0; index < this.DLlayerDatas.length; index++) {
        const element = this.DLlayerDatas[index];
        element.entities.forEach((entitie) => {
          viewer.entities.removeById(entitie);
        });
      }
      this.DLlayerDatas = [];
    },
    //删除建筑退线
    removeJZTXlayerDatas() {
      for (let index = 0; index < this.JZTXlayerDatas.length; index++) {
        const element = this.JZTXlayerDatas[index];

        viewer.entities.removeById("JZTXQ-" + element.id);
      }
      this.JZTXlayerDatas = [];
    },
    //删除地类图斑
    removeDLTBlayerDatas() {
      for (let index = 0; index < this.DLTBlayerDatas.length; index++) {
        const element = this.DLTBlayerDatas[index];
        viewer.entities.removeById("DLTB-" + element.id);
        viewer.entities.removeById("DLTBlable-" + element.id);
      }
      this.DLTBlayerDatas = [];
    },
    /**
     * 点查图层信息
     */
    initEntitiesHandler() {
      let that = this;
      this.getEntitiesHandler = new Cesium.ScreenSpaceEventHandler(
        scene.canvas
      );
      this.getEntitiesHandler.setInputAction(function (click) {
        var pick = viewer.scene.pick(click.position);
        //用地红线信息弹窗
        if (pick && pick.id.id && pick.id.id.indexOf("ydhxp") !== -1) {
          let id = pick.id.id.split("ydhxp-")[1];
          let info = that.LandPlanningList.find((c) => c.id == id);
          that.openOBJInfo("用地红线详情", info.data);
        }
        if (pick && pick.id.id && pick.id.id.indexOf("ydhxl") !== -1) {
          let id = pick.id.id.split("ydhxl-")[1];
          let info = that.LandPlanningList.find((c) => c.id == id);
          that.openOBJInfo("用地红线详情", info.data);
        }
        //道路信息弹窗
        if (pick && pick.id.id && pick.id.id.indexOf("DLX-") !== -1) {
          let id = pick.id.id.split("DLX-")[1];
          let info = that.DLlayerDatas.find((c) => c.id == id);
          that.openOBJInfo("道路信息详情", info.data);
        }
        //图斑地类弹窗
        if (pick && pick.id.id && pick.id.id.indexOf("DLTB-") !== -1) {
          let id = pick.id.id.split("DLTB-")[1];
          let info = that.DLTBlayerDatas.find((c) => c.id == id);
          that.openOBJInfo("地类信息详情", info.data);
        }
        //城镇开发边界弹窗
        if (pick && pick.id.id && pick.id.id.indexOf("CZKFBJ-") !== -1) {
          let id = pick.id.id.split("CZKFBJ-")[1];
          let info = ghqk.CZKFBJDatas.find((c) => c.id == id);
          that.openOBJInfo("城镇开发边界信息详情", info.data);
        }
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
    },
    //打开用地红线信息弹窗
    openOBJInfo(title, info) {
      if (this.OBJInfolayerid) {
        this.$layer.close(this.OBJInfolayerid);
      }
      let w = document.body.offsetWidth;
      let h = document.body.offsetHeight;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      let left = 430 / 2 + 556;
      let top = 430 / 2 + 60;
      this.OBJInfolayerid = this.$layer.iframe({
        content: {
          content: PlanningPlotInfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "430px"], //宽 高
        title: title,
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          // alert("关闭iframe");
        },
      });
    },

    /**
     * //打开限高分析信息弹窗
     * @param layerDataList 楼层信息
     * @param JZXGD 限高值
     * @param DKBM [] 要分析的地块编码
     */
    openXGFXInfo(layerDataList, JZXGD, DKBM) {
      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 - 430 + 430 / 2;
      let top = 430 / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: HighLimitAnalysis, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info: { layerDataList, JZXGD, DKBM } }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "430px"], //宽 高
        title: "限高分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          this.removeLandPlanningList();
          this.removeHighLimit();
        },
      });
    },
    /**
     * //打开退线分析信息弹窗
     * @param layerDataList 楼层信息
     * @param JZTXlayerDatas 退线信息
     * @param DKBM 地块编码
     */
    openJZXGInfo(layerDataList, JZTXlayerDataList, Minfo, DKBM) {
      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 - 430 + 430 / 2;
      let top = 430 / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: backLineAnalysisinfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: {
            info: { layerDataList, JZTXlayerDataList, Minfo, DKBM },
          }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "430px"], //宽 高
        title: "控规分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          this.removeLandPlanningList();
          this.removeJZTXlayerDatas();
          this.removeDLlayerDatasList();
        },
      });
    },

    /**
     * //打开地类图斑分析信息弹窗
     * @param LandPlanningList 规划地块数组
     * @param DLTBlayerDataList 地类图斑信息
     */
    openDLTBInfo(LandPlanningList, DLTBlayerDataList, Minfo) {
      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 - 430 + 430 / 2;
      let top = 430 / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: ZYAnalysisinfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: {
            info: { LandPlanningList, DLTBlayerDataList, Minfo },
          }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "430px"], //宽 高
        title: "占压分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          this.removeLandPlanningList();
          this.removeDLTBlayerDatas();
        },
      });
    },
    /**
     * //打开指标分析信息弹窗
     * @param tableDataList 控规指标和项目指标
     */
    openZBFXInfo(tableDataList) {
      // if (this.ZBFXInfolayerid) {
      //   this.$layer.close(this.ZBFXInfolayerid);
      // }
      let that = this;
      let wpx = 650;
      let hpx = 430;
      let w = document.body.offsetWidth;
      let h = document.body.offsetHeight;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      let left = w - wpx + wpx / 2;
      let top = hpx / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: ZBFXAnalysisinfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: {
            info: { tableDataList },
          }, //props
        },
        offset: [left, top], //left top
        area: [wpx + "px", hpx + "px"], //宽 高
        title: "指标分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //关闭事件
          //指标分析数据
          this.removeLandPlanningList();
          //限高分析数据
          this.removeHighLimit();
        },
      });
    },
    /**
     * //打开模型对比弹窗
     */
    openMXDBInfo() {
      let that = this;
      let modelsloadData = that.modelsload.map((item) => {
        return {
          id: item.id,
          Minfo: item.Minfo,
          layerDataList: item.layerDataList,
        };
      });
      //弹窗最小化
      this.$layer.min(this.layerid);
      if (this.MXDBInfolayerid) {
        this.$layer.close(this.MXDBInfolayerid);
      }
      let w = document.body.offsetWidth;
      let h = document.body.offsetHeight;
      //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
      //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
      let left = 430 / 2;
      let top = 100 / 2 + 60;
      this.MXDBInfolayerid = this.$layer.iframe({
        content: {
          content: MXDBinfo, //传递的组件对象
          parent: this, //当前的vue对象
          data: {
            info: { modelsloadData },
          }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "100px"], //宽 高
        title: "模型对比",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {
          //还原弹窗
          this.$layer.full(that.layerid);
          //关闭事件
          this.DestroyAll();
          this.WaitingSelectionModel = null;
        },
      });
    },
    /**
     * //打开建筑风貌弹窗
     */
    openArchitecturaInfo(layerDataList, LandPlanningList, Minfo) {
      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 - 430 + 430 / 2;
      let top = 430 / 2 + 60;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: ArchitecturaAnalysis, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info: { Minfo, layerDataList, LandPlanningList } }, //props
        },
        offset: [left, top], //left top
        area: ["430px", "430px"], //宽 高
        title: "建筑风貌分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {},
      });
    },
    /**
     * //打开人视弹窗
     */
    openRSInfo() {
      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 - 430 + 430 / 2;
      let top = 100 / 2 + 300;
      this.$layer.iframe({
        id: "BJTC",
        content: {
          content: RSAnalysis, //传递的组件对象
          parent: this, //当前的vue对象
          data: { info: {} }, //props
        },
        offset: [left, top], //left top
        area: ["20rem", "35rem"], //宽 高
        title: "人视分析",
        maxmin: false,
        shade: false, //是否显示遮罩
        shadeClose: false, //点击遮罩是否关闭
        cancel: () => {},
      });
    },

    /**
     * 压平
     * @param Minfos 模型信息
     */
    async yp(Minfos) {
      for (let index = 0; index < Minfos.length; index++) {
        const Minfo = Minfos[index];

        //获取模型信息
        let queryBySQLParameters = {
          getFeatureMode: "SQL",
          datasetNames: [Minfo.datasourcename + ":项目范围"],
          queryParameter: {
            attributeFilter: "1=1",
          },
          hasGeometry: true,
        };
        let e = await mapQuery(
          Minfo.dataurl + "/featureResults.json?returnContent=true",
          queryBySQLParameters
        );

        if (e && e.totalCount > 0) {
          e.features.forEach((element) => {
            let flatPoints = element.geometry.points
              .map((item) => [item.x, item.y, 6.5])
              .flat();
            viewer.scene.layers.layerQueue.forEach((layer) => {
              let name = "flatten" + Math.random();
              let istrue = layer.addFlattenRegion({
                position: flatPoints,
                name: name,
              });
            });
          });
        }
      }
    },
    qxyp() {
      viewer.scene.layers.layerQueue.forEach((layer) => {
        layer.removeAllFlattenRegion();
      });
    },

    removeAll() {
      this.removeEventHandler();
      this.removeLandPlanningList();
      this.removeHighLimit();
      this.removeDLlayerDatasList();
      this.removeJZTXlayerDatas();
      this.removeDLTBlayerDatas();
      ghqk.removeAll();
      this.$layer.close("BJTC");
    },
    DestroyAll() {
      scene.multiViewportMode = Cesium.MultiViewportMode.NONE;
      this.qxyp();
      if (this.getEntitiesHandler) {
        this.getEntitiesHandler.removeInputAction(
          Cesium.ScreenSpaceEventType.LEFT_CLICK
        );
      }
      this.removeAll();
      this.removeModel();

      undergroundMode(false);
    },
  },

  beforeDestroy() {
    this.DestroyAll();
  },
};
</script>

<style lang="scss">
@import "@/../../zt.scss";
</style>
<style lang="scss" scoped>
.card_body_style {
  border: 1px dashed #02a7f0;
}

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

.checkedState {
  position: relative;

  .status {
    position: absolute;
    right: 0;
    top: 0;
    // z-index: 2;
    overflow: hidden;
    // border-radius: 6px;
  }

  .icon {
    position: absolute;
    right: 0;
    top: 0;
    width: 4rem;
    height: 4rem;
    border: 8px;
    background: #ffff80;
    -webkit-clip-path: polygon(100% 0, 0 0, 100% 100%);
    clip-path: polygon(100% 0, 0 0, 100% 100%);
  }

  .txts {
    line-height: 2.6rem;
    text-align: center;
    transform: rotate(45deg);
    transform-origin: center center;
    color: #ec808c;
    // font-size: 18px;
  }

  /* 带圆角的话这个status 和 txts的宽度/宽度 是要比icon的宽度/高度小的,效果可以自己慢慢调 */
  .ce {
    width: 4rem;
    height: 4rem;
  }
}

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