From 7c5afab92b849e3c37dcaa91493971cdce0a0940 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Mon, 1 Nov 2021 16:16:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E6=96=BD=E6=A3=80=E6=9F=A5=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E4=BF=A1=E6=81=AF=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../facilities/facilities_card.dart | 3 + .../facilities_inspect_report_page.dart | 105 ++++++++++-------- 2 files changed, 63 insertions(+), 45 deletions(-) diff --git a/lib/ui/manage_pages/facilities/facilities_card.dart b/lib/ui/manage_pages/facilities/facilities_card.dart index 7d16f82..a54ec3e 100644 --- a/lib/ui/manage_pages/facilities/facilities_card.dart +++ b/lib/ui/manage_pages/facilities/facilities_card.dart @@ -18,6 +18,7 @@ class FacilitiesCard extends StatefulWidget { final int facilitiesType; final FacilitiesCheckListModel model; final VoidCallback? callRefresh; + FacilitiesCard( {Key? key, required this.index, @@ -74,6 +75,7 @@ class _FacilitiesCardState extends State { await Get.to(() => FacilitiesInspectReportPage( facilitiesType: widget.facilitiesType, id: widget.model.id!, + model: widget.index != 1 ? widget.model : null, )); widget.callRefresh!(); }, @@ -98,6 +100,7 @@ class _FacilitiesCardState extends State { await Get.to(() => FacilitiesInspectReportPage( facilitiesType: widget.facilitiesType, id: widget.model.id!, + model: widget.index != 1 ? widget.model : null, )); widget.callRefresh!(); }); diff --git a/lib/ui/manage_pages/facilities/facilities_inspect_report_page.dart b/lib/ui/manage_pages/facilities/facilities_inspect_report_page.dart index f9c4a0c..19013cc 100644 --- a/lib/ui/manage_pages/facilities/facilities_inspect_report_page.dart +++ b/lib/ui/manage_pages/facilities/facilities_inspect_report_page.dart @@ -3,30 +3,33 @@ import 'dart:io'; // Flutter imports: import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/facilities/facilities_check_list_model.dart'; +// Project imports: +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/ui/widgets/app_widgets/aku_pick_image_widget.dart'; +import 'package:aku_community_manager/ui/widgets/app_widgets/aku_single_check_button.dart'; +import 'package:aku_community_manager/ui/widgets/app_widgets/bee_grid_image_view.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; - // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; -// Project imports: -import 'package:aku_community_manager/style/app_style.dart'; -import 'package:aku_community_manager/ui/widgets/app_widgets/aku_pick_image_widget.dart'; -import 'package:aku_community_manager/ui/widgets/app_widgets/aku_single_check_button.dart'; -import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; - class FacilitiesInspectReportPage extends StatefulWidget { final int facilitiesType; final int id; + final FacilitiesCheckListModel? model; + FacilitiesInspectReportPage({ Key? key, /*required*/ required this.facilitiesType, /*required*/ required this.id, + this.model, }) : super(key: key); @override @@ -39,7 +42,9 @@ class _FacilitiesInspectReportPageState // List? _selfPhotos; late List _scenePhotos; String? _describtion; - int _scene = 1;//设施设备状况 1为正常 2为异常 + int _scene = 1; //设施设备状况 1为正常 2为异常 + bool get editEnable => widget.model == null; + @override Widget build(BuildContext context) { return AkuScaffold( @@ -142,9 +147,7 @@ class _FacilitiesInspectReportPageState return Column( children: [ Row( - children: [ - '$title'.text.color(kTextPrimaryColor).size(32.sp).make() - ], + children: ['$title'.text.color(kTextPrimaryColor).size(32.sp).make()], ), 32.w.heightBox, Row( @@ -153,20 +156,24 @@ class _FacilitiesInspectReportPageState text: '正常', value: 1, gropValue: _scene, - onPressed: () { - _scene = 1; - setState(() {}); - }, + onPressed: !editEnable + ? () {} + : () { + _scene = 1; + setState(() {}); + }, ), 80.w.widthBox, AkuSingleCheckButton( text: '异常', value: 2, gropValue: _scene, - onPressed: () { - _scene = 2; - setState(() {}); - }, + onPressed: !editEnable + ? () {} + : () { + _scene = 2; + setState(() {}); + }, ), ], ), @@ -181,25 +188,27 @@ class _FacilitiesInspectReportPageState color: Color(0xFFE8E8E8), ), ), - child: TextField( - minLines: 5, - maxLines: 10, - autofocus: false, - onChanged: (value) { - _describtion = value; - }, - decoration: InputDecoration( - hintText: '请详细描述异常情况', - hintStyle: TextStyle( - fontSize: 28.sp, - color: kTextSubColor, - ), - contentPadding: - EdgeInsets.symmetric(vertical: 16.w, horizontal: 24.w), - border: InputBorder.none, - isDense: true, - ), - ), + child: !editEnable + ? (widget.model!.detail ?? '').text.size(28.sp).black.make() + : TextField( + minLines: 5, + maxLines: 10, + autofocus: false, + onChanged: (value) { + _describtion = value; + }, + decoration: InputDecoration( + hintText: '请详细描述异常情况', + hintStyle: TextStyle( + fontSize: 28.sp, + color: kTextSubColor, + ), + contentPadding: + EdgeInsets.symmetric(vertical: 16.w, horizontal: 24.w), + border: InputBorder.none, + isDense: true, + ), + ), ), ], ) @@ -244,13 +253,19 @@ class _FacilitiesInspectReportPageState // ], // ), 32.w.heightBox, - AkuPickImageWidget( - description: '上传现场照片', - onChanged: (files) { - _scenePhotos = files; - setState(() {}); - }, - ) + !editEnable + ? BeeGridImageView( + urls: (widget.model!.imgList ?? []) + .map((e) => API.image(e.url ?? '')) + .toList(), + ) + : AkuPickImageWidget( + description: '上传现场照片', + onChanged: (files) { + _scenePhotos = files; + setState(() {}); + }, + ) ], ) .box