From 31233e030d8c7e58a0323fef0c2ba3e82ce252d4 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 24 Feb 2021 10:37:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=EF=BC=9A=E6=8E=A5=E5=8D=95?= =?UTF-8?q?=20=E5=AF=B9=E6=8E=A5=EF=BC=9A=E7=94=B3=E8=AF=B7=E5=BB=B6?= =?UTF-8?q?=E6=97=B6=20=E5=AF=B9=E6=8E=A5=EF=BC=9A=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 9 + .../business_and_fix_detail_page.dart | 32 ++- .../business_and_fix/fix_more_time_page.dart | 59 +++-- .../fix_work_finish_page.dart | 228 ++++++++++-------- lib/utils/network/manage_func.dart | 48 ++++ 5 files changed, 249 insertions(+), 127 deletions(-) diff --git a/lib/const/api.dart b/lib/const/api.dart index 11b7675..b539df0 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -78,4 +78,13 @@ class _Manage { ///报事报修:改派 String get repairReassignment => '/user/repair/reassignment'; + + ///报事报修:报事报修:接单 + String get recevingOrders => '/user/repair/receivingOrders'; + + ///报事报修:申请延时 + String get applyDelayed => '/user/repair/applyDelayed'; + +///报事报修:处理完成 +String get handleResult => '/user/repair/handleResult'; } diff --git a/lib/ui/sub_pages/business_and_fix/business_and_fix_detail_page.dart b/lib/ui/sub_pages/business_and_fix/business_and_fix_detail_page.dart index e1f8209..352382b 100644 --- a/lib/ui/sub_pages/business_and_fix/business_and_fix_detail_page.dart +++ b/lib/ui/sub_pages/business_and_fix/business_and_fix_detail_page.dart @@ -6,8 +6,12 @@ import 'package:aku_community_manager/models/manager/bussiness_and_fix/fixed_det import 'package:aku_community_manager/models/manager/bussiness_and_fix/work_order_type_model.dart'; import 'package:aku_community_manager/models/manager/bussiness_and_fix/work_time_limit_model.dart'; import 'package:aku_community_manager/tools/aku_map.dart'; +import 'package:aku_community_manager/ui/sub_pages/business_and_fix/fix_more_time_page.dart'; +import 'package:aku_community_manager/ui/sub_pages/business_and_fix/fix_work_finish_page.dart'; import 'package:aku_community_manager/ui/sub_pages/business_and_fix/fixer_department_page.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/manage_func.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -144,7 +148,7 @@ class _BusinessAndFixDetailPageState extends State { nullColor: AppStyle.minorColor, onPressed: () { Get.to(FixerDepartmentPage( - model:_reportModel , + model: _reportModel, changeType: true, )); }, @@ -159,15 +163,14 @@ class _BusinessAndFixDetailPageState extends State { return AkuMaterialButton( color: AppStyle.primaryColor, nullColor: AppStyle.minorColor, - onPressed: () { - // final userProvider = - // Provider.of(context, listen: false); - // detailModel.fixStatuses.add(FixStatus( - // title: '${userProvider.userInfoModel.nickName}已接单', - // date: DateTime.now(), - // )); - // widget.model.type = FIX_ENUM.PROCESSING; - // Get.back(); + onPressed: () async { + BaseModel baseModel = + await ManageFunc.recevingOrders(widget.model.dispatchId); + if (baseModel.status) { + Get.back(); + } else { + BotToast.showText(text: baseModel.message); + } }, child: Text( '立即接单', @@ -206,7 +209,8 @@ class _BusinessAndFixDetailPageState extends State { ), ), onPressed: () { - // Get.to(FixMoreTimePage(model: widget.model)); + Get.to( + FixMoreTimePage(dispatchId: widget.model.dispatchId)); }, child: Text( '申请延时', @@ -222,7 +226,11 @@ class _BusinessAndFixDetailPageState extends State { radius: 4.w, color: AppStyle.primaryColor, onPressed: () { - // Get.to(FixWorkFinishPage(model: widget.model)); + Get.to(FixWorkFinishPage( + reportDetail: widget.model.reportDetail, + model: _detailModel, + dispatchType: + _detailModel.dispatchType.dispatchType == 1)); }, child: Text( '处理完成', diff --git a/lib/ui/sub_pages/business_and_fix/fix_more_time_page.dart b/lib/ui/sub_pages/business_and_fix/fix_more_time_page.dart index b3807f5..81e8f5d 100644 --- a/lib/ui/sub_pages/business_and_fix/fix_more_time_page.dart +++ b/lib/ui/sub_pages/business_and_fix/fix_more_time_page.dart @@ -1,23 +1,23 @@ // Flutter imports: +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/manage_func.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:aku_ui/common_widgets/aku_material_button.dart'; -import 'package:get/get.dart'; -import 'package:provider/provider.dart'; // Project imports: import 'package:aku_community_manager/const/resource.dart'; -import 'package:aku_community_manager/mock_models/fix/fix_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/tools/screen_tool.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:get/get.dart'; class FixMoreTimePage extends StatefulWidget { - final FixModel model; - FixMoreTimePage({Key key, @required this.model}) : super(key: key); + final int dispatchId; + FixMoreTimePage({Key key, @required this.dispatchId}) : super(key: key); @override _FixMoreTimePageState createState() => _FixMoreTimePageState(); @@ -25,6 +25,20 @@ class FixMoreTimePage extends StatefulWidget { class _FixMoreTimePageState extends State { String _nowSelect = '24h'; + List _delayList = ['24h', '48h', '72h', '未知']; + TextEditingController _textEditingController; + @override + void initState() { + super.initState(); + _textEditingController = TextEditingController(); + } + + @override + void dispose() { + _textEditingController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return AkuScaffold( @@ -56,7 +70,7 @@ class _FixMoreTimePageState extends State { AkuBox.h(24), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: ['24h', '48h', '72h', '未知'].map((e) { + children: _delayList.map((e) { return GestureDetector( onTap: () { setState(() { @@ -131,6 +145,10 @@ class _FixMoreTimePageState extends State { child: TextField( minLines: 7, maxLines: 7, + controller: _textEditingController, + onChanged: (_) { + setState(() {}); + }, decoration: InputDecoration( contentPadding: EdgeInsets.zero, border: InputBorder.none, @@ -141,15 +159,24 @@ class _FixMoreTimePageState extends State { Padding( padding: EdgeInsets.symmetric(horizontal: 32.w), child: AkuMaterialButton( - onPressed: () { - final userProvider = - Provider.of(context, listen: false); - widget.model.detail.fixStatuses.add( - FixStatus( - title: '${userProvider.userInfoModel.nickName}申请延时', - date: DateTime.now()), - ); - Get.back(); + onPressed: () async { + // final userProvider = + // Provider.of(context, listen: false); + // widget.model.detail.fixStatuses.add( + // FixStatus( + // title: '${userProvider.userInfoModel.nickName}申请延时', + // date: DateTime.now()), + // ); + // Get.back(); + BaseModel baseModel = await ManageFunc.applyDelayed( + widget.dispatchId, + _delayList.indexOf(_nowSelect) + 1, + _textEditingController.text ?? ''); + if (baseModel.status) { + Get.back(); + } else { + BotToast.showText(text: baseModel.message); + } }, radius: 8.w, child: Text( diff --git a/lib/ui/sub_pages/business_and_fix/fix_work_finish_page.dart b/lib/ui/sub_pages/business_and_fix/fix_work_finish_page.dart index b06188e..7f4385d 100644 --- a/lib/ui/sub_pages/business_and_fix/fix_work_finish_page.dart +++ b/lib/ui/sub_pages/business_and_fix/fix_work_finish_page.dart @@ -2,26 +2,37 @@ import 'dart:io'; // Flutter imports: +import 'package:aku_community_manager/models/manager/bussiness_and_fix/bussiness_and_fix_model.dart'; +import 'package:aku_community_manager/models/manager/bussiness_and_fix/fixed_detail_model.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/manage_func.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:common_utils/common_utils.dart'; -import 'package:get/get.dart'; // Project imports: -import 'package:aku_community_manager/mock_models/fix/fix_model.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_title_box.dart'; import 'package:aku_community_manager/ui/widgets/inner/pick_image.dart'; +import 'package:get/get.dart'; class FixWorkFinishPage extends StatefulWidget { - final FixModel model; - FixWorkFinishPage({Key key, @required this.model}) : super(key: key); + final FixedDetailModel model; + final String reportDetail; + final bool dispatchType; + FixWorkFinishPage( + {Key key, + @required this.model, + @required this.dispatchType, + @required this.reportDetail}) + : super(key: key); @override _FixWorkFinishPageState createState() => _FixWorkFinishPageState(); @@ -34,6 +45,9 @@ class _FixWorkFinishPageState extends State { TextEditingController _humanController = TextEditingController(); TextEditingController _materialPriceController = TextEditingController(); + + double humanPrice; + double materialPrice; @override void dispose() { _descriptionController?.dispose(); @@ -57,7 +71,7 @@ class _FixWorkFinishPageState extends State { spacing: 24, children: [ Text( - widget.model.title, + widget.reportDetail, style: TextStyle( color: AppStyle.primaryTextColor, fontSize: 28.w, @@ -73,13 +87,15 @@ class _FixWorkFinishPageState extends State { mainAxisSpacing: 16.w, ), itemBuilder: (context, index) { - final img = widget.model.imgs[index]; + // final img = widget.model.imgs[index]; return ClipRRect( - borderRadius: BorderRadius.circular(4.w), - child: (img is String) ? Image.asset(img) : Image.file(img), - ); + borderRadius: BorderRadius.circular(4.w), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: widget.model.repairDetail.imgUrls[index].url, + )); }, - itemCount: widget.model.imgs.length, + itemCount: widget.model.repairDetail.imgUrls.length, ), ], ), @@ -262,87 +278,87 @@ class _FixWorkFinishPageState extends State { ) ], ), - // widget.model.detail.type == FIX_PAYMENT_TYPE.FREE - // ? SizedBox() - // : - AkuTitleBox( - title: '费用明细', - spacing: 16, - children: [ - Row( - children: [ - AkuBox.h(96), - Text('人工费'), - Expanded( - child: TextField( - controller: _humanController, - onChanged: (_) => setState(() {}), - keyboardType: TextInputType.number, - textAlign: TextAlign.end, - decoration: InputDecoration( - border: InputBorder.none, - hintText: '请输入', - hintStyle: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 28.sp, - color: AppStyle.minorTextColor, + widget.dispatchType + ? SizedBox() + : AkuTitleBox( + title: '费用明细', + spacing: 16, + children: [ + Row( + children: [ + AkuBox.h(96), + Text('人工费'), + Expanded( + child: TextField( + controller: _humanController, + onChanged: (_) => setState(() {}), + keyboardType: TextInputType.number, + textAlign: TextAlign.end, + decoration: InputDecoration( + border: InputBorder.none, + hintText: '请输入', + hintStyle: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 28.sp, + color: AppStyle.minorTextColor, + ), + ), + ), ), - ), + ], ), - ), - ], - ), - Divider(height: 1.w), - Row( - children: [ - AkuBox.h(96), - Text('材料费'), - Expanded( - child: TextField( - onChanged: (_) => setState(() {}), - controller: _materialPriceController, - textAlign: TextAlign.end, - keyboardType: TextInputType.number, - decoration: InputDecoration( - border: InputBorder.none, - hintText: '请输入', - hintStyle: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 28.sp, - color: AppStyle.minorTextColor, + Divider(height: 1.w), + Row( + children: [ + AkuBox.h(96), + Text('材料费'), + Expanded( + child: TextField( + onChanged: (_) => setState(() {}), + controller: _materialPriceController, + textAlign: TextAlign.end, + keyboardType: TextInputType.number, + decoration: InputDecoration( + border: InputBorder.none, + hintText: '请输入', + hintStyle: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 28.sp, + color: AppStyle.minorTextColor, + ), + ), + ), ), - ), + ], ), - ), - ], - ), - Divider(height: 1.w), - Row( - children: [ - AkuBox.h(96), - Text('总计费用'), - Spacer(), - Builder( - builder: (context) { - double humanPrice = - double.tryParse(_humanController.text); - double materialPrice = - double.tryParse(_materialPriceController.text); + Divider(height: 1.w), + Row( + children: [ + AkuBox.h(96), + Text('总计费用'), + Spacer(), + Builder( + builder: (context) { + humanPrice = double.tryParse(_humanController.text); + materialPrice = + double.tryParse(_materialPriceController.text); - if (TextUtil.isEmpty(_humanController.text) || - TextUtil.isEmpty(_materialPriceController.text)) { - return Text('人工费或材料费不能为空'); - } else if (humanPrice == null || materialPrice == null) - return Text('输入有误'); - else - return Text( - '¥${(humanPrice + materialPrice).toStringAsFixed(2)}'); - }, - ), - ], - ), - ], - ), + if (TextUtil.isEmpty(_humanController.text) || + TextUtil.isEmpty( + _materialPriceController.text)) { + return Text('人工费或材料费不能为空'); + } else if (humanPrice == null || + materialPrice == null) + return Text('输入有误'); + else + return Text( + '¥${(humanPrice + materialPrice).toStringAsFixed(2)}'); + }, + ), + ], + ), + ], + ), ], ), bottom: AkuMaterialButton( @@ -356,19 +372,33 @@ class _FixWorkFinishPageState extends State { ), height: 96.w, color: AppStyle.primaryColor, - onPressed: () { - widget.model.detail.result = FixResult( - detail: _descriptionController.text, - material: _materialController.text, - imgs: _imgs, - ); - widget.model.type = FIX_ENUM.DONE; - if (widget.model.detail.type == FIX_PAYMENT_TYPE.PAY) - widget.model.detail.priceDetail = FixPriceDetail( - humanPrice: double.parse(_humanController.text), - materialPrice: double.parse(_materialController.text), - ); - Get.back(); + onPressed: () async { + // widget.model.detail.result = FixResult( + // detail: _descriptionController.text, + // material: _materialController.text, + // imgs: _imgs, + // ); + // widget.model.type = FIX_ENUM.DONE; + // if (widget.model.detail.type == FIX_PAYMENT_TYPE.PAY) + // widget.model.detail.priceDetail = FixPriceDetail( + // humanPrice: double.parse(_humanController.text), + // materialPrice: double.parse(_materialController.text), + // ); + // Get.back(); + + BaseModel baseModel = await ManageFunc.handleResult( + widget.model.repairDetail.dispatchId, + _descriptionController.text, + _materialController.text, + humanPrice, + materialPrice, + humanPrice + materialPrice, + 1, []); + if (baseModel.status) { + Get.back(); //TODO 处理完成 + } else { + BotToast.showText(text: baseModel.message); + } }, ), ); diff --git a/lib/utils/network/manage_func.dart b/lib/utils/network/manage_func.dart index 1a76975..7f1de03 100644 --- a/lib/utils/network/manage_func.dart +++ b/lib/utils/network/manage_func.dart @@ -6,6 +6,7 @@ import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:dio/dio.dart'; class ManageFunc { + ///报事报修详情 static Future repairDetail(int id) async { Response response = await NetUtil().dio.get(API.manage.repairDetail, queryParameters: { @@ -14,6 +15,7 @@ class ManageFunc { return FixedDetailModel.fromJson(response.data); } + ///派单类型 static Future dispatchListDetailType() async { Response response = await NetUtil().dio.get( 'http://test.akuhotel.com:8804/IntelligentCommunity' + @@ -21,11 +23,13 @@ class ManageFunc { return response.data as List; } + ///工单时限 static Future workOrderTimeType() async { BaseModel baseModel = await NetUtil().get(API.manage.workOrderTimeLimit); return baseModel.data as List; } + ///工单子类列表 static Future workOrderTypeDetail(int id) async { BaseModel baseModel = await NetUtil().get(API.manage.workOrderTypeDetail, params: { @@ -34,6 +38,7 @@ class ManageFunc { return baseModel.data as List; } + ///派单 static Future repairDispatch(DispatchReportModel model) async { BaseModel baseModel = await NetUtil().get(API.manage.repairDispatch, params: { @@ -48,9 +53,52 @@ class ManageFunc { return baseModel; } + ///改派 static Future repairReassignment(int id, int operato) async { BaseModel baseModel = await NetUtil().get(API.manage.repairReassignment, params: {'dispatchListId': id, 'operator': operato}); return baseModel; } + + ///接单 + static Future recevingOrders(int id) async { + BaseModel basemodel = await NetUtil() + .get(API.manage.recevingOrders, params: {'dispatchListId': id}); + return basemodel; + } + + ///申请延时 + static Future applyDelayed(int id, int delayed, String remark) async { + BaseModel baseModel = + await NetUtil().post(API.manage.applyDelayed, params: { + 'dispatchListId': id, + 'delayedTime': delayed, + 'remake': remark, + }); + return baseModel; + } + + ///报事报修:处理完成 + static Future handleResult( + int dispatchListId, + String detail, + String materialList, + double laborCost, + double materialCost, + double totalCost, + int repairResult, + List fileUrls) async { + BaseModel baseModel = + await NetUtil().post(API.manage.handleResult, params: { + 'dispatchListId': dispatchListId, + 'detail': detail, + 'materialList': materialList, + 'laborCost': laborCost, + 'materialCost': materialCost, + 'totalCost': totalCost, + 'repairResult': repairResult, + 'fileUrls': fileUrls, + }); + return baseModel; + } }