forked from drone/command-center-dashboard

罗广辉
2025-04-21 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7
src/views/Home/AINowFly.vue
@@ -3,32 +3,57 @@
      <div class="title">智引即飞<img @click="closeClick" src="@/assets/images/aiNowFly/close.png"/></div>
      <el-form ref="ruleFormRef" :model="params" :rules="rules" label-width="auto" size="small" status-icon>
         <el-form-item label="任务名称" prop="name">
            <el-input v-model="params.name" />
            <el-input class="ztzf-input" v-model="params.name" />
         </el-form-item>
         <el-form-item label="关联算法" prop="ai_types">
            <el-select v-model="params.ai_types" placeholder="请选择" multiple collapse-tags collapse-tags-tooltip>
            <el-select :teleported="false" class="ztzf-select" v-model="params.ai_types" placeholder="请选择" multiple collapse-tags collapse-tags-tooltip>
               <el-option v-for="item in taskAlgorithm" :key="item.id" :label="item.dictValue" :value="item.dictKey" />
            </el-select>
         </el-form-item>
         <el-form-item label="地址">
            <el-input disabled type="text" v-model="di" placeholder="地名&经纬度"/>
            <el-input class="ztzf-input" disabled type="text" v-model="di" placeholder="地名&经纬度"/>
         </el-form-item>
         <!--         todo-->
         <el-form-item label="事件">
         <el-form-item label="飞行事件">
            <div class="event">
               <img src="@/assets/images/aiNowFly/picture-recording.png" alt="">
               <img src="../../assets/images/aiNowFly/event/startRecord.png" alt="">
               <div class="img-close" v-show="isPhoto">
                  <img @click="isPhoto=false" class="close" src="@/assets/images/aiNowFly/close.png" alt="">
                  <img src="../../assets/images/aiNowFly/event/takePhoto.png" alt="">
               </div>
               <div class="img-close" v-show="isStop">
                  <img @click="isStop=false" class="close" src="@/assets/images/aiNowFly/close.png" alt="">
                  <img src="../../assets/images/aiNowFly/event/hover.png" alt="">
               </div>
               <div class="add-event" @click="isShowEvent = !isShowEvent">+
                  <div class="event-select" v-show="isShowEvent">
                     <div class="photo" @click="isPhoto=true">拍照</div>
                     <div class="stop" @click="isStop=true">悬停</div>
                  </div>
               </div>
            </div>
         </el-form-item>
      </el-form>
      <div class="title-list">可飞行机巢列表:</div>
      <el-table :data="list" height="120" @selection-change="handleSelectionChange">
         <el-table-column type="selection" />
         <!-- <el-table-column type="index" label="序号" /> -->
         <el-table-column prop="nickname" label="机巢名称" />
         <el-table-column prop="minute" label="可飞行时间" />
         <el-table-column prop="exe_distance" label="可飞行距离" />
      </el-table>
      <div class="tabledata">
         <div class="table-content">
            <div class="tabler-item">
               <el-checkbox v-model="isCheckAll" @change="checkedAll"/>
            </div>
            <div class="table-item">机巢名称</div>
            <div class="table-item">可飞行时间</div>
            <div class="table-item">可飞行距离</div>
         </div>
         <div class="table-content" v-for="item in list">
            <div class="tabler-item">
               <el-checkbox v-model="item.checked" @change="handleItemCheck"/>
            </div>
            <div class="table-item">{{ item.nickname }}</div>
            <div class="table-item">{{ item.minute }}(min)</div>
            <div class="table-item">{{ item.exe_distance }}(km)</div>
         </div>
      </div>
      <div class="btn-submit" @click="nowFly"><img src="@/assets/images/aiNowFly/fly.png" alt=""></div>
   </div>
</template>
@@ -61,9 +86,17 @@
   type: 1,
   begin_time: nowTime,
   end_time: nowTime,
   action_modes: [{action_actuator_func: 'startRecord'}],
}
const params = ref(_.cloneDeep(paramsInit))
const di = computed(() => params.value.longitude + ',' + params.value.latitude)
// 事件默认隐藏
const isShowEvent = ref(false);
// 添加事件
const isPhoto = ref(false)
const isStop = ref(false)
const rules = ref({
   name: [
@@ -89,6 +122,14 @@
   await ruleFormRef.value.validate()
   if (!params.value.dock_sns.length) return ElMessage.warning('请选择将要飞行的机巢')
   if (!params.value.longitude) return ElMessage.warning('请选择飞行的点')
   // 先清除,再push
   params.value.action_modes = [{action_actuator_func:'startRecord'}]
   if (isPhoto.value) {
      params.value.action_modes.push({action_actuator_func:'takePhoto'})
   }
   if (isStop.value) {
      params.value.action_modes.push({action_actuator_func:'hover'})
   }
   createTask(params.value).then(res => {
      ElMessage.success('起飞成功')
      if (params.value.dock_sns.length === 1) {
@@ -118,22 +159,22 @@
      label: {
        text: `预计${item.minute}分钟`,
            font: 'bold 16px Source Han Sans CN',  // 加粗并增大字号
           fillColor: new Cesium.Color(27/255, 179/255, 255/255, 1.0),
            fillColor: Cesium.Color.WHITE,
            style: Cesium.LabelStyle.FILL_AND_OUTLINE,
            verticalOrigin: Cesium.VerticalOrigin.CENTER,
            horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
            eyeOffset: new Cesium.Cartesian3(0, 0, -10),
            pixelOffset: new Cesium.Cartesian2(0, -10),
            rotation: Math.atan2(direction.y, direction.x)
           // fillColor: new Cesium.Color(27/255, 179/255, 255/255, 1.0),
            // fillColor: Cesium.Color.WHITE,
            // style: Cesium.LabelStyle.FILL_AND_OUTLINE,
            // verticalOrigin: Cesium.VerticalOrigin.CENTER,
            // horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
            // eyeOffset: new Cesium.Cartesian3(0, 0, -10),
            // pixelOffset: new Cesium.Cartesian2(0, -10),
            rotation: 12.785398, // 修改旋转计算方式
      }
    })
      viewer.entities.add({
         id: `AINow-line-${index}`,
         polyline: {
            width: 4,
            width: 2,
            positions: positionsList,
            material: new Cesium.Color(27/255, 179/255, 255/255, 1.0),
            material: index === 0 ? new Cesium.Color(2/255, 192/255, 255/255, 1) : new Cesium.Color(27/255, 179/255, 255/255, 0.4),
            clampToGround: false,
         },
      })
@@ -205,6 +246,7 @@
  size: 10
});
const isCheckAll = ref(false);
// 获取飞机列表
const getFJList = async () => {
   let pageParams = ref({
@@ -215,10 +257,27 @@
   const res = await getFlyingNestBy(pageParams.value, pagingParams.value)
   list.value = (res.data?.data || []).map(item => ({
      ...item,
      checked: false,
      minute: _.round(item.estimated_arrival_time / 60, 0),
   }))
   if (!list.value.length) ElMessage.warning('附近暂无可用无人机')
   renderingLine()
}
// 单个选择框变化
const handleItemCheck = () => {
  const allChecked = list.value.every(item => item.checked)
  const someChecked = list.value.some(item => item.checked)
  isCheckAll.value = allChecked
  params.value.dock_sns = list.value.filter(item => item.checked).map(item => item.device_sn)
}
// 全选
const checkedAll = () => {
   list.value.forEach(item => {
      item.checked = isCheckAll.value
   })
   params.value.dock_sns = isCheckAll.value ? list.value.map(item => item.device_sn) : []
}
const initMap = () => {
@@ -240,6 +299,8 @@
   list.value = []
   eventPoint = {}
   store.commit('setFootActiveIndex', 0)
   // 显示相关的按钮
   store.commit('setHideBottomIcon', true)
}
onBeforeUnmount(() => {
@@ -292,91 +353,102 @@
    :deep(.el-select),
    :deep(.el-select__wrapper) {
      background-color: #021740;
      box-shadow: 0 0 0 1px #026AD6;
      &.is-focus {
        box-shadow: 0 0 0 1px #026AD6;
      }
    }
:deep(.el-tag, .el-tag.el-tag--primary),
:deep(.el-tag.el-tag--info) {
    --el-tag-bg-color: none !important;
     --el-tag-border-color: none !important;
    --el-tag-hover-color: none !important;
}
    :deep(.el-input__wrapper.is-disabled) {
      background-color: #021740;
      box-shadow: 0 0 0 1px #026AD6;
    }
      .event {
         display: flex;
         img {
            width: 40px;
            height: 34px;
            margin-right: 10px;
         }
         .img-close {
            position: relative;
            .close {
               cursor: pointer;
               width: 8px;
               height: 8px;
               position: absolute;
               top: -8px;
               right: 1px;
            }
         }
         .add-event {
            width: 38px;
            height: 38px;
            background: rgba(83,179,255,0.16);
            border-radius: 8px 8px 8px 8px;
            border: 1px dashed;
            text-align: center;
            line-height: 38px;
            color: #11C4FF;
            position: relative;
            cursor: pointer;
            // border-image: linear-gradient(180deg, rgba(17, 196, 255, 1), rgba(255, 255, 255, 1)) 1 1;
            .event-select {
               z-index: 10;
               position: absolute;
               top: 40px;
               width: 72px;
               height: 70px;
               background: #0F1929;
               box-shadow: inset 0px -50px 50px 0px rgba(27,148,255,0.13);
               border-radius: 8px 8px 8px 8px;
               border: 1px solid #51A8FF;
               text-align: center;
               color: #D3E9FF;
               .photo {
                  height: 36px;
                  border-bottom: 1px solid #51A8FF;
               }
            }
         }
      }
   }
   .title-list {
      padding: 0 0 14px 11px;
   }
   .el-table {
      width: 300px;
      height: 120px;
      margin: 0 0 0 11px;
      overflow: hidden;
      :deep(.el-scrollbar__wrap) {
         overflow-x: hidden !important;
      }
      :deep(.el-table__body-wrapper) {
         overflow-x: hidden !important;
      }
      :deep(.el-table__header-wrapper) {
         th {
            font-size: 12px;
            color: #D3E9FF;
            background-color: #122348;
            font-weight: normal;
            border-bottom: none;
   .tabledata {
      min-height: 120px;
      border: 1px dashed #fff;
      margin: 0px 10px;
      .table-content {
         padding: 0 8px;
         display: flex;
         justify-content: space-between;
         align-items: center;
         &:not(:last-child) {
            border-bottom: 1px dashed #fff;
         }
      }
      :deep(.el-table__empty-block) {
         background-color: #0A1734;
         height: auto !important;  // 移除固定高度
       min-height: 60px;        // 设置最小高度
         .el-table__empty-text {
            color: #FFFFFF;
         }
      }
      :deep(.el-table__body) {
         background-color: #0A1734;
         tr {
            background-color: #0A1734 !important;
            color: #FFFFFF;
            &:hover > td {
               background-color: #0A1734 !important;
            }
         }
      }
      :deep(.el-scrollbar) {
         background-color: #0A1734;
      .table-item {
         width: 100px;
         text-align: center;
         height: 32px;
         line-height: 32px;
         overflow: hidden;
         text-overflow: ellipsis;
         white-space: nowrap;
      }
   }
   .btn-submit {
      cursor: pointer;
      margin-left: 88px;
      margin-top: 12px;
      img { width: 138px; height: 38px; }
   }
   :deep(.el-table__inner-wrapper) {
    border: 1px dashed #2F497D;
    &::before {
      display: none;
    }
  }
  :deep(.el-table__cell) {
    border: none;
  }
  :deep(.el-table__border) {
    display: none;
  }
}
</style>