对接访客管理接口

hmxc
小赖 4 years ago
parent c2829ca922
commit f7250cfae3

@ -47,4 +47,7 @@ class _Manage {
///app id ///app id
String get activityDetail => '/user/activity/findById'; String get activityDetail => '/user/activity/findById';
///访app访
String get visitorList => '/user/visitor/list';
} }

@ -0,0 +1,50 @@
import 'package:common_utils/common_utils.dart';
class VisitorItemModel {
int id;
String roomName;
String name;
int isDrive;
String carNum;
String effectiveTime;
String visitDate;
int visitorStatus;
DateTime get effective => DateUtil.getDateTime(effectiveTime);
DateTime get visit =>
visitDate == null ? null : DateUtil.getDateTime(visitDate);
VisitorItemModel(
{this.id,
this.roomName,
this.name,
this.isDrive,
this.carNum,
this.effectiveTime,
this.visitDate,
this.visitorStatus});
VisitorItemModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
roomName = json['roomName'];
name = json['name'];
isDrive = json['isDrive'];
carNum = json['carNum'];
effectiveTime = json['effectiveTime'];
visitDate = json['visitDate'];
visitorStatus = json['visitorStatus'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['roomName'] = this.roomName;
data['name'] = this.name;
data['isDrive'] = this.isDrive;
data['carNum'] = this.carNum;
data['effectiveTime'] = this.effectiveTime;
data['visitDate'] = this.visitDate;
data['visitorStatus'] = this.visitorStatus;
return data;
}
}

@ -2,6 +2,8 @@
import 'dart:math'; import 'dart:math';
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/models/manager/visitor_item_model.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -14,19 +16,8 @@ import 'package:aku_community_manager/tools/widget_tool.dart';
import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart'; import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart';
class VisitorManagerCard extends StatefulWidget { class VisitorManagerCard extends StatefulWidget {
final String adress; final VisitorItemModel model;
final String name; VisitorManagerCard({Key key, @required this.model}) : super(key: key);
final String plate;
final String time;
final VisitorStatus status;
VisitorManagerCard(
{Key key,
@required this.adress,
@required this.name,
this.plate,
this.time,
@required this.status})
: super(key: key);
@override @override
_VisitorManagerCardState createState() => _VisitorManagerCardState(); _VisitorManagerCardState createState() => _VisitorManagerCardState();
@ -37,19 +28,47 @@ class _VisitorManagerCardState extends State<VisitorManagerCard> {
color: AppStyle.primaryTextColor, color: AppStyle.primaryTextColor,
fontSize: 28.sp, fontSize: 28.sp,
); );
String _adress;
String _name; String get _time {
String _plate; if (widget.model.visit == null)
String _time; return '无信息';
VisitorStatus _status; else
@override return DateUtil.formatDate(
void initState() { widget.model.visit,
super.initState(); format: 'yyyy-MM-dd HH:mm',
_adress = widget.adress; );
_name = widget.name; }
_plate = widget.plate ?? '无信息';
_time = widget.time ?? '无信息'; // String get _visitorStatus {
_status = widget.status; // switch (widget.model.visitorStatus) {
// case 1:
// if (widget.model.effective.difference(DateTime.now()).isNegative)
// return '已过期';
// return '未到';
// case 2:
// return '已到';
// case 3:
// return '已过期';
// case 4:
// return '作废';
// default:
// return '未知';
// }
// }
VisitorStatus get _visitorStatusEnum {
switch (widget.model.visitorStatus) {
case 1:
if (widget.model.effective.difference(DateTime.now()).isNegative)
return VisitorStatus.OUTDATE;
return VisitorStatus.NOT_VISIT;
case 2:
return VisitorStatus.VISIT_DONE;
case 3:
return VisitorStatus.OUTDATE;
default:
return null;
}
} }
@override @override
@ -68,7 +87,7 @@ class _VisitorManagerCardState extends State<VisitorManagerCard> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
_adress, widget.model.roomName,
style: TextStyle( style: TextStyle(
color: AppStyle.primaryTextColor, color: AppStyle.primaryTextColor,
fontSize: 32.sp, fontSize: 32.sp,
@ -84,7 +103,7 @@ class _VisitorManagerCardState extends State<VisitorManagerCard> {
), ),
AkuBox.w(8), AkuBox.w(8),
Text( Text(
'$_name先生', widget.model.name,
style: _textStyle, style: _textStyle,
), ),
AkuBox.w(137), AkuBox.w(137),
@ -95,7 +114,7 @@ class _VisitorManagerCardState extends State<VisitorManagerCard> {
), ),
AkuBox.w(8), AkuBox.w(8),
Text( Text(
_plate, widget.model.carNum ?? '无信息',
style: _textStyle, style: _textStyle,
), ),
Spacer(), Spacer(),
@ -122,7 +141,7 @@ class _VisitorManagerCardState extends State<VisitorManagerCard> {
child: Transform.rotate( child: Transform.rotate(
angle: pi / 4, angle: pi / 4,
child: Image.asset( child: Image.asset(
_statusImage(_status), _statusImage(_visitorStatusEnum),
width: 140.w, width: 140.w,
height: 140.w, height: 140.w,
), ),

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -78,43 +79,12 @@ class _VisitorManagerPageState extends State<VisitorManagerPage>
preferredSize: Size.fromHeight(88.w)), preferredSize: Size.fromHeight(88.w)),
body: TabBarView( body: TabBarView(
controller: _tabController, controller: _tabController,
children: _tabs.map((e) => _buildListView(_tabs.indexOf(e))).toList(), children: [
VisitorManagerView(status: null),
VisitorManagerView(status: 1),
VisitorManagerView(status: 2),
VisitorManagerView(status: 3),
],
)); ));
} }
Widget _buildListView(int index) {
List<VisitorCardsModel> _selectCards;
switch (index) {
case 0:
_selectCards = _cards;
break;
case 1:
_selectCards = _cards
.where((element) => element.status == VisitorStatus.NOT_VISIT)
.toList();
break;
case 2:
_selectCards = _cards
.where((element) => element.status == VisitorStatus.VISIT_DONE)
.toList();
break;
case 3:
_selectCards = _cards
.where((element) => element.status == VisitorStatus.OUTDATE)
.toList();
break;
}
return ListView(
padding: EdgeInsets.only(left: 32.w, right: 32.w),
children: _selectCards
.map((e) => VisitorManagerCard(
adress: e.adress,
name: e.name,
plate: e.plate,
time: e.time,
status: e.status,
))
.toList(),
);
}
} }

@ -0,0 +1,46 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/visitor_item_model.dart';
import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_card.dart';
import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.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 VisitorManagerView extends StatefulWidget {
final int status;
VisitorManagerView({Key key, @required this.status}) : super(key: key);
@override
_VisitorManagerViewState createState() => _VisitorManagerViewState();
}
class _VisitorManagerViewState extends State<VisitorManagerView>
with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController();
@override
Widget build(BuildContext context) {
super.build(context);
return BeeListView(
path: API.manage.visitorList,
controller: _refreshController,
convert: (model) {
return model.tableList
.map((e) => VisitorItemModel.fromJson(e))
.toList();
},
extraParams: {'visitorStatus': widget.status},
builder: (items) {
return ListView.builder(
itemBuilder: (context, index) {
final VisitorItemModel item = items[index];
return VisitorManagerCard(model: item);
},
itemCount: items.length,
);
},
);
}
@override
bool get wantKeepAlive => true;
}
Loading…
Cancel
Save