修改锁详情和锁列表删除锁、锁钥匙删除逻辑

This commit is contained in:
魏少阳 2024-04-11 17:59:19 +08:00
parent 7c84d86160
commit f693608672
8 changed files with 65 additions and 335 deletions

View File

@ -505,7 +505,6 @@
"员工是否有人脸":"员工是否有人脸",
"同时删除员工钥匙":"同时删除员工钥匙",
"删除":"删除",
"打卡方式无效":"打卡方式无效",
"确定要删除员工吗?":"确定要删除员工吗?",
"月统计":"月统计",
"迟到":"迟到",

View File

@ -1003,8 +1003,9 @@ class _LockDetailPageState extends State<LockDetailPage>
@override
void dispose() {
// TODO: implement dispose
///
print("LockDetailPage===dispose");
Get.log("LockDetailPage===dispose");
AppRouteObserver().routeObserver.unsubscribe(this);
state.closedUnlockSuccessfulTimer?.cancel();
_lockRefreshLockDetailInfoDataEvent?.cancel();
@ -1023,7 +1024,7 @@ class _LockDetailPageState extends State<LockDetailPage>
@override
void didPush() {
super.didPush();
print("LockDetailPage===didPush");
Get.log("LockDetailPage===didPush");
state.ifCurrentScreen.value = true;
}
@ -1031,7 +1032,7 @@ class _LockDetailPageState extends State<LockDetailPage>
@override
void didPop() {
super.didPop();
print("LockDetailPage===didPop");
Get.log("LockDetailPage===didPop");
state.ifCurrentScreen.value = false;
logic.cancelBlueConnetctToastTimer();
BlueManage().stopScan();
@ -1050,14 +1051,14 @@ class _LockDetailPageState extends State<LockDetailPage>
void didPopNext() {
super.didPopNext();
state.ifCurrentScreen.value = true;
print("LockDetailPage===didPopNext");
Get.log("LockDetailPage===didPopNext");
}
///
@override
void didPushNext() {
super.didPushNext();
print("LockDetailPage===didPushNext");
Get.log("LockDetailPage===didPushNext");
state.ifCurrentScreen.value = false;
logic.cancelBlueConnetctToastTimer();
BlueManage().stopScan();

View File

@ -44,7 +44,7 @@ class LockSetLogic extends BaseGetXController {
// }
//
if (reply is FactoryDataResetReply) {
if (reply is FactoryDataResetReply && (state.ifCurrentScreen.value == true)) {
_replyFactoryDataResetKey(reply);
}
@ -438,8 +438,6 @@ class LockSetLogic extends BaseGetXController {
state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!;
state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!;
// await _readSupportFunctionsNoParameters(56);
// _readSupportFunctionsNoParameters(62);
}
return entity;
}
@ -508,98 +506,25 @@ class LockSetLogic extends BaseGetXController {
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
// eventBus
_passCurrentLockInformationEvent = eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
// state.lockSetInfoData.value = event.lockSetInfoData;
// state.isAttendance.value = state.lockSetInfoData.value.lockSettingInfo!.attendance!;
// print("22222event.lockSetInfoData.lockSettingInfo!.autoLockSecond:${event.lockSetInfoData.lockSettingInfo!.autoLockSecond}");
// blockSetStateCallback();
getLockSettingInfoData();
});
}
// late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
// void _scanListDiscoveredDeviceSubscriptionAction() {
// _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
// final knownDeviceIndex = list.indexWhere((d) => d.name == BlueManage().connectDeviceName);
// if (knownDeviceIndex >= 0) {
// //
// state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString();
// }
// });
// }
void showDeletAlertTipDialog({String? showContent = ""}) {
var content = showContent!.isEmpty ? "删除设备失败,请确保在设备附近,设备未被连接,设备已打开${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮" : ""}" : showContent;
ShowTipView().showSureAlertDialog(content);
// showCupertinoDialog(context: Get.context!, builder: (context) {
// return CupertinoAlertDialog(
// title: const Text("提示"),
// content: Text(content),
// // content: const Text('删除门锁后如需重新添加需要在门锁设置的"蓝牙功能"选项下先"清除配对",确定吗?'),
// actions: [
// // CupertinoDialogAction(
// // child: Text(TranslationLoader.lanKeys!.cancel!.tr),
// // onPressed: () {
// // Navigator.pop(context);
// // },
// // ),
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.sure!.tr),
// onPressed: () {
// Navigator.pop(context);
// // if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
// // //
// // deletLockInfoData();
// // } else {
// // //
// // deletKeyData();
// // }
// },
// ),
// ],
// );
// },
// );
}
//
// void showCupertinoAlertDialog(widgetContext) {
// showCupertinoDialog(
// context: widgetContext,
// builder: (context) {
// return CupertinoAlertDialog(
// title: Text("提示".tr),
// content: const Text('创建公司后,考勤功能才能使用'),
// actions: [
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.cancel!.tr),
// onPressed: () {
// Get.back();
// },
// ),
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.sure!.tr),
// onPressed: () {
// Navigator.pop(context);
// Get.toNamed(Routers.checkInCreatCompanyPage, arguments: {
// 'lockSetInfoData': state.lockSetInfoData.value
// });
// },
// ),
// ],
// );
// },
// );
// }
///
deleyLockLogicOfRoles(){
if (state.lockBasicInfo.value.isLockOwner == 1) {
//
// showDeletAlertDialog();
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){
//
showDeletPasswordAlertDialog();
ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){
checkLoginPassword();
});
});
} else if (state.lockBasicInfo.value.keyRight == 1){
//
@ -608,114 +533,12 @@ class LockSetLogic extends BaseGetXController {
state.deleteAdministratorIsHaveAllData.value = a;
deletKeyData();
});
// showDeleteAdministratorIsHaveAllDataDialog();
} else{
//
deletKeyData();
}
}
//
// void showDeletAlertDialog() {
// showCupertinoDialog(
// context: Get.context!,
// builder: (context) {
// return CupertinoAlertDialog(
// title: const Text("提示"),
// content: const Text('删除锁后,所有信息都会一起删除,确定删除锁吗?'),
// actions: [
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.cancel!.tr),
// onPressed: () {
// Get.back();
// },
// ),
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.sure!.tr),
// onPressed: () {
// Get.back();
// showDeletPasswordAlertDialog();
// },
// ),
// ],
// );
// },
// );
// }
void showDeletPasswordAlertDialog() {
showDialog(
context: Get.context!,
builder: (BuildContext context) {
return ShowTFView(
title: "请输入登录密码".tr,
tipTitle: "",
controller: state.passwordTF,
sureClick: () {
//
if (state.passwordTF.text.isEmpty) {
showToast("请输入登录密码".tr);
return;
}
checkLoginPassword();
},
cancelClick: () {
//
// BlueManage().stopScan();
Get.back();
},
);
},
);
}
//
// void showDeleteAdministratorIsHaveAllDataDialog() {
// showDialog(
// context: Get.context!,
// builder: (BuildContext context) {
// return CupertinoAlertDialog(
// title: const Text("提示"),
// content: Container(
// height: 100.h,
// child: Row(
// children: [
// GestureDetector(
// onTap: () {
// state.deleteAdministratorIsHaveAllData.value = !state.deleteAdministratorIsHaveAllData.value;
// },
// child: Obx(() => Image.asset(
// state.deleteAdministratorIsHaveAllData.value
// ? 'images/icon_round_select.png'
// : 'images/icon_round_unSelect.png',
// width: 30.w,
// height: 30.w,
// ))),
// SizedBox(width: 15.w,),
// Expanded(child: Text('同时删除其发送的所有钥匙,钥匙删除后不能恢复', maxLines: 2, textAlign: TextAlign.start, style: TextStyle(fontSize: 24.sp))),
// ],
// ),
// ),
// actions: [
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.cancel!.tr),
// onPressed: () {
// Get.back();
// },
// ),
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.delete!.tr),
// onPressed: () {
// Get.back();
// deletKeyData();
// },
// ),
// ],
// );
// },
// );
// }
//
void checkLoginPassword() async {
var entity = await ApiRepository.to.checkLoginPassword(
@ -727,36 +550,10 @@ class LockSetLogic extends BaseGetXController {
}
}
//
// void deletLockLogic() {
// //
// if(state.currentDeviceUUid.value[31] == "1"){
// //
// // if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
// //
// factoryDataResetAction();
// // } else {
// // //
// // if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
// // //
// // deletUserAction();
// // }else{
// // //
// // deletKeyData();
// // }
// // }
// }else if(state.currentDeviceUUid.value[31] == "0"){
// //
// print("666666");
// // showDeletAlertTipDialog(showContent:"当前锁已被强制初始化,可直接添加。");
// deletLockInfoData();
// }
// }
//
void deletLockInfoData() async {
var entity = await ApiRepository.to.deletOwnerLockData(
lockId: state.lockSetInfoData.value.lockId.toString(),
lockId: state.lockSetInfoData.value.lockId!,
);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";

View File

@ -1,10 +1,8 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/tools/baseGetXController.dart';
@ -19,7 +17,7 @@ import '../../../common/XSConstantMacro/XSConstantMacro.dart';
import '../../../network/api_repository.dart';
import '../../../tools/dateTool.dart';
import '../../../tools/eventBusEventManage.dart';
import '../../../tools/showTFView.dart';
import '../../../tools/showTipView.dart';
import '../../../tools/storage.dart';
import '../../../translations/trans_lib.dart';
import '../entity/lockListInfo_entity.dart';
@ -31,14 +29,12 @@ class LockListLogic extends BaseGetXController{
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
//
if (reply is FactoryDataResetReply) {
_replyFactoryDataResetKey(reply);
}
});
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
//
if ((reply is FactoryDataResetReply) && (state.ifCurrentScreen.value == true)) {
_replyFactoryDataResetKey(reply);
}
});
}
Future<void> _replyFactoryDataResetKey(Reply reply) async {
@ -81,13 +77,13 @@ class LockListLogic extends BaseGetXController{
//
Get.log("${reply.commandType!.typeValue} ");
dismissEasyLoading();
showToast("权限校验错误");
// showToast("权限校验错误");
break;
default:
//
Get.log("${reply.commandType!.typeValue} 失败");
dismissEasyLoading();
showToast("权限校验错误");
// showToast("权限校验错误");
break;
}
}
@ -124,118 +120,26 @@ class LockListLogic extends BaseGetXController{
deleyLockLogicOfRoles(){
if (state.lockListInfoItemEntity.isLockOwner == 1) {
//
showDeletAlertDialog();
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){
//
ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){
checkLoginPassword();
});
});
} else if (state.lockListInfoItemEntity.keyRight == 1){
//
showDeleteAdministratorIsHaveAllDataDialog();
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog("同时删除其发送的所有钥匙,钥匙删除后不能恢复".tr, (a){
//
state.deleteAdministratorIsHaveAllData.value = a;
deletKeyData();
});
// showDeleteAdministratorIsHaveAllDataDialog();
} else{
//
deletKeyData();
}
}
//
void showDeletAlertDialog() {
showCupertinoDialog(
context: Get.context!,
builder: (context) {
return CupertinoAlertDialog(
title: Text("提示".tr),
content: Text('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr),
actions: [
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr),
onPressed: () {
Get.back();
showDeletPasswordAlertDialog(context);
},
),
],
);
},
);
}
void showDeletPasswordAlertDialog(BuildContext context) {
//
showDialog(
context: context,
builder: (BuildContext context) {
return ShowTFView(
title: "请输入登录密码".tr,
tipTitle: "",
controller: state.passwordTF,
sureClick: () {
//
if (state.passwordTF.text.isEmpty) {
showToast("请输入登录密码".tr);
return;
}
checkLoginPassword();
},
cancelClick: () {
//
// BlueManage().stopScan();
Get.back();
},
);
},
);
}
//
void showDeleteAdministratorIsHaveAllDataDialog() {
showDialog(
context: Get.context!,
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: Text("提示".tr),
content: SizedBox(
height: 100.h,
child: Row(
children: [
GestureDetector(
onTap: () {
state.deleteAdministratorIsHaveAllData.value = !state.deleteAdministratorIsHaveAllData.value;
},
child: Obx(() => Image.asset(
state.deleteAdministratorIsHaveAllData.value
? 'images/icon_round_select.png'
: 'images/icon_round_unSelect.png',
width: 30.w,
height: 30.w,
))),
SizedBox(width: 15.w,),
Expanded(child: Text('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, maxLines: 2, textAlign: TextAlign.start, style: TextStyle(fontSize: 24.sp))),
],
),
),
actions: [
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.delete!.tr),
onPressed: () {
Get.back();
deletKeyData();
},
),
],
);
},
);
}
//
void checkLoginPassword() async {
var entity = await ApiRepository.to.checkLoginPassword(
@ -250,7 +154,7 @@ class LockListLogic extends BaseGetXController{
//
void deletLockInfoData() async {
var entity = await ApiRepository.to.deletOwnerLockData(
lockId: state.lockListInfoItemEntity.lockId.toString(),
lockId: state.lockListInfoItemEntity.lockId!,
);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";

View File

@ -364,7 +364,7 @@ class ApiProvider extends BaseProvider {
}));
//
Future<Response> deletLockInfo(String lockId) => post(
Future<Response> deletLockInfo(int lockId) => post(
deletLockURL.toUrl,
jsonEncode({
'lockId': lockId,

View File

@ -34,7 +34,7 @@ class BaseProvider extends GetConnect with Api {
bool? isUnShowLoading = false, // loading
bool? isUserBaseUrl = true, // 使baseUrl
}) async {
// print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}");
Get.log("post: url:$url body:$body contentType:$contentType");
if (isUnShowLoading == false) EasyLoading.show();
// print('请求url======>$url');
if (isUserBaseUrl == false) {

View File

@ -398,7 +398,7 @@ class ApiRepository {
//
Future<LockListInfoEntity> deletOwnerLockData(
{required String lockId}) async {
{required int lockId}) async {
final res = await apiProvider.deletLockInfo(lockId);
return LockListInfoEntity.fromJson(res.body);
}

View File

@ -1,7 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/showTFView.dart';
import '../translations/trans_lib.dart';
import 'showDeleteAdministratorIsHaveAllDataWidget.dart';
@ -94,4 +96,31 @@ class ShowTipView {
);
}
void showTFViewAlertDialog(TextEditingController controller, String title, String tipTitle, Function sureClick) {
//
showDialog(
context: Get.context!,
builder: (BuildContext context) {
return ShowTFView(
title: title,
tipTitle: "",
controller: controller,
sureClick: () {
//
if (controller.text.isEmpty) {
EasyLoading.showToast(tipTitle, duration: 2000.milliseconds);
return;
}
sureClick();
},
cancelClick: () {
//
// BlueManage().stopScan();
Get.back();
},
);
},
);
}
}