更新api和路由

This commit is contained in:
2025-11-16 17:34:04 +08:00
parent 646d9d4e23
commit 5df3ec4da9
4 changed files with 342 additions and 7 deletions

View File

@@ -58,6 +58,22 @@ import { Response, SeverityLevel, AlarmSourceType, Operator, AlarmCode, Notifica
* @property {number} thresholds
*/
/**
* @typedef {object} ListAreaThresholdAlarmResponse
* @property {Array<AreaThresholdAlarmDTO>} list
* @property {PaginationDTO} pagination
*/
/**
* @typedef {object} AreaThresholdAlarmsParams
* @property {number} [area_controller_id] - 按区域主控ID过滤
* @property {SeverityLevel} [level] - 按告警等级过滤
* @property {string} [order_by] - 排序字段,例如 "id DESC"
* @property {number} [page]
* @property {number} [page_size]
* @property {SensorType} [sensor_type] - 按传感器类型过滤
*/
/**
* @typedef {object} UpdateAreaThresholdAlarmDTO
* @property {Operator} operator - 新的操作符
@@ -84,6 +100,22 @@ import { Response, SeverityLevel, AlarmSourceType, Operator, AlarmCode, Notifica
* @property {number} thresholds
*/
/**
* @typedef {object} ListDeviceThresholdAlarmResponse
* @property {Array<DeviceThresholdAlarmDTO>} list
* @property {PaginationDTO} pagination
*/
/**
* @typedef {object} DeviceThresholdAlarmsParams
* @property {number} [device_id] - 按设备ID过滤
* @property {SeverityLevel} [level] - 按告警等级过滤
* @property {string} [order_by] - 排序字段,例如 "id DESC"
* @property {number} [page]
* @property {number} [page_size]
* @property {SensorType} [sensor_type] - 按传感器类型过滤
*/
/**
* @typedef {object} UpdateDeviceThresholdAlarmDTO
* @property {Operator} operator - 新的操作符
@@ -147,6 +179,15 @@ export const getActiveAlarms = (params) => {
return http.get('/api/v1/alarm/threshold/active-alarms', { params });
};
/**
* 根据过滤条件和分页参数查询区域阈值告警列表
* @param {AreaThresholdAlarmsParams} params - 查询参数
* @returns {Promise<ListAreaThresholdAlarmResponse>}
*/
export const getAreaThresholdAlarms = (params) => {
return http.get('/api/v1/alarm/threshold/area', { params });
};
/**
* 为指定的区域主控创建一个新的阈值告警规则
* @param {CreateAreaThresholdAlarmDTO} requestBody - 创建区域阈值告警请求体
@@ -184,6 +225,15 @@ export const deleteAreaThresholdAlarm = (task_id) => {
return http.delete(`/api/v1/alarm/threshold/area/${task_id}`);
};
/**
* 根据过滤条件和分页参数查询设备阈值告警列表
* @param {DeviceThresholdAlarmsParams} params - 查询参数
* @returns {Promise<ListDeviceThresholdAlarmResponse>}
*/
export const getDeviceThresholdAlarms = (params) => {
return http.get('/api/v1/alarm/threshold/device', { params });
};
/**
* 为单个设备创建一个新的阈值告警规则
* @param {CreateDeviceThresholdAlarmDTO} requestBody - 创建设备阈值告警请求体
@@ -252,10 +302,12 @@ export const snoozeAlarm = (id, requestBody) => {
export const AlarmApi = {
getActiveAlarms,
getAreaThresholdAlarms,
createAreaThresholdAlarm,
getAreaThresholdAlarmById,
updateAreaThresholdAlarm,
deleteAreaThresholdAlarm,
getDeviceThresholdAlarms,
createDeviceThresholdAlarm,
getDeviceThresholdAlarmById,
updateDeviceThresholdAlarm,

View File

@@ -17,7 +17,7 @@
:collapse="isCollapse"
:collapse-transition="false"
router
:default-openeds="['/device-management', '/monitor', '/pms']"
:default-openeds="['/device-management', '/monitor', '/pms', '/alarm']"
>
<el-menu-item index="/">
<el-icon>
@@ -203,7 +203,18 @@
</el-icon>
<span>告警中心</span>
</template>
<!-- 占位, 后续可添加告警管理和告警配置 -->
<el-menu-item index="/alarms">
<el-icon>
<Warning />
</el-icon>
<template #title>告警管理</template>
</el-menu-item>
<el-menu-item index="/alarms/thresholds">
<el-icon>
<Setting />
</el-icon>
<template #title>阈值告警配置</template>
</el-menu-item>
</el-sub-menu>
</el-menu>
@@ -344,7 +355,7 @@ export default {
const activeMenu = computed(() => {
const path = route.path;
if (path.startsWith('/monitor') || path.startsWith('/pms') || path.startsWith('/devices') || path.startsWith('/device-templates')) {
if (path.startsWith('/monitor') || path.startsWith('/pms') || path.startsWith('/devices') || path.startsWith('/device-templates') || path.startsWith('/alarms')) {
return path;
}
return route.path;
@@ -457,4 +468,4 @@ export default {
font-size: 14px;
border-top: 1px solid #eee;
}
</style>
</style>

View File

@@ -24,12 +24,16 @@ import TaskExecutionLogsView from '../views/monitor/TaskExecutionLogsView.vue';
import UserActionLogsView from '../views/monitor/UserActionLogsView.vue';
import WeighingBatchesView from '../views/monitor/WeighingBatchesView.vue';
import WeighingRecordsView from '../views/monitor/WeighingRecordsView.vue';
import AlarmList from '../views/alarm/AlarmList.vue';
import ThresholdAlarmList from '../views/alarm/ThresholdAlarmList.vue';
const routes = [
{path: '/', component: Home, meta: {requiresAuth: true, title: '系统首页'}},
{path: '/devices', component: DeviceList, meta: {requiresAuth: true, title: '设备管理'}},
{path: '/device-templates', component: DeviceTemplateList, meta: {requiresAuth: true, title: '设备模板管理'}},
{path: '/plans', component: PlanList, meta: {requiresAuth: true, title: '计划管理'}},
{path: '/alarms', component: AlarmList, meta: {requiresAuth: true, title: '告警管理'}},
{path: '/alarms/thresholds', component: ThresholdAlarmList, meta: {requiresAuth: true, title: '阈值告警配置'}},
{path: '/login', component: LoginForm},
{path: '/pms/farm-management', name: 'PigFarmManagement', component: PigFarmManagementView, meta: { requiresAuth: true, title: '栏舍管理' }},
{path: '/pms/batch-management', name: 'PigBatchManagement', component: PigBatchManagementView, meta: { requiresAuth: true, title: '猪群管理' }},