Commit a35340e1 authored by 张宏's avatar 张宏

222

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