Commit a35340e1 authored by 张宏's avatar 张宏

222

parent 7a77a537
......@@ -65,6 +65,18 @@ class MonitoringMockData {
static List<AlertInfoBO> getMockAlerts() {
return const [
AlertInfoBO(
title: '设备告警',
description: '温度高于阈值26℃,当前温度29℃',
time: '2026-05-04 16:22:49',
status: '待处理',
),
AlertInfoBO(
title: '温度异常',
description: '2023年2月,华为云集中发布了三款软件开发工具:需求管理服务 CodeArts Req、测试管理服务 CodeArts TestPlan、代码检查服务 CodeArts Check。随着 CodeArts 不断的丰富与发展,华为云在 DevSecOps 领域的布局又迈出了稳健的一步。 [22]2023年2月14日,华为云发布分布式编译构建系统 CodeArts Build,旨在支撑企业实现高效的软件开发,缩短产品上市周期,帮助企业的软件产品快速形成关键竞争力。',
time: '2026-05-04 16:22:49',
status: '已处理',
),
AlertInfoBO(
title: '温度异常',
description: '温度高于阈值26℃,当前温度29℃',
time: '2026-05-04 16:22:49',
......
......@@ -1039,7 +1039,7 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
/// 清除选中的告警(用于关闭弹窗)
void clearSelectedAlert() {
if (isClosed) return;
emit(state.copyWith(selectedAlert: null));
emit(state.copyWith(clearSelectedAlert: true));
}
/// 标记告警为已处理
......
......@@ -145,6 +145,7 @@ class MonitoringIndexState extends Equatable {
bool clearLatestMcuReport = false,
bool clearPatientInfo = false,
bool clearMqttDeviceSn = false,
bool clearSelectedAlert = false,
}) {
return MonitoringIndexState(
status: status ?? this.status,
......@@ -182,7 +183,9 @@ class MonitoringIndexState extends Equatable {
clearMqttDeviceSn ? null : mqttDeviceSn ?? this.mqttDeviceSn,
cabinCameraSn: cabinCameraSn ?? this.cabinCameraSn,
cabinWifiPwd: cabinWifiPwd ?? this.cabinWifiPwd,
selectedAlert: selectedAlert ?? this.selectedAlert,
selectedAlert: clearSelectedAlert
? null
: selectedAlert ?? this.selectedAlert,
);
}
......
......@@ -271,7 +271,9 @@ class _MonitoringIndexContentState extends State<MonitoringIndexContent> {
value: _monitoringIndexCubit,
child: MonitoringAlertDetailDialog(alert: alert),
),
).then((_) {
).whenComplete(() {
// 使用 whenComplete 替代 then,确保无论 Future 成功或失败都会清理状态,
// 防止 _currentDialogAlert 锁死导致后续点击永远无法弹出 dialog
_currentDialogAlert = null;
_monitoringIndexCubit.clearSelectedAlert();
});
......
......@@ -75,13 +75,24 @@ class MonitoringAlertCard extends StatelessWidget {
itemBuilder: (context, index) {
final item = alerts[index];
final pending = item.status.contains('待处理');
return _buildAlertItem(context, item, pending);
return _buildAlertItem(
context,
item,
pending,
key: ValueKey('${item.title}_${item.time}_$index'),
);
},
);
}
Widget _buildAlertItem(BuildContext context, AlertInfoBO item, bool pending) {
Widget _buildAlertItem(
BuildContext context,
AlertInfoBO item,
bool pending, {
Key? key,
}) {
return InkWell(
key: key,
onTap: () => context.read<MonitoringIndexCubit>().selectAlert(item),
borderRadius: BorderRadius.circular(16.r),
child: IntrinsicHeight(
......
......@@ -33,15 +33,23 @@ class MonitoringAlertDetailDialog extends StatelessWidget {
),
borderRadius: BorderRadius.circular(20.r),
),
child: Column(
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildHeader(),
SizedBox(height: 30.h),
_buildContent(context),
_buildDesc(),
SizedBox(height: 60.h),
_buildBottomButtons(context),
],
),
Positioned(
left: 0,
right: 0,
bottom: 40.h,
child: _buildBottomButtons(context),
),
],
),
);
......@@ -64,7 +72,7 @@ class MonitoringAlertDetailDialog extends StatelessWidget {
Text(
'告警详情',
style: TextStyle(
color: const Color(0xFF00D4FF),
color: Colors.white,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
),
......@@ -142,15 +150,14 @@ class MonitoringAlertDetailDialog extends StatelessWidget {
width: double.infinity,
padding: EdgeInsets.only(left: 60.w,right: 60.w),
decoration: BoxDecoration(
border: Border.all(
color: Colors.red,
width: 1.w,
),
// border: Border.all(
// color: Colors.red,
// width: 1.w,
// ),
),
child: SingleChildScrollView(
child: Text(
// alert.description,
"2023年2月,华为云集中发布了三款软件开发工具:需求管理服务 CodeArts Req、测试管理服务 CodeArts TestPlan、代码检查服务 CodeArts Check。随着 CodeArts 不断的丰富与发展,华为云在 DevSecOps 领域的布局又迈出了稳健的一步。 [22]2023年2月14日,华为云发布分布式编译构建系统 CodeArts Build,旨在支撑企业实现高效的软件开发,缩短产品上市周期,帮助企业的软件产品快速形成关键竞争力。",
alert.description,
style: TextStyle(
color: Color(0xFFB1F0FF),
fontSize: 24.sp,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment