diff --git a/lib/const/api.dart b/lib/const/api.dart index e88201a..7c787fc 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -62,4 +62,7 @@ class _Manage { ///借还管理:查询全部物品 String get borrowList => '/user/borrow/articleList'; + + ///借还管理:根据物品主键id查询所有的物品明细信息 + String get borrowDetailList => '/user/borrow/articleDetailList'; } diff --git a/lib/models/manager/borrow/borrow_detail_item_model.dart b/lib/models/manager/borrow/borrow_detail_item_model.dart new file mode 100644 index 0000000..892b40e --- /dev/null +++ b/lib/models/manager/borrow/borrow_detail_item_model.dart @@ -0,0 +1,39 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; + +class BorrowDetailItemModel { + int id; + String name; + String code; + int borrowStatus; + List imgUrls; + ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first; + + BorrowDetailItemModel( + {this.id, this.name, this.code, this.borrowStatus, this.imgUrls}); + + BorrowDetailItemModel.fromJson(Map json) { + id = json['id']; + name = json['name']; + code = json['code']; + borrowStatus = json['borrowStatus']; + 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['name'] = this.name; + data['code'] = this.code; + data['borrowStatus'] = this.borrowStatus; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart b/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart index f5f135d..f03d578 100644 --- a/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart +++ b/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart @@ -73,7 +73,7 @@ class _AllBorrowGoodsState extends State { _buildCard(BorrowItemModel object) { return GestureDetector( - // onTap: () => Get.to(BorrowItemPage(object: object)), + onTap: () => Get.to(BorrowItemPage(id: object.id)), child: Container( padding: EdgeInsets.all(24.w), margin: EdgeInsets.only(top: 16.w), diff --git a/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart index 17569d4..ea0cc8b 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart @@ -1,9 +1,13 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/borrow/borrow_detail_item_model.dart'; +import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; @@ -18,14 +22,15 @@ import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_item_de import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; class BorrowItemPage extends StatefulWidget { - final BorrowObject object; - BorrowItemPage({Key key, @required this.object}) : super(key: key); + final int id; + BorrowItemPage({Key key, @required this.id}) : super(key: key); @override _BorrowItemPageState createState() => _BorrowItemPageState(); } class _BorrowItemPageState extends State { + EasyRefreshController _refreshController = EasyRefreshController(); @override Widget build(BuildContext context) { final userProvider = Provider.of(context); @@ -36,7 +41,7 @@ class _BorrowItemPageState extends State { ? AkuMaterialButton( minWidth: 120.w, onPressed: () { - Get.to(AddBorrowItemPage(object: widget.object)); + // Get.to(AddBorrowItemPage(object: widget.object)); }, child: Text( '新增', @@ -48,21 +53,31 @@ class _BorrowItemPageState extends State { ) : SizedBox(), ], - body: ListView.builder( - padding: EdgeInsets.symmetric(horizontal: 32.w), - itemBuilder: (context, index) { - return _buildCard(widget.object.items[index]); + body: BeeListView( + path: API.manage.borrowDetailList, + controller: _refreshController, + extraParams: {'articleId': widget.id}, + convert: (model) => model.tableList + .map((e) => BorrowDetailItemModel.fromJson(e)) + .toList(), + builder: (items) { + return ListView.builder( + padding: EdgeInsets.symmetric(horizontal: 32.w), + itemBuilder: (context, index) { + return _buildCard(items[index]); + }, + itemCount: items.length, + ); }, - itemCount: widget.object.items.length, ), ); } - _buildCard(SingleBorrowGoods item) { + _buildCard(BorrowDetailItemModel item) { final userProvider = Provider.of(context); return GestureDetector( onTap: () { - Get.to(BorrowItemDetailPage(item: item)); + // Get.to(BorrowItemDetailPage(item: item)); }, child: Container( margin: EdgeInsets.only(top: 16.w), @@ -101,7 +116,7 @@ class _BorrowItemPageState extends State { CupertinoDialogAction( child: Text('删除'), onPressed: () { - widget.object.items.remove(item); + //TODO delete setState(() {}); Get.back(); }, @@ -141,19 +156,12 @@ class _BorrowItemPageState extends State { AkuBox.w(24), ClipRRect( borderRadius: BorderRadius.circular(4.w), - child: (item.assetpath is String) - ? Image.asset( - item.assetpath, - height: 184.w, - width: 184.w, - fit: BoxFit.cover, - ) - : Image.file( - item.assetpath, - height: 184.w, - width: 184.w, - fit: BoxFit.cover, - ), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_PLACEHOLDER_WEBP, + image: API.image(item.firstImg?.url ?? ''), + height: 184.w, + width: 184.w, + ), ), AkuBox.w(24), Expanded(