From 7319ec49da9f1490ad35f47e0da62546d1cc7ff4 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Tue, 27 Jan 2026 18:05:34 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
applications/drone-command/src/views/dataCockpit/components/RealWarning.vue | 130 +++++--------------------------------------
1 files changed, 16 insertions(+), 114 deletions(-)
diff --git a/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue b/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue
index 132e7a2..09d99e6 100644
--- a/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue
+++ b/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue
@@ -2,137 +2,39 @@
* @Author : yuan
* @Date : 2026-01-08 09:29:07
* @LastEditors : yuan
- * @LastEditTime : 2026-01-26 09:59:52
+ * @LastEditTime : 2026-01-27 14:49:56
* @FilePath : \applications\drone-command\src\views\dataCockpit\components\RealWarning.vue
* @Description :
* Copyright 2026 OBKoro1, All Rights Reserved.
* 2026-01-08 09:29:07
-->
<template>
- <div
- class="real-warning"
- v-loading="loading"
- element-loading-background="rgba(5, 5, 15, 0.6)"
- element-loading-text="加载中..."
- >
+ <div class="real-warning" v-loading="props.loading" element-loading-background="rgba(5, 5, 15, 0.6)"
+ element-loading-text="加载中...">
<div class="list-content">
- <EmptyState v-if="!realWarningData.length" />
- <RealTemplate
- v-else
- v-for="(item, ind) in realWarningData"
- :key="ind"
- :data="item"
- @signal="() => handleAction('signal', item)"
- @counter="() => handleAction('counter', item)"
- @favorite="() => handleFavorite(item)"
- />
+ <EmptyState v-if="!props.data.length && !props.loading" />
+ <RealTemplate v-else v-for="(item, ind) in props.data" :key="ind" :data="item"
+ @signal="emit('signal', item)" @counter="emit('counter', item)" @favorite="emit('favorite', item)" />
</div>
</div>
</template>
<script setup>
import RealTemplate from './templateComponents/RealTemplate.vue'
-import {
- alarmLogApi,
- alarmFavoriteRemoveApi,
- alarmFavoriteSaveApi,
- interferenceAndExpulsionApi
-} from '@/api/dataCockpit'
-import { onMounted, ref } from 'vue'
import EmptyState from './EmptyState.vue'
-import { ElMessage } from 'element-plus'
-const realWarningData = ref([])
-const loading = ref(true)
-const minLoadingMs = 400
-
-const actionTextMap = {
- signal: '信号干扰',
- 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: getAlarmRecordId(item)
+const props = defineProps({
+ data: {
+ type: Array,
+ default: () => []
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
})
-const handleAction = async (type, item) => {
- const actionText = actionTextMap[type] || '操作'
- try {
- const res = await interferenceAndExpulsionApi(buildPayload(type, item))
- 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 + '失败' })
- }
-}
-
-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 + '失败' })
- }
-}
-
-const fetchRealWarning = async () => {
- const startAt = Date.now()
- loading.value = true
- try {
- const params = { current: 1, size: 20, alarmType: '1' }
- const res = await alarmLogApi(params)
- const records = res?.data?.data?.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) {
- await new Promise((resolve) => setTimeout(resolve, minLoadingMs - elapsed))
- }
- loading.value = false
- }
-}
-
-onMounted(() => {
- fetchRealWarning()
-})
+const emit = defineEmits(['signal', 'counter', 'favorite'])
</script>
<style lang="scss" scoped>
--
Gitblit v1.9.3