From 57db1151a04c3a969b28f2fd6860b96f21519ecf Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Wed, 18 Aug 2021 09:55:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E9=AA=8C=E6=94=B6?= =?UTF-8?q?=E8=AE=B0=E5=BD=95/=E9=AA=8C=E6=94=B6=E7=BB=93=E6=9E=9C/?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=AA=8C=E6=94=B6/=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 4 + lib/const/engineer_repair.dart | 14 ++ ...er_repair_new_acceptance_record_model.dart | 38 +++ ..._repair_new_acceptance_record_model.g.dart | 31 +++ .../engineer_repair_result_model.dart | 27 +++ .../engineer_repair_result_model.g.dart | 22 ++ .../engineer_repair_acceptance_page.dart | 165 ++++++++++++- ...er_repair_acceptance_record_list_page.dart | 110 +++++++++ ...ngineer_repair_acceptance_result_page.dart | 223 ++++++++++++++++++ .../engineer_repair_complete_page.dart | 1 + .../engineer_repair_depart_company_page.dart | 1 + .../engineer_repair_detail_page.dart | 164 ++++++++----- .../engineer_repair/engineer_repair_func.dart | 67 ++++++ 13 files changed, 796 insertions(+), 71 deletions(-) create mode 100644 lib/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart create mode 100644 lib/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.g.dart create mode 100644 lib/json_models/manager/engineer_repair/engineer_repair_result_model.dart create mode 100644 lib/json_models/manager/engineer_repair/engineer_repair_result_model.g.dart create mode 100644 lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_record_list_page.dart create mode 100644 lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_result_page.dart diff --git a/lib/const/api.dart b/lib/const/api.dart index ad3f25e..643b2bb 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -366,6 +366,10 @@ class _Upload { ///上传报事报修工程维修完成维修图片照片 String get engineerRepairComplete => '/user/upload/uploadButlerAppCompleteMaintenance'; + + ///上传报事报修工程维修验收照片图片照片 + String get engineerRepairAcceptance => + '/user/upload/uploadButlerAppAcceptance'; } class _Message { diff --git a/lib/const/engineer_repair.dart b/lib/const/engineer_repair.dart index a9ffd12..2a27be8 100644 --- a/lib/const/engineer_repair.dart +++ b/lib/const/engineer_repair.dart @@ -43,4 +43,18 @@ class _EngineerRepair { ///管家app 报事报修工程维修:根据工程维修主键id查询最新的维修结果 String get repairResult => '/user/repairEngineering/findNewResultByRepairEngineeringId'; + + ///管家app 报事报修工程维修:提交验收报告 + String get submitAcceptance => '/user/repairEngineering/submitAcceptance'; + + ///管家app 报事报修工程维修:根据工程维修主键id查询最新的验收记录(只查询一条记录) + String get acceptanceRecordNew => + '/user/repairEngineering/findNewAcceptanceRecordByRepairEngineeringId'; + + ///管家app 报事报修工程维修:根据工程维修主键id查询验收记录(查询多条记录) + String get acceptanceRecordList => + '/user/repairEngineering/findAcceptanceRecordByRepairEngineeringId'; + + ///管家app 报事报修工程维修:开始整改 + String get startRectification => '/user/repairEngineering/startRectification'; } diff --git a/lib/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart b/lib/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart new file mode 100644 index 0000000..aadd9c0 --- /dev/null +++ b/lib/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart @@ -0,0 +1,38 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'engineer_repair_new_acceptance_record_model.g.dart'; + +@JsonSerializable() +class EngineerRepairNewAcceptanceRecordModel { + final int id; + final int repairEngineeringId; + final String content; + final String billMaterials; + final List maintenanceImgLists; + final String createName; + final String createDate; + final int results; + final String advice; + final String acceptancePeople; + final String acceptancePeopleName; + final String acceptanceDate; + final List acceptanceImgLists; + factory EngineerRepairNewAcceptanceRecordModel.fromJson( + Map json) => + _$EngineerRepairNewAcceptanceRecordModelFromJson(json); + EngineerRepairNewAcceptanceRecordModel( + this.id, + this.repairEngineeringId, + this.content, + this.billMaterials, + this.maintenanceImgLists, + this.createName, + this.createDate, + this.results, + this.advice, + this.acceptancePeople, + this.acceptancePeopleName, + this.acceptanceDate, + this.acceptanceImgLists); +} diff --git a/lib/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.g.dart b/lib/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.g.dart new file mode 100644 index 0000000..824e2cb --- /dev/null +++ b/lib/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'engineer_repair_new_acceptance_record_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +EngineerRepairNewAcceptanceRecordModel + _$EngineerRepairNewAcceptanceRecordModelFromJson( + Map json) { + return EngineerRepairNewAcceptanceRecordModel( + json['id'] as int, + json['repairEngineeringId'] as int, + json['content'] as String, + json['billMaterials'] as String, + (json['maintenanceImgLists'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + json['createName'] as String, + json['createDate'] as String, + json['results'] as int, + json['advice'] as String, + json['acceptancePeople'] as String, + json['acceptancePeopleName'] as String, + json['acceptanceDate'] as String, + (json['acceptanceImgLists'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); +} diff --git a/lib/json_models/manager/engineer_repair/engineer_repair_result_model.dart b/lib/json_models/manager/engineer_repair/engineer_repair_result_model.dart new file mode 100644 index 0000000..b5ea9e0 --- /dev/null +++ b/lib/json_models/manager/engineer_repair/engineer_repair_result_model.dart @@ -0,0 +1,27 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'engineer_repair_result_model.g.dart'; + +@JsonSerializable() +class EngineerRepairResultModel { + final int id; + final int repairEngineeringId; + final String content; + final String billMaterials; + final List maintenanceImgLists; + final String createName; + final String createDate; + + factory EngineerRepairResultModel.fromJson(Map json) => + _$EngineerRepairResultModelFromJson(json); + + EngineerRepairResultModel( + this.id, + this.repairEngineeringId, + this.content, + this.billMaterials, + this.maintenanceImgLists, + this.createName, + this.createDate); +} diff --git a/lib/json_models/manager/engineer_repair/engineer_repair_result_model.g.dart b/lib/json_models/manager/engineer_repair/engineer_repair_result_model.g.dart new file mode 100644 index 0000000..918591a --- /dev/null +++ b/lib/json_models/manager/engineer_repair/engineer_repair_result_model.g.dart @@ -0,0 +1,22 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'engineer_repair_result_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +EngineerRepairResultModel _$EngineerRepairResultModelFromJson( + Map json) { + return EngineerRepairResultModel( + json['id'] as int, + json['repairEngineeringId'] as int, + json['content'] as String, + json['billMaterials'] as String, + (json['maintenanceImgLists'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + json['createName'] as String, + json['createDate'] as String, + ); +} diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_page.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_page.dart index e3942a9..ba76636 100644 --- a/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_page.dart +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_page.dart @@ -1,19 +1,34 @@ +import 'dart:io'; + import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_detail_model.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_result_model.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_acceptance_record_list_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_func.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'; +import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_title_box.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; import 'engineer_repair_map.dart'; class EngineerRepairAcceptancePage extends StatefulWidget { final EngineerRepairDetailModel detailModel; - const EngineerRepairAcceptancePage({Key? key, required this.detailModel}) + final EngineerRepairResultModel resultModel; + + const EngineerRepairAcceptancePage( + {Key? key, required this.detailModel, required this.resultModel}) : super(key: key); @override @@ -23,19 +38,145 @@ class EngineerRepairAcceptancePage extends StatefulWidget { class _EngineerRepairAcceptancePageState extends State { + int _selectResult = 0; + String _reportDetail = ''; + List _files = []; + @override Widget build(BuildContext context) { return AkuScaffold( title: '验收审核', body: ListView( - children: [], + children: [ + _buildInfo(), + _buildCheckBox(), + ], + ), + bottom: AkuBottomButton( + title: '确认提交', + onTap: () async { + Function cancel = BotToast.showLoading(); + List urls = []; + urls = await EngineerRepairFunc.uploadAcceptanceImages(_files); + var result = await EngineerRepairFunc.submitAcceptance( + widget.resultModel.id, + widget.detailModel.id, + _selectResult, + _reportDetail, + urls); + cancel(); + if (result) { + Get.back(); + Get.back(); + } + }, ), ); } + Widget _buildCheckBox() { + return AkuTitleBox( + title: '审核内容', + children: [ + 40.w.heightBox, + '审核结果'.text.size(28.sp).color(kTextPrimaryColor).make(), + 16.w.heightBox, + Row( + children: [ + AkuSingleCheckButton( + text: '工程维修', + value: 1, + gropValue: _selectResult, + onPressed: () { + _selectResult = 1; + setState(() {}); + }, + ), + 80.w.widthBox, + AkuSingleCheckButton( + text: '异常', + value: 2, + gropValue: _selectResult, + onPressed: () { + _selectResult = 2; + setState(() {}); + }, + ), + ], + ), + 40.w.heightBox, + '审核意见'.text.size(28.sp).color(kTextPrimaryColor).make(), + 16.w.heightBox, + Container( + width: 686.w, + height: 300.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), + border: Border.all( + width: 2.w, + color: Color(0xFFE8E8E8), + ), + ), + child: TextField( + minLines: 5, + maxLines: 10, + autofocus: false, + onChanged: (value) { + setState(() { + _reportDetail = 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, + ), + ), + ), + '上传到场验收照片'.text.size(28.sp).color(kTextPrimaryColor).make(), + 16.w.heightBox, + AkuPickImageWidget(onChanged: (value) { + _files.clear(); + _files.addAll(value); + setState(() {}); + }), + 16.w.heightBox, + GestureDetector( + onTap: () async { + List models = []; + models.addAll(await EngineerRepairFunc.getAcceptanceRecordList( + widget.detailModel.id)); + await Get.to( + () => EngineerRepairAcceptanceRecordListPage(models: models)); + }, + child: Container( + color: Colors.white, + padding: EdgeInsets.all(32.w), + child: Row( + children: [ + '查看验收记录'.text.size(28.sp).color(kTextPrimaryColor).make(), + Spacer(), + Icon( + CupertinoIcons.chevron_right, + size: 40.w, + ) + ], + ), + ), + ) + ], + ); + } + _buildInfo() { return AkuTitleBox( - title: '报修信息', + title: '维修结果', suffix: Text( ERMap.statusString(widget.detailModel.status), style: TextStyle(color: Color(0xFFFF4501)), @@ -44,19 +185,19 @@ class _EngineerRepairAcceptancePageState AkuBox.h(16), _buildTile( R.ASSETS_MESSAGE_IC_PEOPLE_PNG, - '报修人', - widget.detailModel.createName, + '处理描述', + widget.resultModel.content, ), _buildTile( R.ASSETS_MESSAGE_IC_PHONE_PNG, - '联系电话', - widget.detailModel.createTel, + '材料清单', + widget.resultModel.billMaterials, ), - _buildTile(R.ASSETS_MESSAGE_IC_AREA_PNG, '报修区域', - '${S.of(context)!.tempPlotName}'), + _buildTile(R.ASSETS_MESSAGE_IC_AREA_PNG, '完成时间', + widget.resultModel.createDate), AkuBox.h(8), Text( - widget.detailModel.reportDetail, + '现场照片', style: TextStyle( color: AppStyle.primaryTextColor, fontWeight: FontWeight.bold, @@ -70,7 +211,7 @@ class _EngineerRepairAcceptancePageState crossAxisSpacing: 16.w, mainAxisSpacing: 16.w, ), - children: widget.detailModel.imgUrls.map((e) { + children: widget.resultModel.maintenanceImgLists.map((e) { return ClipRRect( borderRadius: BorderRadius.circular(4.w), child: FadeInImage.assetNetwork( diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_record_list_page.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_record_list_page.dart new file mode 100644 index 0000000..26b7d18 --- /dev/null +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_record_list_page.dart @@ -0,0 +1,110 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart'; +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class EngineerRepairAcceptanceRecordListPage extends StatefulWidget { + final List models; + + const EngineerRepairAcceptanceRecordListPage({Key? key, required this.models}) + : super(key: key); + + @override + _EngineerRepairAcceptanceRecordListPageState createState() => + _EngineerRepairAcceptanceRecordListPageState(); +} + +class _EngineerRepairAcceptanceRecordListPageState + extends State { + @override + Widget build(BuildContext context) { + return AkuScaffold( + title: '验收记录', + body: ListView( + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + children: widget.models + .mapIndexed( + (currentValue, index) => _buildCard(currentValue, index)) + .toList(), + ), + ); + } + + Widget _buildCard(EngineerRepairNewAcceptanceRecordModel model, index) { + return Container( + width: double.infinity, + color: Colors.white, + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + child: Column( + children: [ + Row( + children: [ + '${S.of(context)!.tempPlotName}' + .text + .size(32.sp) + .color(kTextPrimaryColor) + .make(), + Spacer(), + '${model.results == 1 ? '通过' : '驳回'}' + .text + .size(32.sp) + .color(Colors.red) + .make(), + ], + ), + 40.w.heightBox, + Row( + children: [ + '验收人'.text.size(28.sp).color(kTextSubColor).make(), + Spacer(), + model.acceptancePeopleName.text + .size(28.sp) + .color(kTextPrimaryColor) + .make(), + ], + ), + 40.w.heightBox, + '现场情况'.text.size(28.sp).color(kTextSubColor).make(), + 40.w.heightBox, + model.advice.text.size(28.sp).color(kTextPrimaryColor).make(), + 40.w.heightBox, + '现场照片'.text.size(28.sp).color(kTextSubColor).make(), + 24.w.heightBox, + GridView( + padding: EdgeInsets.only(top: 16.w), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 16.w, + mainAxisSpacing: 16.w, + ), + children: model.acceptanceImgLists.map((e) { + return ClipRRect( + borderRadius: BorderRadius.circular(4.w), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(e.url!)), + ); + }).toList(), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + ), + 40.w.heightBox, + Row( + children: [ + '反馈时间'.text.size(28.sp).color(kTextSubColor).make(), + Spacer(), + model.acceptanceDate.text + .size(28.sp) + .color(kTextPrimaryColor) + .make(), + ], + ), + ], + ), + ); + } +} diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_result_page.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_result_page.dart new file mode 100644 index 0000000..eb74e21 --- /dev/null +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_acceptance_result_page.dart @@ -0,0 +1,223 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/const/resource.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart'; +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_acceptance_record_list_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_func.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_title_box.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class EngineerRepairAcceptanceResultPage extends StatefulWidget { + final EngineerRepairNewAcceptanceRecordModel recordModel; + + const EngineerRepairAcceptanceResultPage( + {Key? key, required this.recordModel}) + : super(key: key); + + @override + _EngineerRepairAcceptanceResultPageState createState() => + _EngineerRepairAcceptanceResultPageState(); +} + +class _EngineerRepairAcceptanceResultPageState + extends State { + @override + Widget build(BuildContext context) { + return AkuScaffold( + title: '验收结果', + body: ListView( + children: [ + _buildAcceptanceResult(), + 16.w.heightBox, + _buildRepairResult(), + 16.w.heightBox, + GestureDetector( + onTap: () async { + List models = []; + models.addAll(await EngineerRepairFunc.getAcceptanceRecordList( + widget.recordModel.repairEngineeringId)); + await Get.to( + () => EngineerRepairAcceptanceRecordListPage(models: models)); + }, + child: Container( + color: Colors.white, + padding: EdgeInsets.all(32.w), + child: Row( + children: [ + '查看验收记录'.text.size(28.sp).color(kTextPrimaryColor).make(), + Spacer(), + Icon( + CupertinoIcons.chevron_right, + size: 40.w, + ) + ], + ), + ), + ) + ], + ), + bottom: widget.recordModel.results == 1 + ? SizedBox() + : AkuBottomButton( + title: '开始整改', + onTap: () async { + var result = await EngineerRepairFunc.startRectification( + widget.recordModel.repairEngineeringId); + if (result) { + Get.back(); + Get.back(); + } + }, + ), + ); + } + + _buildAcceptanceResult() { + return Container( + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + width: double.infinity, + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '验收单位'.text.size(28.sp).color(kTextSubColor).make(), + 24.w.heightBox, + '${widget.recordModel.acceptancePeopleName}' + .text + .size(32.sp) + .color(kTextPrimaryColor) + .bold + .make(), + 40.w.heightBox, + '验收结果'.text.size(28.sp).color(kTextSubColor).make(), + 24.w.heightBox, + '${widget.recordModel.results == 1 ? '通过' : '驳回'}' + .text + .size(32.sp) + .color(Colors.red) + .bold + .make(), + 40.w.heightBox, + '反馈意见'.text.size(28.sp).color(kTextSubColor).make(), + 24.w.heightBox, + widget.recordModel.advice.text + .size(28.sp) + .color(kTextPrimaryColor) + .make(), + 40.w.heightBox, + '到现场验收照片'.text.size(28.sp).color(kTextSubColor).make(), + 24.w.heightBox, + GridView( + padding: EdgeInsets.only(top: 16.w), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 16.w, + mainAxisSpacing: 16.w, + ), + children: widget.recordModel.acceptanceImgLists.map((e) { + return ClipRRect( + borderRadius: BorderRadius.circular(4.w), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(e.url!)), + ); + }).toList(), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + ), + 40.w.heightBox, + '反馈时间'.text.size(28.sp).color(kTextSubColor).make(), + 24.w.heightBox, + widget.recordModel.acceptanceDate.text + .size(28.sp) + .color(kTextPrimaryColor) + .make(), + ], + ), + ); + } + + _buildRepairResult() { + return AkuTitleBox( + title: '维修结果', + children: [ + AkuBox.h(16), + _buildTile( + R.ASSETS_MESSAGE_IC_PEOPLE_PNG, + '处理描述', + widget.recordModel.content, + ), + _buildTile( + R.ASSETS_MESSAGE_IC_PHONE_PNG, + '材料清单', + widget.recordModel.billMaterials, + ), + _buildTile(R.ASSETS_MESSAGE_IC_AREA_PNG, '完成时间', + widget.recordModel.createDate), + AkuBox.h(8), + Text( + '现场照片', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.w, + ), + ), + GridView( + padding: EdgeInsets.only(top: 16.w), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 16.w, + mainAxisSpacing: 16.w, + ), + children: widget.recordModel.maintenanceImgLists.map((e) { + return ClipRRect( + borderRadius: BorderRadius.circular(4.w), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(e.url!)), + ); + }).toList(), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + ), + ], + ); + } + + Widget _buildTile(String asset, String title, String subTitle) { + return Row( + children: [ + AkuBox.h(56), + Image.asset( + asset, + height: 40.w, + width: 40.w, + ), + AkuBox.w(4), + Text( + title, + style: TextStyle( + fontSize: 28.sp, + color: AppStyle.minorTextColor, + ), + ), + Spacer(), + Text( + subTitle, + style: TextStyle( + fontSize: 28.sp, + color: AppStyle.primaryTextColor, + ), + ), + ], + ); + } +} diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_complete_page.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_complete_page.dart index 5f04b8b..8eda332 100644 --- a/lib/ui/manage_pages/engineer_repair/engineer_repair_complete_page.dart +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_complete_page.dart @@ -86,6 +86,7 @@ class _EngineerRepairCompletePageState urls = await EngineerRepairFunc.uploadCompleteImages(_files); var result = await EngineerRepairFunc.complete(widget.detailModel.id, _reportDetailController.text, _materialController.text, urls); + cancel(); if (result) { Get.back(); Get.back(); diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_depart_company_page.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_depart_company_page.dart index 958bcf5..256a286 100644 --- a/lib/ui/manage_pages/engineer_repair/engineer_repair_depart_company_page.dart +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_depart_company_page.dart @@ -35,6 +35,7 @@ class _EngineerRepairDepartCompanyState firstRefresh: true, header: MaterialHeader(), onRefresh: () async { + _models.clear(); _models.addAll(await EngineerRepairFunc.getOrganization()); _onLoad = false; setState(() {}); diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_detail_page.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_detail_page.dart index 7cef3a0..516c5fa 100644 --- a/lib/ui/manage_pages/engineer_repair/engineer_repair_detail_page.dart +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_detail_page.dart @@ -1,12 +1,17 @@ import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_detail_model.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_process_model.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_result_model.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_work_report_model.dart'; import 'package:aku_community_manager/models/user/user_info_model.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/user_tool.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_acceptance_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_acceptance_record_list_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_acceptance_result_page.dart'; import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_complete_page.dart'; import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_depart_company_page.dart'; import 'package:aku_community_manager/ui/manage_pages/engineer_repair/engineer_repair_depart_person_page.dart'; @@ -60,6 +65,8 @@ class _EngineerRepairDetailPageState extends State { onRefresh: () async { _model = await EngineerRepairFunc.getEngineerRepairDetail( widget.repairEngineerId); + _processModels.clear(); + _reportModels.clear(); _processModels.addAll( await EngineerRepairFunc.getProcess(widget.repairEngineerId)); _reportModels.addAll( @@ -78,13 +85,18 @@ class _EngineerRepairDetailPageState extends State { children: [ _buildInfo(), 16.w.heightBox, - if (_model!.maintenanceStaff != null) _buildOperator(), - if (_model!.organizationId != null) _buildOrganization(), + if (_model?.maintenanceStaff != null) _buildOperator(), + if (_model?.organizationId != null) _buildOrganization(), if (_processModels.isNotEmpty) _buildProcess(), if (_reportModels.isNotEmpty) _buildReport(), GestureDetector( - onTap: () { - // TODO:跳转验收记录 + onTap: () async { + List models = []; + models.addAll( + await EngineerRepairFunc.getAcceptanceRecordList( + widget.repairEngineerId)); + await Get.to(() => EngineerRepairAcceptanceRecordListPage( + models: models)); }, child: Container( color: Colors.white, @@ -116,72 +128,106 @@ class _EngineerRepairDetailPageState extends State { if (_model != null) { switch (_model!.status) { case 1: - return AkuBottomButton( - title: '立即派单', - onTap: () async { - await Get.off(EngineerRepairDepartCompany( - repairId: widget.repairEngineerId)); - }, - ); + return UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.SENDTOCOMPANY + ? AkuBottomButton( + title: '立即派单', + onTap: () async { + await Get.off(EngineerRepairDepartCompany( + repairId: widget.repairEngineerId)); + }, + ) + : SizedBox(); case 2: - return AkuBottomButton( - title: '立即派单', - onTap: () async { - await Get.off(EngineerRepairDepartPersonPage( - organizationId: _model!.organizationId!, - organizationName: _model!.organizationName!, - repairId: _model!.id)); - }, - ); - case 3: - return AkuBottomButton( - title: '立即接单', - onTap: () async { - var result = await EngineerRepairFunc.personPick(_model!.id); - if (result) { - Get.back(); - } - }, - ); - case 4: - return Row( - children: [ - AkuMaterialButton( - minWidth: 287.w, - onPressed: () async { - await Get.to( - () => EngineerRepairCompletePage(detailModel: _model!)); + print(UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.SENDTOPERSON); + return UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.SENDTOPERSON + ? AkuBottomButton( + title: '立即派单', + onTap: () async { + await Get.off(EngineerRepairDepartPersonPage( + organizationId: _model!.organizationId!, + organizationName: _model!.organizationName!, + repairId: _model!.id)); }, - color: Colors.black, - child: '维修完成'.text.size(32.sp).color(Colors.white).make()), - AkuMaterialButton( - color: kPrimaryColor, - onPressed: () async { - await Get.to( - () => EngineerRepairReportPage(repairId: _model!.id)); + ) + : SizedBox(); + case 3: + return UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.PICK + ? AkuBottomButton( + title: '立即接单', + onTap: () async { + var result = + await EngineerRepairFunc.personPick(_model!.id); + if (result) { + Get.back(); + } }, - child: '汇报进度'.text.size(32.sp).color(Colors.black).make()), - ], - ); + ) + : SizedBox(); + case 4: + return UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.PICK + ? Row( + children: [ + AkuMaterialButton( + minWidth: 287.w, + onPressed: () async { + await Get.to(() => + EngineerRepairCompletePage(detailModel: _model!)); + }, + color: Colors.black, + child: + '维修完成'.text.size(32.sp).color(Colors.white).make()), + AkuMaterialButton( + color: kPrimaryColor, + onPressed: () async { + await Get.to(() => + EngineerRepairReportPage(repairId: _model!.id)); + }, + child: + '汇报进度'.text.size(32.sp).color(Colors.black).make()), + ], + ) + : SizedBox(); case 5: return UserTool.userProvider.infoModel!.engineeringRepairAuthority == ERAUTH.SENDTOCOMPANY ? AkuMaterialButton( color: kPrimaryColor, onPressed: () async { - await Get.to( - () => EngineerRepairReportPage(repairId: _model!.id)); + EngineerRepairResultModel? resultModel = + await EngineerRepairFunc.getRepairResult( + widget.repairEngineerId); + if (resultModel != null) { + await Get.to(() => EngineerRepairAcceptancePage( + resultModel: resultModel, + detailModel: _model!, + )); + } }, child: '验收审核'.text.size(32.sp).color(Colors.black).make()) : SizedBox(); case 6: - return AkuMaterialButton( - color: kPrimaryColor, - onPressed: () async { - await Get.to( - () => EngineerRepairReportPage(repairId: _model!.id)); - }, - child: '验收结果'.text.size(32.sp).color(Colors.black).make()); + return UserTool.userProvider.infoModel!.engineeringRepairAuthority == + ERAUTH.PICK + ? AkuMaterialButton( + color: kPrimaryColor, + onPressed: () async { + EngineerRepairNewAcceptanceRecordModel? + acceptanceRecordModel = + await EngineerRepairFunc.getAcceptanceRecord( + widget.repairEngineerId); + if (acceptanceRecordModel != null) { + await Get.to(() => EngineerRepairAcceptanceResultPage( + recordModel: acceptanceRecordModel, + )); + } + }, + child: '验收结果'.text.size(32.sp).color(Colors.black).make()) + : SizedBox(); default: return SizedBox(); } @@ -292,10 +338,10 @@ class _EngineerRepairDetailPageState extends State { R.ASSETS_MESSAGE_IC_PEOPLE_PNG, '维修单位', _model!.organizationName!), 16.w.heightBox, _buildTile(R.ASSETS_MESSAGE_IC_PEOPLE_PNG, '主要负责人', - _model!.organizationLeadingName!), + _model!.organizationLeadingName ?? ''), 16.w.heightBox, _buildTile(R.ASSETS_MESSAGE_IC_PHONE_PNG, '联系电话', - _model!.organizationLeadingTel!) + _model!.organizationLeadingTel ?? '') ], ).pOnly(bottom: 16.w); } diff --git a/lib/ui/manage_pages/engineer_repair/engineer_repair_func.dart b/lib/ui/manage_pages/engineer_repair/engineer_repair_func.dart index 67345ce..e286b8a 100644 --- a/lib/ui/manage_pages/engineer_repair/engineer_repair_func.dart +++ b/lib/ui/manage_pages/engineer_repair/engineer_repair_func.dart @@ -2,9 +2,11 @@ import 'dart:io'; import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_detail_model.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_new_acceptance_record_model.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_organization_model.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_person_model.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_process_model.dart'; +import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_result_model.dart'; import 'package:aku_community_manager/json_models/manager/engineer_repair/engineer_repair_work_report_model.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; @@ -144,4 +146,69 @@ class EngineerRepairFunc { await NetUtil().uploadFiles(files, API.upload.engineerRepairComplete); return model; } + + static Future getRepairResult(int repairId) async { + var model = await NetUtil().get(API.engineerRepair.repairResult, params: { + 'repairEngineeringId': repairId, + }); + if (model.status ?? false) { + return EngineerRepairResultModel.fromJson(model.data); + } else { + return null; + } + } + + static Future submitAcceptance(int id, int repairId, int result, + String advice, List urls) async { + var model = + await NetUtil().post(API.engineerRepair.submitAcceptance, params: { + 'id': id, + 'repairEngineeringId': repairId, + 'results': result, + 'advice': advice, + 'acceptanceImgUrls': urls, + }); + return model.status ?? false; + } + + static Future uploadAcceptanceImages(List files) async { + var model = + await NetUtil().uploadFiles(files, API.upload.engineerRepairAcceptance); + return model; + } + + static Future getAcceptanceRecord(int repairId) async { + var model = + await NetUtil().get(API.engineerRepair.acceptanceRecordNew, params: { + 'repairEngineeringId': repairId, + }); + if (model.status ?? false) { + return EngineerRepairNewAcceptanceRecordModel.fromJson(model.data); + } else { + return null; + } + } + + static Future> + getAcceptanceRecordList(int repairId) async { + var model = + await NetUtil().get(API.engineerRepair.acceptanceRecordList, params: { + 'repairEngineeringId': repairId, + }); + if (model.status ?? false) { + return (model.data as List) + .map((e) => EngineerRepairNewAcceptanceRecordModel.fromJson(e)) + .toList(); + } else { + return []; + } + } + + static Future startRectification(int repairId) async { + var model = + await NetUtil().post(API.engineerRepair.startRectification, params: { + 'id': repairId, + }); + return model.status ?? false; + } }