From be54a30b2dcfe7f6503e6009f3e63c797ef731b9 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 5 Nov 2020 20:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=09=E6=B7=BB=E5=8A=A0=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mock_models/fix/fix_model.dart | 31 +++--- .../fix_work_finish_page.dart | 95 ++++++++++++++++++- 2 files changed, 114 insertions(+), 12 deletions(-) diff --git a/lib/mock_models/fix/fix_model.dart b/lib/mock_models/fix/fix_model.dart index 333ec11..6288538 100644 --- a/lib/mock_models/fix/fix_model.dart +++ b/lib/mock_models/fix/fix_model.dart @@ -1,6 +1,7 @@ -import 'package:aku_community_manager/const/resource.dart'; import 'package:flutter/material.dart'; +import 'package:aku_community_manager/const/resource.dart'; + enum FIX_ENUM { ///待派单 HAND_OUT, @@ -110,15 +111,6 @@ class FixModel { title: '分派给李保国师傅', date: DateTime(2020, 10, 23, 10, 32, 14)), FixStatus(title: '师傅已接单', date: DateTime(2020, 10, 23, 10, 38, 26)), ], - result: FixResult( - detail: '电饭煲插头没插', - material: '无', - imgs: [R.ASSETS_STATIC_FIX_FOOD_PNG], - ), - review: UserReviewInfo( - rate: 5, - content: '师傅太用心了', - ), ), ), FixModel( @@ -130,7 +122,7 @@ class FixModel { userName: '杨建', userPhoneNumber: '18882929292', fixArea: 'A区', - type: FIX_PAYMENT_TYPE.FREE, + type: FIX_PAYMENT_TYPE.PAY, limit: FIX_DATE_LIMIT.HOUR_24, subType: FIX_SUB_TYPE.NORMAL, fixStatuses: [ @@ -149,6 +141,10 @@ class FixModel { rate: 5, content: '师傅太用心了', ), + priceDetail: FixPriceDetail( + humanPrice: 10, + materialPrice: 0, + ), ), ), ]; @@ -228,6 +224,8 @@ class FixDetailModel { FixResult result; UserReviewInfo review; + + FixPriceDetail priceDetail; FixDetailModel({ this.userName, this.userPhoneNumber, @@ -238,6 +236,7 @@ class FixDetailModel { this.fixStatuses, this.result, this.review, + this.priceDetail, }); } @@ -271,3 +270,13 @@ class UserReviewInfo { this.content, }); } + +class FixPriceDetail { + double humanPrice; + double materialPrice; + FixPriceDetail({ + this.humanPrice, + this.materialPrice, + }); + double get allPrice => humanPrice + materialPrice; +} 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 d4452a2..54b3a71 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 @@ -8,6 +8,7 @@ import 'package:aku_community_manager/tools/screen_tool.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:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -24,6 +25,18 @@ class _FixWorkFinishPageState extends State { List _imgs = []; TextEditingController _descriptionController = TextEditingController(); TextEditingController _materialController = TextEditingController(); + + TextEditingController _humanController = TextEditingController(); + TextEditingController _materialPriceController = TextEditingController(); + @override + void dispose() { + _descriptionController?.dispose(); + _materialController?.dispose(); + _materialPriceController?.dispose(); + _materialPriceController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return AkuScaffold( @@ -243,10 +256,85 @@ 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, + ), + ), + ), + ), + ], + ), + 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); + + 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)}'); + }, + ), + ], + ), ], ), ], @@ -269,6 +357,11 @@ class _FixWorkFinishPageState extends State { 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(); }, ),