From ad9d4febc9156c62c85e1618f4350191f2bfe6eb Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Fri, 26 Mar 2021 17:17:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E5=AF=B9=E6=8E=A5=EF=BC=9A=E5=B7=A1?= =?UTF-8?q?=E6=A3=80=E7=AE=A1=E7=90=86=EF=BC=9A=E6=A0=B9=E6=8D=AE=E5=B7=A1?= =?UTF-8?q?=E6=A3=80=E8=AE=A1=E5=88=92=E4=B8=BB=E9=94=AEid=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=B7=A1=E6=A3=80=E7=82=B9=E9=83=A8=E5=88=86=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .fvm/fvm_config.json | 2 +- .vscode/settings.json | 2 +- lib/const/api.dart | 3 + .../inspection/inspection_list_model.dart | 6 +- .../inspection/inspection_point_model.dart | 24 +++ .../inspection_manage_card.dart | 143 ++++++++++-------- .../inspection_manage_details_page.dart | 128 +++++++++------- .../inspection_manage_page.dart | 2 +- .../inspection_manage_view.dart | 17 ++- lib/ui/sub_pages/manage_func.dart | 9 ++ 10 files changed, 210 insertions(+), 126 deletions(-) create mode 100644 lib/models/manager/inspection/inspection_point_model.dart diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 07d62f9..309af34 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,3 +1,3 @@ { - "flutterSdkVersion": "2.0.2" + "flutterSdkVersion": "2.0.0" } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 2ccc2b5..42141d1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "dart.flutterSdkPath": "/Users/zhangmeng/fvm/versions/2.0.2" + "dart.flutterSdkPath": "/Users/zhangmeng/fvm/versions/2.0.0" } \ No newline at end of file diff --git a/lib/const/api.dart b/lib/const/api.dart index 14a6d02..5717f73 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -143,6 +143,9 @@ class _Manage { ///巡检管理:根据巡检执行情况主键id查询巡检详情 String get inspectionFindDetailByld => '/user/inspection/findDetailById'; + + ///巡检管理:根据巡检计划主键id查询巡检点部分信息(开始巡检前调用) + String get inspectionPointByPlanId => '/user/inspection/findPointByPlanId'; } class _Upload { diff --git a/lib/models/manager/inspection/inspection_list_model.dart b/lib/models/manager/inspection/inspection_list_model.dart index d2c5c85..e3e07b3 100644 --- a/lib/models/manager/inspection/inspection_list_model.dart +++ b/lib/models/manager/inspection/inspection_list_model.dart @@ -7,6 +7,7 @@ class InspectionListModel { String actualBeginDate; String actualEndDate; int status; + String inspectorName; InspectionListModel( {this.id, @@ -16,7 +17,8 @@ class InspectionListModel { this.endDate, this.actualBeginDate, this.actualEndDate, - this.status}); + this.status, + this.inspectorName}); InspectionListModel.fromJson(Map json) { id = json['id']; @@ -27,6 +29,7 @@ class InspectionListModel { actualBeginDate = json['actualBeginDate']; actualEndDate = json['actualEndDate']; status = json['status']; + inspectorName = json['inspectorName']; } Map toJson() { @@ -39,6 +42,7 @@ class InspectionListModel { data['actualBeginDate'] = this.actualBeginDate; data['actualEndDate'] = this.actualEndDate; data['status'] = this.status; + data['inspectorName'] = this.inspectorName; return data; } } diff --git a/lib/models/manager/inspection/inspection_point_model.dart b/lib/models/manager/inspection/inspection_point_model.dart new file mode 100644 index 0000000..50faec9 --- /dev/null +++ b/lib/models/manager/inspection/inspection_point_model.dart @@ -0,0 +1,24 @@ +class InspectionPointModel { + int id; + String name; + int checkNum; + String completeDate; + + InspectionPointModel({this.id, this.name, this.checkNum, this.completeDate}); + + InspectionPointModel.fromJson(Map json) { + id = json['id']; + name = json['name']; + checkNum = json['checkNum']; + completeDate = json['completeDate']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['checkNum'] = this.checkNum; + data['completeDate'] = this.completeDate; + return data; + } +} diff --git a/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart b/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart index 837a0be..b8eae81 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart @@ -1,58 +1,65 @@ import 'package:aku_community_manager/models/manager/inspection/inspection_list_model.dart'; +import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart'; import 'package:aku_ui/aku_ui.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; class InspectionManageCard extends StatefulWidget { final InspectionListModel cardModel; - final bool extra; - InspectionManageCard({Key key, this.cardModel, this.extra = true}) - : super(key: key); + InspectionManageCard({ + Key key, + this.cardModel, + }) : super(key: key); @override _InspectionManageCardState createState() => _InspectionManageCardState(); } class _InspectionManageCardState extends State { - @override - Widget build(BuildContext context) { - TextStyle _textstyle = - TextStyle(color: AppStyle.minorTextColor, fontSize: 28.sp); - Map _inspectionStatus = { - 1: '待巡检', - 2: '已巡检', - }; - Color _inspectionColor(int status) { - switch (status) { - case 1: - return Color(0xFF4501); - break; - case 2: - return Color(0x999999); - default: - return Colors.black; - } + TextStyle _textstyle = + TextStyle(color: AppStyle.minorTextColor, fontSize: 28.sp); + Map _inspectionStatus = {1: '待巡检', 2: '已巡检', 3: '巡检中', 4: '未巡检'}; + Color _inspectionColor(int status) { + switch (status) { + case 1: + return Color(0xFFFF4501); + break; + case 2: + return Color(0xFF999999); + case 3: + return Color(0xFFFF4501); + case 4: + return Color(0xFFFF4501); + default: + return Colors.blue; } + } + bool get isManager { + UserProvider userProvider = Provider.of(context); + return userProvider.infoModel.canOperation; + } + + @override + Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, children: [ 16.w.heightBox, AkuButton( - onPressed: widget.extra - ? () { - Get.to( - InspectionManageDetailsPage( - inspectionStatus: widget.cardModel.status, - executeId: widget.cardModel.id, - ), - ); - } - : () {}, + onPressed: () { + Get.to( + InspectionManageDetailsPage( + inspectionStatus: widget.cardModel.status, + executeId: widget.cardModel.id, + ), + ); + }, child: Container( alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 24.w, right: 24.w, bottom: 40.w), @@ -62,19 +69,19 @@ class _InspectionManageCardState extends State { color: Color(0xFFFFFFFF)), child: Column(children: [ Container( - height: widget.extra ? 93.w : 86.w, + height: 93.w, width: double.infinity, alignment: Alignment.centerLeft, child: Row( children: [ Text( '${widget.cardModel.name}', + overflow: TextOverflow.ellipsis, style: TextStyle( color: AppStyle.primaryTextColor, - fontSize: widget.extra ? 32.sp : 36.sp, + fontSize: 32.sp, fontWeight: FontWeight.bold), - ), - Spacer(), + ).expand(), _inspectionStatus[widget.cardModel.status] .text .color(_inspectionColor(widget.cardModel.status)) @@ -84,9 +91,38 @@ class _InspectionManageCardState extends State { ], ), ), - ...widget.extra - ? [Divider(height: 1.w), 24.w.heightBox] - : [ + Divider(height: 1.w), + 24.w.heightBox, + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Image.asset( + R.ASSETS_MANAGE_IC_RENWU_PNG, + width: 40.w, + height: 40.w, + ), + 4.w.widthBox, + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '巡检编号', + style: _textstyle, + ), + ], + ), + 36.w.widthBox, + Text( + widget.cardModel.code, + maxLines: 2, + textAlign: TextAlign.right, + style: AppStyle().primaryStyle, + ).expand() + ], + ), + 12.w.heightBox, + ...isManager + ? [ Row( children: [ Image.asset( @@ -96,38 +132,19 @@ class _InspectionManageCardState extends State { ), 4.w.widthBox, Text( - '巡检名称', + '巡检人', style: _textstyle, ), Spacer(), Text( - widget.cardModel.name, + widget.cardModel.inspectorName, style: AppStyle().primaryStyle, ) ], ), 12.w.heightBox, - ], - Row( - children: [ - Image.asset( - R.ASSETS_MANAGE_IC_RENWU_PNG, - width: 40.w, - height: 40.w, - ), - 4.w.widthBox, - Text( - '巡检编号', - style: _textstyle, - ), - Spacer(), - Text( - widget.cardModel.code, - style: AppStyle().primaryStyle, - ) - ], - ), - 12.w.heightBox, + ] + : [SizedBox()], Row( children: [ Image.asset( @@ -145,7 +162,7 @@ class _InspectionManageCardState extends State { ], ), 12.w.heightBox, - ...widget.cardModel?.actualBeginDate == null + ...widget?.cardModel?.actualBeginDate == null ? [SizedBox()] : [ Row( @@ -169,7 +186,7 @@ class _InspectionManageCardState extends State { ), 12.w.heightBox, ], - widget.cardModel?.actualEndDate == null + widget?.cardModel?.actualEndDate == null ? SizedBox() : Row( children: [ diff --git a/lib/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart b/lib/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart index 9a0d8b9..ae64c03 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart @@ -1,6 +1,8 @@ // Flutter imports: import 'package:aku_community_manager/models/manager/inspection/inspection_detail_model.dart'; +import 'package:aku_community_manager/models/manager/inspection/inspection_point_model.dart'; import 'package:aku_community_manager/ui/sub_pages/manage_func.dart'; +import 'package:aku_ui/aku_ui.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -32,23 +34,25 @@ class _InspectionManageDetailsPageState extends State { TextStyle _textstyle = TextStyle(color: AppStyle.minorTextColor, fontSize: 28.sp); - Map _inspectionStatus = { - 1: '待巡检', - 2: '已巡检', - }; + Map _inspectionStatus = {1: '待巡检', 2: '已巡检', 3: '巡检中', 4: '未巡检'}; Color _inspectionColor(int status) { switch (status) { case 1: - return Color(0xFF4501); + return Color(0xFFFF4501); break; case 2: - return Color(0x999999); + return Color(0xFF999999); + case 3: + return Color(0xFFFF4501); + case 4: + return Color(0xFFFF4501); default: - return Colors.black; + return Colors.blue; } } InspectionDetailModel _detailModel; + List _pointModels; bool _onload = true; EasyRefreshController _refreshController; @override @@ -70,40 +74,52 @@ class _InspectionManageDetailsPageState @override Widget build(BuildContext context) { return AkuScaffold( - title: '巡检详情', - body: EasyRefresh( - controller: _refreshController, - firstRefresh: true, - onRefresh: () async { - _detailModel = await ManageFunc.getInspectionDetail(widget.executeId); - _onload = false; - setState(() {}); - }, - child: _onload - ? SizedBox() - : Column( - children: [ - _inspectionHeadCard(), - 16.w.heightBox, - Container( - padding: - EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), - decoration: BoxDecoration(color: Color(0xFFFFFF)), - child: Column( - children: [ - '巡检站点'.text.black.size(32.sp).bold.make(), - _buildInspectionTile( - '', - 1, - 1, - ), - ].sepWidget(separate: 16.w.heightBox), - ), - ) - ], - ), - ), - ); + title: '巡检详情', + body: EasyRefresh( + controller: _refreshController, + firstRefresh: true, + header: + MaterialHeader(valueColor: AlwaysStoppedAnimation(kPrimaryColor)), + onRefresh: () async { + _detailModel = + await ManageFunc.getInspectionDetail(widget.executeId); + ManageFunc.getInspectionPoint(widget.executeId).then((value) { + _pointModels = + value.map((e) => InspectionPointModel.fromJson(e)).toList(); + }); + _onload = false; + setState(() {}); + }, + child: _onload + ? SizedBox() + : Column( + children: [ + _inspectionHeadCard(), + 16.w.heightBox, + Container( + padding: EdgeInsets.symmetric( + horizontal: 32.w, vertical: 24.w), + decoration: BoxDecoration(color: Color(0xFFFFFFFF)), + width: double.infinity, + constraints: BoxConstraints( + minHeight: 85.w, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '巡检站点'.text.black.size(32.sp).bold.make(), + ].sepWidget(separate: 16.w.heightBox), + ), + ) + ], + ), + ), + bottom: AkuButton( + onPressed: () {}, + padding: EdgeInsets.symmetric(vertical: 26.w), + color: kPrimaryColor, + child: '开始巡检'.text.black.bold.size(32.sp).make(), + ).pOnly(bottom: MediaQuery.of(context).padding.bottom)); } Widget _inspectionHeadCard() { @@ -143,6 +159,7 @@ class _InspectionManageDetailsPageState ), ), Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.asset( R.ASSETS_MANAGE_IC_RENWU_PNG, @@ -150,15 +167,22 @@ class _InspectionManageDetailsPageState height: 40.w, ), 4.w.widthBox, - Text( - '巡检名称', - style: _textstyle, + Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '巡检名称', + style: _textstyle, + ), + ], ), - Spacer(), + 36.w.widthBox, Text( _detailModel.name, + maxLines: 2, + textAlign: TextAlign.right, style: AppStyle().primaryStyle, - ) + ).expand() ], ), 12.w.heightBox, @@ -258,9 +282,10 @@ class _InspectionManageDetailsPageState return Row( children: [ CircleAvatar( - child: '巡$index'.text.color(Color(0x3F8FFE)).size(28.sp).bold.make(), + child: + '巡$index'.text.color(Color(0xFF3F8FFE)).size(28.sp).bold.make(), radius: 48.w, - backgroundColor: Color(0xE9F2FF), + backgroundColor: Color(0xFFE9F2FF), ), 24.w.widthBox, Column( @@ -278,13 +303,14 @@ class _InspectionManageDetailsPageState .make(), 14.w.widthBox, Icon( - CupertinoIcons.chevron_right_circle, - size: 14.w, + CupertinoIcons.chevron_right, + size: 28.w, + color: Color(0xFF999999), ), ], ) .box - .color(Color(0xF9F9F9)) + .color(Color(0xFFF9F9F9)) .withRounded(value: 4.w) .padding(EdgeInsets.all(24.w)) .make() diff --git a/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart b/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart index efd7459..52cd3b1 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart @@ -63,7 +63,7 @@ class _InspectionManagePageState extends State children: List.generate( _tabs.length, (index) => InspectionMangeView( - inspectionStatus: index, + inspectionStatus: index + 1, ), ), ), diff --git a/lib/ui/manage_pages/inspection_manage/inspection_manage_view.dart b/lib/ui/manage_pages/inspection_manage/inspection_manage_view.dart index 60f93f5..922fa07 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_view.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_view.dart @@ -43,14 +43,15 @@ class _InspectionMangeViewState extends State { }, builder: (items) { return ListView.separated( - padding: EdgeInsets.symmetric(horizontal: 32.w), - itemBuilder: (context, index) { - return InspectionManageCard(cardModel: items[index]); - }, - separatorBuilder: (_, __) { - return 8.w.heightBox; - }, - itemCount: items.length); + padding: EdgeInsets.symmetric(horizontal: 32.w), + itemBuilder: (context, index) { + return InspectionManageCard(cardModel: items[index]); + }, + separatorBuilder: (context, index) { + return 8.w.heightBox; + }, + itemCount: items.length, + ); }, ); } diff --git a/lib/ui/sub_pages/manage_func.dart b/lib/ui/sub_pages/manage_func.dart index 9d35e43..d0bbe40 100644 --- a/lib/ui/sub_pages/manage_func.dart +++ b/lib/ui/sub_pages/manage_func.dart @@ -1,6 +1,7 @@ import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/models/manager/decoration/decoration_detail_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_detail_model.dart'; +import 'package:aku_community_manager/models/manager/inspection/inspection_point_model.dart'; import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:dio/dio.dart'; @@ -33,4 +34,12 @@ class ManageFunc { }); return InspectionDetailModel.fromJson(baseModel.data); } + + static Future getInspectionPoint(int id) async { + BaseModel baseModel = + await NetUtil().get(API.manage.inspectionPointByPlanId, params: { + "planId": id, + }); + return baseModel.data as List; + } }