From f6936086720a315d05dbb5d006e5ebfacfc60ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 11 Apr 2024 17:59:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=81=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=92=8C=E9=94=81=E5=88=97=E8=A1=A8=E5=88=A0=E9=99=A4=E9=94=81?= =?UTF-8?q?=E3=80=81=E9=94=81=E9=92=A5=E5=8C=99=E5=88=A0=E9=99=A4=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_keys.json | 1 - .../lockDetail/lockDetail_page.dart | 11 +- .../lockSet/lockSet/lockSet_logic.dart | 213 +----------------- .../lockMian/lockList/lockList_logic.dart | 140 ++---------- star_lock/lib/network/api_provider.dart | 2 +- star_lock/lib/network/api_provider_base.dart | 2 +- star_lock/lib/network/api_repository.dart | 2 +- star_lock/lib/tools/showTipView.dart | 29 +++ 8 files changed, 65 insertions(+), 335 deletions(-) diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index e914b36c..db7f805f 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -505,7 +505,6 @@ "员工是否有人脸":"员工是否有人脸", "同时删除员工钥匙":"同时删除员工钥匙", "删除":"删除", - "打卡方式无效":"打卡方式无效", "确定要删除员工吗?":"确定要删除员工吗?", "月统计":"月统计", "迟到":"迟到", diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index d9c20246..008fe933 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1003,8 +1003,9 @@ class _LockDetailPageState extends State @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 @override void didPush() { super.didPush(); - print("LockDetailPage===didPush"); + Get.log("LockDetailPage===didPush"); state.ifCurrentScreen.value = true; } @@ -1031,7 +1032,7 @@ class _LockDetailPageState extends State @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 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(); diff --git a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart index 4096bec8..afd07a2b 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart @@ -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().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>_scanListDiscoveredDeviceSubscription; - // void _scanListDiscoveredDeviceSubscriptionAction() { - // _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on>().listen((List 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 = ""; diff --git a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart index 17bb0f22..e0316bcd 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart @@ -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 _replySubscription; void _initReplySubscription() { - _replySubscription = - EventBusManager().eventBus!.on().listen((reply) async { - // 恢复出厂设置 - if (reply is FactoryDataResetReply) { - _replyFactoryDataResetKey(reply); - } - - }); + _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + // 恢复出厂设置 + if ((reply is FactoryDataResetReply) && (state.ifCurrentScreen.value == true)) { + _replyFactoryDataResetKey(reply); + } + }); } Future _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 = ""; diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 82a4470b..b4e0d1e2 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -364,7 +364,7 @@ class ApiProvider extends BaseProvider { })); // 删除锁 - Future deletLockInfo(String lockId) => post( + Future deletLockInfo(int lockId) => post( deletLockURL.toUrl, jsonEncode({ 'lockId': lockId, diff --git a/star_lock/lib/network/api_provider_base.dart b/star_lock/lib/network/api_provider_base.dart index 60158673..04273d85 100644 --- a/star_lock/lib/network/api_provider_base.dart +++ b/star_lock/lib/network/api_provider_base.dart @@ -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) { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 095a094d..c4ed9d54 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -398,7 +398,7 @@ class ApiRepository { // 删除锁 Future deletOwnerLockData( - {required String lockId}) async { + {required int lockId}) async { final res = await apiProvider.deletLockInfo(lockId); return LockListInfoEntity.fromJson(res.body); } diff --git a/star_lock/lib/tools/showTipView.dart b/star_lock/lib/tools/showTipView.dart index 2dc8384d..225f7015 100644 --- a/star_lock/lib/tools/showTipView.dart +++ b/star_lock/lib/tools/showTipView.dart @@ -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(); + }, + ); + }, + ); + } + } \ No newline at end of file