115 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Dart
		
	
	
			
		
		
	
	
			115 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Dart
		
	
	
| import 'package:flutter/material.dart';
 | ||
| import 'package:qhd_prevention/customWidget/toast_util.dart';
 | ||
| import 'package:qhd_prevention/pages/my_appbar.dart';
 | ||
| import 'package:qhd_prevention/tools/tools.dart';
 | ||
| import '../../http/ApiService.dart';
 | ||
| import '/customWidget/search_bar_widget.dart';
 | ||
| 
 | ||
| class LowPage extends StatefulWidget {
 | ||
|   const LowPage({super.key});
 | ||
| 
 | ||
|   @override
 | ||
|   State<LowPage> createState() => _LowPagePageState();
 | ||
| }
 | ||
| 
 | ||
| class _LowPagePageState extends State<LowPage> {
 | ||
|   // 模拟数据
 | ||
|   final List<Map<String, dynamic>> _dataInfos = List.generate(10, (i) {
 | ||
|     return {
 | ||
|       'title': '测试数据标题标题 ${i + 1}',
 | ||
|     };
 | ||
|   });
 | ||
| 
 | ||
|   final TextEditingController _searchController = TextEditingController();
 | ||
|   String treeJson="";
 | ||
| 
 | ||
|   @override
 | ||
|   void initState() {
 | ||
|     // TODO: implement initState
 | ||
|     super.initState();
 | ||
| 
 | ||
|     _getLowList();
 | ||
|   }
 | ||
| 
 | ||
|   Future<void> _getLowList() async {
 | ||
|     try {
 | ||
| 
 | ||
|       final result = await ApiService.getHiddenTreatmentListTree();
 | ||
|       if (result['result'] == 'success') {
 | ||
|         setState(() {
 | ||
|           treeJson= result['zTreeNodes'];
 | ||
|         });
 | ||
| 
 | ||
|       }else{
 | ||
|         ToastUtil.showNormal(context, "加载数据失败");
 | ||
|         // _showMessage('加载数据失败');
 | ||
|       }
 | ||
|     } catch (e) {
 | ||
|       // 出错时可以 Toast 或者在页面上显示错误状态
 | ||
|       print('加载数据失败:$e');
 | ||
|     }
 | ||
|   }
 | ||
| 
 | ||
|   @override
 | ||
|   Widget build(BuildContext context) {
 | ||
|     return Scaffold(
 | ||
|       appBar: MyAppbar(
 | ||
|         title: "法律法规",
 | ||
|       ),
 | ||
|       body: SafeArea(
 | ||
|           child: _vcDetailWidget()
 | ||
|       ),
 | ||
|     );
 | ||
|   }
 | ||
| 
 | ||
|   Widget _vcDetailWidget() {
 | ||
|     return Column(
 | ||
|       children: [
 | ||
|         Padding(
 | ||
|           padding: EdgeInsets.all(10),
 | ||
|           child: SearchBarWidget(
 | ||
|             controller: _searchController,
 | ||
|             onSearch: (keyboard) {
 | ||
|               // 输入请求接口
 | ||
| 
 | ||
|             },
 | ||
|           ),
 | ||
|         ),
 | ||
| 
 | ||
|         // 修复:使用Expanded包裹ListView确保正确高度
 | ||
|         Expanded(
 | ||
|           child: ListView.separated(
 | ||
|             separatorBuilder: (_, __) => const Divider(height: 0.5, color: Colors.black12,),
 | ||
|             itemCount: _dataInfos.length,
 | ||
|             itemBuilder: (context, index) {
 | ||
|               final item = _dataInfos[index];
 | ||
|               return _fxitemCell(item);
 | ||
|             },
 | ||
|           ),
 | ||
|         ),
 | ||
|       ],
 | ||
|     );
 | ||
|   }
 | ||
| 
 | ||
|   Widget _fxitemCell(final item) {
 | ||
|     String title = item['title'];
 | ||
| 
 | ||
|     return Container(
 | ||
|       height: 50,
 | ||
|       color: Colors.white,
 | ||
|       padding: EdgeInsets.symmetric(horizontal: 16), // 添加水平内边距
 | ||
|       child: Row(
 | ||
|         mainAxisAlignment: MainAxisAlignment.spaceBetween,
 | ||
|         children: [
 | ||
|           Text(title), 
 | ||
|           Icon(Icons.arrow_forward_ios, color: Colors.black26,)
 | ||
|         ],
 | ||
|       ),
 | ||
|     );
 | ||
|   }
 | ||
| 
 | ||
|   void _showMessage(String msg) {
 | ||
|     ToastUtil.showNormal(context, msg);
 | ||
|   }
 | ||
| }
 |