| 
									
										
										
										
											2025-07-16 18:07:10 +08:00
										 |  |  |  | import 'dart:ui'; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  |  | import 'package:qhd_prevention/customWidget/danner_repain_item.dart'; | 
					
						
							|  |  |  |  | import 'package:qhd_prevention/customWidget/department_picker.dart'; | 
					
						
							|  |  |  |  | import 'package:qhd_prevention/customWidget/search_bar_widget.dart'; | 
					
						
							|  |  |  |  | import 'package:qhd_prevention/pages/home/scan_page.dart'; | 
					
						
							|  |  |  |  | import 'package:qhd_prevention/pages/home/work/risk_list_page.dart'; | 
					
						
							|  |  |  |  | import 'package:qhd_prevention/pages/my_appbar.dart'; | 
					
						
							|  |  |  |  | import 'package:qhd_prevention/tools/SmallWidget.dart'; | 
					
						
							|  |  |  |  | import 'package:qhd_prevention/tools/tools.dart'; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-24 20:01:23 +08:00
										 |  |  |  | import '../../http/ApiService.dart'; | 
					
						
							| 
									
										
										
										
											2025-07-16 18:07:10 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | class AiAlarmPage extends StatefulWidget { | 
					
						
							|  |  |  |  |   const AiAlarmPage({super.key}); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   @override | 
					
						
							|  |  |  |  |   _AiAlarmPageState createState() => _AiAlarmPageState(); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | class _AiAlarmPageState extends State<AiAlarmPage> | 
					
						
							|  |  |  |  |     with SingleTickerProviderStateMixin { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   late List<dynamic> _list = []; | 
					
						
							|  |  |  |  |   int pageNum = 1; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   // 模拟数据
 | 
					
						
							|  |  |  |  |   final List<NotificationItem> _notifications = List.generate(10, (i) { | 
					
						
							|  |  |  |  |     bool read = i % 3 == 0; | 
					
						
							|  |  |  |  |     String title = '测试数据标题标题 ${i + 1}'; | 
					
						
							|  |  |  |  |     String time = '2025-06-${10 + i} 12:3${i}'; | 
					
						
							|  |  |  |  |     return NotificationItem(title, time); | 
					
						
							|  |  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2025-07-24 11:18:47 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-16 18:07:10 +08:00
										 |  |  |  |   final TextEditingController _searchController = TextEditingController(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   @override | 
					
						
							|  |  |  |  |   void initState() { | 
					
						
							|  |  |  |  |     super.initState(); | 
					
						
							|  |  |  |  |       _getAiAlarmList(""); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   @override | 
					
						
							|  |  |  |  |   void dispose() { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     super.dispose(); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   void _handleItemTap(NotificationItem item, int index) { | 
					
						
							|  |  |  |  |     print("点击了是: ${item.title}"); | 
					
						
							| 
									
										
										
										
											2025-07-31 21:15:00 +08:00
										 |  |  |  |     // pushPage(RiskListPage(), context);
 | 
					
						
							| 
									
										
										
										
											2025-07-16 18:07:10 +08:00
										 |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   // 显示分类选择器
 | 
					
						
							|  |  |  |  |   void showCategoryPicker() { | 
					
						
							|  |  |  |  |     showModalBottomSheet( | 
					
						
							|  |  |  |  |       context: context, | 
					
						
							|  |  |  |  |       isScrollControlled: true, | 
					
						
							|  |  |  |  |       barrierColor: Colors.black54, | 
					
						
							|  |  |  |  |       backgroundColor: Colors.transparent, | 
					
						
							|  |  |  |  |       builder: | 
					
						
							| 
									
										
										
										
											2025-07-24 11:18:47 +08:00
										 |  |  |  |           (ctx) => DepartmentPicker(onSelected: (id, name) { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |           }), | 
					
						
							| 
									
										
										
										
											2025-07-16 18:07:10 +08:00
										 |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   Future<void> _getAiAlarmList(String keyWord) async { | 
					
						
							| 
									
										
										
										
											2025-08-08 11:05:06 +08:00
										 |  |  |  |     // LoadingDialogHelper.show();
 | 
					
						
							| 
									
										
										
										
											2025-07-16 18:07:10 +08:00
										 |  |  |  |     try { | 
					
						
							|  |  |  |  |       final result = await ApiService.getAiAlarmList("-1", pageNum.toString(),keyWord); | 
					
						
							|  |  |  |  |       if (result['result'] == 'success') { | 
					
						
							|  |  |  |  |         final List<dynamic> newList = result['varList'] ?? []; | 
					
						
							|  |  |  |  |         setState(() { | 
					
						
							|  |  |  |  |           _list.addAll(newList); | 
					
						
							|  |  |  |  |         }); | 
					
						
							|  |  |  |  |       } | 
					
						
							|  |  |  |  |     } catch (e) { | 
					
						
							|  |  |  |  |       print('加载出错: $e'); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   @override | 
					
						
							|  |  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |  |     return Scaffold( | 
					
						
							|  |  |  |  |       appBar: MyAppbar( | 
					
						
							|  |  |  |  |         title: "AI报警", | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       body: SafeArea( | 
					
						
							|  |  |  |  |         child: Column( | 
					
						
							|  |  |  |  |           children: [ | 
					
						
							|  |  |  |  |             // Search bar
 | 
					
						
							|  |  |  |  |             Padding( | 
					
						
							|  |  |  |  |               padding: const EdgeInsets.all(10), | 
					
						
							|  |  |  |  |               child: SearchBarWidget( | 
					
						
							|  |  |  |  |                 showResetButton: true, | 
					
						
							|  |  |  |  |                 onInputTap: () { | 
					
						
							|  |  |  |  |                   showCategoryPicker(); | 
					
						
							|  |  |  |  |                 }, | 
					
						
							|  |  |  |  |                 hintText: "", | 
					
						
							|  |  |  |  |                 isClickableOnly: true, | 
					
						
							|  |  |  |  |                 onSearch: (text) { | 
					
						
							|  |  |  |  |                   // print('----------');
 | 
					
						
							|  |  |  |  |                   _getAiAlarmList(text); | 
					
						
							|  |  |  |  |                 }, | 
					
						
							|  |  |  |  |                 controller: _searchController, | 
					
						
							|  |  |  |  |               ), | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             // List
 | 
					
						
							|  |  |  |  |             Expanded( | 
					
						
							|  |  |  |  |               child: _list.isEmpty | 
					
						
							| 
									
										
										
										
											2025-07-28 14:22:07 +08:00
										 |  |  |  |                   ? NoDataWidget.show() | 
					
						
							| 
									
										
										
										
											2025-07-16 18:07:10 +08:00
										 |  |  |  |                   : ListView.separated( | 
					
						
							|  |  |  |  |                   itemCount: _notifications.length, | 
					
						
							|  |  |  |  |                   separatorBuilder: (_, __) => const SizedBox(), | 
					
						
							|  |  |  |  |                   itemBuilder: (context, index) { | 
					
						
							|  |  |  |  |                     // NotificationItem item = _notifications[index];
 | 
					
						
							|  |  |  |  |                     // return GestureDetector(
 | 
					
						
							|  |  |  |  |                     //   onTap: () => _handleItemTap(item, index),
 | 
					
						
							|  |  |  |  |                     //   child: DannerRepainItem(
 | 
					
						
							|  |  |  |  |                     //     title: '测试--------new',
 | 
					
						
							|  |  |  |  |                     //     details: [
 | 
					
						
							|  |  |  |  |                     //       '清单类型:测试',
 | 
					
						
							|  |  |  |  |                     //       '排查周期:测试',
 | 
					
						
							|  |  |  |  |                     //       '包含检查项:3',
 | 
					
						
							|  |  |  |  |                     //       '负责人:是测试',
 | 
					
						
							|  |  |  |  |                     //       '起始时间:2025-6-20',
 | 
					
						
							|  |  |  |  |                     //       '',
 | 
					
						
							|  |  |  |  |                     //       '测试一下是否跳过时间',
 | 
					
						
							|  |  |  |  |                     //     ],
 | 
					
						
							|  |  |  |  |                     //     showBottomTags: true,
 | 
					
						
							|  |  |  |  |                     //     bottomTags: [
 | 
					
						
							|  |  |  |  |                     //       riskTagText(1, "重大风险:0"),
 | 
					
						
							|  |  |  |  |                     //       riskTagText(2, "较大:3"),
 | 
					
						
							|  |  |  |  |                     //       riskTagText(3, "一般:1"),
 | 
					
						
							|  |  |  |  |                     //       riskTagText(4, "低:0"),
 | 
					
						
							|  |  |  |  |                     //     ],
 | 
					
						
							|  |  |  |  |                     //   ),
 | 
					
						
							|  |  |  |  |                     // );
 | 
					
						
							|  |  |  |  |                   }, | 
					
						
							|  |  |  |  |                 ), | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |           ], | 
					
						
							|  |  |  |  |         ), | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // 模拟数据模版
 | 
					
						
							|  |  |  |  | class NotificationItem { | 
					
						
							|  |  |  |  |   final String title; | 
					
						
							|  |  |  |  |   final String time; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   NotificationItem(this.title, this.time); | 
					
						
							|  |  |  |  | } |