无人机管理后台前端(已迁走)
张含笑
2025-07-01 26ef5d236a8d69c89faf9ef4a3cb1b4d8aee709f
feat:正射调整角度
2 files modified
674 ■■■■ changed files
src/views/dataCenter/components/dataCenterMap.vue 21 ●●●●● patch | view | raw | blame | history
src/views/dataCenter/dataCenter.vue 653 ●●●●● patch | view | raw | blame | history
src/views/dataCenter/components/dataCenterMap.vue
@@ -111,13 +111,11 @@
  restoreAllIcons();
  if (currentClickEntity.billboard) {
    const status = currentClickEntity?.properties?._customData?._value?.data.status;
    console.log('stayus', currentClickEntity?.properties?._customData?._value?.data);
    currentClickEntity.billboard.image =
      status === 1 || status === null ? activeIcon : getEventActiveImage(status);
    currentClickEntity.billboard.scale = 1; // 可选缩放效果
    activeEntity.value = currentClickEntity;
  }
  removeLabel();
  viewer.scene.postRender.addEventListener(labelBoxUpdate);
};
@@ -128,7 +126,6 @@
  handler = new Cesium.ScreenSpaceEventHandler(viewer?.scene.canvas);
  handler.setInputAction(singleMachineEvent, Cesium.ScreenSpaceEventType.LEFT_CLICK);
};
// 清除所有数据点实体
const clearDataPoints = () => {
  if (!viewer) return;
@@ -138,7 +135,6 @@
  dataPointEntities.value = [];
  activeEntity.value = null;
};
const removeHandler = () => {
  handler?.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
  handler?.destroy();
@@ -147,11 +143,7 @@
const renderDataPoint = mapList => {
  if (!viewer || !mapList?.length) return;
  // 清除旧实体
  clearDataPoints();
  // 添加新实体
  mapList.forEach((item, index) => {
    const entity = viewer?.entities.add({
      id: `dataCenter-point-${index}-${Date.now()}`,
@@ -210,12 +202,9 @@
    viewerRef.value = viewer;
    isViewerReady.value = true;
    // 初始化事件处理器
    handlerInit();
    isMapInitialized.value = true;
    console.log('地图初始化完成');
    // 初始化后立即渲染已有数据
    if (dataPointList.value.length > 0) {
      renderDataPoint(dataPointList.value);
    }
@@ -243,9 +232,7 @@
  try {
    const res = await getMapInfoAPI(ids);
    dataPointList.value = res.data.data || [];
    console.log('dataPointList.value', dataPointList.value);
    // 确保地图已初始化后再渲染
    if (isMapInitialized.value && viewer) {
      renderDataPoint(dataPointList.value);
    }
@@ -255,13 +242,7 @@
};
const isViewerReady = ref(false);
/**
 * 初始化标注添加
 * @param data 数据
 */
const initEntityOrPopup = data => {
  console.log('data', data);
  //地图点在范围内
  watch(
    () => isMapInitialized.value,
src/views/dataCenter/dataCenter.vue
@@ -1,12 +1,23 @@
<template>
  <div
    class="manage-m-all-10 manage-m-t-0 manage-p-all-20 manage-h-0 manage-flex-1 manage-flex manage-f-d-c manage-b-r-5 manage-b-c-w">
    class="manage-m-all-10 manage-m-t-0 manage-p-all-20 manage-h-0 manage-flex-1 manage-flex manage-f-d-c manage-b-r-5 manage-b-c-w"
  >
    <div class="dataCenter-table">
      <searchData @search="searchClick" @downFun="downloadFile" @allDownFun="aLLDownloadFile"></searchData>
      <searchData
        @search="searchClick"
        @downFun="downloadFile"
        @allDownFun="aLLDownloadFile"
      ></searchData>
      <!-- 表格部分 -->
      <div class="dataTable">
        <el-table v-loading="loadings" element-loading-text="加载中" stripe :data="tableData" class="custom-header"
          @selection-change="handleSelectionChange">
        <el-table
          v-loading="loadings"
          element-loading-text="加载中"
          stripe
          :data="tableData"
          class="custom-header"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" />
          <el-table-column label="序号" type="index" width="60">
            <template #default="{ $index }">
@@ -25,25 +36,45 @@
          <el-table-column property="nestName" label="所属机巢" />
          <el-table-column property="jobName" label="任务名称" show-overflow-tooltip />
          <el-table-column prop="nickName" label="文件名称" show-overflow-tooltip />
          <el-table-column property="link" label="缩图" width="120">
          <el-table-column property="link" label="缩略图" width="120">
            <template #default="scope">
              <img class="quanjing" @click="clickpanorama(scope.row)" v-if="scope.row?.resultType === 5"
                :src="scope.row?.smallUrl" alt="" />
              <img v-else-if="scope.row?.resultType === 1" :src="convertVideoUrlToThumbnail(scope.row?.link)" alt=""
                class="imageBox" @click="enterFullScreen(scope.row)" />
              <img
                class="quanjing"
                @click="clickpanorama(scope.row)"
                v-if="scope.row?.resultType === 5"
                :src="scope.row?.smallUrl"
                alt=""
              />
              <img
                v-else-if="scope.row?.resultType === 1"
                :src="convertVideoUrlToThumbnail(scope.row?.link)"
                alt=""
                class="imageBox"
                @click="enterFullScreen(scope.row)"
              />
              <!-- 正射 -->
              <!-- <img v-else-if="scope.row?.resultType === 4" :src="getzsSmallImg(scope.row?.link)" alt=""
                class="imageBox" /> -->
                  <el-image v-else-if="scope.row?.resultType === 4" :src="getzsSmallImg(scope.row?.link)" :preview-src-list="[getzsSmallImg(scope.row?.link)]" fit="cover"
                preview-teleported />
              <el-image v-else :src="scope.row?.smallUrl" :preview-src-list="[scope.row?.showUrl]" fit="cover"
                preview-teleported />
              <el-image
                v-else-if="scope.row?.resultType === 4"
                :src="getzsSmallImg(scope.row?.link)"
                :preview-src-list="[getzsSmallImg(scope.row?.link)]"
                fit="cover"
                preview-teleported
              />
              <el-image
                v-else
                :src="scope.row?.smallUrl"
                :preview-src-list="[scope.row?.showUrl]"
                fit="cover"
                preview-teleported
              />
            </template>
          </el-table-column>
          <el-table-column prop="jobTime" label="任务时间" />
          <el-table-column property="photoType" label="文件类别">
            <template #default="scope">
              <span>{{ photoTypeMap[scope.row.photoType] ? photoTypeMap[scope.row.photoType]:'tif' }}</span>
              <span>{{
                photoTypeMap[scope.row.photoType] ? photoTypeMap[scope.row.photoType] : 'tif'
              }}</span>
            </template>
          </el-table-column>
          <el-table-column property="resultType" label="文件格式">
@@ -54,21 +85,44 @@
          <el-table-column label="操作" width="150" align="center">
            <template #default="scope">
              <span class="look" @click="lookDetail(scope.row)">查看</span>
              <span class="delete" @click="deleteDetail(scope.row)" v-if="scope.row.resultType !== 2">删除</span>
              <span
                class="delete"
                @click="deleteDetail(scope.row)"
                v-if="scope.row.resultType !== 2"
                >删除</span
              >
              <span class="location" @click="positionDetail(scope.row)" v-if="shouldShowLocation(scope.row)">定位</span>
              <span
                class="location"
                @click="positionDetail(scope.row)"
                v-if="shouldShowLocation(scope.row)"
                >定位</span
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 分页 -->
      <div class="pagination">
        <el-pagination v-model:current-page="jobListParams.current" v-model:page-size="jobListParams.size"
          :page-sizes="[10, 20, 30, 40]" background layout="total, sizes, prev, pager, next, jumper" :total="total"
          @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        <el-pagination
          v-model:current-page="jobListParams.current"
          v-model:page-size="jobListParams.size"
          :page-sizes="[10, 20, 30, 40]"
          background
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
      <!-- 查看弹框 -->
    <el-dialog v-model="dialogVisible" width="60%" append-to-body @close="dialogClose" align-center>
      <el-dialog
        v-model="dialogVisible"
        width="60%"
        append-to-body
        @close="dialogClose"
        align-center
      >
        <template #header="{ titleId, titleClass }">
          <div class="my-header">
            <!-- <h4 :id="titleId" :class="titleClass">{{ detailTitle }}</h4> -->
@@ -81,7 +135,7 @@
            <video
              v-if="dialogDetailList?.resultType === 1"
              style="width: 100%"
             class="videoItem"
              class="videoItem"
              ref="videoRefs"
              controls
              autoplay
@@ -109,12 +163,10 @@
                  class="title-input"
                  clearable
                />
                 <span class="editname" @click="editTitle(dialogDetailList)"
                  ><el-icon>
                    <Edit /> </el-icon
                <span class="editname" @click="editTitle(dialogDetailList)"
                  ><el-icon> <Edit /> </el-icon
                ></span>
              </div>
            </div>
            <div>任务名称:{{ dialogDetailList?.jobName ? dialogDetailList?.jobName : '--' }}</div>
            <div>
@@ -123,7 +175,7 @@
            <div>
              拍摄机巢:{{ dialogDetailList?.nestName ? dialogDetailList?.nestName : '--' }}
            </div>
            <div>
            <div v-if="dialogDetailList?.resultType != 4">
              照片位置:{{ _.round(dialogDetailList?.longitude, 3) }},{{
                _.round(dialogDetailList?.latitude, 3)
              }}
@@ -147,7 +199,7 @@
              }}
            </div>
            <div>
              照片文件大小:{{
              文件大小:{{
                bytesToMB(dialogDetailList?.attachSize)
                  ? bytesToMB(dialogDetailList?.attachSize)
                  : '--'
@@ -166,47 +218,68 @@
        </div>
      </el-dialog>
      <!-- 全景预览 -->
      <PanoramaPopup v-model:panoramaParamsShow="panoramaParamsShow" v-model:panoramaParamsUrl="panoramaParamsUrl">
      <PanoramaPopup
        v-model:panoramaParamsShow="panoramaParamsShow"
        v-model:panoramaParamsUrl="panoramaParamsUrl"
      >
      </PanoramaPopup>
      <!-- 视频预览 -->
      <el-dialog :title="currentVideoTitle" modal-class="videoDialog" append-to-body width="54%" v-model="VideoShow"
        :close-on-click-modal="false" :destroy-on-close="true" @close="currentVideoIndex = -1">
      <el-dialog
        :title="currentVideoTitle"
        modal-class="videoDialog"
        append-to-body
        width="54%"
        v-model="VideoShow"
        :close-on-click-modal="false"
        :destroy-on-close="true"
        @close="currentVideoIndex = -1"
      >
        <div class="video-container">
          <video style="width: 100%" class="videoBox" ref="videoRefs" controls autoplay :src="currentVideoUrl"></video>
          <video
            style="width: 100%"
            class="videoBox"
            ref="videoRefs"
            controls
            autoplay
            :src="currentVideoUrl"
          ></video>
        </div>
      </el-dialog>
      <!-- 地图弹框 -->
      <dataCenterMap ref="mapComponent" v-model:show="dataCenterMapVisible" :jobId="jobId" @lookDetail="lookDetail"
        :dotData="mapList"></dataCenterMap>
      <dataCenterMap
        ref="mapComponent"
        v-model:show="dataCenterMapVisible"
        :jobId="jobId"
        @lookDetail="lookDetail"
        :dotData="mapList"
      ></dataCenterMap>
    </div>
  </div>
</template>
<script setup>
import { useStore } from 'vuex'
import { PublicCesium } from '@/utils/cesium/publicCesium'
import { Cartesian3 } from 'cesium'
import * as Cesium from 'cesium'
import EventPopUpBox from '@/hooks/components/EventPopUpBox.vue'
import { nextTick, render } from 'vue'
import defaultIcon from '@/assets/images/dataCenter/datamap/eventCompleted.png'
const userInfo = computed(() => store.getters.userInfo)
const isShow = defineModel('show')
const viewerRef = shallowRef(null)
let viewer = null
const viewInstance = shallowRef(null)
const store = useStore()
const currentAreaPosition = ref({ height: 1987280, latitude: 27.636112, longitude: 115.732975 })
let handler = null
import EventBus from '@/utils/eventBus'
import dataCenterMap from '@/views/dataCenter/components/dataCenterMap.vue'
import PanoramaPopup from '@/components/PanoramaPopup/PanoramaPopup.vue' //全景
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus'
import searchData from '@/views/dataCenter/components/searchData.vue'
import fy1 from '@/assets/images/dataCenter/1.jpeg'
import _ from 'lodash'
import { useStore } from 'vuex';
import { PublicCesium } from '@/utils/cesium/publicCesium';
import { Cartesian3 } from 'cesium';
import * as Cesium from 'cesium';
import EventPopUpBox from '@/hooks/components/EventPopUpBox.vue';
import { nextTick, render } from 'vue';
import defaultIcon from '@/assets/images/dataCenter/datamap/eventCompleted.png';
const userInfo = computed(() => store.getters.userInfo);
const isShow = defineModel('show');
const viewerRef = shallowRef(null);
let viewer = null;
const viewInstance = shallowRef(null);
const store = useStore();
const currentAreaPosition = ref({ height: 1987280, latitude: 27.636112, longitude: 115.732975 });
let handler = null;
import EventBus from '@/utils/eventBus';
import dataCenterMap from '@/views/dataCenter/components/dataCenterMap.vue';
import PanoramaPopup from '@/components/PanoramaPopup/PanoramaPopup.vue'; //全景
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus';
import searchData from '@/views/dataCenter/components/searchData.vue';
import fy1 from '@/assets/images/dataCenter/1.jpeg';
import _ from 'lodash';
import {
  getaiImagesPageAPI,
  getAttachInfoAPI,
@@ -214,24 +287,24 @@
  downloadApi,
  updataTitleApi,
  getOrthoimageInfo,
} from '@/api/dataCenter/dataCenter'
import { getShowImg, getSmallImg, getzsSmallImg } from '@/utils/util'
import { onMounted, watch } from 'vue'
import dayjs from 'dayjs'
} from '@/api/dataCenter/dataCenter';
import { getShowImg, getSmallImg, getzsSmallImg } from '@/utils/util';
import { onMounted, watch } from 'vue';
import dayjs from 'dayjs';
function bytesToMB (bytes, decimalPlaces = 2) {
  if (typeof bytes !== 'number' || bytes < 0) return '0'
  return (bytes / 1048576).toFixed(decimalPlaces) + ' MB'
function bytesToMB(bytes, decimalPlaces = 2) {
  if (typeof bytes !== 'number' || bytes < 0) return '0';
  return (bytes / 1048576).toFixed(decimalPlaces) + ' MB';
}
// 视频一帧
function convertVideoUrlToThumbnail (videoUrl) {
function convertVideoUrlToThumbnail(videoUrl) {
  // 检查是否是有效的视频URL
  if (!videoUrl || typeof videoUrl !== 'string') {
    return videoUrl
    return videoUrl;
  }
  // 替换文件扩展名
  const thumbnailUrl = videoUrl.replace(/\.mp4$/, '_small.jpg')
  return thumbnailUrl
  const thumbnailUrl = videoUrl.replace(/\.mp4$/, '_small.jpg');
  return thumbnailUrl;
}
const resultTypeMap = {
  0: '照片',
@@ -239,84 +312,84 @@
  2: 'AI识别',
  5: '全景',
  4: '正射',
}
};
const photoTypeMap = {
  visible: '可见光',
  ir: '红外',
}
};
// 判断省市区
const areaCode = userInfo.value?.detail?.areaCode || ''
const areaCode = userInfo.value?.detail?.areaCode || '';
// 判断账号级别
const isProvinceLevel = computed(() => areaCode.endsWith('00000000')) // 省级:后8位为0
const isCityLevel = computed(() => !isProvinceLevel.value && areaCode.endsWith('000000')) // 市级:后6位为0
const isDistrictLevel = computed(() => !isProvinceLevel.value && !isCityLevel.value) // 区县级
const isProvinceLevel = computed(() => areaCode.endsWith('00000000')); // 省级:后8位为0
const isCityLevel = computed(() => !isProvinceLevel.value && areaCode.endsWith('000000')); // 市级:后6位为0
const isDistrictLevel = computed(() => !isProvinceLevel.value && !isCityLevel.value); // 区县级
// 处理区域名称的函数
function processAddress (str) {
  if (!str) return ''
  const parts = str.split(',')
function processAddress(str) {
  if (!str) return '';
  const parts = str.split(',');
  // 省级账号:显示市和区(去除省级)
  if (isProvinceLevel.value) {
    return parts.filter(part => !part.endsWith('省')).join(',')
    return parts.filter(part => !part.endsWith('省')).join(',');
  }
  // 市级账号:只显示区(去除省和市)
  if (isCityLevel.value) {
    return parts.filter(part => !part.endsWith('省') && !part.endsWith('市')).join(',')
    return parts.filter(part => !part.endsWith('省') && !part.endsWith('市')).join(',');
  }
  // 区县级账号:不显示区域信息(在模板中已隐藏该列)
  return ''
  return '';
}
const showRegionColumn = computed(() => {
  // 是否显示列
  return tableData.value.some(row => {
    const processed = processAddress(row.regionName || '')
    return processed !== ''
  })
})
const loadings = ref(true)
let loading
const total = ref(0)
const startTime = dayjs().subtract(6, 'day').startOf('day')
const endTime = dayjs().endOf('day')
const timeRange = [startTime.format('YYYY-MM-DD HH:mm:ss'), endTime.format('YYYY-MM-DD HH:mm:ss')]
    const processed = processAddress(row.regionName || '');
    return processed !== '';
  });
});
const loadings = ref(true);
let loading;
const total = ref(0);
const startTime = dayjs().subtract(6, 'day').startOf('day');
const endTime = dayjs().endOf('day');
const timeRange = [startTime.format('YYYY-MM-DD HH:mm:ss'), endTime.format('YYYY-MM-DD HH:mm:ss')];
// 全景预览
const panoramaParamsShow = ref(false)
const panoramaParamsUrl = ref(null)
const panoramaParamsShow = ref(false);
const panoramaParamsUrl = ref(null);
const clickpanorama = val => {
  panoramaParamsShow.value = true
  panoramaParamsUrl.value = val.link
}
  panoramaParamsShow.value = true;
  panoramaParamsUrl.value = val.link;
};
// 视频
const currentVideoTitle = ref('')
const VideoShow = ref(false)
const currentVideoUrl = ref(null)
const currentVideoTitle = ref('');
const VideoShow = ref(false);
const currentVideoUrl = ref(null);
const enterFullScreen = val => {
  currentVideoTitle.value = val?.nickName
  currentVideoUrl.value = val?.link
  VideoShow.value = true
}
  currentVideoTitle.value = val?.nickName;
  currentVideoUrl.value = val?.link;
  VideoShow.value = true;
};
const jobListParams = reactive({
  current: 1,
  size: 10,
  orderByCreateTime: true,
  searchParams: { startTime: timeRange[0], endTime: timeRange[1] },
})
const tableData = ref([])
});
const tableData = ref([]);
// 获取列表数据
const getaiImagesPage = () => {
  loadings.value = true
  loadings.value = true;
  const params = {
    orderByCreateTime: jobListParams.orderByCreateTime,
    ...jobListParams.searchParams,
  }
  };
  getaiImagesPageAPI(params, {
    current: jobListParams.current,
    size: jobListParams.size
    size: jobListParams.size,
  })
    .then(res => {
      total.value = res.data.data.total
      total.value = res.data.data.total;
      tableData.value = res.data.data.records.map(i => ({
        ...i,
        checked: false,
@@ -324,41 +397,41 @@
        smallUrl: getSmallImg(i?.link),
        showUrl: getShowImg(i?.link),
        file_name: i.name.split('/').pop(),
      }))
      }));
    })
    .catch(error => {
      // 可选:这里可以添加错误处理逻辑
      console.error("获取数据失败:", error)
      console.error('获取数据失败:', error);
    })
    .finally(() => {
      loadings.value = false // 无论成功失败都会执行
    })
}
      loadings.value = false; // 无论成功失败都会执行
    });
};
// 查询
const searchClick = params => {
  jobListParams.current = 1
  jobListParams.size = 10
  jobListParams.searchParams = params
  getaiImagesPage()
}
  jobListParams.current = 1;
  jobListParams.size = 10;
  jobListParams.searchParams = params;
  getaiImagesPage();
};
const handleSizeChange = val => {
  jobListParams.size = val
  getaiImagesPage()
}
  jobListParams.size = val;
  getaiImagesPage();
};
const handleCurrentChange = val => {
  jobListParams.current = val
  getaiImagesPage()
}
  jobListParams.current = val;
  getaiImagesPage();
};
// 多选
const selectedRows = ref([])
const selectedRows = ref([]);
const handleSelectionChange = val => {
  // 更新选中状态
  tableData.value.forEach(item => {
    item.checked = val.some(selected => selected.id === item.id)
  })
    item.checked = val.some(selected => selected.id === item.id);
  });
  selectedRows.value = val
}
  selectedRows.value = val;
};
// 删除
const deleteDetail = val => {
  ElMessageBox.confirm('您确定删除吗?', '提示', {
@@ -369,36 +442,36 @@
    .then(() => {
      deleteFileMultipleApi(val.id)
        .then(res => {
          ElMessage.success('删除成功')
          getaiImagesPage()
          ElMessage.success('删除成功');
          getaiImagesPage();
        })
        .catch(error => {
          ElMessage.error('删除失败')
        })
          ElMessage.error('删除失败');
        });
    })
    .catch(() => { })
}
    .catch(() => {});
};
// url下载
function aLinkDownload (url, name) {
  const a = document.createElement('a')
  a.style.display = 'none'
  a.href = url
  a.download = name
  document.body.appendChild(a)
  a.click()
  document.body.removeChild(a)
function aLinkDownload(url, name) {
  const a = document.createElement('a');
  a.style.display = 'none';
  a.href = url;
  a.download = name;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
}
const fileDownload = () => {
  const list = selectedRows.value.filter(i => i.checked)
  if (!list?.length) return ElMessage.warning('请选择文件')
  const list = selectedRows.value.filter(i => i.checked);
  if (!list?.length) return ElMessage.warning('请选择文件');
  if (list.length === 1) {
    list.forEach((item, index) => {
      const suffix = item.url.split('.').pop()
      aLinkDownload(item.url, item.nickName + '.' + suffix)
    })
      const suffix = item.url.split('.').pop();
      aLinkDownload(item.url, item.nickName + '.' + suffix);
    });
  } else {
    loading = ElLoading.service({ background: 'rgba(0, 0, 0, 0.5)', text: '打包中,请稍等...' })
    const fileIds = list.map(i => i.id)
    loading = ElLoading.service({ background: 'rgba(0, 0, 0, 0.5)', text: '打包中,请稍等...' });
    const fileIds = list.map(i => i.id);
    let aaa = {
      areaCode: '',
      attachIds: fileIds,
@@ -410,236 +483,234 @@
      resultType: '',
      startTime: '',
      wayLineJobIds: [],
    }
    };
    downloadApi(aaa).then(res => {
      aLinkDownload(res.data.data, `sjzx-file-pack-${dayjs().format('YYYYMMDDHHmmss')}.zip`)
      loading.close()
    })
      aLinkDownload(res.data.data, `sjzx-file-pack-${dayjs().format('YYYYMMDDHHmmss')}.zip`);
      loading.close();
    });
  }
}
};
// 下载
const downloadFile = () => {
  fileDownload()
}
  fileDownload();
};
const detailDownLoad = val => {
  const suffix = val.link?.split('.').pop()
  aLinkDownload(val.link, val?.nickName + '.' + suffix)
}
  const suffix = val.link?.split('.').pop();
  aLinkDownload(val.link, val?.nickName + '.' + suffix);
};
// 全部下载
const aLLDownloadFile = () => {
  loading = ElLoading.service({ background: 'rgba(0, 0, 0, 0.5)', text: '打包中,请稍等...' })
  loading = ElLoading.service({ background: 'rgba(0, 0, 0, 0.5)', text: '打包中,请稍等...' });
  const params = {
    ...jobListParams.searchParams,
  }
  params.areaCode = ''
  };
  params.areaCode = '';
  downloadApi(params).then(res => {
    aLinkDownload(res.data.data, `sjzx-file-pack-${dayjs().format('YYYYMMDDHHmmss')}.zip`)
    loading.close()
  })
}
    aLinkDownload(res.data.data, `sjzx-file-pack-${dayjs().format('YYYYMMDDHHmmss')}.zip`);
    loading.close();
  });
};
// 地图弹框
const mapComponent = ref(null) // 创建子组件引用
const mapList = ref(null)
const dataCenterMapVisible = ref(false)
const jobId = ref('')
const statusType = ref(null)
const mapComponent = ref(null); // 创建子组件引用
const mapList = ref(null);
const dataCenterMapVisible = ref(false);
const jobId = ref('');
const statusType = ref(null);
const positionDetail = val => {
  jobId.value = val.wayLineJobId
  mapList.value = val
  dataCenterMapVisible.value = true
  jobId.value = val.wayLineJobId;
  mapList.value = val;
  dataCenterMapVisible.value = true;
  // 确保地图组件加载完成
  nextTick(() => {
    if (mapComponent.value) {
      // 调用子组件方法并传递数据
      mapComponent.value.initEntityOrPopup(val)
      mapComponent.value.initEntityOrPopup(val);
    }
  })
}
  });
};
const fileNameedit = ref('')
const fileNameedit = ref('');
// 编辑文件名
const editTitle = val => {
  val.checkedinput = true
  fileNameedit.value = val?.nickName
}
  val.checkedinput = true;
  fileNameedit.value = val?.nickName;
};
// 通用空值检查函数
const validateNickname = (name, fieldName) => {
  if (!name || name.trim() === '') {
    ElMessage.warning(`${fieldName}不能为空`)
    return false
    ElMessage.warning(`${fieldName}不能为空`);
    return false;
  }
  if (name.length > 50) {
    ElMessage.warning(`${fieldName}不能超过50个字符`)
    return false
    ElMessage.warning(`${fieldName}不能超过50个字符`);
    return false;
  }
  return true
}
  return true;
};
// 保存文件名
const saveTitle = item => {
  const updateparams = {
    id: item.id,
    nickName: `${item.nickName.trim()}`,
  }
  };
  // 验证并提示
  if (!validateNickname(updateparams.nickName, '名称')) return
  item.checkedinput = false
  detailTitle.value = item.nickName
  if (!validateNickname(updateparams.nickName, '名称')) return;
  item.checkedinput = false;
  detailTitle.value = item.nickName;
  updataTitleApi(updateparams)
    .then(res => {
      if (res.status === 200) {
        ElMessage.success('修改成功')
        getaiImagesPage()
        ElMessage.success('修改成功');
        getaiImagesPage();
      } else {
        ElMessage.error(res.data.message || '修改失败')
        ElMessage.error(res.data.message || '修改失败');
      }
    })
    .catch(error => {
      ElMessage.error('请求失败,请稍后重试')
      console.error('API error:', error)
    })
}
      ElMessage.error('请求失败,请稍后重试');
      console.error('API error:', error);
    });
};
// 正射地图
const yxShowBox = ref(false)
const yxShowBox = ref(false);
const removeHandler = () => {
  handler?.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
  handler?.destroy()
  handler = null
}
const isMapInitialized = ref(false) //地图加载
  handler?.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
  handler?.destroy();
  handler = null;
};
const isMapInitialized = ref(false); //地图加载
const initMap = () => {
  if (viewer || isMapInitialized.value) return
  const container = document.getElementById('detaildataCenterMap')
  if (viewer || isMapInitialized.value) return;
  const container = document.getElementById('detaildataCenterMap');
  if (!container) {
    console.error('地图容器未找到')
    return
    console.error('地图容器未找到');
    return;
  }
  viewInstance.value = new PublicCesium({
    dom: 'detaildataCenterMap',
    flatMode: false,
    terrain: false,
    mapFilter: true,
  })
  viewer = viewInstance.value.getViewer()
  viewerRef.value = viewer
  isMapInitialized.value = true
  // console.log('地图初始化完成');
}
  });
  viewer = viewInstance.value.getViewer();
  viewerRef.value = viewer;
  isMapInitialized.value = true;
};
// 判断是否是正射
function isTifFile (filename) {
  const lastDot = filename.lastIndexOf('.')
  if (lastDot === -1) return false // 无后缀
  return filename.slice(lastDot + 1).toLowerCase() === 'tif'
function isTifFile(filename) {
  const lastDot = filename.lastIndexOf('.');
  if (lastDot === -1) return false; // 无后缀
  return filename.slice(lastDot + 1).toLowerCase() === 'tif';
}
const shouldShowLocation = row => {
  return row.resultType !== 1 && row.resultType !== 4
}
  return row.resultType !== 1 && row.resultType !== 4;
};
// 查看弹框
const dialogVisible = ref(false)
const dialogDetailList = ref(null)
const detailTitle = ref('')
let curCustomImageryProvider = null
const orthoimageApi = ref('')
const positiongeom = ref('')
const odmToken = ref(null)
const dialogVisible = ref(false);
const dialogDetailList = ref(null);
const detailTitle = ref('');
let curCustomImageryProvider = null;
const orthoimageApi = ref('');
const positiongeom = ref('');
const odmToken = ref(null);
const lookDetail = val => {
  if (val.resultType === 4) {
    // 正射
    getOrthoimageInfo(val.wayLineJobId).then(async res => {
      dialogVisible.value = true
      detailTitle.value = val.nickName
      dialogDetailList.value = val
      console.log('3333', detailTitle.value, dialogDetailList.value)
      await nextTick()
      initMap()
      positiongeom.value = res.data.data.geom
      orthoimageApi.value = res.data.data.orthoimageApi
      odmToken.value = res.data.data.odmToken
      dialogVisible.value = true;
      detailTitle.value = val.nickName;
      dialogDetailList.value = val;
      await nextTick();
      initMap();
      positiongeom.value = res.data.data.geom;
      orthoimageApi.value = res.data.data.orthoimageApi;
      odmToken.value = res.data.data.odmToken;
      if (res.data.data != null && isMapInitialized.value === true) {
        curCustomImageryProvider = viewInstance.value.addCustomImageryProviderDataSource(
          new Cesium.UrlTemplateImageryProvider({
            url: `${import.meta.env.VITE_APP_AREA_NAME}/webodm${res.data.data.orthoimageApi}?jwt=${res.data.data.odmToken.split(' ')[1]
              }`,
            // maximumLevel: 12,
            url: `${import.meta.env.VITE_APP_AREA_NAME}/webodm${res.data.data.orthoimageApi}?jwt=${
              res.data.data.odmToken.split(' ')[1]
            }`,
          })
        )
        yxShowBox.value = true
        );
        yxShowBox.value = true;
        // 添加定位
        if (positiongeom.value) {
          // 解析WKT格式的多边形坐标
          const wktString = positiongeom.value
          const coordinates = parseWKTCoordinates(wktString)
          const wktString = positiongeom.value;
          const coordinates = parseWKTCoordinates(wktString);
          if (coordinates.length > 0) {
            // 创建多边形边界
            const positions = coordinates.map(coord =>
              Cesium.Cartesian3.fromDegrees(coord[0], coord[1])
            )
            );
            // 计算多边形的包围球
            const boundingSphere = Cesium.BoundingSphere.fromPoints(positions)
            const viewer = viewInstance.value.getViewer()
            const boundingSphere = Cesium.BoundingSphere.fromPoints(positions);
            const viewer = viewInstance.value.getViewer();
            if (viewer && viewer.camera) {
              viewer.camera.flyToBoundingSphere(boundingSphere, {
                duration: 0, // 飞行动画持续时间(秒)
                offset: new Cesium.HeadingPitchRange(0, -0.5, boundingSphere.radius * 1.5),
              })
                duration: 0, // 增加动画时间使过渡更平滑
                offset: new Cesium.HeadingPitchRange(
                  Cesium.Math.toRadians(-45), // 航向角:-45度(东北方向)
                  Cesium.Math.toRadians(-90), // 俯仰角:-30度(向下倾斜30度)
                  boundingSphere.radius * 2.5 // 距离:2.5倍半径
                ),
              });
            } else {
              console.error('无法获取有效的 Viewer 或 camera 对象')
              console.error('无法获取有效的 Viewer 或 camera 对象');
            }
          }
        }
      }
    })
    });
  } else {
    getAttachInfoAPI(val.id).then(res => {
      detailTitle.value = res.data.data.nickName.split('.jpeg')[0]
      detailTitle.value = res.data.data.nickName.split('.jpeg')[0];
      dialogDetailList.value = {
        ...res.data.data,
        checkedinput: false,
        editName: res.data.data?.nickName?.split('.jpeg')[0],
      }
      dialogVisible.value = true
    })
      };
      dialogVisible.value = true;
    });
  }
}
};
// WKT坐标解析函数
function parseWKTCoordinates (wktString) {
function parseWKTCoordinates(wktString) {
  // 解析POLYGON格式的WKT字符串
  const regex = /POLYGON\s*\(\((.*?)\)\)/i
  const match = wktString.match(regex)
  if (!match || !match[1]) return []
  const regex = /POLYGON\s*\(\((.*?)\)\)/i;
  const match = wktString.match(regex);
  if (!match || !match[1]) return [];
  // 分割坐标对
  const coordinatePairs = match[1].split(/,\s*/)
  const coordinatePairs = match[1].split(/,\s*/);
  return coordinatePairs.map(pair => {
    const [lon, lat] = pair.trim().split(/\s+/).map(Number)
    return [lon, lat]
  })
    const [lon, lat] = pair.trim().split(/\s+/).map(Number);
    return [lon, lat];
  });
}
function dialogClose () {
function dialogClose() {
  // 对话框关闭时清理资源
  viewInstance.value?.viewerDestroy()
  viewer = null
  isMapInitialized.value = false
  viewInstance.value?.viewerDestroy();
  viewer = null;
  isMapInitialized.value = false;
}
onMounted(() => {
  getaiImagesPage()
  getaiImagesPage();
  // 监听打开全景事件
  EventBus.on('open-panorama', params => {
    panoramaParamsShow.value = params.show
    panoramaParamsUrl.value = params.url
  })
})
    panoramaParamsShow.value = params.show;
    panoramaParamsUrl.value = params.url;
  });
});
onBeforeUnmount(() => {
  // 组件卸载时移除事件监听,防止内存泄漏
  EventBus.off('open-panorama')
  viewInstance.value?.removeAllCustomImageryProviderDataSource(curCustomImageryProvider)
  viewInstance.value?.viewerDestroy()
})
  EventBus.off('open-panorama');
  viewInstance.value?.removeAllCustomImageryProviderDataSource(curCustomImageryProvider);
  viewInstance.value?.viewerDestroy();
});
</script>
<style scoped lang="scss">
@@ -716,20 +787,20 @@
.detailContainer {
  display: flex;
  justify-content: space-between;
align-items: center;
  align-items: center;
  .leftImg {
    width: 70%;
    height: 500px;
overflow: hidden;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
.videoItem {
 width: 100%;
    .videoItem {
      width: 100%;
      height: 100%;
      object-fit: cover;
}
    }
    #detaildataCenterMap {
      width: 100%;
      height: 100%;
@@ -798,7 +869,7 @@
  margin-bottom: 0 !important;
  font-size: 16px;
  >.editText {
  > .editText {
    cursor: pointer;
    margin-right: 6px;
@@ -817,4 +888,4 @@
    }
  }
}
</style>
</style>