| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							| 
									
										
										
										
											2025-09-10 15:50:05 +08:00
										 |  |  | import 'package:qhd_prevention/customWidget/toast_util.dart'; | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  | import 'package:qhd_prevention/pages/my_appbar.dart'; | 
					
						
							| 
									
										
										
										
											2025-09-08 17:53:44 +08:00
										 |  |  | import 'package:qhd_prevention/tools/tools.dart'; | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  | import '../../http/ApiService.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  | class UserinfoPage extends StatefulWidget { | 
					
						
							|  |  |  |   const UserinfoPage({super.key}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   State<UserinfoPage> createState() => _UserinfoPageState(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _UserinfoPageState extends State<UserinfoPage> { | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Map<String, dynamic> user = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     // TODO: implement initState
 | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _getUserInfo(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> _getUserInfo() async { | 
					
						
							|  |  |  |     try { | 
					
						
							| 
									
										
										
										
											2025-09-08 17:53:44 +08:00
										 |  |  |       LoadingDialogHelper.show(); | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |       final result = await ApiService.getUserInfo(); | 
					
						
							| 
									
										
										
										
											2025-09-08 17:53:44 +08:00
										 |  |  |       LoadingDialogHelper.hide(); | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |       if (result['result'] == 'success') { | 
					
						
							|  |  |  |         setState(() { | 
					
						
							|  |  |  |            user= result['pd']; | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       }else{ | 
					
						
							| 
									
										
										
										
											2025-09-10 15:50:05 +08:00
										 |  |  |         ToastUtil.showNormal(context, "加载数据失败"); | 
					
						
							|  |  |  |         // _showMessage('加载数据失败');
 | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |       } | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							| 
									
										
										
										
											2025-09-08 17:53:44 +08:00
										 |  |  |       LoadingDialogHelper.hide(); | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |       // 出错时可以 Toast 或者在页面上显示错误状态
 | 
					
						
							|  |  |  |       print('加载数据失败:$e'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     return Scaffold( | 
					
						
							|  |  |  |       appBar: MyAppbar(title: "人员信息"), | 
					
						
							|  |  |  |       body: SafeArea( | 
					
						
							|  |  |  |         child: ListView( | 
					
						
							|  |  |  |           children: [ | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |             _userItemCell("姓名", user["NAME"]??"", false), | 
					
						
							|  |  |  |             Divider(height: 1), | 
					
						
							|  |  |  |             _userItemCell("性别", user["SEX_NAME"]??"", false), | 
					
						
							|  |  |  |             Divider(height: 1), | 
					
						
							|  |  |  |             _userItemCell("部门", user["DEPARTMENT_NAME"]??"", false), | 
					
						
							|  |  |  |             Divider(height: 1), | 
					
						
							| 
									
										
										
										
											2025-08-27 16:14:10 +08:00
										 |  |  |             _userItemCell("岗位(工种)", user["POST_NAME"]??"", true), | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |             Divider(height: 1), | 
					
						
							|  |  |  |             _userItemCell("人员类型", user["PERSONNEL_TYPE_NAME"]??"", false), | 
					
						
							|  |  |  |             Divider(height: 1), | 
					
						
							|  |  |  |             _userItemCell("入职时间", user["ENTRY_DATE"]??"", false), | 
					
						
							|  |  |  |             Divider(height: 1), | 
					
						
							| 
									
										
										
										
											2025-08-27 16:14:10 +08:00
										 |  |  |             // _userItemCell("工种", user["TYPE_OF_WORK_NAME"]??"", false),
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |           ], | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget _userItemCell(final String title, final String detail, bool isLast) { | 
					
						
							|  |  |  |     return Container( | 
					
						
							|  |  |  |       padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 15), | 
					
						
							|  |  |  |       decoration: | 
					
						
							|  |  |  |           isLast | 
					
						
							|  |  |  |               ? const BoxDecoration( | 
					
						
							|  |  |  |                 color: Colors.white, | 
					
						
							|  |  |  |                 border: Border( | 
					
						
							|  |  |  |                   bottom: BorderSide(color: Colors.grey, width: 0), | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |               ) | 
					
						
							|  |  |  |               : const BoxDecoration( | 
					
						
							|  |  |  |                 color: Colors.white, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 border: Border( | 
					
						
							|  |  |  |                   bottom: BorderSide(color: Colors.grey, width: 0.5), | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |       child: Row( | 
					
						
							|  |  |  |         mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
					
						
							|  |  |  |         crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							|  |  |  |         children: [ | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |           Text(title, style: const TextStyle(fontSize: 16, )), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |           Flexible( | 
					
						
							|  |  |  |             child: Text( | 
					
						
							|  |  |  |               detail, | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |               style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500,color: Colors.grey), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |               textAlign: TextAlign.right, | 
					
						
							|  |  |  |               maxLines: 2, | 
					
						
							|  |  |  |               overflow: TextOverflow.ellipsis, | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ], | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   void _showMessage(String msg) { | 
					
						
							| 
									
										
										
										
											2025-09-15 15:54:03 +08:00
										 |  |  |     ToastUtil.showNormal(context, msg); | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  | } |