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>{
'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!,

View File

@ -182,7 +182,13 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
arguments: <String, ElectronicKeyListItem>{
'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!,

View File

@ -154,7 +154,7 @@ class FingerprintDetailLogic extends BaseGetXController{
);
if(entity.errorCode!.codeIsSuccessful){
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_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -69,7 +68,8 @@ class _FingerprintListPageState extends State<FingerprintListPage>
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<FingerprintListPage>
fingerprintItemData.fingerprintName!,
logic.getKeyType(fingerprintItemData),
logic.getKeyDateType(fingerprintItemData), () async {
final data = await Get.toNamed(Routers.fingerprintDetailPage,
final data = await Get.toNamed(
Routers.fingerprintDetailPage,
arguments: <String, FingerprintItemData>{
'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!)

View File

@ -25,6 +25,7 @@ class PasswordKeyListLogic extends BaseGetXController {
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().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<PasswordKeyListEntity> mockNetworkDataRequest(
@ -396,10 +399,10 @@ class PasswordKeyListLogic extends BaseGetXController {
Future<void> 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

View File

@ -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<PasswordKeyListPage>
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<PasswordKeyListPage>
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () {
Navigator.pushNamed(
context, Routers.passwordKeyPerpetualPage,
arguments: <String, LockListInfoItemEntity>{'keyInfo': state.keyInfo.value})
.then((Object? val) {
context, Routers.passwordKeyPerpetualPage,
arguments: <String, LockListInfoItemEntity>{
'keyInfo': state.keyInfo.value
}).then((Object? val) {
if (val != null) {
getHttpData(isRefresh: true);
}
@ -146,7 +148,8 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
children: <Widget>[
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<PasswordKeyListPage>
),
child: _electronicKeyItem(index, 'images/icon_password.png',
passwordKeyListItem.keyboardPwdName!, useDateStr, () {
Navigator.pushNamed(context, Routers.passwordKeyDetailPage, arguments: <String, PasswordKeyListItem>{'itemData': passwordKeyListItem})
.then((Object? val) {
if (val != null) {
// getHttpData(isRefresh: true);
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
arguments: <String, PasswordKeyListItem>{
'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<PasswordKeyListPage>
));
}
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<PasswordKeyListPage>
]),
),
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)
],
),

View File

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