fix:修复删除密码/卡/指纹/管理员/不会消失的问题

This commit is contained in:
anfe 2024-06-04 18:05:33 +08:00
parent 9174935452
commit a515433345
7 changed files with 107 additions and 70 deletions

View File

@ -151,7 +151,13 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
arguments: <String, ElectronicKeyListItem>{ arguments: <String, ElectronicKeyListItem>{
'itemData': indexEntity, 'itemData': indexEntity,
}).then((Object? val) { }).then((Object? val) {
if (val != null) { if (val == 'deletScuess') {
state.itemDataList.removeWhere(
( ElectronicKeyListItem item) =>
item.keyId ==
indexEntity.keyId!);
setState(() {});
} else if (val != null) {
logic logic
.refreshIndividualKeys( .refreshIndividualKeys(
lockId: indexEntity.lockId!, lockId: indexEntity.lockId!,

View File

@ -182,7 +182,13 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
arguments: <String, ElectronicKeyListItem>{ arguments: <String, ElectronicKeyListItem>{
'itemData': indexEntity, 'itemData': indexEntity,
}).then((Object? val) { }).then((Object? val) {
if (val != null) { if (val == 'deletScuess') {
state.itemDataList.removeWhere(
( ElectronicKeyListItem item) =>
item.keyId ==
indexEntity.keyId!);
setState(() {});
} else if (val != null) {
logic logic
.refreshIndividualKeys( .refreshIndividualKeys(
lockId: indexEntity.lockId!, lockId: indexEntity.lockId!,

View File

@ -154,7 +154,7 @@ class FingerprintDetailLogic extends BaseGetXController{
); );
if(entity.errorCode!.codeIsSuccessful){ if(entity.errorCode!.codeIsSuccessful){
showToast('删除成功'.tr, something: (){ showToast('删除成功'.tr, something: (){
Get.back(result: 'addScuess'); Get.back(result: 'deletScuess');
}); });
} }
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -69,7 +68,8 @@ class _FingerprintListPageState extends State<FingerprintListPage>
onPressed: () async { onPressed: () async {
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) { if (isDemoMode == false) {
ShowTipView().showIosTipWithContentDialog('重置后,该锁的指纹都将被删除哦,确认要重置吗?'.tr, () async { ShowTipView().showIosTipWithContentDialog(
'重置后,该锁的指纹都将被删除哦,确认要重置吗?'.tr, () async {
state.isDeletAll = true; state.isDeletAll = true;
state.deletKeyID = '1'; state.deletKeyID = '1';
state.deletFingerNo = 0; state.deletFingerNo = 0;
@ -161,11 +161,18 @@ class _FingerprintListPageState extends State<FingerprintListPage>
fingerprintItemData.fingerprintName!, fingerprintItemData.fingerprintName!,
logic.getKeyType(fingerprintItemData), logic.getKeyType(fingerprintItemData),
logic.getKeyDateType(fingerprintItemData), () async { logic.getKeyDateType(fingerprintItemData), () async {
final data = await Get.toNamed(Routers.fingerprintDetailPage, final data = await Get.toNamed(
Routers.fingerprintDetailPage,
arguments: <String, FingerprintItemData>{ arguments: <String, FingerprintItemData>{
'fingerprintItemData': fingerprintItemData, 'fingerprintItemData': fingerprintItemData,
}); });
if (data != null) { if (data == 'deletScuess') {
state.fingerprintItemListData.removeWhere(
(FingerprintItemData item) =>
item.fingerprintId ==
fingerprintItemData.fingerprintId!);
setState(() {});
} else if (data != null) {
logic logic
.refreshIndividualKeys( .refreshIndividualKeys(
fingerprintId: fingerprintItemData.fingerprintId!) fingerprintId: fingerprintItemData.fingerprintId!)

View File

@ -25,6 +25,7 @@ class PasswordKeyListLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) { EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
@ -70,7 +71,8 @@ class PasswordKeyListLogic extends BaseGetXController {
keyID: '0', keyID: '0',
userID: (await Storage.getUid())!, userID: (await Storage.getUid())!,
pwdNo: state.itemData.isCustom == 1 ? state.pwdNo : 0, 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, operate: state.itemData.isCustom == 1 ? 2 : 3,
isAdmin: 0, isAdmin: 0,
useCountLimit: 0xffff, useCountLimit: 0xffff,
@ -157,7 +159,8 @@ class PasswordKeyListLogic extends BaseGetXController {
keyID: '0', keyID: '0',
userID: (await Storage.getUid())!, userID: (await Storage.getUid())!,
pwdNo: state.itemData.isCustom == 1 ? state.pwdNo : 0, 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, operate: state.itemData.isCustom == 1 ? 2 : 3,
isAdmin: 0, isAdmin: 0,
useCountLimit: 0xffff, useCountLimit: 0xffff,
@ -398,8 +401,8 @@ class PasswordKeyListLogic extends BaseGetXController {
final PasswordKeyEntity entity = final PasswordKeyEntity entity =
await ApiRepository.to.passwordKey(lockId, keyboardPwdId); await ApiRepository.to.passwordKey(lockId, keyboardPwdId);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
final int index = state.itemDataList final int index = state.itemDataList.indexWhere(
.indexWhere((PasswordKeyListItem item) => item.keyboardPwdId == keyboardPwdId); (PasswordKeyListItem item) => item.keyboardPwdId == keyboardPwdId);
state.itemDataList.removeAt(index); state.itemDataList.removeAt(index);
state.itemDataList.insert(index, entity.data!); state.itemDataList.insert(index, entity.data!);
} }
@ -407,6 +410,7 @@ class PasswordKeyListLogic extends BaseGetXController {
/// ///
StreamSubscription? _getPasswordListRefreshUIEvent; StreamSubscription? _getPasswordListRefreshUIEvent;
void _getPasswordListRefreshUIAction() { void _getPasswordListRefreshUIAction() {
// eventBus // eventBus
_getPasswordListRefreshUIEvent = eventBus _getPasswordListRefreshUIEvent = eventBus

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
@ -64,13 +63,15 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
style: TextStyle(color: Colors.white, fontSize: 24.sp), style: TextStyle(color: Colors.white, fontSize: 24.sp),
), ),
onPressed: () async { onPressed: () async {
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); final bool? isDemoMode =
await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) { if (isDemoMode == false) {
if (state.itemDataList.isEmpty) { if (state.itemDataList.isEmpty) {
logic.showToast('暂无密码,无需重置'.tr); logic.showToast('暂无密码,无需重置'.tr);
return; return;
} }
ShowTipView().showIosTipWithContentDialog('该锁的密码都将被删除'.tr, logic.getUserInfoRequest); ShowTipView().showIosTipWithContentDialog(
'该锁的密码都将被删除'.tr, logic.getUserInfoRequest);
} else { } else {
logic.showToast('演示模式'.tr); logic.showToast('演示模式'.tr);
} }
@ -106,8 +107,9 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
onClick: () { onClick: () {
Navigator.pushNamed( Navigator.pushNamed(
context, Routers.passwordKeyPerpetualPage, context, Routers.passwordKeyPerpetualPage,
arguments: <String, LockListInfoItemEntity>{'keyInfo': state.keyInfo.value}) arguments: <String, LockListInfoItemEntity>{
.then((Object? val) { 'keyInfo': state.keyInfo.value
}).then((Object? val) {
if (val != null) { if (val != null) {
getHttpData(isRefresh: true); getHttpData(isRefresh: true);
} }
@ -146,7 +148,8 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
children: <Widget>[ children: <Widget>[
SlidableAction( SlidableAction(
onPressed: (BuildContext context) { onPressed: (BuildContext context) {
ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { ShowTipView().showIosTipWithContentDialog(
'确定要删除吗?'.tr, () async {
state.itemData = passwordKeyListItem; state.itemData = passwordKeyListItem;
state.pwdNo = passwordKeyListItem.pwdUserNo!; state.pwdNo = passwordKeyListItem.pwdUserNo!;
state.pwd = passwordKeyListItem.keyboardPwd!; state.pwd = passwordKeyListItem.keyboardPwd!;
@ -162,10 +165,23 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
), ),
child: _electronicKeyItem(index, 'images/icon_password.png', child: _electronicKeyItem(index, 'images/icon_password.png',
passwordKeyListItem.keyboardPwdName!, useDateStr, () { passwordKeyListItem.keyboardPwdName!, useDateStr, () {
Navigator.pushNamed(context, Routers.passwordKeyDetailPage, arguments: <String, PasswordKeyListItem>{'itemData': passwordKeyListItem}) Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
.then((Object? val) { arguments: <String, PasswordKeyListItem>{
if (val != null) { 'itemData': passwordKeyListItem
// getHttpData(isRefresh: true); }).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<PasswordKeyListPage>
)); ));
} }
Widget _electronicKeyItem(int itemIndex, String lockTypeIcon, String lockTypeTitle, String useDateStr, Function()? action) { Widget _electronicKeyItem(int itemIndex, String lockTypeIcon,
final PasswordKeyListItem passwordKeyListItem = state.itemDataList[itemIndex]; String lockTypeTitle, String useDateStr, Function()? action) {
final PasswordKeyListItem passwordKeyListItem =
state.itemDataList[itemIndex];
return GestureDetector( return GestureDetector(
onTap: action, onTap: action,
@ -223,11 +241,13 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
]), ]),
), ),
SizedBox(width: 10.w), SizedBox(width: 10.w),
if (passwordKeyListItem.keyboardPwdStatus == 2) Text( if (passwordKeyListItem.keyboardPwdStatus == 2)
Text(
'已过期'.tr, '已过期'.tr,
style: style: TextStyle(color: Colors.red, fontSize: 20.sp),
TextStyle(color: Colors.red, fontSize: 20.sp), )
) else Container(), else
Container(),
// SizedBox(width: 15.w) // SizedBox(width: 15.w)
], ],
), ),

View File

@ -126,10 +126,7 @@ class ApiProvider extends BaseProvider {
'searchStr': searchStr 'searchStr': searchStr
})); }));
Future<Response> electronicKey( Future<Response> electronicKey(int lockId, int keyId) => post(
int lockId, int keyId
) =>
post(
keydetail.toUrl, keydetail.toUrl,
jsonEncode({ jsonEncode({
'lockId': lockId.toString(), 'lockId': lockId.toString(),
@ -449,13 +446,12 @@ class ApiProvider extends BaseProvider {
'searchStr': searchStr 'searchStr': searchStr
})); }));
Future<Response> passwordKey(int lockId, int keyboardPwdId,) => Future<Response> passwordKey(
post( int lockId,
passwordKeyDetailURL.toUrl, int keyboardPwdId,
jsonEncode({ ) =>
'lockId': lockId, post(passwordKeyDetailURL.toUrl,
'keyboardPwdId': keyboardPwdId jsonEncode({'lockId': lockId, 'keyboardPwdId': keyboardPwdId}));
}));
Future<Response> resetPasswordKey(String lockId, String operatorUid) => post( Future<Response> resetPasswordKey(String lockId, String operatorUid) => post(
resetPasswordURL.toUrl, resetPasswordURL.toUrl,
@ -1116,9 +1112,7 @@ class ApiProvider extends BaseProvider {
})); }));
// //
Future<Response> getFingerprintsData( Future<Response> getFingerprintsData(int fingerprintId) => post(
int fingerprintId) =>
post(
getFingerprintDetailURL.toUrl, getFingerprintDetailURL.toUrl,
jsonEncode({ jsonEncode({
'fingerprintId': fingerprintId, 'fingerprintId': fingerprintId,