From 98ff0df343bd4e5d2d5e138a02c6db2b7fa9696b Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 27 Jan 2026 10:23:03 +0800
Subject: [PATCH] feat:角色权限弹窗配置页面,调整
---
applications/drone-command/src/views/dataCockpit/components/RealWarning.vue | 115 +++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 79 insertions(+), 36 deletions(-)
diff --git a/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue b/applications/drone-command/src/views/dataCockpit/components/RealWarning.vue
index 7210005..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-08 14:49: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.
@@ -15,28 +15,35 @@
element-loading-background="rgba(5, 5, 15, 0.6)"
element-loading-text="加载中..."
>
- <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="() => console.log('收藏', item.id)"
- />
+ <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)"
+ />
+ </div>
</div>
</template>
<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'
const realWarningData = ref([])
-const loading = ref(false)
+const loading = ref(true)
const minLoadingMs = 400
const actionTextMap = {
@@ -44,37 +51,60 @@
counter: '诱导驱离'
}
-const buildPayload = (item) => ({
- alarmRecordId: item.id,
- areaCode: item.areaCode,
- counterEffect: '',
- coverRadiusM: item.coverRadiusM,
- deployLatitude: item.latitude,
- deployLongitude: item.longitude,
- deviceCode: item.deviceCode,
- deviceId: item.deviceId,
- deviceModel: item.deviceModel,
- deviceName: item.deviceName,
- deviceType: item.deviceType,
- droneDeviceCode: item.droneSerialNo,
- droneName: item.droneName,
- droneType: item.droneType,
- findTime: item.alarmTime,
- id: item.id,
- workMode: ''
+
+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 handleAction = async (type, item) => {
const actionText = actionTextMap[type] || '操作'
try {
- const res = await interferenceAndExpulsionApi(buildPayload(item))
+ 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 + '失败' })
}
}
@@ -85,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) {
@@ -102,8 +137,16 @@
<style lang="scss" scoped>
.real-warning {
+ display: flex;
+ flex-direction: column;
width: 100%;
height: 100%;
+ overflow: hidden;
}
+.list-content {
+ height: 0;
+ flex: 1;
+ overflow-y: auto;
+}
</style>
--
Gitblit v1.9.3