From f69eb20ac12fa8af1358f59f7b57e04e39570c54 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Sat, 19 Apr 2025 15:00:58 +0800
Subject: [PATCH] feat:巡检任务列表首次有任务时候加载航线

---
 src/components/CurrentTaskDetails/CurrentTaskDetails.vue |   41 +++++++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/src/components/CurrentTaskDetails/CurrentTaskDetails.vue b/src/components/CurrentTaskDetails/CurrentTaskDetails.vue
index 7cdda60..a935c95 100644
--- a/src/components/CurrentTaskDetails/CurrentTaskDetails.vue
+++ b/src/components/CurrentTaskDetails/CurrentTaskDetails.vue
@@ -1,3 +1,13 @@
+<!--
+ * @Author: shuishen 1109946754@qq.com
+ * @Date: 2025-04-19 13:13:15
+ * @LastEditors: shuishen 1109946754@qq.com
+ * @LastEditTime: 2025-04-19 14:15:02
+ * @FilePath: \command-center-dashboard\src\components\CurrentTaskDetails\CurrentTaskDetails.vue
+ * @Description: 
+ * 
+ * Copyright (c) 2025 by shuishen, All Rights Reserved. 
+-->
 <!--当前任务详情-->
 <template>
 	<el-dialog
@@ -47,11 +57,11 @@
 import { getLiveAiLinkApi } from '@/api/payload'
 import { CURRENT_CONFIG } from '@/utils/http/config'
 import { useDroneWS } from '@/hooks/useDroneWS'
+import { useTaskDetails } from '@/hooks/useTaskDetails/useTaskDetails'
 
 const isAutoControl = ref(true) //是否自动控制
 const lineQuality = ref(1) //1流畅,2标清
 const taskDetailsViewer = ref(null) //地图实例
-let taskDetails = ref({}) //任务详情
 const deviceOsdInfo = computed(() => wsInfo.value?.device_osd)
 const dockSn = computed(() => taskDetails?.value?.device_sns?.[0])
 const droneSn = computed(() => deviceOsdInfo?.value?.data?.sn)
@@ -65,8 +75,15 @@
 const isTakeOff = ref(false) // 是在飞行中
 const isMaxMap = ref(false) //是大地图
 
-const workspace_id = ref('')
-let { wsInfo,removeWS } = useDroneWS(workspace_id) //ws信息,是一个ref对象
+// 获取机巢直播
+const getDeviceLiveUrl = async () => {
+	const res = await liveStart(dockSn.value, 2)
+	currentLiveUrl.value = res.data.data.rtcs_url
+}
+
+let { taskDetails, workspace_id, getTaskDetails } = useTaskDetails(getDeviceLiveUrl)
+let { wsInfo, removeWS } = useDroneWS(workspace_id) //ws信息,是一个ref对象
+
 watch(
 	wsInfo,
 	() => {
@@ -88,12 +105,6 @@
 provide('trueAltitude', trueAltitude)
 provide('isAiLive', isAiLive)
 provide('video_id', video_id)
-
-// 获取机巢直播
-const getDeviceLiveUrl = async () => {
-	const res = await liveStart(dockSn.value, 2)
-	currentLiveUrl.value = res.data.data.rtcs_url
-}
 
 const getAiLiveUrl = async () => {
 	const res = await getLiveAiLinkApi({
@@ -129,19 +140,9 @@
 	isTakeOff.value = currentIsTakeOff
 	isTakeOff.value ? await getDroneLiveUrl() : await getDeviceLiveUrl()
 }
-// 获取任务详情获取航线文件
-const getTaskDetails = () => {
-	if (!props.id) ElMessage.warning('请检查是否传入id')
-	getJobDetails({ wayLineJobInfoId: props.id }).then(async res => {
-		taskDetails.value = res.data.data
-		await getDeviceLiveUrl()
-		taskDetails.value.workspace_id = taskDetails.value.way_lines[0]?.workspace_id
-		workspace_id.value = taskDetails.value.workspace_id
-	})
-}
 
 onMounted(() => {
-	getTaskDetails()
+	getTaskDetails(props?.id)
 	EventBus.on('CurrentTaskDetails-timeStop', changeLineQuality)
 	EventBus.on('CurrentTaskDetails-getAiLiveUrl', getAiLiveUrl)
 	EventBus.on('CurrentTaskDetails-getDroneLiveUrl', getDroneLiveUrl)

--
Gitblit v1.9.3