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

hmxc
小赖 4 years ago
parent fdf33b205b
commit 459ce0f13b

@ -42,7 +42,6 @@ class _User {
///
String get updateTel => '/user/personalData/updateTel';
}
class _Manage {
@ -60,4 +59,7 @@ class _Manage {
///()
String get repairList => '/user/repair/list';
///
String get borrowList => '/user/borrow/articleList';
}

@ -2,6 +2,8 @@
import 'package:aku_community_manager/const/resource.dart';
import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart';
//TODO CLEAN BOTTOM CODES.
@Deprecated("borrow_data need to be cleaned.")
class BorrowData {
static List<BorrowModel> get checkModels => models.where((e) {
return e.borrowGoods.status == BORROW_STATUS.WAIT_CHECK;

@ -24,6 +24,8 @@ enum GOODS_STATUS {
LOST,
}
//TODO CLEAN BOTTOM CODES.
@Deprecated(" borrow_model need to be cleaned.")
class BorrowModel {
String borrowPerson;
String phone;

@ -0,0 +1,48 @@
import 'package:aku_community_manager/models/common/img_model.dart';
class BorrowItemModel {
int id;
String name;
int borrowNum;
int remainingNum;
int quantity;
List<ImgModel> imgUrls;
ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first;
BorrowItemModel(
{this.id,
this.name,
this.borrowNum,
this.remainingNum,
this.quantity,
this.imgUrls});
BorrowItemModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
borrowNum = json['borrowNum'];
remainingNum = json['remainingNum'];
quantity = json['quantity'];
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['borrowNum'] = this.borrowNum;
data['remainingNum'] = this.remainingNum;
data['quantity'] = this.quantity;
if (this.imgUrls != null) {
data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList();
}
return data;
}
}

@ -1,15 +1,17 @@
// Flutter imports:
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/borrow/borrow_item_model.dart';
import 'package:aku_community_manager/ui/widgets/common/bee_list_view.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';
// Project imports:
import 'package:aku_community_manager/const/resource.dart';
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';
@ -26,6 +28,7 @@ class AllBorrowGoods extends StatefulWidget {
}
class _AllBorrowGoodsState extends State<AllBorrowGoods> {
EasyRefreshController _refreshController = EasyRefreshController();
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
@ -48,21 +51,29 @@ class _AllBorrowGoodsState extends State<AllBorrowGoods> {
)
: SizedBox(),
],
body: ListView.builder(
body: BeeListView(
path: API.manage.borrowList,
controller: _refreshController,
convert: (model) =>
model.tableList.map((e) => BorrowItemModel.fromJson(e)).toList(),
builder: (items) {
return ListView.builder(
padding: EdgeInsets.symmetric(
horizontal: 32.w,
),
itemBuilder: (context, index) {
return _buildCard(BorrowData.borrowObjects[index]);
return _buildCard(items[index]);
},
itemCount: items.length,
);
},
itemCount: BorrowData.borrowObjects.length,
),
);
}
_buildCard(BorrowObject object) {
_buildCard(BorrowItemModel object) {
return GestureDetector(
onTap: () => Get.to(BorrowItemPage(object: object)),
// onTap: () => Get.to(BorrowItemPage(object: object)),
child: Container(
padding: EdgeInsets.all(24.w),
margin: EdgeInsets.only(top: 16.w),
@ -70,18 +81,11 @@ class _AllBorrowGoodsState extends State<AllBorrowGoods> {
children: [
ClipRRect(
borderRadius: BorderRadius.circular(4.w),
child: (object.assetPath is String)
? Image.asset(
object.assetPath,
width: 184.w,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(object.firstImg?.url ?? ''),
height: 184.w,
fit: BoxFit.cover,
)
: Image.file(
object.assetPath,
width: 184.w,
height: 184.w,
fit: BoxFit.cover,
),
),
AkuBox.w(24),
@ -91,10 +95,10 @@ class _AllBorrowGoodsState extends State<AllBorrowGoods> {
_buildRow(R.ASSETS_MANAGE_ARTICLE_PNG, '物品名称', object.name),
AkuBox.h(12),
_buildRow(R.ASSETS_MANAGE_BORROW_PNG, '借出数量',
object.borrowNumber.toString()),
object.borrowNum.toString()),
AkuBox.h(12),
_buildRow(R.ASSETS_MANAGE_REMAINING_PNG, '剩余数量',
object.items.length.toString()),
object.remainingNum.toString()),
],
)),
],

Loading…
Cancel
Save