From 33a1cecb8eaf57c8482173886cdf4e9eb7efaafd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Fri, 9 Aug 2024 14:00:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=A1=E3=80=81=E6=8C=87?= =?UTF-8?q?=E7=BA=B9=E3=80=81=E4=BA=BA=E8=84=B8=E3=80=81=E9=81=A5=E6=8E=A7?= =?UTF-8?q?=E3=80=81=E6=8E=8C=E9=9D=99=E8=84=89=E3=80=81=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=B6=85=E8=BF=87=E4=B8=89=E9=A1=B5=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E5=88=A0=E9=99=A4=E8=BF=9B=E5=85=A5=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=9C=80=E5=90=8E=E4=B8=80=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=88=97=E8=A1=A8=E5=8D=A1=E9=A1=BF=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/cardList/cardList_logic.dart | 3 +- .../card/cardList/cardList_page.dart | 24 ++++++----- .../face/faceList/faceList_logic.dart | 41 ++++++++++-------- .../face/faceList/faceList_page.dart | 33 ++++++--------- .../fingerprintList_logic.dart | 3 +- .../fingerprintList/fingerprintList_page.dart | 40 +++++++++--------- .../lockDetail/lockDetail_page.dart | 4 +- .../uploadElectricQuantity_logic.dart | 8 ++-- .../uploadElectricQuantity_page.dart | 8 ++-- .../uploadElectricQuantity_state.dart | 4 ++ .../palm/palmList/palmList_page.dart | 20 ++++----- .../passwordKeyList/passwordKeyList_page.dart | 42 +++++++++---------- .../remoteControlList_page.dart | 18 ++++---- 13 files changed, 124 insertions(+), 124 deletions(-) diff --git a/lib/main/lockDetail/card/cardList/cardList_logic.dart b/lib/main/lockDetail/card/cardList/cardList_logic.dart index cb5c420c..f57cde7c 100755 --- a/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -131,8 +131,7 @@ class CardListLogic extends BaseGetXController { privateKey: getPrivateKeyList, token: getTokenList, isBeforeAddUser: false); - } else if (deviceConnectionState == - BluetoothConnectionState.disconnected) { + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); if (state.ifCurrentScreen.value == true) { diff --git a/lib/main/lockDetail/card/cardList/cardList_page.dart b/lib/main/lockDetail/card/cardList/cardList_page.dart index 8dba8e5b..9dc6a76f 100755 --- a/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -110,14 +110,16 @@ class _CardListPageState extends State with RouteAware { btnName: '添加卡'.tr, onClick: () async { - final data = await Get.toNamed(Routers.addCardPage, + await Get.toNamed(Routers.addCardPage, arguments: { 'lockId': state.lockId.value, 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); - if (data != null) { + })!.then((value) { getHttpData(isRefresh: true); - } + }); + // if (data != null) { + // getHttpData(isRefresh: true); + // } }, ), SizedBox( @@ -174,13 +176,13 @@ class _CardListPageState extends State with RouteAware { fingerprintItemData.cardName!, logic.getKeyType(fingerprintItemData), logic.getKeyDateType(fingerprintItemData), () async { - final data = await Get.toNamed(Routers.cardDetailPage, - arguments: { - 'fingerprintItemData': fingerprintItemData, - }); - if (data != null) { - getHttpData(isRefresh: true); - } + await Get.toNamed(Routers.cardDetailPage, + arguments: { + 'fingerprintItemData': fingerprintItemData, + })!.then((value) => getHttpData(isRefresh: true)); + // if (data != null) { + // getHttpData(isRefresh: true); + // } }), ); }, diff --git a/lib/main/lockDetail/face/faceList/faceList_logic.dart b/lib/main/lockDetail/face/faceList/faceList_logic.dart index 05494f98..c03900a0 100755 --- a/lib/main/lockDetail/face/faceList/faceList_logic.dart +++ b/lib/main/lockDetail/face/faceList/faceList_logic.dart @@ -298,7 +298,11 @@ class FaceListLogic extends BaseGetXController { } // 获取人脸列表 - Future getFaceListData() async { + Future getFaceListData({required bool isRefresh}) async { + if (isRefresh) { + state.faceItemListData.clear(); + pageNo = 1; + } final FingerprintListDataEntity entity = await ApiRepository.to.getFaceListData( lockId: state.lockId.value.toString(), pageNo: pageNo.toString(), @@ -307,21 +311,27 @@ class FaceListLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { // state.faceItemListData.value = entity.data!.list!; - if (pageNo == 1) { - state.faceItemListData.value = entity.data!.list!; + // if (pageNo == 1) { + // state.faceItemListData.value = entity.data!.list!; + // pageNo++; + // } else { + // if (entity.data!.list!.isNotEmpty) { + // state.faceItemListData.value.addAll(entity.data!.list!); + // pageNo++; + // } + // } + if (entity.errorCode!.codeIsSuccessful) { + // 更新数据列表 + state.faceItemListData.addAll(entity.data!.list!); + // 更新页码 pageNo++; - } else { - if (entity.data!.list!.isNotEmpty) { - state.faceItemListData.value.addAll(entity.data!.list!); - pageNo++; - } } } return entity; } // 删除的人脸 - void deletFacesData() async { + Future deletFacesData() async { String faceId = ''; if (state.isDeletAll == false) { faceId = state.deletKeyID; @@ -331,9 +341,8 @@ class FaceListLogic extends BaseGetXController { lockId: state.lockId.value, ); if (entity.errorCode!.codeIsSuccessful) { - showToast('删除成功', something: (){ - pageNo = 1; - getFaceListData(); + showToast('删除成功'.tr, something: (){ + getFaceListData(isRefresh: true); }); } } @@ -350,9 +359,8 @@ class FaceListLogic extends BaseGetXController { lockId: state.lockId.value, ); if (entity.errorCode!.codeIsSuccessful) { - showToast('重置成功', something: (){ - pageNo = 1; - getFaceListData(); + showToast('重置成功'.tr, something: (){ + getFaceListData(isRefresh: true); }); } } @@ -387,8 +395,7 @@ class FaceListLogic extends BaseGetXController { late StreamSubscription _teamEvent; void _initRefreshAction() { _teamEvent = eventBus.on().listen((OtherTypeRefreshListEvent event) { - pageNo = 1; - getFaceListData(); + getFaceListData(isRefresh: true); }); } diff --git a/lib/main/lockDetail/face/faceList/faceList_page.dart b/lib/main/lockDetail/face/faceList/faceList_page.dart index d1ad4ebf..0303ea41 100755 --- a/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -31,10 +31,10 @@ class _FaceListPageState extends State with RouteAware { final FaceListLogic logic = Get.put(FaceListLogic()); final FaceListState state = Get.find().state; - Future getHttpData() async { + Future getHttpData({required bool isRefresh}) async { final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - logic.getFaceListData().then((FingerprintListDataEntity value) { + logic.getFaceListData(isRefresh: isRefresh).then((FingerprintListDataEntity value) { if (mounted) { setState(() {}); } @@ -46,7 +46,7 @@ class _FaceListPageState extends State with RouteAware { void initState() { super.initState(); - getHttpData(); + getHttpData(isRefresh: true); } @override @@ -92,19 +92,17 @@ class _FaceListPageState extends State with RouteAware { ), body: EasyRefreshTool( onRefresh: () { - logic.pageNo = 1; - getHttpData(); + getHttpData(isRefresh: true); }, onLoad: () { - getHttpData(); + getHttpData(isRefresh: false); }, child: Column( children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { - logic.pageNo = 1; - getHttpData(); + getHttpData(isRefresh: true); }, ), SizedBox( @@ -115,15 +113,12 @@ class _FaceListPageState extends State with RouteAware { btnName: '添加人脸'.tr, onClick: () async { - final data = await Get.toNamed(Routers.addFaceTypePage, - arguments: { + await Get.toNamed(Routers.addFaceTypePage, arguments: { 'lockId': state.lockId.value, 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); - if (data != null) { - logic.pageNo = 1; - getHttpData(); - } + })!.then((value) { + getHttpData(isRefresh: true); + }); }, ), SizedBox(height: 64.h) @@ -158,14 +153,10 @@ class _FaceListPageState extends State with RouteAware { getFaceItemData.faceName!, logic.getKeyType(getFaceItemData), logic.getKeyDateType(getFaceItemData), () async { - final data = await Get.toNamed(Routers.faceDetailPage, + await Get.toNamed(Routers.faceDetailPage, arguments: { 'faceItemData': getFaceItemData, - }); - if (data != null) { - logic.pageNo = 1; - getHttpData(); - } + })!.then((value) => getHttpData(isRefresh: true)); }), ); } diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index 178733e2..84237ed4 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -328,8 +328,7 @@ class FingerprintListLogic extends BaseGetXController { */ // 获取指纹列表 - Future getFingerprintsListData( - {required bool isRefresh}) async { + Future getFingerprintsListData({required bool isRefresh}) async { // 如果是下拉刷新,清空已有数据 if (isRefresh) { state.fingerprintItemListData.clear(); diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index 9e902e4b..9049dd12 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -113,14 +113,14 @@ class _FingerprintListPageState extends State btnName: '添加指纹'.tr, onClick: () async { - final data = await Get.toNamed(Routers.addFingerprintTypePage, + await Get.toNamed(Routers.addFingerprintTypePage, arguments: { 'lockId': state.lockId.value, 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); - if (data != null) { - getHttpData(isRefresh: true); - } + })!.then((value) => getHttpData(isRefresh: true)); + // if (data != null) { + // getHttpData(isRefresh: true); + // } }, ), SizedBox(height: 64.h) @@ -175,23 +175,21 @@ class _FingerprintListPageState extends State fingerprintItemData.fingerprintName!, logic.getKeyType(fingerprintItemData), logic.getKeyDateType(fingerprintItemData), () async { - final data = await Get.toNamed( - Routers.fingerprintDetailPage, - arguments: { + await Get.toNamed(Routers.fingerprintDetailPage, arguments: { 'fingerprintItemData': fingerprintItemData, - }); - if (data == 'deletScuess') { - state.fingerprintItemListData.removeWhere( - (FingerprintItemData item) => - item.fingerprintId == - fingerprintItemData.fingerprintId!); - setState(() {}); - } else if (data != null) { - logic - .refreshIndividualKeys( - fingerprintId: fingerprintItemData.fingerprintId!) - .then((dynamic value) => setState(() {})); - } + })!.then((value) { + getHttpData(isRefresh: true); + }); + // if (data == 'deletScuess') { + // // state.fingerprintItemListData.removeWhere((FingerprintItemData item) => item.fingerprintId == fingerprintItemData.fingerprintId!); + // // setState(() {}); + // getHttpData(isRefresh: true); + // } else if (data != null) { + // logic + // .refreshIndividualKeys( + // fingerprintId: fingerprintItemData.fingerprintId!) + // .then((dynamic value) => setState(() {})); + // } }), ); }, diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 5c51da64..ec5a7e81 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1227,7 +1227,7 @@ class _LockDetailPageState extends State fit: BoxFit.fitWidth), ), ), - SizedBox(height: 10.w), + SizedBox(height: 5.w), Expanded( child: Text(name, style: TextStyle( @@ -1260,7 +1260,7 @@ class _LockDetailPageState extends State fit: BoxFit.fitWidth), ), ), - SizedBox(height: 20.h), + SizedBox(height: 5.h), Text( name, style: TextStyle( diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index 11be080d..23d80a44 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -108,13 +108,13 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 电池剩余电量 final int battRemCap = reply.data[132]; - state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = - battRemCap; + state.battRemCap.value = battRemCap>100?100:battRemCap; + state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = state.battRemCap.value; // 备用电池剩余电量 final int battRemCapStandby = reply.data[133]; - state.lockSetInfoData.value.lockBasicInfo!.electricQuantityStandby = - battRemCapStandby; + state.battRemCapStandby.value = battRemCapStandby>100?100:battRemCapStandby; + state.lockSetInfoData.value.lockBasicInfo!.electricQuantityStandby = state.battRemCapStandby.value; uploadElectricQuantityRequest( battRemCap.toString(), battRemCapStandby.toString()); diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart index 02096b54..1aea288a 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart @@ -57,23 +57,23 @@ class _UploadElectricQuantityPageState extends State children: [ Expanded( child: Text( - "${"电池1".tr}${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo.value.electricQuantity ?? ""}%", + "${"电池1".tr}${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.battRemCap.value}%", style: TextStyle(fontSize: 20.sp), )), ], )), Visibility( visible: (state.lockSetInfoData.value.lockFeature ?? LockFeature()).isSupportBackupBattery == 1, - child: Row( + child: Obx(() => Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Text( - "${"电池2".tr}${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo.value.electricQuantityStandby ?? ""}%", + "${"电池2".tr}${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.battRemCapStandby.value}%", style: TextStyle(fontSize: 20.sp), )), ], - ), + )), ), SizedBox(height: 10.h), Obx(() => Row( diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart index 2a49df8c..4898804f 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart @@ -12,12 +12,16 @@ class UploadElectricQuantityState {// 0普通状态可用 1不可用 if(lockSetInfoData.value.lockBasicInfo!=null){ lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!; uploadElectricQuantityDate.value = lockSetInfoData.value.lockBasicInfo!.electricQuantityDate!; + battRemCap.value = lockSetInfoData.value.lockBasicInfo!.electricQuantity ?? 0; + battRemCapStandby.value = lockSetInfoData.value.lockBasicInfo!.electricQuantityStandby ?? 0; } } } Rx lockSetInfoData = LockSetInfoData().obs; Rx lockBasicInfo = LockBasicInfo().obs; RxInt uploadElectricQuantityDate = 0.obs; + RxInt battRemCap = 0.obs; + RxInt battRemCapStandby = 0.obs; int differentialTime = 0; RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 diff --git a/lib/main/lockDetail/palm/palmList/palmList_page.dart b/lib/main/lockDetail/palm/palmList/palmList_page.dart index 7cbc8872..190098eb 100755 --- a/lib/main/lockDetail/palm/palmList/palmList_page.dart +++ b/lib/main/lockDetail/palm/palmList/palmList_page.dart @@ -108,13 +108,13 @@ class _PalmListPageState extends State with RouteAware { AddBottomWhiteBtn( btnName: '添加掌静脉', onClick: () async { - final data = await Get.toNamed(Routers.addPalmTypePage, arguments: { + await Get.toNamed(Routers.addPalmTypePage, arguments: { 'lockId': state.lockId.value, 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); - if (data != null) { - getHttpData(isRefresh: true); - } + })!.then((value) => getHttpData(isRefresh: true)); + // if (data != null) { + // getHttpData(isRefresh: true); + // } }, ), SizedBox( @@ -171,13 +171,13 @@ class _PalmListPageState extends State with RouteAware { fingerprintItemData.palmVeinName!, logic.getKeyType(fingerprintItemData), logic.getKeyDateType(fingerprintItemData), () async { - final data = await Get.toNamed(Routers.palmDetailPage, + final data = await Get.toNamed(Routers.palmDetailPage, arguments: { 'fingerprintItemData': fingerprintItemData, - }); - if (data != null) { - getHttpData(isRefresh: true); - } + })!.then((value) => getHttpData(isRefresh: true)); + // if (data != null) { + // getHttpData(isRefresh: true); + // } }), ); }, diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index ac96dbb8..30d1cf37 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -112,12 +112,11 @@ class _PasswordKeyListPageState extends State ), AddBottomWhiteBtn( btnName: '获取密码'.tr, - onClick: () { - Navigator.pushNamed( - context, Routers.passwordKeyPerpetualPage, + onClick: () async { + await Get.toNamed(Routers.passwordKeyPerpetualPage, arguments: { 'keyInfo': state.keyInfo.value - }).then((Object? val) { + })!.then((Object? val) { if (val != null) { getHttpData(isRefresh: true); } @@ -179,25 +178,26 @@ class _PasswordKeyListPageState extends State ], ), child: _electronicKeyItem(index, 'images/icon_password.png', - passwordKeyListItem.keyboardPwdName!, useDateStr, () { - Navigator.pushNamed(context, Routers.passwordKeyDetailPage, + passwordKeyListItem.keyboardPwdName!, useDateStr, () async { + await Get.toNamed(Routers.passwordKeyDetailPage, arguments: { 'itemData': passwordKeyListItem - }).then((Object? val) { - if (val == 'deletScuess') { - state.itemDataList.removeWhere( - (PasswordKeyListItem item) => - item.keyboardPwdId == - passwordKeyListItem.keyboardPwdId!); - setState(() {}); - } else if (val != null) { - logic - .refreshIndividualKeys( - lockId: passwordKeyListItem.lockId!, - keyboardPwdId: - passwordKeyListItem.keyboardPwdId!) - .then((dynamic value) => setState(() {})); - } + })!.then((Object? val) { + getHttpData(isRefresh: true); + // if (val == 'deletScuess') { + // state.itemDataList.removeWhere( + // (PasswordKeyListItem item) => + // item.keyboardPwdId == + // passwordKeyListItem.keyboardPwdId!); + // setState(() {}); + // } else if (val != null) { + // logic + // .refreshIndividualKeys( + // lockId: passwordKeyListItem.lockId!, + // keyboardPwdId: + // passwordKeyListItem.keyboardPwdId!) + // .then((dynamic value) => setState(() {})); + // } }); }), ); diff --git a/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart b/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart index f217c93f..65819360 100755 --- a/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart +++ b/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart @@ -110,14 +110,14 @@ class _RemoteControlListPageState extends State with Rout btnName: '添加遥控', onClick: () async { - final data = await Get.toNamed(Routers.addRemoteControlTypePage, + await Get.toNamed(Routers.addRemoteControlTypePage, arguments: { 'lockId': state.lockId.value, 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); - if (data != null) { - getHttpData(isRefresh: true); - } + })!.then((value) => getHttpData(isRefresh: true)); + // if (data != null) { + // getHttpData(isRefresh: true); + // } }, ), SizedBox( @@ -172,13 +172,13 @@ class _RemoteControlListPageState extends State with Rout fingerprintItemData.remoteName!, logic.getKeyType(fingerprintItemData), logic.getKeyDateType(fingerprintItemData), () async { - final data = await Get.toNamed(Routers.remoteControlDetailPage, + await Get.toNamed(Routers.remoteControlDetailPage, arguments: { 'fingerprintItemData': fingerprintItemData, - }); - if (data != null) { + })!.then((data) { getHttpData(isRefresh: true); - } + }); + }), ); },