diff --git a/lib/main/lockDetail/face/faceList/faceList_logic.dart b/lib/main/lockDetail/face/faceList/faceList_logic.dart index debdc5ce..9781a916 100755 --- a/lib/main/lockDetail/face/faceList/faceList_logic.dart +++ b/lib/main/lockDetail/face/faceList/faceList_logic.dart @@ -22,6 +22,7 @@ class FaceListLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; + void _initReplySubscription() { _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { @@ -77,11 +78,15 @@ class FaceListLogic extends BaseGetXController { userID: (await Storage.getUid())!, faceNo: state.deletFaceNo, useCountLimit: 0xffff, - operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 + operate: state.isDeletAll == true ? 3 : 2, + // 0:注册 1:修改 2:删除 3:删除全部 isAdmin: 0, - isForce: 0, // 是否是胁迫 - isRound: 0, // 是否是循环 - weekRound: 0, // 周循环 + isForce: 0, + // 是否是胁迫 + isRound: 0, + // 是否是循环 + weekRound: 0, + // 周循环 startDate: 0x11223344, endDate: 0x11223344, startTime: '0', @@ -277,11 +282,15 @@ class FaceListLogic extends BaseGetXController { userID: (await Storage.getUid())!, faceNo: state.deletFaceNo, useCountLimit: 0xffff, - operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 + operate: state.isDeletAll == true ? 3 : 2, + // 0:注册 1:修改 2:删除 3:删除全部 isAdmin: 0, - isForce: 0, // 是否是胁迫 - isRound: 0, // 是否是循环 - weekRound: 0, // 周循环 + isForce: 0, + // 是否是胁迫 + isRound: 0, + // 是否是循环 + weekRound: 0, + // 周循环 startDate: 0x11223344, endDate: 0x11223344, startTime: '0', @@ -348,8 +357,8 @@ class FaceListLogic extends BaseGetXController { lockId: state.lockId.value, ); if (entity.errorCode!.codeIsSuccessful) { - showToast('删除成功'.tr, something: () { - getFaceListData(isRefresh: true); + showToast('删除成功'.tr, something: () async { + await getFaceListData(isRefresh: true); }); } } @@ -366,8 +375,8 @@ class FaceListLogic extends BaseGetXController { lockId: state.lockId.value, ); if (entity.errorCode!.codeIsSuccessful) { - showToast('重置成功'.tr, something: () { - getFaceListData(isRefresh: true); + showToast('重置成功'.tr, something: () async{ + await getFaceListData(isRefresh: true); }); } } @@ -403,11 +412,12 @@ class FaceListLogic extends BaseGetXController { // 监听修改完详情之后刷新列表 late StreamSubscription _teamEvent; + void _initRefreshAction() { _teamEvent = eventBus .on() - .listen((OtherTypeRefreshListEvent event) { - getFaceListData(isRefresh: true); + .listen((OtherTypeRefreshListEvent event) async { + await getFaceListData(isRefresh: true); }); } @@ -434,6 +444,7 @@ class FaceListLogic extends BaseGetXController { // senderCheckingUserInfoCount(); } + getFaceListData(isRefresh: true); } @override diff --git a/lib/main/lockDetail/face/faceList/faceList_page.dart b/lib/main/lockDetail/face/faceList/faceList_page.dart index 5758785b..43248d26 100755 --- a/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -31,24 +30,6 @@ class _FaceListPageState extends State with RouteAware { final FaceListLogic logic = Get.put(FaceListLogic()); final FaceListState state = Get.find().state; - Future getHttpData({required bool isRefresh}) async { - final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if (isDemoMode == false) { - logic.getFaceListData(isRefresh: isRefresh).then((FingerprintListDataEntity value) { - if (mounted) { - setState(() {}); - } - }); - } - } - - @override - void initState() { - super.initState(); - - getHttpData(isRefresh: true); - } - @override Widget build(BuildContext context) { return Scaffold( @@ -92,17 +73,17 @@ class _FaceListPageState extends State with RouteAware { ), body: EasyRefreshTool( onRefresh: () { - getHttpData(isRefresh: true); + logic.getFaceListData(isRefresh: true); }, onLoad: () { - getHttpData(isRefresh: false); + logic.getFaceListData(isRefresh: false); }, child: Column( children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { - getHttpData(isRefresh: true); + logic.getFaceListData(isRefresh: true); }, ), SizedBox( @@ -110,14 +91,15 @@ class _FaceListPageState extends State with RouteAware { ), Expanded(child: _buildMainUI()), AddBottomWhiteBtn( - btnName: - '添加人脸'.tr, + btnName: '添加人脸'.tr, onClick: () async { - await Get.toNamed(Routers.addFaceTypePage, arguments: { + await Get.toNamed(Routers.addFaceTypePage, + arguments: { 'lockId': state.lockId.value, 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - })!.then((value) { - getHttpData(isRefresh: true); + })! + .then((value) { + logic.getFaceListData(isRefresh: true); }); }, ), @@ -154,9 +136,11 @@ class _FaceListPageState extends State with RouteAware { logic.getKeyType(getFaceItemData), logic.getKeyDateType(getFaceItemData), () async { await Get.toNamed(Routers.faceDetailPage, - arguments: { + arguments: { 'faceItemData': getFaceItemData, - })!.then((value) => getHttpData(isRefresh: true)); + })! + .then((value) => + logic.getFaceListData(isRefresh: true)); }), ); }