无人机管理后台前端(已迁走)
shuishen
2025-06-27 5a6b7d9120ab30d29fb06e2b2b20de03d4de1ddc
src/views/dataCenter/dataCenter.vue
@@ -1,4 +1,5 @@
<template>
<basic-container>
  <div class="dataCenter-table">
    <searchData
      @search="searchClick"
@@ -25,9 +26,9 @@
            }}
          </template>
        </el-table-column>
        <el-table-column prop="regionName" label="所属区域" >
        <el-table-column prop="regionName" label="所属区域" v-if="!isDistrictLevel">
          <template #default="scope">
            <span>{{processAddress(scope.row.regionName)}}</span>
            <span>{{ processAddress(scope.row.regionName) }}</span>
          </template>
        </el-table-column>
        <el-table-column property="nestName" label="所属机巢" />
@@ -80,15 +81,14 @@
          <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
            >
            <!-- && !isTifFile(scope.row.nickName)
            scope.row.resultType !== 1-->
            <span
              class="location"
              @click="positionDetail(scope.row)"
              v-if="shouldShowLocation(scope.row)"
              >定位</span
            >定位</span
            >
          </template>
        </el-table-column>
@@ -116,15 +116,33 @@
      </template>
      <div class="detailContainer">
        <div class="leftImg">
          <img
          <!-- <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=""
           /> -->
          <!-- 地图 -->
          <div
            v-if="dialogDetailList?.resultType === 4"
            v-else-if="dialogDetailList?.resultType === 4"
            id="detaildataCenterMap"
            class="ztzf-cesium"
          ></div>
@@ -134,11 +152,11 @@
          <div class="title">
            <div class="inputEdit">
              文件名称:<span class="fileTitle" v-if="!dialogDetailList?.checkedinput">{{
                dialogDetailList?.editName
                dialogDetailList?.nickName ? dialogDetailList?.nickName : '--'
              }}</span>
              <el-input
                v-else
                v-model="dialogDetailList.editName"
                v-model="dialogDetailList.nickName"
                @keyup.enter="saveTitle()"
                class="title-input"
                clearable
@@ -146,7 +164,7 @@
            </div>
            <div class="editname">
              <span v-if="!dialogDetailList?.checkedinput" @click="editTitle(dialogDetailList)"
                ><el-icon><Edit /></el-icon
              ><el-icon><Edit /></el-icon
              ></span>
              <div v-else class="suffixBoxEdit">
                <div class="editText" @click="submitEditSuffix(dialogDetailList)">✔</div>
@@ -154,26 +172,48 @@
              </div>
            </div>
          </div>
          <div>任务名称:{{ dialogDetailList?.jobName }}</div>
          <div>所属区域:{{ dialogDetailList?.regionName }}</div>
          <div>拍摄机巢:{{ dialogDetailList?.nestName }}</div>
          <div>任务名称:{{ dialogDetailList?.jobName ? dialogDetailList?.jobName : '--' }}</div>
          <div>
            所属区域:{{ dialogDetailList?.regionName ? dialogDetailList?.regionName : '--' }}
          </div>
          <div>拍摄机巢:{{ dialogDetailList?.nestName ? dialogDetailList?.nestName : '--' }}</div>
          <div>
            照片位置:{{ _.round(dialogDetailList?.longitude, 3) }},{{
              _.round(dialogDetailList?.latitude, 3)
            }}
          </div>
          <div>任务时间:{{ dialogDetailList?.jobTime }}</div>
          <div>拍摄时间:{{ dialogDetailList?.createTime }}</div>
          <div>文件类型:{{ photoTypeMap[dialogDetailList?.photoType] }}</div>
          <div>文件格式:{{ resultTypeMap[dialogDetailList?.resultType] }}</div>
          <div>照片文件大小:{{ bytesToMB(dialogDetailList?.attachSize) }}</div>
          <div>任务时间:{{ dialogDetailList?.jobTime ? dialogDetailList?.jobTime : '--' }}</div>
          <div>
            拍摄时间:{{ dialogDetailList?.createTime ? dialogDetailList?.createTime : '--' }}
          </div>
          <div>
            文件类型:{{
              photoTypeMap[dialogDetailList?.photoType]
                ? photoTypeMap[dialogDetailList?.photoType]
                : '--'
            }}
          </div>
          <div>
            文件格式:{{
              resultTypeMap[dialogDetailList?.resultType]
                ? resultTypeMap[dialogDetailList?.resultType]
                : '--'
            }}
          </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
            >
          </div>
        </div>
@@ -215,6 +255,7 @@
      :dotData="mapList"
    ></dataCenterMap>
  </div>
    </basic-container>
</template>
<script setup>
@@ -254,8 +295,6 @@
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';
@@ -282,28 +321,30 @@
  ir: '红外',
};
// 判断省市区
const areas = 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); // 区县级
// 处理区域名称的函数
function processAddress(str) {
 const parts = str.split(',');
if(areas ==="360000000000"){
   return parts.filter(part => !part.endsWith('省')).join(',');
}
  //
  // // 检查是否有省级单位(以"省"结尾)
  // const hasProvince = parts.some(part => part.endsWith('省'));
  // // 检查是否有市级单位(以"市"结尾)
  // const hasCity = parts.some(part => part.endsWith('市'));
  if (!str) return '';
  // if (hasProvince) {
  //   // 移除省级部分(第一个以"省"结尾的元素)
  //   return parts.filter(part => !part.endsWith('省')).join(',');
  // } else if (hasCity) {
  //   // 如果有市,返回空字符串
  //   return '';
  // }
  const parts = str.split(',');
  // 既没有省也没有市,返回原字符串
  return str;
  // 省级账号:显示市和区(去除省级)
  if (isProvinceLevel.value) {
    return parts.filter(part => !part.endsWith('省')).join(',');
  }
  // 市级账号:只显示区(去除省和市)
  if (isCityLevel.value) {
    return parts.filter(part => !part.endsWith('省') && !part.endsWith('市')).join(',');
  }
  // 区县级账号:不显示区域信息(在模板中已隐藏该列)
  return '';
}
const showRegionColumn = computed(() => {
  // 检查表格数据中是否有任何行的 regionName 处理后不为空
@@ -360,7 +401,7 @@
        showUrl: getShowImg(i?.link),
        file_name: i.name.split('/').pop(),
      }));
      // console.log('res', tableData.value);
      loadings.value = false;
    }
  );
@@ -519,16 +560,17 @@
const saveTitle = item => {
  const updateparams = {
    id: item.id,
    nickName: `${item.editName.trim()}`,
    nickName: `${item.nickName.trim()}`,
  };
  // 验证并提示
  if (!validateNickname(updateparams.nickName, '名称')) return;
  item.checkedinput = false;
  detailTitle.value = item.editName;
  detailTitle.value = item.nickName;
  updataTitleApi(updateparams)
    .then(res => {
      if (res.status === 200) {
        ElMessage.success('修改成功');
        getaiImagesPage();
      } else {
        ElMessage.error(res.data.message || '修改失败');
      }
@@ -540,7 +582,6 @@
};
// 正射地图
const yxShowBox = ref(false);
const removeHandler = () => {
  handler?.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
  handler?.destroy();
@@ -568,7 +609,7 @@
  // console.log('地图初始化完成');
};
// 查看弹框
// 判断是否是正射
function isTifFile(filename) {
  const lastDot = filename.lastIndexOf('.');
  if (lastDot === -1) return false; // 无后缀
@@ -577,11 +618,13 @@
const shouldShowLocation = row => {
  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 lookDetail = val => {
  if (val.resultType === 4) {
@@ -590,8 +633,11 @@
      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;
      if (res.data.data != null && isMapInitialized.value === true) {
@@ -604,12 +650,34 @@
          })
        );
        yxShowBox.value = true;
        // 添加定位
        if (positiongeom.value) {
          // 解析WKT格式的多边形坐标
          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();
            if (viewer && viewer.camera) {
              viewer.camera.flyToBoundingSphere(boundingSphere, {
                duration: 0, // 飞行动画持续时间(秒)
                offset: new Cesium.HeadingPitchRange(0, -0.5, boundingSphere.radius * 1.5),
              });
            } else {
              console.error('无法获取有效的 Viewer 或 camera 对象');
            }
          }
        }
      }
    });
  } else {
    getAttachInfoAPI(val.id).then(res => {
      detailTitle.value = res.data.data.nickName.split('.jpeg')[0];
      // dialogDetailList.value = res.data.data;
      dialogDetailList.value = {
        ...res.data.data,
        checkedinput: false,
@@ -619,7 +687,19 @@
    });
  }
};
// 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();
@@ -644,32 +724,40 @@
<style scoped lang="scss">
.dataCenter-table {
  margin: 0 18px 16px 10px;
  background-color: #ffffff;
  padding: 14px 18px;
  height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  .dataTable {
    height: 700px;
    height: 0;
    flex: 1;
    overflow: auto;
    .look {
      color: #1c5cff;
      cursor: pointer;
      margin-right: 10px;
    }
    .delete {
      color: #ff241c;
      margin-right: 10px;
      cursor: pointer;
    }
    .location {
      color: #19876d;
      cursor: pointer;
    }
  }
  .pagination {
    display: flex;
    justify-content: end;
    margin-top: 20px;
  }
  .quanjing,
  .el-image,
  .imageBox {
@@ -677,54 +765,70 @@
    width: 76px;
    height: 72px;
  }
  .videoDialog :deep(.el-dialog) {
    height: 600px;
    width: 54%;
  }
  .video-container {
    width: 100%;
    aspect-ratio: 16/9; /* 按视频比例设置(如16:9) */
    overflow: hidden; /* 隐藏溢出部分 */
    aspect-ratio: 16/9;
    /* 按视频比例设置(如16:9) */
    overflow: hidden;
    /* 隐藏溢出部分 */
  }
  .videoBox {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 保持比例完整显示 */
    object-fit: contain;
    /* 保持比例完整显示 */
    display: block;
  }
}
:deep(.custom-header th.el-table__cell) {
  color: rgba(0, 0, 0, 0.85);
}
// 弹框
.detailContainer {
  display: flex;
  justify-content: space-between;
  .leftImg {
    width: 70%;
    height: 500px;
    img {
      width: 100%;
      height: 100%;
    }
    #detaildataCenterMap {
      width: 100%;
      height: 100%;
    }
  }
  .rightDetail {
    width: 30%;
    padding-left: 40px;
    .title {
      display: flex;
      margin: 0 !important;
      .editname {
        cursor: pointer;
      }
      .inputEdit {
        display: flex;
        align-items: center;
        width: 100%;
        .fileTitle {
          width: 70%;
          white-space: nowrap;
@@ -733,49 +837,60 @@
        }
      }
    }
    div {
      margin-bottom: 20px;
    }
  }
}
.my-header :deep(.el-dialog__title) {
  margin: 0 !important;
  height: 19px;
}
.my-header {
  display: flex;
  align-items: center;
  .el-button {
    margin-left: 20px;
  }
}
.title-input {
  margin-bottom: 0 !important;
  width: 70%;
}
.editname {
  margin-bottom: 0 !important;
}
.suffixBoxEdit {
  display: flex;
  // align-items: center;
  justify-content: space-between;
  margin-bottom: 0 !important;
  font-size: 16px;
  > .editText {
  >.editText {
    cursor: pointer;
    margin-right: 6px;
    &:hover {
      transform: scale(1.2);
    }
  }
  .editimg {
    cursor: pointer;
    width: 15px;
    height: 15px;
    &:hover {
      transform: scale(1.2);
    }
  }
}
</style>
</style>