diff --git a/lib/ui/manage_pages/facilities/facilities_card.dart b/lib/ui/manage_pages/facilities/facilities_card.dart index ec3d8b7..c0dc3e6 100644 --- a/lib/ui/manage_pages/facilities/facilities_card.dart +++ b/lib/ui/manage_pages/facilities/facilities_card.dart @@ -17,8 +17,12 @@ import 'package:aku_community_manager/tools/aku_divider.dart'; class FacilitiesCard extends StatefulWidget { final int index; + final int facilitiesType; final FacilitiesCheckListModel model; - FacilitiesCard({Key key, this.index, this.model}) : super(key: key); + final VoidCallback callRefresh; + FacilitiesCard( + {Key key, this.index, this.model, this.facilitiesType, this.callRefresh}) + : super(key: key); @override _FacilitiesCardState createState() => _FacilitiesCardState(); @@ -64,8 +68,12 @@ class _FacilitiesCardState extends State { padding: EdgeInsets.symmetric( vertical: 8.w, horizontal: 24.w), color: Color(0xFFFFC40C), - onPressed: () { - Get.to(() => FacilitiesInspectReportPage()); + onPressed: () async { + await Get.to(() => FacilitiesInspectReportPage( + facilitiesType: widget.facilitiesType, + id: widget.model.id, + )); + widget.callRefresh(); }, child: '填写报告' .text @@ -84,8 +92,12 @@ class _FacilitiesCardState extends State { .color(Colors.white) .padding(EdgeInsets.all(24.w)) .make() - .onInkTap(() { - Get.to(() => FacilitiesInspectReportPage()); + .onInkTap(() async { + await Get.to(() => FacilitiesInspectReportPage( + facilitiesType: widget.facilitiesType, + id: widget.model.id, + )); + 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 66a2999..c2658d8 100644 --- a/lib/ui/manage_pages/facilities/facilities_inspect_report_page.dart +++ b/lib/ui/manage_pages/facilities/facilities_inspect_report_page.dart @@ -2,12 +2,17 @@ import 'dart:io'; // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/ui/manage_pages/facilities/facilities_map.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:aku_ui/common_widgets/aku_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; // Project imports: @@ -17,7 +22,13 @@ import 'package:aku_community_manager/ui/widgets/app_widgets/aku_single_check_bu import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; class FacilitiesInspectReportPage extends StatefulWidget { - FacilitiesInspectReportPage({Key key}) : super(key: key); + final int facilitiesType; + final int id; + FacilitiesInspectReportPage({ + Key key, + @required this.facilitiesType, + @required this.id, + }) : super(key: key); @override _FacilitiesInspectReportPageState createState() => @@ -28,16 +39,20 @@ class _FacilitiesInspectReportPageState extends State { List _selfPhotos; List _scenePhotos; + String _describtion; + int _scene = 0; @override Widget build(BuildContext context) { return AkuScaffold( title: '检查报告', body: ListView( children: [ - _basicMessageCard(), - _descriptionCard('场地情况', 0), + // _basicMessageCard(), + _descriptionCard( + widget.facilitiesType == 1 ? '设施情况' : '设备情况', + ), _scenePhotoCard(), - _selfPhotoCard(), + // _selfPhotoCard(), ], ), bottom: _bottomSubmitButton(), @@ -46,7 +61,24 @@ class _FacilitiesInspectReportPageState Widget _bottomSubmitButton() { return AkuButton( - onPressed: () {}, + onPressed: () async { + List _scenePhotoUrl = await NetUtil().uploadFiles( + _scenePhotos, + API.upload.uploadFacilitiCheckPhoto, + ); + + BaseModel baseModel = + await NetUtil().post(API.manage.submitFacilitiesCheckInfo, params: { + "id": widget.id, + "situation": _scene, + "detail": _describtion, + "imgUrls": _scenePhotoUrl, + }); + if (baseModel.status) { + Get.back(); + } + BotToast.showText(text: baseModel.message); + }, width: double.infinity, height: 100.w, child: '立即提交'.text.color(kTextPrimaryColor).bold.size(32.sp).make(), @@ -104,11 +136,9 @@ class _FacilitiesInspectReportPageState ); } - int _scene = 0; - Widget _descriptionCard( String title, - int index, + // int index, ) { return Column( children: [ @@ -156,7 +186,9 @@ class _FacilitiesInspectReportPageState minLines: 5, maxLines: 10, autofocus: false, - onChanged: (value) {}, + onChanged: (value) { + _describtion = value; + }, decoration: InputDecoration( hintText: '请详细描述异常情况', hintStyle: TextStyle( diff --git a/lib/ui/manage_pages/facilities/facilities_view.dart b/lib/ui/manage_pages/facilities/facilities_view.dart index b0c1866..294d02b 100644 --- a/lib/ui/manage_pages/facilities/facilities_view.dart +++ b/lib/ui/manage_pages/facilities/facilities_view.dart @@ -46,7 +46,8 @@ class _FacilitiesViewState extends State { controller: _refreshController, convert: (models) { return models.tableList - .map((e) => FacilitiesCheckListModel.fromJson(e)).toList(); + .map((e) => FacilitiesCheckListModel.fromJson(e)) + .toList(); }, builder: (items) { return ListView.separated( @@ -54,7 +55,11 @@ class _FacilitiesViewState extends State { itemBuilder: (context, index) { return FacilitiesCard( index: widget.index, - model:items[index], + facilitiesType: widget.facilitiesType, + model: items[index], + callRefresh: () { + _refreshController.callRefresh(); + }, ); }, separatorBuilder: (_, __) {