fix提测问题: 卡/密码/指纹 列表超过 20 条删除单条后下拉卡顿问题
This commit is contained in:
parent
1d5c745454
commit
778fcffe1d
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
@ -27,10 +26,11 @@ class CardListLogic extends BaseGetXController {
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
|
||||
if ((reply is SenderAddICCardWithTimeCycleCoercionReply) &&
|
||||
(state.ifCurrentScreen.value == true)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
});
|
||||
@ -40,7 +40,7 @@ class CardListLogic extends BaseGetXController {
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
final int status = reply.data[2];
|
||||
|
||||
switch(status){
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
cancelBlueConnetctToastTimer();
|
||||
@ -48,10 +48,13 @@ class CardListLogic extends BaseGetXController {
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<int> token = reply.data.sublist(5, 9);
|
||||
@ -59,25 +62,24 @@ class CardListLogic extends BaseGetXController {
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:(await Storage.getUid())!,
|
||||
cardNo:state.deletCardNo,
|
||||
useCountLimit:0xffff,
|
||||
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
||||
isAdmin:0,
|
||||
isForce:0, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:0, // 周循环
|
||||
startDate: 0x11223344,
|
||||
endDate: 0x11223344,
|
||||
startTime:'0',
|
||||
endTime:'0',
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
isBeforeAddUser: false
|
||||
);
|
||||
keyID: state.deletKeyID,
|
||||
userID: (await Storage.getUid())!,
|
||||
cardNo: state.deletCardNo,
|
||||
useCountLimit: 0xffff,
|
||||
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
||||
isAdmin: 0,
|
||||
isForce: 0, // 是否是胁迫
|
||||
isRound: 0, // 是否是循环
|
||||
weekRound: 0, // 周循环
|
||||
startDate: 0x11223344,
|
||||
endDate: 0x11223344,
|
||||
startTime: '0',
|
||||
endTime: '0',
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token,
|
||||
isBeforeAddUser: false);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
@ -88,44 +90,48 @@ class CardListLogic extends BaseGetXController {
|
||||
// 删除卡片
|
||||
Future<void> senderAddICCard() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:(await Storage.getUid())!,
|
||||
cardNo:state.deletCardNo,
|
||||
useCountLimit:0xffff,
|
||||
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
||||
isAdmin:0,
|
||||
isForce:0, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:0, // 周循环
|
||||
startDate: 0x11223344,
|
||||
endDate: 0x11223344,
|
||||
startTime:'0',
|
||||
endTime:'0',
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
isBeforeAddUser: false
|
||||
);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
keyID: state.deletKeyID,
|
||||
userID: (await Storage.getUid())!,
|
||||
cardNo: state.deletCardNo,
|
||||
useCountLimit: 0xffff,
|
||||
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
||||
isAdmin: 0,
|
||||
isForce: 0, // 是否是胁迫
|
||||
isRound: 0, // 是否是循环
|
||||
weekRound: 0, // 周循环
|
||||
startDate: 0x11223344,
|
||||
endDate: 0x11223344,
|
||||
startTime: '0',
|
||||
endTime: '0',
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
isBeforeAddUser: false);
|
||||
} else if (deviceConnectionState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
@ -133,32 +139,34 @@ class CardListLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 获取IC卡列表
|
||||
Future<FingerprintListDataEntity> getICCardListData() async{
|
||||
final FingerprintListDataEntity entity = await ApiRepository.to.getICCardListData(
|
||||
Future<FingerprintListDataEntity> getICCardListData(
|
||||
{required bool isRefresh}) async {
|
||||
// 如果是下拉刷新,清空已有数据
|
||||
if (isRefresh) {
|
||||
state.fingerprintItemListData.clear();
|
||||
pageNo = 1;
|
||||
}
|
||||
final FingerprintListDataEntity entity =
|
||||
await ApiRepository.to.getICCardListData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
pageNo: pageNo.toString(),
|
||||
pageSize: pageSize,
|
||||
searchStr: state.searchController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (pageNo == 1) {
|
||||
state.fingerprintItemListData.value = entity.data!.list!;
|
||||
pageNo++;
|
||||
} else {
|
||||
if (entity.data!.list!.isNotEmpty) {
|
||||
state.fingerprintItemListData.value.addAll(entity.data!.list!);
|
||||
pageNo++;
|
||||
}
|
||||
}
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// 更新数据列表
|
||||
state.fingerprintItemListData.addAll(entity.data!.list!);
|
||||
// 更新页码
|
||||
pageNo++;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
// 删除所有IC卡
|
||||
Future<void> deletICCardData() async{
|
||||
Future<void> deletICCardData() async {
|
||||
String cardId = '';
|
||||
String type = '1';
|
||||
if(state.isDeletAll == false){
|
||||
if (state.isDeletAll == false) {
|
||||
cardId = state.deletKeyID;
|
||||
type = '0';
|
||||
}
|
||||
@ -166,18 +174,15 @@ class CardListLogic extends BaseGetXController {
|
||||
cardId: cardId,
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: type,
|
||||
deleteType:'1'
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if(state.isDeletAll == false){
|
||||
showToast('删除成功'.tr, something: (){
|
||||
pageNo = 1;
|
||||
getICCardListData();
|
||||
deleteType: '1');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (state.isDeletAll == false) {
|
||||
showToast('删除成功'.tr, something: () {
|
||||
getICCardListData(isRefresh: true);
|
||||
});
|
||||
}else{
|
||||
showToast('重置成功'.tr, something: (){
|
||||
pageNo = 1;
|
||||
getICCardListData();
|
||||
} else {
|
||||
showToast('重置成功'.tr, something: () {
|
||||
getICCardListData(isRefresh: true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -186,44 +191,48 @@ class CardListLogic extends BaseGetXController {
|
||||
// 监听修改完详情之后刷新列表
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((OtherTypeRefreshListEvent event) {
|
||||
pageNo = 1;
|
||||
getICCardListData();
|
||||
_teamEvent = eventBus
|
||||
.on<OtherTypeRefreshListEvent>()
|
||||
.listen((OtherTypeRefreshListEvent event) {
|
||||
getICCardListData(isRefresh: true);
|
||||
});
|
||||
}
|
||||
|
||||
String getKeyType(FingerprintItemData fingerprintItemData){
|
||||
String keyTypeStr = '';//
|
||||
if(fingerprintItemData.cardStatus == 1){
|
||||
if(fingerprintItemData.startDate! > DateTime.now().millisecondsSinceEpoch){
|
||||
String getKeyType(FingerprintItemData fingerprintItemData) {
|
||||
String keyTypeStr = ''; //
|
||||
if (fingerprintItemData.cardStatus == 1) {
|
||||
if (fingerprintItemData.startDate! >
|
||||
DateTime.now().millisecondsSinceEpoch) {
|
||||
keyTypeStr = '未生效'.tr;
|
||||
}
|
||||
|
||||
}else if(fingerprintItemData.cardStatus == 2){
|
||||
} else if (fingerprintItemData.cardStatus == 2) {
|
||||
keyTypeStr = '已失效'.tr;
|
||||
}
|
||||
return keyTypeStr;
|
||||
}
|
||||
|
||||
String getKeyDateType(FingerprintItemData fingerprintItemData){
|
||||
String keyDateTypeStr = '';// 永久:1;限时2,单次3,循环:4
|
||||
if(fingerprintItemData.cardType! == 1){
|
||||
keyDateTypeStr = '${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} 永久';
|
||||
}else if(fingerprintItemData.cardType! == 2){
|
||||
keyDateTypeStr = '${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时';
|
||||
}else if(fingerprintItemData.cardType! == 4){
|
||||
keyDateTypeStr = '${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环';
|
||||
String getKeyDateType(FingerprintItemData fingerprintItemData) {
|
||||
String keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环:4
|
||||
if (fingerprintItemData.cardType! == 1) {
|
||||
keyDateTypeStr =
|
||||
'${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} 永久';
|
||||
} else if (fingerprintItemData.cardType! == 2) {
|
||||
keyDateTypeStr =
|
||||
'${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时';
|
||||
} else if (fingerprintItemData.cardType! == 4) {
|
||||
keyDateTypeStr =
|
||||
'${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环';
|
||||
}
|
||||
return keyDateTypeStr;
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
super.onReady();
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_initReplySubscription();
|
||||
|
||||
_initRefreshAction();
|
||||
@ -239,10 +248,10 @@ class CardListLogic extends BaseGetXController {
|
||||
Future<void> onClose() async {
|
||||
super.onClose();
|
||||
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false) {
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
@ -31,11 +30,13 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
|
||||
final CardListLogic logic = Get.put(CardListLogic());
|
||||
final CardListState state = Get.find<CardListLogic>().state;
|
||||
|
||||
Future<void> getHttpData() async {
|
||||
Future<void> getHttpData({required bool isRefresh}) async {
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
logic.getICCardListData().then((FingerprintListDataEntity value){
|
||||
if(mounted) {
|
||||
logic
|
||||
.getICCardListData(isRefresh: isRefresh)
|
||||
.then((FingerprintListDataEntity value) {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
@ -46,12 +47,11 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
getHttpData();
|
||||
getHttpData(isRefresh: true);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
@ -67,7 +67,8 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
|
||||
onPressed: () async {
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
ShowTipView().showIosTipWithContentDialog('重置后,该锁的卡都将被删除哦,确认要重置吗?'.tr, () async {
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
'重置后,该锁的卡都将被删除哦,确认要重置吗?'.tr, () async {
|
||||
state.isDeletAll = true;
|
||||
state.deletKeyID = '0';
|
||||
state.deletCardNo = 0;
|
||||
@ -82,34 +83,33 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
|
||||
],
|
||||
),
|
||||
body: EasyRefreshTool(
|
||||
onRefresh: (){
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
onRefresh: () {
|
||||
getHttpData(isRefresh: true);
|
||||
},
|
||||
onLoad: (){
|
||||
getHttpData();
|
||||
onLoad: () {
|
||||
getHttpData(isRefresh: false);
|
||||
},
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
KeySearchWidget(
|
||||
editingController: state.searchController,
|
||||
onSubmittedAction: () {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
getHttpData(isRefresh: true);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20.h),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}',
|
||||
btnName:
|
||||
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}',
|
||||
onClick: () async {
|
||||
final data = await Get.toNamed(Routers.addCardPage, arguments: <String, int>{
|
||||
'lockId': state.lockId.value,
|
||||
'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
final data = await Get.toNamed(Routers.addCardPage,
|
||||
arguments: <String, int>{
|
||||
'lockId': state.lockId.value,
|
||||
'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
getHttpData(isRefresh: true);
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -125,59 +125,69 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => state.fingerprintItemListData.value.isNotEmpty
|
||||
? SlidableAutoCloseBehavior(
|
||||
child: ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index];
|
||||
return Slidable(
|
||||
key:ValueKey(fingerprintItemData.fingerprintId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context){
|
||||
ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async {
|
||||
state.isDeletAll = false;
|
||||
state.deletKeyID = fingerprintItemData.cardId.toString();
|
||||
state.deletCardNo = int.parse(fingerprintItemData.cardNumber!);
|
||||
logic.senderAddICCard();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
label: '删除'.tr,
|
||||
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
||||
),
|
||||
],
|
||||
child: ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final FingerprintItemData fingerprintItemData =
|
||||
state.fingerprintItemListData.value[index];
|
||||
return Slidable(
|
||||
key: ValueKey(fingerprintItemData.fingerprintId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
'确定要删除吗?'.tr, () async {
|
||||
state.isDeletAll = false;
|
||||
state.deletKeyID =
|
||||
fingerprintItemData.cardId.toString();
|
||||
state.deletCardNo =
|
||||
int.parse(fingerprintItemData.cardNumber!);
|
||||
logic.senderAddICCard();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
label: '删除'.tr,
|
||||
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_card.png',
|
||||
fingerprintItemData.cardName!,
|
||||
logic.getKeyType(fingerprintItemData),
|
||||
logic.getKeyDateType(fingerprintItemData), () async {
|
||||
final data = await Get.toNamed(Routers.cardDetailPage,
|
||||
arguments: <String, FingerprintItemData>{
|
||||
'fingerprintItemData': fingerprintItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
getHttpData(isRefresh: true);
|
||||
}
|
||||
}),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_card.png',
|
||||
fingerprintItemData.cardName!,
|
||||
logic.getKeyType(fingerprintItemData),
|
||||
logic.getKeyDateType(fingerprintItemData), () async {
|
||||
final data = await Get.toNamed(
|
||||
Routers.cardDetailPage, arguments: <String, FingerprintItemData>{
|
||||
'fingerprintItemData': fingerprintItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
),
|
||||
) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h));
|
||||
)
|
||||
: NoData(
|
||||
noDataHeight: 1.sh -
|
||||
ScreenUtil().statusBarHeight -
|
||||
ScreenUtil().bottomBarHeight -
|
||||
190.h -
|
||||
64.h));
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String ifInvalidation, String showTime, Function() action) {
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle,
|
||||
String ifInvalidation, String showTime, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
@ -201,14 +211,13 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Text(
|
||||
lockTypeTitle,
|
||||
child: Text(lockTypeTitle,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp,
|
||||
color: AppColors.blackColor)),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
@ -18,15 +17,17 @@ import '../../../../tools/storage.dart';
|
||||
import 'fingerprintListData_entity.dart';
|
||||
import 'fingerprintList_state.dart';
|
||||
|
||||
class FingerprintListLogic extends BaseGetXController{
|
||||
class FingerprintListLogic extends BaseGetXController {
|
||||
FingerprintListState state = FingerprintListState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
// 添加指纹开始(此处用作删除指纹)
|
||||
if((reply is SenderAddFingerprintWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
|
||||
if ((reply is SenderAddFingerprintWithTimeCycleCoercionReply) &&
|
||||
(state.ifCurrentScreen.value == true)) {
|
||||
_replyAddFingerprintBegin(reply);
|
||||
}
|
||||
|
||||
@ -45,7 +46,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
||||
final int status = reply.data[2];
|
||||
|
||||
switch(status){
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
cancelBlueConnetctToastTimer();
|
||||
@ -54,10 +55,13 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<int> token = reply.data.sublist(5, 9);
|
||||
@ -65,25 +69,24 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:(await Storage.getUid())!,
|
||||
fingerNo:state.deletFingerNo,
|
||||
useCountLimit:0xffff,
|
||||
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
||||
isAdmin:0,
|
||||
isForce:0, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:0, // 周循环
|
||||
startDate: 0x11223344,
|
||||
endDate: 0x11223344,
|
||||
startTime:'0',
|
||||
endTime:'0',
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
isBeforeAddUser: false
|
||||
);
|
||||
keyID: state.deletKeyID,
|
||||
userID: (await Storage.getUid())!,
|
||||
fingerNo: state.deletFingerNo,
|
||||
useCountLimit: 0xffff,
|
||||
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
||||
isAdmin: 0,
|
||||
isForce: 0, // 是否是胁迫
|
||||
isRound: 0, // 是否是循环
|
||||
weekRound: 0, // 周循环
|
||||
startDate: 0x11223344,
|
||||
endDate: 0x11223344,
|
||||
startTime: '0',
|
||||
endTime: '0',
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token,
|
||||
isBeforeAddUser: false);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
@ -245,81 +248,124 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
// 删除指纹
|
||||
Future<void> senderAddFingerprint() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:(await Storage.getUid())!,
|
||||
fingerNo:state.deletFingerNo,
|
||||
useCountLimit:0xffff,
|
||||
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
||||
isAdmin:0,
|
||||
isForce:0, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:0, // 周循环
|
||||
startDate: 0x11223344,
|
||||
endDate: 0x11223344,
|
||||
startTime:'0',
|
||||
endTime:'0',
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
isBeforeAddUser: false
|
||||
);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
keyID: state.deletKeyID,
|
||||
userID: (await Storage.getUid())!,
|
||||
fingerNo: state.deletFingerNo,
|
||||
useCountLimit: 0xffff,
|
||||
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
||||
isAdmin: 0,
|
||||
isForce: 0, // 是否是胁迫
|
||||
isRound: 0, // 是否是循环
|
||||
weekRound: 0, // 周循环
|
||||
startDate: 0x11223344,
|
||||
endDate: 0x11223344,
|
||||
startTime: '0',
|
||||
endTime: '0',
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
isBeforeAddUser: false);
|
||||
} else if (deviceConnectionState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* //请求密码钥匙列表
|
||||
Future<PasswordKeyListEntity> mockNetworkDataRequest(
|
||||
{required bool isRefresh}) async {
|
||||
// 如果是下拉刷新,清空已有数据
|
||||
if (isRefresh) {
|
||||
state.itemDataList.clear();
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
final PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList(
|
||||
state.keyInfo.value.keyStatus.toString(),
|
||||
state.keyInfo.value.lockId.toString(),
|
||||
pageNo.toString(),
|
||||
pageSize.toString(),
|
||||
state.searchController.text);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// 更新数据列表
|
||||
state.itemDataList.addAll(entity.data!.itemList!);
|
||||
// 更新页码
|
||||
pageNo++;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// 获取指纹列表
|
||||
Future<FingerprintListDataEntity> getFingerprintsListData() async{
|
||||
// state.fingerprintItemListData.value.clear();
|
||||
final FingerprintListDataEntity entity = await ApiRepository.to.getFingerprintsListData(
|
||||
Future<FingerprintListDataEntity> getFingerprintsListData(
|
||||
{required bool isRefresh}) async {
|
||||
// 如果是下拉刷新,清空已有数据
|
||||
if (isRefresh) {
|
||||
state.fingerprintItemListData.clear();
|
||||
pageNo = 1;
|
||||
}
|
||||
final FingerprintListDataEntity entity =
|
||||
await ApiRepository.to.getFingerprintsListData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
pageNo: pageNo.toString(),
|
||||
pageSize: pageSize.toString(),
|
||||
searchStr: state.searchController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (pageNo == 1) {
|
||||
state.fingerprintItemListData.value = entity.data!.list!;
|
||||
pageNo++;
|
||||
} else {
|
||||
if (entity.data!.list!.isNotEmpty) {
|
||||
state.fingerprintItemListData.value.addAll(entity.data!.list!);
|
||||
pageNo++;
|
||||
}
|
||||
}
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// if (pageNo == 1) {
|
||||
// state.fingerprintItemListData.value = entity.data!.list!;
|
||||
// pageNo++;
|
||||
// } else {
|
||||
// if (entity.data!.list!.isNotEmpty) {
|
||||
// state.fingerprintItemListData.value.addAll(entity.data!.list!);
|
||||
// pageNo++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// 更新数据列表
|
||||
state.fingerprintItemListData.addAll(entity.data!.list!);
|
||||
// 更新页码
|
||||
pageNo++;
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
// 重置所有的指纹
|
||||
Future<void> deletAllFingerprintsData() async{
|
||||
Future<void> deletAllFingerprintsData() async {
|
||||
String fingerprintId = '';
|
||||
String type = '1';
|
||||
if(state.isDeletAll == false){
|
||||
if (state.isDeletAll == false) {
|
||||
fingerprintId = state.deletKeyID;
|
||||
type = '0';
|
||||
}
|
||||
@ -327,18 +373,15 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
fingerprintId: fingerprintId,
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: type,
|
||||
deleteType:'1'
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if(state.isDeletAll == false){
|
||||
showToast('删除成功'.tr, something:(){
|
||||
pageNo = 1;
|
||||
getFingerprintsListData();
|
||||
deleteType: '1');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (state.isDeletAll == false) {
|
||||
showToast('删除成功'.tr, something: () {
|
||||
getFingerprintsListData(isRefresh: true);
|
||||
});
|
||||
}else{
|
||||
showToast('重置成功'.tr, something:(){
|
||||
pageNo = 1;
|
||||
getFingerprintsListData();
|
||||
} else {
|
||||
showToast('重置成功'.tr, something: () {
|
||||
getFingerprintsListData(isRefresh: true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -347,35 +390,39 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
// 监听修改完详情之后刷新列表
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((OtherTypeRefreshListEvent event) {
|
||||
pageNo = 1;
|
||||
getFingerprintsListData();
|
||||
_teamEvent = eventBus
|
||||
.on<OtherTypeRefreshListEvent>()
|
||||
.listen((OtherTypeRefreshListEvent event) {
|
||||
getFingerprintsListData(isRefresh: true);
|
||||
});
|
||||
}
|
||||
|
||||
String getKeyType(FingerprintItemData fingerprintItemData){
|
||||
String getKeyType(FingerprintItemData fingerprintItemData) {
|
||||
// fingerprintStatus 1:正常 2:失效
|
||||
String keyTypeStr = '';//
|
||||
String keyTypeStr = ''; //
|
||||
// (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : ""
|
||||
if(fingerprintItemData.fingerprintStatus == 1){
|
||||
if(fingerprintItemData.startDate! > DateTime.now().millisecondsSinceEpoch){
|
||||
if (fingerprintItemData.fingerprintStatus == 1) {
|
||||
if (fingerprintItemData.startDate! >
|
||||
DateTime.now().millisecondsSinceEpoch) {
|
||||
keyTypeStr = '未生效'.tr;
|
||||
}
|
||||
|
||||
}else if(fingerprintItemData.fingerprintStatus == 2){
|
||||
} else if (fingerprintItemData.fingerprintStatus == 2) {
|
||||
keyTypeStr = '已失效'.tr;
|
||||
}
|
||||
return keyTypeStr;
|
||||
}
|
||||
|
||||
String getKeyDateType(FingerprintItemData fingerprintItemData){
|
||||
String keyDateTypeStr = '';// 永久:1;限时2,单次3,循环:4
|
||||
if(fingerprintItemData.fingerprintType! == 1){
|
||||
keyDateTypeStr = "${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} ${"永久".tr}";
|
||||
}else if(fingerprintItemData.fingerprintType! == 2){
|
||||
keyDateTypeStr = '${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时';
|
||||
}else if(fingerprintItemData.fingerprintType! == 4){
|
||||
keyDateTypeStr = '${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环';
|
||||
String getKeyDateType(FingerprintItemData fingerprintItemData) {
|
||||
String keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环:4
|
||||
if (fingerprintItemData.fingerprintType! == 1) {
|
||||
keyDateTypeStr =
|
||||
"${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} ${"永久".tr}";
|
||||
} else if (fingerprintItemData.fingerprintType! == 2) {
|
||||
keyDateTypeStr =
|
||||
'${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时';
|
||||
} else if (fingerprintItemData.fingerprintType! == 4) {
|
||||
keyDateTypeStr =
|
||||
'${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环';
|
||||
}
|
||||
return keyDateTypeStr;
|
||||
}
|
||||
@ -385,8 +432,8 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
super.onReady();
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_initReplySubscription();
|
||||
|
||||
_initRefreshAction();
|
||||
@ -402,10 +449,10 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
Future<void> onClose() async {
|
||||
super.onClose();
|
||||
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false) {
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
@ -29,14 +28,17 @@ class FingerprintListPage extends StatefulWidget {
|
||||
State<FingerprintListPage> createState() => _FingerprintListPageState();
|
||||
}
|
||||
|
||||
class _FingerprintListPageState extends State<FingerprintListPage> with RouteAware {
|
||||
class _FingerprintListPageState extends State<FingerprintListPage>
|
||||
with RouteAware {
|
||||
final logic = Get.put(FingerprintListLogic());
|
||||
final state = Get.find<FingerprintListLogic>().state;
|
||||
|
||||
Future<void> getHttpData() async {
|
||||
Future<void> getHttpData({required bool isRefresh}) async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
logic.getFingerprintsListData().then((FingerprintListDataEntity value){
|
||||
logic
|
||||
.getFingerprintsListData(isRefresh: isRefresh)
|
||||
.then((FingerprintListDataEntity value) {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
@ -48,7 +50,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> with RouteAwa
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
getHttpData();
|
||||
getHttpData(isRefresh: true);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -68,7 +70,8 @@ class _FingerprintListPageState extends State<FingerprintListPage> with RouteAwa
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
ShowTipView().showIosTipWithContentDialog("重置后,该锁的指纹都将被删除哦,确认要重置吗?".tr, () async {
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
"重置后,该锁的指纹都将被删除哦,确认要重置吗?".tr, () async {
|
||||
state.isDeletAll = true;
|
||||
state.deletKeyID = "1";
|
||||
state.deletFingerNo = 0;
|
||||
@ -82,20 +85,18 @@ class _FingerprintListPageState extends State<FingerprintListPage> with RouteAwa
|
||||
],
|
||||
),
|
||||
body: EasyRefreshTool(
|
||||
onRefresh: (){
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
onRefresh: () {
|
||||
getHttpData(isRefresh: true);
|
||||
},
|
||||
onLoad: (){
|
||||
getHttpData();
|
||||
onLoad: () {
|
||||
getHttpData(isRefresh: false);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
KeySearchWidget(
|
||||
editingController: state.searchController,
|
||||
onSubmittedAction: () {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
getHttpData(isRefresh: true);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
@ -103,16 +104,16 @@ class _FingerprintListPageState extends State<FingerprintListPage> with RouteAwa
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}',
|
||||
btnName:
|
||||
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.addFingerprintTypePage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
var data = await Get.toNamed(Routers.addFingerprintTypePage,
|
||||
arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
getHttpData(isRefresh: true);
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -126,61 +127,70 @@ class _FingerprintListPageState extends State<FingerprintListPage> with RouteAwa
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => state.fingerprintItemListData.value.isNotEmpty
|
||||
? SlidableAutoCloseBehavior(
|
||||
child: ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index];
|
||||
// 指纹
|
||||
return Slidable(
|
||||
key:ValueKey(fingerprintItemData.fingerprintId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context){
|
||||
ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () async {
|
||||
state.isDeletAll = false;
|
||||
state.deletKeyID = fingerprintItemData.fingerprintId.toString();
|
||||
state.deletFingerNo = int.parse(fingerprintItemData.fingerprintNumber!);
|
||||
logic.senderAddFingerprint();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
// foregroundColor: Colors.white,
|
||||
label: '删除'.tr,
|
||||
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
||||
),
|
||||
],
|
||||
child: ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
FingerprintItemData fingerprintItemData =
|
||||
state.fingerprintItemListData.value[index];
|
||||
// 指纹
|
||||
return Slidable(
|
||||
key: ValueKey(fingerprintItemData.fingerprintId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
"确定要删除吗?".tr, () async {
|
||||
state.isDeletAll = false;
|
||||
state.deletKeyID =
|
||||
fingerprintItemData.fingerprintId.toString();
|
||||
state.deletFingerNo = int.parse(
|
||||
fingerprintItemData.fingerprintNumber!);
|
||||
logic.senderAddFingerprint();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
// foregroundColor: Colors.white,
|
||||
label: '删除'.tr,
|
||||
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_fingerprint.png',
|
||||
fingerprintItemData.fingerprintName!,
|
||||
logic.getKeyType(fingerprintItemData),
|
||||
logic.getKeyDateType(fingerprintItemData), () async {
|
||||
var data = await Get.toNamed(Routers.fingerprintDetailPage,
|
||||
arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
getHttpData(isRefresh: true);
|
||||
}
|
||||
}),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_fingerprint.png',
|
||||
fingerprintItemData.fingerprintName!,
|
||||
logic.getKeyType(fingerprintItemData),
|
||||
logic.getKeyDateType(fingerprintItemData), () async {
|
||||
var data = await Get.toNamed(
|
||||
Routers.fingerprintDetailPage,
|
||||
arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
),
|
||||
) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h));
|
||||
)
|
||||
: NoData(
|
||||
noDataHeight: 1.sh -
|
||||
ScreenUtil().statusBarHeight -
|
||||
ScreenUtil().bottomBarHeight -
|
||||
190.h -
|
||||
64.h));
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String ifInvalidation, String showTime, Function() action) {
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle,
|
||||
String ifInvalidation, String showTime, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
@ -204,24 +214,24 @@ class _FingerprintListPageState extends State<FingerprintListPage> with RouteAwa
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: ifInvalidation.isNotEmpty ? 1.sw - 110.w - 100.w : 1.sw - 110.w - 50.w,
|
||||
width: ifInvalidation.isNotEmpty
|
||||
? 1.sw - 110.w - 100.w
|
||||
: 1.sw - 110.w - 50.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
lockTypeTitle,
|
||||
child: Text(lockTypeTitle,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp,
|
||||
color: AppColors.blackColor)),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(ifInvalidation,
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: Colors.red)),
|
||||
style: TextStyle(fontSize: 22.sp, color: Colors.red)),
|
||||
SizedBox(width: 10.w),
|
||||
],
|
||||
),
|
||||
@ -298,5 +308,4 @@ class _FingerprintListPageState extends State<FingerprintListPage> with RouteAwa
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
state.ifCurrentScreen.value = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,13 +25,16 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
|
||||
if ((reply is SenderCustomPasswordsReply) &&
|
||||
(state.ifCurrentScreen.value == true)) {
|
||||
_replyAddPassword(reply);
|
||||
}
|
||||
|
||||
if ((reply is SenderResetPasswordsReply) && (state.ifCurrentScreen.value == true)) {
|
||||
if ((reply is SenderResetPasswordsReply) &&
|
||||
(state.ifCurrentScreen.value == true)) {
|
||||
_replyResetPassword(reply);
|
||||
}
|
||||
});
|
||||
@ -49,10 +52,13 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<int> token = reply.data.sublist(5, 9);
|
||||
@ -95,10 +101,13 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<int> token = reply.data.sublist(5, 9);
|
||||
@ -131,11 +140,14 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
@ -182,11 +194,14 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
@ -255,26 +270,16 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
state.itemDataList.addAll(entity.data!.itemList!);
|
||||
// 更新页码
|
||||
pageNo++;
|
||||
|
||||
// if (pageNo == 1) {
|
||||
// state.itemDataList.value.clear();
|
||||
// state.itemDataList.value = entity.data!.itemList!;
|
||||
// pageNo++;
|
||||
// } else {
|
||||
// if (entity.data!.itemList!.isNotEmpty) {
|
||||
// state.itemDataList.value.addAll(entity.data!.itemList!);
|
||||
// pageNo++;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
//密码钥匙重置请求
|
||||
Future<void> resetPasswordKeyListRequest() async {
|
||||
final PasswordKeyListEntity entity = await ApiRepository.to.keyboardPwdReset(
|
||||
lockId: state.keyInfo.value.lockId.toString(),
|
||||
passwordKey: state.encrpyKey);
|
||||
final PasswordKeyListEntity entity = await ApiRepository.to
|
||||
.keyboardPwdReset(
|
||||
lockId: state.keyInfo.value.lockId.toString(),
|
||||
passwordKey: state.encrpyKey);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast('重置成功'.tr, something: () {
|
||||
pageNo = 1;
|
||||
@ -390,8 +395,9 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
StreamSubscription? _getPasswordListRefreshUIEvent;
|
||||
void _getPasswordListRefreshUIAction() {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_getPasswordListRefreshUIEvent =
|
||||
eventBus.on<GetPasswordListRefreshUI>().listen((GetPasswordListRefreshUI event) {
|
||||
_getPasswordListRefreshUIEvent = eventBus
|
||||
.on<GetPasswordListRefreshUI>()
|
||||
.listen((GetPasswordListRefreshUI event) {
|
||||
mockNetworkDataRequest(isRefresh: true);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user