Merge remote-tracking branch 'origin/main'
commit
d35bdbe6d8
|
@ -1,6 +1,7 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:qhd_prevention/pages/app/Danger_paicha/check_information_one_item.dart';
|
||||
import 'package:qhd_prevention/tools/tools.dart';
|
||||
|
||||
import 'HttpManager.dart';
|
||||
|
@ -1937,6 +1938,7 @@ U6Hzm1ninpWeE+awIDAQAB
|
|||
String dangerDetail,String dataTime,String type,String responsibleId,
|
||||
String yinHuanTypeIds,String hazardLeve,String buMenId,String buMenPDId,
|
||||
String yinHuanTypeNames,String hiddenType1,String hiddenType2,String hiddenType3,) {
|
||||
print("======>$type");
|
||||
return HttpManager().request(
|
||||
basePath,
|
||||
'/app/customHidden/$msg',
|
||||
|
@ -1957,7 +1959,7 @@ U6Hzm1ninpWeE+awIDAQAB
|
|||
"REFERENCE_BASIS":item["REFERENCE_BASIS"] ??"",
|
||||
"SOURCE": '2',
|
||||
"STATE": '0',
|
||||
|
||||
"CLEARIMG": '1',
|
||||
|
||||
"HIDDENDESCR": hazardDescription,
|
||||
"HIDDENPART": partDescription,
|
||||
|
@ -2000,5 +2002,117 @@ U6Hzm1ninpWeE+awIDAQAB
|
|||
);
|
||||
}
|
||||
|
||||
/// 提交排查项
|
||||
static Future<Map<String, dynamic>> submitInvestigationItems(
|
||||
item,String longitude,String latitude,
|
||||
String itemsString,String idsString,String checkrecordId,) {
|
||||
return HttpManager().request(
|
||||
basePath,
|
||||
'/app/customCheckRecord/add',
|
||||
method: Method.post,
|
||||
data: {
|
||||
"CUSTOM_ID": item["CUSTOM_ID"],
|
||||
"LIST_NAME": SessionService.instance.listItemNameJson,
|
||||
"CREATOR": SessionService.instance.username,
|
||||
"LATITUDE": latitude,
|
||||
"LONGITUDE": longitude,
|
||||
"ITEMS": itemsString,
|
||||
"IDS": idsString,
|
||||
"CHECKRECORD_ID": checkrecordId,
|
||||
"tm": DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
"CORPINFO_ID": SessionService.instance.corpinfoId,
|
||||
"USER_ID": SessionService.instance.loginUserId,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// 提交排查项
|
||||
static Future<Map<String, dynamic>> getCheckInformationList(String id) {
|
||||
return HttpManager().request(
|
||||
basePath,
|
||||
'/app/customHidden/getOtherHidden',
|
||||
method: Method.post,
|
||||
data: {
|
||||
|
||||
"CUSTOM_ID": id,
|
||||
"CORPINFO_ID": SessionService.instance.corpinfoId,
|
||||
"USER_ID": SessionService.instance.loginUserId,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// 暂存其他隐患记录
|
||||
static Future<Map<String, dynamic>> checkInformationOneItemData(
|
||||
String msg,String id,unqualifiedInspectionItemID,
|
||||
String hazardDescription,String partDescription,String latitude,String longitude,
|
||||
String dangerDetail,String dataTime,String type,String responsibleId,
|
||||
String yinHuanTypeIds,String hazardLeve,String buMenId,String buMenPDId,
|
||||
String yinHuanTypeNames,String hiddenType1,String hiddenType2,String hiddenType3,) {
|
||||
print("======>$type");
|
||||
return HttpManager().request(
|
||||
basePath,
|
||||
'/app/customHidden/$msg',
|
||||
method: Method.post,
|
||||
data: {
|
||||
|
||||
"HIDDEN_ID":unqualifiedInspectionItemID,
|
||||
"SOURCE": '3',
|
||||
"STATE": '0',
|
||||
|
||||
"HIDDENDESCR": hazardDescription,
|
||||
"HIDDENPART": partDescription,
|
||||
"LATITUDE": latitude,
|
||||
"LONGITUDE": longitude,
|
||||
|
||||
"RECTIFYDESCR": dangerDetail,
|
||||
"RECTIFICATIONDEADLINE": dataTime,
|
||||
"RECTIFICATIONTYPE": type,
|
||||
"RECTIFICATIONOR": responsibleId,
|
||||
|
||||
"HIDDENTYPE": yinHuanTypeIds,
|
||||
"HIDDENLEVEL":hazardLeve,
|
||||
"RECTIFICATIONDEPT": buMenId,
|
||||
"HIDDENFINDDEPT": buMenPDId.isNotEmpty?buMenPDId:buMenId,
|
||||
|
||||
"CREATOR": SessionService.instance.loginUserId,
|
||||
"LISTMANAGER_ID": id,
|
||||
"HIDDENTYPE_NAME": yinHuanTypeNames,
|
||||
"HIDDENTYPE1": hiddenType1 ,
|
||||
"HIDDENTYPE2": hiddenType2 ,
|
||||
"HIDDENTYPE3": hiddenType3 ,
|
||||
"CORPINFO_ID": SessionService.instance.corpinfoId,
|
||||
"USER_ID": SessionService.instance.loginUserId,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// 提交排查项
|
||||
static Future<Map<String, dynamic>> customCheckRecordFinish(String time,String text,
|
||||
String CHECKRECORD_ID,String id,String json) {
|
||||
return HttpManager().request(
|
||||
basePath,
|
||||
'/app/customCheckRecord/finish',
|
||||
method: Method.post,
|
||||
data: {
|
||||
"CHECK_TIME": time,
|
||||
"DESCR": text,
|
||||
"CHECKRECORD_ID": CHECKRECORD_ID,
|
||||
"CUSTOM_ID": id,
|
||||
"OTHER": json,
|
||||
"CORPINFO_ID": SessionService.instance.corpinfoId,
|
||||
"USER_ID": SessionService.instance.loginUserId,
|
||||
|
||||
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,763 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:qhd_prevention/customWidget/ItemWidgetFactory.dart';
|
||||
import 'package:qhd_prevention/customWidget/bottom_picker.dart';
|
||||
import 'package:qhd_prevention/customWidget/bottom_picker_two.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_hidden_type.dart';
|
||||
import 'package:qhd_prevention/customWidget/department_picker_two.dart';
|
||||
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
||||
import 'package:qhd_prevention/pages/home/tap/item_list_widget.dart';
|
||||
import 'package:qhd_prevention/pages/my_appbar.dart';
|
||||
import 'package:qhd_prevention/tools/tools.dart';
|
||||
import '../../../customWidget/photo_picker_row.dart';
|
||||
import '../../../http/ApiService.dart';
|
||||
|
||||
class CheckInformationOneItem extends StatefulWidget {
|
||||
const CheckInformationOneItem(this.id,this.item, this.result, {super.key,required this.onClose});
|
||||
|
||||
final String id;
|
||||
final item;
|
||||
final Map<String, dynamic> result;
|
||||
final Function(String,String) onClose;
|
||||
@override
|
||||
State<CheckInformationOneItem> createState() => _CheckInformationOneItemState();
|
||||
}
|
||||
|
||||
class _CheckInformationOneItemState extends State<CheckInformationOneItem> {
|
||||
final _standardController = TextEditingController();
|
||||
final _partController = TextEditingController();
|
||||
final _dangerDetailController = TextEditingController();
|
||||
|
||||
|
||||
String _repairLevelName = "";
|
||||
String hazardLeve ="";
|
||||
late bool _isDanger = false;//true 1 false 2
|
||||
late bool _canClick = true;
|
||||
late List<dynamic> _hazardLeveLlist = []; //隐患级别
|
||||
// 存储各单位的人员列表
|
||||
List<Map<String, dynamic>> _personCache = [];
|
||||
|
||||
|
||||
List<String> _yinHuanImages = [];
|
||||
List<String> _yinHuanVido = [];
|
||||
// String _yinHuanVido="";
|
||||
dynamic _hazardLeve;
|
||||
String yinHuanId = "";
|
||||
String yinHuanName = "";
|
||||
String buMenId = "";
|
||||
String buMenPDId = "";
|
||||
String buMenName = "";
|
||||
String responsibleId="";
|
||||
String responsibleName="";
|
||||
String dataTime = "";
|
||||
|
||||
List<String> _zhengGaiImages = [];
|
||||
List<String> _yinHuanTypeIds = [];
|
||||
List<String> _yinHuanTypeNames = [];
|
||||
|
||||
String unqualifiedInspectionItemID="";
|
||||
String listId="";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
|
||||
|
||||
|
||||
// unqualifiedInspectionItemID=SessionService.instance.unqualifiedInspectionItemID.toString();
|
||||
unqualifiedInspectionItemID=widget.item.departmentId;
|
||||
setState(() {
|
||||
if(unqualifiedInspectionItemID.isNotEmpty){
|
||||
List<dynamic> hImgs=widget.result["hImgs"];
|
||||
List<dynamic> rImgs=widget.result["rImgs"];
|
||||
dynamic pd=widget.result["pd"];
|
||||
|
||||
for(int i=0;i<hImgs.length;i++){
|
||||
if (hImgs[i]['FILEPATH'].toString().endsWith('.mp4')) {
|
||||
_yinHuanVido.add(ApiService.baseImgPath +hImgs[i]['FILEPATH']);
|
||||
} else {
|
||||
_yinHuanImages.add(ApiService.baseImgPath +hImgs[i]["FILEPATH"]);
|
||||
}
|
||||
}
|
||||
// _yinHuanVido视频
|
||||
// _yinHuanImages= hImgs.map((e) => ApiService.baseImgPath +e["FILEPATH"]).toList();
|
||||
_standardController.text=pd["HIDDENDESCR"];
|
||||
_partController.text=pd["HIDDENPART"];
|
||||
_repairLevelName =pd["HIDDENLEVELNAME"];
|
||||
hazardLeve =pd["HIDDENLEVEL"];
|
||||
_yinHuanTypeIds= pd["HIDDENTYPE"].toString().split(",");
|
||||
_yinHuanTypeNames= pd["HIDDENTYPE_NAME"].toString().split("/");
|
||||
yinHuanName=pd["HIDDENTYPE_NAME"].toString();
|
||||
|
||||
if(pd["RECTIFICATIONTYPE"]=="1"){
|
||||
_isDanger=true;
|
||||
}else{
|
||||
_isDanger=false;
|
||||
}
|
||||
|
||||
buMenId=pd["RECTIFICATIONDEPT"];
|
||||
buMenPDId=pd["HIDDENFINDDEPT"];
|
||||
buMenName=pd["RECTIFICATIONDEPTNAME"];
|
||||
responsibleId=pd["RECTIFICATIONOR"];
|
||||
responsibleName=pd["RECTIFICATIONORNAME"];
|
||||
dataTime=pd["RECTIFICATIONDEADLINE"];
|
||||
|
||||
_dangerDetailController.text=pd["RECTIFYDESCR"];
|
||||
_zhengGaiImages= rImgs.map((e) => ApiService.baseImgPath +e["FILEPATH"]).toList();
|
||||
// _zhengGaiImages整改图片"rImgs" -> [_GrowableList]
|
||||
|
||||
}else{
|
||||
listId=widget.id;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
_getHazardLevel();
|
||||
|
||||
|
||||
}
|
||||
|
||||
Future<void> _getHazardLevel() async {
|
||||
try {
|
||||
final result = await ApiService.getHazardLevel();
|
||||
if (result['result'] == 'success') {
|
||||
final List<dynamic> newList = result['list'] ?? [];
|
||||
setState(() {
|
||||
_hazardLeveLlist.addAll(newList);
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching data: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_standardController.dispose();
|
||||
_partController.dispose();
|
||||
_dangerDetailController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: MyAppbar(title: "隐患登记"),
|
||||
body: Column(
|
||||
children: [
|
||||
// 详情滚动区域
|
||||
_pageDetail(),
|
||||
// 底部警示文字,固定在页面底部
|
||||
// Container(
|
||||
// padding: const EdgeInsets.all(15),
|
||||
// color: Colors.white,
|
||||
// child: Text(
|
||||
// ' 严禁在本互联网非涉密平台处理、传输国家秘密和工作秘密,请确认扫描、传输的文件资料不涉及国家秘密和工作秘密',
|
||||
// style: TextStyle(fontSize: 14, color: Colors.red),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionContainer({required Widget child}) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _pageDetail() {
|
||||
return Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
|
||||
// _buildSectionContainer(
|
||||
// child: ItemListWidget.multiLineTitleTextField(
|
||||
// label: '检查内容:',
|
||||
// isEditable: false,
|
||||
// text: widget.item['CHECK_CONTENT'] ?? '',
|
||||
// ),
|
||||
// ),
|
||||
|
||||
_buildSectionContainer(
|
||||
child: RepairedPhotoSection(
|
||||
title: "隐患照片",
|
||||
maxCount: 4,
|
||||
mediaType: MediaType.image,
|
||||
initialMediaPaths:_yinHuanImages,
|
||||
isShowAI: true,
|
||||
onMediaAdded: (value) {
|
||||
_yinHuanImages.add(value);
|
||||
},
|
||||
onMediaRemoved: (value) {
|
||||
|
||||
},
|
||||
onChanged: (List<File> files) {
|
||||
// // 上传图片 files
|
||||
// _yinHuanImages.clear();
|
||||
// for(int i=0;i<files.length;i++){
|
||||
// _yinHuanImages.add(files[i].path);
|
||||
// }
|
||||
},
|
||||
onAiIdentify: () {
|
||||
// AI 识别逻辑
|
||||
if(_yinHuanImages.isEmpty){
|
||||
ToastUtil.showNormal(context, "请先上传一张图片");
|
||||
return;
|
||||
}
|
||||
if(_yinHuanImages.length>1){
|
||||
ToastUtil.showNormal(context, "识别暂时只能上传一张图片");
|
||||
return;
|
||||
}
|
||||
_identifyImg(_yinHuanImages[0]);
|
||||
},
|
||||
),
|
||||
),
|
||||
_buildSectionContainer(
|
||||
child: RepairedPhotoSection(
|
||||
title: "隐患视频",
|
||||
maxCount: 1,
|
||||
mediaType: MediaType.video,
|
||||
initialMediaPaths: _yinHuanVido,
|
||||
onMediaAdded: (value) {
|
||||
_yinHuanVido.add(value);
|
||||
},
|
||||
onChanged: (List<File> files) {
|
||||
// 上传视频 files
|
||||
// _yinHuanVido=files[0].path;
|
||||
},
|
||||
onAiIdentify: () {
|
||||
// AI 视频识别逻辑
|
||||
},
|
||||
),
|
||||
),
|
||||
_buildSectionContainer(
|
||||
child: ListItemFactory.createBuildMultilineInput(
|
||||
"隐患描述",
|
||||
"请对隐患进行详细描述(必填项)",
|
||||
_standardController,
|
||||
),
|
||||
),
|
||||
_buildSectionContainer(
|
||||
child: ListItemFactory.createBuildMultilineInput(
|
||||
"隐患部位",
|
||||
"请对隐患部位进行详细描述(必填项)",
|
||||
_partController,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
String choice = await BottomPickerTwo.show<String>(
|
||||
context,
|
||||
items: _hazardLeveLlist,
|
||||
itemBuilder: (item) => Text(item["NAME"], textAlign: TextAlign.center),
|
||||
initialIndex: 0,
|
||||
);
|
||||
if (choice != null) {
|
||||
for(int i=0;i<_hazardLeveLlist.length;i++){
|
||||
if(choice==_hazardLeveLlist[i]["NAME"]){
|
||||
_hazardLeve = _hazardLeveLlist[i];
|
||||
}
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_repairLevelName=_hazardLeve["NAME"];
|
||||
hazardLeve = _hazardLeve["BIANMA"];
|
||||
if("5ff9daf78e9a4fb1b40d77980656799d"==_hazardLeve["DICTIONARIES_ID"]){
|
||||
_isDanger=false;
|
||||
_canClick=false;
|
||||
}else{
|
||||
_canClick=true;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
child: _buildSectionContainer(
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(
|
||||
leftText: "隐患级别",
|
||||
rightText: _repairLevelName.isNotEmpty?_repairLevelName:"请选择",
|
||||
isRight: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
barrierColor: Colors.black54,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder:
|
||||
(ctx) => DepartmentPickerHiddenType(
|
||||
onSelected: (jsonString) {
|
||||
Map<String, List<String>> result = jsonString;
|
||||
_yinHuanTypeIds = List<String>.from(result['id']!);
|
||||
_yinHuanTypeNames = List<String>.from(result['name']!);
|
||||
setState(() {
|
||||
yinHuanName=_yinHuanTypeNames[_yinHuanTypeNames.length-1];
|
||||
});
|
||||
|
||||
|
||||
// print(jsonEncode(json));
|
||||
// List<String> _yinHuanTypeIds = [];
|
||||
// List<String> _yinHuanTypeNames = [];
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: _buildSectionContainer(
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(
|
||||
leftText: "隐患类型",
|
||||
rightText: yinHuanName.isNotEmpty?truncateText(yinHuanName):"请选择",
|
||||
isRight: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildSectionContainer(
|
||||
child: ListItemFactory.createYesNoSectionTwo(
|
||||
title: "是否立即整改",
|
||||
horizontalPadding: 0,
|
||||
verticalPadding: 0,
|
||||
yesLabel: "是",
|
||||
noLabel: "否",
|
||||
groupValue: _isDanger,
|
||||
canClick: _canClick,
|
||||
context:context,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
_isDanger = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
if (_isDanger)
|
||||
Column(
|
||||
children: [
|
||||
_buildSectionContainer(
|
||||
child: ListItemFactory.createBuildMultilineInput(
|
||||
"整改描述",
|
||||
"请对隐患进行整改描述(必填项)",
|
||||
_dangerDetailController,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
_buildSectionContainer(
|
||||
child: RepairedPhotoSection(
|
||||
title: "整改后图片",
|
||||
maxCount: 4,
|
||||
horizontalPadding: 0,
|
||||
mediaType: MediaType.image,
|
||||
isShowAI: false,
|
||||
initialMediaPaths: _zhengGaiImages,
|
||||
onMediaAdded: (value) {
|
||||
_zhengGaiImages.add(value);
|
||||
},
|
||||
onChanged: (List<File> files) {
|
||||
// 上传图片 files
|
||||
// _zhengGaiImages.clear();
|
||||
// for(int i=0;i<files.length;i++){
|
||||
// _zhengGaiImages.add(files[i].path);
|
||||
// }
|
||||
|
||||
},
|
||||
onAiIdentify: () {
|
||||
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!_isDanger)
|
||||
Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
barrierColor: Colors.black54,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder:
|
||||
(ctx) => DepartmentPickerTwo(
|
||||
onSelected: (id, name,pdId) async {
|
||||
setState(() {
|
||||
buMenId = id;
|
||||
buMenName = name;
|
||||
buMenPDId=pdId;
|
||||
|
||||
responsibleId="";
|
||||
responsibleName="";
|
||||
});
|
||||
// 拉取该单位的人员列表并缓存
|
||||
final result = await ApiService.getListTreePersonList(id);
|
||||
_personCache=List<Map<String, dynamic>>.from(
|
||||
result['userList'] as List,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: _buildSectionContainer(
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(
|
||||
leftText: "整改责任部门",
|
||||
rightText: buMenName.isNotEmpty ? buMenName : "请选择",
|
||||
isRight: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
SizedBox(height: 10),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if ( buMenId.isEmpty) {
|
||||
ToastUtil.showNormal(context, '请先选择部门');
|
||||
return;
|
||||
}
|
||||
DepartmentPersonPicker.show(
|
||||
context,
|
||||
personsData: _personCache,
|
||||
onSelected: (userId, name) {
|
||||
setState(() {
|
||||
// renYuanId = userId;
|
||||
// renYuanName = name;
|
||||
|
||||
responsibleId=userId;
|
||||
responsibleName=name;
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
);
|
||||
},
|
||||
child:Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(
|
||||
leftText: "整改负责人",
|
||||
rightText: responsibleName.isNotEmpty?responsibleName:"请选择",
|
||||
isRight: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder:
|
||||
(_) => HDatePickerDialog(
|
||||
initialDate: DateTime.now(),
|
||||
onCancel: () => Navigator.of(context).pop(),
|
||||
onConfirm: (selected) async {
|
||||
Navigator.of(context).pop();
|
||||
setState(() {
|
||||
dataTime = DateFormat(
|
||||
'yyyy-MM-dd',
|
||||
).format(selected);
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: _buildSectionContainer(
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(
|
||||
leftText: "整改期限",
|
||||
rightText: dataTime.isNotEmpty ? dataTime : "请选择",
|
||||
isRight: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: 30),
|
||||
CustomButton(
|
||||
onPressed: () {
|
||||
_riskListCheckAppAdd();
|
||||
},
|
||||
text: "提交",
|
||||
backgroundColor: Colors.blue,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _riskListCheckAppAdd() async {
|
||||
LoadingDialogHelper.show(context);
|
||||
if(_yinHuanImages.isEmpty){
|
||||
ToastUtil.showNormal(context, "请上传隐患图片");
|
||||
return;
|
||||
}
|
||||
|
||||
String hazardDescription=_standardController.text.trim();
|
||||
if(hazardDescription.isEmpty){
|
||||
ToastUtil.showNormal(context, "请填隐患描述");
|
||||
return;
|
||||
}
|
||||
|
||||
String partDescription=_partController.text.trim();
|
||||
if(partDescription.isEmpty){
|
||||
ToastUtil.showNormal(context, "请填隐患部位");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(hazardLeve.isEmpty){
|
||||
ToastUtil.showNormal(context, "请选择隐患级别");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(_yinHuanTypeIds.isEmpty){
|
||||
ToastUtil.showNormal(context, "请选择隐患类型");
|
||||
return;
|
||||
}
|
||||
|
||||
String type="1";
|
||||
String dangerDetail="";
|
||||
if(_isDanger){
|
||||
type="1";
|
||||
dangerDetail=_dangerDetailController.text.trim();
|
||||
if(dangerDetail.isEmpty){
|
||||
ToastUtil.showNormal(context, "请填整改描述");
|
||||
return;
|
||||
}
|
||||
|
||||
if(_zhengGaiImages.isEmpty){
|
||||
ToastUtil.showNormal(context, "请上传整改后图片");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
type="2";
|
||||
if(buMenId.isEmpty){
|
||||
ToastUtil.showNormal(context, "请选择整改部门");
|
||||
return;
|
||||
}
|
||||
|
||||
if(responsibleId.isEmpty){
|
||||
ToastUtil.showNormal(context, "请选择整改人");
|
||||
return;
|
||||
}
|
||||
|
||||
if(dataTime.isEmpty){
|
||||
ToastUtil.showNormal(context, "请选择整改期限");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String yinHuanTypeIds="";
|
||||
String yinHuanTypeNames="";
|
||||
for(int i=0;i<_yinHuanTypeIds.length;i++){
|
||||
String yinHuanTypeId= _yinHuanTypeIds[i];
|
||||
String yinHuanTypeName= _yinHuanTypeNames[i];
|
||||
if(yinHuanTypeIds.isEmpty){
|
||||
yinHuanTypeIds=yinHuanTypeId;
|
||||
}else{
|
||||
yinHuanTypeIds="$yinHuanTypeIds,$yinHuanTypeId";
|
||||
}
|
||||
if(yinHuanTypeNames.isEmpty){
|
||||
yinHuanTypeNames=yinHuanTypeName;
|
||||
}else{
|
||||
yinHuanTypeNames="$yinHuanTypeNames/$yinHuanTypeName";
|
||||
}
|
||||
}
|
||||
|
||||
String hiddenType1="";
|
||||
if(_yinHuanTypeIds.length>1){
|
||||
hiddenType1=_yinHuanTypeIds[0];
|
||||
}
|
||||
String hiddenType2="";
|
||||
if(_yinHuanTypeIds.length>2){
|
||||
hiddenType1=_yinHuanTypeIds[1];
|
||||
}
|
||||
String hiddenType3="";
|
||||
if(_yinHuanTypeIds.length>3){
|
||||
hiddenType1=_yinHuanTypeIds[2];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取定位
|
||||
Position position = await _determinePosition();
|
||||
String longitude=position.longitude.toString();
|
||||
String latitude=position.latitude.toString();
|
||||
|
||||
try {
|
||||
// final result = await ApiService.temporaryStorageOfHidden(
|
||||
// unqualifiedInspectionItemID.isNotEmpty?"edit":"add",widget.item,unqualifiedInspectionItemID,
|
||||
// hazardDescription, partDescription, latitude, longitude,
|
||||
// dangerDetail, dataTime, type, responsibleId,
|
||||
// yinHuanTypeIds, hazardLeve, buMenId, buMenPDId,
|
||||
// yinHuanTypeNames, hiddenType1, hiddenType2, hiddenType3,);
|
||||
|
||||
final result = await ApiService.checkInformationOneItemData(
|
||||
unqualifiedInspectionItemID.isNotEmpty?"edit":"add",listId,unqualifiedInspectionItemID,
|
||||
hazardDescription, partDescription, latitude, longitude,
|
||||
dangerDetail, dataTime, type, responsibleId,
|
||||
yinHuanTypeIds, hazardLeve, buMenId, buMenPDId,
|
||||
yinHuanTypeNames, hiddenType1, hiddenType2, hiddenType3,);
|
||||
|
||||
|
||||
if (result['result'] == 'success') {
|
||||
|
||||
String hiddenId = result['pd']['HIDDEN_ID'] ;
|
||||
// SessionService.instance.setUnqualifiedInspectionItemIDJson(hiddenId);
|
||||
|
||||
for (int i=0;i<_yinHuanImages.length;i++){
|
||||
_addImgFiles(_yinHuanImages[i],"3",hiddenId);
|
||||
}
|
||||
|
||||
if(_yinHuanVido.isNotEmpty) {
|
||||
_addImgFiles(_yinHuanVido[0],"3",hiddenId);
|
||||
}
|
||||
|
||||
if(_isDanger){
|
||||
for (int i=0;i<_zhengGaiImages.length;i++){
|
||||
_addImgFiles(_zhengGaiImages[i],"4",hiddenId);
|
||||
}
|
||||
}
|
||||
LoadingDialogHelper.hide(context);
|
||||
setState(() {
|
||||
ToastUtil.showNormal(context, "提交成功");
|
||||
Navigator.pop(context);
|
||||
widget.onClose(hiddenId,_standardController.text.trim());
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
LoadingDialogHelper.hide(context);
|
||||
print('Error fetching data: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<String> _addImgFiles(String imagePath,String type,String id) async {
|
||||
try {
|
||||
|
||||
final raw = await ApiService.addImgFiles( imagePath, type, id);
|
||||
if (raw['result'] == 'success') {
|
||||
return raw['imgPath'];
|
||||
}else{
|
||||
// _showMessage('反馈提交失败');
|
||||
return "";
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> _identifyImg(String imagePath) async {
|
||||
try {
|
||||
LoadingDialogHelper.show(context);
|
||||
final raw = await ApiService.identifyImg( imagePath);
|
||||
if (raw['result'] == 'success') {
|
||||
final List<dynamic> newList = raw['aiHiddens'] ?? [];
|
||||
|
||||
String miaoShuText="";
|
||||
String zhengGaiText="";
|
||||
for(int i=0;i<newList.length;i++){
|
||||
// 1. 将字符串解析为 Map
|
||||
final Map<String, dynamic> item1 = jsonDecode(newList[i]);
|
||||
if(miaoShuText.isEmpty){
|
||||
miaoShuText=item1["hiddenDescr"];
|
||||
}else{
|
||||
miaoShuText=miaoShuText+";"+item1["hiddenDescr"];
|
||||
}
|
||||
|
||||
if(zhengGaiText.isEmpty){
|
||||
zhengGaiText=item1["rectificationSuggestions"];
|
||||
}else{
|
||||
zhengGaiText=zhengGaiText+";"+item1["rectificationSuggestions"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LoadingDialogHelper.hide(context);
|
||||
setState(() {
|
||||
_isDanger=true;
|
||||
_standardController.text=miaoShuText;
|
||||
_dangerDetailController.text=zhengGaiText;
|
||||
});
|
||||
}else{
|
||||
ToastUtil.showNormal(context, "识别失败");
|
||||
LoadingDialogHelper.hide(context);
|
||||
// _showMessage('反馈提交失败');
|
||||
// return "";
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
// return "";
|
||||
LoadingDialogHelper.hide(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Position> _determinePosition() async {
|
||||
bool serviceEnabled;
|
||||
LocationPermission permission;
|
||||
|
||||
// 检查定位服务是否启用
|
||||
serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
if (!serviceEnabled) {
|
||||
return Future.error('Location services are disabled.');
|
||||
}
|
||||
|
||||
// 获取权限
|
||||
permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
permission = await Geolocator.requestPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
return Future.error('Location permissions are denied');
|
||||
}
|
||||
}
|
||||
|
||||
if (permission == LocationPermission.deniedForever) {
|
||||
return Future.error(
|
||||
'Location permissions are permanently denied, we cannot request permissions.');
|
||||
}
|
||||
|
||||
// 获取当前位置
|
||||
return await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||
}
|
||||
|
||||
String truncateText(String text, {int maxLength = 17}) {
|
||||
if (text.length <= maxLength) return text;
|
||||
return '${text.substring(0, maxLength)}...';
|
||||
}
|
||||
|
||||
}
|
|
@ -40,6 +40,7 @@ class _CheckRecordPageState extends State<CheckRecordPage> {
|
|||
void _handleItemTap(item) {
|
||||
//item点击事件
|
||||
String id="";
|
||||
|
||||
switch(widget.type ){
|
||||
case 1://检查记录
|
||||
id=item["LISTMANAGER_ID"];
|
||||
|
@ -126,7 +127,7 @@ class _CheckRecordPageState extends State<CheckRecordPage> {
|
|||
|
||||
break;
|
||||
case 2://标准排查清单
|
||||
// _getStandardInvestigationRecordList(_page,searchKey,departmentId,startDate,endDate,selectedZQTimeId,responsibleName,selectedQDTypeId,false);
|
||||
_getStandardInvestigationRecordList(_page,searchKey,departmentId,startDate,endDate,selectedZQTimeId,responsibleName,selectedQDTypeId,false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class HazardRegistrationPage extends StatefulWidget {
|
|||
|
||||
final item;
|
||||
final Map<String, dynamic> result;
|
||||
final Function(String) onClose;
|
||||
final Function(String,String) onClose;
|
||||
@override
|
||||
State<HazardRegistrationPage> createState() => _HazardRegistrationPageState();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class _HazardRegistrationPageState extends State<HazardRegistrationPage> {
|
|||
_yinHuanTypeNames= pd["HIDDENTYPE_NAME"].toString().split("/");
|
||||
yinHuanName=pd["HIDDENTYPE_NAME"].toString();
|
||||
|
||||
if(pd["RECTIFICATIONTYPE"]==1){
|
||||
if(pd["RECTIFICATIONTYPE"]=="1"){
|
||||
_isDanger=true;
|
||||
}else{
|
||||
_isDanger=false;
|
||||
|
@ -640,7 +640,7 @@ class _HazardRegistrationPageState extends State<HazardRegistrationPage> {
|
|||
setState(() {
|
||||
ToastUtil.showNormal(context, "提交成功");
|
||||
Navigator.pop(context);
|
||||
widget.onClose(hiddenId);
|
||||
widget.onClose(hiddenId,_standardController.text.trim());
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
@ -32,14 +32,15 @@ class ApplicationPage extends StatelessWidget {
|
|||
// 处理项目点击事件
|
||||
void _handleItemClick(BuildContext context, AppItem item) {
|
||||
switch (item) {
|
||||
case AppItem.riskInspection:
|
||||
// 跳转到隐患排查页面
|
||||
pushPage(DangerPage(1), context);
|
||||
break;
|
||||
case AppItem.quickReport:
|
||||
// 跳转到隐患快报页面
|
||||
pushPage(QuickReportPage(), context);
|
||||
break;
|
||||
|
||||
case AppItem.riskInspection:
|
||||
// 跳转到隐患排查页面
|
||||
pushPage(DangerPage(1), context);
|
||||
break;
|
||||
case AppItem.checkRecord:
|
||||
// 跳转到检查记录页面
|
||||
pushPage(CheckRecordPage(1), context);
|
||||
|
|
|
@ -0,0 +1,671 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:qhd_prevention/customWidget/ItemWidgetFactory.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/picker/CupertinoDatePicker.dart';
|
||||
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
||||
import 'package:qhd_prevention/http/ApiService.dart';
|
||||
import 'package:qhd_prevention/pages/home/tap/item_list_widget.dart';
|
||||
import 'package:qhd_prevention/pages/mine/mine_sign_page.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 'Danger_paicha/check_information_one_item.dart';
|
||||
import 'danner_repair.dart';
|
||||
|
||||
|
||||
class CheckingInformationOnePage extends StatefulWidget {
|
||||
const CheckingInformationOnePage(this.id,this.checkrecordId, {super.key});
|
||||
|
||||
final String id;
|
||||
final String checkrecordId;
|
||||
|
||||
@override
|
||||
State<CheckingInformationOnePage> createState() => _CheckingInformationOnePageState();
|
||||
}
|
||||
|
||||
class _CheckingInformationOnePageState extends State<CheckingInformationOnePage> {
|
||||
|
||||
final List<DepartmentEntry> departments = [
|
||||
DepartmentEntry(department: '请选择', responsible: '请选择',index:'',departmentId: '',responsibleId:''),
|
||||
];
|
||||
|
||||
final List<DepartmentEntry> otherHidden = [];
|
||||
|
||||
final TextEditingController contentController = TextEditingController();
|
||||
|
||||
// 存储各单位的人员列表
|
||||
List<Map<String, dynamic>> _personCache = [];
|
||||
List<dynamic> listDates = [];
|
||||
String dataTime="";
|
||||
String stringTime="";
|
||||
String imagePath="";
|
||||
String CHECKRECORD_ID="";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
final now =DateTime.now();
|
||||
dataTime=DateFormat('yyyy-MM-dd').format(now);
|
||||
stringTime=DateFormat('HH:mm').format(now);
|
||||
_getCheckInformationList();
|
||||
}
|
||||
|
||||
Future<void> _getCheckInformationList() async {
|
||||
try {
|
||||
|
||||
final result = await ApiService.getCheckInformationList(widget.id);
|
||||
if (result['result'] == 'success') {
|
||||
final List<dynamic> newList = result['hiddenList'] ?? [];
|
||||
setState(() {
|
||||
|
||||
CHECKRECORD_ID= result['CHECKRECORD_ID'];
|
||||
listDates.addAll(newList);//"HIDDENDESCR" -> "3111111"
|
||||
for(int i=0;i<listDates.length;i++){
|
||||
try{
|
||||
otherHidden.add(DepartmentEntry(department: listDates[i]["HIDDENDESCR"], responsible: '请选择',index:'',departmentId:listDates[i]['HIDDEN_ID'] ,responsibleId:''));
|
||||
}catch(e){
|
||||
otherHidden.add(DepartmentEntry(department: "", responsible: '请选择',index:'',departmentId:listDates[i]['HIDDEN_ID'],responsibleId:''));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
ToastUtil.showNormal(context, "加载数据失败");
|
||||
// _showMessage('加载数据失败');
|
||||
}
|
||||
} catch (e) {
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: MyAppbar(title: "检查信息"),
|
||||
body: ListView(
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(
|
||||
leftText: "日期选择",
|
||||
rightText: dataTime.isEmpty?"请选择":dataTime,
|
||||
isRight: true,
|
||||
),
|
||||
),
|
||||
|
||||
Divider(height: 1,),
|
||||
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: GestureDetector(
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(leftText: '时间选择', rightText: stringTime.isEmpty?'请选择':stringTime, isRight: true),
|
||||
onTap: () async {
|
||||
DateTime? picked = await BottomDateTimePicker.showDate(context);
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
stringTime = DateFormat('HH:mm').format(picked);
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10,),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 10,left: 15,right: 15),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("检查部门的人",style: TextStyle(color: Colors.black,fontSize: 16)),
|
||||
CustomButton(
|
||||
onPressed: () {
|
||||
_addDepartment();
|
||||
},
|
||||
text: "添加",
|
||||
backgroundColor: Colors.blue,
|
||||
borderRadius: 17,
|
||||
height: 34,
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 10,right: 10),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: List.generate(
|
||||
departments.length,
|
||||
(index) => _departmentItem(
|
||||
departments[index],
|
||||
index,
|
||||
showLabel: index == 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
///其他隐患
|
||||
SizedBox(height: 10,),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 10,left: 15,right: 15),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("其他隐患信息",style: TextStyle(color: Colors.black,fontSize: 16)),
|
||||
CustomButton(
|
||||
onPressed: () {
|
||||
_addOtherHidden();
|
||||
},
|
||||
text: "添加",
|
||||
backgroundColor: Colors.blue,
|
||||
borderRadius: 17,
|
||||
height: 34,
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 10,right: 10),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: List.generate(
|
||||
otherHidden.length,
|
||||
(index) => _otherHiddenItem(otherHidden[index],
|
||||
index,
|
||||
showLabel: index == 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
SizedBox(height: 10,),
|
||||
|
||||
Container(
|
||||
color: Colors.white,
|
||||
child: ItemListWidget.multiLineTitleTextField(
|
||||
label: '备注:',
|
||||
isEditable: true,
|
||||
isRequired:false,
|
||||
controller: contentController,
|
||||
text: "",
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 10,),
|
||||
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.only(top: 10,bottom: 10,left: 15,right: 15),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
pushPage(MineSignPage(), context);
|
||||
},
|
||||
child: Text("用户",style: TextStyle(color: Colors.black,fontSize: 16)),
|
||||
),
|
||||
|
||||
_buildConfirmButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.only(left: 15,right: 15),
|
||||
child: Row(
|
||||
children: [
|
||||
if (imagePath.isNotEmpty)
|
||||
Text('签字照片:',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
if (imagePath.isNotEmpty)
|
||||
Image.file(File(imagePath),width: 230,height: 150,fit: BoxFit.cover,),
|
||||
|
||||
],
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
// 确认按钮
|
||||
// const Spacer(),
|
||||
_buildTrueButton(),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 验收部门和负责人选择的item
|
||||
Widget _departmentItem(
|
||||
DepartmentEntry entry,
|
||||
int index, {
|
||||
required bool showLabel,
|
||||
}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black12, width: 1),
|
||||
),
|
||||
child: _noAccepet_repair(false,index),
|
||||
),
|
||||
|
||||
// 当 num > 1 时,左上角显示删除按钮
|
||||
if (index > 0)
|
||||
Positioned(
|
||||
top: -20,
|
||||
left: -20,
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
icon: const Icon(Icons.cancel, color: Colors.red, size: 25),
|
||||
onPressed: () {
|
||||
_removeDepartment(index);
|
||||
// 这里处理删除逻辑,比如:
|
||||
// setState(() => _items.removeAt(num));
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _addDepartment() {
|
||||
setState(() {
|
||||
departments.add(DepartmentEntry(department: '请选择', responsible: '请选择',index:'',departmentId: '',responsibleId:''));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// #region 不整改
|
||||
Widget _noAccepet_repair(bool _accept,int index, ) {
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
barrierColor: Colors.black54,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (ctx) => DepartmentPicker(onSelected: (id, name) async {
|
||||
|
||||
setState(() {
|
||||
// buMenId=id;
|
||||
// buMenName=name;
|
||||
//
|
||||
// // 清空已选人员
|
||||
// renYuanId="";
|
||||
// renYuanName="";
|
||||
departments[index].department=name;
|
||||
departments[index].departmentId=id;
|
||||
|
||||
departments[index].responsible="";
|
||||
departments[index].responsibleId="";
|
||||
|
||||
});
|
||||
|
||||
// 拉取该单位的人员列表并缓存
|
||||
final result = await ApiService.getListTreePersonList(id);
|
||||
_personCache=List<Map<String, dynamic>>.from(
|
||||
result['userList'] as List,
|
||||
);
|
||||
|
||||
|
||||
}),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(
|
||||
leftText: "整改部门",
|
||||
rightText: departments[index].department.isNotEmpty?departments[index].department:"请选择",
|
||||
isRight: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Divider(
|
||||
height: 10,
|
||||
color: _accept ? h_backGroundColor() : Colors.transparent,
|
||||
),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if ( departments[index].departmentId.isEmpty) {
|
||||
ToastUtil.showNormal(context, '请先选择部门');
|
||||
return;
|
||||
}
|
||||
DepartmentPersonPicker.show(
|
||||
context,
|
||||
personsData: _personCache,
|
||||
onSelected: (userId, name) {
|
||||
setState(() {
|
||||
// renYuanId = userId;
|
||||
// renYuanName = name;
|
||||
|
||||
departments[index].responsible=name;
|
||||
departments[index].responsibleId=userId;
|
||||
departments[index].index=(index-1).toString();
|
||||
});
|
||||
|
||||
},
|
||||
);
|
||||
},
|
||||
child:Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: ListItemFactory.createRowSpaceBetweenItem(
|
||||
leftText: "整改负责人",
|
||||
rightText: departments[index].responsible.isNotEmpty?departments[index].responsible:"请选择",
|
||||
isRight: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _removeDepartment(int index) {
|
||||
if (index == 0) return; // 防止删除第一行
|
||||
setState(() {
|
||||
departments.removeAt(index);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Widget _buildConfirmButton() {
|
||||
return SizedBox(
|
||||
width: 80,
|
||||
height: 30,
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
final path = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => MineSignPage()),
|
||||
);
|
||||
// 更新状态(当子页面关闭时)
|
||||
setState(() {
|
||||
imagePath = path ?? '';
|
||||
});
|
||||
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF4285F4),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'手写签字',
|
||||
style: TextStyle(fontSize: 12, color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _otherHiddenItem(
|
||||
final DepartmentEntry entry,
|
||||
int index, {
|
||||
required bool showLabel,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: () => _selectItem(entry,index),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black12, width: 1),
|
||||
),
|
||||
child: ItemListWidget.multiLineTitleTextField(
|
||||
label: '隐患描述:',
|
||||
isEditable: false,
|
||||
controller: contentController,
|
||||
text: entry.department,
|
||||
),
|
||||
),
|
||||
|
||||
// 当 num > 1 时,左上角显示删除按钮
|
||||
// if (index > 0)
|
||||
Positioned(
|
||||
top: -20,
|
||||
left: -20,
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
icon: const Icon(Icons.cancel, color: Colors.red, size: 25),
|
||||
onPressed: () {
|
||||
_removeOtherHidden(index);
|
||||
// 这里处理删除逻辑,比如:
|
||||
// setState(() => _items.removeAt(num));
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
void _addOtherHidden() {
|
||||
setState(() {
|
||||
otherHidden.add(DepartmentEntry(department: '请选择', responsible: '请选择',index:'',departmentId: '',responsibleId:''));
|
||||
});
|
||||
}
|
||||
|
||||
void _removeOtherHidden(int index) {
|
||||
if (index == 0) return; // 防止删除第一行
|
||||
setState(() {
|
||||
otherHidden.removeAt(index);
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, dynamic> nullResult={};
|
||||
void _selectItem(final item,int index) {
|
||||
String hiddenId=item.departmentId;
|
||||
if(hiddenId.isNotEmpty) {
|
||||
_getTemporaryStorageOfHidden(item,hiddenId,index);
|
||||
}else{
|
||||
pushPage(CheckInformationOneItem(
|
||||
widget.id,item,nullResult,
|
||||
onClose: (String departmentId,String yinHuanText) {
|
||||
setState(() {
|
||||
// this.yinHuanText=yinHuanText;
|
||||
// item["REFERENCE_BASIS"]="option2";
|
||||
// _selectedValue="option2";
|
||||
// unqualifiedInspectionItemID=departmentId;
|
||||
otherHidden[index].department=yinHuanText;
|
||||
otherHidden[index].departmentId=departmentId;
|
||||
});
|
||||
|
||||
},
|
||||
), context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Future<void> _getTemporaryStorageOfHidden( item,String hiddenId,int index) async {
|
||||
|
||||
try {
|
||||
final result = await ApiService.getTemporaryStorageOfHidden(hiddenId);
|
||||
if (result['result'] == 'success') {
|
||||
|
||||
pushPage(CheckInformationOneItem(
|
||||
widget.id,item,result,
|
||||
onClose: (String departmentId,String yinHuanText) {
|
||||
setState(() {
|
||||
// this.yinHuanText=yinHuanText;
|
||||
// unqualifiedInspectionItemID=departmentId;
|
||||
otherHidden[index].department=yinHuanText;
|
||||
otherHidden[index].departmentId=departmentId;
|
||||
});
|
||||
|
||||
},
|
||||
), context);
|
||||
|
||||
} else {
|
||||
ToastUtil.showNormal(context, "加载数据失败");
|
||||
// _showMessage('加载数据失败');
|
||||
}
|
||||
} catch (e) {
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Widget _buildTrueButton() {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
_customCheckRecordFinish();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF4285F4),
|
||||
padding: const EdgeInsets.symmetric(vertical:5,horizontal: 80),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'提交',
|
||||
style: TextStyle(fontSize: 14, color: Colors.white),
|
||||
),
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _customCheckRecordFinish( ) async {
|
||||
try {
|
||||
|
||||
bool departmentsAllInput=true;
|
||||
bool departmentsSameMan=false;
|
||||
for(int i=0;i<departments.length;i++){
|
||||
if( departments[i].responsibleId.isEmpty){
|
||||
departmentsAllInput=false;
|
||||
}else{
|
||||
for(int m=i+1;m<departments.length;m++){
|
||||
if(departments[i].responsibleId==departments[m].responsibleId){
|
||||
departmentsSameMan=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!departmentsAllInput){
|
||||
ToastUtil.showNormal(context, "请添加验收部门负责人");
|
||||
return;
|
||||
}
|
||||
|
||||
if(departmentsSameMan){
|
||||
ToastUtil.showNormal(context, "不能选择重复的验收部门负责人");
|
||||
return;
|
||||
}
|
||||
|
||||
_addImgFiles(imagePath,"13",CHECKRECORD_ID) ;
|
||||
|
||||
String time=dataTime + ' ' + stringTime + ':00';
|
||||
String text=contentController.text.trim();
|
||||
|
||||
// 转换为 JSON 字符串
|
||||
String json = _convertDepartmentsToJson(departments);
|
||||
|
||||
final result = await ApiService.customCheckRecordFinish(time,text,CHECKRECORD_ID,widget.id,json);
|
||||
if (result['result'] == 'success') {
|
||||
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
});
|
||||
|
||||
} else {
|
||||
ToastUtil.showNormal(context, "加载数据失败");
|
||||
// _showMessage('加载数据失败');
|
||||
}
|
||||
} catch (e) {
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
}
|
||||
}
|
||||
|
||||
String _convertDepartmentsToJson(List<DepartmentEntry> departments) {
|
||||
// 1. 将列表中的每个对象转换为 Map
|
||||
List<Map<String, dynamic>> jsonList = departments
|
||||
.map((dept) => dept.toJson())
|
||||
.toList();
|
||||
|
||||
// 2. 使用 jsonEncode 转换为 JSON 字符串
|
||||
return jsonEncode(jsonList);
|
||||
}
|
||||
|
||||
|
||||
Future<String> _addImgFiles(String imagePath,String type,String id) async {
|
||||
try {
|
||||
|
||||
final raw = await ApiService.addImgFiles( imagePath, type, id);
|
||||
if (raw['result'] == 'success') {
|
||||
return raw['imgPath'];
|
||||
}else{
|
||||
// _showMessage('反馈提交失败');
|
||||
return "";
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载首页数据失败:$e');
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,389 @@
|
|||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qhd_prevention/customWidget/danner_repain_item.dart';
|
||||
import 'package:qhd_prevention/customWidget/department_picker.dart';
|
||||
import 'package:qhd_prevention/customWidget/search_bar_widget.dart';
|
||||
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
||||
import 'package:qhd_prevention/http/ApiService.dart';
|
||||
import 'package:qhd_prevention/pages/home/scan_page.dart';
|
||||
import 'package:qhd_prevention/pages/home/work/risk_list_page.dart';
|
||||
import 'package:qhd_prevention/pages/my_appbar.dart';
|
||||
import 'package:qhd_prevention/tools/SmallWidget.dart';
|
||||
import 'package:qhd_prevention/tools/tools.dart';
|
||||
|
||||
class HomeDangerPage extends StatefulWidget {
|
||||
const HomeDangerPage( {super.key});
|
||||
|
||||
|
||||
@override
|
||||
_HomeDangerPageState createState() => _HomeDangerPageState();
|
||||
}
|
||||
|
||||
class _HomeDangerPageState extends State<HomeDangerPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
int _selectedTab = 0;
|
||||
|
||||
// // 模拟数据
|
||||
// final List<NotificationItem> _notifications = List.generate(10, (i) {
|
||||
// bool read = i % 3 == 0;
|
||||
// String title = '测试数据标题标题 ${i + 1}';
|
||||
// String time = '2025-06-${10 + i} 12:3${i}';
|
||||
// return NotificationItem(title, time);
|
||||
// });
|
||||
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
|
||||
String appBarTitle="";
|
||||
String id="";
|
||||
String searchKey="";
|
||||
String searchName="";
|
||||
bool showBottomTags=true;
|
||||
|
||||
|
||||
|
||||
|
||||
List<dynamic> listOne = [];
|
||||
List<dynamic> listTwo = [];
|
||||
|
||||
List<dynamic> listDates = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
_tabController.addListener(() {
|
||||
|
||||
if (_tabController.indexIsChanging) {
|
||||
setState(() => _selectedTab = _tabController.index);
|
||||
print('切换到标签:${_tabController.index}');
|
||||
listDates.clear();
|
||||
setState(() {
|
||||
if(_selectedTab==0){
|
||||
listDates.addAll(listOne);
|
||||
showBottomTags=true;
|
||||
}else{
|
||||
listDates.addAll(listTwo);
|
||||
showBottomTags=false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
id=SessionService.instance.loginUser?["DEPARTMENT_ID"]??"";
|
||||
getListData();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void getListData(){
|
||||
listDates.clear();
|
||||
listOne.clear();
|
||||
listTwo.clear();
|
||||
appBarTitle="待排查";
|
||||
_getHazardInvestigationList();
|
||||
_getStandardInvestigationList();
|
||||
// case 3://首页-待排查
|
||||
// appBarTitle="待排查";
|
||||
// // _getStandardInvestigationRecordList(_page,keyWord,"","","","","","",addList);
|
||||
// break;
|
||||
|
||||
}
|
||||
|
||||
Future<void> _getHazardInvestigationList() async {
|
||||
try {
|
||||
|
||||
final result = await ApiService.getHazardInvestigationList(id,searchKey);
|
||||
if (result['result'] == 'success') {
|
||||
final List<dynamic> newList = result['varList'] ?? [];
|
||||
setState(() {
|
||||
|
||||
for(int i=0;i<newList.length;i++){
|
||||
if(newList[i]["checkCount"]==0){
|
||||
listOne.add(newList[i]);
|
||||
// }else{
|
||||
// listTwo.add(newList[i]);
|
||||
}
|
||||
}
|
||||
listDates.addAll(listOne);
|
||||
});
|
||||
|
||||
}else{
|
||||
ToastUtil.showNormal(context, "加载数据失败");
|
||||
// _showMessage('加载数据失败');
|
||||
}
|
||||
} catch (e) {
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getStandardInvestigationList() async {
|
||||
try {
|
||||
|
||||
final result = await ApiService.getStandardInvestigationList(id,searchKey);
|
||||
if (result['result'] == 'success') {
|
||||
final List<dynamic> newList = result['varList'] ?? [];
|
||||
setState(() {
|
||||
|
||||
for(int i=0;i<newList.length;i++){
|
||||
if(newList[i]["checkCount"]==0){
|
||||
// listOne.add(newList[i]);
|
||||
// }else{
|
||||
listTwo.add(newList[i]);
|
||||
}
|
||||
}
|
||||
listDates.addAll(listOne);
|
||||
});
|
||||
|
||||
}else{
|
||||
ToastUtil.showNormal(context, "加载数据失败");
|
||||
// _showMessage('加载数据失败');
|
||||
}
|
||||
} catch (e) {
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _handleItemTap( item, int index) async {
|
||||
print("点击了是: ${index}");
|
||||
SessionService.instance.setListItemNameJson(item['NAME']);
|
||||
switch(_selectedTab ){
|
||||
case 0://隐患排查
|
||||
// pushPage(RiskListPage(1,item["LISTMANAGER_ID"]), context);
|
||||
final result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => RiskListPage(1,item["LISTMANAGER_ID"])),
|
||||
);
|
||||
break;
|
||||
case 1://标准排查
|
||||
// pushPage(RiskListPage(2,item["CUSTOM_ID"]), context);
|
||||
final result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => RiskListPage(2,item["CUSTOM_ID"])),
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
getListData();
|
||||
}
|
||||
|
||||
// 显示分类选择器
|
||||
void showCategoryPicker() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
barrierColor: Colors.black54,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder:
|
||||
(ctx) => DepartmentPicker(onSelected: (id, name) {
|
||||
setState(() {
|
||||
searchKey=id;
|
||||
searchName=name;
|
||||
_searchController.text=name;
|
||||
});
|
||||
getListData();
|
||||
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: MyAppbar(
|
||||
title: "隐患排查",
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
pushPage(ScanPage(), context);
|
||||
},
|
||||
child: Text(
|
||||
"清单扫描",
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
// Tab bar
|
||||
TabBar(
|
||||
controller: _tabController,
|
||||
labelStyle: TextStyle(fontSize: 16),
|
||||
indicator: UnderlineTabIndicator(
|
||||
borderSide: BorderSide(width: 3.0, color: Colors.blue),
|
||||
insets: EdgeInsets.symmetric(horizontal: 100.0),
|
||||
),
|
||||
labelColor: Colors.blue,
|
||||
unselectedLabelColor: Colors.grey,
|
||||
tabs: const [Tab(text: '待排查'), Tab(text: '已排查')],
|
||||
),
|
||||
|
||||
Container(
|
||||
color: Colors.white,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: SearchBarWidget(
|
||||
showResetButton: true,
|
||||
onInputTap: () {
|
||||
showCategoryPicker();
|
||||
|
||||
},
|
||||
hintText: "",
|
||||
isClickableOnly: true,
|
||||
onSearch: (text) {
|
||||
print('----------');
|
||||
// searchKey=text;
|
||||
// getListData();
|
||||
},
|
||||
controller: _searchController,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// List
|
||||
Expanded(
|
||||
child: listDates.isEmpty
|
||||
? NoDataWidget.show()
|
||||
: ListView.separated(
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
itemCount: listDates.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(),
|
||||
itemBuilder: (context, index) {
|
||||
final item = listDates[index];
|
||||
return GestureDetector(
|
||||
onTap: () => _handleItemTap(item, index),
|
||||
child: DannerRepainItem(
|
||||
title: item['NAME'],
|
||||
details: [
|
||||
'清单类型:${item['TYPENAME']}',
|
||||
'排查周期:${item['PERIODNAME']}',
|
||||
'包含检查项:${item['count']}',
|
||||
'负责人:${item['USER_NAME']}',
|
||||
'起始时间:${item['START_DATE']}-${item['END_DATE']}',
|
||||
|
||||
],
|
||||
showBottomTags: showBottomTags,
|
||||
bottomTags: [
|
||||
riskTagText(1, "重大风险:${item['ACOUNT']}"),
|
||||
riskTagText(2, "较大:${item['BCOUNT']}"),
|
||||
riskTagText(3, "一般:${item['CCOUNT']}"),
|
||||
riskTagText(4, "低:${item['DCOUNT']}"),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _itemCell(final item) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: 15, right: 15, bottom: 15),
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(5)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.star_rate_sharp,
|
||||
color: Colors.green,
|
||||
size: 18,
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
Text("测试--------", style: TextStyle(fontSize: 14)),
|
||||
],
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios_rounded,
|
||||
color: Colors.grey,
|
||||
size: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(height: 1),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
|
||||
child: Column(
|
||||
spacing: 5,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
HhTextStyleUtils.secondaryTitle("清单类型:测试"),
|
||||
HhTextStyleUtils.secondaryTitle("排查周期:测试"),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
HhTextStyleUtils.secondaryTitle("包含检查项:3"),
|
||||
HhTextStyleUtils.secondaryTitle("负责人:是测试"),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
HhTextStyleUtils.secondaryTitle(
|
||||
"起始时间:2025-6-20 - 2026-3-31",
|
||||
),
|
||||
SizedBox(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 0, bottom: 15, left: 15, right: 15),
|
||||
child: Row(
|
||||
spacing: 5,
|
||||
children: [
|
||||
riskTagText(1, "重大风险:0"),
|
||||
riskTagText(2, "较大:3"),
|
||||
riskTagText(3, "一般:1"),
|
||||
riskTagText(4, "低:0"),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 模拟数据模版
|
||||
class NotificationItem {
|
||||
final String title;
|
||||
final String time;
|
||||
|
||||
NotificationItem(this.title, this.time);
|
||||
}
|
|
@ -3,6 +3,7 @@ import 'dart:async';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:qhd_prevention/customWidget/ItemWidgetFactory.dart';
|
||||
import 'package:qhd_prevention/pages/home/NFC/home_nfc_list_page.dart';
|
||||
import 'package:qhd_prevention/pages/home/home_danger_page.dart';
|
||||
import 'package:qhd_prevention/pages/home/low_page.dart';
|
||||
import 'package:qhd_prevention/pages/home/risk/riskControl_page.dart';
|
||||
import 'package:qhd_prevention/pages/home/study/study_garden_page.dart';
|
||||
|
@ -421,7 +422,7 @@ class _HomePageState extends State<HomePage> {
|
|||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (index == 1) {
|
||||
pushPage(DangerPage(3), context);
|
||||
pushPage(HomeDangerPage(), context);
|
||||
} else if (index == 2) {
|
||||
pushPage(DangerWaitListPage(DangerType.wait, 2), context);
|
||||
} else if (index == 3) {
|
||||
|
|
|
@ -175,18 +175,26 @@ class _DangerPageState extends State<DangerPage>
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
void _handleItemTap( item, int index) {
|
||||
Future<void> _handleItemTap( item, int index) async {
|
||||
print("点击了是: ${index}");
|
||||
SessionService.instance.setListItemNameJson(item['NAME']);
|
||||
switch(widget.type ){
|
||||
case 1://隐患排查
|
||||
pushPage(RiskListPage(widget.type,item["LISTMANAGER_ID"]), context);
|
||||
// pushPage(RiskListPage(widget.type,item["LISTMANAGER_ID"]), context);
|
||||
final result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => RiskListPage(widget.type,item["LISTMANAGER_ID"])),
|
||||
);
|
||||
break;
|
||||
case 2://标准排查
|
||||
appBarTitle="标准排查";
|
||||
pushPage(RiskListPage(widget.type,item["CUSTOM_ID"]), context);
|
||||
// pushPage(RiskListPage(widget.type,item["CUSTOM_ID"]), context);
|
||||
final result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => RiskListPage(widget.type,item["CUSTOM_ID"])),
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
getListData();
|
||||
}
|
||||
|
||||
// 显示分类选择器
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
||||
import 'package:qhd_prevention/http/ApiService.dart';
|
||||
import 'package:qhd_prevention/pages/app/Danger_paicha/danger_image_updata_page.dart';
|
||||
|
@ -43,8 +46,13 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
];
|
||||
|
||||
List<dynamic> listDates = [];
|
||||
List<dynamic> listDatesTwo = [];
|
||||
String unqualifiedInspectionItemID="";
|
||||
Map<String, dynamic> nullResult={};
|
||||
List<dynamic> upDataItemList=[];
|
||||
|
||||
String yinHuanText="";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
|
@ -57,12 +65,14 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
|
||||
Future<void> _getInvestigationItems( ) async {
|
||||
try {
|
||||
|
||||
listDates.clear();
|
||||
final result = await ApiService.getInvestigationItems(widget.item);
|
||||
if (result['result'] == 'success') {
|
||||
final List<dynamic> newList = result['varList'] ?? [];
|
||||
// final List<dynamic> newListTwo = result['records'] ?? [];
|
||||
setState(() {
|
||||
listDates.addAll(newList);
|
||||
// listDatesTwo.addAll(newListTwo);
|
||||
});
|
||||
|
||||
}else{
|
||||
|
@ -119,7 +129,7 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
width: screenWidth - 30,
|
||||
height: 50,
|
||||
child: TextButton(
|
||||
onPressed: _selectedValue != null ? _submit : null,
|
||||
onPressed: _submit,//_selectedValue != null ? _submit : null,
|
||||
child: Text(
|
||||
"提交",
|
||||
style: TextStyle(
|
||||
|
@ -268,6 +278,7 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
if(value!="option2") {
|
||||
SessionService.instance.setUnqualifiedInspectionItemIDJson("");
|
||||
_selectedValue = value;
|
||||
item["REFERENCE_BASIS"]=value;
|
||||
}else{
|
||||
_goUnqualifiedPage(item);
|
||||
// pushPage(HazardRegistrationPage(item), context);
|
||||
|
@ -328,8 +339,10 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
}else{
|
||||
pushPage(HazardRegistrationPage(
|
||||
item,nullResult,
|
||||
onClose: (String departmentId) {
|
||||
onClose: (String departmentId,String yinHuanText) {
|
||||
setState(() {
|
||||
this.yinHuanText=yinHuanText;
|
||||
item["REFERENCE_BASIS"]="option2";
|
||||
_selectedValue="option2";
|
||||
unqualifiedInspectionItemID=departmentId;
|
||||
});
|
||||
|
@ -347,8 +360,10 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
|
||||
pushPage(HazardRegistrationPage(
|
||||
item,result,
|
||||
onClose: (String departmentId) {
|
||||
onClose: (String departmentId,String yinHuanText) {
|
||||
setState(() {
|
||||
this.yinHuanText=yinHuanText;
|
||||
item["REFERENCE_BASIS"]="option2";
|
||||
_selectedValue="option2";
|
||||
unqualifiedInspectionItemID=departmentId;
|
||||
});
|
||||
|
@ -385,8 +400,147 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
|
||||
void _submit() {
|
||||
if (_selectedValue == null) return;
|
||||
|
||||
LoadingDialogHelper.show(context);
|
||||
_submitInvestigationItems();
|
||||
// 这里可以添加导航到下一页的代码
|
||||
// Navigator.push(context, MaterialPageRoute(builder: (_) => NextPage()));
|
||||
}
|
||||
|
||||
|
||||
Future<void> _submitInvestigationItems() async {
|
||||
|
||||
//获取定位
|
||||
Position position = await _determinePosition();
|
||||
String longitude=position.longitude.toString();
|
||||
String latitude=position.latitude.toString();
|
||||
|
||||
|
||||
bool hasNoSelectItem=false;
|
||||
for(int i=0;i<listDates.length;i++){
|
||||
final item=listDates[i];
|
||||
// final itemTwo=listDatesTwo[i];
|
||||
if(item["REFERENCE_BASIS"]=="option1"){
|
||||
upDataItemList.add( {
|
||||
"CUSTOM_ITEM_ID": item["CUSTOM_ITEM_ID"],
|
||||
"RECORDITEM_ID": item["RECORDITEM_ID"],
|
||||
"ISNORMAL": "0",
|
||||
"CHECK_RESULT": item["CHECK_QUALIFIED"],
|
||||
});
|
||||
}else if(item["REFERENCE_BASIS"]=="option2"){
|
||||
upDataItemList.add( {
|
||||
"CUSTOM_ITEM_ID": item["CUSTOM_ITEM_ID"],
|
||||
"RECORDITEM_ID": item["RECORDITEM_ID"],
|
||||
"ISNORMAL": "1",
|
||||
"CHECK_RESULT":yinHuanText.isNotEmpty?yinHuanText:item["CHECK_QUALIFIED"],
|
||||
});
|
||||
// upDataItemList.add(UpDataItem.fromJson(itemTwo["CUSTOM_ITEM_ID"], itemTwo["CUSTOM_ITEM_ID"], "1",
|
||||
// yinHuanText.isNotEmpty?yinHuanText:item["CHECK_QUALIFIED"]));
|
||||
}else if(item["REFERENCE_BASIS"]=="option3"){
|
||||
upDataItemList.add( {
|
||||
"CUSTOM_ITEM_ID": item["CUSTOM_ITEM_ID"],
|
||||
"RECORDITEM_ID": item["RECORDITEM_ID"],
|
||||
"ISNORMAL": "2",
|
||||
"CHECK_RESULT":"",
|
||||
});
|
||||
// upDataItemList.add(UpDataItem.fromJson(itemTwo["CUSTOM_ITEM_ID"], itemTwo["CUSTOM_ITEM_ID"], "2", ""));
|
||||
}else{
|
||||
hasNoSelectItem=true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(hasNoSelectItem){
|
||||
ToastUtil.showNormal(context, "还有位选择的排查项");
|
||||
LoadingDialogHelper.hide(context);
|
||||
return;
|
||||
}
|
||||
String itemsString= jsonEncode(upDataItemList);
|
||||
|
||||
try {
|
||||
final result = await ApiService.submitInvestigationItems(widget.item,longitude,latitude,itemsString,"","");
|
||||
if (result['result'] == 'success') {
|
||||
|
||||
setState(() {
|
||||
ToastUtil.showNormal(context, "提交成功");
|
||||
Navigator.pop(context);
|
||||
LoadingDialogHelper.hide(context);
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
ToastUtil.showNormal(context, "加载数据失败");
|
||||
LoadingDialogHelper.hide(context);
|
||||
// _showMessage('加载数据失败');
|
||||
}
|
||||
} catch (e) {
|
||||
LoadingDialogHelper.hide(context);
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Position> _determinePosition() async {
|
||||
bool serviceEnabled;
|
||||
LocationPermission permission;
|
||||
|
||||
// 检查定位服务是否启用
|
||||
serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
if (!serviceEnabled) {
|
||||
return Future.error('Location services are disabled.');
|
||||
}
|
||||
|
||||
// 获取权限
|
||||
permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
permission = await Geolocator.requestPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
return Future.error('Location permissions are denied');
|
||||
}
|
||||
}
|
||||
|
||||
if (permission == LocationPermission.deniedForever) {
|
||||
return Future.error(
|
||||
'Location permissions are permanently denied, we cannot request permissions.');
|
||||
}
|
||||
|
||||
// 获取当前位置
|
||||
return await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||
}
|
||||
|
||||
String truncateText(String text, {int maxLength = 17}) {
|
||||
if (text.length <= maxLength) return text;
|
||||
return '${text.substring(0, maxLength)}...';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 模拟数据模版
|
||||
class UpDataItem {
|
||||
final String CUSTOM_ITEM_ID;
|
||||
final String RECORDITEM_ID;
|
||||
final String ISNORMAL;
|
||||
final String CHECK_RESULT;
|
||||
|
||||
UpDataItem(
|
||||
this.CUSTOM_ITEM_ID,
|
||||
this.RECORDITEM_ID,
|
||||
this.ISNORMAL,
|
||||
this.CHECK_RESULT,
|
||||
);
|
||||
|
||||
factory UpDataItem.fromJson(
|
||||
String CUSTOM_ITEM_ID,
|
||||
String RECORDITEM_ID,
|
||||
String ISNORMAL,
|
||||
String CHECK_RESULT,
|
||||
) {
|
||||
return UpDataItem(
|
||||
CUSTOM_ITEM_ID, // 直接传递参数,不使用命名参数语法
|
||||
RECORDITEM_ID,
|
||||
ISNORMAL,
|
||||
CHECK_RESULT,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
||||
import 'package:qhd_prevention/http/ApiService.dart';
|
||||
import 'package:qhd_prevention/pages/app/checking_information_one_page.dart';
|
||||
import 'package:qhd_prevention/pages/home/scan_page.dart';
|
||||
import 'package:qhd_prevention/pages/home/work/danger_project_page.dart';
|
||||
import 'package:qhd_prevention/pages/my_appbar.dart';
|
||||
|
@ -28,12 +31,19 @@ class _riskListPageState extends State<RiskListPage> {
|
|||
// ];
|
||||
|
||||
List<dynamic> listDates = [];
|
||||
Map<String, dynamic> checkMap = {};
|
||||
String checkrecordId="";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
_getData();
|
||||
}
|
||||
|
||||
void _getData(){
|
||||
listDates.clear();
|
||||
switch(widget.type ){
|
||||
case 1://隐患排查
|
||||
_getRiskPointsList();
|
||||
|
@ -54,6 +64,7 @@ class _riskListPageState extends State<RiskListPage> {
|
|||
final List<dynamic> newList = result['varList'] ?? [];
|
||||
setState(() {
|
||||
listDates.addAll(newList);
|
||||
|
||||
});
|
||||
|
||||
}else{
|
||||
|
@ -73,7 +84,34 @@ class _riskListPageState extends State<RiskListPage> {
|
|||
if (result['result'] == 'success') {
|
||||
final List<dynamic> newList = result['varList'] ?? [];
|
||||
setState(() {
|
||||
|
||||
listDates.addAll(newList);
|
||||
|
||||
try{
|
||||
checkrecordId=result['CHECKRECORD_ID'];
|
||||
checkMap.addAll(result['checkmap'] ?? []);
|
||||
if(checkMap.isNotEmpty){
|
||||
for(int i=0;i<listDates.length;i++){
|
||||
try{
|
||||
String num= checkMap[listDates[i]["CHECK_ITEM"]].toString();
|
||||
(listDates[i] as Map<String, dynamic>)["checkmap"] =num;
|
||||
|
||||
}catch(e){
|
||||
print('加载数据失败:$e');
|
||||
(listDates[i] as Map<String, dynamic>)["checkmap"] ="";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}catch(e){
|
||||
for(int i=0;i<listDates.length;i++) {
|
||||
(listDates[i] as Map<String, dynamic>)["checkmap"] = "";
|
||||
}
|
||||
print('没有这些数据:$e');
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}else{
|
||||
|
@ -139,6 +177,7 @@ class _riskListPageState extends State<RiskListPage> {
|
|||
}
|
||||
|
||||
Widget _itemCell(final item) {
|
||||
|
||||
return Padding(padding: EdgeInsets.symmetric(vertical: 7, horizontal: 15),
|
||||
child: GestureDetector(
|
||||
onTap: () => _selectItem(item),
|
||||
|
@ -152,7 +191,7 @@ class _riskListPageState extends State<RiskListPage> {
|
|||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Image.asset("assets/images/zt-ing.png", width: 70, height: 70,),
|
||||
Image.asset(item["checkmap"].toString().isEmpty?"assets/images/zt-ing.png":"assets/images/zt-over.png", width: 70, height: 70,),
|
||||
const SizedBox(width: 10), // 添加间距
|
||||
Column(
|
||||
children: [
|
||||
|
@ -187,17 +226,20 @@ class _riskListPageState extends State<RiskListPage> {
|
|||
}
|
||||
}
|
||||
|
||||
void _nextHandle() {
|
||||
|
||||
}
|
||||
|
||||
void _selectItem(final item) {
|
||||
Future<void> _selectItem(final item) async {
|
||||
switch(widget.type ){
|
||||
case 1://隐患排查
|
||||
_isInElectronicFence(item);
|
||||
break;
|
||||
case 2://标准排查
|
||||
pushPage(DangerProjectPage(item), context);
|
||||
// pushPage(DangerProjectPage(item), context);
|
||||
final result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => DangerProjectPage(item)),
|
||||
);
|
||||
_getData();
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -225,6 +267,28 @@ class _riskListPageState extends State<RiskListPage> {
|
|||
}
|
||||
}
|
||||
|
||||
void _nextHandle() {
|
||||
bool canGo=true;
|
||||
for(int i=0;i<listDates.length;i++){
|
||||
try{
|
||||
int num= listDates[i]["checkmap"];
|
||||
if(1!=num){
|
||||
canGo=false;
|
||||
}
|
||||
}catch(e){
|
||||
canGo=false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!canGo){
|
||||
ToastUtil.showNormal(context, "清单为全部检查,无法提交");
|
||||
return;
|
||||
}
|
||||
pushPage(CheckingInformationOnePage(widget.id,checkrecordId), context);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -183,6 +183,8 @@ class SessionService {
|
|||
String? departmentHiddenTypeJsonStr;
|
||||
String? customRecordDangerJson;
|
||||
String? unqualifiedInspectionItemID;
|
||||
String? listItemNameJson;
|
||||
|
||||
|
||||
/// 如果以下任何一项为空,则跳转到登录页
|
||||
void loginSession(BuildContext context) {
|
||||
|
@ -226,6 +228,7 @@ class SessionService {
|
|||
|
||||
void setUnqualifiedInspectionItemIDJson(String json) => unqualifiedInspectionItemID = json;
|
||||
|
||||
void setListItemNameJson(String json) => listItemNameJson = json;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue