对接借还管理的全部物品子列表接口

hmxc
小赖 4 years ago
parent 459ce0f13b
commit c54b390609

@ -62,4 +62,7 @@ class _Manage {
/// ///
String get borrowList => '/user/borrow/articleList'; String get borrowList => '/user/borrow/articleList';
///id
String get borrowDetailList => '/user/borrow/articleDetailList';
} }

@ -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<ImgModel> imgUrls;
ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first;
BorrowDetailItemModel(
{this.id, this.name, this.code, this.borrowStatus, this.imgUrls});
BorrowDetailItemModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
code = json['code'];
borrowStatus = json['borrowStatus'];
if (json['imgUrls'] != null) {
imgUrls = new List<ImgModel>();
json['imgUrls'].forEach((v) {
imgUrls.add(new ImgModel.fromJson(v));
});
} else
imgUrls = [];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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;
}
}

@ -73,7 +73,7 @@ class _AllBorrowGoodsState extends State<AllBorrowGoods> {
_buildCard(BorrowItemModel object) { _buildCard(BorrowItemModel object) {
return GestureDetector( return GestureDetector(
// onTap: () => Get.to(BorrowItemPage(object: object)), onTap: () => Get.to(BorrowItemPage(id: object.id)),
child: Container( child: Container(
padding: EdgeInsets.all(24.w), padding: EdgeInsets.all(24.w),
margin: EdgeInsets.only(top: 16.w), margin: EdgeInsets.only(top: 16.w),

@ -1,9 +1,13 @@
// Flutter imports: // 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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.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'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
class BorrowItemPage extends StatefulWidget { class BorrowItemPage extends StatefulWidget {
final BorrowObject object; final int id;
BorrowItemPage({Key key, @required this.object}) : super(key: key); BorrowItemPage({Key key, @required this.id}) : super(key: key);
@override @override
_BorrowItemPageState createState() => _BorrowItemPageState(); _BorrowItemPageState createState() => _BorrowItemPageState();
} }
class _BorrowItemPageState extends State<BorrowItemPage> { class _BorrowItemPageState extends State<BorrowItemPage> {
EasyRefreshController _refreshController = EasyRefreshController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context); final userProvider = Provider.of<UserProvider>(context);
@ -36,7 +41,7 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
? AkuMaterialButton( ? AkuMaterialButton(
minWidth: 120.w, minWidth: 120.w,
onPressed: () { onPressed: () {
Get.to(AddBorrowItemPage(object: widget.object)); // Get.to(AddBorrowItemPage(object: widget.object));
}, },
child: Text( child: Text(
'新增', '新增',
@ -48,21 +53,31 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
) )
: SizedBox(), : SizedBox(),
], ],
body: ListView.builder( body: BeeListView(
padding: EdgeInsets.symmetric(horizontal: 32.w), path: API.manage.borrowDetailList,
itemBuilder: (context, index) { controller: _refreshController,
return _buildCard(widget.object.items[index]); 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<UserProvider>(context); final userProvider = Provider.of<UserProvider>(context);
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
Get.to(BorrowItemDetailPage(item: item)); // Get.to(BorrowItemDetailPage(item: item));
}, },
child: Container( child: Container(
margin: EdgeInsets.only(top: 16.w), margin: EdgeInsets.only(top: 16.w),
@ -101,7 +116,7 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
CupertinoDialogAction( CupertinoDialogAction(
child: Text('删除'), child: Text('删除'),
onPressed: () { onPressed: () {
widget.object.items.remove(item); //TODO delete
setState(() {}); setState(() {});
Get.back(); Get.back();
}, },
@ -141,19 +156,12 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
AkuBox.w(24), AkuBox.w(24),
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(4.w), borderRadius: BorderRadius.circular(4.w),
child: (item.assetpath is String) child: FadeInImage.assetNetwork(
? Image.asset( placeholder: R.ASSETS_PLACEHOLDER_WEBP,
item.assetpath, image: API.image(item.firstImg?.url ?? ''),
height: 184.w, height: 184.w,
width: 184.w, width: 184.w,
fit: BoxFit.cover, ),
)
: Image.file(
item.assetpath,
height: 184.w,
width: 184.w,
fit: BoxFit.cover,
),
), ),
AkuBox.w(24), AkuBox.w(24),
Expanded( Expanded(

Loading…
Cancel
Save