diff --git a/lib/const/api.dart b/lib/const/api.dart index 5717f73..38eeb3b 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -146,6 +146,13 @@ class _Manage { ///巡检管理:根据巡检计划主键id查询巡检点部分信息(开始巡检前调用) String get inspectionPointByPlanId => '/user/inspection/findPointByPlanId'; + + ///巡检管理:开始巡检 + String get inspectionStart => '/user/inspection/startInspection'; + + ///巡检管理:根据巡检执行情况主键id查询巡检点部分信息(开始巡检后调用) + String get inspecntionFindPointByExecuteId => + '/user/inspection/findPointByExecuteId'; } class _Upload { diff --git a/lib/models/manager/inspection/inspection_detail_model.dart b/lib/models/manager/inspection/inspection_detail_model.dart index 8230d63..d9ea66b 100644 --- a/lib/models/manager/inspection/inspection_detail_model.dart +++ b/lib/models/manager/inspection/inspection_detail_model.dart @@ -7,6 +7,8 @@ class InspectionDetailModel { String endDate; String actualBeginDate; String actualEndDate; + int sort; + int status; InspectionDetailModel( {this.id, @@ -16,7 +18,9 @@ class InspectionDetailModel { this.beginDate, this.endDate, this.actualBeginDate, - this.actualEndDate}); + this.actualEndDate, + this.sort, + this.status}); InspectionDetailModel.fromJson(Map json) { id = json['id']; @@ -27,6 +31,8 @@ class InspectionDetailModel { endDate = json['endDate']; actualBeginDate = json['actualBeginDate']; actualEndDate = json['actualEndDate']; + sort = json['sort']; + status = json['status']; } Map toJson() { @@ -39,6 +45,8 @@ class InspectionDetailModel { data['endDate'] = this.endDate; data['actualBeginDate'] = this.actualBeginDate; data['actualEndDate'] = this.actualEndDate; + data['sort'] = this.sort; + data['status'] = this.status; 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 d11f040..34aacf5 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart @@ -51,7 +51,6 @@ class _InspectionManageCardState extends State { onPressed: () { Get.to( InspectionManageDetailsPage( - inspectionStatus: widget.cardModel.status, executeId: widget.cardModel.id, ), ); 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 34ae2f7..999460c 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,8 +1,12 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.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/ui/sub_pages/manage_func.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:aku_ui/aku_ui.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -18,11 +22,9 @@ import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; class InspectionManageDetailsPage extends StatefulWidget { final int executeId; - final int inspectionStatus; InspectionManageDetailsPage({ Key key, @required this.executeId, - @required this.inspectionStatus, }) : super(key: key); @override @@ -83,23 +85,16 @@ class _InspectionManageDetailsPageState onRefresh: () async { _detailModel = await ManageFunc.getInspectionDetail(widget.executeId); - await ManageFunc.getInspectionPoint(_detailModel.inspectionPlanId) - .then( - (value) { - if (value == null) { - _pointModels = []; - } else { - _pointModels = value - .map((e) => InspectionPointModel.fromJson(e)) - .toList(); - } - }, - ); + _pointModels = await (_detailModel.status == 1 + ? ManageFunc.getInspectionPointByPlanId( + planId: _detailModel.inspectionPlanId) + : ManageFunc.getInspectionPointByExcuteId( + excuteId: widget.executeId)); _onload = false; setState(() {}); }, child: _onload - ? SizedBox() + ? _emptyWidget() : Column( children: [ _inspectionHeadCard(), @@ -127,17 +122,32 @@ class _InspectionManageDetailsPageState ], ), ), - bottom: AkuButton( - onPressed: () {}, - padding: EdgeInsets.symmetric(vertical: 26.w), - color: kPrimaryColor, - child: (widget.inspectionStatus == 1 ? '开始巡检' : '立即扫码') - .text - .black - .bold - .size(32.sp) - .make(), - ).pOnly(bottom: MediaQuery.of(context).padding.bottom)); + bottom: (!_onload) && + (_detailModel.status != 2) && + (_detailModel.status != 4) + ? AkuButton( + onPressed: _detailModel.status == 1 + ? () async { + BaseModel _baseModel = await NetUtil().get( + API.manage.inspectionStart, + params: {"executeId": widget.executeId}); + if (_baseModel.status) { + setState(() {}); + } else { + BotToast.showText(text: _baseModel.message); + } + } + : () {}, + padding: EdgeInsets.symmetric(vertical: 26.w), + color: kPrimaryColor, + child: (_detailModel.status == 1 ? '开始巡检' : '立即扫码') + .text + .black + .bold + .size(32.sp) + .make(), + ).pOnly(bottom: MediaQuery.of(context).padding.bottom) + : SizedBox()); } Widget _inspectionHeadCard() { @@ -167,9 +177,9 @@ class _InspectionManageDetailsPageState fontWeight: FontWeight.bold), ), Spacer(), - _inspectionStatus[widget.inspectionStatus] + _inspectionStatus[_detailModel.status] .text - .color(_inspectionColor(widget.inspectionStatus)) + .color(_inspectionColor(_detailModel.status)) .bold .size(28.sp) .make() @@ -313,11 +323,11 @@ class _InspectionManageDetailsPageState ], ), Spacer(), - _inspectionStatus[widget.inspectionStatus] + _inspectionStatus[_detailModel.status] .text .size(24.sp) .bold - .color(_inspectionColor(widget.inspectionStatus)) + .color(_inspectionColor(_detailModel.status)) .make(), 14.w.widthBox, Icon( 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 52cd3b1..151d8b1 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart @@ -31,9 +31,9 @@ class _InspectionManagePageState extends State UserProvider _userProvider = Provider.of(context, listen: false); if (_userProvider.infoModel.canOperation) { - return ['待巡检', '已巡检', '巡检中', '全部']; + return ['待巡检', '已巡检', '巡检中', '未巡检']; } else { - return ['待巡检', '已巡检', '巡检中', '全部']; + return ['待巡检', '已巡检', '巡检中', '未巡检']; } } diff --git a/lib/ui/sub_pages/manage_func.dart b/lib/ui/sub_pages/manage_func.dart index d0bbe40..ac7b413 100644 --- a/lib/ui/sub_pages/manage_func.dart +++ b/lib/ui/sub_pages/manage_func.dart @@ -5,6 +5,7 @@ import 'package:aku_community_manager/models/manager/inspection/inspection_point 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'; +import 'package:flutter/material.dart'; class ManageFunc { static Future getDetcorationDetail(int id) async { @@ -35,11 +36,25 @@ class ManageFunc { return InspectionDetailModel.fromJson(baseModel.data); } - static Future getInspectionPoint(int id) async { + static Future> getInspectionPointByPlanId( + {@required int planId}) async { BaseModel baseModel = await NetUtil().get(API.manage.inspectionPointByPlanId, params: { - "planId": id, + "planId": planId, }); - return baseModel.data as List; + return (baseModel.data as List) + .map((e) => InspectionPointModel.fromJson(e)) + .toList(); + } + + static Future> getInspectionPointByExcuteId( + {@required int excuteId}) async { + BaseModel baseModel = await NetUtil() + .get(API.manage.inspecntionFindPointByExecuteId, params: { + "planId": excuteId, + }); + return (baseModel.data as List) + .map((e) => InspectionPointModel.fromJson(e)) + .toList(); } }