From 3461f4f7528032e983e7c4ee462e64abb253db6d Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 6 Nov 2020 13:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=80=9F=E8=BF=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/manage/info.png | Bin 0 -> 2201 bytes lib/mock_models/borrow/borrow_data.dart | 68 +++++- lib/mock_models/borrow/borrow_model.dart | 10 + .../borrow_manager/borrow_manager_card.dart | 221 ++++++++++++++++++ .../borrow_manager_check_page.dart | 170 ++++++++++++++ .../borrow_manager/borrow_manager_page.dart | 33 +++ pubspec.lock | 49 +++- pubspec.yaml | 2 + 8 files changed, 548 insertions(+), 5 deletions(-) create mode 100644 assets/manage/info.png create mode 100644 lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart create mode 100644 lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart diff --git a/assets/manage/info.png b/assets/manage/info.png new file mode 100644 index 0000000000000000000000000000000000000000..fad8ff980af177970ac1743358ed973805c31add GIT binary patch literal 2201 zcmV;K2xj+*P)| zw#N96&b-~8k<&kx76rl?{8bgw2vz*iq)H7Dx%5=D*}bAAz22Lz`Rbmzdwp+j=goV! z2fj%*_s7lmJM;bQcV@oxotZ_*ixUBKlFo%82k7VoIlvsCBLPS8+yirfjszUVa}Ue` zIudXc&pj{)=t#g(JomuoJHTeMS!lQ0uLFR$0KlvGLqsnHfI&nYWc!HdSpawz5vKv* z51r4$<#PG)YPA|TGH?>_iw7#D20YKZnTSS+=HsGuCN7DV0iFwr}75 zRFbyhWKsp#f%hl?yePIo#KT1NNh#&QG!4;O-$q1V1b~fQ^gdH6m99z?Vrl?+*tS}& zLtQ-YG$QUSm&<#yS{)A_JXkz-?AS*DU^f5^#DF|fsZ_2>YdEI@kQWT!_rKd^&YSi; z@0MDv_PaE_E>4&4`)@VI?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pxM*<%?Zo zz*Tju$p&U|u&%Yfmx#7Sc-z+j;A@3Kp=gYGEdadSHnAF)Ne6)b9ISWd!c?zzXs!1W z(d|79*CSF&&RF+UR^`=>ju)nSxoBcyV&mN09N&A1ODR3>dENp3jE#*w(F?s*eYvPJ z7xFWP$m?xbkeuQ$fLnTRgu+gaUy_JoL@K*ZmBp7+SQb?biRnkRJi z2kT=^*9Ko`@;N}qZ!`y(19T+dD4u&@4$zT+qj>ItIY37Oj^eoo<^UZDIEv>Um;-bq b;3)oY2ymW_{?1(n00000NkvXXu0mjfh`cB> literal 0 HcmV?d00001 diff --git a/lib/mock_models/borrow/borrow_data.dart b/lib/mock_models/borrow/borrow_data.dart index 2428927..da06a3f 100644 --- a/lib/mock_models/borrow/borrow_data.dart +++ b/lib/mock_models/borrow/borrow_data.dart @@ -2,13 +2,73 @@ import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; class BorrowData { + static List get checkModels => models.where((e) { + return e.borrowGoods.status == BORROW_STATUS.WAIT_CHECK; + }).toList(); + static List get borrowModels => models.where((e) { + return e.borrowGoods.status == BORROW_STATUS.BORROWING; + }).toList(); + + static List get doneModels => models.where((e) { + return e.borrowGoods.status == BORROW_STATUS.DONE; + }).toList(); + static List models = [ BorrowModel( + title: '归还梯子一个', + borrowPerson: '李慧珍', + borrowTime: 5, + goodsStatus: GOODS_STATUS.BROKEN, + phone: '19981712931', + borrowGoods: SingleBorrowGoods( + name: '梯子', + assetpath: R.ASSETS_STATIC_TEMP_LADDER_PNG, + code: '3193713894', + status: BORROW_STATUS.WAIT_CHECK, + ), + date: DateTime(2020, 5, 5, 12, 35, 45), + ), + BorrowModel( + title: '归还梯子一个', borrowPerson: '李慧珍', - borrowTime: null, - goodsStatus: null, - phone: null, - borrowGoods: SingleBorrowGoods(name: ''), + borrowTime: 5, + goodsStatus: GOODS_STATUS.BROKEN, + phone: '19981712931', + borrowGoods: SingleBorrowGoods( + name: '梯子', + assetpath: R.ASSETS_STATIC_TEMP_LADDER_PNG, + code: '3193713894', + status: BORROW_STATUS.DONE, + ), + date: DateTime(2020, 5, 5, 12, 35, 45), + ), + BorrowModel( + title: '借用电钻一把', + borrowPerson: '刘虎门', + borrowTime: 12, + goodsStatus: GOODS_STATUS.NORMAL, + phone: '19981738879', + borrowGoods: SingleBorrowGoods( + name: '电钻', + assetpath: R.ASSETS_STATIC_TEMP_DRILL_PNG, + code: '31937293841', + status: BORROW_STATUS.BORROWING, + ), + date: DateTime(2020, 4, 5, 12, 35, 45), + ), + BorrowModel( + borrowPerson: '刘海保', + borrowTime: 5, + title: '借用榔头一把', + goodsStatus: GOODS_STATUS.NORMAL, + phone: '19981738879', + borrowGoods: SingleBorrowGoods( + name: '榔头', + assetpath: R.ASSETS_STATIC_TEMP_HAMMER_PNG, + code: '3193794102481', + status: BORROW_STATUS.BORROWING, + ), + date: DateTime(2020, 3, 5, 12, 35, 45), ), ]; diff --git a/lib/mock_models/borrow/borrow_model.dart b/lib/mock_models/borrow/borrow_model.dart index 3d5c4b1..343c73b 100644 --- a/lib/mock_models/borrow/borrow_model.dart +++ b/lib/mock_models/borrow/borrow_model.dart @@ -19,6 +19,7 @@ enum BORROW_STATUS { enum GOODS_STATUS { NORMAL, BROKEN, + LOST, } class BorrowModel { @@ -28,6 +29,7 @@ class BorrowModel { GOODS_STATUS goodsStatus; String title; SingleBorrowGoods borrowGoods; + DateTime date; BorrowModel({ @required this.borrowPerson, @@ -35,6 +37,8 @@ class BorrowModel { @required this.borrowTime, @required this.goodsStatus, @required this.borrowGoods, + @required this.title, + @required this.date, }); } @@ -69,6 +73,12 @@ class SingleBorrowGoods { String code; dynamic assetpath; BORROW_STATUS status; + String get borrowValue => { + BORROW_STATUS.BORROWING: '出借中', + BORROW_STATUS.DONE: '已归还', + BORROW_STATUS.NOT_BORROW: '未出借', + BORROW_STATUS.WAIT_CHECK: '待检查', + }[status]; SingleBorrowGoods({ this.name, this.code, diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart new file mode 100644 index 0000000..755ccef --- /dev/null +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart @@ -0,0 +1,221 @@ +import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; +import 'package:aku_community_manager/mock_models/users/user_info_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/widget_tool.dart'; +import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_chip_box.dart'; +import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class BorrowManagerCard extends StatefulWidget { + final BorrowModel model; + BorrowManagerCard({Key key, this.model}) : super(key: key); + + @override + _BorrowManagerCardState createState() => _BorrowManagerCardState(); +} + +class _BorrowManagerCardState extends State { + USER_ROLE get role => + Provider.of(context, listen: false).userInfoModel.role; + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(top: 16.w), + padding: EdgeInsets.all(24.w), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8.w), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + AkuChipBox(title: '借还管理'), + AkuBox.w(24), + Text( + DateUtil.formatDate(widget.model.date), + style: TextStyle(), + ), + Spacer(), + Text( + widget.model.borrowGoods.borrowValue, + style: TextStyle( + color: AppStyle.failColor, + fontWeight: FontWeight.bold, + fontSize: 24.sp, + ), + ), + ], + ), + AkuBox.h(24), + Text( + widget.model.title, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 32.sp, + fontWeight: FontWeight.bold, + ), + ), + AkuBox.h(16), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + (widget.model.borrowGoods.assetpath is String) + ? Image.asset( + widget.model.borrowGoods.assetpath, + height: 184.w, + width: 183.w, + fit: BoxFit.cover, + ) + : Image.file( + widget.model.borrowGoods.assetpath, + height: 184.w, + width: 183.w, + fit: BoxFit.cover, + ), + AkuBox.w(24), + Expanded( + child: Column( + children: [ + _buildRow(R.ASSETS_MESSAGE_IC_PEOPLE_PNG, '借用人员', + widget.model.borrowPerson), + _buildRow(R.ASSETS_MESSAGE_IC_PHONE_PNG, '联系电话', + widget.model.phone), + _buildRow(R.ASSETS_MANAGE_IC_TIME_PNG, '借用时常', + '${widget.model.borrowTime}天'), + _buildRow( + R.ASSETS_MANAGE_INFO_PNG, + '物品状态', + widget.model.goodsStatus == GOODS_STATUS.BROKEN + ? '损坏' + : widget.model.goodsStatus == GOODS_STATUS.LOST + ? '丢失' + : '正常', + color: widget.model.goodsStatus == GOODS_STATUS.NORMAL + ? AppStyle.primaryTextColor + : AppStyle.failColor, + ), + ], + ), + ), + ], + ), + ..._buildCard(), + ], + ), + ); + } + + List _buildCard() { + if (role != USER_ROLE.MANAGER) + return []; + else if (widget.model.borrowGoods.status == BORROW_STATUS.DONE) { + return []; + } else + return [ + Divider(height: 48.w), + Row( + children: [ + Spacer(), + MaterialButton( + minWidth: 160.w, + height: 64.w, + child: Text( + '电话联系', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + ), + onPressed: () { + launch('tel:${widget.model.phone}'); + }, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.w), + side: BorderSide(color: AppStyle.primaryColor, width: 2.w), + ), + ), + AkuBox.w(24), + widget.model.borrowGoods.status == BORROW_STATUS.BORROWING + ? AkuMaterialButton( + minWidth: 160.w, + height: 64.w, + color: AppStyle.primaryColor, + radius: 4.w, + onPressed: () { + BotToast.showText(text: '已提醒用户'); + }, + child: Text( + '提醒归还', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.w, + ), + ), + ) + : SizedBox(), + widget.model.borrowGoods.status == BORROW_STATUS.WAIT_CHECK + ? AkuMaterialButton( + minWidth: 160.w, + height: 64.w, + color: AppStyle.primaryColor, + radius: 4.w, + onPressed: () { + Get.to(BorrowManagerCheckPage(model: widget.model)); + }, + child: Text( + '检查信息', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 28.w, + ), + ), + ) + : SizedBox(), + ], + ), + ]; + } + + _buildRow( + String assetPath, + String title, + String subTitle, { + Color color = AppStyle.primaryTextColor, + }) { + return Row( + children: [ + Image.asset( + assetPath, + height: 40.w, + width: 40.w, + ), + Text( + '$title\:', + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 28.w, + ), + ), + Text( + subTitle, + style: TextStyle( + color: color, + fontSize: 28.w, + ), + ), + ], + ); + } +} diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart new file mode 100644 index 0000000..4114a9c --- /dev/null +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart @@ -0,0 +1,170 @@ +import 'package:aku_community_manager/mock_models/borrow/borrow_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/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class BorrowManagerCheckPage extends StatefulWidget { + final BorrowModel model; + BorrowManagerCheckPage({Key key, @required this.model}) : super(key: key); + + @override + _BorrowManagerCheckPageState createState() => _BorrowManagerCheckPageState(); +} + +class _BorrowManagerCheckPageState extends State { + GOODS_STATUS borrowStatus = GOODS_STATUS.NORMAL; + @override + Widget build(BuildContext context) { + return AkuScaffold( + title: '检查物品', + bottom: AkuBottomButton( + title: '确认归还', + onTap: () { + widget.model.goodsStatus = borrowStatus; + widget.model.borrowGoods.status = BORROW_STATUS.DONE; + Get.back(); + }, + ), + body: ListView( + padding: EdgeInsets.symmetric(vertical: 16.w), + children: [ + Container( + color: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Column( + children: [ + _buildRow( + '物品名称', + Text( + widget.model.borrowGoods.name, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + ), + ), + Divider(height: 1.w), + _buildRow( + '物品单号', + Text( + widget.model.borrowGoods.code, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + ), + ), + Divider(height: 1.w), + _buildRow( + '归还数量', + Text( + '1', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + )), + Divider(height: 1.w), + _buildRow( + '物品情况', + Row( + children: [ + _buildCard(GOODS_STATUS.NORMAL), + AkuBox.w(24), + _buildCard(GOODS_STATUS.BROKEN), + AkuBox.w(24), + _buildCard(GOODS_STATUS.LOST), + ], + ), + ), + Divider(height: 1.w), + AkuBox.h(16), + _buildRow( + '物品图片', + (widget.model.borrowGoods.assetpath is String) + ? Image.asset( + widget.model.borrowGoods.assetpath, + height: 184.w, + width: 184.w, + fit: BoxFit.cover, + ) + : Image.file( + widget.model.borrowGoods.assetpath, + height: 184.w, + width: 184.w, + fit: BoxFit.cover, + ), + ), + AkuBox.h(28), + ], + ), + ), + ], + ), + ); + } + + _buildRow(String title, Widget child) { + return Row( + children: [ + AkuBox.h(96), + Text( + title, + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 28.w, + ), + ), + AkuBox.w(80), + Expanded( + child: Align( + alignment: Alignment.centerLeft, + child: child, + ), + ), + ], + ); + } + + _buildCard(GOODS_STATUS status) { + return GestureDetector( + onTap: () { + borrowStatus = status; + setState(() {}); + }, + child: Container( + height: 56.w, + width: 112.w, + child: Text( + { + GOODS_STATUS.NORMAL: '完好', + GOODS_STATUS.BROKEN: '损坏', + GOODS_STATUS.LOST: '丢失', + }[status], + style: TextStyle( + color: borrowStatus == status + ? AppStyle.secondaryColor + : AppStyle.minorTextColor, + fontSize: 28.sp, + ), + ), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + border: Border.all( + color: borrowStatus == status + ? AppStyle.secondaryColor + : AppStyle.minorTextColor, + width: 2.w, + ), + ), + ), + ); + } +} diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart index 59b5619..4d793bc 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart @@ -1,7 +1,10 @@ +import 'package:aku_community_manager/mock_models/borrow/borrow_data.dart'; +import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; import 'package:aku_community_manager/mock_models/users/user_info_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/ui/sub_pages/borrow_manager/all_borrow_goods.dart'; +import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_card.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; @@ -61,6 +64,36 @@ class _BorrowManagerPageState extends State ), ), ], + body: TabBarView( + controller: _tabController, + children: _getChildren(), + ), ); } + + List _getChildren() { + switch (role) { + case USER_ROLE.MANAGER: + return [ + getView(BorrowData.models), + getView(BorrowData.borrowModels), + getView(BorrowData.checkModels), + getView(BorrowData.doneModels), + ]; + break; + default: + return []; + } + } +} + +Widget getView(List models) { + return ListView.builder( + itemBuilder: (context, index) { + return BorrowManagerCard( + model: models[index], + ); + }, + itemCount: models.length, + ); } diff --git a/pubspec.lock b/pubspec.lock index d2f6c2f..887b13b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -172,6 +172,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" get: dependency: "direct main" description: @@ -338,6 +343,48 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0-nullsafety.3" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.7.10" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.0.1+4" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.0.1+9" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.9" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.5+1" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.0.1+3" vector_math: dependency: transitive description: @@ -347,4 +394,4 @@ packages: version: "2.1.0-nullsafety.3" sdks: dart: ">=2.10.0 <2.11.0" - flutter: ">=1.20.0 <2.0.0" + flutter: ">=1.22.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index c180439..1f7cbac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -56,6 +56,8 @@ dependencies: expandable: ^4.1.4 + url_launcher: ^5.7.10 + aku_ui: git: url: http://test.akuhotel.com:8099/aku_fe/aku_ui.git