From d3673c653dacec337935d17ff91898c968d7f295 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Thu, 15 Jul 2021 11:40:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=EF=BC=8C=E5=AE=8C=E5=96=84=E5=AE=B6=E6=94=BF?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 7 + .../house_keeping_list_model.dart | 11 ++ .../house_keeping_process_model.dart | 45 +++++ .../house_keeping_process_model.g.dart | 20 ++ .../house_keeping/house_keeping_card.dart | 43 ++++- .../house_keeping_detail_page.dart | 179 +++++++++++++++++- .../house_keeping/house_keeping_func.dart | 45 ++++- .../house_keeping/house_keeping_view.dart | 10 +- 8 files changed, 336 insertions(+), 24 deletions(-) create mode 100644 lib/models/house_keeping/house_keeping_process_model.dart create mode 100644 lib/models/house_keeping/house_keeping_process_model.g.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index bf59cc20..e5208a8e 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -286,6 +286,13 @@ class _Manager { ///app新版家政服务:确认提交家政 String get submitHouseKeeping => '/user/housekeepingService/submitHousekeeping'; + + ///app新版家政服务:根据家政服务主键id查询家政服务服务进程 + String get houseKeepingProcess => + '/user/housekeepingService/findHousekeepingProcessRecord'; + + ///app新版家政服务:取消服务 + String get housekeepingCancel => '/user/housekeepingService/cancel'; } class _Community { diff --git a/lib/models/house_keeping/house_keeping_list_model.dart b/lib/models/house_keeping/house_keeping_list_model.dart index 553c3209..ed7da8fd 100644 --- a/lib/models/house_keeping/house_keeping_list_model.dart +++ b/lib/models/house_keeping/house_keeping_list_model.dart @@ -96,6 +96,17 @@ class HouseKeepingListModel extends Equatable { } } + String get completionString { + switch (this.completion) { + case 1: + return '未完成'; + case 2: + return '已完成'; + default: + return '未知'; + } + } + @override List get props { return [ diff --git a/lib/models/house_keeping/house_keeping_process_model.dart b/lib/models/house_keeping/house_keeping_process_model.dart new file mode 100644 index 00000000..5f8338f4 --- /dev/null +++ b/lib/models/house_keeping/house_keeping_process_model.dart @@ -0,0 +1,45 @@ +import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'house_keeping_process_model.g.dart'; + +@JsonSerializable() +class HouseKeepingProcessModel extends Equatable { + final int id; + final int housekeepingServiceId; + final String operationDate; + final int operationType; + @JsonKey(name: 'operator') + final int opName; + final int operatorType; + final String operatorContent; + HouseKeepingProcessModel({ + required this.id, + required this.housekeepingServiceId, + required this.operationDate, + required this.operationType, + required this.opName, + required this.operatorType, + required this.operatorContent, + }); + factory HouseKeepingProcessModel.fromJson(Map json) => + _$HouseKeepingProcessModelFromJson(json); + factory HouseKeepingProcessModel.fail() => HouseKeepingProcessModel( + id: -1, + housekeepingServiceId: -1, + operationDate: '', + opName: 0, + operationType: 0, + operatorContent: '', + operatorType: 1); + @override + List get props { + return [ + id, + housekeepingServiceId, + operationDate, + operationType, + operatorType, + operatorContent, + ]; + } +} diff --git a/lib/models/house_keeping/house_keeping_process_model.g.dart b/lib/models/house_keeping/house_keeping_process_model.g.dart new file mode 100644 index 00000000..f746283f --- /dev/null +++ b/lib/models/house_keeping/house_keeping_process_model.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'house_keeping_process_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +HouseKeepingProcessModel _$HouseKeepingProcessModelFromJson( + Map json) { + return HouseKeepingProcessModel( + id: json['id'] as int, + housekeepingServiceId: json['housekeepingServiceId'] as int, + operationDate: json['operationDate'] as String, + operationType: json['operationType'] as int, + opName: json['operator'] as int, + operatorType: json['operatorType'] as int, + operatorContent: json['operatorContent'] as String, + ); +} diff --git a/lib/ui/manager/house_keeping/house_keeping_card.dart b/lib/ui/manager/house_keeping/house_keeping_card.dart index 207a1787..377ce16a 100644 --- a/lib/ui/manager/house_keeping/house_keeping_card.dart +++ b/lib/ui/manager/house_keeping/house_keeping_card.dart @@ -2,10 +2,13 @@ import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/models/house_keeping/house_keeping_list_model.dart'; +import 'package:aku_community/models/house_keeping/house_keeping_process_model.dart'; import 'package:aku_community/ui/manager/house_keeping/house_keeping_detail_page.dart'; +import 'package:aku_community/ui/manager/house_keeping/house_keeping_func.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/buttons/card_bottom_button.dart'; import 'package:aku_community/widget/others/aku_chip_box.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flustars/flustars.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -14,7 +17,10 @@ import 'package:velocity_x/velocity_x.dart'; class HouseKeepingCard extends StatelessWidget { final HouseKeepingListModel model; - const HouseKeepingCard({Key? key, required this.model}) : super(key: key); + final VoidCallback callRefresh; + const HouseKeepingCard( + {Key? key, required this.model, required this.callRefresh}) + : super(key: key); String get dateStart => DateUtil.formatDateStr(model.createDate, format: 'yyyy-MM-dd HH:mm:ss'); @@ -22,11 +28,17 @@ class HouseKeepingCard extends StatelessWidget { Widget build(BuildContext context) { return GestureDetector( onTap: () async { - Get.to(() => HouseKeepingDetailPage(model: model)); + List processModels = + await HouseKeepingFunc.getHouseKeepingProcess( + model.id, + ); + Get.to(() => HouseKeepingDetailPage( + model: model, + processModels: processModels, + )); }, child: Container( padding: EdgeInsets.all(24.w), - child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -131,17 +143,36 @@ class HouseKeepingCard extends StatelessWidget { switch (model.status) { case 1: return [ - CardBottomButton.white(onPressed: () async {}, text: ('取消服务')), + CardBottomButton.white( + onPressed: () async { + Function cancel = BotToast.showLoading(); + await HouseKeepingFunc.cancelHouseKeepingProcess(model.id); + cancel(); + callRefresh(); + }, + text: ('取消服务')), ]; case 2: return [ - CardBottomButton.white(onPressed: () async {}, text: ('取消服务')), + CardBottomButton.white( + onPressed: () async { + Function cancel = BotToast.showLoading(); + await HouseKeepingFunc.cancelHouseKeepingProcess(model.id); + cancel(); + callRefresh(); + }, + text: ('取消服务')), ]; case 3: return [ CardBottomButton.white( onPressed: () async { - Get.to(() => HouseKeepingDetailPage(model: model)); + List processModels = + await HouseKeepingFunc.getHouseKeepingProcess(model.id); + Get.to(() => HouseKeepingDetailPage( + model: model, + processModels: processModels, + )); }, text: ('查看详情')), ]; diff --git a/lib/ui/manager/house_keeping/house_keeping_detail_page.dart b/lib/ui/manager/house_keeping/house_keeping_detail_page.dart index 9d48e340..0ca8b1be 100644 --- a/lib/ui/manager/house_keeping/house_keeping_detail_page.dart +++ b/lib/ui/manager/house_keeping/house_keeping_detail_page.dart @@ -1,17 +1,25 @@ +import 'package:aku_community/widget/bee_divider.dart'; +import 'package:flustars/flustars.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; import 'package:aku_community/models/house_keeping/house_keeping_list_model.dart'; +import 'package:aku_community/models/house_keeping/house_keeping_process_model.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/views/bee_grid_image_view.dart'; -import 'package:flustars/flustars.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:velocity_x/velocity_x.dart'; class HouseKeepingDetailPage extends StatefulWidget { final HouseKeepingListModel model; - HouseKeepingDetailPage({Key? key, required this.model}) : super(key: key); + final List processModels; + HouseKeepingDetailPage( + {Key? key, required this.model, required this.processModels}) + : super(key: key); @override _HouseKeepingDetailPageState createState() => _HouseKeepingDetailPageState(); @@ -26,6 +34,42 @@ class _HouseKeepingDetailPageState extends State { padding: EdgeInsets.symmetric(vertical: 24.w), children: [ _buildInfo(), + 16.w.heightBox, + _buildProcess(), + 16.w.heightBox, + Offstage( + offstage: widget.model.handlingTime == null, + child: Column( + children: [ + 16.w.heightBox, + _serviceFeedBack(), + ], + ), + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), + color: Colors.white, + child: Row( + children: [ + '服务费用'.text.size(28.sp).black.make(), + Spacer(), + '¥ ${widget.model.payFee ?? 0}' + .text + .size(32.sp) + .color(Colors.red) + .make() + ], + ), + ), + Offstage( + offstage: widget.model.evaluationTime == null, + child: Column( + children: [ + 16.w.heightBox, + _buildEvaluate(), + ], + ), + ) ], ), ); @@ -80,9 +124,10 @@ class _HouseKeepingDetailPageState extends State { ); } - Widget _buidProcess() { + Widget _buildProcess() { return Container( padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w), + color: Colors.white, width: double.infinity, child: Column( children: [ @@ -91,20 +136,136 @@ class _HouseKeepingDetailPageState extends State { '服务进程'.text.size(36.sp).bold.black.make(), ], ), + 24.w.heightBox, + ...widget.processModels + .map((e) => _buildProcessTile(e.operatorContent, e.operationDate)) + .toList() + .sepWidget(separate: 24.w.heightBox) ], ), ); } - Widget _buidProcessTile(String title, DateTime date) { + Widget _buildProcessTile(String content, String date) { return Row(children: [ - title.text.size(28.sp).color(ktextSubColor).make(), + content.text.size(28.sp).color(ktextSubColor).make(), Spacer(), - '${DateUtil.formatDate(date, format: 'yyyy-MM-dd HH:mm:ss')}' + '${DateUtil.formatDateStr(date, format: 'yyyy-MM-dd HH:mm:ss')}' .text .size(28.sp) .black .make(), ]); } + + Widget _buildEvaluate() { + return Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w), + color: Colors.white, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '服务评价'.text.size(36.sp).bold.black.make(), + 40.w.heightBox, + Row( + children: [ + '综合评价'.text.size(28.sp).color(ktextSubColor).make(), + 40.w.widthBox, + RatingBar( + ignoreGestures: true, + allowHalfRating: true, + itemPadding: EdgeInsets.symmetric(horizontal: 15.w), + itemSize: 32.w, + initialRating: (widget.model.evaluation ?? 0).toDouble(), + ratingWidget: RatingWidget( + empty: Icon( + CupertinoIcons.star, + ), + full: Icon( + CupertinoIcons.star_fill, + color: kPrimaryColor, + ), + half: Icon( + CupertinoIcons.star_lefthalf_fill, + color: kPrimaryColor, + )), + onRatingUpdate: (value) {}) + ], + ), + 40.w.heightBox, + BeeDivider.horizontal(), + 40.w.heightBox, + (widget.model.evaluationContent ?? '') + .text + .size(28.sp) + .black + .softWrap(true) + .make(), + BeeGridImageView(urls: []) + ], + ), + ); + } + + Widget _serviceFeedBack() { + return Container( + width: double.infinity, + color: Colors.white, + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w), + child: Column( + children: [ + '服务反馈'.text.size(36.sp).bold.black.make(), + 40.w.heightBox, + Row( + children: [ + '完成情况'.text.size(28.sp).color(ktextSubColor).make(), + Spacer(), + widget.model.completionString.text.size(32.sp).black.make() + ], + ), + 40.w.heightBox, + Row( + children: [ + Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + width: 40.w, + height: 40.w, + ), + 8.w.widthBox, + '维修人'.text.size(28.sp).color(ktextSubColor).make(), + Spacer(), + widget.model.proposerName.text.size(28.sp).black.make(), + ], + ), + 16.w.heightBox, + Row( + children: [ + Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + width: 40.w, + height: 40.w, + ), + 8.w.widthBox, + '联系电话'.text.size(28.sp).color(ktextSubColor).make(), + Spacer(), + widget.model.proposerTel.text.size(28.sp).black.make(), + ], + ), + 16.w.heightBox, + 40.w.heightBox, + '处理描述'.text.size(28.sp).color(ktextSubColor).make(), + 24.w.heightBox, + (widget.model.processDescription ?? '') + .text + .size(2) + .black + .softWrap(true) + .make(), + BeeGridImageView(urls: []) + ], + ), + ); + } } diff --git a/lib/ui/manager/house_keeping/house_keeping_func.dart b/lib/ui/manager/house_keeping/house_keeping_func.dart index 45a030eb..d47814b8 100644 --- a/lib/ui/manager/house_keeping/house_keeping_func.dart +++ b/lib/ui/manager/house_keeping/house_keeping_func.dart @@ -1,20 +1,51 @@ import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/house_keeping/house_keeping_process_model.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; class HouseKeepingFunc { - static Future submitHouseKeeping( - int estateId, - int type, - String content, - List urls - ) async { + ///提交新增家政服务 + static Future submitHouseKeeping( + int estateId, int type, String content, List urls) async { BaseModel baseModel = await NetUtil().post(API.manager.submitHouseKeeping, - params: {"estateId": estateId, "type": type, "content": content,"submitImgUrls":urls}); + params: { + "estateId": estateId, + "type": type, + "content": content, + "submitImgUrls": urls + }); if (baseModel.status ?? false) { return true; } else { return false; } } + + ///获取家政服务进程 + static Future getHouseKeepingProcess(int id) async { + BaseModel baseModel = await NetUtil().get(API.manager.houseKeepingProcess, + params: {"housekeepingServiceId": id}); + if (baseModel.status ?? false) { + return (baseModel.data as List) + .map((e) => HouseKeepingProcessModel.fromJson(e)) + .toList(); + } else { + return []; + } + } + + ///取消家政服务 + static Future cancelHouseKeepingProcess(int id) async { + BaseModel baseModel = + await NetUtil().get(API.manager.housekeepingCancel, params: { + "housekeepingServiceId": id, + }); + if (baseModel.status ?? false) { + BotToast.showText(text: '取消成功'); + return true; + } else { + return false; + } + } } diff --git a/lib/ui/manager/house_keeping/house_keeping_view.dart b/lib/ui/manager/house_keeping/house_keeping_view.dart index ae7bf580..af89b1e3 100644 --- a/lib/ui/manager/house_keeping/house_keeping_view.dart +++ b/lib/ui/manager/house_keeping/house_keeping_view.dart @@ -46,9 +46,14 @@ class _HouseKeepingViewState extends State }, builder: (items) { return ListView.separated( - padding: EdgeInsets.symmetric(horizontal: 24.w), + padding: EdgeInsets.symmetric(horizontal: 24.w), itemBuilder: (context, index) { - return HouseKeepingCard(model: items[index]); + return HouseKeepingCard( + model: items[index], + callRefresh: () { + _controller.callRefresh(); + }, + ); }, separatorBuilder: (_, __) { return 24.w.heightBox; @@ -56,6 +61,7 @@ class _HouseKeepingViewState extends State itemCount: items.length); }); } + @override bool get wantKeepAlive => true; }