From a5154333450288bab11e69a0a14e5182e925f207 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 4 Jun 2024 18:05:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=AF=86=E7=A0=81/=E5=8D=A1/=E6=8C=87=E7=BA=B9/=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98/=E4=B8=8D=E4=BC=9A=E6=B6=88=E5=A4=B1?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorizedAdminList_page.dart | 8 ++- .../electronicKeyList_page.dart | 8 ++- .../fingerprintDetail_logic.dart | 2 +- .../fingerprintList/fingerprintList_page.dart | 15 +++-- .../passwordKeyList_logic.dart | 46 ++++++++------- .../passwordKeyList/passwordKeyList_page.dart | 56 +++++++++++++------ lib/network/api_provider.dart | 42 ++++++-------- 7 files changed, 107 insertions(+), 70 deletions(-) diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index cd1220d8..aac3c42e 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -151,7 +151,13 @@ class _AuthorizedAdminListPageState extends State { arguments: { 'itemData': indexEntity, }).then((Object? val) { - if (val != null) { + if (val == 'deletScuess') { + state.itemDataList.removeWhere( + ( ElectronicKeyListItem item) => + item.keyId == + indexEntity.keyId!); + setState(() {}); + } else if (val != null) { logic .refreshIndividualKeys( lockId: indexEntity.lockId!, diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 7359179c..153c3193 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -182,7 +182,13 @@ class _ElectronicKeyListPageState extends State { arguments: { 'itemData': indexEntity, }).then((Object? val) { - if (val != null) { + if (val == 'deletScuess') { + state.itemDataList.removeWhere( + ( ElectronicKeyListItem item) => + item.keyId == + indexEntity.keyId!); + setState(() {}); + } else if (val != null) { logic .refreshIndividualKeys( lockId: indexEntity.lockId!, diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart index 7d70c18c..5211aba8 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart @@ -154,7 +154,7 @@ class FingerprintDetailLogic extends BaseGetXController{ ); if(entity.errorCode!.codeIsSuccessful){ showToast('删除成功'.tr, something: (){ - Get.back(result: 'addScuess'); + Get.back(result: 'deletScuess'); }); } } diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index 107343c8..91865d3d 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_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'; @@ -69,7 +68,8 @@ class _FingerprintListPageState extends State 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 = '1'; state.deletFingerNo = 0; @@ -161,11 +161,18 @@ class _FingerprintListPageState extends State fingerprintItemData.fingerprintName!, logic.getKeyType(fingerprintItemData), logic.getKeyDateType(fingerprintItemData), () async { - final data = await Get.toNamed(Routers.fingerprintDetailPage, + final data = await Get.toNamed( + Routers.fingerprintDetailPage, arguments: { 'fingerprintItemData': fingerprintItemData, }); - if (data != null) { + if (data == 'deletScuess') { + state.fingerprintItemListData.removeWhere( + (FingerprintItemData item) => + item.fingerprintId == + fingerprintItemData.fingerprintId!); + setState(() {}); + } else if (data != null) { logic .refreshIndividualKeys( fingerprintId: fingerprintItemData.fingerprintId!) diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index 21572725..6e093bb8 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -25,6 +25,7 @@ class PasswordKeyListLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; + void _initReplySubscription() { _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { @@ -70,7 +71,8 @@ class PasswordKeyListLogic extends BaseGetXController { keyID: '0', userID: (await Storage.getUid())!, pwdNo: state.itemData.isCustom == 1 ? state.pwdNo : 0, - pwd: state.pwd, //state.deletPWD, + pwd: state.pwd, + //state.deletPWD, operate: state.itemData.isCustom == 1 ? 2 : 3, isAdmin: 0, useCountLimit: 0xffff, @@ -157,7 +159,8 @@ class PasswordKeyListLogic extends BaseGetXController { keyID: '0', userID: (await Storage.getUid())!, pwdNo: state.itemData.isCustom == 1 ? state.pwdNo : 0, - pwd: state.pwd, //state.deletPWD, + pwd: state.pwd, + //state.deletPWD, operate: state.itemData.isCustom == 1 ? 2 : 3, isAdmin: 0, useCountLimit: 0xffff, @@ -228,28 +231,28 @@ class PasswordKeyListLogic extends BaseGetXController { } /** - * //请求操作记录列表(门锁日志) - void mockNetworkDataRequest({required bool isRefresh}) async { - // 如果是下拉刷新,清空已有数据 - if (isRefresh) { + * //请求操作记录列表(门锁日志) + void mockNetworkDataRequest({required bool isRefresh}) async { + // 如果是下拉刷新,清空已有数据 + if (isRefresh) { state.lockLogItemList.clear(); pageNo = 1; - } - DoorLockLogEntity entity = await ApiRepository.to.lockEventList( - lockId: state.keyInfos.value.lockId!, - lockEventType: state.dropdownValue.value, - pageNo: pageNo, - pageSize: int.parse(pageSize), - startDate: state.startDate.value, - endDate: state.endDate.value); - if (entity.errorCode!.codeIsSuccessful) { + } + DoorLockLogEntity entity = await ApiRepository.to.lockEventList( + lockId: state.keyInfos.value.lockId!, + lockEventType: state.dropdownValue.value, + pageNo: pageNo, + pageSize: int.parse(pageSize), + startDate: state.startDate.value, + endDate: state.endDate.value); + if (entity.errorCode!.codeIsSuccessful) { // 更新数据列表 state.lockLogItemList.addAll(entity.data!.itemList!); // 更新页码 pageNo++; - } - } - */ + } + } + */ //请求密码钥匙列表 Future mockNetworkDataRequest( @@ -396,10 +399,10 @@ class PasswordKeyListLogic extends BaseGetXController { Future refreshIndividualKeys( {required int lockId, required int keyboardPwdId}) async { final PasswordKeyEntity entity = - await ApiRepository.to.passwordKey(lockId, keyboardPwdId); + await ApiRepository.to.passwordKey(lockId, keyboardPwdId); if (entity.errorCode!.codeIsSuccessful) { - final int index = state.itemDataList - .indexWhere((PasswordKeyListItem item) => item.keyboardPwdId == keyboardPwdId); + final int index = state.itemDataList.indexWhere( + (PasswordKeyListItem item) => item.keyboardPwdId == keyboardPwdId); state.itemDataList.removeAt(index); state.itemDataList.insert(index, entity.data!); } @@ -407,6 +410,7 @@ class PasswordKeyListLogic extends BaseGetXController { /// 刷新密码列表 StreamSubscription? _getPasswordListRefreshUIEvent; + void _getPasswordListRefreshUIAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _getPasswordListRefreshUIEvent = eventBus diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index b6c79629..4ed1ff0a 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; @@ -64,13 +63,15 @@ class _PasswordKeyListPageState extends State style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () async { - final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { if (state.itemDataList.isEmpty) { logic.showToast('暂无密码,无需重置'.tr); return; } - ShowTipView().showIosTipWithContentDialog('该锁的密码都将被删除'.tr, logic.getUserInfoRequest); + ShowTipView().showIosTipWithContentDialog( + '该锁的密码都将被删除'.tr, logic.getUserInfoRequest); } else { logic.showToast('演示模式'.tr); } @@ -105,9 +106,10 @@ class _PasswordKeyListPageState extends State btnName: TranslationLoader.lanKeys!.getPassword!.tr, onClick: () { Navigator.pushNamed( - context, Routers.passwordKeyPerpetualPage, - arguments: {'keyInfo': state.keyInfo.value}) - .then((Object? val) { + context, Routers.passwordKeyPerpetualPage, + arguments: { + 'keyInfo': state.keyInfo.value + }).then((Object? val) { if (val != null) { getHttpData(isRefresh: true); } @@ -146,7 +148,8 @@ class _PasswordKeyListPageState extends State children: [ SlidableAction( onPressed: (BuildContext context) { - ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { + ShowTipView().showIosTipWithContentDialog( + '确定要删除吗?'.tr, () async { state.itemData = passwordKeyListItem; state.pwdNo = passwordKeyListItem.pwdUserNo!; state.pwd = passwordKeyListItem.keyboardPwd!; @@ -162,10 +165,23 @@ class _PasswordKeyListPageState extends State ), child: _electronicKeyItem(index, 'images/icon_password.png', passwordKeyListItem.keyboardPwdName!, useDateStr, () { - Navigator.pushNamed(context, Routers.passwordKeyDetailPage, arguments: {'itemData': passwordKeyListItem}) - .then((Object? val) { - if (val != null) { - // getHttpData(isRefresh: true); + Navigator.pushNamed(context, 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(() {})); } }); }), @@ -181,8 +197,10 @@ class _PasswordKeyListPageState extends State )); } - Widget _electronicKeyItem(int itemIndex, String lockTypeIcon, String lockTypeTitle, String useDateStr, Function()? action) { - final PasswordKeyListItem passwordKeyListItem = state.itemDataList[itemIndex]; + Widget _electronicKeyItem(int itemIndex, String lockTypeIcon, + String lockTypeTitle, String useDateStr, Function()? action) { + final PasswordKeyListItem passwordKeyListItem = + state.itemDataList[itemIndex]; return GestureDetector( onTap: action, @@ -223,11 +241,13 @@ class _PasswordKeyListPageState extends State ]), ), SizedBox(width: 10.w), - if (passwordKeyListItem.keyboardPwdStatus == 2) Text( - '已过期'.tr, - style: - TextStyle(color: Colors.red, fontSize: 20.sp), - ) else Container(), + if (passwordKeyListItem.keyboardPwdStatus == 2) + Text( + '已过期'.tr, + style: TextStyle(color: Colors.red, fontSize: 20.sp), + ) + else + Container(), // SizedBox(width: 15.w) ], ), diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 81804437..3c2b6aa4 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -126,15 +126,12 @@ class ApiProvider extends BaseProvider { 'searchStr': searchStr })); - Future electronicKey( - int lockId, int keyId - ) => - post( - keydetail.toUrl, - jsonEncode({ - 'lockId': lockId.toString(), - 'keyId': keyId.toString(), - })); + Future electronicKey(int lockId, int keyId) => post( + keydetail.toUrl, + jsonEncode({ + 'lockId': lockId.toString(), + 'keyId': keyId.toString(), + })); Future sendElectronicKey( int createUser, @@ -449,13 +446,12 @@ class ApiProvider extends BaseProvider { 'searchStr': searchStr })); - Future passwordKey(int lockId, int keyboardPwdId,) => - post( - passwordKeyDetailURL.toUrl, - jsonEncode({ - 'lockId': lockId, - 'keyboardPwdId': keyboardPwdId - })); + Future passwordKey( + int lockId, + int keyboardPwdId, + ) => + post(passwordKeyDetailURL.toUrl, + jsonEncode({'lockId': lockId, 'keyboardPwdId': keyboardPwdId})); Future resetPasswordKey(String lockId, String operatorUid) => post( resetPasswordURL.toUrl, @@ -1116,17 +1112,15 @@ class ApiProvider extends BaseProvider { })); // 获取指纹详情 - Future getFingerprintsData( - int fingerprintId) => - post( - getFingerprintDetailURL.toUrl, - jsonEncode({ - 'fingerprintId': fingerprintId, - })); + Future getFingerprintsData(int fingerprintId) => post( + getFingerprintDetailURL.toUrl, + jsonEncode({ + 'fingerprintId': fingerprintId, + })); // 获取指纹列表 Future getFingerprintsListData( - String lockId, String pageNo, String pageSize, String searchStr) => + String lockId, String pageNo, String pageSize, String searchStr) => post( getFingerprintListURL.toUrl, jsonEncode({