借还管理状态列表 接口对接

hmxc
小赖 4 years ago
parent d32bba3521
commit 8cbfebae61

@ -68,4 +68,6 @@ class _Manage {
///id
String get borrowItemDetail => '/user/borrow/findById';
String get borrowStatusList => '/user/borrow/list';
}

@ -0,0 +1,119 @@
import 'package:aku_community_manager/models/common/img_model.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
class BorrowStatusItemModel {
int id;
int articleDetailId;
String articleName;
///1.2.3.
int borrowStatus;
///1.2.3.
int status;
int borrowTime;
String beginDate;
String endDate;
String borrowName;
String borrowTel;
String createDate;
List<ImgModel> imgUrls;
ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first;
DateTime get create => DateUtil.getDateTime(createDate);
DateTime get begin => DateUtil.getDateTime(beginDate);
DateTime get end => DateUtil.getDateTime(endDate);
///1.2.3.
String get borrowStatusValue {
switch (borrowStatus) {
case 1:
return '出借中';
case 2:
return '已还';
case 3:
return '待检查';
default:
return '未知';
}
}
///1.2.3.
String get statusValue {
switch (status) {
case 1:
return '正常';
case 2:
return '损坏';
case 3:
return '丢失';
default:
return '未知';
}
}
///1.2.3.
Color get statusColor {
switch (status) {
case 1:
return AppStyle.primaryTextColor;
default:
return AppStyle.failColor;
}
}
BorrowStatusItemModel(
{this.id,
this.articleDetailId,
this.articleName,
this.borrowStatus,
this.status,
this.borrowTime,
this.beginDate,
this.endDate,
this.borrowName,
this.borrowTel,
this.createDate,
this.imgUrls});
BorrowStatusItemModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
articleDetailId = json['articleDetailId'];
articleName = json['articleName'];
borrowStatus = json['borrowStatus'];
status = json['status'];
borrowTime = json['borrowTime'];
beginDate = json['beginDate'];
endDate = json['endDate'];
borrowName = json['borrowName'];
borrowTel = json['borrowTel'];
createDate = json['createDate'];
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['articleDetailId'] = this.articleDetailId;
data['articleName'] = this.articleName;
data['borrowStatus'] = this.borrowStatus;
data['status'] = this.status;
data['borrowTime'] = this.borrowTime;
data['beginDate'] = this.beginDate;
data['endDate'] = this.endDate;
data['borrowName'] = this.borrowName;
data['borrowTel'] = this.borrowTel;
data['createDate'] = this.createDate;
if (this.imgUrls != null) {
data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList();
}
return data;
}
}

@ -1,25 +1,23 @@
// 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: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';
// Project imports:
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';
class BorrowManagerCard extends StatefulWidget {
final BorrowModel model;
final BorrowStatusItemModel model;
BorrowManagerCard({Key key, this.model}) : super(key: key);
@override
@ -46,12 +44,12 @@ class _BorrowManagerCardState extends State<BorrowManagerCard> {
AkuChipBox(title: '借还管理'),
AkuBox.w(24),
Text(
DateUtil.formatDate(widget.model.date),
DateUtil.formatDate(widget.model.create),
style: TextStyle(),
),
Spacer(),
Text(
widget.model.borrowGoods.borrowValue,
widget.model.borrowStatusValue,
style: TextStyle(
color: AppStyle.failColor,
fontWeight: FontWeight.bold,
@ -62,7 +60,7 @@ class _BorrowManagerCardState extends State<BorrowManagerCard> {
),
AkuBox.h(24),
Text(
widget.model.title,
widget.model.articleName,
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 32.sp,
@ -73,40 +71,27 @@ class _BorrowManagerCardState extends State<BorrowManagerCard> {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(widget.model.borrowGoods.assetpath is String)
? Image.asset(
widget.model.borrowGoods.assetpath,
FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(widget.model.firstImg?.url ?? ''),
height: 184.w,
width: 183.w,
fit: BoxFit.cover,
)
: Image.file(
widget.model.borrowGoods.assetpath,
height: 184.w,
width: 183.w,
fit: BoxFit.cover,
width: 184.w,
),
AkuBox.w(24),
Expanded(
child: Column(
children: [
_buildRow(R.ASSETS_MESSAGE_IC_PEOPLE_PNG, '借用人员',
widget.model.borrowPerson),
widget.model.borrowName),
_buildRow(R.ASSETS_MESSAGE_IC_PHONE_PNG, '联系电话',
widget.model.phone),
widget.model.borrowTel),
_buildRow(R.ASSETS_MANAGE_IC_TIME_PNG, '借用时常',
'${widget.model.borrowTime}'),
'${(widget.model.borrowTime / 24).toStringAsFixed(0)}'),
_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,
widget.model.statusValue,
color: widget.model.statusColor,
),
],
),
@ -120,9 +105,10 @@ class _BorrowManagerCardState extends State<BorrowManagerCard> {
}
List<Widget> _buildCard() {
if (role != USER_ROLE.MANAGER)
final userProvider = Provider.of<UserProvider>(context);
if (!userProvider.infoModel.canOperation)
return [];
else if (widget.model.borrowGoods.status == BORROW_STATUS.DONE) {
else if (widget.model.borrowStatus == 2) {
return [];
} else
return [
@ -142,7 +128,7 @@ class _BorrowManagerCardState extends State<BorrowManagerCard> {
),
),
onPressed: () {
launch('tel:${widget.model.phone}');
launch('tel:${widget.model.borrowTel}');
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.w),
@ -150,7 +136,7 @@ class _BorrowManagerCardState extends State<BorrowManagerCard> {
),
),
AkuBox.w(24),
widget.model.borrowGoods.status == BORROW_STATUS.BORROWING
widget.model.borrowStatus == 1
? AkuMaterialButton(
minWidth: 160.w,
height: 64.w,
@ -169,14 +155,15 @@ class _BorrowManagerCardState extends State<BorrowManagerCard> {
),
)
: SizedBox(),
widget.model.borrowGoods.status == BORROW_STATUS.WAIT_CHECK
widget.model.borrowStatus == 3
? AkuMaterialButton(
minWidth: 160.w,
height: 64.w,
color: AppStyle.primaryColor,
radius: 4.w,
onPressed: () {
Get.to(BorrowManagerCheckPage(model: widget.model));
//TODO
// Get.to(BorrowManagerCheckPage(model: widget.model));
},
child: Text(
'检查信息',

@ -1,4 +1,5 @@
// Flutter imports:
import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_view.dart';
import 'package:flutter/material.dart';
// Package imports:
@ -30,12 +31,13 @@ class _BorrowManagerPageState extends State<BorrowManagerPage>
Provider.of<UserProvider>(context, listen: false).userInfoModel.role;
TabController _tabController;
List<String> get _tabs {
switch (role) {
case USER_ROLE.MANAGER:
return ['全部', '出借中', '待检查', '已归还'];
default:
return ['全部', '出借中', '已归还'];
}
final userProvider = Provider.of<UserProvider>(context, listen: false);
return [
'全部',
'出借中',
...userProvider.infoModel.canOperation ? ['待检查'] : [],
'已归还'
];
}
@override
@ -77,32 +79,14 @@ class _BorrowManagerPageState extends State<BorrowManagerPage>
}
List<Widget> _getChildren() {
switch (role) {
case USER_ROLE.MANAGER:
final userProvider = Provider.of<UserProvider>(context);
return [
getView(BorrowData.models),
getView(BorrowData.borrowModels),
getView(BorrowData.checkModels),
getView(BorrowData.doneModels),
BorrowManagerView(),
BorrowManagerView(status: 1),
...userProvider.infoModel.canOperation
? [BorrowManagerView(status: 3)]
: [],
BorrowManagerView(status: 2),
];
break;
default:
return [
getView(BorrowData.models),
getView(BorrowData.borrowModels),
getView(BorrowData.doneModels),
];
}
}
}
Widget getView(List<BorrowModel> models) {
return ListView.builder(
itemBuilder: (context, index) {
return BorrowManagerCard(
model: models[index],
);
},
itemCount: models.length,
);
}

@ -0,0 +1,42 @@
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_card.dart';
import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
class BorrowManagerView extends StatefulWidget {
final int status;
BorrowManagerView({Key key, this.status}) : super(key: key);
@override
_BorrowManagerViewState createState() => _BorrowManagerViewState();
}
class _BorrowManagerViewState extends State<BorrowManagerView>
with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController();
@override
Widget build(BuildContext context) {
super.build(context);
return BeeListView(
path: API.manage.borrowStatusList,
extraParams: {'borrowStatus': widget.status},
controller: _refreshController,
convert: (model) => model.tableList
.map((e) => BorrowStatusItemModel.fromJson(e))
.toList(),
builder: (items) {
return ListView.builder(
itemBuilder: (context, index) {
return BorrowManagerCard(model: items[index]);
},
itemCount: items.length,
);
},
);
}
@override
bool get wantKeepAlive => true;
}
Loading…
Cancel
Save