From 744f065df13d2207c75c00ff11e19d881d30248f Mon Sep 17 00:00:00 2001 From: hs <873121290@qq.com> Date: Mon, 7 Jul 2025 16:49:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/home/work/danger_repair_page.dart | 287 +++++--------------- 1 file changed, 72 insertions(+), 215 deletions(-) diff --git a/lib/pages/home/work/danger_repair_page.dart b/lib/pages/home/work/danger_repair_page.dart index 6ebdc93..5c9ed88 100644 --- a/lib/pages/home/work/danger_repair_page.dart +++ b/lib/pages/home/work/danger_repair_page.dart @@ -1,18 +1,14 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; -import 'package:photo_view/photo_view.dart'; -import 'package:photo_view/photo_view_gallery.dart'; import 'package:qhd_prevention/customWidget/custom_button.dart'; -import 'package:qhd_prevention/customWidget/single_image_viewer.dart'; +import 'package:qhd_prevention/pages/home/work/dangerTypeItems/danger_detail.dart'; +import 'package:qhd_prevention/pages/home/work/dangerTypeItems/finish/danger_acceptance_finish.dart'; +import 'package:qhd_prevention/pages/home/work/dangerTypeItems/wait/danger_acceptance.dart'; +import 'package:qhd_prevention/pages/home/work/dangerTypeItems/wait/danner_repair.dart'; import 'package:qhd_prevention/pages/home/work/danger_wait_list_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 '../../../customWidget/ItemWidgetFactory.dart'; -import '../../../customWidget/date_picker_dialog.dart'; -import '../../../customWidget/photo_picker_row.dart'; +import 'dangerTypeItems/finish/danner_repair_finish.dart'; class DangerRepairPage extends StatefulWidget { const DangerRepairPage(this.dangerType, {Key? key}) : super(key: key); @@ -24,8 +20,8 @@ class DangerRepairPage extends StatefulWidget { } class _DangerRepairPageState extends State { + // 是否整改 bool _accepted = false; - var _selectData = DateTime.now(); Widget build(BuildContext context) { return Scaffold( @@ -36,183 +32,95 @@ class _DangerRepairPageState extends State { // 可滚动内容区域 Expanded( child: SingleChildScrollView( - padding: const EdgeInsets.all(15), + padding: const EdgeInsets.symmetric(horizontal: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - // 第一部分:内嵌列表 - _danner_detail(), - - ListItemFactory.createYesNoSection( - title: '是否正常整改', - yesLabel: '是', - noLabel: '否', - groupValue: _accepted, - onChanged: (val) { - setState(() { - _accepted = val; - }); - }, - ), - // 整改选项 - _accepted ? _danner_repair() : _noAccepet_repair(_accepted), - - const SizedBox(height: 20), - CustomButton(text: "提交", backgroundColor: Colors.blue), + // 隐患详情 + DangerDetail(), + SizedBox(height: 15), + if (widget.dangerType == DangerType.wait) // 隐患整改 + _danner_type_wait() + else if (widget.dangerType == + DangerType.waitAcceptance) ...[ // 已整改、待验收 + DannerRepairFinish(), + SizedBox(height: 15), + DangerAcceptance(), + const SizedBox(height: 20), + CustomButton( + text: "提交", + backgroundColor: Colors.blue, + onPressed: () { + _submitToServer(); + }, + ), + ] else if (widget.dangerType == DangerType.acceptanced) ...[ + DannerRepairFinish(), + SizedBox(height: 15), + DangerAcceptanceFinish() + ] + else + SizedBox(), ], ), ), ), // 底部警示文字,固定在页面底部 - Container( - padding: const EdgeInsets.all(15), - color: Colors.white, - child: Text( - ' 严禁在本互联网非涉密平台处理、传输国家秘密和工作秘密,请确认扫描、传输的文件资料不涉及国家秘密和工作秘密', - style: TextStyle(fontSize: 14, color: Colors.red), + if (widget.dangerType == DangerType.wait || + widget.dangerType == DangerType.waitAcceptance) + Container( + padding: const EdgeInsets.all(15), + color: Colors.white, + child: Text( + ' 严禁在本互联网非涉密平台处理、传输国家秘密和工作秘密,请确认扫描、传输的文件资料不涉及国家秘密和工作秘密', + style: TextStyle(fontSize: 14, color: Colors.red), + ), ), - ), ], ), ), ); } - /// 整改 - Widget _danner_repair() { - return Container( - padding: EdgeInsets.only(bottom: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(5), - ), + /// 隐患整改 + Widget _danner_type_wait() { + return SizedBox( child: Column( children: [ - ListItemFactory.createBuildSimpleSection("隐患整改"), - Divider(height: 1), - Container( - height: 130, - padding: EdgeInsets.all(15), - child: Column( - children: [ - Row( - children: [HhTextStyleUtils.mainTitle("隐患描述", fontSize: 15)], - ), - TextField( - keyboardType: TextInputType.multiline, - maxLines: null, // 不限制行数,输入多少文字就撑开多少行 - style: TextStyle(fontSize: 15), - decoration: InputDecoration( - hintText: '请对隐患进行详细描述(必填项)', - border: InputBorder.none, - ), - ), - ], - ), - ), - Divider(height: 1), - GestureDetector( - onTap: () { - showDialog( - context: context, - builder: - (_) => HDatePickerDialog( - initialDate: DateTime.now(), - onCancel: () => Navigator.of(context).pop(), - onConfirm: (selected) { - print('选中日期: $selected'); - Navigator.of(context).pop(); - setState(() { - _selectData = selected; - }); - }, - ), - ); + ListItemFactory.createYesNoSection( + horizontalPadding: 0, + + title: '是否正常整改', + yesLabel: '是', + noLabel: '否', + groupValue: _accepted, + onChanged: (val) { + setState(() { + _accepted = val; + }); }, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10), - child: ListItemFactory.createRowSpaceBetweenItem( - leftText: "整改日期", - rightText: "请选择", - isRight: true, - ), - ), ), - Divider(), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10), - child: ListItemFactory.createRowSpaceBetweenItem( - leftText: "整改后照片", - rightText: "0/4", - ), + // 整改选项 + _accepted ? DannerRepair() : _noAccepet_repair(_accepted), + + const SizedBox(height: 20), + CustomButton( + text: "提交", + backgroundColor: Colors.blue, + onPressed: () { + _submitToServer(); + }, ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10), - child: PhotoPickerRow( - maxCount: 4, - onChanged: (List images) { - // images 列表更新 - }, - ), - ), - Divider(), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - CustomButton( - onPressed: () {}, - text: "添加", - backgroundColor: Colors.blue, - borderRadius: 17, - height: 34, - padding: EdgeInsets.symmetric(horizontal: 20), - ), - ], - ), - _departmentItem(1), - _departmentItem(2), - Divider(), - // ListItemFactory.createYesNoSection(title: "是否有整改方案", yesLabel: "", noLabel: noLabel, groupValue: groupValue, onChanged: onChanged) ], ), ); } - Widget _departmentItem(int index) { - 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 > 1 时,左上角显示删除按钮 - if (index > 1) - Positioned( - top: -20, - left: -20, - child: IconButton( - padding: EdgeInsets.zero, - constraints: const BoxConstraints(), - icon: const Icon(Icons.cancel, color: Colors.red, size: 25), - onPressed: () { - // 这里处理删除逻辑,比如: - // setState(() => _items.removeAt(index)); - }, - ), - ), - ], - ), - ); + void _submitToServer() { + // Todo 发送给接口... } - - /// 不整改 + // #region 不整改 Widget _noAccepet_repair(bool _accept) { return Column( children: [ @@ -228,7 +136,10 @@ class _DangerRepairPageState extends State { isRight: true, ), ), - Divider(height: 10,color: _accept ? Colors.black12 : Colors.transparent,), + Divider( + height: 10, + color: _accept ? h_backGroundColor() : Colors.transparent, + ), Container( padding: EdgeInsets.symmetric(horizontal: 10), decoration: BoxDecoration( @@ -244,58 +155,4 @@ class _DangerRepairPageState extends State { ], ); } - - /// 隐患详情 - Widget _danner_detail() { - return Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(5), - ), - padding: const EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ListView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: 16, - itemBuilder: (context, index) { - if (index == 0) { - return ListItemFactory.createAloneTextItem( - text: "地坪漆漆未分配全皮肤期漆未分配全皮肤期漆未分配全皮肤期未分配全皮肤期间哦飞机哦脾气金佛怕", - ); - } else if ((index > 0 && index < 4) || - index == 5 || - (index > 6 && index < 15)) { - return ListItemFactory.createRowSpaceBetweenItem( - leftText: "隐患来源", - rightText: "隐患排查", - ); - } else if (index == 4 || index == 6) { - return ListItemFactory.createColumnTextItem( - topText: "存在风险", - bottomText: "哦IQ好然后前后hi前后哦i", - ); - } - return ListItemFactory.createTextImageItem( - text: "隐患照片", - imageUrl: - "https://pic.rmb.bdstatic.com/bjh/news/100b8b78cbd136ede03249d9f3b3f5c42221.jpeg", - onImageTapped: () { - pushPage( - SingleImageViewer( - imageUrl: - "https://pic.rmb.bdstatic.com/bjh/news/100b8b78cbd136ede03249d9f3b3f5c42221.jpeg", - ), - context, - ); - }, - ); - }, - ), - ], - ), - ); - } }