2025.7.5 写了连个picker,正在写隐患快报

main
xufei 2025-07-25 18:06:37 +08:00
parent 507dee2e67
commit 11d32bf42e
9 changed files with 762 additions and 113 deletions

View File

@ -35,7 +35,8 @@ class ListItemFactory {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
rightText,
_truncateText(rightText,14),
// rightText,
style: TextStyle(fontSize: 15, color: Colors.grey),
),
SizedBox(width: 2,),
@ -47,7 +48,14 @@ class ListItemFactory {
],
),
);
}
//
static String _truncateText(String text, int maxLength) {
if (text.length <= maxLength) return text;
return text.substring(0, maxLength) + '...';
}
///2
static Widget createColumnTextItem({

View File

@ -0,0 +1,83 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
///
/// Example:
/// ```dart
/// final choice = await BottomPickerTwo.show<String>(
/// context,
/// items: ['选项1', '选项2', '选项3'],
/// itemBuilder: (item) => Text(item, textAlign: TextAlign.center),
/// initialIndex: 1,
/// );
/// if (choice != null) {
/// // choice
/// }
/// ```
class BottomPickerTwo {
///
///
/// [items]:
/// [itemBuilder]: Widget
/// [initialIndex]:
/// [itemExtent]:
/// [height]:
static Future<dynamic> show<T>(
BuildContext context, {
required List<dynamic> items,
required Widget Function(dynamic item) itemBuilder,
int initialIndex = 0,
double itemExtent = 40.0,
double height = 250,
}) {
//
T selected = items[initialIndex];
return showModalBottomSheet<T>(
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
),
builder: (ctx) {
return SizedBox(
height: height,
child: Column(
children: [
//
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('取消'),
),
TextButton(
onPressed: () => Navigator.of(ctx).pop(selected),
child: const Text('确定'),
),
],
),
),
const Divider(height: 1),
//
Expanded(
child: CupertinoPicker(
scrollController:
FixedExtentScrollController(initialItem: initialIndex),
itemExtent: 30,
onSelectedItemChanged: (index) {
selected = items[index];
},
children: items.map(itemBuilder).toList(),
),
),
],
),
);
},
);
}
}

View File

@ -0,0 +1,230 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:qhd_prevention/customWidget/search_bar_widget.dart';
import 'package:qhd_prevention/http/ApiService.dart';
import '../tools/tools.dart'; // SessionService
//
class Category {
final String id;
final String name;
final List<Category> children;
Category({
required this.id,
required this.name,
this.children = const [],
});
factory Category.fromJson(Map<String, dynamic> json) {
return Category(
id: json['id'] as String,
name: json['name'] as String,
children: (json['nodes'] as List<dynamic>)
.map((e) => Category.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
}
/// id name
typedef DeptSelectHiddenTypeCallback = void Function(String id, String name);
class DepartmentPickerHiddenType extends StatefulWidget {
/// id name
final DeptSelectHiddenTypeCallback onSelected;
const DepartmentPickerHiddenType({Key? key, required this.onSelected}) : super(key: key);
@override
_DepartmentPickerHiddenTypeState createState() => _DepartmentPickerHiddenTypeState();
}
class _DepartmentPickerHiddenTypeState extends State<DepartmentPickerHiddenType> {
String selectedId = '';
String selectedName = '';
Set<String> expandedSet = {};
List<Category> original = [];
List<Category> filtered = [];
bool loading = true;
final TextEditingController _searchController = TextEditingController();
@override
void initState() {
super.initState();
//
selectedId = '';
selectedName = '';
expandedSet = {};
_searchController.addListener(_onSearchChanged);
_loadData();
}
@override
void dispose() {
_searchController.removeListener(_onSearchChanged);
_searchController.dispose();
super.dispose();
}
Future<void> _loadData() async {
try {
List<dynamic> raw;
if (SessionService.instance.departmentHiddenTypeJsonStr?.isNotEmpty ?? false) {
raw = json.decode(SessionService.instance.departmentHiddenTypeJsonStr!) as List<dynamic>;
} else {
final resultLevel = await ApiService. getHiddenLevelsListTwo();
List<dynamic> levelList = resultLevel['list'] as List;
String parentId="";
for(int i=0;i<levelList.length;i++){
String level = levelList[i]['BIANMA'];
String province= SessionService.instance.loginUser?["PROVINCE"]??"";
// null
bool isMatch = level.contains(province);
if(isMatch){
parentId=levelList[i]['DICTIONARIES_ID'];
}
}
final result = await ApiService.getHiddenTypeList(parentId);
final String nodes = result['zTreeNodes'] as String;
SessionService.instance.departmentHiddenTypeJsonStr = nodes;
raw = json.decode(nodes) as List<dynamic>;
}
setState(() {
original = raw.map((e) => Category.fromJson(e as Map<String, dynamic>)).toList();
filtered = original;
loading = false;
});
} catch (e) {
setState(() => loading = false);
}
}
void _onSearchChanged() {
final query = _searchController.text.toLowerCase().trim();
setState(() {
filtered = query.isEmpty ? original : _filterCategories(original, query);
});
}
List<Category> _filterCategories(List<Category> list, String query) {
List<Category> result = [];
for (var cat in list) {
final children = _filterCategories(cat.children, query);
if (cat.name.toLowerCase().contains(query) || children.isNotEmpty) {
result.add(Category(id: cat.id, name: cat.name, children: children));
}
}
return result;
}
Widget _buildRow(Category cat, int indent) {
final hasChildren = cat.children.isNotEmpty;
final isExpanded = expandedSet.contains(cat.id);
final isSelected = cat.id == selectedId;
return Column(
children: [
InkWell(
onTap: () {
setState(() {
if (hasChildren) {
isExpanded ? expandedSet.remove(cat.id) : expandedSet.add(cat.id);
}
selectedId = cat.id;
selectedName = cat.name;
});
},
child: Container(
color: Colors.white,
child: Row(
children: [
SizedBox(width: 16.0 * indent),
SizedBox(
width: 24,
child: hasChildren
? Icon(isExpanded ? Icons.arrow_drop_down_rounded : Icons.arrow_right_rounded,
size: 35, color: Colors.grey[600])
: const SizedBox.shrink(),
),
const SizedBox(width: 5),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Text(cat.name),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Icon(
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
color: Colors.green,
),
),
],
),
),
),
if (hasChildren && isExpanded)
...cat.children.map((c) => _buildRow(c, indent + 1)),
],
);
}
@override
Widget build(BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.7,
color: Colors.white,
child: Column(
children: [
Container(
color: Colors.white,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
children: [
GestureDetector(
onTap: () => Navigator.of(context).pop(),
child: const Text('取消', style: TextStyle(fontSize: 16)),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: SearchBarWidget(
controller: _searchController,
isShowSearchButton: false,
onSearch: (keyboard) {
},
),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).pop();
widget.onSelected(selectedId, selectedName);
},
child: const Text('确定', style: TextStyle(fontSize: 16, color: Colors.green)),
),
],
),
),
Divider(),
Expanded(
child: loading
? const Center(child: CircularProgressIndicator())
: Container(
color: Colors.white,
child: ListView.builder(
itemCount: filtered.length,
itemBuilder: (ctx, idx) => _buildRow(filtered[idx], 0),
),
),
),
],
),
);
}
}

View File

@ -664,6 +664,30 @@ U6Hzm1ninpWeE+awIDAQAB
);
}
///
static Future<Map<String, dynamic>> addImgFiles(String imagePath,String type,String id) async {
final file = File(imagePath);
if (!await file.exists()) {
throw ApiException('file_not_found', '图片不存在:$imagePath');
}
final fileName = file.path.split(Platform.pathSeparator).last;
return HttpManager().uploadFaceImage(
baseUrl: basePath,
path: '/app/feedback/upload',
fromData: {
'FOREIGN_KEY': id,
'TYPE': type,
"corpUserId":"",
'CORPINFO_ID': SessionService.instance.corpinfoId,
'USER_ID': SessionService.instance.loginUserId,
'FFILE': await MultipartFile.fromFile(
file.path,
filename: fileName
),
}
);
}
///
static Future<Map<String, dynamic>> changePassWord(String oldPwd,String confirmPwd) {
return HttpManager().request(
@ -938,6 +962,35 @@ U6Hzm1ninpWeE+awIDAQAB
},
);
}
/// 2
static Future<Map<String, dynamic>> getHiddenLevelsListTwo() {
return HttpManager().request(
basePath,
'/dictionaries/getLevels',
method: Method.post,
data: {
"DICTIONARIES_ID": '3babc15144444bdc8d763d0af2bdfff8',
"CORPINFO_ID": SessionService.instance.corpinfoId,
"USER_ID": SessionService.instance.loginUserId,
},
);
}
///
static Future<Map<String, dynamic>> getHiddenTypeList(String parentId) {
return HttpManager().request(
basePath,
'/dictionaries/listAllDictToParId',
method: Method.post,
data: {
"parentId": parentId,
"CORPINFO_ID": SessionService.instance.corpinfoId,
"USER_ID": SessionService.instance.loginUserId,
},
);
}
///
static Future<Map<String, dynamic>> getListTreePersonList(String DEPARTMENT_ID) {
return HttpManager().request(
@ -1157,29 +1210,40 @@ U6Hzm1ninpWeE+awIDAQAB
///
static Future<Map<String, dynamic>> normalRectificationSubmission(String id,String buMenId,String renYuanId) {
static Future<Map<String, dynamic>> normalRectificationSubmission(
String dataTime,String miaoShu,String acceptedPrepareType,String acceptedPlanType,
String id,String caertTime,String listName,
String standard,String method,String fund,String person,
String workTime,String time,String work,String other,String json) {
// print("============>"+ dataTime+ miaoShu+ acceptedPrepareType+ acceptedPlanType+
// id+ caertTime+ listName+ standard+ method+ fund+ person+
// workTime+ time+ work+ other+ json);
return HttpManager().request(
basePath,
'/app/hidden/rectify',
method: Method.post,
data: {
// "RECTIFICATIONTIME": _this.RECTIFICATIONTIME,
// "RECTIFYDESCR": _this.RECTIFYDESCR,
// "HAVESCHEME": _this.HAVESCHEME,
// "HAVEPLAN": _this.HAVEPLAN,
// "HIDDEN_ID": _this.id,
//
// "SCREENINGDATE": _this.pd.CREATTIME ? _this.pd.CREATTIME : '',
// "LISTNAME": _this.pd.LIST_NAME ? _this.pd.LIST_NAME : '',
// "GOVERNSTANDARDS": _this.pd.GOVERNSTANDARDS ? _this.pd.GOVERNSTANDARDS : '',
// "GOVERNMETHOD": _this.pd.GOVERNMETHOD ? _this.pd.GOVERNMETHOD : '',
// "EXPENDITURE": _this.pd.EXPENDITURE ? _this.pd.EXPENDITURE : '',
// "PRINCIPAL": _this.pd.PRINCIPAL ? _this.pd.PRINCIPAL : '',
// "PROGRAMMING": _this.pd.PROGRAMMING ? _this.pd.PROGRAMMING : '',
// "TIMELIMITFOR": _this.pd.TIMELIMITFOR ? _this.pd.TIMELIMITFOR : '',
// "JOBREQUIREMENT": _this.pd.JOBREQUIREMENT ? _this.pd.JOBREQUIREMENT : '',
// "OTHERBUSINESS": _this.pd.OTHERBUSINESS ? _this.pd.OTHERBUSINESS : '',
// "OTHER": JSON.stringify(_this.other),
"RECTIFICATIONTIME": dataTime,
"RECTIFYDESCR": miaoShu,
"HAVESCHEME": acceptedPrepareType,
"HAVEPLAN": acceptedPlanType,
"HIDDEN_ID": id,
"SCREENINGDATE": caertTime.isNotEmpty ? caertTime : '',
"LISTNAME": listName.isNotEmpty ? caertTime : '',
"GOVERNSTANDARDS": standard,
"GOVERNMETHOD": method,
"EXPENDITURE": fund,
"PRINCIPAL": person,
"PROGRAMMING": workTime,
"TIMELIMITFOR": time,
"JOBREQUIREMENT": work,
"OTHERBUSINESS": other,
"OTHER": json,
"CORPINFO_ID": SessionService.instance.corpinfoId,
"USER_ID": SessionService.instance.loginUserId,
},
@ -1187,6 +1251,20 @@ U6Hzm1ninpWeE+awIDAQAB
}
///
static Future<Map<String, dynamic>> getHazardLevel() {
return HttpManager().request(
basePath,
'/dictionaries/getLevels?tm=${DateTime.now().millisecondsSinceEpoch}',
method: Method.post,
data: {
"DICTIONARIES_ID": '5e7cf8620ba54ad89719d0be62133c7a',
"CORPINFO_ID": SessionService.instance.corpinfoId,
"USER_ID": SessionService.instance.loginUserId,
},
);
}
}

View File

@ -1,9 +1,16 @@
import 'dart:io';
import 'package:flutter/material.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_picker.dart';
import 'package:qhd_prevention/customWidget/department_picker_hidden_type.dart';
import 'package:qhd_prevention/pages/my_appbar.dart';
import '../../../customWidget/photo_picker_row.dart';
import '../../../http/ApiService.dart';
class QuickReportPage extends StatefulWidget {
const QuickReportPage({super.key});
@ -17,13 +24,43 @@ class _QuickReportPageState extends State<QuickReportPage> {
final _partController = TextEditingController();
final _dangerDetailController = TextEditingController();
final String _repairLevel = "请选择";
final String _repairType = "请选择";
final String _dangerOrganize = "请选择";
final String _dangerTime = "请选择";
String _repairLevel = "";
late bool _isDanger = false;
late List<dynamic> _hazardLeveLlist = []; //
dynamic _hazardLeve;
String yinHuanId = "";
String yinHuanName = "";
String buMenId = "";
String buMenName = "";
String dataTime = "";
@override
void initState() {
// TODO: implement initState
super.initState();
_getHazardLevel();
}
Future<void> _getHazardLevel() async {
try {
final result = await ApiService.getHazardLevel();
if (result['result'] == 'success') {
final List<dynamic> newList = result['varList'] ?? [];
setState(() {
_hazardLeveLlist.addAll(newList);
});
}
} catch (e) {
print('Error fetching data: $e');
}
}
@override
void dispose() {
_standardController.dispose();
@ -41,14 +78,14 @@ class _QuickReportPageState extends State<QuickReportPage> {
//
_pageDetail(),
//
Container(
padding: const EdgeInsets.all(15),
color: Colors.white,
child: Text(
' 严禁在本互联网非涉密平台处理、传输国家秘密和工作秘密,请确认扫描、传输的文件资料不涉及国家秘密和工作秘密',
style: TextStyle(fontSize: 14, color: Colors.red),
),
),
// Container(
// padding: const EdgeInsets.all(15),
// color: Colors.white,
// child: Text(
// ' 严禁在本互联网非涉密平台处理、传输国家秘密和工作秘密,请确认扫描、传输的文件资料不涉及国家秘密和工作秘密',
// style: TextStyle(fontSize: 14, color: Colors.red),
// ),
// ),
],
),
);
@ -111,18 +148,53 @@ class _QuickReportPageState extends State<QuickReportPage> {
_partController,
),
),
_buildSectionContainer(
GestureDetector(
onTap: () async {
final choice = await BottomPickerTwo.show<String>(
context,
items: _hazardLeveLlist,
itemBuilder: (item) => Text(item, textAlign: TextAlign.center),
initialIndex: 0,
);
if (choice != null) {
setState(() {
_hazardLeve = choice;
_repairLevel=_hazardLeve[""];
});
}
},
child: _buildSectionContainer(
child: ListItemFactory.createRowSpaceBetweenItem(
leftText: "隐患级别",
rightText: _repairLevel,
rightText: _repairLevel.isNotEmpty?_repairLevel:"请选择",
isRight: true,
),
),
_buildSectionContainer(
child: ListItemFactory.createRowSpaceBetweenItem(
leftText: "隐患类型",
rightText: _repairType,
isRight: true,
),
GestureDetector(
onTap: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
barrierColor: Colors.black54,
backgroundColor: Colors.transparent,
builder:
(ctx) => DepartmentPickerHiddenType(
onSelected: (id, name) async {
setState(() {
yinHuanId = id;
yinHuanName = name;
});
},
),
);
},
child: _buildSectionContainer(
child: ListItemFactory.createRowSpaceBetweenItem(
leftText: "隐患类型",
rightText: yinHuanName.isNotEmpty?yinHuanName:"请选择",
isRight: true,
),
),
),
_buildSectionContainer(
@ -169,25 +241,68 @@ class _QuickReportPageState extends State<QuickReportPage> {
if (!_isDanger)
Column(
children: [
_buildSectionContainer(
child: ListItemFactory.createRowSpaceBetweenItem(
leftText: "整改责任部门",
rightText: _dangerOrganize,
isRight: true,
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;
});
},
),
);
},
child: _buildSectionContainer(
child: ListItemFactory.createRowSpaceBetweenItem(
leftText: "整改责任部门",
rightText: buMenName.isNotEmpty ? buMenName : "请选择",
isRight: true,
),
),
),
_buildSectionContainer(
child: ListItemFactory.createRowSpaceBetweenItem(
leftText: "整改期限",
rightText: _dangerTime,
isRight: true,
GestureDetector(
onTap: () {
showDialog(
context: context,
builder:
(_) => HDatePickerDialog(
initialDate: DateTime.now(),
onCancel: () => Navigator.of(context).pop(),
onConfirm: (selected) {
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(text: "提交", backgroundColor: Colors.blue),
CustomButton(
onPressed: () {},
text: "提交",
backgroundColor: Colors.blue,
),
],
),
),

View File

@ -93,26 +93,27 @@ class ApplicationPage extends StatelessWidget {
// 使
final List<Map<String, dynamic>> buttonInfos = [
{
'title': '隐患排查',
'title': '隐患快报',
'list': [
{'item': AppItem.riskInspection, 'icon': 'assets/icon-apps/icon-zl-6.png', 'title': '隐患排查', 'num': 0},
{'item': AppItem.quickReport, 'icon': 'assets/icon-apps/icon-pc-1.png', 'title': '隐患快报', 'num': 2},
{'item': AppItem.checkRecord, 'icon': 'assets/icon-apps/icon-zl-2.png', 'title': '检查记录', 'num': 0},
],
},
{
'title': '专项检',
'title': '隐患排',
'list': [
{'item': AppItem.specialRectification, 'icon': 'assets/icon-apps/icon-pc-1.png', 'title': '隐患整改', 'num': 5},
{'item': AppItem.specialRecord, 'icon': 'assets/icon-apps/icon-zl-2.png', 'title': '隐患记录', 'num': 0},
{'item': AppItem.riskInspection, 'icon': 'assets/icon-apps/icon-zl-6.png', 'title': '隐患排查', 'num': 0},
{'item': AppItem.checkRecord, 'icon': 'assets/icon-apps/icon-zl-2.png', 'title': '检查记录', 'num': 0},
// {'item': AppItem.specialRectification, 'icon': 'assets/icon-apps/icon-pc-1.png', 'title': '隐患整改', 'num': 5},
// {'item': AppItem.specialRecord, 'icon': 'assets/icon-apps/icon-zl-2.png', 'title': '隐患记录', 'num': 0},
],
},
{
'title': '监管帮扶',
'list': [
{'item': AppItem.supervisionRectification, 'icon': 'assets/icon-apps/icon-pc-1.png', 'title': '隐患整改', 'num': 2},
{'item': AppItem.supervisionRecord, 'icon': 'assets/icon-apps/icon-zl-2.png', 'title': '隐患记录', 'num': 0},
{'item': AppItem.supervisionRectification, 'icon': 'assets/icon-apps/icon-zl-6.png', 'title': '标准排查', 'num': 2},
{'item': AppItem.supervisionRecord, 'icon': 'assets/icon-apps/icon-zl-2.png', 'title': '检查记录', 'num': 0},
],
},
@ -131,7 +132,7 @@ class ApplicationPage extends StatelessWidget {
'title': '监测预警',
'list': [
{'item': AppItem.aiAlarm, 'icon': 'assets/icon-apps/icon-pc-1.png', 'title': 'AI报警', 'num': 0},
// {'item': AppItem.supervisionRecord, 'icon': 'assets/icon-apps/icon-zl-2.png', 'title': '隐患记录', 'num': 0},
],
},
];

View File

@ -17,10 +17,31 @@ class DepartmentEntry {
String department;
String responsible;
String index;
String departmentId;
String responsibleId;
DepartmentEntry({
required this.department,
required this.responsible,
required this.index,
required this.departmentId,
required this.responsibleId,
});
// Map
Map<String, dynamic> toJson() {
return {
'DEPARTMENT_ID': departmentId,
'USER_ID': responsibleId,
'DEPARTMENT_NAME': department,
'USER_NAME': responsible,
'index': index,
};
}
}
///
@ -28,12 +49,12 @@ class DannerRepair extends StatefulWidget {
DannerRepair(this.pd, {super.key});
final Map<String, dynamic> pd;
final _DannerRepairState DannerRepairState=_DannerRepairState();
@override
State<DannerRepair> createState() => DannerRepairState;
State<DannerRepair> createState() => DannerRepairState();
}
class _DannerRepairState extends State<DannerRepair> {
class DannerRepairState extends State<DannerRepair> {
//
bool acceptedPrepare = false;
@ -41,7 +62,6 @@ class _DannerRepairState extends State<DannerRepair> {
//
bool acceptedPlan = false;
final standardController = TextEditingController();
final methodController = TextEditingController();
final fundController = TextEditingController();
@ -50,10 +70,11 @@ class _DannerRepairState extends State<DannerRepair> {
final timeController = TextEditingController();
final workController = TextEditingController();
final otherController = TextEditingController();
final TextEditingController miaoShuController = TextEditingController();
late var _selectData = DateTime.now();
late TextEditingController miaoShuController;
String dataTime="";
//
List<String> gaiHouImages = [];
@ -65,20 +86,20 @@ class _DannerRepairState extends State<DannerRepair> {
final List<DepartmentEntry> _departments = [
DepartmentEntry(department: '请选择', responsible: '请选择'),
final List<DepartmentEntry> departments = [
DepartmentEntry(department: '请选择', responsible: '请选择',index:'',departmentId: '',responsibleId:''),
];
void _addDepartment() {
setState(() {
_departments.add(DepartmentEntry(department: '请选择', responsible: '请选择'));
departments.add(DepartmentEntry(department: '请选择', responsible: '请选择',index:'',departmentId: '',responsibleId:''));
});
}
void _removeDepartment(int index) {
if (index == 0) return; //
setState(() {
_departments.removeAt(index);
departments.removeAt(index);
});
}
@ -100,6 +121,7 @@ class _DannerRepairState extends State<DannerRepair> {
timeController.dispose();
workController.dispose();
otherController.dispose();
miaoShuController.dispose();
super.dispose();
}
@ -203,9 +225,9 @@ class _DannerRepairState extends State<DannerRepair> {
Column(
children: List.generate(
_departments.length,
departments.length,
(index) => _departmentItem(
_departments[index],
departments[index],
index,
showLabel: index == 0,
),
@ -275,7 +297,7 @@ class _DannerRepairState extends State<DannerRepair> {
Widget _acceptPrepare() {
final fields = [
_buildReadOnlyRow("排查日期", widget.pd["CREATTIME"]),
_buildReadOnlyRow("隐患清单", "-----"),
_buildReadOnlyRow("隐患清单", ""),
ListItemFactory.createBuildMultilineInput("治理标准", "请输入治理标准", standardController),
ListItemFactory.createBuildMultilineInput("治理方法", "请输入治理方法", methodController),
ListItemFactory.createBuildMultilineInput("经费落实", "请输入经费落实", fundController),
@ -323,7 +345,7 @@ class _DannerRepairState extends State<DannerRepair> {
decoration: BoxDecoration(
border: Border.all(color: Colors.black12, width: 1),
),
child: _noAccepet_repair(false),
child: _noAccepet_repair(false,index),
),
// num > 1
@ -346,15 +368,12 @@ class _DannerRepairState extends State<DannerRepair> {
),
);
}
// #region
Widget _noAccepet_repair(bool _accept) {
String buMenId="";
String buMenName="";
String renYuanId="";
String renYuanName="";
//
late List<Map<String, dynamic>> _personCache = [];
//
List<Map<String, dynamic>> _personCache = [];
// #region
Widget _noAccepet_repair(bool _accept,int index, ) {
return Column(
children: [
@ -368,14 +387,20 @@ class _DannerRepairState extends State<DannerRepair> {
builder: (ctx) => DepartmentPicker(onSelected: (id, name) async {
setState(() {
buMenId=id;
buMenName=name;
// buMenId=id;
// buMenName=name;
//
// //
// renYuanId="";
// renYuanName="";
departments[index].department=name;
departments[index].departmentId=id;
//
renYuanId="";
renYuanName="";
departments[index].responsible="";
departments[index].responsibleId="";
});
//
final result = await ApiService.getListTreePersonList(id);
_personCache=List<Map<String, dynamic>>.from(
@ -394,7 +419,7 @@ class _DannerRepairState extends State<DannerRepair> {
),
child: ListItemFactory.createRowSpaceBetweenItem(
leftText: "整改部门",
rightText: buMenName,
rightText: departments[index].department.isNotEmpty?departments[index].department:"请选择",
isRight: true,
),
),
@ -407,7 +432,7 @@ class _DannerRepairState extends State<DannerRepair> {
GestureDetector(
onTap: () {
if ( renYuanId.isEmpty) {
if ( departments[index].departmentId.isEmpty) {
ToastUtil.showNormal(context, '请先选择部门');
return;
}
@ -416,9 +441,14 @@ class _DannerRepairState extends State<DannerRepair> {
personsData: _personCache,
onSelected: (userId, name) {
setState(() {
renYuanId = userId;
renYuanName = name;
// renYuanId = userId;
// renYuanName = name;
departments[index].responsible=name;
departments[index].responsibleId=userId;
departments[index].index=(index-1).toString();
});
},
);
},
@ -430,7 +460,7 @@ class _DannerRepairState extends State<DannerRepair> {
),
child: ListItemFactory.createRowSpaceBetweenItem(
leftText: "整改负责人",
rightText: renYuanName,
rightText: departments[index].responsible.isNotEmpty?departments[index].responsible:"请选择",
isRight: true,
),
),

View File

@ -57,6 +57,8 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
late List<Map<String, dynamic>> _personCache = [];
late DannerRepair dannerRepair;
//
final GlobalKey<DannerRepairState> dannerRepairKey = GlobalKey();
@override
void initState() {
@ -123,6 +125,13 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
setState(() {
pd = data['pd'];
buMenId=pd["RECTIFICATIONDEPT"];
buMenName=pd["RECTIFICATIONDEPTNAME"];
renYuanId=pd["RECTIFICATIONOR"];
renYuanName=pd["RECTIFICATIONORNAME"];
hs = data['hs'] ?? {};
//
@ -357,7 +366,7 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
Widget _getRepairState() {
dannerRepair= DannerRepair(pd);
dannerRepair= DannerRepair(pd,key: dannerRepairKey, );
return dannerRepair;
}
@ -449,77 +458,90 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
Future<void> _normalRectificationSubmission() async {
try {
String miaoShu= dannerRepair.DannerRepairState.miaoShuController.text;
String dataTime= dannerRepairKey.currentState!.dataTime;
if(dataTime.isEmpty){
ToastUtil.showNormal(context, "请选择整改时间");
return;
}
String miaoShu= dannerRepairKey.currentState!.miaoShuController.text.trim();
if(miaoShu.isEmpty){
ToastUtil.showNormal(context, "请填整改描述");
return;
}
String dataTime= dannerRepair.DannerRepairState.dataTime;
if(dataTime.isEmpty){
ToastUtil.showNormal(context, "请选择整改时间");
return;
}
List<String> gaiHouImages = dannerRepair.DannerRepairState.gaiHouImages;
List<String> gaiHouImages = dannerRepairKey.currentState!.gaiHouImages;
if(gaiHouImages.isEmpty){
ToastUtil.showNormal(context, "请上传整改后照片");
return;
}
String acceptedPrepareType="0";
String standard="";
String method="";
String fund="";
String person="";
String workTime="";
String time="";
String work="";
String other="";
List<String> fangAnImages =[];
//
bool acceptedPrepare= dannerRepair.DannerRepairState.acceptedPrepare;
bool acceptedPrepare= dannerRepairKey.currentState!.acceptedPrepare;
if(acceptedPrepare){
acceptedPrepareType="1";
String standard= dannerRepair.DannerRepairState.standardController.text;
standard= dannerRepairKey.currentState!.standardController.text;
if(standard.isEmpty){
ToastUtil.showNormal(context, "请输入治理标准要求");
return;
}
String method= dannerRepair.DannerRepairState.methodController.text;
method= dannerRepairKey.currentState!.methodController.text;
if(method.isEmpty){
ToastUtil.showNormal(context, "请输入治理方法");
return;
}
String fund= dannerRepair.DannerRepairState.fundController.text;
fund= dannerRepairKey.currentState!.fundController.text;
if(fund.isEmpty){
ToastUtil.showNormal(context, "请输入经费和物资的落实");
return;
}
String person= dannerRepair.DannerRepairState.personController.text;
person= dannerRepairKey.currentState!.personController.text;
if(person.isEmpty){
ToastUtil.showNormal(context, "请输入负责治理人员");
return;
}
String workTime= dannerRepair.DannerRepairState.workTimeController.text;
workTime= dannerRepairKey.currentState!.workTimeController.text;
if(workTime.isEmpty){
ToastUtil.showNormal(context, "请输入工时安排");
return;
}
String time= dannerRepair.DannerRepairState.timeController.text;
time= dannerRepairKey.currentState!.timeController.text;
if(time.isEmpty){
ToastUtil.showNormal(context, "请输入时限要求");
return;
}
String work= dannerRepair.DannerRepairState.workController.text;
work= dannerRepairKey.currentState!.workController.text;
if(work.isEmpty){
ToastUtil.showNormal(context, "请输入工作要求");
return;
}
String other= dannerRepair.DannerRepairState.otherController.text;
other= dannerRepairKey.currentState!.otherController.text;
if(other.isEmpty){
ToastUtil.showNormal(context, "请输入工作要求");
return;
}
List<String> fangAnImages = dannerRepair.DannerRepairState.fangAnImages;
fangAnImages = dannerRepairKey.currentState!.fangAnImages;
if(fangAnImages.isEmpty){
ToastUtil.showNormal(context, "请上传方案照片");
return;
@ -527,12 +549,14 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
}
String acceptedPlanType="0";
List<String> jiHuaImages =[];
//
bool acceptedPlan= dannerRepair.DannerRepairState.acceptedPlan;
bool acceptedPlan= dannerRepairKey.currentState!.acceptedPlan;
if(acceptedPlan){
List<String> fangAnImages = dannerRepair.DannerRepairState.jiHuaImages;
if(fangAnImages.isEmpty){
acceptedPlanType="1";
jiHuaImages = dannerRepairKey.currentState!.jiHuaImages;
if(jiHuaImages.isEmpty){
ToastUtil.showNormal(context, "请上传计划照片");
return;
}
@ -540,10 +564,59 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
List<DepartmentEntry> departments = dannerRepairKey.currentState!.departments;
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;
}
final result = await ApiService.normalRectificationSubmission(pd["HIDDEN_ID"],buMenId,renYuanId);
if(departmentsSameMan){
ToastUtil.showNormal(context, "不能选择重复的验收部门负责人");
return;
}
String caertTime= pd["CREATTIME"];
String listName= "";//pd["LIST_NAME"];
String id= pd["HIDDEN_ID"];
// JSON
String json = _convertDepartmentsToJson(departments);
for(int i=0;i<gaiHouImages.length;i++){
_addImgFiles(gaiHouImages[i],"4",id) ;
}
for(int i=0;i<fangAnImages.length;i++){
_addImgFiles(fangAnImages[i],"8",id) ;
}
for(int i=0;i<jiHuaImages.length;i++){
_addImgFiles(jiHuaImages[i],"22",id) ;
}
final result = await ApiService.normalRectificationSubmission(
dataTime, miaoShu, acceptedPrepareType, acceptedPlanType,
id, caertTime, listName,
standard, method, fund, person,
workTime, time, work, other, json);
if (result['result'] == 'success') {
setState(() {
ToastUtil.showNormal(context, "提交成功");
@ -581,6 +654,34 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
}
}
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 "";
}
}
String _getSourceText(String? source) {
switch (source) {
@ -602,3 +703,5 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
}
}

View File

@ -158,6 +158,7 @@ class SessionService {
String? dangerJson;
String? riskJson;
String? departmentJsonStr;
String? departmentHiddenTypeJsonStr;
///
void loginSession(BuildContext context) {