diff --git a/assets/images/videostart.png b/assets/images/videostart.png new file mode 100644 index 0000000..0e90cdd Binary files /dev/null and b/assets/images/videostart.png differ diff --git a/lib/constants/app_enums.dart b/lib/constants/app_enums.dart index c8ec46b..f7c0a21 100644 --- a/lib/constants/app_enums.dart +++ b/lib/constants/app_enums.dart @@ -396,6 +396,9 @@ enum UploadFileType { /// 重点工程隐患视频 - 类型: '173', 路径: 'key_projects_hidden_dangers_video' keyProjectsHiddenDangersVideo('173', 'key_projects_hidden_dangers_video'), + /// 重点工程 隐患整改图片 - 类型: '174', 路径: 'key_homework_rectification_pictures' + keyHomeworkRectificationPictures('174', 'key_homework_rectification_pictures'), + /// 重点工程签字 - 类型: '175', 路径: 'key_homework_signature_inspector' keyHomeworkSignatureInspector('175', 'key_homework_signature_inspector'), diff --git a/lib/customWidget/item_list_widget.dart b/lib/customWidget/item_list_widget.dart index c856e41..0f73eae 100644 --- a/lib/customWidget/item_list_widget.dart +++ b/lib/customWidget/item_list_widget.dart @@ -924,6 +924,7 @@ class ItemListWidget { double fontSize = 14, // 字体大小 Color btnColor = Colors.blue, bool isRequired = false, + bool isShowPoint = true, }) { return Container( padding: const EdgeInsets.symmetric( @@ -935,6 +936,7 @@ class ItemListWidget { children: [ Row( children: [ + if(isShowPoint) Text("* ", style: TextStyle(color: Colors.red)), Text( label, diff --git a/lib/http/modules/key_tasks_api.dart b/lib/http/modules/key_tasks_api.dart index cbacb68..95f9620 100644 --- a/lib/http/modules/key_tasks_api.dart +++ b/lib/http/modules/key_tasks_api.dart @@ -94,5 +94,43 @@ class KeyTasksApi { } + /// 安全环保检查 隐患分页 + static Future> setKeyTasksHiddenDangerList(Map data) { + return HttpManager().request( + '${ApiService.basePath}/keyProject', + '/hidden/list', + method: Method.post, + data: { + ...data + }, + ); + } + + + /// 安全环保检查 隐患详情 + static Future> getKeyTasksHiddenDangerDetail(String id) { + return HttpManager().request( + '${ApiService.basePath}/keyProject', + '/hidden/$id', + method: Method.get, + data: { + // ...data + }, + ); + } + + /// 安全环保检查 隐患整改提交 + static Future> setHiddenDangerRectification(Map data) { + return HttpManager().request( + '${ApiService.basePath}/keyProject', + '/hiddenRectificationRecord/rectification', + method: Method.post, + data: { + ...data + }, + ); + } + + } \ No newline at end of file diff --git a/lib/pages/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_danger_detail.dart b/lib/pages/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_danger_detail.dart new file mode 100644 index 0000000..74d251c --- /dev/null +++ b/lib/pages/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_danger_detail.dart @@ -0,0 +1,1512 @@ +import 'dart:io'; + +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:intl/intl.dart'; +import 'package:open_file/open_file.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:qhd_prevention/constants/app_enums.dart'; +import 'package:qhd_prevention/customWidget/DocumentPicker.dart'; +import 'package:qhd_prevention/customWidget/ItemWidgetFactory.dart'; +import 'package:qhd_prevention/customWidget/MultiDictValuesPicker.dart'; +import 'package:qhd_prevention/customWidget/big_video_viewer.dart'; +import 'package:qhd_prevention/customWidget/bottom_picker_two.dart'; +import 'package:qhd_prevention/customWidget/custom_button.dart'; +import 'package:qhd_prevention/customWidget/department_person_picker.dart'; +import 'package:qhd_prevention/customWidget/department_picker.dart'; +import 'package:qhd_prevention/customWidget/department_picker_three.dart'; +import 'package:qhd_prevention/customWidget/department_picker_two.dart'; +import 'package:qhd_prevention/customWidget/full_screen_video_page.dart'; +import 'package:qhd_prevention/customWidget/item_list_widget.dart'; +import 'package:qhd_prevention/customWidget/photo_picker_row.dart'; +import 'package:qhd_prevention/customWidget/picker/CupertinoDatePicker.dart'; +import 'package:qhd_prevention/customWidget/read_file_page.dart'; +import 'package:qhd_prevention/customWidget/single_image_viewer.dart'; +import 'package:qhd_prevention/customWidget/toast_util.dart'; +import 'package:qhd_prevention/http/ApiService.dart'; +import 'package:qhd_prevention/http/modules/key_tasks_api.dart'; +import 'package:qhd_prevention/pages/home/keyTasks/keyTasksDetail/key_taskes_detail_widget.dart'; +import 'package:qhd_prevention/pages/home/keyTasks/keyTasksDetail/key_taskes_onlylook_detail_page.dart'; +import 'package:qhd_prevention/pages/my_appbar.dart'; +import 'package:qhd_prevention/services/SessionService.dart'; +import 'package:qhd_prevention/tools/h_colors.dart'; +import 'package:qhd_prevention/tools/tools.dart'; +import 'dart:convert'; +import 'package:video_player/video_player.dart'; +import 'package:qhd_prevention/http/modules/safety_check_api.dart'; + +class KeyTasksHiddenDangerDetail extends StatefulWidget { + const KeyTasksHiddenDangerDetail( + this.item, + this.itemId, + this.hiddenId, + this.foreignKey, + this.canChange, { + Key? key, + this.inspectId, + this.inspectCodeId, + }) : super(key: key); + + final item; // 1 隐患整改 2 隐患记录 + final String itemId; + final String hiddenId; + final String foreignKey; + final bool canChange; + final String? inspectId; + final String? inspectCodeId; + + @override + _KeyTasksHiddenDangerDetailState createState() => _KeyTasksHiddenDangerDetailState(); +} + +class _KeyTasksHiddenDangerDetailState extends State { + late Map pd = {}; + + List files = []; + List videoList = []; + List files2 = []; + + List files4 = []; + List files5 = []; //验收图片 + List files6 = []; //安全环保检查验收图片 + List checkList = []; + List files7 = []; + + //隐患整改照片集合 + List> rectifiedPhotosList = []; + + //隐患验收照片集合 + List> acceptancePhotosList = []; + + bool modalShow = false; + VideoPlayerController? _videoController; + + ///隐患确认 + String buMenId = ""; + String buMenName = ""; + String responsibleId = ""; + String responsibleName = ""; + + // 存储各单位的人员列表缓存: key = deptId + final Map>> _personCache = {}; + + String attachmentUp = '处置方案附件'; + // 整改图片 + List gaiHouImages = []; + + + ///隐患验收 + // 是否合格 + bool _hazardAcceptanceQualified = true; + final TextEditingController _acceptanceDescriptionController = + TextEditingController(); + final TextEditingController _replyFeedbackController = + TextEditingController(); + List _acceptanceImages = []; + + // 查看过程记录 + bool _showAllData = false; + + //附件 + late SelectedFile? choosefile = null; + + String title='隐患记录'; + final TextEditingController _descriptionController = TextEditingController(); + + @override + void initState() { + super.initState(); + + switch (widget.item) { + case 1: //隐患整改 + title = "隐患整改"; + hiddenDangerRectification['id']=widget.itemId; + hiddenDangerRectification['foreignKey']=widget.foreignKey; + hiddenDangerRectification['hiddenId']=widget.hiddenId; + + break; + case 2: //隐患记录 + title='隐患记录'; + break; + } + + + _getUserData(); + getData(); + } + + + @override + void dispose() { + _videoController?.dispose(); + super.dispose(); + } + + Future getData() async { + try { + final data = await KeyTasksApi.getKeyTasksHiddenDangerDetail(widget.itemId); + if (data['success']) { + setState(() { + pd = data['data']; + _getImagePath( + widget.hiddenId, + UploadFileType.keyProjectsHiddenDangersPictures, + ); + _getImagePath( + widget.hiddenId, + UploadFileType.keyProjectsHiddenDangersVideo, + ); + if (pd['rectificationRecord'] != null){ + _getImagePath( + widget.itemId, + UploadFileType.keyHomeworkRectificationPictures, + ); + } + + }); + } else { + ToastUtil.showNormal(context, "获取列表失败"); + } + } catch (e) { + print('Error fetching data: $e'); + } + } + + Future _getUserData() async { + try { + final raw = await AuthApi.getUserData(); + if (raw['success']) { + setState(() { + responsibleId = raw['data']['id']; + responsibleName = raw['data']['name']; + buMenId = raw['data']['departmentId']; + buMenName = raw['data']['departmentName']; + }); + } else { + ToastUtil.showNormal(context, "获取个人信息失败"); + } + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载首页数据失败:$e'); + } + } + + Future _getImagePath(id, type) async { + try { + final data = await FileApi.getImagePath(id, type); + if (data['success']) { + setState(() { + List images = data['data'] ?? []; + if (UploadFileType.keyProjectsHiddenDangersPictures == type) { + files.addAll(images); + } else if (UploadFileType.keyProjectsHiddenDangersVideo == type) { + videoList.addAll(images); + }else if (UploadFileType.keyHomeworkRectificationPictures == type) { + files2.addAll(images); + } + + + }); + } else { + // ToastUtil.showNormal(context, "获取图片失败"); + } + } catch (e) { + print('Error fetching data: $e'); + } + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: MyAppbar(title: title), + body: + pd.isEmpty + ? const Center(child: CircularProgressIndicator()) + : _listWidget(), + ); + } + + Widget _listWidget() { + List list = pd["hiddenAcceptUserCO"] ?? []; + + return LayoutBuilder( + builder: (context, constraints) { + return SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints(minHeight: constraints.maxHeight), + child: Padding( + padding: const EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + Card( + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 10, + left: 10, + right: 10, + ), + child: Row( + children: [ + Container( + width: 3, + height: 15, + color: Colors.blue, + ), + const SizedBox(width: 8), + Text( + "检查记录", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + + _buildInfoItem( + '重点作业名称', + pd["projectName"] ?? '', + ), + Divider(height: 1), + ItemListWidget.OneRowButtonTitle( + isShowPoint: false, + label: '安全环保检查信息:', + buttonText: '【关联检查流程】', + onTap: () { + pushPage( + KeyTaskesOnlylookDetailPage(inspectionId: widget.foreignKey ?? '', handleType: SafeCheckDetailMode.detail), + context, + ); + }, + ), + + ], + ), + ), + + //隐患信息 + SizedBox(height: 10), + Card( + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 10, + left: 10, + right: 10, + ), + child: Row( + children: [ + Container( + width: 3, + height: 15, + color: Colors.blue, + ), + const SizedBox(width: 8), + Text( + "隐患信息", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + + _buildInfoItem('隐患来源', _getSourceDangers(pd)), + + Divider(height: 1), + _buildInfoItem('隐患类型', pd['hiddenTypeName'] ?? ''), + + Divider(height: 1), + _buildInfoItem('隐患级别', pd['hiddenLevelName'] ?? ''), + + Divider(height: 1), + _buildInfoItem('隐患状态', _getState(pd)), + + Divider(height: 1), + _buildInfoItem('隐患描述', pd['hiddenDesc'] ?? ''), + + + if ((pd['positionDesc'] ?? '').isNotEmpty) + Divider(height: 1), + if ((pd['positionDesc'] ?? '').isNotEmpty) + _buildInfoItem('隐患位置描述', pd['positionDesc'] ?? ''), + + Divider(height: 1), + _buildInfoItem( + '整改类型', + _getRectificationType(pd['rectificationType']), + ), + + Divider(height: 1), + _buildInfoItem('整改期限', pd['rectificationDeadline'] ?? ''), + + Divider(height: 1), + _buildInfoItem('整改部门', pd['rectificationDepartmentName'] ?? ''), + + Divider(height: 1), + _buildInfoItem('整改人', pd['rectificationUserName'] ?? ''), + + Divider(height: 1), + _buildInfoItem('隐患发现部门', pd['findDepartmentName'] ?? ''), + + Divider(height: 1), + _buildInfoItem('隐患发现人', pd['findUserName'] ?? ''), + + Divider(height: 1), + _buildInfoItem('隐患发现时间', _changeTime(pd['createTime'] ?? ''),), + + + Divider(height: 1), + // 隐患照片 + // const Text('隐患照片', style: TextStyle(fontWeight: FontWeight.bold)), + // _buildImageGrid(files, onTap: (index) => _showImageGallery(files, index)), + ListItemFactory.createTextImageItem( + text: "隐患照片", + imageUrls: + files + .map((item) => item['filePath'].toString()) + .toList(), + horizontalPadding: 10, + onImageTapped: (index) { + presentOpaque( + SingleImageViewer( + imageUrl: '', + imageUrls: + files + .map( + (item) => + ApiService.baseImgPath + + item['filePath'], + ) + .toList(), + initialIndex: index, + ), + context, + ); + }, + ), + + // 隐患视频 + if (videoList.isNotEmpty) ...[ + SizedBox(height: 10), + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Text( + '隐患视频', + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + + GestureDetector( + onTap: () { + showDialog( + context: context, + barrierColor: Colors.black54, + builder: + (_) => VideoPlayerPopup( + videoUrl: + ApiService.baseImgPath + + videoList[0]['filePath'], + ), + ); + }, + child: Image.asset( + 'assets/images/videostart.png', // 替换为你的视频占位图 + color: Colors.blue, + width: 120, + height: 120, + ), + ), + ], + ], + ), + ), + + + // 整改信息(发现人预填) + if (pd['rectificationRecord'] != null) ...[ + SizedBox(height: 10), + // const Divider(height: 10,color: Colors.grey,), + Card( + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 10, + left: 10, + right: 10, + ), + child: Row( + children: [ + Container( + width: 3, + height: 15, + color: Colors.blue, + ), + const SizedBox(width: 8), + Text( + "整改信息", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + + _buildInfoItem( + '整改部门', + pd["rectificationRecord"]['rectificationDepartmentIdName'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '整改人', + pd["rectificationRecord"]['rectificationUserIdName'] ?? '', + ), + + Divider(height: 1), + _buildInfoItem( + '整改时间', + _changeTime( pd["rectificationRecord"]['rectificationTime'] ?? ''), + // pd["rectificationRecord"]['rectificationTime'] ?? '', + ), + + Divider(height: 1), + _buildInfoItem( + '整改描述', + // _changeTime( pd["hiddenUserPresetsCO"]['rectifyDeadline'] ?? ''), + pd["rectificationRecord"]['rectificationDesc'] ?? '', + ), + + ListItemFactory.createTextImageItem( + text: "整改后图片", + imageUrls: + files2.map((item) => item['filePath'].toString()).toList(), + horizontalPadding: 10, + onImageTapped: (index) { + presentOpaque( + SingleImageViewer( + imageUrl: + ApiService.baseImgPath + files2[index]['filePath'], + ), + context, + ); + }, + ), + + ], + ), + ), + ], + + + // // 整改信息 + // if (pd['hiddenRectifyUserCO'] != null && + // (pd["state"] != 100) && + // (widget.item == 6 || widget.item == 7)) ...[ + // SizedBox(height: 10), + // + // // const Divider(height: 10,color: Colors.grey,), + // if (!_showAllData) + // _ectificationInformationItem( + // pd["hiddenRectifyUserCO"][(pd["hiddenRectifyUserCO"] + // .length - + // 1)], + // 0, + // ), + // + // if (_showAllData) + // ListView.builder( + // shrinkWrap: true, // 自适应内容高度 + // physics: const NeverScrollableScrollPhysics(), + // itemCount: pd["hiddenRectifyUserCO"].length, + // itemBuilder: + // (ctx, idx) => _ectificationInformationItem( + // pd["hiddenRectifyUserCO"][idx], + // idx, + // ), + // ), + // ], + + // // 验收信息 + // if (pd['hiddenAcceptUserCO'] != null && + // (pd["state"] != 100) && + // ((widget.item == 7) || (widget.item == 3))) ...[ + // SizedBox(height: 10), + // + // // const Divider(height: 10,color: Colors.grey,), + // if (!_showAllData) + // _acceptanceInformationItem(list.last, (list.length - 1)), + // + // if (_showAllData) + // ListView.builder( + // shrinkWrap: true, // 自适应内容高度 + // physics: const NeverScrollableScrollPhysics(), + // itemCount: pd["hiddenAcceptUserCO"].length, + // itemBuilder: + // (ctx, idx) => _acceptanceInformationItem( + // pd["hiddenAcceptUserCO"][idx], + // idx, + // ), + // ), + // ], + + + + ///=============以下是操作 + //隐患整改操作 + if (widget.item==1)...[ + SizedBox(height: 10), + Card( + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 10, + left: 10, + right: 10, + ), + child: Row( + children: [ + Container( + width: 3, + height: 15, + color: Colors.blue, + ), + const SizedBox(width: 8), + Text( + "整改信息", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + + + GestureDetector( + onTap: () async { + DateTime? picked = await BottomDateTimePicker.showDate( + mode: BottomPickerMode.dateTimeWithSeconds, + context, + allowPast:false, + ); + if (picked != null) { + setState(() { + hiddenDangerRectification['rectificationTime']= DateFormat('yyyy-MM-dd HH:mm:ss').format(picked); + }); + } + + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 15), + child: ListItemFactory.createRowSpaceBetweenItem( + isRequired:true, + leftText: "整改时间", + rightText: hiddenDangerRectification['rectificationTime'].isNotEmpty?hiddenDangerRectification['rectificationTime']:"请选择", + isRight: true, + ), + ), + ), + + const Divider(height: 1), + Container( + padding: EdgeInsets.all(15), + child: Column( + children: [ + ListItemFactory.createBuildMultilineInput( + isRequired:true, + "整改描述", + "请对整改进行详细描述(必填项)", + _descriptionController, + ), + ], + ), + ), + + ItemListWidget.itemContainer( + RepairedPhotoSection( + isRequired:true, + title: "整改照片", + maxCount: 4, + mediaType: MediaType.image, + onChanged: (files) { + // 上传 files 到服务器 + gaiHouImages.clear(); + for(int i=0;i files) { + // // 上传图片 files + // _acceptanceImages.clear(); + // for (int i = 0; i < files.length; i++) { + // _acceptanceImages.add(files[i].path); + // } + // }, + // onAiIdentify: () {}, + // ), + // ), + // ], + // + // Divider(height: 1), + // if (!_hazardAcceptanceQualified) + // ItemListWidget.twoRowSelectableTitleText( + // label: '打回意见', + // isEditable: true, + // text: '请输入', + // isRequired: true, + // showSelect: false, + // controller: _replyFeedbackController, + // ), + // ], + // ), + // ), + // ], + + + + + + + //操作按钮 + + if (widget.item==1)...[ + SizedBox(height: 10,), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + + // 查看详情按钮 + Expanded( + child: CustomButton( + height: 35, + onPressed: () { + _setHiddenDangerRectification(); + + // _setHiddenDangerAcceptance(); + }, + textStyle: const TextStyle(color: Colors.white), + buttonStyle: ButtonStyleType.primary, + text: '提交', + ), + ), + + ], + ), + ], + + // 添加底部安全区域间距 + SizedBox(height: MediaQuery.of(context).padding.bottom + 20), + ], + ), + ), + ), + ); + }, + ); + } + + + Widget _buildInfoItem(String title, String value) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 120, + child: Text( + title, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + ), + Expanded(child: Text(value, textAlign: TextAlign.right)), + ], + ), + ); + } + + //隐患整改 + Future _setHiddenDangerRectification() async { + try { + + String miaoShu = _descriptionController.text.trim(); + if (miaoShu.isEmpty) { + ToastUtil.showNormal(context, "请填整改描述"); + return; + } + hiddenDangerRectification['rectificationDesc'] = miaoShu; + + String dataTime = hiddenDangerRectification['rectificationTime']??''; + if (dataTime.isEmpty) { + ToastUtil.showNormal(context, "请选择整改时间"); + return; + } + + if (gaiHouImages.isEmpty) { + ToastUtil.showNormal(context, "请上传整改照片"); + return; + } + + LoadingDialogHelper.show(); + + if (gaiHouImages.isNotEmpty) { + await _addImgFilesZhengGaiID( + gaiHouImages, + UploadFileType.keyHomeworkRectificationPictures, + ); + } + + + LoadingDialogHelper.show(); + final Map raw = await KeyTasksApi.setHiddenDangerRectification(hiddenDangerRectification,); + + if (raw['success']) { + LoadingDialogHelper.hide(); + setState(() { + ToastUtil.showNormal(context, "提交成功"); + Navigator.of(context).pop('1'); + }); + } else { + ToastUtil.showNormal(context, "提交失败"); + LoadingDialogHelper.hide(); + } + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载首页数据失败:$e'); + LoadingDialogHelper.hide(); + } + } + + //隐患验收 + Future _setHiddenDangerAcceptance() async { + try { + if (_hazardAcceptanceQualified) { + hiddenDangerAcceptance['status'] = 1; + String text = _acceptanceDescriptionController.text.trim(); + if (text.isEmpty) { + ToastUtil.showNormal(context, "请填写验收描述"); + return; + } + hiddenDangerAcceptance['descr'] = text; + + if (hiddenDangerAcceptance['rectificationTime'].isEmpty) { + ToastUtil.showNormal(context, "请选择验收日期"); + return; + } + + // if(_acceptanceImages.isEmpty){ + // ToastUtil.showNormal(context, "请选择验收图片"); + // return; + // } + + if (_acceptanceImages.isNotEmpty) { + await _addImgFiles( + _acceptanceImages, + UploadFileType.hiddenDangerVerificationPhoto, + hiddenDangerAcceptance['hiddenId'], + ); + } + } else { + hiddenDangerAcceptance['status'] = 0; + String text = _replyFeedbackController.text.trim(); + if (text.isEmpty) { + ToastUtil.showNormal(context, "请填写打回意见"); + return; + } + hiddenDangerAcceptance['repulseCause'] = text; + } + + LoadingDialogHelper.show(); + final raw = await HiddenDangerApi.setHiddenDangerAcceptance( + hiddenDangerAcceptance, + ); + if (raw['success']) { + LoadingDialogHelper.hide(); + setState(() { + ToastUtil.showNormal(context, "提交成功"); + Navigator.of(context).pop('1'); + }); + } else { + ToastUtil.showNormal(context, "提交失败"); + LoadingDialogHelper.hide(); + } + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载首页数据失败:$e'); + LoadingDialogHelper.hide(); + } + } + + /// 拉取某单位人员并缓存(兼容返回结构) + Future _getPersonListForUnitId(String id) async { + if (id.isEmpty) return; + LoadingDialogHelper.show(); + try { + final result = await BasicInfoApi.getDeptUsers(id); + LoadingDialogHelper.hide(); + // 兼容 result['data'] / result['userList'] 等常见字段 + dynamic raw = result['data']; + List> list = []; + if (raw is List) { + list = + raw.map>((e) { + if (e is Map) return e; + if (e is Map) return Map.from(e); + return {}; + }).toList(); + } else { + list = []; + } + setState(() { + _personCache[id] = list; + }); + } catch (e) { + LoadingDialogHelper.hide(); + ToastUtil.showError(context, '获取人员失败:$e'); + setState(() { + _personCache[id] = []; + }); + } + } + + + + // String _getSourceDangers(final item) { + // int type = item["source"]; + // if (1 == type) { + // return "隐患快报"; + // } else if (2 == type) { + // return "清单排查"; + // } else if (3 == type) { + // return "标准排查"; + // } else if (4 == type) { + // return "安全环保检查(监管端)"; + // } else if (5 == type) { + // return "安全环保检查(企业端)"; + // } else if (6 == type) { + // return "消防点检"; + // }else if (7 == type) { + // return "视频巡屏"; + // } else { + // return "NFC设备巡检"; + // } + // } + // String _getState(final item) { + // int type = item["state"]; + // if (100 == type) { + // return "待确认"; + // } else if (200 == type) { + // return "未整改"; + // } else if (201 == type) { + // return "确认打回"; + // } else if (202 == type) { + // return "待处理特殊隐患"; + // } else if (300 == type) { + // return "已整改"; + // } else if (301 == type) { + // return "已验收"; + // } else if (302 == type) { + // return "验收打回"; + // } else if (303 == type) { + // return "验收打回"; + // } else if (400 == type) { + // return "已处理特殊隐患"; + // } else if (99 == type) { + // return "强制关闭(人员变动)"; + // } else if (98 == type) { + // return "安全环保检查/清单排查暂存"; + // } else if (102 == type) { + // return "安全环保检查,隐患待指派"; + // } else if (97 == type) { + // return "已过期"; + // } else if (101 == type) { + // return "忽略隐患"; + // } else { + // return "已过期"; + // } + // } + + String _getSourceDangers(final item) { + int type = item["source"] ?? 0; + if (1 == type) { + return "隐患来源:安全环保检查(监管端)"; + } else if (2 == type) { + return "隐患来源:安全环保检查(企业端)"; + } else { + return "隐患来源:"; + } + } + + String _getState(final item) { + //1,未整改,2:已整改,3:已验收,4:验收打回 + int type = item["state"]; + if(1==type){ + return "未整改"; + }else if(2==type){ + return "已整改"; + }else if(3==type){ + return "已验收"; + }else if(4==type){ + return "验收打回"; + }else{ + return ""; + } + } + + + String _changeTime(String time) { + try { + // 解析 ISO 8601 格式的时间字符串 + DateTime dateTime = DateTime.parse(time); + // 格式化为年月日 + return DateFormat('yyyy-MM-dd HH:mm:ss').format(dateTime); + } catch (e) { + // 如果解析失败,返回原字符串或默认值 + return ''; + } + } + + String _getRectificationType(int? type) { + switch (type) { + case 1: + return '立即整改'; + case 2: + return '限期整改'; + default: + return ''; + } + } + + Future _addImgFiles( + List imagePaths, + UploadFileType type, + String hiddenId, + ) async { + try { + final raw = await FileApi.uploadFiles(imagePaths, type, ''); + if (raw['success']) { + hiddenDangerAcceptance['hiddenUserId'] = raw['data']['foreignKey']; + return raw['data']; + } else { + // _showMessage('反馈提交失败'); + return ""; + } + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载首页数据失败:$e'); + return ""; + } + } + + Future _addImgFilesZhengGai( + List imagePaths, + UploadFileType type, + ) async { + try { + final raw = await FileApi.uploadFiles(imagePaths, type, ''); + if (raw['success']) { + hiddenDangerRectification['hiddenSchemeId'] = raw['data']['foreignKey']; + + return raw['data']; + } else { + // _showMessage('反馈提交失败'); + return ""; + } + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载首页数据失败:$e'); + return ""; + } + } + + Future _addImgFilesZhengGaiID( + List imagePaths, + UploadFileType type, + ) async { + try { + final raw = await FileApi.uploadFiles(imagePaths, type, widget.itemId); + if (raw['success']) { + // raw['data']['foreignKey']; + return raw['data']; + } else { + // _showMessage('反馈提交失败'); + return ""; + } + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载首页数据失败:$e'); + return ""; + } + } + + + + String _getText(int source) { + if (source == 1) { + return "是"; + } else { + return "否"; + } + } + + String _delayInformationText(text) { + if (text != '') { + if (text == 1) { + return "通过"; + } else { + return "未通过"; + } + } else { + return ""; + } + } + + String _delayInformationTextTwo(text) { + if (text != '') { + if (text == 1) { + return "待审核"; + }else if(text == 2){ + return "审批中"; + }else if(text == 3){ + return "已通过"; + }else if(text == 4){ + return "已拒绝"; + } else if(text == 5){ + return "已撤回"; + } else { + return "未通过"; + } + } else { + return ""; + } + } + + //整改信息 + Widget _ectificationInformationItem(itemData, int idx) { + return Card( + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 10, left: 10, right: 10), + child: Row( + children: [ + Container(width: 3, height: 15, color: Colors.blue), + const SizedBox(width: 8), + Text( + "整改信息", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + + _buildInfoItem( + pd["isRelated"] == 0 ? '整改部门' : '整改单位(相关方项目)', + itemData['deptName'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + pd["isRelated"] == 0 ? '整改人' : '整改人(相关方项目)', + itemData['userName'] ?? '', + ), + + if (itemData['status'] != 0) ...[ + Divider(height: 1), + _buildInfoItem( + '整改时间', + _changeTime( itemData['rectificationTime'] ?? ''), + // itemData['rectificationTime'] ?? '', + ), + Divider(height: 1), + _buildInfoItem('整改描述', itemData['descr'] ?? ''), + Divider(height: 1), + _buildInfoItem('临时整改措施', itemData['remarks'] ?? ''), + Divider(height: 1), + _buildInfoItem( + '投入资金', + '${itemData['investmentFunds'].toString() ?? ''}元', + ), + + Divider(height: 1), + // const Text('整改后图片', style: TextStyle(fontWeight: FontWeight.bold)), + // _buildImageGrid(files2, onTap: (index) => _showImageGallery(files2, index)), + ListItemFactory.createTextImageItem( + text: "整改后图片", + imageUrls: + files2.map((item) => item['filePath'].toString()).toList(), + horizontalPadding: 10, + onImageTapped: (index) { + presentOpaque( + SingleImageViewer( + imageUrl: + ApiService.baseImgPath + files2[index]['filePath'], + ), + context, + ); + }, + ), + + Divider(height: 1), + _buildInfoItem( + '整改方案', + itemData['isRectificationScheme'] == 1 ? '有' : '无', + ), + Divider(height: 1), + if (itemData['isRectificationScheme'] == 1 && + itemData["hiddenSchemeCO"] != null) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // _buildInfoItem( + // '排查日期', + // itemData["hiddenSchemeCO"]['screeningDate'] ?? '', + // ), + + // Divider(height: 1), + _buildInfoItem( + '治理标准', + itemData["hiddenSchemeCO"]['governStanDards'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '治理方法', + itemData["hiddenSchemeCO"]['governMethod'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '经费落实', + itemData["hiddenSchemeCO"]['expenditure'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '负责人员', + itemData["hiddenSchemeCO"]['principal'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '工时安排', + itemData["hiddenSchemeCO"]['programming'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '时限要求', + itemData["hiddenSchemeCO"]['timeLimitFor'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '工作要求', + itemData["hiddenSchemeCO"]['jobRequireMent'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '其他事项', + itemData["hiddenSchemeCO"]['otherBusiness'] ?? '', + ), + Divider(height: 1), + ListItemFactory.createTextImageItem( + text: "方案图片", + imageUrls: + files4 + .map((item) => item['filePath'].toString()) + .toList(), + horizontalPadding: 10, + onImageTapped: (index) { + presentOpaque( + SingleImageViewer( + imageUrl: + ApiService.baseImgPath + + files4[index]['filePath'], + ), + context, + ); + }, + ), + ], + ), + ], + + if (itemData['status'] == 0) ...[ + Divider(height: 1), + _buildInfoItem('是否正常整改', '否'), + Divider(height: 1), + _buildInfoItem('无法整改原因', itemData['repulseCause'] ?? ''), + ], + ], + ), + ); + } + + //验收信息 + Widget _acceptanceInformationItem(itemData, int idx) { + // if(!_showAllData&&itemData['status']!=null&&itemData['status']==0){ + // return SizedBox(); + // }else{ + return Card( + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 10, left: 10, right: 10), + child: Row( + children: [ + Container(width: 3, height: 15, color: Colors.blue), + const SizedBox(width: 8), + Text( + "验收信息", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + + _buildInfoItem( + '验收部门', + // pd["isRelated"]==0?'验收部门':'验收单位(相关方项目)', + itemData['deptName'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '验收人', + // pd["isRelated"]==0?'验收人':'验收人(相关方项目)', + itemData['userName'] ?? '', + ), + Divider(height: 1), + _buildInfoItem( + '验收时间', + _changeTime(itemData['rectificationTime'] ?? ''), + ), + + if (itemData['status'] != null && itemData['status'] == 0) ...[ + Divider(height: 1), + _buildInfoItem('是否合格', '不合格'), + Divider(height: 1), + _buildInfoItem('验收打回意见', itemData['repulseCause'] ?? ''), + ], + + if (itemData['status'] != 0) ...[ + Divider(height: 1), + _buildInfoItem('是否合格', '合格'), + + if ((itemData['descr'] ?? '').isNotEmpty) ...[ + Divider(height: 1), + _buildInfoItem( + '验收描述', + itemData['descr'] ?? '', + // itemData['repulseCause'] ?? '', + ), + ], + + if (acceptancePhotosList.isNotEmpty && + getFilePathList(acceptancePhotosList, idx).isNotEmpty) ...[ + Divider(height: 1), + ListItemFactory.createTextImageItem( + text: "验收图片", + // imageUrls: files5.map((item) => item['filePath'].toString()).toList(), + imageUrls: getFilePathList(acceptancePhotosList, idx), + horizontalPadding: 10, + onImageTapped: (index) { + presentOpaque( + SingleImageViewer( + imageUrl: + ApiService.baseImgPath + + // files5[index]['filePath'], + acceptancePhotosList[idx][index]['filePath'], + ), + context, + ); + }, + ), + ], + ], + ], + ), + ); + // } + } + + List getFilePathList(List list, int idx) { + // List list= oldList.reversed.toList(); + if (list.isEmpty || idx < 0 || idx >= list.length || list[idx] == null) { + return []; // 返回空列表作为默认值 + } + + final items = list[idx]; + if (items == null || items.isEmpty) { + return []; + } + + // 方法1:使用 cast() + return (items as List) + .map( + (item) => + (item as Map)['filePath']?.toString() ?? '', + ) + .toList(); + } + + + //隐患整改 + Map hiddenDangerRectification = { + "hiddenRectificationRecordId":"", + "foreignKey": "", + "hiddenId": "", + "rectificationTime": "", + "rectificationDesc": "", + }; + + //隐患验收 + Map hiddenDangerAcceptance = { + "id": "", + "hiddenId": "", + "hiddenUserId": "", + "status": "", + "descr": "", + "rectificationTime": "", + "repulseCause": "", + "checkUserId": "", + }; +} diff --git a/lib/pages/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_danger_list.dart b/lib/pages/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_danger_list.dart new file mode 100644 index 0000000..57d64b7 --- /dev/null +++ b/lib/pages/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_danger_list.dart @@ -0,0 +1,596 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:qhd_prevention/CustomWidget/range_filter_bar.dart'; +import 'package:qhd_prevention/customWidget/custom_button.dart'; +import 'package:qhd_prevention/customWidget/search_bar_widget.dart'; +import 'package:qhd_prevention/customWidget/toast_util.dart'; +import 'package:qhd_prevention/http/ApiService.dart'; +import 'package:qhd_prevention/http/modules/key_tasks_api.dart'; +import 'package:qhd_prevention/pages/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_danger_detail.dart'; +import 'package:qhd_prevention/pages/my_appbar.dart'; +import 'package:qhd_prevention/tools/h_colors.dart'; +import 'package:qhd_prevention/tools/tools.dart'; +import 'dart:async'; + + + +class KeyTasksHiddenDangerList extends StatefulWidget { + const KeyTasksHiddenDangerList( this.appItem, {super.key}); + + + final int appItem;// 1 隐患整改 2 隐患记录 + + @override + State createState() => _KeyTasksHiddenDangerListState(); +} + +class _KeyTasksHiddenDangerListState extends State { + int _page = 1; + String searchKey = ""; + int _totalPage = 1; + late List _list = []; + bool _isLoading = false; + bool _hasMore = true; + Timer? _debounceTimer; + String buttonTextOne = '查看'; + String buttonTextTwo = '确认'; + String title = "隐患记录"; + + final TextEditingController _searchController = TextEditingController(); + + bool isJGD = false; + + @override + void initState() { + super.initState(); + // 初始均为空 + + _searchController.addListener(_onSearchChanged); + + switch (widget.appItem) { + case 1: + buttonTextTwo = '整改'; + title = "隐患整改"; + keyTasksHiddenDangerListData['stateList']=[1]; + break; + case 2: + buttonTextTwo = '查看'; + title = "隐患记录"; + keyTasksHiddenDangerListData['stateList']=[1,2,3,4]; + break; + } + + _getListData(false); + } + + @override + void dispose() { + _debounceTimer?.cancel(); + _searchController.removeListener(_onSearchChanged); + _searchController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + // 取屏幕宽度 + final double screenWidth = MediaQuery.of(context).size.width; + + return Scaffold( + appBar: MyAppbar(title:title), + + body: SafeArea( + child: NotificationListener( + onNotification: _onScroll, + child: _vcDetailWidget(), + ), + ), + backgroundColor: Colors.white, + ); + } + + Widget _vcDetailWidget() { + return Column( + children: [ + + if(widget.appItem==1) + Padding( + padding: EdgeInsets.all(10), + child: SearchBarWidget( + controller: _searchController, + isShowSearchButton: true, + showResetButton:true, + hintText: '请输入隐患描述', + onTextChanged: (value) {}, + onSearch: (keyboard) { + _performSearch(_searchController.text); + }, + ), + ), + + if(widget.appItem==2) + RangeFilterBar( + initial: RangeOption.none, + onRangeChanged: (range) { + String searchData=''; + switch (range) { + case RangeOption.oneWeek: + final data = DateTime.now().subtract( + const Duration(days: 7), + ); + final time = DateFormat('yyyy-MM-dd').format(data); + searchData = time; + break; + case RangeOption.oneMonth: + final data = DateTime.now().subtract( + const Duration(days: 30), + ); + final time = DateFormat('yyyy-MM-dd').format(data); + searchData = time; + break; + case RangeOption.threeMonths: + final data = DateTime.now().subtract( + const Duration(days: 90), + ); + final time = DateFormat('yyyy-MM-dd').format(data); + searchData = time; + case RangeOption.none: + break; + case RangeOption.oneDay: + break; + } + _performSearch(searchData); + }, + onFilterPressed: () async { + // 弹出筛选对话框或跳转到筛选页面 + String searchData=''; + // searchData = await pushPage( + // SafecheckListfilterPage( + // searchData: searchData, + // mode: widget.mode, + // ), + // context, + // ); + _performSearch(searchData); + }, + ), + + Container(height: 5, color: h_backGroundColor()), + Expanded( + child: + _list.isEmpty + ? NoDataWidget.show() + : ListView.builder( + itemCount: _list.length, + itemBuilder: (context, index) { + final item = _list[index]; + return _fxitemCell(item); + }, + ), + ), + ], + ); + } + + Widget _fxitemCell(pageData) { + // 使用GestureDetector包裹整个列表项以添加点击事件 + return GestureDetector( + onTap: () {}, + + child: Container( + margin: EdgeInsets.all(6), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.3), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 标题 + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, // 添加这一行 + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.only(left: 10, top: 15, right: 8), + child: Text( + '隐患描述: ${pageData['hiddenDesc'] ?? ''}', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + maxLines: 1, // 只显示一行 + overflow: TextOverflow.ellipsis, // 超出部分显示省略号 + ), + ), + ), + + // 状态标签 + Container( + padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: _getLevelColor(pageData), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(12), + topRight: Radius.circular(12), // 改为右上角 + ), + ), + child: Text( + pageData['hiddenLevelName'] ?? '', + style: TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + + SizedBox(height: 16), + + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 来源 + Expanded( + child: Text( + _getSourceDangers(pageData), + style: TextStyle(fontSize: 14, color: Colors.black87), + ), + ), + // 隐患状态 + // Expanded( + // child: Text( + // '隐患状态: ${_getState(pageData)}', + // style: TextStyle(fontSize: 14, color: Colors.black87), + // ), + // ), + ], + ), + ), + + SizedBox(height: 8), + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 来源 + // Expanded( + // child: Text( + // _getSourceDangers(pageData), + // style: TextStyle(fontSize: 14, color: Colors.black87), + // ), + // ), + // 隐患状态 + Expanded( + child: Text( + '隐患状态: ${_getState(pageData)}', + style: TextStyle(fontSize: 14, color: Colors.black87), + ), + ), + ], + ), + ), + + SizedBox(height: 8), + + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 隐患发现人 - 使用 Expanded 包裹 + Expanded( + child: Text( + '发现人:${truncateString(pageData['createName'] ?? '')}', + style: TextStyle(fontSize: 14, color: Colors.black87), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ), + + // 隐患发现时间 - 使用 Expanded 包裹 + Expanded( + child: Text( + '发现时间:${_changeTime(pageData['createTime'] ?? '')}', + + style: TextStyle(fontSize: 14, color: Colors.black87), + // maxLines: 1, + // overflow: TextOverflow.ellipsis, + ), + ), + ], + ), + ), + + + if(widget.appItem==2)...[ + if (pageData['rectificationUserId'] != null && + pageData['rectificationUserId'].isNotEmpty)...[ + SizedBox(height: 8), + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 整改人 + Expanded( + child: Text( + '整改人:${pageData['rectificationUserName'] ?? ''}', + style: TextStyle(fontSize: 14, color: Colors.black87), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ), + + Expanded( + child: Text( + '整改时间:${_changeTime(pageData['rectificationTime'] ?? '')}', + + style: TextStyle(fontSize: 14, color: Colors.black87), + // maxLines: 1, + // overflow: TextOverflow.ellipsis, + ), + ), + ], + ), + ), + ], + + if (pageData['acceptUserId'] != null && + pageData['acceptUserId'].isNotEmpty)...[ + SizedBox(height: 8), + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // 整改人 + Text( + '验收人: ${pageData['acceptUserName'] ?? ''}', + style: TextStyle(fontSize: 14, color: Colors.black87), + ), + + Text( + '隐患验收时间: ${_changeTime(pageData['acceptUserTime']??'')}', + style: TextStyle( + fontSize: 14, + color: Colors.black87, + ), + ), + ], + ), + ), + ], + ], + + + SizedBox(height: 8), + + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + //查看 + + Expanded( + child: CustomButton( + height: 35, + onPressed: () async { + // print('查看: ${pageData['title']}'); + pushPage( + KeyTasksHiddenDangerDetail( + 2, + pageData['id'], + pageData['hiddenId'], + pageData['foreignKey'], + false, + ), + context, + ); + }, + backgroundColor: h_backGroundColor(), + textStyle: const TextStyle(color: Colors.black), + buttonStyle: ButtonStyleType.secondary, + text: buttonTextOne, + ), + ), + + if(widget.appItem==1) + SizedBox(width: 10), // 使用width而不是height + //整改 + if(widget.appItem==1) + Expanded( + child: CustomButton( + height: 35, + onPressed: () async { + pushPage( + KeyTasksHiddenDangerDetail( + 1, + pageData['id'], + pageData['hiddenId'], + pageData['foreignKey'], + false, + ), + context, + ); + }, + backgroundColor: h_AppBarColor(), + textStyle: const TextStyle(color: Colors.white), + buttonStyle: ButtonStyleType.primary, + text: buttonTextTwo, + ), + ), + + ], + ), + + SizedBox(height: 10), + ], + ), + ), + ); + } + + void _performSearch(String keyword) { + // 执行搜索逻辑 + // if (keyword.isNotEmpty) { + // print('执行搜索: $keyword'); + // 调用API或其他搜索操作 + // 输入请求接口 + _page = 1; + searchKey = keyword; + _getListData(false); + // } + } + + bool _onScroll(ScrollNotification n) { + if (n.metrics.pixels > n.metrics.maxScrollExtent - 100 && + _hasMore && + !_isLoading) { + _page++; + _getListData(true); + } + return false; + } + + void _onSearchChanged() { + final query = _searchController.text.toLowerCase().trim(); + setState(() { + print("=====>" + query); + // filtered = query.isEmpty ? original : _filterCategories(original, query); + }); + } + + + Future _getListData(bool loadMore) async { + try { + if (_isLoading) return; + _isLoading = true; + + keyTasksHiddenDangerListData['pageIndex']=_page; + keyTasksHiddenDangerListData['hiddenDesc']=searchKey; + + LoadingDialogHelper.show(); + final Map result = await KeyTasksApi.setKeyTasksHiddenDangerList(keyTasksHiddenDangerListData); + LoadingDialogHelper.hide(); + + if (result['success']) { + _totalPage = result['pageSize'] ?? 1; + final List newList = result['data'] ?? []; + // setState(() { + // _list.addAll(newList); + // }); + + setState(() { + if (loadMore) { + _list.addAll(newList); + } else { + _list = newList; + } + _hasMore = _page < _totalPage; + // if (_hasMore) _page++; + }); + } else { + ToastUtil.showNormal(context, "加载数据失败"); + // _showMessage('加载数据失败'); + } + } catch (e) { + LoadingDialogHelper.hide(); + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载数据失败:$e'); + } finally { + // if (!loadMore) LoadingDialogHelper.hide(); + _isLoading = false; + } + } + + String _getSourceDangers(final item) { + int type = item["source"] ?? 0; + if (1 == type) { + return "隐患来源:安全环保检查(监管端)"; + } else if (2 == type) { + return "隐患来源:安全环保检查(企业端)"; + } else { + return "隐患来源:"; + } + } + + // 隐患等级颜色 + Color _getLevelColor(final item) { + String type = item["hiddenLevelName"] ?? ''; + if ("重大隐患" == type) { + return Colors.red; + } else if ("较大隐患" == type) { + return Color(0xFFFF6A4D); + } else if ("一般隐患" == type) { + return Colors.orange; + } else if ("轻微隐患" == type) { + return h_AppBarColor(); + } else { + return Colors.green; + } + } + + String _getState(final item) { + //1,未整改,2:已整改,3:已验收,4:验收打回 + int type = item["state"]; + if(1==type){ + return "未整改"; + }else if(2==type){ + return "已整改"; + }else if(3==type){ + return "已验收"; + }else if(4==type){ + return "验收打回"; + }else{ + return ""; + } + } + + String _changeTime(String time) { + try { + // 解析 ISO 8601 格式的时间字符串 + DateTime dateTime = DateTime.parse(time); + // 格式化为年月日 + return DateFormat('yyyy-MM-dd').format(dateTime); + } catch (e) { + // 如果解析失败,返回原字符串或默认值 + return ' '; + } + } + + String truncateString(String input) { + if (input.length > 10) { + return '${input.substring(0, 10)}...'; + } + return input; + } + + + Map keyTasksHiddenDangerListData={ + "hiddenDesc": "", + "stateList": [], + "pageSize": 20, + "pageIndex": 1 + }; + + +} diff --git a/lib/pages/home/keyTasks/key_tasks_check_list_page.dart b/lib/pages/home/keyTasks/key_tasks_check_list_page.dart index a35cbd2..3f64b88 100644 --- a/lib/pages/home/keyTasks/key_tasks_check_list_page.dart +++ b/lib/pages/home/keyTasks/key_tasks_check_list_page.dart @@ -56,7 +56,7 @@ class _KeyTasksCheckListPageState extends State { super.initState(); - title='检查发起'; + title='被检查确认'; keyTasksInspectionListData['statusList']=[2]; diff --git a/lib/pages/home/keyTasks/key_tasks_tab_page.dart b/lib/pages/home/keyTasks/key_tasks_tab_page.dart index b75c9a2..1685772 100644 --- a/lib/pages/home/keyTasks/key_tasks_tab_page.dart +++ b/lib/pages/home/keyTasks/key_tasks_tab_page.dart @@ -3,6 +3,7 @@ import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:qhd_prevention/pages/home/doorAndCar/doorCar_tab_page.dart'; +import 'package:qhd_prevention/pages/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_danger_list.dart'; import 'package:qhd_prevention/pages/home/keyTasks/key_tasks_check_list_page.dart'; import 'package:qhd_prevention/pages/home/keyTasks/key_tasks_confirm_list_page.dart'; import 'package:qhd_prevention/pages/my_appbar.dart'; @@ -60,7 +61,7 @@ class _DoorcarTabPageState extends State { icon: 'assets/images/door_ico9.png', badge: 0, onTap: () async { - // await pushPage(KeyTasksHiddenList(1), context); + await pushPage(KeyTasksHiddenDangerList(1), context); _getDoorCarCount(); }, ), @@ -69,7 +70,7 @@ class _DoorcarTabPageState extends State { icon: 'assets/images/door_ico9.png', badge: 0, onTap: () async { - // await pushPage(KeyTasksHiddenList(2), context); + await pushPage(KeyTasksHiddenDangerList(2), context); _getDoorCarCount(); }, ),