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

hmxc
小赖 4 years ago
parent d32bba3521
commit 8cbfebae61

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

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