From a4201c87e9428d230d3778a940c2cbb114efd89a Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Tue, 27 Jan 2026 08:45:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
applications/drone-command/src/views/dataCockpit/components/RealWarning.vue | 63 +++++++++++++++++++++++++++----
1 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue b/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue
index e40f246..132e7a2 100644
--- a/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue
+++ b/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue
@@ -2,7 +2,7 @@
* @Author : yuan
* @Date : 2026-01-08 09:29:07
* @LastEditors : yuan
- * @LastEditTime : 2026-01-19 11:31:09
+ * @LastEditTime : 2026-01-26 09:59:52
* @FilePath : \applications\drone-command\src\views\dataCockpit\components\RealWarning.vue
* @Description :
* Copyright 2026 OBKoro1, All Rights Reserved.
@@ -24,7 +24,7 @@
:data="item"
@signal="() => handleAction('signal', item)"
@counter="() => handleAction('counter', item)"
- @favorite="() => console.log('收藏', item.id)"
+ @favorite="() => handleFavorite(item)"
/>
</div>
</div>
@@ -32,7 +32,12 @@
<script setup>
import RealTemplate from './templateComponents/RealTemplate.vue'
-import { alarmLogApi, interferenceAndExpulsionApi } from '@/api/dataCockpit'
+import {
+ alarmLogApi,
+ alarmFavoriteRemoveApi,
+ alarmFavoriteSaveApi,
+ interferenceAndExpulsionApi
+} from '@/api/dataCockpit'
import { onMounted, ref } from 'vue'
import EmptyState from './EmptyState.vue'
import { ElMessage } from 'element-plus'
@@ -46,9 +51,23 @@
counter: '诱导驱离'
}
+
+const getAlarmRecordId = (item) => item?.alarmRecordId ?? item?.id
+const getFavoriteId = (item) =>
+ item?.favoriteId ??
+ item?.alarmFavoriteId ??
+ item?.fwAlarmFavoriteId ??
+ item?.favoriteRecordId ??
+ getAlarmRecordId(item)
+
+const isFavorited = (item) => {
+ const value = item?.favorited ?? item?.isFavorite
+ return value === 1 || value === '1' || value === true
+}
+
const buildPayload = (type, item) => ({
counterWay: type === 'signal' ? 1 : type === 'counter' ? 2 : '',
- alarmRecordId: item?.alarmRecordId ?? item?.id
+ alarmRecordId: getAlarmRecordId(item)
})
const handleAction = async (type, item) => {
@@ -56,13 +75,36 @@
try {
const res = await interferenceAndExpulsionApi(buildPayload(type, item))
if (res?.data?.success) {
- ElMessage({ type: 'success', message: `${actionText}成功` })
+ ElMessage({ type: 'success', message: actionText + '成功' })
await fetchRealWarning()
} else {
- ElMessage({ type: 'error', message: res?.data?.msg || `${actionText}失败` })
+ ElMessage({ type: 'error', message: res?.data?.msg || actionText + '失败' })
}
} catch (error) {
- ElMessage({ type: 'error', message: `${actionText}失败` })
+ ElMessage({ type: 'error', message: actionText + '失败' })
+ }
+}
+
+const handleFavorite = async (item) => {
+ const alarmRecordId = getAlarmRecordId(item)
+ if (!alarmRecordId) {
+ ElMessage({ type: 'warning', message: '缺少告警记录ID' })
+ return
+ }
+ const isFavorite = isFavorited(item)
+ const actionText = isFavorite ? '取消关注' : '关注'
+ try {
+ const res = isFavorite
+ ? await alarmFavoriteRemoveApi(getFavoriteId(item))
+ : await alarmFavoriteSaveApi({ alarmRecordId })
+ if (res?.data?.success) {
+ ElMessage({ type: 'success', message: actionText + '成功' })
+ await fetchRealWarning()
+ } else {
+ ElMessage({ type: 'error', message: res?.data?.msg || actionText + '失败' })
+ }
+ } catch (error) {
+ ElMessage({ type: 'error', message: actionText + '失败' })
}
}
@@ -73,7 +115,12 @@
const params = { current: 1, size: 20, alarmType: '1' }
const res = await alarmLogApi(params)
const records = res?.data?.data?.records ?? []
- realWarningData.value = records
+ realWarningData.value = records.map((record) => ({
+ ...record,
+ isFavorite:
+ record?.isFavorite ??
+ (record?.favorited === 1 || record?.favorited === '1')
+ }))
} finally {
const elapsed = Date.now() - startAt
if (elapsed < minLoadingMs) {
--
Gitblit v1.9.3