From bdbef0fbde20317d19bfc6d3473dabb10fb3fb3b Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Sat, 19 Apr 2025 15:41:21 +0800
Subject: [PATCH] feat: 修改任务事件概况的饼状图颜色

---
 src/components/CurrentTaskDetails/CurrentTaskDetails.vue |   86 +++++++++++++++++++++++--------------------
 1 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/src/components/CurrentTaskDetails/CurrentTaskDetails.vue b/src/components/CurrentTaskDetails/CurrentTaskDetails.vue
index be5398b..a9d4cdb 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 15:07:04
+ * @FilePath: \command-center-dashboard\src\components\CurrentTaskDetails\CurrentTaskDetails.vue
+ * @Description: 
+ * 
+ * Copyright (c) 2025 by shuishen, All Rights Reserved. 
+-->
 <!--当前任务详情-->
 <template>
 	<el-dialog
@@ -20,9 +30,7 @@
 				<TaskDetailsHead />
 				<TaskDetailsLeft />
 			</template>
-
 			<!--	控制面板,里面有方法需要立即执行,不可用v-if		-->
-			<!--			<ControlPanel />-->
 			<ControlPanel v-show="!isAutoControl" />
 			<img alt="" :src="amplifyImg" class="amplify" @click="isMaxMap = !isMaxMap" />
 		</div>
@@ -47,52 +55,55 @@
 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)
 const trueAltitude = ref('') // 真实高度
 const isAiLive = ref(false) // 是ai直播
 const video_id = ref('') // 直播视频id
-
 const isShow = defineModel('show') // 是否显示当前任务详情
 const props = defineProps(['id'])
 const currentLiveUrl = ref('') // 当前直播地址
 const isTakeOff = ref(false) // 是在飞行中
 const isMaxMap = ref(false) //是大地图
-
-const workspace_id = ref('')
-let wsInfo = useDroneWS(workspace_id) //ws信息,是一个ref对象
-watch(wsInfo, () => {
-	// wsInfo 变化触发
-	setCurrentLiveUrl()
-}, { deep: true })
-provide('wsInfo', wsInfo)
-
-
-provide('isAutoControl', isAutoControl)
-provide('lineQuality', lineQuality)
-provide('taskDetailsViewer', taskDetailsViewer)
-provide('taskDetails', taskDetails)
-provide('deviceOsdInfo', deviceOsdInfo)
-provide('dockOsdInfo', wsInfo?.value?.dock_osd)
-provide('dockSn', dockSn)
-provide('droneSn', droneSn)
-provide('trueAltitude', trueAltitude)
-provide('isAiLive', isAiLive)
-provide('video_id', video_id)
-
-
+const client_id = 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对象
+
+provide('wsInfo', wsInfo)
+provide('deviceOsdInfo', deviceOsdInfo)
+provide('dockOsdInfo', wsInfo?.value?.dock_osd)
+provide('dockSn', dockSn)
+provide('droneSn', droneSn)
+provide('isAutoControl', isAutoControl)
+provide('lineQuality', lineQuality)
+provide('taskDetailsViewer', taskDetailsViewer)
+provide('taskDetails', taskDetails)
+provide('trueAltitude', trueAltitude)
+provide('isAiLive', isAiLive)
+provide('video_id', video_id)
+provide('client_id', client_id)
+
+watch(
+	wsInfo,
+	() => {
+		// wsInfo 变化触发
+		setCurrentLiveUrl()
+	},
+	{ deep: true }
+)
 
 const getAiLiveUrl = async () => {
 	const res = await getLiveAiLinkApi({
@@ -105,11 +116,14 @@
 }
 
 // 获取无人机直播url
-async function getDroneLiveUrl() {
+async function getDroneLiveUrl(reset = false) {
+	currentLiveUrl.value = ''
+	await nextTick()
 	const res = await liveStart(droneSn.value, lineQuality.value)
 	currentLiveUrl.value = res.data.data.rtcs_url
 	video_id.value = res.data.data.video_id
 	isAiLive.value = false
+	reset && ElMessage.success('刷新成功')
 }
 
 // 无人机直播画质切换
@@ -121,26 +135,16 @@
 // 设置当前直播地址
 const setCurrentLiveUrl = async () => {
 	const deviceInfo = deviceOsdInfo.value?.data?.host
-  if (!deviceInfo) return
+	if (!deviceInfo) return
 	const currentIsTakeOff = ![14, 0].includes(deviceInfo?.mode_code)
 	// 如果还是之前的状态,不切换
 	if (isTakeOff.value === currentIsTakeOff) return
 	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)
@@ -218,6 +222,8 @@
 		position: absolute;
 		left: 340px;
 		bottom: 183px;
+		width: 22px;
+		height: 22px;
 	}
 }
 </style>

--
Gitblit v1.9.3