diff --git a/lib/constants/app_enums.dart b/lib/constants/app_enums.dart index 2229752..7120cda 100644 --- a/lib/constants/app_enums.dart +++ b/lib/constants/app_enums.dart @@ -510,7 +510,10 @@ enum UploadFileType { /// 封闭区域人员申请人签字 - 类型: '609', 路径: 'enclosed_area_personnel_applicant_signature' enclosedAreaPersonnelApplicantSignature('609', 'enclosed_area_personnel_applicant_signature'), /// 封闭区域车辆申请人签字 - 类型: '610', 路径: 'enclosed_area_vehicle_applicant_signature' - enclosedAreaVehicleApplicantSignature('610', 'enclosed_area_vehicle_applicant_signature'); + enclosedAreaVehicleApplicantSignature('610', 'enclosed_area_vehicle_applicant_signature'), + + /// 重点作业处罚反馈图片 - 类型: '701', 路径: 'feedback_image_key_homework_punishment' + feedbackImageKeyHomeworkPunishment('701', 'feedback_image_key_homework_punishment'); diff --git a/lib/http/modules/key_tasks_api.dart b/lib/http/modules/key_tasks_api.dart index 3cb7f49..ff9d612 100644 --- a/lib/http/modules/key_tasks_api.dart +++ b/lib/http/modules/key_tasks_api.dart @@ -47,6 +47,18 @@ class KeyTasksApi { ); } + /// 删除 + static Future> deleteTasksData(String id) { + return HttpManager().request( + '${ApiService.basePath}/keyProject', + '/keyProject/$id', + method: Method.post, + data: { + // ...data + }, + ); + } + /// 摄像头系统-获取所有的摄像头数据 static Future> getKeyTasksListCameraAll(String type) { return HttpManager().request( @@ -153,4 +165,31 @@ class KeyTasksApi { } + /// 隐患处罚 + static Future> getHiddenDangerPenalty(Map data) { + return HttpManager().request( + '${ApiService.basePath}/keyProject', + '/hidden/penalty/feedback/list', + method: Method.post, + data: { + ...data + }, + ); + } + + /// 提交反馈 + static Future> setPenaltyFeedback(Map data) { + return HttpManager().request( + '${ApiService.basePath}/keyProject', + '/hidden/penalty/feedback/save', + method: Method.post, + data: { + ...data + }, + ); + } + + + + } \ No newline at end of file diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 27c1c67..bd3d870 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -1002,7 +1002,7 @@ class HomePageState extends RouteAwareState case "隐患治理": case "隐患管理": case "风险管控应用": - // await pushPage(ApplicationPageTwo(), context); + await pushPage(HiddenDangerTabPage(), context); break; case "消防检查": // await pushPage(FireManagementTabPage(), context); 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 index 9e905e6..e5ed1e2 100644 --- 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 @@ -48,7 +48,7 @@ class KeyTasksHiddenDangerDetail extends StatefulWidget { this.inspectCodeId, }) : super(key: key); - final item; // 1 隐患整改 2 隐患记录 + final item; // 1 隐患整改 2 隐患记录 3 处罚反馈 final String itemId; final String hiddenId; final String foreignKey; @@ -129,6 +129,9 @@ class _KeyTasksHiddenDangerDetailState extends State case 2: //隐患记录 title='隐患记录'; break; + case 3: //处罚反馈 + title='处罚反馈'; + break; } @@ -765,6 +768,93 @@ class _KeyTasksHiddenDangerDetailState extends State ), ], + //处罚反馈 + if (widget.item==3)...[ + 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, + ), + ), + ], + ), + ), + + ItemListWidget.itemContainer( + RepairedPhotoSection( + isRequired:true, + title: "罚款缴纳单", + maxCount: 4, + mediaType: MediaType.image, + onChanged: (files) { + // 上传 files 到服务器 + gaiHouImages.clear(); + for(int i=0;i //操作按钮 - if (widget.item==1)...[ + if (widget.item==1||widget.item==3)...[ SizedBox(height: 10,), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -910,8 +1000,11 @@ class _KeyTasksHiddenDangerDetailState extends State child: CustomButton( height: 35, onPressed: () { - _setHiddenDangerRectification(); - + if(widget.item==3){ + _setPenaltyFeedback(); + }else{ + _setHiddenDangerRectification(); + } // _setHiddenDangerAcceptance(); }, textStyle: const TextStyle(color: Colors.white), @@ -1018,6 +1111,46 @@ class _KeyTasksHiddenDangerDetailState extends State } } + //隐患处理 + Future _setPenaltyFeedback() async { + try { + + + if (gaiHouImages.isEmpty) { + ToastUtil.showNormal(context, "请上传罚款缴纳单图片"); + return; + } + + penaltyFeedbackData['hiddenPenaltyId']=widget.itemId; + penaltyFeedbackData['feedbackUserId']=widget.hiddenId; + + LoadingDialogHelper.show(); + if (gaiHouImages.isNotEmpty) { + String url= await _addImgFilesZhengGaiID( + gaiHouImages, + UploadFileType.feedbackImageKeyHomeworkPunishment, + ); + penaltyFeedbackData['finePaymentReceipt']=url; + } + + LoadingDialogHelper.show(); + final Map raw = await KeyTasksApi.setPenaltyFeedback(penaltyFeedbackData,); + LoadingDialogHelper.hide(); + if (raw['success']) { + setState(() { + ToastUtil.showNormal(context, "提交成功"); + Navigator.of(context).pop('1'); + }); + } else { + ToastUtil.showNormal(context, "提交失败"); + } + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载首页数据失败:$e'); + LoadingDialogHelper.hide(); + } + } + //隐患验收 Future _setHiddenDangerAcceptance() async { try { @@ -1271,7 +1404,7 @@ class _KeyTasksHiddenDangerDetailState extends State final raw = await FileApi.uploadFiles(imagePaths, type, widget.hiddenId); if (raw['success']) { // raw['data']['foreignKey']; - return raw['data']; + return raw['data']['foreignKey']; } else { // _showMessage('反馈提交失败'); return ""; @@ -1618,4 +1751,15 @@ class _KeyTasksHiddenDangerDetailState extends State "repulseCause": "", "checkUserId": "", }; + + + //处罚反馈 + Map penaltyFeedbackData = { + "feedbackTime": "", + "hiddenPenaltyId": "", + "finePaymentReceipt": "", + "feedbackUserId": '' + }; + + } diff --git a/lib/pages/home/keyTasks/keyTasksDetail/key_tasks_confirm_detail_page.dart b/lib/pages/home/keyTasks/keyTasksDetail/key_tasks_confirm_detail_page.dart index dac375e..8d6bfe1 100644 --- a/lib/pages/home/keyTasks/keyTasksDetail/key_tasks_confirm_detail_page.dart +++ b/lib/pages/home/keyTasks/keyTasksDetail/key_tasks_confirm_detail_page.dart @@ -132,7 +132,7 @@ class _KeyTasksConfirmDetailPageState extends State { Divider(height: 1), _buildInfoItem('重点作业名称', pd['projectName'] ?? ''), Divider(height: 1), - _buildInfoItem('重点作业属性', pd['projectTypeName'] ?? ''), + _buildInfoItem('重点作业属性', pd['projectTypeName']!=null?pd['projectTypeName'].map((e) => e.toString()).join(","):''), Divider(height: 1), _buildInfoItem('计划工期开始', pd['planWorkStartDate'] ?? ''), Divider(height: 1), @@ -636,6 +636,9 @@ class _KeyTasksConfirmDetailPageState extends State { case 6: typeText='已完工'; break; + case 7: + typeText='已驳回'; + break; } return typeText; } diff --git a/lib/pages/home/keyTasks/keyTasksDetail/punishmentKeyTasks/key_tasks_punishment_filter_page.dart b/lib/pages/home/keyTasks/keyTasksDetail/punishmentKeyTasks/key_tasks_punishment_filter_page.dart new file mode 100644 index 0000000..c669575 --- /dev/null +++ b/lib/pages/home/keyTasks/keyTasksDetail/punishmentKeyTasks/key_tasks_punishment_filter_page.dart @@ -0,0 +1,475 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:qhd_prevention/customWidget/MultiDictValuesPicker.dart'; +import 'package:qhd_prevention/customWidget/bottom_picker.dart'; +import 'package:qhd_prevention/customWidget/custom_button.dart'; +import 'package:qhd_prevention/customWidget/date_picker_dialog.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/item_list_widget.dart'; +import 'package:qhd_prevention/customWidget/picker/CupertinoDatePicker.dart'; +import 'package:qhd_prevention/customWidget/toast_util.dart'; +import 'package:qhd_prevention/http/modules/basic_info_api.dart'; +import 'package:qhd_prevention/pages/my_appbar.dart'; +import 'package:qhd_prevention/tools/tools.dart'; + +class KeyTasksPunishmentFilterPage extends StatefulWidget { + const KeyTasksPunishmentFilterPage({ + super.key, + required this.searchData, + + }); + + final Map searchData; + + @override + State createState() => _KeyTasksPunishmentFilterPageState(); +} + +class _KeyTasksPunishmentFilterPageState extends State { + + // controllers / state + + /// 隐患描述 + TextEditingController _inspectionSiteController = TextEditingController(); + /// 被处罚单位 + TextEditingController _initiatorInspectionController = TextEditingController(); + /// 重点作业名称 + TextEditingController _inspectorController = TextEditingController(); + /// 处罚原因 + TextEditingController _punishmentReasonController = TextEditingController(); + + // 存储各单位的人员列表 + final Map>> _personCache = {}; + + DateTime? _startDate; + DateTime? _endDate; + Map searchData = {}; + + final DateFormat _dateFmt = DateFormat('yyyy-MM-dd'); + + + @override + void initState() { + // TODO: implement initState + super.initState(); + _fetchData(); + } + + Future _fetchData() async { + setState(() { + searchData=widget.searchData; + _inspectionSiteController.text = searchData['hiddenDesc']; + _initiatorInspectionController.text = searchData['xgfCorpinfoName']; + _inspectorController.text = searchData['projectName']; + _punishmentReasonController.text = searchData['projectName']; + + }); + } + + + // ========== 页面构建 ========== + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: const MyAppbar(title: '筛选'), + backgroundColor: Colors.white, + body: SafeArea( + child: Column( + children: [ + Expanded( + child: ListView( + children: [ + Container( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + buildTextFieldRow( + labelText: '隐患描述', + controller: _inspectionSiteController, + hintText: '请输入隐患描述', + onChanged: (value) { + searchData['hiddenDesc'] = value; + }, + ), + + + const SizedBox(height: 10), + buildTextFieldRow( + labelText: '被处罚单位', + controller: _initiatorInspectionController, + hintText: '请输入被处罚单位', + onChanged: (value) { + searchData['xgfCorpinfoName'] = value; + }, + ), + + const SizedBox(height: 10), + buildTextFieldRow( + labelText: '处罚原因', + controller: _punishmentReasonController, + hintText: '请输入处罚原因', + onChanged: (value) { + searchData['projectName'] = value; + }, + ), + + const SizedBox(height: 10), + buildTextFieldRow( + labelText: '重点作业名称', + controller: _inspectorController, + hintText: '请输入重点作业名称', + onChanged: (value) { + searchData['projectName'] = value; + }, + ), + + + ], + ), + ), + ], + ), + ), + ItemListWidget.itemContainer( + Row( + children: [ + CustomButton( + text: '重置', + padding: const EdgeInsets.symmetric( + vertical: 8, + horizontal: 30, + ), + buttonStyle: ButtonStyleType.secondary, + onPressed: _resetAll, + ), + const SizedBox(width: 12), + Expanded( + child: CustomButton(text: '确定', onPressed: _confirm), + ), + ], + ), + ), + ], + ), + ), + ); + } + + + + + + @override + void dispose() { + _inspectionSiteController.dispose(); + _initiatorInspectionController.dispose(); + _inspectorController.dispose(); + _punishmentReasonController.dispose(); + super.dispose(); + } + + Widget buildTextFieldRow({ + required String labelText, + required TextEditingController controller, + required String hintText, + ValueChanged? onChanged, + }) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + labelText, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w500, + color: Colors.black, + ), + ), + const SizedBox(height: 8), + Container( + height: 45, + decoration: BoxDecoration( + border: Border.all(color: Colors.grey), + borderRadius: BorderRadius.circular(5), + ), + padding: const EdgeInsets.symmetric(horizontal: 8), + alignment: Alignment.centerLeft, + child: TextFormField( + controller: controller, + decoration: InputDecoration( + hintText: hintText, + hintStyle: const TextStyle(color: Colors.grey), + border: InputBorder.none, + isDense: true, + ), + maxLines: 1, + onChanged: onChanged, + ), + ), + ], + ); + } + + Widget buildChooseRow({ + required String labelText, + required String hintText, + required String valueText, + required VoidCallback onTap, + bool showArrow = true, + }) { + final bool hasValue = valueText.trim().isNotEmpty; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + labelText, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w500, + color: Colors.black, + ), + ), + const SizedBox(height: 8), + Container( + height: 45, + decoration: BoxDecoration( + border: Border.all(color: Colors.grey), + borderRadius: BorderRadius.circular(5), + ), + child: InkWell( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Row( + children: [ + Expanded( + child: Text( + hasValue ? valueText : hintText, + style: TextStyle( + color: hasValue ? Colors.black87 : Colors.black54, + fontSize: 15, + ), + overflow: TextOverflow.ellipsis, + ), + ), + if (showArrow) + const Icon(Icons.arrow_drop_down, color: Colors.black54), + ], + ), + ), + ), + ), + ], + ); + } + + // Future _chooseDepartment({required String typeStr}) async { + // showModalBottomSheet( + // context: context, + // isScrollControlled: true, + // barrierColor: Colors.black54, + // backgroundColor: Colors.transparent, + // builder: + // (_) => DepartmentPicker( + // onSelected: (id, name) async { + // setState(() { + // searchData['inspectionDepartmentId']=id; + // searchData['inspectionDepartmentName']=name; + // // personUnderInspection['departmentId'] = id; + // // personUnderInspection['userName'] = name; + // // if (typeStr == '检查部门') { + // // _inspectionDeptName = name; + // // } else if (typeStr == '被检查单位') { + // // _inspectedDepartmentName = name; + // // } + // }); + // // 拉该单位人员并缓存 + // await _getPersonListForUnitId(typeStr); + // }, + // ), + // ).then((_) { + // // 可选:FocusHelper.clearFocus(context); + // }); + // } + + Future _getPersonListForUnitId(String typeStr) async { + String unitId = searchData['inspectionDepartmentId'] ?? ''; + // 拉取该单位的人员列表并缓存 + final result = await BasicInfoApi.getDeptUsers(unitId); + 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[typeStr] = list; + }); + //FocusHelper.clearFocus(context); + } + + + Future _getApproverList() async { + try { + + List newList = [ + {'dataId':'1','dataName':'视频识别报警',}, + {'dataId':'2','dataName':'安全环保检查(监管端)',}, + {'dataId':'3','dataName':'安全环保检查(企业端)',}, + ]; + showModalBottomSheet( + context: context, + isScrollControlled: true, + barrierColor: Colors.black54, + backgroundColor: Colors.transparent, + builder: + (ctx) => DepartmentPickerThree( + listdata: newList, + onSelected: (id, name,pdId) async { + setState(() { + searchData['source']=id; + searchData['sourceName']=name; + }); + + }, + ), + ); + + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载首页数据失败:$e'); + // return ""; + LoadingDialogHelper.hide(); + } + } + + /// 弹出人员选择,需先选择单位 + // void choosePersonHandle(String typeStr) async { + // final personList = _personCache[typeStr]; + // if (!FormUtils.hasValue(_personCache, typeStr)) { + // ToastUtil.showNormal(context, '请先选择单位'); + // return; + // } + // + // DepartmentPersonPicker.show( + // context, + // personsData: personList!, + // onSelectedWithIndex: (userId, name, index) { + // setState(() { + // if (typeStr == '检查人') { + // _inspectionUserName = name; + // } else { + // _inspectedUserName = name; + // } + // }); + // //FocusHelper.clearFocus(context); + // }, + // ).then((_) {}); + // } + + Future _pickDate({required bool isStart}) async { + DateTime? picked = await BottomDateTimePicker.showDate( + context, + minTimeStr: !isStart ? searchData['startTime'] : null, + mode: BottomPickerMode.dateTime, + ); + if (picked != null) { + setState(() { + final dateFormat = DateFormat('yyyy-MM-dd HH:mm'); + if (isStart) { + _startDate = picked; + searchData['startTime'] = dateFormat.format(picked); + } else { + _endDate = picked; + searchData['endTime'] = dateFormat.format(picked); + } + // 保证开始 <= 结束 + if (_endDate != null && _endDate!.isBefore(picked)) { + _endDate = null; + } + }); + } + } + + // // 选择检查状态 + // Future _pickCheckStatus() async { + // List> items = SafeCheckListItem.getStepList(); + // final choice = await BottomPicker.show( + // context, + // items: items.map((item) => item['name'].toString()).toList(), + // itemBuilder: (item) => Text(item, textAlign: TextAlign.center), + // initialIndex: 0, + // ); + // if (choice != null) { + // setState(() { + // Map item = items[items.indexWhere((item) => item['name'] == choice)]; + // _checkStatus = item['id']; + // }); + // } + // } + + + // Future _pickYearDate() async { + // DateTime? picked = await BottomDateTimePicker.showDate( + // context, + // minTimeStr: null, + // mode: BottomPickerMode.year, + // ); + // if (picked != null) { + // setState(() { + // final dateFormat = DateFormat('yyyy'); + // searchData['year'] = dateFormat.format(picked); + // }); + // } + // } + + // ========== 重置 / 确定 ========== + void _resetAll() { + setState(() { + _inspectionSiteController.clear(); + _initiatorInspectionController.clear(); + _inspectorController.clear(); + _punishmentReasonController.clear(); + + // searchData['hiddenDesc']=''; + // searchData['source']=''; + // searchData['sourceName']=''; + // searchData['startTime']=''; + // searchData['endTime']=''; + // searchData['projectName']=''; + // searchData['hiddenFindUserName']=''; + // searchData['orderBy']=''; + // searchData['orderDirection']=''; + // searchData['groupBy']=''; + + }); + final Map pd = { + ...searchData, + }; + Navigator.of(context).pop(pd); + } + + void _confirm() { + final Map pd = { + ...searchData, + }; + // for (Map subject in subjectList) { + // if (subject['bianma'] == pd['inspectionSubject']) { + // pd['inspectionSubject'] = subject['name']; + // } + // } + Navigator.of(context).pop(pd); + } + + +} diff --git a/lib/pages/home/keyTasks/keyTasksDetail/punishmentKeyTasks/key_tasks_punishment_list.dart b/lib/pages/home/keyTasks/keyTasksDetail/punishmentKeyTasks/key_tasks_punishment_list.dart new file mode 100644 index 0000000..f3f52c1 --- /dev/null +++ b/lib/pages/home/keyTasks/keyTasksDetail/punishmentKeyTasks/key_tasks_punishment_list.dart @@ -0,0 +1,581 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:qhd_prevention/CustomWidget/range_filter_bar.dart'; +import 'package:qhd_prevention/common/route_service.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/home/keyTasks/keyTasksDetail/keyTasksHiddenDanger/key_tasks_hidden_filter_page.dart'; +import 'package:qhd_prevention/pages/home/keyTasks/keyTasksDetail/punishmentKeyTasks/key_tasks_punishment_filter_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:async'; + + + +class KeyTasksPunishmentList extends StatefulWidget { + const KeyTasksPunishmentList( {super.key}); + + + @override + State createState() => _KeyTasksPunishmentListState(); +} + +class _KeyTasksPunishmentListState extends State { + int _page = 1; + // String searchKey = ""; + int _totalPage = 1; + + bool _isLoading = false; + bool _hasMore = true; + Timer? _debounceTimer; + String buttonTextOne = '查看'; + String buttonTextTwo = '确认'; + String title = ""; + + final TextEditingController _searchController = TextEditingController(); + + bool isJGD = false; + + late List _list = []; + + @override + void initState() { + super.initState(); + // 初始均为空 + + _searchController.addListener(_onSearchChanged); + + _distinguishData(); + + } + + Future _distinguishData() async { + + buttonTextTwo = '反馈'; + title = "处罚反馈"; + final parentPerm = 'dashboard:Key-assignment:Hidden-hazard-record'; + final targetPerm = ''; + final menuPath = await RouteService.getMenuPath(parentPerm, targetPerm); + keyTasksPunishmentData['menuPath']=menuPath; + + _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: [ + + RangeFilterBar( + initial: RangeOption.none, + mode: RangeFilterBarMode.dayWeekMonth, + onRangeChanged: (range) { + switch (range) { + case RangeOption.oneDay: + keyTasksPunishmentData['hiddenCreateTimeStart'] = DateFormat('yyyy-MM-dd HH:mm:ss') + .format(DateTime.now().subtract(const Duration(days: 1))); + break; + case RangeOption.oneWeek: + keyTasksPunishmentData['hiddenCreateTimeStart'] = DateFormat('yyyy-MM-dd HH:mm:ss') + .format(DateTime.now().subtract(const Duration(days: 7))); + break; + case RangeOption.oneMonth: + keyTasksPunishmentData['hiddenCreateTimeStart'] = DateFormat('yyyy-MM-dd HH:mm:ss') + .format(DateTime.now().subtract(const Duration(days: 30))); + break; + case RangeOption.threeMonths: + break; + case RangeOption.none: + break; + } + _performSearch(); + }, + onFilterPressed: () async { + // 弹出筛选对话框或跳转到筛选页面 + // String searchData=''; + final searchData= await pushPage( + KeyTasksPunishmentFilterPage( + searchData: keyTasksPunishmentData, + ), + context, + ); + if(searchData!=null){ + keyTasksPunishmentData=searchData; + _performSearch(); + } + + }, + ), + + 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( + '被处罚单位: ${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( + '被处罚人:${pageData['findUserName'] ?? ''}', + style: TextStyle(fontSize: 14, color: Colors.black87), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ), + + // Expanded( + // child: Text( + // '发现时间:${_changeTime(pageData['createTime'] ?? '')}', + // + // style: TextStyle(fontSize: 14, color: Colors.black87), + // // maxLines: 1, + // // overflow: TextOverflow.ellipsis, + // ), + // ), + ], + ), + ), + + SizedBox(height: 8), + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // 整改人 + Expanded( + child: + Text('处罚原因: ${pageData['projectName'] ?? ''}', + style: TextStyle(fontSize: 14, color: Colors.black87), + ), + ), + ], + ), + ), + + SizedBox(height: 8), + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // 整改人 + Expanded( + child: + Text('下发人: ${pageData['projectName'] ?? ''}', + style: TextStyle(fontSize: 14, color: Colors.black87), + ), + ), + ], + ), + ), + + SizedBox(height: 8), + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // 整改人 + Expanded( + child: + Text('处罚反馈状态: ${pageData['projectName'] ?? ''}', + style: TextStyle(fontSize: 14, color: Colors.black87), + ), + ), + ], + ), + ), + + SizedBox(height: 8), + Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // 整改人 + Expanded( + child: + Text( + '重点作业名称: ${pageData['projectName'] ?? ''}', + style: TextStyle(fontSize: 14, color: Colors.black87), + ), + ), + // Expanded( + // child: + // Text( + // '', + // 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']}'); + await pushPage( + KeyTasksHiddenDangerDetail( + 2, + pageData['id'], + pageData['hiddenId'], + pageData['foreignKey'], + false, + ), + context, + ); + _page = 1; + _getListData(false); + }, + backgroundColor: h_backGroundColor(), + textStyle: const TextStyle(color: Colors.black), + buttonStyle: ButtonStyleType.secondary, + text: buttonTextOne, + ), + ), + + + SizedBox(width: 10), // 使用width而不是height + Expanded( + child: CustomButton( + height: 35, + onPressed: () async { + await pushPage( + KeyTasksHiddenDangerDetail( + 3, + pageData['hiddenPenaltyId']??'', + pageData['feedbackUserId']??'', + pageData['feedbackUserName']??'', + false, + ), + context, + ); + _page = 1; + _getListData(false); + }, + backgroundColor: h_AppBarColor(), + textStyle: const TextStyle(color: Colors.white), + buttonStyle: ButtonStyleType.primary, + text: buttonTextTwo, + ), + ), + + ], + ), + + SizedBox(height: 10), + ], + ), + ), + ); + } + + void _performSearch() { + // 执行搜索逻辑 + // 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; + + keyTasksPunishmentData['pageIndex']=_page; + // keyTasksPunishmentData['hiddenDesc']=searchKey; + + LoadingDialogHelper.show(); + final Map result = await KeyTasksApi.getHiddenDangerPenalty(keyTasksPunishmentData); + 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) { + //隐患来源,1-视频识别报警,2-安全环保检查(监管端) 3-安全环保检查(企业端) + int type = item["source"] ?? 0; + if (1 == type) { + return "隐患来源:视频识别报警"; + } else if (2 == type) { + return "隐患来源:安全环保检查(监管端)"; + } else if (3 == 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 keyTasksPunishmentData={ + "needTotalCount": true, + "pageSize": 20, + "orderBy": "", + "hiddenCreateTimeStart": "", + "groupBy": "", + "fineFlag": 1, + "hiddenDesc": "", + "xgfCorpinfoName": "", + "pageIndex": '', + "hiddenSource": '', + "orderDirection": "", + "findUserName": "", + "projectName": "", + "hiddenCreateTimeEnd": "" + }; + + +} diff --git a/lib/pages/home/keyTasks/key_tasks_confirm_list_page.dart b/lib/pages/home/keyTasks/key_tasks_confirm_list_page.dart index 3a83336..2dd414a 100644 --- a/lib/pages/home/keyTasks/key_tasks_confirm_list_page.dart +++ b/lib/pages/home/keyTasks/key_tasks_confirm_list_page.dart @@ -163,7 +163,7 @@ class _KeyTasksConfirmListPageState extends State { ), ), const SizedBox(height: 8), - _buildItemChild('重点作业属性:',item['projectTypeName']??""), + _buildItemChild('重点作业属性:',item['projectTypeName']!=null?item['projectTypeName'].map((e) => e.toString()).join(","):''), const SizedBox(height: 8), _buildItemChild('辖区单位:',item['jurisdictionCorpinfoName']??""), const SizedBox(height: 8), @@ -193,7 +193,7 @@ class _KeyTasksConfirmListPageState extends State { buttonStyle:ButtonStyleType.primary, text: '查看'),), - if((item['uncheckHiddenCount']==0&&item['unFinishInspectionCount']==0)||item["applyStatus"]==1)...[ + if(((item['uncheckHiddenCount']==0&&item['unFinishInspectionCount']==0)||item["applyStatus"]==1)&&item["applyStatus"]!=7)...[ const SizedBox(width: 8), Expanded(child: CustomButton( height: 35, @@ -218,6 +218,56 @@ class _KeyTasksConfirmListPageState extends State { text: item["applyStatus"]==1?'开工申请':'完工申请'),), ], + if(item["applyStatus"]==1&&item["createSource"]==2)...[ + const SizedBox(width: 8), + Expanded(child: CustomButton( + height: 35, + onPressed: () async { + final ok = await CustomAlertDialog.showConfirm( + context, + title: '删除', + content: '确定要删除吗?', + cancelText: '取消', + ); + if (ok) { + _deleteTasksData(item); + } + }, + backgroundColor: Colors.red, + textStyle: const TextStyle(color: Colors.red), + buttonStyle: ButtonStyleType.primary, + text: '删除'),), + ], + + if(item["applyStatus"]==7)...[ + const SizedBox(width: 8), + Expanded(child: CustomButton( + height: 35, + onPressed: () { + _goToDetail(item,index,2); + }, + backgroundColor: h_AppBarColor(), + textStyle: const TextStyle(color: Colors.red), + buttonStyle:ButtonStyleType.primary, + text: '重新提交'),), + const SizedBox(width: 8), + Expanded(child: CustomButton( + height: 35, + onPressed: () async { + final ok = await CustomAlertDialog.showConfirm( + context, + title: '驳回原因', + cancelText:'', + content: item["rejectReason"]??'', + ); + + }, + backgroundColor: h_AppBarColor(), + textStyle: const TextStyle(color: Colors.red), + buttonStyle:ButtonStyleType.secondary, + text: '驳回原因'),), + ] + ],), @@ -309,6 +359,9 @@ class _KeyTasksConfirmListPageState extends State { case 6: typeText='已完工'; break; + case 7: + typeText='已驳回'; + break; } return typeText; } @@ -361,7 +414,7 @@ class _KeyTasksConfirmListPageState extends State { Map keyTasksConfirmListData={ "projectName": "", - "applyStatusList": [1,4],//状态,0:暂存。1:未开工,2:开工申请中,3:已超期,4:进行中,5:完工申请中,6:已完工 + "applyStatusList": [1,4,7],//状态,0:暂存。1:未开工,2:开工申请中,3:已超期,4:进行中,5:完工申请中,6:已完工 "pageSize": 20, "pageIndex": 1, "needTotalCount": true, @@ -386,6 +439,25 @@ class _KeyTasksConfirmListPageState extends State { } } + Future _deleteTasksData( item) async { + try { + + final Map result; + result = await KeyTasksApi.deleteTasksData(item["id"]); + if (result['success'] ) { + ToastUtil.showNormal(context, '删除成功'); + // _list.remove(item); + getListData(false); + }else{ + ToastUtil.showNormal(context, '删除失败'); + // _showMessage('加载数据失败'); + } + } catch (e) { + // 出错时可以 Toast 或者在页面上显示错误状态 + print('加载数据失败:$e'); + } + } + Map upKeyTasksData={ "applyStatus": '5', diff --git a/lib/pages/home/keyTasks/key_tasks_tab_page.dart b/lib/pages/home/keyTasks/key_tasks_tab_page.dart index 9603094..b332dfb 100644 --- a/lib/pages/home/keyTasks/key_tasks_tab_page.dart +++ b/lib/pages/home/keyTasks/key_tasks_tab_page.dart @@ -6,6 +6,7 @@ import 'package:qhd_prevention/common/route_service.dart'; import 'package:qhd_prevention/http/modules/key_tasks_api.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/keyTasksDetail/punishmentKeyTasks/key_tasks_punishment_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'; @@ -82,6 +83,17 @@ class _DoorcarTabPageState extends State { }, ), + AppSectionItem( + title: '处罚反馈', + icon: 'assets/images/door_ico10.png', + menuPerms:'dashboard:Key-assignment:Hidden-Hazard-Record', + badge: 0, + onTap: () async { + await pushPage(KeyTasksPunishmentList(), context); + _getDoorCarCount(); + }, + ), + ]), ];