diff --git a/lib/const/api.dart b/lib/const/api.dart index 4ebf479..d4f2886 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -69,5 +69,15 @@ class _Manage { ///借还管理:根据物品明细id 查询物品信息 String get borrowItemDetail => '/user/borrow/findById'; + ///借还管理:查询所有的借还信息(包含条件搜索) String get borrowStatusList => '/user/borrow/list'; + + ///借还管理:提醒归还(管理员发送) + String get remindUserReturn => '/user/borrow/remind'; + + ///借还管理:检查信息 + String get borrowCheckInfo => '/user/borrow/checkItems'; + + ///借还管理:提交检查结果 + String get borrowCheck => '/user/borrow/submitCheck'; } diff --git a/lib/models/manager/borrow/borrow_check_item_model.dart b/lib/models/manager/borrow/borrow_check_item_model.dart new file mode 100644 index 0000000..12fc6d1 --- /dev/null +++ b/lib/models/manager/borrow/borrow_check_item_model.dart @@ -0,0 +1,47 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; + +class BorrowCheckItemModel { + int id; + int articleDetailId; + String articleName; + String code; + int status; + List imgUrls; + ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first; + + BorrowCheckItemModel( + {this.id, + this.articleDetailId, + this.articleName, + this.code, + this.status, + this.imgUrls}); + + BorrowCheckItemModel.fromJson(Map json) { + id = json['id']; + articleDetailId = json['articleDetailId']; + articleName = json['articleName']; + code = json['code']; + status = json['status']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['articleDetailId'] = this.articleDetailId; + data['articleName'] = this.articleName; + data['code'] = this.code; + data['status'] = this.status; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart index 4e07b88..06694c3 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_card.dart @@ -1,12 +1,15 @@ // Flutter imports: import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/models/manager/borrow/borrow_status_item_model.dart'; +import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:flutter/material.dart'; // Package imports: 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:get/get.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -142,8 +145,21 @@ class _BorrowManagerCardState extends State { height: 64.w, color: AppStyle.primaryColor, radius: 4.w, - onPressed: () { - BotToast.showText(text: '已提醒用户'); + onPressed: () async { + //TODO unknown param `butlerMessage` + Function cancel = BotToast.showLoading(); + await NetUtil().post( + API.manage.remindUserReturn, + params: { + 'borrowId': widget.model.id, + 'butlerMessage': { + 'title': '', + 'content': '', + }, + }, + showMessage: true, + ); + cancel(); }, child: Text( '提醒归还', @@ -161,9 +177,8 @@ class _BorrowManagerCardState extends State { height: 64.w, color: AppStyle.primaryColor, radius: 4.w, - onPressed: () { - //TODO - // Get.to(BorrowManagerCheckPage(model: widget.model)); + onPressed: () async { + await Get.to(BorrowManagerCheckPage(id: widget.model.id)); }, child: Text( '检查信息', 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 index 2b71b3d..da96e8c 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_check_page.dart @@ -1,5 +1,11 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/borrow/borrow_check_item_model.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; // Package imports: import 'package:get/get.dart'; @@ -12,105 +18,126 @@ import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.dart'; class BorrowManagerCheckPage extends StatefulWidget { - final BorrowModel model; - BorrowManagerCheckPage({Key key, @required this.model}) : super(key: key); + final int id; + BorrowManagerCheckPage({Key key, @required this.id}) : super(key: key); @override _BorrowManagerCheckPageState createState() => _BorrowManagerCheckPageState(); } class _BorrowManagerCheckPageState extends State { - GOODS_STATUS borrowStatus = GOODS_STATUS.NORMAL; + int borrowStatus = 1; + BorrowCheckItemModel _model; @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(); + onTap: () async { + Function cancel = BotToast.showLoading(); + await NetUtil().post( + API.manage.borrowCheck, + params: { + 'articleBorrowId': widget.id, + 'articleStatus': borrowStatus, + }, + showMessage: true, + ); + cancel(); + Get.back(result: true); }, ), - 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, + body: EasyRefresh( + firstRefresh: true, + onRefresh: () async { + BaseModel model = await NetUtil().get( + API.manage.borrowCheckInfo, + params: {'articleBorrowId': widget.id}, + showMessage: true, + ); + if (model.data == null) { + // Get.back(); + return; + } + _model = BorrowCheckItemModel.fromJson(model.data); + setState(() {}); + }, + header: MaterialHeader(), + child: _model == null + ? SizedBox() + : ListView( + padding: EdgeInsets.symmetric(vertical: 16.w), + children: [ + Container( + color: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Column( + children: [ + _buildRow( + '物品名称', + Text( + _model.articleName, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + ), + ), + Divider(height: 1.w), + _buildRow( + '物品单号', + Text( + _model.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(1), + AkuBox.w(24), + _buildCard(2), + AkuBox.w(24), + _buildCard(3), + ], + ), + ), + Divider(height: 1.w), + AkuBox.h(16), + _buildRow( + '物品图片', + FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(_model.firstImg?.url ?? ''), + height: 184.w, + width: 184.w, + ), + ), + AkuBox.h(28), + ], ), ), - ), - 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), - ], - ), - ), - ], + ], + ), ), ); } @@ -137,7 +164,7 @@ class _BorrowManagerCheckPageState extends State { ); } - _buildCard(GOODS_STATUS status) { + _buildCard(int status) { return GestureDetector( onTap: () { borrowStatus = status; @@ -148,9 +175,9 @@ class _BorrowManagerCheckPageState extends State { width: 112.w, child: Text( { - GOODS_STATUS.NORMAL: '完好', - GOODS_STATUS.BROKEN: '损坏', - GOODS_STATUS.LOST: '丢失', + 1: '完好', + 2: '损坏', + 3: '丢失', }[status], style: TextStyle( color: borrowStatus == status diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index b4b96d6..83cccc5 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -37,7 +37,6 @@ class NetUtil { onRequest: (RequestOptions options) async => options, onResponse: (Response response) async { LoggerData.addData(response); - print(response.headers); return response; }, onError: (DioError error) async { diff --git a/pubspec.lock b/pubspec.lock index 3b500c3..c5d6955 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -192,6 +192,20 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.3.5" + device_info: + dependency: transitive + description: + name: device_info + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" + device_info_platform_interface: + dependency: transitive + description: + name: device_info_platform_interface + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.1" dio: dependency: "direct main" description: @@ -464,6 +478,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.9.3" + package_info: + dependency: transitive + description: + name: package_info + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.4.3+4" path: dependency: transitive description: @@ -554,7 +575,7 @@ packages: name: power_logger url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.0" + version: "0.1.1" pretty_json: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9152a80..92a1dfb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,7 +51,7 @@ dependencies: dio: - power_logger: ^0.1.0 + power_logger: ^0.1.1 logger: ^0.9.4 aku_ui: git: