修改锁详情和锁列表删除锁、锁钥匙删除逻辑
This commit is contained in:
parent
7c84d86160
commit
f693608672
@ -505,7 +505,6 @@
|
|||||||
"员工是否有人脸":"员工是否有人脸",
|
"员工是否有人脸":"员工是否有人脸",
|
||||||
"同时删除员工钥匙":"同时删除员工钥匙",
|
"同时删除员工钥匙":"同时删除员工钥匙",
|
||||||
"删除":"删除",
|
"删除":"删除",
|
||||||
"打卡方式无效":"打卡方式无效",
|
|
||||||
"确定要删除员工吗?":"确定要删除员工吗?",
|
"确定要删除员工吗?":"确定要删除员工吗?",
|
||||||
"月统计":"月统计",
|
"月统计":"月统计",
|
||||||
"迟到":"迟到",
|
"迟到":"迟到",
|
||||||
|
|||||||
@ -1003,8 +1003,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
// TODO: implement dispose
|
||||||
|
|
||||||
/// 取消路由订阅
|
/// 取消路由订阅
|
||||||
print("LockDetailPage===dispose");
|
Get.log("LockDetailPage===dispose");
|
||||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
state.closedUnlockSuccessfulTimer?.cancel();
|
state.closedUnlockSuccessfulTimer?.cancel();
|
||||||
_lockRefreshLockDetailInfoDataEvent?.cancel();
|
_lockRefreshLockDetailInfoDataEvent?.cancel();
|
||||||
@ -1023,7 +1024,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
@override
|
@override
|
||||||
void didPush() {
|
void didPush() {
|
||||||
super.didPush();
|
super.didPush();
|
||||||
print("LockDetailPage===didPush");
|
Get.log("LockDetailPage===didPush");
|
||||||
state.ifCurrentScreen.value = true;
|
state.ifCurrentScreen.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,7 +1032,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
@override
|
@override
|
||||||
void didPop() {
|
void didPop() {
|
||||||
super.didPop();
|
super.didPop();
|
||||||
print("LockDetailPage===didPop");
|
Get.log("LockDetailPage===didPop");
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
BlueManage().stopScan();
|
BlueManage().stopScan();
|
||||||
@ -1050,14 +1051,14 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
void didPopNext() {
|
void didPopNext() {
|
||||||
super.didPopNext();
|
super.didPopNext();
|
||||||
state.ifCurrentScreen.value = true;
|
state.ifCurrentScreen.value = true;
|
||||||
print("LockDetailPage===didPopNext");
|
Get.log("LockDetailPage===didPopNext");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 进入下级界面 当前界面即将消失
|
/// 进入下级界面 当前界面即将消失
|
||||||
@override
|
@override
|
||||||
void didPushNext() {
|
void didPushNext() {
|
||||||
super.didPushNext();
|
super.didPushNext();
|
||||||
print("LockDetailPage===didPushNext");
|
Get.log("LockDetailPage===didPushNext");
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
BlueManage().stopScan();
|
BlueManage().stopScan();
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// 恢复出厂设置
|
// 恢复出厂设置
|
||||||
if (reply is FactoryDataResetReply) {
|
if (reply is FactoryDataResetReply && (state.ifCurrentScreen.value == true)) {
|
||||||
_replyFactoryDataResetKey(reply);
|
_replyFactoryDataResetKey(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,8 +438,6 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||||
state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||||
// await _readSupportFunctionsNoParameters(56);
|
|
||||||
// _readSupportFunctionsNoParameters(62);
|
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@ -508,98 +506,25 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
||||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||||
_passCurrentLockInformationEvent = eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
|
_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();
|
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 = ""}) {
|
void showDeletAlertTipDialog({String? showContent = ""}) {
|
||||||
var content = showContent!.isEmpty ? "删除设备失败,请确保在设备附近,设备未被连接,设备已打开${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮" : ""}" : showContent;
|
var content = showContent!.isEmpty ? "删除设备失败,请确保在设备附近,设备未被连接,设备已打开${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮" : ""}" : showContent;
|
||||||
ShowTipView().showSureAlertDialog(content);
|
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(){
|
deleyLockLogicOfRoles(){
|
||||||
if (state.lockBasicInfo.value.isLockOwner == 1) {
|
if (state.lockBasicInfo.value.isLockOwner == 1) {
|
||||||
// 超级管理员必须通过连接蓝牙删除
|
// 超级管理员必须通过连接蓝牙删除
|
||||||
// showDeletAlertDialog();
|
|
||||||
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){
|
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){
|
||||||
// 删除锁
|
// 删除锁
|
||||||
showDeletPasswordAlertDialog();
|
ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){
|
||||||
|
checkLoginPassword();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else if (state.lockBasicInfo.value.keyRight == 1){
|
} else if (state.lockBasicInfo.value.keyRight == 1){
|
||||||
// 授权管理员弹框提示
|
// 授权管理员弹框提示
|
||||||
@ -608,114 +533,12 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
state.deleteAdministratorIsHaveAllData.value = a;
|
state.deleteAdministratorIsHaveAllData.value = a;
|
||||||
deletKeyData();
|
deletKeyData();
|
||||||
});
|
});
|
||||||
// showDeleteAdministratorIsHaveAllDataDialog();
|
|
||||||
} else{
|
} else{
|
||||||
// 普通用户直接删除
|
// 普通用户直接删除
|
||||||
deletKeyData();
|
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 {
|
void checkLoginPassword() async {
|
||||||
var entity = await ApiRepository.to.checkLoginPassword(
|
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 {
|
void deletLockInfoData() async {
|
||||||
var entity = await ApiRepository.to.deletOwnerLockData(
|
var entity = await ApiRepository.to.deletOwnerLockData(
|
||||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
lockId: state.lockSetInfoData.value.lockId!,
|
||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
BlueManage().connectDeviceMacAddress = "";
|
BlueManage().connectDeviceMacAddress = "";
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -19,7 +17,7 @@ import '../../../common/XSConstantMacro/XSConstantMacro.dart';
|
|||||||
import '../../../network/api_repository.dart';
|
import '../../../network/api_repository.dart';
|
||||||
import '../../../tools/dateTool.dart';
|
import '../../../tools/dateTool.dart';
|
||||||
import '../../../tools/eventBusEventManage.dart';
|
import '../../../tools/eventBusEventManage.dart';
|
||||||
import '../../../tools/showTFView.dart';
|
import '../../../tools/showTipView.dart';
|
||||||
import '../../../tools/storage.dart';
|
import '../../../tools/storage.dart';
|
||||||
import '../../../translations/trans_lib.dart';
|
import '../../../translations/trans_lib.dart';
|
||||||
import '../entity/lockListInfo_entity.dart';
|
import '../entity/lockListInfo_entity.dart';
|
||||||
@ -31,14 +29,12 @@ class LockListLogic extends BaseGetXController{
|
|||||||
// 监听蓝牙协议返回结果
|
// 监听蓝牙协议返回结果
|
||||||
late StreamSubscription<Reply> _replySubscription;
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
void _initReplySubscription() {
|
void _initReplySubscription() {
|
||||||
_replySubscription =
|
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
// 恢复出厂设置
|
||||||
// 恢复出厂设置
|
if ((reply is FactoryDataResetReply) && (state.ifCurrentScreen.value == true)) {
|
||||||
if (reply is FactoryDataResetReply) {
|
_replyFactoryDataResetKey(reply);
|
||||||
_replyFactoryDataResetKey(reply);
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _replyFactoryDataResetKey(Reply reply) async {
|
Future<void> _replyFactoryDataResetKey(Reply reply) async {
|
||||||
@ -81,13 +77,13 @@ class LockListLogic extends BaseGetXController{
|
|||||||
// 权限校验错误
|
// 权限校验错误
|
||||||
Get.log("${reply.commandType!.typeValue} ");
|
Get.log("${reply.commandType!.typeValue} ");
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
showToast("权限校验错误");
|
// showToast("权限校验错误");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//失败
|
//失败
|
||||||
Get.log("${reply.commandType!.typeValue} 失败");
|
Get.log("${reply.commandType!.typeValue} 失败");
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
showToast("权限校验错误");
|
// showToast("权限校验错误");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,118 +120,26 @@ class LockListLogic extends BaseGetXController{
|
|||||||
deleyLockLogicOfRoles(){
|
deleyLockLogicOfRoles(){
|
||||||
if (state.lockListInfoItemEntity.isLockOwner == 1) {
|
if (state.lockListInfoItemEntity.isLockOwner == 1) {
|
||||||
// 超级管理员必须通过连接蓝牙删除
|
// 超级管理员必须通过连接蓝牙删除
|
||||||
showDeletAlertDialog();
|
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){
|
||||||
|
// 删除锁
|
||||||
|
ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){
|
||||||
|
checkLoginPassword();
|
||||||
|
});
|
||||||
|
});
|
||||||
} else if (state.lockListInfoItemEntity.keyRight == 1){
|
} else if (state.lockListInfoItemEntity.keyRight == 1){
|
||||||
// 授权管理员弹框提示
|
// 授权管理员弹框提示
|
||||||
showDeleteAdministratorIsHaveAllDataDialog();
|
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog("同时删除其发送的所有钥匙,钥匙删除后不能恢复".tr, (a){
|
||||||
|
// 授权管理员删除
|
||||||
|
state.deleteAdministratorIsHaveAllData.value = a;
|
||||||
|
deletKeyData();
|
||||||
|
});
|
||||||
|
// showDeleteAdministratorIsHaveAllDataDialog();
|
||||||
} else{
|
} else{
|
||||||
// 普通用户直接删除
|
// 普通用户直接删除
|
||||||
deletKeyData();
|
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 {
|
void checkLoginPassword() async {
|
||||||
var entity = await ApiRepository.to.checkLoginPassword(
|
var entity = await ApiRepository.to.checkLoginPassword(
|
||||||
@ -250,7 +154,7 @@ class LockListLogic extends BaseGetXController{
|
|||||||
// 当是锁拥有者的时候,删除锁
|
// 当是锁拥有者的时候,删除锁
|
||||||
void deletLockInfoData() async {
|
void deletLockInfoData() async {
|
||||||
var entity = await ApiRepository.to.deletOwnerLockData(
|
var entity = await ApiRepository.to.deletOwnerLockData(
|
||||||
lockId: state.lockListInfoItemEntity.lockId.toString(),
|
lockId: state.lockListInfoItemEntity.lockId!,
|
||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
BlueManage().connectDeviceMacAddress = "";
|
BlueManage().connectDeviceMacAddress = "";
|
||||||
|
|||||||
@ -364,7 +364,7 @@ class ApiProvider extends BaseProvider {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// 删除锁
|
// 删除锁
|
||||||
Future<Response> deletLockInfo(String lockId) => post(
|
Future<Response> deletLockInfo(int lockId) => post(
|
||||||
deletLockURL.toUrl,
|
deletLockURL.toUrl,
|
||||||
jsonEncode({
|
jsonEncode({
|
||||||
'lockId': lockId,
|
'lockId': lockId,
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class BaseProvider extends GetConnect with Api {
|
|||||||
bool? isUnShowLoading = false, // 是否显示loading
|
bool? isUnShowLoading = false, // 是否显示loading
|
||||||
bool? isUserBaseUrl = true, // 文件上传不使用baseUrl
|
bool? isUserBaseUrl = true, // 文件上传不使用baseUrl
|
||||||
}) async {
|
}) 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();
|
if (isUnShowLoading == false) EasyLoading.show();
|
||||||
// print('请求url======>$url');
|
// print('请求url======>$url');
|
||||||
if (isUserBaseUrl == false) {
|
if (isUserBaseUrl == false) {
|
||||||
|
|||||||
@ -398,7 +398,7 @@ class ApiRepository {
|
|||||||
|
|
||||||
// 删除锁
|
// 删除锁
|
||||||
Future<LockListInfoEntity> deletOwnerLockData(
|
Future<LockListInfoEntity> deletOwnerLockData(
|
||||||
{required String lockId}) async {
|
{required int lockId}) async {
|
||||||
final res = await apiProvider.deletLockInfo(lockId);
|
final res = await apiProvider.deletLockInfo(lockId);
|
||||||
return LockListInfoEntity.fromJson(res.body);
|
return LockListInfoEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/tools/showTFView.dart';
|
||||||
|
|
||||||
import '../translations/trans_lib.dart';
|
import '../translations/trans_lib.dart';
|
||||||
import 'showDeleteAdministratorIsHaveAllDataWidget.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();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user