无人机管理后台前端(已迁走)
罗广辉
2025-10-11 02409bfbe15f22fc3b5dccadabfd860a660a49d9
src/views/dataCenter/dataCenter.vue
@@ -1,12 +1,74 @@
<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
      ref="searchBoxRef"
      :searchjobId="searchjobId"
      :switchFolders="switchFolders"
      :switchStar = "switchStar"
        @search="searchClick"
        @downFun="downloadFile"
        @allDownFun="aLLDownloadFile"
        @handleswitchFolders="handleswitchFolders"
        @handleswitchList="handleswitchList"
        @handleStartList="handleStartList"
        @handleBack ="handleBack"
       :viewDetails ="viewDetails"
      ></searchData>
      <!-- 文件夹 -->
      <div v-if="switchFolders" class="dataTable">
            <el-table
         class="custom-header custom-body"
          v-loading="loadings"
          element-loading-text=""
          :data="folderList"
            @selection-change="foldersSelectionChange"
        >
          <el-table-column type="selection" width="55" />
          <el-table-column label="序号" type="index" width="60">
            <template #default="{ $index }">
              {{
                ($index + 1 + (FolderListParams.page - 1) * FolderListParams.page_size)
                  .toString()
                  .padStart(2, '0')
              }}
            </template>
          </el-table-column>
          <el-table-column property="recordName" label="任务名称" show-overflow-tooltip />
           <el-table-column property="regionName" label="所属区域">
             <template #default="scope">
              <span>{{scope.row.city_name ? scope.row.city_name :'--'}},{{scope.row.area_name ? scope.row.area_name :'--'}}</span>
            </template>
            </el-table-column>
          <el-table-column property="nickname" label="所属机巢" >
             <template #default="scope">
              <span>{{scope.row.nickname ? scope.row.nickname :'--'}}</span>
            </template>
            </el-table-column>
          <el-table-column label="操作" align="center">
            <template #default="scope">
              <el-button icon="el-icon-view" type="text" @click="foldersOpen(scope.row)"
                >查看</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 表格部分 -->
      <div class="dataTable">
        <el-table v-loading="loadings" element-loading-text="加载中" stripe :data="tableData" class="custom-header"
          @selection-change="handleSelectionChange">
      <div class="dataTable" v-else>
        <el-table
        border
          v-loading="loadings"
          element-loading-text=""
          :data="tableData"
          class="custom-header"
          @selection-change="handleSelectionChange"
          @cell-click="handleCellClick"
        >
          <el-table-column type="selection" width="55" />
          <el-table-column label="序号" type="index" width="60">
            <template #default="{ $index }">
@@ -24,24 +86,61 @@
          </el-table-column>
          <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 prop="nickName" label="文件名称" width="160">
            <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)" />
              <el-tooltip-copy :content="scope.row.nickName" :showCopyText="true">
                {{scope.row.nickName}}
              </el-tooltip-copy>
            </template>
          </el-table-column>
          <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=""
              />
              <!-- 视频 -->
              <div v-else-if="scope.row?.resultType === 1" class="videoItem1">
                <img
                  :src="convertVideoUrlToThumbnail(scope.row?.link)"
                  alt=""
                  class="imageBox"
                  @click="enterFullScreen(scope.row)"
                />
                <img
                  class="playBox"
                  @click="enterFullScreen(scope.row)"
                  src="@/assets/images/dataCenter/videoplay.png"
                  alt=""
                />
              </div>
              <!-- 正射 -->
              <img v-else-if="scope.row?.resultType === 4" :src="getzsSmallImg(scope.row?.link)" alt=""
                class="imageBox" />
              <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] }}</span>
              <span>{{
                photoTypeMap[scope.row.photoType] ? photoTypeMap[scope.row.photoType] : '--'
              }}</span>
            </template>
          </el-table-column>
          <el-table-column property="resultType" label="文件格式">
@@ -49,50 +148,90 @@
              <span>{{ resultTypeMap[row?.resultType] }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="150" align="center">
          <el-table-column label="操作" width="240" 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="location" @click="positionDetail(scope.row)" v-if="shouldShowLocation(scope.row)">定位</span>
              <el-button icon="el-icon-view" type="text" @click="lookDetail(scope.row)"
                >查看</el-button
              >
              <el-button
                v-if="scope.row.resultType !== 2"
                icon="el-icon-delete"
                type="text"
                @click="deleteDetail(scope.row)"
                >删除</el-button
              >
              <el-button
                v-if="shouldShowLocation(scope.row)"
                type="text"
                @click="positionDetail(scope.row)"
              >
                <img :src="positionicon" class="custom-icon" />定位</el-button
              >
              <el-button type="text" @click="handleStar(scope.row)"><el-icon><Star /></el-icon>{{ scope.row.isFavorite ? '取消收藏':'收藏' }}</el-button>
              <el-popover
                placement="top-start"
                title="扫二维码分享"
                :width="148"
                trigger="click"
                popper-class="custom-qrcode-popover-share"
                @show="handleShare(scope.row)"
              >
                <template #reference>
                  <el-button type="text"><el-icon><Share /></el-icon>分享</el-button>
                </template>
                <div class="qrcode-content">
                  <div class="myQrCode" :id="`myQrCode-${scope.row.id}`" :ref="setQrCodeRef(scope.row.id)"></div>
                </div>
              </el-popover>
            </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
      :current-page="switchFolders ? FolderListParams.page : jobListParams.current"
      :page-size="switchFolders ? FolderListParams.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">
      <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>
            <!-- <h4 :id="titleId" :class="titleClass">{{ detailTitle }}</h4> -->
            <h4 :id="titleId" :class="titleClass">详情</h4>
          </div>
        </template>
        <div class="detailContainer">
          <div class="leftImg">
            <!-- <img
            v-if="dialogDetailList?.resultType === 1"
            :src="convertVideoUrlToThumbnail(dialogDetailList?.link)"
            alt=""
            class="imageBox"
          /> -->
            <!-- 视频 -->
            <video v-if="dialogDetailList?.resultType === 1" style="width: 100%" class="imageBox" ref="videoRefs"
              controls autoplay :src="dialogDetailList.link"></video>
            <!-- 全景 -->
            <!-- <img
             class="quanjing"
             @click="clickpanorama(dialogDetailList)"
             v-else-if="dialogDetailList?.resultType === 5"
             :src="dialogDetailList?.resultType?.smallUrl"
             alt=""
           /> -->
            <video
              v-if="dialogDetailList?.resultType === 1"
              style="width: 100%"
              class="videoItem"
              ref="videoRefs"
              controls
              autoplay
              :src="dialogDetailList.link"
            ></video>
            <!-- 地图 -->
            <div v-else-if="dialogDetailList?.resultType === 4" id="detaildataCenterMap" class="ztzf-cesium"></div>
            <div
              v-else-if="dialogDetailList?.resultType === 4"
              id="detaildataCenterMap"
              class="ztzf-cesium"
            ></div>
            <img v-else :src="getSmallImg(dialogDetailList?.link)" alt="" />
          </div>
          <div class="rightDetail">
@@ -101,25 +240,27 @@
                文件名称:<span class="fileTitle" v-if="!dialogDetailList?.checkedinput">{{
                  dialogDetailList?.nickName ? dialogDetailList?.nickName : '--'
                }}</span>
                <el-input v-else v-model="dialogDetailList.nickName" @keyup.enter="saveTitle()" class="title-input"
                  clearable />
              </div>
              <div class="editname">
                <span v-if="!dialogDetailList?.checkedinput" @click="editTitle(dialogDetailList)"><el-icon>
                    <Edit />
                  </el-icon></span>
                <div v-else class="suffixBoxEdit">
                  <div class="editText" @click="submitEditSuffix(dialogDetailList)">✔</div>
                  <div class="editText" @click="cancelEditSuffix(dialogDetailList)">✖</div>
                </div>
                <el-input
                  v-else
                  v-model="dialogDetailList.nickName"
                  @blur="saveTitle(dialogDetailList)"
                  @keyup.enter="saveTitle(dialogDetailList)"
                  class="title-input"
                  clearable
                />
                <span class="editname" @click="editTitle(dialogDetailList)"
                  ><el-icon> <Edit /> </el-icon
                ></span>
              </div>
            </div>
            <div>任务名称:{{ dialogDetailList?.jobName ? dialogDetailList?.jobName : '--' }}</div>
            <div>
              所属区域:{{ dialogDetailList?.regionName ? dialogDetailList?.regionName : '--' }}
            </div>
            <div>拍摄机巢:{{ dialogDetailList?.nestName ? dialogDetailList?.nestName : '--' }}</div>
            <div>
              拍摄机巢:{{ dialogDetailList?.nestName ? dialogDetailList?.nestName : '--' }}
            </div>
            <div v-if="dialogDetailList?.resultType != 4">
              照片位置:{{ _.round(dialogDetailList?.longitude, 3) }},{{
                _.round(dialogDetailList?.latitude, 3)
              }}
@@ -143,86 +284,118 @@
              }}
            </div>
            <div>
              照片文件大小:{{
              文件大小:{{
                bytesToMB(dialogDetailList?.attachSize)
                  ? bytesToMB(dialogDetailList?.attachSize)
                  : '--'
              }}
            </div>
            <div>
              <el-button type="success" plain icon="el-icon-download"
                @click="detailDownLoad(dialogDetailList)">下载</el-button>
              <el-button
                type="success"
                plain
                icon="el-icon-download"
                @click="detailDownLoad(dialogDetailList)"
                >下载</el-button
              >
            </div>
          </div>
        </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 fileimg from '@/assets/images/dataCenter/filePackage.png'
import { getShowImg, getSmallImg, getzsSmallImg } from '@/utils/util';
import { onMounted, watch } from 'vue';
import dayjs from 'dayjs';
import ElTooltipCopy from '@/components/ElTooltipCopy.vue';
import videoplay from '@/assets/images/dataCenter/videoplay.png';
import positionicon from '@/assets/images/dataCenter/positionicon.png';
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';
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 QRCode from 'qrcodejs2-fix'
import fy1 from '@/assets/images/dataCenter/1.jpeg';
import _ from 'lodash';
import {
  getaiImagesPageAPI,
  getAttachInfoAPI,
  deleteFileMultipleApi,
  downloadApi,
  updataTitleApi,
  getOrthoimageInfo,
} 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 '无效输入'
  return (bytes / 1048576).toFixed(decimalPlaces) + ' MB'
  getOrthoimageInfo, getDownloadStatusApi,getJobIdsBySnApi, starAdd, cancelStar
} from '@/api/dataCenter/dataCenter';
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;
const switchFolders = ref(false)
const switchStar = ref(false)
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: '照片',
@@ -230,84 +403,94 @@
  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([])
  searchParams: { startTime: timeRange[0], endTime: timeRange[1], isFavorite: false },
});
const FolderListParams = reactive({
    page: 1,
    page_size: 10,
    startTime: jobListParams.searchParams.startTime?.slice(0, 10),
    endTime: jobListParams.searchParams.endTime?.slice(0, 10),
     waylineName:'',
    dockSn:'',
    areaCode:''
});
const tableData = ref([]);
// 获取列表数据
const getaiImagesPage = () => {
  loadings.value = true
  loadings.value = true;
  const params = {
    orderByCreateTime: jobListParams.orderByCreateTime,
    ...jobListParams.searchParams,
  };
  if( searchjobId.value === ''){
    params.wayLineJobId = ''
  }
  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,
@@ -315,40 +498,142 @@
        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 folderList = ref([])
// 获取文件夹数据
const getFolderList=()=>{
    loadings.value = true;
    const apiParams = {
      ...FolderListParams,
      };
    getJobIdsBySnApi(apiParams)
      .then(res => {
    folderList.value = res.data.data.records.map(i => ({ ...i, checked: false }))
    total.value = res.data.data.total
      })
      .finally(() => {
        loadings.value = false;
      })
}
const searchjobId = ref('')
const viewDetails = ref('')
// 文件夹查看
const foldersOpen = (val)=>{
    loadings.value = true;
    tableData.value=[]
    searchjobId.value = val.job_id
    switchFolders.value = false
    viewDetails.value = true
}
// 获取数据时使用各自的分页参数
const fetchData = () => {
  if (switchFolders.value) {
    getFolderList();
  } else {
    getaiImagesPage();
  }
};
// 列表
function handleswitchList() {
  switchFolders.value = false;
  switchStar.value = false;
  jobListParams.current = 1;
  jobListParams.size = 10;
  jobListParams.searchParams.isFavorite = false;
  getaiImagesPage();
}
// 切换文件夹
 const handleswitchFolders = () => {
 searchjobId.value = ''
     switchFolders.value = true;
     switchStar.value = false;
     jobListParams.current = 1;
     FolderListParams.page = 1;
     searchBoxRef.value?.handleReset();
      fetchData();
   };
   const handleBack =()=>{
    searchjobId.value = ''
    switchFolders.value = true
    viewDetails.value = false
    jobListParams.current = 1;
    FolderListParams.page = 1;
     fetchData();
   }
   const searchBoxRef = ref(null);
// 收藏列表
const handleStartList = () => {
  switchFolders.value = false;
  switchStar.value = true;
  jobListParams.current = 1;
  jobListParams.size = 10;
  jobListParams.searchParams.isFavorite = true;
  getaiImagesPage();
}
// 查询
const searchClick = params => {
  jobListParams.current = 1
  jobListParams.size = 10
  jobListParams.searchParams = params
  getaiImagesPage()
}
const handleSizeChange = val => {
  jobListParams.size = val
  getaiImagesPage()
}
const handleCurrentChange = val => {
  jobListParams.current = val
  getaiImagesPage()
}
  if(switchFolders.value){
    FolderListParams.page = 1;
    FolderListParams.page_size = 10;
    FolderListParams.startTime = params?.startTime?.slice(0, 10);
    FolderListParams.endTime = params?.endTime?.slice(0, 10);
    FolderListParams.waylineName=params?.jobName,
   FolderListParams.dockSn = params?.deviceSn
   FolderListParams.areaCode = params?.areaCode
    getFolderList()
  }else{
     jobListParams.current = 1;
      jobListParams.size = 10;
      jobListParams.searchParams = {
      ...jobListParams.searchParams,
      ...params
    };
    getaiImagesPage()
  }
};
const handleSizeChange = (val) => {
  if (switchFolders.value) {
    FolderListParams.page_size = val;
  } else {
    jobListParams.size = val;
  }
  fetchData();
};
const handleCurrentChange = (val) => {
  if (switchFolders.value) {
    FolderListParams.page = val;
  } else {
    jobListParams.current = val;
  }
  fetchData();
};
// 多选
const selectedRows = ref([])
const selectedRows = ref([]);
const handleSelectionChange = val => {
  // 更新选中状态
  tableData.value.forEach(item => {
    item.checked = val.some(selected => selected.id === item.id)
  })
  selectedRows.value = val
    item.checked = val.some(selected => selected.id === item.id);
  });
  selectedRows.value = val;
};
// 文件夹多选
const foldersSelectedRows = ref([]);
const foldersSelectionChange =(val)=>{
 folderList.value.forEach(item => {
    item.checked = val.some(foldersselected => foldersselected.id === item.id);
  });
  foldersSelectedRows.value = val;
}
// 删除
const deleteDetail = val => {
@@ -360,36 +645,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 fileDownload = async () => {
  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,
@@ -400,246 +685,313 @@
      jobName: '',
      resultType: '',
      startTime: '',
      wayLineJobIds: [],
    }
    downloadApi(aaa).then(res => {
      aLinkDownload(res.data.data, `sjzx-file-pack-${dayjs().format('YYYYMMDDHHmmss')}.zip`)
      type:'htsjzx'
    };
    const res = await getDownloadStatusApi({type: 'htsjzx'})
    if (!['CANCELLED','COMPLETED'].includes(res.data.data?.status || 'COMPLETED')){
      loading.close()
    })
      return ElMessage.warning('还有正在处理的')
    }
    downloadApi(aaa).finally(res => {
      loading.close();
    });
  }
};
// 文件夹打包下载
async function folderDownload() {
   const jobId =  foldersSelectedRows.value.filter(i => i.checked).map(i => i.job_id)
   if (!jobId?.length) return ElMessage.warning('请选择文件夹')
   const res = await getDownloadStatusApi({type: 'dpsjzx'})
   if (!['CANCELLED','COMPLETED'].includes(res.data.data?.status || 'COMPLETED')){
      return ElMessage.warning('还有正在处理的')
   }
   await downloadApi({ wayLineJobIds:jobId, withFolder: true, resultType: 0, type:'htsjzx' })
}
// 下载
const downloadFile = () => {
  fileDownload()
}
 switchFolders.value?folderDownload(): 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
}
// 取消
const cancelEditSuffix = item => {
  item.nickName = fileNameedit.value
  item.checkedinput = false
}
const submitEditSuffix = item => {
  saveTitle(item)
}
  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('地图初始化完成');
}
    layerMode: 4
  });
  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) {
  // 解析POLYGON格式的WKT字符串
  const regex = /POLYGON\s*\(\((.*?)\)\)/i;
  const match = wktString.match(regex);
  if (!match || !match[1]) return [];
  // 分割坐标对
  const coordinatePairs = match[1].split(/,\s*/);
  return coordinatePairs.map(pair => {
    const [lon, lat] = pair.trim().split(/\s+/).map(Number);
    return [lon, lat];
  });
}
function dialogClose() {
  // 对话框关闭时清理资源
  viewInstance.value?.viewerDestroy();
  viewer = null;
  isMapInitialized.value = false;
}
function handleCellClick(row, column) {
  if (column.no === 5) {
    navigator.clipboard.writeText(row.nickName).then(() => {
      ElMessage.success('复制文件名称成功')
    })
  }
}
// WKT坐标解析函数
function parseWKTCoordinates (wktString) {
  // 解析POLYGON格式的WKT字符串
  const regex = /POLYGON\s*\(\((.*?)\)\)/i
  const match = wktString.match(regex)
  if (!match || !match[1]) return []
  // 分割坐标对
  const coordinatePairs = match[1].split(/,\s*/)
  return coordinatePairs.map(pair => {
    const [lon, lat] = pair.trim().split(/\s+/).map(Number)
    return [lon, lat]
  })
// 收藏 or 取消收藏
function handleStar(row) {
  if (row.isFavorite) {
    cancelStar(row.id).then(res => {
      ElMessage.success('取消收藏成功')
      getaiImagesPage();
    })
  } else {
    starAdd({ attachId: row.id }).then(res => {
      ElMessage.success('收藏成功')
      getaiImagesPage();
    })
  }
}
function dialogClose () {
  // 对话框关闭时清理资源
  viewInstance.value?.viewerDestroy()
  viewer = null
  isMapInitialized.value = false
// 分享
const myQrCode = ref(null)
let qrCodeInstance = null
const qrCodeRefs = ref({});
// 设置动态ref的方法
const setQrCodeRef = (id) => (el) => {
    if (el) {
        qrCodeRefs.value[id] = el;
    }
};
async function handleShare(row) {
  try {
    await nextTick();
    const qrCodeElement = qrCodeRefs.value[row.id]
    if (qrCodeInstance) {
      qrCodeInstance.clear();
      qrCodeInstance = null;
      qrCodeElement.innerHTML = '';
    }
    // await nextTick();
    qrCodeInstance = new QRCode(qrCodeElement, {
      width: 130,
      height: 130,
      text: row.link,
    });
    qrCodeElement.removeAttribute('title');
  } catch (error) {
    console.error('生成二维码失败:', error);
  }
}
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 lang="scss">
.custom-qrcode-popover-share {
  width: 120px;
}
</style>
<style scoped lang="scss">
.dataCenter-table {
  height: 0;
@@ -657,7 +1009,12 @@
      cursor: pointer;
      margin-right: 10px;
    }
    .custom-icon {
      width: 14px;
      height: 14px;
      margin-right: 5px;
      vertical-align: middle;
    }
    .delete {
      color: #ff241c;
      margin-right: 10px;
@@ -669,7 +1026,67 @@
      cursor: pointer;
    }
  }
   .fileshow {
       display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  overflow: auto;
  flex: 1;
  min-height: 0; /* 关键:解决 flex 容器中的最小高度问题 */
  align-content: flex-start; /* 让内容从顶部开始排列 */
         .filePackage {
          display: flex;
    justify-content: center;
            width: 260px;
            height: 146px;
            border-radius: 4px 4px 4px 4px;
            position: relative;
            background: #ddd;
            cursor: pointer;
            img {
               width: 111px;
               height: 111px;
            }
            .el-checkbox {
               position: absolute;
               top: 0;
               left: 6px;
            }
            .itemName {
               position: absolute;
               bottom: 0;
               left: 0;
               height: 23px;
               width: 100%;
          padding: 0 10px;
          box-sizing: border-box;
               background: rgba(22, 56, 101, 0.3);
               border-radius: 0px 0px 4px 4px;
               font-family: Source Han Sans CN, Source Han Sans CN;
               font-weight: 400;
               font-size: 14px;
               color: #ffffff;
               line-height: 23px;
               display: flex;
               align-items: center;
               justify-content: space-between;
               div {
                  white-space: nowrap;
               }
               img {
                  width: 14px;
                  height: 14px;
                  cursor: pointer;
               }
            }
         }
      }
  .pagination {
    display: flex;
    justify-content: end;
@@ -683,7 +1100,17 @@
    width: 76px;
    height: 72px;
  }
  .videoItem1 {
    .playBox {
      width: 20px;
      height: 20px;
      position: absolute;
      top: 46%;
      left: 43%;
      transform: translate(-50%, -50%);
      cursor: pointer;
    }
  }
  .videoDialog :deep(.el-dialog) {
    height: 600px;
    width: 54%;
@@ -708,22 +1135,30 @@
:deep(.custom-header th.el-table__cell) {
  color: rgba(0, 0, 0, 0.85);
  background: #fafafa;
  height: 60px !important;
}
:deep(.custom-body .el-table__body tr) {
  height: 53px !important;
}
// 弹框
.detailContainer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .leftImg {
    width: 70%;
    height: 500px;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
    .videoItem {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    #detaildataCenterMap {
      width: 100%;
      height: 100%;
@@ -740,6 +1175,11 @@
      .editname {
        cursor: pointer;
         :deep(.el-icon) {
    width: 20px;  // 调整图标宽度(默认通常14px左右)
    height: 20px; // 调整图标高度(与宽度保持一致)
    font-size: 20px; // 部分图标可能依赖font-size控制大小,同步设置
  }
      }
      .inputEdit {
@@ -792,7 +1232,7 @@
  margin-bottom: 0 !important;
  font-size: 16px;
  >.editText {
  > .editText {
    cursor: pointer;
    margin-right: 6px;
@@ -811,4 +1251,4 @@
    }
  }
}
</style>
</style>