From 7a2bc773f95cce1a7bd51d0ed44c3a001b82e6f4 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 23 Feb 2021 16:57:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=EF=BC=9A=E6=B4=BE=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 3 + .../dispatch_report_model.dart | 12 +-- .../business_and_fix_detail_page.dart | 89 +++++++----------- .../fixer_department_page.dart | 94 ++++++++++++------- lib/ui/widgets/inner/show_bottom_sheet.dart | 5 +- lib/utils/network/manage_func.dart | 14 +++ 6 files changed, 116 insertions(+), 101 deletions(-) diff --git a/lib/const/api.dart b/lib/const/api.dart index 198d8d7..f570120 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -72,5 +72,8 @@ class _Manage { ///报事报修:查询所有的工单类型明细信息(工单子类信息) String get workOrderTypeDetail => '/user/repair/findWorkOrderTypeDetail'; + + ///报事报修:报事报修:派单 + String get repairDispatch => '/user/repair/dispatch'; } diff --git a/lib/models/manager/bussiness_and_fix/dispatch_report_model.dart b/lib/models/manager/bussiness_and_fix/dispatch_report_model.dart index 09b54d5..b240198 100644 --- a/lib/models/manager/bussiness_and_fix/dispatch_report_model.dart +++ b/lib/models/manager/bussiness_and_fix/dispatch_report_model.dart @@ -8,12 +8,12 @@ class DispatchReportModel { String remark; DispatchReportModel.zero() { - dispatchListId = 0; - workOrderTyoe = 0; - workOrderTyoe = 0; - workOrderTimeLimit = 0; - type = 0; - operato = 0; + dispatchListId = -1; + workOrderTyoe = -1; + workOrderTypeDetail = -1; + workOrderTimeLimit = -1; + type = -1; + operato = -1; remark = ''; } DispatchReportModel( 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 ee99aad..39c5011 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,6 +6,7 @@ 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/fixer_department_page.dart'; import 'package:aku_community_manager/utils/network/manage_func.dart'; import 'package:flutter/material.dart'; @@ -13,6 +14,7 @@ import 'package:flutter/material.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; import 'package:provider/provider.dart'; // Project imports: @@ -63,51 +65,6 @@ class _BusinessAndFixDetailPageState extends State { super.dispose(); } - // String get fixType { - // switch (detailModel.type) { - // case FIX_PAYMENT_TYPE.FREE: - // return '无偿服务'; - // break; - // case FIX_PAYMENT_TYPE.PAY: - // return '有偿服务'; - // break; - // default: - // return ''; - // break; - // } - // } - - // String get dateLimit { - // switch (detailModel.limit) { - // case FIX_DATE_LIMIT.HOUR_24: - // return '24小时内处理'; - // break; - // case FIX_DATE_LIMIT.HOUR_12: - // return '12小时内处理'; - // break; - // case FIX_DATE_LIMIT.HOUR_8: - // return '8小时内处理'; - // break; - // default: - // return ''; - // break; - // } - // } - - // String get subType { - // switch (detailModel.subType) { - // case FIX_SUB_TYPE.NORMAL: - // return '一般单'; - // break; - // case FIX_SUB_TYPE.HURRY: - // return '加急单'; - // break; - // default: - // return ''; - // break; - // } - // } - Widget fixTypeWidget() { UserProvider userProvider = Provider.of(context, listen: false); @@ -136,10 +93,10 @@ class _BusinessAndFixDetailPageState extends State { header: MaterialHeader(), onRefresh: () async { _detailModel = await ManageFunc.repairDetail(widget.model.id); + _reportModel.dispatchListId = widget.model.id; + _reportModel.workOrderTyoe = 1; _onload = false; - setState(() { - - }); + setState(() {}); }, child: _onload ? _empty() @@ -170,7 +127,7 @@ class _BusinessAndFixDetailPageState extends State { _reportModel.workOrderTyoe != null && _reportModel.workOrderTimeLimit != null ? () { - // Get.to(FixerDepartmentPage(model: widget.model)); + Get.to(FixerDepartmentPage(model: _reportModel)); } : null, child: Text( @@ -342,9 +299,11 @@ class _BusinessAndFixDetailPageState extends State { children: [ _buildTypeTile( '派单类型', - _dispatchModels==null + _dispatchModels == null ? null - : _dispatchModels[_reportModel.type]?.showName, + : _dispatchModels[_dispatchModels.indexWhere( + (element) => element.showValue == _reportModel.type)] + .showName, canTap, helpContent: '请选择服务类型', onTap: () async { @@ -354,20 +313,26 @@ class _BusinessAndFixDetailPageState extends State { showItemSheet( title: '派单类型', items: _dispatchModels.map((e) => e.showName).toList(), + ids: _dispatchModels.map((e) => e.showValue).toList(), selectItem: _reportModel.type, onTap: (result) { _reportModel.type = result; }, ).then((_) { + if (_reportModel.type == -1) { + _dispatchModels = null; + } setState(() {}); }); }, ), _buildTypeTile( '工单时限', - _timeLimitModels==null + _timeLimitModels == null ? null - : _timeLimitModels[_reportModel.workOrderTimeLimit]?.name, + : _timeLimitModels[_timeLimitModels.indexWhere((element) => + element.id == _reportModel.workOrderTimeLimit)] + ?.name, canTap, helpContent: '请选择工单时限', onTap: () async { @@ -377,20 +342,26 @@ class _BusinessAndFixDetailPageState extends State { showItemSheet( title: '工单时限', items: _timeLimitModels.map((e) => e.name).toList(), + ids: _timeLimitModels.map((e) => e.id).toList(), selectItem: _reportModel.workOrderTimeLimit, onTap: (result) { _reportModel.workOrderTimeLimit = result; }, ).then((_) { + if (_reportModel.workOrderTimeLimit == -1) { + _timeLimitModels = null; + } setState(() {}); }); }, ), _buildTypeTile( '工单子类', - _workTypeModels==null + _workTypeModels == null ? null - : _workTypeModels[_reportModel.workOrderTyoe].name, + : _workTypeModels[_workTypeModels.indexWhere((element) => + element.id == _reportModel.workOrderTypeDetail)] + .name, canTap, helpContent: '请选择工单子类', onTap: () async { @@ -400,11 +371,15 @@ class _BusinessAndFixDetailPageState extends State { showItemSheet( title: '工单子类', items: _workTypeModels.map((e) => e.name).toList(), - selectItem: _reportModel.workOrderTyoe, + ids: _workTypeModels.map((e) => e.id).toList(), + selectItem: _reportModel.workOrderTypeDetail, onTap: (result) { - _reportModel.workOrderTyoe = result; + _reportModel.workOrderTypeDetail = result; }, ).then((_) { + if (_reportModel.workOrderTypeDetail == -1) { + _workTypeModels = null; + } setState(() {}); }); }, diff --git a/lib/ui/sub_pages/business_and_fix/fixer_department_page.dart b/lib/ui/sub_pages/business_and_fix/fixer_department_page.dart index 6ddab40..0e74024 100644 --- a/lib/ui/sub_pages/business_and_fix/fixer_department_page.dart +++ b/lib/ui/sub_pages/business_and_fix/fixer_department_page.dart @@ -1,8 +1,11 @@ // Flutter imports: import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/bussiness_and_fix/dispatch_report_model.dart'; import 'package:aku_community_manager/models/manager/fixer_item_model.dart'; import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/manage_func.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: @@ -13,14 +16,13 @@ import 'package:get/get.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/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'; class FixerDepartmentPage extends StatefulWidget { - final FixModel model; + final DispatchReportModel model; final bool changeType; FixerDepartmentPage({Key key, @required this.model, this.changeType = false}) : super(key: key); @@ -30,6 +32,7 @@ class FixerDepartmentPage extends StatefulWidget { } class _FixerDepartmentPageState extends State { + DispatchReportModel _reportModel; List _pickedFixers = []; List _fixerItems = []; @@ -45,6 +48,7 @@ class _FixerDepartmentPageState extends State { _fixerItems = (model.data as List) .map((e) => FixerItemModel.fromJson(e)) .toList(); + _reportModel = widget.model; setState(() {}); }, child: ListView.builder( @@ -57,29 +61,41 @@ class _FixerDepartmentPageState extends State { ), bottom: AkuMaterialButton( height: 96.w, - onPressed: _pickedFixers.isEmpty - ? null - : () { - if (widget.changeType) { - Get.back(); - _pickedFixers.forEach((element) { - widget.model.detail.fixStatuses.add( - FixStatus( - title: '改派给${element.name}', date: DateTime.now()), - ); - }); - } else { - Get.back(); - Get.back(); - widget.model.type = FIX_ENUM.WAIT_PICKUP; - _pickedFixers.forEach((element) { - widget.model.detail.fixStatuses.add( - FixStatus( - title: '分配给${element.name}', date: DateTime.now()), - ); - }); - } - }, + onPressed: () async { + if (widget.changeType) { + } else { + BaseModel baseModel = await ManageFunc.repairDispatch(_reportModel); + if (baseModel.status) { + Get.back(); + Get.back(); + } else { + BotToast.showText(text: baseModel.message); + } + } + }, + // onPressed: _pickedFixers.isEmpty + // ? null + // : () { + // if (widget.changeType) { + // Get.back(); + // _pickedFixers.forEach((element) { + // widget.model.detail.fixStatuses.add( + // FixStatus( + // title: '改派给${element.name}', date: DateTime.now()), + // ); + // }); + // } else { + // Get.back(); + // Get.back(); + // widget.model.type = FIX_ENUM.WAIT_PICKUP; + // _pickedFixers.forEach((element) { + // widget.model.detail.fixStatuses.add( + // FixStatus( + // title: '分配给${element.name}', date: DateTime.now()), + // ); + // }); + // } + // }, color: AppStyle.primaryColor, nullColor: AppStyle.primaryColor.withOpacity(0.5), child: Text( @@ -139,13 +155,14 @@ class _FixerDepartmentPageState extends State { AkuMaterialButton( height: 96.w, onPressed: () { - if (_pickedFixers - .indexWhere((element) => element.id == e.id) == - -1) { - _pickedFixers.add(e); - } else { - _pickedFixers.remove(e); - } + // if (_pickedFixers + // .indexWhere((element) => element.id == e.id) == + // -1) { + // _pickedFixers.add(e); + // } else { + // _pickedFixers.remove(e); + // } + _reportModel.operato = e.id; setState(() {}); }, child: Row( @@ -154,12 +171,17 @@ class _FixerDepartmentPageState extends State { Checkbox( checkColor: AppStyle.primaryTextColor, activeColor: AppStyle.primaryColor, - value: _pickedFixers.indexOf(e) != -1, + value: _reportModel.operato == e.id, onChanged: (state) { - if (_pickedFixers.indexOf(e) == -1) { - _pickedFixers.add(e); + // if (_pickedFixers.indexOf(e) == -1) { + // _pickedFixers.add(e); + // } else { + // _pickedFixers.remove(e); + // } + if (_reportModel.operato == e.id) { + _reportModel.operato = -1; } else { - _pickedFixers.remove(e); + _reportModel.operato = e.id; } setState(() {}); }, diff --git a/lib/ui/widgets/inner/show_bottom_sheet.dart b/lib/ui/widgets/inner/show_bottom_sheet.dart index fee2962..0f6f029 100644 --- a/lib/ui/widgets/inner/show_bottom_sheet.dart +++ b/lib/ui/widgets/inner/show_bottom_sheet.dart @@ -58,6 +58,7 @@ Future showNormalSheet(String title, List children) async { Future showItemSheet({ String title, List items, + List ids, int selectItem, Function(int result) onTap, }) async { @@ -69,14 +70,14 @@ Future showItemSheet({ minWidth: double.infinity, onPressed: () { Get.back(); - onTap(items.indexOf(e)); + onTap(ids[items.indexOf(e)]); }, child: Text( e, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 32.sp, - color: e == items[selectItem] + color: items.indexOf(e)==ids.indexOf(selectItem) ? AppStyle.secondaryColor : AppStyle.primaryTextColor, ), diff --git a/lib/utils/network/manage_func.dart b/lib/utils/network/manage_func.dart index 4a6cd8a..e278c65 100644 --- a/lib/utils/network/manage_func.dart +++ b/lib/utils/network/manage_func.dart @@ -1,4 +1,5 @@ import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/bussiness_and_fix/dispatch_report_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/net_util.dart'; @@ -32,4 +33,17 @@ class ManageFunc { }); return baseModel.data as List; } + + static Future repairDispatch(DispatchReportModel model) async { + BaseModel baseModel = await NetUtil().get(API.manage.repairDispatch, params:{ + 'dispatchListId':model.dispatchListId, + 'workOrderType':model.workOrderTyoe, + 'workOrderTypeDetail':model.workOrderTypeDetail, + 'workOrderTimeLimit':model.workOrderTimeLimit, + 'type':model.type, + 'operator':model.operato, + 'remake':model.remark, + }); + return baseModel; + } }