diff --git a/assets/manage/info.png b/assets/manage/info.png new file mode 100644 index 0000000..fad8ff9 Binary files /dev/null and b/assets/manage/info.png differ 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