Merge branch 'master' into talk_flutter
# Conflicts: # star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart # star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart 代码合并
This commit is contained in:
commit
4a131c88f5
@ -409,6 +409,8 @@
|
||||
"edit":"Edit",
|
||||
"stressFingerprint":"Stress Fingerprint",
|
||||
"effectiveDay":"Effective Day",
|
||||
"stressCard":"Stress Card",
|
||||
"stressPassword":"Stress Password",
|
||||
|
||||
"whetherTheEmployeeHasPassword":"If The Employee Has A Password",
|
||||
"whetherTheEmployeeHasCard":"If The Employee Has A Card",
|
||||
|
||||
@ -409,6 +409,8 @@
|
||||
"edit":"edit",
|
||||
"stressFingerprint":"stressFingerprint",
|
||||
"effectiveDay":"effectiveDay",
|
||||
"stressPassword":"stressPassword",
|
||||
"stressCard":"stressCard",
|
||||
|
||||
"whetherTheEmployeeHasPassword":"whetherTheEmployeeHasPassword",
|
||||
"whetherTheEmployeeHasCard":"whetherTheEmployeeHasCard",
|
||||
|
||||
@ -412,6 +412,8 @@
|
||||
"edit":"编辑",
|
||||
"stressFingerprint":"胁迫指纹",
|
||||
"effectiveDay":"有效日",
|
||||
"stressCard":"胁迫卡",
|
||||
"stressPassword":"胁迫密码",
|
||||
|
||||
"whetherTheEmployeeHasPassword":"员工是否有密码",
|
||||
"whetherTheEmployeeHasCard":"员工是否有卡",
|
||||
|
||||
@ -195,7 +195,7 @@ SPEC CHECKSUMS:
|
||||
google_maps_flutter_ios: abdac20d6ce8931f6ebc5f46616df241bfaa2cfd
|
||||
GoogleMaps: 025272d5876d3b32604e5c080dc25eaf68764693
|
||||
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
|
||||
network_info_plus: 122280582fe2fa2bbb8681a4269745cd5c3a9b32
|
||||
network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f
|
||||
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
|
||||
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
|
||||
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
|
||||
|
||||
@ -15,7 +15,6 @@ import 'package:star_lock/main/lockDetail/lcokSet/msgNotification/msgNotificatio
|
||||
import 'package:star_lock/main/lockDetail/lcokSet/notificationMode/notificationMode_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/otherTypeKey/addFace/addFace_page.dart';
|
||||
import 'package:star_lock/mine/about/webviewShow_page.dart';
|
||||
import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart';
|
||||
@ -37,6 +36,12 @@ import 'login/forgetPassword/starLock_forgetPassword_page.dart';
|
||||
import 'login/login/starLock_login_page.dart';
|
||||
import 'login/register/starLock_register_page.dart';
|
||||
import 'login/seletCountryRegion/seletCountryRegion_page.dart';
|
||||
import 'main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_page.dart';
|
||||
import 'main/lockDetail/card/addICCard/addICCard_page.dart';
|
||||
import 'main/lockDetail/card/cardDetail/cardDetail_page.dart';
|
||||
import 'main/lockDetail/card/cardList/cardList_page.dart';
|
||||
import 'main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart';
|
||||
import 'main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart';
|
||||
import 'main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart';
|
||||
import 'main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart';
|
||||
import 'main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart';
|
||||
@ -49,6 +54,14 @@ import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkin
|
||||
import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart';
|
||||
import 'main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart';
|
||||
import 'main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart';
|
||||
import 'main/lockDetail/face/addFace/addFace_page.dart';
|
||||
import 'main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart';
|
||||
import 'main/lockDetail/face/faceList/faceList_page.dart';
|
||||
import 'main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart';
|
||||
import 'main/lockDetail/fingerprint/addFingerprintSeletType/addFingerprintManage/addFingerprintTypeManage_page.dart';
|
||||
import 'main/lockDetail/fingerprint/addFingerprintTip/addFingerprintTip_page.dart';
|
||||
import 'main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart';
|
||||
import 'main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart';
|
||||
import 'main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart';
|
||||
import 'main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_page.dart';
|
||||
import 'main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart';
|
||||
@ -86,11 +99,8 @@ import 'main/lockDetail/lcokSet/wirelessKeyboard/seletWirelessKeyboard/seletWire
|
||||
import 'main/lockDetail/lcokSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart';
|
||||
import 'main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart';
|
||||
import 'main/lockDetail/monitoring/monitoringRealTimeScreen/monitoringRealTimeScreen_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addICCard/addICCard_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart';
|
||||
import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_page.dart';
|
||||
import 'main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart';
|
||||
import 'main/lockDetail/videoLog/editVideoLog/editVideoLog_page.dart';
|
||||
import 'main/lockDetail/videoLog/videoLog/videoLog_page.dart';
|
||||
import 'main/lockDetail/videoLog/videoLogDetail/videoLogDetail_page.dart';
|
||||
@ -111,9 +121,6 @@ import 'main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicMa
|
||||
import 'main/lockDetail/electronicKey/sendElectronicKey/sendElectronicManageKey/sendElectronicKeyManage_page.dart';
|
||||
import 'main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart';
|
||||
import 'main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_page.dart';
|
||||
import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart';
|
||||
import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart';
|
||||
import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart';
|
||||
@ -190,11 +197,9 @@ abstract class Routers {
|
||||
static const passwordKeyListPage = '/PasswordKeyListPage'; // 密码钥匙列表
|
||||
static const passwordKeyManagePage = '/PasswordKeyManagePage'; // 密码钥匙
|
||||
static const passwordKeyDetailPage = '/PasswordKeyDetailPage'; // 密码钥匙详情
|
||||
static const otherTypeKeyListPage = '/OtherTypeKeyListPage'; // 卡、指纹、遥控钥匙列表
|
||||
static const otherTypeKeyDetailPage =
|
||||
'/OtherTypeKeyDetailPage'; // 卡、指纹、遥控钥匙详情
|
||||
static const otherTypeKeyManagePage =
|
||||
'/OtherTypeKeyManagePage'; // 卡、指纹、遥控钥匙添加
|
||||
// static const otherTypeKeyListPage = '/OtherTypeKeyListPage'; // 卡、指纹、遥控钥匙列表
|
||||
// static const otherTypeKeyDetailPage = '/OtherTypeKeyDetailPage'; // 卡、指纹、遥控钥匙详情
|
||||
// static const otherTypeKeyManagePage = '/OtherTypeKeyManagePage'; // 卡、指纹、遥控钥匙添加
|
||||
static const otherTypeKeyChangeDatePage =
|
||||
'/OtherTypeKeyChangeDatePage'; // 卡、指纹、遥控钥匙详情修改日期
|
||||
static const otherTypeKeyChangeValidityDatePage =
|
||||
@ -383,6 +388,18 @@ abstract class Routers {
|
||||
static const editVideoLogPage = '/EditVideoLogPage'; // 编辑视频日志
|
||||
static const videoLogDetailPage = '/VideoLogDetailPage'; // 视频日志详情
|
||||
static const videoLogDownLoadPage = '/VideoLogDownLoadPage'; // 视频下载列表
|
||||
|
||||
static const remoteControlListPage = '/RemoteControlListPage'; // 遥控列表
|
||||
static const addRemoteControlManagePage = '/AddRemoteControlManagePage'; // 添加遥控
|
||||
|
||||
static const cardListPage = '/CardListPage'; // 卡列表
|
||||
static const addCardTypeManagePage = '/AddCardTypeManagePage'; // 添加卡
|
||||
static const cardDetailPage = '/CardDetailPage'; // 卡详情
|
||||
static const fingerprintListPage = '/FingerprintListPage'; // 指纹列表
|
||||
static const addFingerprintTypeManagePage = '/AddFingerprintTypeManagePage'; // 添加指纹
|
||||
static const fingerprintDetailPage = '/FingerprintDetailPage'; // 指纹详情
|
||||
static const faceList = '/FaceList'; // 人脸列表
|
||||
static const addFaceTypeManagePage = '/AddFaceTypeManagePage'; // 添加人脸
|
||||
}
|
||||
|
||||
abstract class AppRouters {
|
||||
@ -459,18 +476,18 @@ abstract class AppRouters {
|
||||
name: Routers.passwordKeyDetailPage,
|
||||
page: () => const PasswordKeyDetailPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routers.otherTypeKeyListPage,
|
||||
page: () => const OtherTypeKeyListPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routers.otherTypeKeyDetailPage,
|
||||
page: () => const OtherTypeKeyDetailPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routers.otherTypeKeyManagePage,
|
||||
page: () => const OtherTypeKeyManagePage(),
|
||||
),
|
||||
// GetPage(
|
||||
// name: Routers.otherTypeKeyListPage,
|
||||
// page: () => const OtherTypeKeyListPage(),
|
||||
// ),
|
||||
// GetPage(
|
||||
// name: Routers.otherTypeKeyDetailPage,
|
||||
// page: () => const OtherTypeKeyDetailPage(),
|
||||
// ),
|
||||
// GetPage(
|
||||
// name: Routers.otherTypeKeyManagePage,
|
||||
// page: () => const OtherTypeKeyManagePage(),
|
||||
// ),
|
||||
GetPage(
|
||||
name: Routers.authorizedAdminListPage,
|
||||
page: () => const AuthorizedAdminListPage(),
|
||||
@ -942,5 +959,35 @@ abstract class AppRouters {
|
||||
GetPage(
|
||||
name: Routers.videoLogDownLoadPage,
|
||||
page: () => const VideoLogDownLoadPage()),
|
||||
GetPage(
|
||||
name: Routers.remoteControlListPage,
|
||||
page: () => const RemoteControlListPage()),
|
||||
GetPage(
|
||||
name: Routers.addRemoteControlManagePage,
|
||||
page: () => const AddRemoteControlManagePage()),
|
||||
GetPage(
|
||||
name: Routers.cardListPage,
|
||||
page: () => const CardListPage()),
|
||||
GetPage(
|
||||
name: Routers.addCardTypeManagePage,
|
||||
page: () => const AddCardTypeManagePage()),
|
||||
GetPage(
|
||||
name: Routers.cardDetailPage,
|
||||
page: () => const CardDetailPage()),
|
||||
GetPage(
|
||||
name: Routers.fingerprintListPage,
|
||||
page: () => const FingerprintListPage()),
|
||||
GetPage(
|
||||
name: Routers.addFingerprintTypeManagePage,
|
||||
page: () => const AddFingerprintTypeManagePage()),
|
||||
GetPage(
|
||||
name: Routers.fingerprintDetailPage,
|
||||
page: () => const FingerprintDetailPage()),
|
||||
GetPage(
|
||||
name: Routers.faceList,
|
||||
page: () => const FaceList()),
|
||||
GetPage(
|
||||
name: Routers.addFaceTypeManagePage,
|
||||
page: () => const AddFaceTypeManagePage()),
|
||||
];
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ class BlueManage{
|
||||
// 监听发送事件
|
||||
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
||||
StreamSubscription? _scanSubscription;
|
||||
StreamSubscription<dynamic>? _currentConnectionStream;
|
||||
|
||||
// 监听蓝牙连接状态
|
||||
DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
@ -126,7 +127,7 @@ class BlueManage{
|
||||
if(deviceConnectionState == DeviceConnectionState.connected){
|
||||
return;
|
||||
}
|
||||
_flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 100000)).listen((connectionStateUpdate) async {
|
||||
_currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 100000)).listen((connectionStateUpdate) async {
|
||||
// 获取状态
|
||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||
print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}');
|
||||
@ -206,16 +207,15 @@ class BlueManage{
|
||||
|
||||
// 断开连接
|
||||
Future<void> disconnect(String deviceMAC) async {
|
||||
|
||||
try {
|
||||
_currentConnectionStream?.cancel();
|
||||
print('disconnecting to device: $deviceMAC');
|
||||
} on Exception catch (e, _) {
|
||||
print("Error disconnecting from a device: $e");
|
||||
} finally {
|
||||
// EventBusManager().eventBusFir(ConnectionStateUpdate(
|
||||
// deviceId: deviceMAC,
|
||||
// connectionState: DeviceConnectionState.disconnected,
|
||||
// failure: null,
|
||||
// ));
|
||||
deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
// _currentConnectionStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,5 +394,6 @@ class BlueManage{
|
||||
|
||||
disposed(){
|
||||
_sendStreamSubscription?.cancel();
|
||||
_currentConnectionStream?.cancel();
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,7 @@ class SenderAddStressFingerprintCommand extends SenderProtocol {
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? fingerNo;
|
||||
int? fingerType;
|
||||
int? useCountLimit;
|
||||
List<int>? token;
|
||||
int? startTime;
|
||||
@ -25,11 +26,13 @@ class SenderAddStressFingerprintCommand extends SenderProtocol {
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
List<int>? signKey;
|
||||
|
||||
SenderAddStressFingerprintCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.fingerNo,
|
||||
this.fingerType,
|
||||
this.useCountLimit,
|
||||
this.token,
|
||||
this.startTime,
|
||||
@ -37,6 +40,7 @@ class SenderAddStressFingerprintCommand extends SenderProtocol {
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
this.signKey
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
@ -71,8 +75,11 @@ class SenderAddStressFingerprintCommand extends SenderProtocol {
|
||||
// PwdNo
|
||||
subData.add(fingerNo!);
|
||||
|
||||
// fingerType
|
||||
subData.add(fingerType!);
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(0xff);
|
||||
subData.add(255);
|
||||
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
@ -95,22 +102,21 @@ class SenderAddStressFingerprintCommand extends SenderProtocol {
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
authCodeData.addAll(signKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
subData.add(authCode.bytes.length);
|
||||
subData.addAll(authCode.bytes);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? icCardNo;
|
||||
int? cardType;
|
||||
int? useCountLimit;
|
||||
List<int>? token;
|
||||
int? startTime;
|
||||
@ -25,11 +26,13 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
List<int>? signKey;
|
||||
|
||||
SenderAddStressICCardCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.icCardNo,
|
||||
this.cardType,
|
||||
this.useCountLimit,
|
||||
this.token,
|
||||
this.startTime,
|
||||
@ -37,6 +40,7 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
this.signKey
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
@ -68,9 +72,12 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// PwdNo
|
||||
// icCardNo
|
||||
subData.add(icCardNo!);
|
||||
|
||||
// cardType
|
||||
subData.add(cardType!);
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(0xff);
|
||||
|
||||
@ -95,16 +102,16 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
authCodeData.addAll(signKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
|
||||
@ -58,12 +58,12 @@ class CommandReciverManager {
|
||||
print("appDataReceiveData:$data"); // &&(data[4] == 0x11)
|
||||
if((data[0] == 0xEF)&&(data[1] == 0x01)&&(data[2] == 0xEE)&&(data[3] == 0x02)){
|
||||
var tmpType = (data[7] & 0x0f);// 包标识
|
||||
print("temType:$tmpType");
|
||||
// print("temType:$tmpType");
|
||||
|
||||
var dataLen = data[8] * 256 + data[9];// 高16位用来指示后面数据块内容的长度
|
||||
var oriLen = data[10] * 256 + data[11];// 低16位用来指示数据加密前的原长度
|
||||
print("dataLen:$dataLen oriLen:$oriLen");
|
||||
List<int> dataList = [];
|
||||
// print("dataLen:$dataLen oriLen:$oriLen");
|
||||
// List<int> dataList = [];
|
||||
List<int> oriDataList = [];
|
||||
switch(tmpType){
|
||||
case 0: //不加密
|
||||
|
||||
@ -548,6 +548,7 @@ class IoSenderManage {
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? fingerNo,
|
||||
required int? fingerType,
|
||||
required int? useCountLimit,
|
||||
required List<int>? token,
|
||||
required int? startTime,
|
||||
@ -555,12 +556,14 @@ class IoSenderManage {
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
required List<int>? signKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderAddStressFingerprintCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
fingerNo: fingerNo,
|
||||
fingerType: fingerType,
|
||||
useCountLimit: useCountLimit,
|
||||
token: token,
|
||||
startTime: startTime,
|
||||
@ -568,6 +571,7 @@ class IoSenderManage {
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
signKey: signKey
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
@ -576,6 +580,7 @@ class IoSenderManage {
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? icCardNo,
|
||||
required int? cardType,
|
||||
required int? useCountLimit,
|
||||
required List<int>? token,
|
||||
required int? startTime,
|
||||
@ -583,12 +588,14 @@ class IoSenderManage {
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
required List<int>? signKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderAddStressICCardCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
icCardNo: icCardNo,
|
||||
cardType: cardType,
|
||||
useCountLimit: useCountLimit,
|
||||
token: token,
|
||||
startTime: startTime,
|
||||
@ -596,6 +603,7 @@ class IoSenderManage {
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
signKey: signKey
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ class AuthorizedAdminSendEntity {
|
||||
}
|
||||
|
||||
class Data {
|
||||
int? receiverUid;
|
||||
String? receiverUid;
|
||||
ReceiverUser? receiverUser;
|
||||
int? keyId;
|
||||
|
||||
@ -149,15 +149,16 @@ class Phone {
|
||||
class Cloud {
|
||||
String? username;
|
||||
String? password;
|
||||
int? cloudUid;
|
||||
// String? cloudUid;
|
||||
int? userId;
|
||||
String? updatedAt;
|
||||
String? createdAt;
|
||||
int? id;
|
||||
|
||||
Cloud({this.username,
|
||||
Cloud(
|
||||
{this.username,
|
||||
this.password,
|
||||
this.cloudUid,
|
||||
// this.cloudUid,
|
||||
this.userId,
|
||||
this.updatedAt,
|
||||
this.createdAt,
|
||||
@ -166,7 +167,7 @@ class Cloud {
|
||||
Cloud.fromJson(Map<String, dynamic> json) {
|
||||
username = json['username'];
|
||||
password = json['password'];
|
||||
cloudUid = json['cloud_uid'];
|
||||
// cloudUid = json['cloud_uid'];
|
||||
userId = json['user_id'];
|
||||
updatedAt = json['updated_at'];
|
||||
createdAt = json['created_at'];
|
||||
@ -177,7 +178,7 @@ class Cloud {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['username'] = username;
|
||||
data['password'] = password;
|
||||
data['cloud_uid'] = cloudUid;
|
||||
// data['cloud_uid'] = cloudUid;
|
||||
data['user_id'] = userId;
|
||||
data['updated_at'] = updatedAt;
|
||||
data['created_at'] = createdAt;
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
@ -327,9 +329,9 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
|
||||
var entity = await ApiRepository.to.setRoomStatusData(
|
||||
lockId: state.keyInfo.value.lockId!,
|
||||
roomStatus:1,
|
||||
roomStatus: 1,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("标记为已入住成功啦啦啦啦啦");
|
||||
Toast.show(msg: "标记成功");
|
||||
setState(() {});
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import 'addCardTypeManage_tabbar.dart';
|
||||
|
||||
class AddCardTypeManagePage extends StatefulWidget {
|
||||
const AddCardTypeManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddCardTypeManagePage> createState() => _AddCardTypeManagePageState();
|
||||
}
|
||||
|
||||
class _AddCardTypeManagePageState extends State<AddCardTypeManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 0卡 1指纹 2钥匙
|
||||
Map map = Get.arguments;
|
||||
var lockId = map["lockId"];
|
||||
var fromType = map["fromType"]; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";
|
||||
if(fromType == 2){
|
||||
fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
AddCardManageTabbar(initialIndex: index, lockId: lockId, fromType: fromType, fromTypeTwoStaffName:fromTypeTwoStaffName),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,29 +1,28 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import '../otherTypeAddKey/otherTypeAddKey_page.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../addCardType_page.dart';
|
||||
|
||||
class OtherTypeKeyManageTabbar extends StatefulWidget {
|
||||
class AddCardManageTabbar extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
var lockType = 0;
|
||||
var lockId = 0;
|
||||
var fromType = 0; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";// 从添加员工进入 传入员工名字
|
||||
OtherTypeKeyManageTabbar(
|
||||
{Key? key, required this.initialIndex, required this.lockType, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName})
|
||||
|
||||
AddCardManageTabbar(
|
||||
{Key? key, required this.initialIndex, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<OtherTypeKeyManageTabbar> createState() =>
|
||||
_OtherTypeKeyManageTabbarState();
|
||||
State<AddCardManageTabbar> createState() => _AddCardManageTabbarState();
|
||||
}
|
||||
|
||||
class _OtherTypeKeyManageTabbarState extends State<OtherTypeKeyManageTabbar>
|
||||
with SingleTickerProviderStateMixin {
|
||||
class _AddCardManageTabbarState extends State<AddCardManageTabbar> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
@ -36,6 +35,7 @@ class _OtherTypeKeyManageTabbarState extends State<OtherTypeKeyManageTabbar>
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
@ -46,11 +46,11 @@ class _OtherTypeKeyManageTabbarState extends State<OtherTypeKeyManageTabbar>
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
@ -89,13 +89,12 @@ class _OtherTypeKeyManageTabbarState extends State<OtherTypeKeyManageTabbar>
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _itemTabs
|
||||
.map((ItemView item) => OtherTypeAddKeyPage(
|
||||
seletType: item.seletType,
|
||||
lockType: widget.lockType,
|
||||
lockId: widget.lockId,
|
||||
fromType: widget.fromType,
|
||||
fromTypeTwoStaffName:widget.fromTypeTwoStaffName
|
||||
))
|
||||
.map((ItemView item) => AddCardPage(
|
||||
seletType: item.seletType,
|
||||
lockId: widget.lockId,
|
||||
fromType: widget.fromType,
|
||||
fromTypeTwoStaffName:widget.fromTypeTwoStaffName
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
@ -0,0 +1,98 @@
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'addCardType_state.dart';
|
||||
|
||||
class AddCardTypeLogic extends BaseGetXController{
|
||||
AddCardTypeState state = AddCardTypeState();
|
||||
|
||||
// 添加卡数据
|
||||
void addCardData() async {
|
||||
var fingerprintType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
var startDate = "";
|
||||
var endDate = "";
|
||||
if (state.seletType.value == "0") {
|
||||
fingerprintType = 1;
|
||||
startDate = "0";
|
||||
endDate = "0";
|
||||
} else if (state.seletType.value == "1") {
|
||||
fingerprintType = 2;
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
if (state.endTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (int.parse(state.beginTimeTimestamp.value) >=
|
||||
int.parse(state.endTimeTimestamp.value)) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
startDate = state.beginTimeTimestamp.value;
|
||||
endDate = state.endTimeTimestamp.value;
|
||||
} else if (state.seletType.value == "2") {
|
||||
if (state.effectiveDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择生效时间");
|
||||
return;
|
||||
}
|
||||
if (state.failureDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择失效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.weekdaysList.value.isEmpty) {
|
||||
Toast.show(msg: "请选择有效日");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (state.effectiveDateTime.value >= state.failureDateTime.value) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
startDate = state.effectiveDateTime.value.toString();
|
||||
endDate = state.failureDateTime.value.toString();
|
||||
fingerprintType = 4;
|
||||
}
|
||||
|
||||
var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫卡 2:胁迫卡
|
||||
print("addOtherType startDate:$startDate endDate:$endDate");
|
||||
Get.toNamed(Routers.addICCardPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"cardName": state.nameController.text,
|
||||
"cardNumber": "123456",
|
||||
"cardType": fingerprintType.toString(),
|
||||
"isCoerced": isCoerced,
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,44 +1,52 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'otherTypeAddKey_logic.dart';
|
||||
import 'addCardType_logic.dart';
|
||||
|
||||
class OtherTypeAddKeyPage extends StatefulWidget {
|
||||
final String seletType;
|
||||
final int lockType; // 0卡 1指纹 2钥匙
|
||||
class AddCardPage extends StatefulWidget {
|
||||
final String seletType; // 永久限时循环下标
|
||||
final int lockId;
|
||||
final int fromType;// // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final String fromTypeTwoStaffName;// 从添加员工进入 传入员工名字
|
||||
const OtherTypeAddKeyPage(
|
||||
{Key? key, required this.seletType, required this.lockType, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName}) : super(key: key);
|
||||
final int fromType; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final String fromTypeTwoStaffName; // 从添加员工进入 传入员工名字
|
||||
|
||||
const AddCardPage(
|
||||
{Key? key,
|
||||
required this.seletType,
|
||||
required this.lockId,
|
||||
required this.fromType,
|
||||
required this.fromTypeTwoStaffName})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<OtherTypeAddKeyPage> createState() => _OtherTypeAddKeyPageState();
|
||||
State<AddCardPage> createState() => _AddCardPageState();
|
||||
}
|
||||
|
||||
class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
final logic = Get.put(OtherTypeAddKeyLogic());
|
||||
final state = Get.find<OtherTypeAddKeyLogic>().state;
|
||||
class _AddCardPageState extends State<AddCardPage> {
|
||||
final logic = Get.put(AddCardTypeLogic());
|
||||
final state = Get.find<AddCardTypeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
state.seletType.value = widget.seletType;
|
||||
state.lockType.value = widget.lockType;
|
||||
state.lockId.value = widget.lockId;
|
||||
state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
// state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Your code here
|
||||
});
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
@ -50,8 +58,10 @@ class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
@ -61,8 +71,10 @@ class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyTimeLimitWidget(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
@ -74,18 +86,24 @@ class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
// 循环
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(Routers.electronicKeyPeriodValidityPage);
|
||||
Map result = await Get.toNamed(
|
||||
Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value = result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value = result['endDate'].millisecondsSinceEpoch;
|
||||
print('得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
state.effectiveDateTime.value =
|
||||
result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value =
|
||||
result['endDate'].millisecondsSinceEpoch;
|
||||
print(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
@ -125,13 +143,17 @@ class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.beginTimeTimestamp.value =
|
||||
DateTime.parse(state.beginTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
@ -140,13 +162,17 @@ class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.endTimeTimestamp.value = DateTime.parse(state.endTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.endTimeTimestamp.value =
|
||||
DateTime.parse(state.endTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
@ -157,29 +183,30 @@ class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
||||
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(btnName: TranslationLoader.lanKeys!.next!.tr, onClick: () async {
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||
onClick: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
// print("state.seletType:${state.seletType.value}");
|
||||
if (state.nameController.text.isEmpty) {
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
if(state.nameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
logic.addFingerprintsData();
|
||||
}else{
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
|
||||
}),
|
||||
logic.addCardData();
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -258,10 +285,10 @@ class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
String title;
|
||||
switch (type) {
|
||||
case 0:
|
||||
title = TranslationLoader.lanKeys!.card!.tr;
|
||||
title = TranslationLoader.lanKeys!.stressCard!.tr;
|
||||
break;
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.fingerprint!.tr;
|
||||
title = TranslationLoader.lanKeys!.stressFingerprint!.tr;
|
||||
break;
|
||||
case 2:
|
||||
title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
||||
@ -319,5 +346,4 @@ class _OtherTypeAddKeyPageState extends State<OtherTypeAddKeyPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,12 +1,11 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class OtherTypeAddKeyState{
|
||||
class AddCardTypeState{
|
||||
|
||||
final lockId = 0.obs;
|
||||
final seletType = "0".obs;// 0永久 1显示 2循环
|
||||
final lockType = 0.obs;// 0卡 1指纹 2钥匙
|
||||
final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final isStressFingerprint = false.obs;
|
||||
|
||||
@ -20,7 +19,7 @@ class OtherTypeAddKeyState{
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
OtherTypeAddKeyState() {
|
||||
AddCardTypeState() {
|
||||
// Map map = Get.arguments;
|
||||
// lockId.value = map["lockId"];
|
||||
// fromType.value = map["fromType"];
|
||||
@ -45,11 +45,6 @@ class AddICCardLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintStatus:$status");
|
||||
|
||||
@ -69,13 +64,20 @@ class AddICCardLogic extends BaseGetXController{
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -101,11 +103,6 @@ class AddICCardLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardConfirmation(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintstatus:$status");
|
||||
|
||||
@ -114,12 +111,12 @@ class AddICCardLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
if(state.isCoerced.value == "2"){
|
||||
// 非胁迫指纹
|
||||
if(state.isCoerced.value == "1"){
|
||||
// 非胁迫
|
||||
int addResultStatus = reply.data[5];
|
||||
if(addResultStatus == 0){
|
||||
// 成功更新序列号
|
||||
state.cardNumber.value = (reply.data[6]+1).toString();
|
||||
state.cardNumber.value = (reply.data[6]).toString();
|
||||
addICCardData();
|
||||
}else if(addResultStatus == 255){
|
||||
// 255 自动退出
|
||||
@ -153,10 +150,6 @@ class AddICCardLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
Future<void> _replyAddICStressCard(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintstatus:$status");
|
||||
@ -169,8 +162,37 @@ class AddICCardLogic extends BaseGetXController{
|
||||
addICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
//无权限
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddStressICCardCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
icCardNo:1,
|
||||
cardType:1,
|
||||
useCountLimit:1,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
signKey: getSignKeyList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
@ -190,10 +212,10 @@ class AddICCardLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 添加卡片开始
|
||||
// 添加卡片
|
||||
Future<void> senderAddICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -209,8 +231,10 @@ class AddICCardLogic extends BaseGetXController{
|
||||
userID:await Storage.getUid(),
|
||||
cardNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -222,14 +246,17 @@ class AddICCardLogic extends BaseGetXController{
|
||||
|
||||
// 添加胁迫卡片
|
||||
Future<void> senderAddStressICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
@ -238,13 +265,17 @@ class AddICCardLogic extends BaseGetXController{
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
icCardNo:1,
|
||||
cardType:1,
|
||||
useCountLimit:1,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
signKey: getSignKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -264,6 +295,13 @@ class AddICCardLogic extends BaseGetXController{
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "添加成功");
|
||||
if(state.fromType.value == 2){
|
||||
// 回调指纹号
|
||||
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(entity.data!.cardId.toString()));
|
||||
}else if(state.fromType.value == 1){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
}
|
||||
Get.close(2);
|
||||
updateIdCardUserNoLoadData(entity.data!.cardId.toString());
|
||||
}
|
||||
}
|
||||
@ -275,14 +313,14 @@ class AddICCardLogic extends BaseGetXController{
|
||||
cardUserNo: state.cardNumber.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
if(state.fromType.value == 2){
|
||||
// 回调指纹号
|
||||
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(cardId));
|
||||
}else if(state.fromType.value == 1){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
}
|
||||
Get.close(2);
|
||||
// Toast.show(msg: "添加成功");
|
||||
// if(state.fromType.value == 2){
|
||||
// // 回调指纹号
|
||||
// eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(cardId));
|
||||
// }else if(state.fromType.value == 1){
|
||||
// eventBus.fire(OtherTypeRefreshListEvent());
|
||||
// }
|
||||
// Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,175 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addICCard.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'cardDetail_state.dart';
|
||||
|
||||
class CardDetailLogic extends BaseGetXController{
|
||||
CardDetailState state = CardDetailState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderAddICCardReply)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加卡片开始(此处用作删除卡片)
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintStatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
deletICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
String? userID = await Storage.getUid();
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:userID,
|
||||
cardNo:int.parse(state.typeNumber.value),
|
||||
useCountLimit:0,
|
||||
startTime:state.effectiveDateTime.value,
|
||||
endTime:state.failureDateTime.value,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除卡片
|
||||
Future<void> senderAddICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
String? userID = await Storage.getUid();
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:userID,
|
||||
cardNo:int.parse(state.typeNumber.value),
|
||||
useCountLimit:0,
|
||||
startTime:state.effectiveDateTime.value,
|
||||
endTime:state.failureDateTime.value,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 编辑iC卡
|
||||
void editICCardData() async{
|
||||
var entity = await ApiRepository.to.editICCardData(
|
||||
cardId: state.keyId.value.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: state.effectiveDateTime.value.toString(),
|
||||
endDate: state.failureDateTime.value.toString(),
|
||||
isCoerced: state.isStressFingerprint.value ? "2" : "1",
|
||||
cardName: state.changeNameController.text,
|
||||
changeType: "1",
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除IC卡
|
||||
void deletICCardData() async{
|
||||
var entity = await ApiRepository.to.deletIcCardData(
|
||||
cardId: state.fingerprintItemData.value.cardId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
type: "0",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
@ -9,29 +10,30 @@ import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/showTFView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'otherTypeKeyDetail_logic.dart';
|
||||
import 'cardDetail_logic.dart';
|
||||
|
||||
class OtherTypeKeyDetailPage extends StatefulWidget {
|
||||
const OtherTypeKeyDetailPage({Key? key}) : super(key: key);
|
||||
class CardDetailPage extends StatefulWidget {
|
||||
const CardDetailPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<OtherTypeKeyDetailPage> createState() => _OtherTypeKeyDetailPageState();
|
||||
State<CardDetailPage> createState() => _CardDetailPageState();
|
||||
}
|
||||
|
||||
class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
final logic = Get.put(OtherTypeKeyDetailLogic());
|
||||
final state = Get.find<OtherTypeKeyDetailLogic>().state;
|
||||
class _CardDetailPageState extends State<CardDetailPage> {
|
||||
final logic = Get.put(CardDetailLogic());
|
||||
final state = Get.find<CardDetailLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${getAppBarTitle(state.type.value)}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
barTitle: "${TranslationLoader.lanKeys!.card!.tr}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
// actionsList: [
|
||||
@ -46,7 +48,7 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
body: Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "${getAppBarTitle(state.type.value)}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
leftTitel: "${TranslationLoader.lanKeys!.card!.tr}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
rightTitle: state.typeNumber.value,
|
||||
isHaveDirection: false,
|
||||
isHaveLine: true)),
|
||||
@ -59,7 +61,7 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
showCupertinoAlertDialog(context);
|
||||
})),
|
||||
Obx(() => Visibility(
|
||||
visible: (state.keyType.value == 4 || state.keyType.value == 2) ? true : false,
|
||||
visible: (state.keyType.value == 4 || state.keyType.value == 2) ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
allHeight: 70.h,
|
||||
@ -74,54 +76,21 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
// 当是指纹的时候
|
||||
if(state.keyType.value == 2){
|
||||
// 限时
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeDatePage, arguments: {
|
||||
"pushType": state.type.value,
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
});
|
||||
}
|
||||
}else if(state.keyType.value == 4){
|
||||
// 循环
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"pushType": state.type.value,
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
}
|
||||
// break;
|
||||
// case 2:
|
||||
// // 遥控
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.keyType.value == 4 ? true : false,
|
||||
child: Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr,
|
||||
rightTitle: state.weekDay.value.join(','),
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
// switch(state.type.value){
|
||||
// case 0:
|
||||
// // 卡
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
// 当是指纹的时候
|
||||
// 当是指纹的时候
|
||||
if(state.keyType.value == 2){
|
||||
// 限时
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeDatePage, arguments: {
|
||||
"pushType": state.type.value,
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
});
|
||||
}
|
||||
}else if(state.keyType.value == 4){
|
||||
// 循环
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"pushType": state.type.value,
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
@ -133,13 +102,46 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
// break;
|
||||
// case 2:
|
||||
// // 遥控
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
})))
|
||||
}
|
||||
// break;
|
||||
// case 2:
|
||||
// // 遥控
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.keyType.value == 4 ? true : false,
|
||||
child: Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr,
|
||||
rightTitle: state.weekDay.value.join(','),
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
// switch(state.type.value){
|
||||
// case 0:
|
||||
// // 卡
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
// 当是指纹的时候
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"pushType": state.type.value,
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
// break;
|
||||
// case 2:
|
||||
// // 遥控
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
})))
|
||||
),
|
||||
Container(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
@ -156,7 +158,7 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
})),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
||||
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
@ -170,14 +172,14 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
action: () {
|
||||
switch (state.type.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
// 卡
|
||||
Get.toNamed(Routers.keyOperationRecordPage, arguments: {
|
||||
'lockId': state.fingerprintItemData.value.lockId.toString(),
|
||||
'cardId': state.fingerprintItemData.value.cardId.toString()
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
// 指纹
|
||||
Get.toNamed(Routers.keyOperationRecordPage, arguments: {
|
||||
'lockId': state.fingerprintItemData.value.lockId.toString(),
|
||||
'fingerprintId': state.fingerprintItemData.value.fingerprintId.toString()
|
||||
@ -218,21 +220,7 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
switch(state.type.value){
|
||||
case 0:
|
||||
// 卡
|
||||
logic.editICCardData();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
logic.editFingerprintsData();
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
logic.editICCardData();
|
||||
});
|
||||
},
|
||||
);
|
||||
@ -328,23 +316,6 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
// );
|
||||
// }
|
||||
|
||||
String getAppBarTitle(int type) {
|
||||
String title = "";
|
||||
switch (type) {
|
||||
case 0:
|
||||
title = TranslationLoader.lanKeys!.card!.tr;
|
||||
break;
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.fingerprint!.tr;
|
||||
break;
|
||||
case 2:
|
||||
title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
@ -360,20 +331,7 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
return;
|
||||
}
|
||||
Get.back();
|
||||
switch(state.type.value){
|
||||
case 0:
|
||||
// 卡
|
||||
logic.editICCardData();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
logic.editFingerprintsData();
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
}
|
||||
logic.editICCardData();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
@ -388,23 +346,10 @@ class _OtherTypeKeyDetailPageState extends State<OtherTypeKeyDetailPage> {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
switch (state.type.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
logic.deletICCardData();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
logic.deletFingerprintsData();
|
||||
break;
|
||||
case 2:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
String? idStr = await Storage.getUid();
|
||||
logic.senderAddICCard();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
@ -0,0 +1,40 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class CardDetailState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
final type = 0.obs;// 0卡 1指纹 2遥控
|
||||
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
|
||||
final typeNumber = "".obs;// 指纹号
|
||||
final typeName = "".obs;// 指纹名字
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
final keyType = 0.obs;// 永久:1;限时2,单次3,循环:4
|
||||
var weekDay = [].obs;// 有效日
|
||||
var adder = "".obs;// 添加者
|
||||
var addTime = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;// 卡id
|
||||
|
||||
final isStressFingerprint = false.obs;
|
||||
CardDetailState() {
|
||||
Map map = Get.arguments;
|
||||
fingerprintItemData.value = map["fingerprintItemData"];
|
||||
keyId.value = fingerprintItemData.value.cardId!;
|
||||
typeNumber.value = fingerprintItemData.value.cardNumber!;
|
||||
typeName.value = fingerprintItemData.value.cardName!;
|
||||
changeNameController.text = typeName.value;
|
||||
effectiveDateTime.value = fingerprintItemData.value.startDate!;
|
||||
failureDateTime.value = fingerprintItemData.value.endDate!;
|
||||
keyType.value = fingerprintItemData.value.cardType!;
|
||||
adder.value = fingerprintItemData.value.senderUsername!;
|
||||
addTime.value = fingerprintItemData.value.createDate!;
|
||||
isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false;
|
||||
weekDay.value = fingerprintItemData.value.weekDay!;
|
||||
}
|
||||
}
|
||||
382
star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart
Normal file
382
star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart
Normal file
@ -0,0 +1,382 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addICCard.dart';
|
||||
import '../../../../blue/io_protocol/io_checkingCardStatus.dart';
|
||||
import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'cardList_state.dart';
|
||||
|
||||
class CardListLogic extends BaseGetXController {
|
||||
CardListState state = CardListState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderAddICCardReply) && (state.isDeletCardData == true)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderCheckingCardStatusReply) {
|
||||
_replyReferEventRecordNumber(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderCheckingUserInfoCountReply){
|
||||
_replyCheckingUserInfoCount(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加卡片开始(此处用作删除卡片)
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintStatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletCardData = false;
|
||||
deletICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
cardNo:state.deletCardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取卡片状态
|
||||
Future<void> _replyReferEventRecordNumber(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> _replyCheckingUserInfoCount(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
// 用户数量
|
||||
int userNum = reply.data[5];
|
||||
// print("userNum:$userNum");
|
||||
|
||||
// 指纹数量
|
||||
int fingerNum = reply.data[6];
|
||||
// print("fingerNum:$fingerNum");
|
||||
|
||||
// 密码数量
|
||||
int pwdNum = reply.data[7];
|
||||
|
||||
// 卡片数量
|
||||
int cardNum = reply.data[8];
|
||||
|
||||
// 记录数量
|
||||
int logsNum = reply.data[9];
|
||||
|
||||
// 版本
|
||||
int verNo = reply.data[10];
|
||||
|
||||
// 最大管理员指纹数量
|
||||
int maxAdminFingerNum = reply.data[11];
|
||||
|
||||
// 最大用户指纹数量
|
||||
int maxUserFingerNum = reply.data[12];
|
||||
|
||||
// 最大管理员密码数量
|
||||
int maxAdminPassNum = reply.data[13];
|
||||
|
||||
// 最大用户密码数量
|
||||
int maxUserPassNum = reply.data[14];
|
||||
|
||||
// 最大管理员卡片数量
|
||||
int maxAdminCardNum = reply.data[15];
|
||||
|
||||
// 最大用户卡片数量
|
||||
int maxUserCardNum = reply.data[16];
|
||||
|
||||
// 序列号
|
||||
var serialNo = reply.data.sublist(17, 21);
|
||||
print("serialNo:$serialNo");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询卡片状态
|
||||
Future<void> senderCheckingCardStatus() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderCheckingCardStatusCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
role:0xff,
|
||||
cardCount:20,
|
||||
cardNo:1,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderCheckingUserInfoCountCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
role:0xff,
|
||||
nowTime:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
// 删除卡片
|
||||
Future<void> senderAddICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
cardNo:state.deletCardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取IC卡列表
|
||||
void getICCardListData() async{
|
||||
var entity = await ApiRepository.to.getICCardListData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
pageNo: '1',
|
||||
pageSize: '20',
|
||||
searchStr: state.searchController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.fingerprintItemListData.value = entity.data!.list!;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除所有IC卡
|
||||
void deletICCardData() async{
|
||||
var cardId = "";
|
||||
var type = "1";
|
||||
if(state.isDeletAll == false){
|
||||
cardId = state.deletKeyID;
|
||||
type = "0";
|
||||
}
|
||||
print("delet fingerprintId $cardId");
|
||||
var entity = await ApiRepository.to.deletIcCardData(
|
||||
cardId: cardId,
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: type,
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if(state.isDeletAll == false){
|
||||
Toast.show(msg: "删除成功");
|
||||
}else{
|
||||
Toast.show(msg: "重置成功");
|
||||
}
|
||||
|
||||
state.isDeletCardData = false;
|
||||
getICCardListData();
|
||||
}
|
||||
}
|
||||
|
||||
// 监听修改完详情之后刷新列表
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((event) {
|
||||
getICCardListData();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
// print("aaaaaaa:$isDemoMode");
|
||||
if(isDemoMode == false){
|
||||
_initReplySubscription();
|
||||
|
||||
_initRefreshAction();
|
||||
|
||||
// 卡
|
||||
getICCardListData();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false) {
|
||||
// senderQueryingFingerprintStatus();
|
||||
// senderCheckingCardStatus();
|
||||
senderCheckingUserInfoCount();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onClose() async {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
304
star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart
Normal file
304
star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart
Normal file
@ -0,0 +1,304 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/left_slide_actions.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
import 'cardList_logic.dart';
|
||||
|
||||
class CardListPage extends StatefulWidget {
|
||||
const CardListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CardListPage> createState() => _CardListPageState();
|
||||
}
|
||||
|
||||
class _CardListPageState extends State<CardListPage> {
|
||||
final logic = Get.put(CardListLogic());
|
||||
final state = Get.find<CardListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.card!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(height: 20.h),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName:
|
||||
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.addCardTypeManagePage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getICCardListData();
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.searchController,
|
||||
autofocus: false,
|
||||
onChanged: (value) {
|
||||
print("onChanged:$value");
|
||||
},
|
||||
onEditingComplete: () {
|
||||
print("onEditingComplete:");
|
||||
},
|
||||
onSubmitted: (value) {
|
||||
logic.getICCardListData();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
icon: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.h, bottom: 20.h, right: 20.w, left: 10.w),
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_search.png',
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => state.fingerprintItemListData.value.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index];
|
||||
if (index < state.fingerprintItemListData.value.length) {
|
||||
return LeftSlideActions(
|
||||
key: Key(fingerprintItemData.cardName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(fingerprintItemData),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_card.png',
|
||||
fingerprintItemData.cardName!,
|
||||
fingerprintItemData.cardType! == 1
|
||||
? "永久"
|
||||
:
|
||||
"${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", () async {
|
||||
var data = await Get.toNamed(
|
||||
Routers.cardDetailPage, arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getICCardListData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
) : const NoData());
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(FingerprintItemData fingerprintItemData) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
state.deletKeyID = fingerprintItemData.cardId.toString();
|
||||
state.deletCardNo = int.parse(fingerprintItemData.cardNumber!);
|
||||
showIosTipViewDialog(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
state.isDeletCardData = true;
|
||||
state.isDeletAll = false;
|
||||
state.deletUserID = (await Storage.getUid())!;
|
||||
logic.senderAddICCard();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(
|
||||
BuildContext context,
|
||||
) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
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);
|
||||
state.isDeletCardData = true;
|
||||
state.isDeletAll = true;
|
||||
state.deletKeyID = "1";
|
||||
state.deletUserID = "DeleteAll!@#";
|
||||
state.deletCardNo = 255;
|
||||
logic.senderAddICCard();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class CardListState {
|
||||
final lockId = 0.obs;
|
||||
|
||||
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
||||
var isDeletCardData = false;
|
||||
var isDeletAll = false;
|
||||
var deletKeyID = "";
|
||||
var deletUserID = "DeleteAll!@#";
|
||||
var deletCardNo = 0;
|
||||
|
||||
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
CardListState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
fingerprintName: state.fingerprintItemData.value.fingerprintName!,
|
||||
changeType: "1",
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
@ -40,6 +41,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
cardName: state.fingerprintItemData.value.cardName!,
|
||||
changeType: '1',
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
@ -1,9 +1,10 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
@ -15,10 +16,12 @@ class OtherTypeKeyChangeDatePage extends StatefulWidget {
|
||||
const OtherTypeKeyChangeDatePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<OtherTypeKeyChangeDatePage> createState() => _OtherTypeKeyChangeDatePageState();
|
||||
State<OtherTypeKeyChangeDatePage> createState() =>
|
||||
_OtherTypeKeyChangeDatePageState();
|
||||
}
|
||||
|
||||
class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage> {
|
||||
class _OtherTypeKeyChangeDatePageState
|
||||
extends State<OtherTypeKeyChangeDatePage> {
|
||||
final logic = Get.put(OtherTypeKeyChangeDateLogic());
|
||||
final state = Get.find<OtherTypeKeyChangeDateLogic>().state;
|
||||
|
||||
@ -27,7 +30,8 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.periodValidity!.tr}",
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.periodValidity!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
@ -48,7 +52,6 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
|
||||
logic.editFingerprintsData();
|
||||
break;
|
||||
case 2:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -72,12 +75,14 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.beginTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch;
|
||||
state.beginTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}";
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
state.beginTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2, '0')}-${p.day.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}')
|
||||
.millisecondsSinceEpoch;
|
||||
state.beginTime.value =
|
||||
"${p.year}.${p.month.toString().padLeft(2, '0')}.${p.day.toString().padLeft(2, '0')} ${p.hour.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
@ -86,12 +91,14 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.endTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch;
|
||||
state.endTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}";
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
state.endTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2, '0')}-${p.day.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}')
|
||||
.millisecondsSinceEpoch;
|
||||
state.endTime.value =
|
||||
"${p.year}.${p.month.toString().padLeft(2, '0')}.${p.day.toString().padLeft(2, '0')} ${p.hour.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
],
|
||||
);
|
||||
@ -1,8 +1,7 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../otherTypeKeyList/fingerprintListData_entity.dart';
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class OtherTypeKeyChangeDateState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
@ -20,6 +20,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
fingerprintName: state.fingerprintItemData.value.fingerprintName!,
|
||||
changeType: "1",
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
@ -42,6 +43,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
cardName: state.fingerprintItemData.value.cardName!,
|
||||
changeType: '1',
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
@ -17,10 +17,12 @@ class OtherTypeKeyChangeValidityDatePage extends StatefulWidget {
|
||||
const OtherTypeKeyChangeValidityDatePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<OtherTypeKeyChangeValidityDatePage> createState() => _OtherTypeKeyChangeValidityDatePageState();
|
||||
State<OtherTypeKeyChangeValidityDatePage> createState() =>
|
||||
_OtherTypeKeyChangeValidityDatePageState();
|
||||
}
|
||||
|
||||
class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeValidityDatePage> {
|
||||
class _OtherTypeKeyChangeValidityDatePageState
|
||||
extends State<OtherTypeKeyChangeValidityDatePage> {
|
||||
final logic = Get.put(OtherTypeKeyChangeValidityDateLogic());
|
||||
final state = Get.find<OtherTypeKeyChangeValidityDateLogic>().state;
|
||||
|
||||
@ -46,9 +48,9 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
|
||||
child: SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||
onClick: () {
|
||||
if(state.pushType.value == 0){
|
||||
if (state.pushType.value == 0) {
|
||||
logic.editICCardData();
|
||||
}else if(state.pushType.value == 1){
|
||||
} else if (state.pushType.value == 1) {
|
||||
logic.editFingerprintsData();
|
||||
}
|
||||
}),
|
||||
@ -69,7 +71,9 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
|
||||
height: 60.h,
|
||||
// color: Colors.red,
|
||||
padding: EdgeInsets.only(left: 30.w, top: 15.h),
|
||||
child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))),
|
||||
child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr,
|
||||
style:
|
||||
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))),
|
||||
Container(
|
||||
height: 100.h,
|
||||
padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h),
|
||||
@ -118,29 +122,35 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if(state.weekDay.value.contains(index)){
|
||||
if (state.weekDay.value.contains(index)) {
|
||||
state.weekDay.value.remove(index);
|
||||
}else{
|
||||
} else {
|
||||
state.weekDay.value.add(index);
|
||||
}
|
||||
state.weekDay.value.sort();
|
||||
});
|
||||
},
|
||||
child: Obx(() => Container(
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
margin: EdgeInsets.all(10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: state.weekDay.value.contains(index) ? AppColors.mainColor :Colors.white,
|
||||
border: Border.all(width: 1, color: AppColors.btnDisableColor),
|
||||
borderRadius: BorderRadius.circular(30.w),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
margin: EdgeInsets.all(10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: state.weekDay.value.contains(index)
|
||||
? AppColors.mainColor
|
||||
: Colors.white,
|
||||
border: Border.all(width: 1, color: AppColors.btnDisableColor),
|
||||
borderRadius: BorderRadius.circular(30.w),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
dateStr,
|
||||
style: TextStyle(fontSize: 20.sp, color: state.weekDay.value.contains(index) ? Colors.white : AppColors.darkGrayTextColor),
|
||||
style: TextStyle(
|
||||
fontSize: 20.sp,
|
||||
color: state.weekDay.value.contains(index)
|
||||
? Colors.white
|
||||
: AppColors.darkGrayTextColor),
|
||||
)),
|
||||
)),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -153,34 +163,38 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
"${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
"${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.beginTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch;
|
||||
state.beginTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}";
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
state.beginTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2, '0')}-${p.day.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}')
|
||||
.millisecondsSinceEpoch;
|
||||
state.beginTime.value =
|
||||
"${p.year}.${p.month.toString().padLeft(2, '0')}.${p.day.toString().padLeft(2, '0')} ${p.hour.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
"${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
"${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.endTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch;
|
||||
state.endTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}";
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
state.endTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2, '0')}-${p.day.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}')
|
||||
.millisecondsSinceEpoch;
|
||||
state.endTime.value =
|
||||
"${p.year}.${p.month.toString().padLeft(2, '0')}.${p.day.toString().padLeft(2, '0')} ${p.hour.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
@ -189,5 +203,4 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../otherTypeKeyList/fingerprintListData_entity.dart';
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class OtherTypeKeyChangeValidityDateState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
@ -1,13 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/style/default_style.dart';
|
||||
import 'package:flutter_pickers/style/picker_style.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/pduration.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/suffix.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/style/default_style.dart';
|
||||
// import 'package:flutter_pickers/style/picker_style.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/pduration.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/suffix.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/style/picker_style.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/suffix.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
@ -41,10 +46,10 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
actionsList: [
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
var data = await Get.toNamed(Routers.checkingInAddHolidaysPage, arguments: {
|
||||
"companyId": state.companyId.value
|
||||
});
|
||||
if(data != null) {
|
||||
var data = await Get.toNamed(
|
||||
Routers.checkingInAddHolidaysPage,
|
||||
arguments: {"companyId": state.companyId.value});
|
||||
if (data != null) {
|
||||
logic.editStaffLoadData();
|
||||
}
|
||||
},
|
||||
@ -59,47 +64,60 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
],
|
||||
),
|
||||
body: Obx(() {
|
||||
return state.holidaysListData.value!.isNotEmpty ? ListView.builder(
|
||||
itemCount: state.holidaysListData.value!.length,
|
||||
itemBuilder: (c, index) {
|
||||
HolidaysMonthListData holidaysMonthListData = state.holidaysListData.value![index];
|
||||
return _checkingInListMouthItem(holidaysMonthListData);
|
||||
}):const NoData();
|
||||
})
|
||||
);
|
||||
return state.holidaysListData.value!.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: state.holidaysListData.value!.length,
|
||||
itemBuilder: (c, index) {
|
||||
HolidaysMonthListData holidaysMonthListData =
|
||||
state.holidaysListData.value![index];
|
||||
return _checkingInListMouthItem(holidaysMonthListData);
|
||||
})
|
||||
: const NoData();
|
||||
}));
|
||||
}
|
||||
|
||||
Widget _checkingInListMouthItem(HolidaysMonthListData holidaysMonthListData) {
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
height: 140.h*holidaysMonthListData.listItem!.length + 20.w,
|
||||
height: 140.h * holidaysMonthListData.listItem!.length + 20.w,
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
color: colorWithMonth(int.parse(holidaysMonthListData.listItem![0].month.toString())),
|
||||
color: colorWithMonth(int.parse(
|
||||
holidaysMonthListData.listItem![0].month.toString())),
|
||||
width: 100.w,
|
||||
height: 140.h*holidaysMonthListData.listItem!.length,
|
||||
height: 140.h * holidaysMonthListData.listItem!.length,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${holidaysMonthListData.listItem![0].month}\n${TranslationLoader.lanKeys!.month!.tr}",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 28.sp, color: Colors.white),
|
||||
))),
|
||||
"${holidaysMonthListData.listItem![0].month}\n${TranslationLoader.lanKeys!.month!.tr}",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 28.sp, color: Colors.white),
|
||||
))),
|
||||
SizedBox(
|
||||
height: 140.h*holidaysMonthListData.listItem!.length,
|
||||
width: 1.sw - 100.w - 20.w*2,
|
||||
height: 140.h * holidaysMonthListData.listItem!.length,
|
||||
width: 1.sw - 100.w - 20.w * 2,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: holidaysMonthListData.listItem!.length,
|
||||
itemBuilder: (c, index) {
|
||||
ListItem listItem = holidaysMonthListData.listItem![index];
|
||||
return _checkingInListItem(index, listItem.vacationName, DateTool().dateToYMDString(listItem.vacationStartDate.toString()), DateTool().dateToYMDString(listItem.vacationEndDate.toString()), listItem.fillClassDate!.isNotEmpty ? DateTool().dateToYMDString(listItem.fillClassDate.toString()):"", () async {
|
||||
var data = await Get.toNamed(Routers.checkingInDeletHolidaysPage, arguments: {
|
||||
"listItem": listItem
|
||||
});
|
||||
if(data != null) {
|
||||
return _checkingInListItem(
|
||||
index,
|
||||
listItem.vacationName,
|
||||
DateTool().dateToYMDString(
|
||||
listItem.vacationStartDate.toString()),
|
||||
DateTool().dateToYMDString(
|
||||
listItem.vacationEndDate.toString()),
|
||||
listItem.fillClassDate!.isNotEmpty
|
||||
? DateTool().dateToYMDString(
|
||||
listItem.fillClassDate.toString())
|
||||
: "", () async {
|
||||
var data = await Get.toNamed(
|
||||
Routers.checkingInDeletHolidaysPage,
|
||||
arguments: {"listItem": listItem});
|
||||
if (data != null) {
|
||||
logic.editStaffLoadData();
|
||||
}
|
||||
});
|
||||
@ -111,13 +129,19 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _checkingInListItem(int index, String? lockTypeTitle, String? vacationStartDate, String? vacationEndDate, String? makeUpClass, Function() action) {
|
||||
Widget _checkingInListItem(
|
||||
int index,
|
||||
String? lockTypeTitle,
|
||||
String? vacationStartDate,
|
||||
String? vacationEndDate,
|
||||
String? makeUpClass,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
color:Colors.white,
|
||||
color: Colors.white,
|
||||
height: 140.h,
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h),
|
||||
child: Row(
|
||||
@ -174,27 +198,27 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
showListType();
|
||||
},
|
||||
child: Obx(() => Container(
|
||||
width: 300.w,
|
||||
height: 50.h,
|
||||
color: AppColors.mainColor,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"${state.seletYear.value}${TranslationLoader.lanKeys!.year!.tr}",
|
||||
style: TextStyle(color: Colors.white, fontSize: 26.sp),
|
||||
width: 300.w,
|
||||
height: 50.h,
|
||||
color: AppColors.mainColor,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"${state.seletYear.value}${TranslationLoader.lanKeys!.year!.tr}",
|
||||
style: TextStyle(color: Colors.white, fontSize: 26.sp),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5.w,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_lockDetail_checkIn_topTitle.png',
|
||||
width: 22.w,
|
||||
height: 16.w,
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 5.w,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_lockDetail_checkIn_topTitle.png',
|
||||
width: 22.w,
|
||||
height: 16.w,
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -242,9 +266,9 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Color colorWithMonth(int month){
|
||||
Color colorWithMonth(int month) {
|
||||
Color colorType;
|
||||
switch (month){
|
||||
switch (month) {
|
||||
case 1:
|
||||
colorType = const Color(0xFFb8d152);
|
||||
break;
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
@ -16,7 +18,8 @@ class CheckingInSetWorkTimePage extends StatefulWidget {
|
||||
const CheckingInSetWorkTimePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CheckingInSetWorkTimePage> createState() => _CheckingInSetWorkTimePageState();
|
||||
State<CheckingInSetWorkTimePage> createState() =>
|
||||
_CheckingInSetWorkTimePageState();
|
||||
}
|
||||
|
||||
class _CheckingInSetWorkTimePageState extends State<CheckingInSetWorkTimePage> {
|
||||
@ -27,77 +30,100 @@ class _CheckingInSetWorkTimePageState extends State<CheckingInSetWorkTimePage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(barTitle: "${TranslationLoader.lanKeys!.work!.tr} ${TranslationLoader.lanKeys!.time!.tr} ${TranslationLoader.lanKeys!.set!.tr}", haveBack:true, backgroundColor: AppColors.mainColor),
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.work!.tr} ${TranslationLoader.lanKeys!.time!.tr} ${TranslationLoader.lanKeys!.set!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: buildMainUI(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildMainUI(){
|
||||
Widget buildMainUI() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(leftTitel:TranslationLoader.lanKeys!.officeHours!.tr, rightTitle:state.beginTime.value, isHaveDirection: true, isHaveLine: true, action:(){
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.officeHours!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
DateTime today = DateTime.now();
|
||||
state.beginTimeTimestamp.value = DateTime.parse(
|
||||
'${today.year}-${today.month.toString().padLeft(2,'0')}-${today.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch.toString();
|
||||
state.beginTime.value = "${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}";
|
||||
'${today.year}-${today.month.toString().padLeft(2, '0')}-${today.day.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}')
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
state.beginTime.value =
|
||||
"${p.hour.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(leftTitel:TranslationLoader.lanKeys!.closingTime!.tr, rightTitle:state.endTime.value, isHaveDirection: true, action:(){
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.closingTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
DateTime today = DateTime.now();
|
||||
state.endTimeTimestamp.value = DateTime.parse(
|
||||
'${today.year}-${today.month.toString().padLeft(2,'0')}-${today.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch.toString();
|
||||
state.endTime.value = "${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}";
|
||||
'${today.year}-${today.month.toString().padLeft(2, '0')}-${today.day.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}')
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
state.endTime.value =
|
||||
"${p.hour.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
SizedBox(height: 30.h,),
|
||||
SubmitBtn(btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||
})),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||
borderRadius: 20.w,
|
||||
fontSize: 32.sp,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w),
|
||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||
onClick: () {
|
||||
if(state.beginTimeTimestamp.value.isEmpty){
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if(state.endTimeTimestamp.value.isEmpty){
|
||||
if (state.endTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择结束时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if(int.parse(state.beginTimeTimestamp.value) > int.parse(state.endTimeTimestamp.value)){
|
||||
if (int.parse(state.beginTimeTimestamp.value) >
|
||||
int.parse(state.endTimeTimestamp.value)) {
|
||||
Toast.show(msg: "结束时间不能大于开始时间");
|
||||
return;
|
||||
}
|
||||
if(state.pushType.value == "2"){
|
||||
if (state.pushType.value == "2") {
|
||||
logic.editCheckInSetInfoData();
|
||||
}else{
|
||||
} else {
|
||||
Get.back(result: {
|
||||
"beginTime":state.beginTime.value,
|
||||
"beginTimeTimestamp":state.beginTimeTimestamp.value,
|
||||
"endTime":state.endTime.value,
|
||||
"endTimeTimestamp":state.endTimeTimestamp.value,
|
||||
"beginTime": state.beginTime.value,
|
||||
"beginTimeTimestamp": state.beginTimeTimestamp.value,
|
||||
"endTime": state.endTime.value,
|
||||
"endTimeTimestamp": state.endTimeTimestamp.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
),
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String getNowDate(){
|
||||
String getNowDate() {
|
||||
// 获取当前时间对象
|
||||
DateTime today = DateTime.now();
|
||||
String dateSlug ="${today.hour.toString().padLeft(2,'0')}:${today.minute.toString().padLeft(2,'0')}";
|
||||
String dateSlug =
|
||||
"${today.hour.toString().padLeft(2, '0')}:${today.minute.toString().padLeft(2, '0')}";
|
||||
|
||||
// //获取当前时间的年
|
||||
// int year = now.year;
|
||||
@ -115,5 +141,4 @@ class _CheckingInSetWorkTimePageState extends State<CheckingInSetWorkTimePage> {
|
||||
// print("组合 $year-$month-$day $hour:$minute:$millisecond");
|
||||
return dateSlug;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyManagePage,
|
||||
Routers.addCardTypeManagePage,
|
||||
arguments: {
|
||||
"lockId": state
|
||||
.getKeyInfosData.value.lockId,
|
||||
@ -187,7 +187,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyManagePage,
|
||||
Routers.addFingerprintTypeManagePage,
|
||||
arguments: {
|
||||
"lockId": state
|
||||
.getKeyInfosData.value.lockId,
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
final ElectronicKeyDetailState state = ElectronicKeyDetailState();
|
||||
|
||||
//修改钥匙名称请求
|
||||
Future<void> modifyKeyNameRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.modifyKeyNameForAdmin(state.itemData.value.keyId.toString(),
|
||||
state.changeNameController.text, '');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("修改要是名称成功啦啦啦啦啦");
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
|
||||
//删除电子钥匙名称请求
|
||||
Future<void> deleteKeyRequest() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.deleteElectronicKey(state.itemData.value.keyId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("删除电子钥匙成功");
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,12 +3,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/jh_pop_menus.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
@ -28,16 +25,11 @@ class ElectronicKeyDetailPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
final TextEditingController _changeNameController = TextEditingController();
|
||||
ElectronicKeyListItem itemData = ElectronicKeyListItem();
|
||||
final logic = Get.put(ElectronicKeyDetailLogic());
|
||||
final state = Get.find<ElectronicKeyDetailLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["itemData"] != null)) {
|
||||
itemData = obj["itemData"];
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
@ -68,38 +60,29 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: _changeNameController.text.isNotEmpty
|
||||
? _changeNameController.text
|
||||
: itemData.keyName,
|
||||
rightTitle: state.changeNameController.text.isNotEmpty
|
||||
? state.changeNameController.text
|
||||
: state.itemData.value.keyName,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
allHeight: 90.h,
|
||||
rightTitle: getUseDateStr(itemData),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyDetailChangeDate,
|
||||
arguments: {"itemData": itemData});
|
||||
}),
|
||||
getPeriodValidityWidget(),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
|
||||
rightTitle: itemData.username,
|
||||
rightTitle: state.itemData.value.username,
|
||||
action: () {}),
|
||||
const SizedBox(height: 1),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.sender!.tr,
|
||||
rightTitle: itemData.senderUsername,
|
||||
rightTitle: state.itemData.value.senderUsername,
|
||||
action: () {}),
|
||||
const SizedBox(height: 1),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.senderTime!.tr,
|
||||
rightTitle: getSenderDate(itemData),
|
||||
rightTitle: getSenderDate(state.itemData.value),
|
||||
action: () {}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
@ -108,8 +91,9 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w,
|
||||
child:
|
||||
_switch(itemData.faceAuthentication == 1 ? true : false)),
|
||||
child: _switch(state.itemData.value.faceAuthentication == 1
|
||||
? true
|
||||
: false)),
|
||||
action: () {}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
@ -119,8 +103,8 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.keyOperationRecordPage,
|
||||
arguments: {
|
||||
'lockId': itemData.lockId.toString(),
|
||||
'keyId': itemData.keyId.toString()
|
||||
'lockId': state.itemData.value.lockId.toString(),
|
||||
'keyId': state.itemData.value.keyId.toString()
|
||||
});
|
||||
}),
|
||||
Container(height: 40.h),
|
||||
@ -139,106 +123,136 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr(ElectronicKeyListItem indexEntity) {
|
||||
String useDateStr = '';
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n 永久';
|
||||
useDateStr = '永久';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n 单次';
|
||||
useDateStr = '单次';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr = '循环';
|
||||
//根据类型获取限时有效期样式
|
||||
Widget getPeriodValidityWidget() {
|
||||
int? dateType = state.itemData.value.keyType;
|
||||
if (dateType == XSConstantMacro.keyTypeLong) {
|
||||
return getLongTypeDateWidget();
|
||||
} else if (dateType == XSConstantMacro.keyTypeTime) {
|
||||
return getTimeLimitTypeDateWidget();
|
||||
} else if (dateType == XSConstantMacro.keyTypeOnce) {
|
||||
return getOnceTypeDateWidget();
|
||||
} else if (dateType == XSConstantMacro.keyTypeLoop) {
|
||||
return getLoopTypeDateWidget();
|
||||
}
|
||||
|
||||
return useDateStr;
|
||||
return Container();
|
||||
}
|
||||
|
||||
//永久钥匙
|
||||
Widget getLongTypeDateWidget() {
|
||||
return CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: '永久',
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.electronicKeyDetailChangeDate,
|
||||
arguments: {"itemData": state.itemData.value});
|
||||
});
|
||||
}
|
||||
|
||||
//限时钥匙
|
||||
Widget getTimeLimitTypeDateWidget() {
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
|
||||
String useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
|
||||
return CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
allHeight: 90.h,
|
||||
rightTitle: useDateStr,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.electronicKeyDetailChangeDate,
|
||||
arguments: {"itemData": state.itemData.value});
|
||||
});
|
||||
}
|
||||
|
||||
//单次钥匙
|
||||
Widget getOnceTypeDateWidget() {
|
||||
return CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: '单次',
|
||||
isHaveDirection: false,
|
||||
);
|
||||
}
|
||||
|
||||
//循环钥匙
|
||||
Widget getLoopTypeDateWidget() {
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
|
||||
String useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)} \n ${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
|
||||
List getEffectiveDateList = [];
|
||||
List weekDaysList = state.itemData.value.weekDays!;
|
||||
if (weekDaysList.isNotEmpty) {
|
||||
String effectiveDateStr = '';
|
||||
for (int i = 0; i < weekDaysList.length; i++) {
|
||||
if (weekDaysList[i] == 1) {
|
||||
effectiveDateStr = '一';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 2) {
|
||||
effectiveDateStr = '二';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 3) {
|
||||
effectiveDateStr = '三';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 4) {
|
||||
effectiveDateStr = '四';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 5) {
|
||||
effectiveDateStr = '五';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 6) {
|
||||
effectiveDateStr = '六';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 7) {
|
||||
effectiveDateStr = '日';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
allHeight: 90.h,
|
||||
rightTitle: useDateStr,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyPeriodValidityPage);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: '有效日',
|
||||
rightTitle: getEffectiveDateList.map((e) => e.toString()).join(','),
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyPeriodValidityPage);
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
//发送时间
|
||||
String getSenderDate(ElectronicKeyListItem indexEntity) {
|
||||
String senderDate = '';
|
||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
senderDate = dateStr.toLocal().toString().substring(0, 16);
|
||||
return senderDate;
|
||||
}
|
||||
|
||||
// Widget commonItem(String leftTitle, String rightTitle,
|
||||
// {bool isHaveDirection = false,
|
||||
// bool isHaveLine = false,
|
||||
// bool isHaveRightWidget = false,
|
||||
// Widget? rightWidget,
|
||||
// Function()? action}) {
|
||||
// return GestureDetector(
|
||||
// onTap: action,
|
||||
// child: Column(
|
||||
// // mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Container(
|
||||
// // height: 80.h,
|
||||
// color: Colors.white,
|
||||
// padding: EdgeInsets.only(
|
||||
// left: 20.w, right: 10.w, top: 20.w, bottom: 20.w),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// SizedBox(width: 20.w),
|
||||
// Text(
|
||||
// leftTitle,
|
||||
// style:
|
||||
// TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
// ),
|
||||
// SizedBox(width: 20.w),
|
||||
// Expanded(
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// isHaveRightWidget
|
||||
// ? rightWidget!
|
||||
// : Text(
|
||||
// rightTitle,
|
||||
// textAlign: TextAlign.end,
|
||||
// style: TextStyle(
|
||||
// fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(width: 5.w),
|
||||
// isHaveDirection
|
||||
// ? Image.asset(
|
||||
// 'images/icon_right.png',
|
||||
// width: 50.w,
|
||||
// height: 50.w,
|
||||
// )
|
||||
// : SizedBox(width: 10.w),
|
||||
// // SizedBox(width:10.w),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// isHaveLine
|
||||
// ? Container(
|
||||
// height: 0.5.h,
|
||||
// color: Colors.grey,
|
||||
// )
|
||||
// : Container()
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
CupertinoSwitch _switch(isOn) {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
@ -253,33 +267,6 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//修改钥匙名称请求
|
||||
Future<void> modifyKeyNameRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.modifyKeyNameForAdmin(
|
||||
itemData.keyId.toString(), _changeNameController.text, '');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("修改要是名称成功啦啦啦啦啦");
|
||||
Toast.show(msg: "修改成功");
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//删除电子钥匙名称请求
|
||||
Future<void> deleteKeyRequest() async {
|
||||
ElectronicKeyListEntity entity =
|
||||
await ApiRepository.to.deleteElectronicKey(itemData.keyId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("删除电子钥匙成功");
|
||||
Toast.show(msg: "删除成功");
|
||||
setState(() {
|
||||
Navigator.pop(context, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@ -288,11 +275,11 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
title:
|
||||
"${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}",
|
||||
tipTitle: "请输入",
|
||||
controller: _changeNameController,
|
||||
controller: state.changeNameController,
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
if (_changeNameController.text.isNotEmpty) {
|
||||
modifyKeyNameRequest();
|
||||
if (state.changeNameController.text.isNotEmpty) {
|
||||
logic.modifyKeyNameRequest();
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
@ -304,7 +291,7 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
@ -312,14 +299,12 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
deleteKeyRequest();
|
||||
logic.deleteKeyRequest();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
|
||||
class ElectronicKeyDetailState {
|
||||
final itemData = ElectronicKeyListItem().obs;
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
|
||||
ElectronicKeyDetailState() {
|
||||
Map map = Get.arguments;
|
||||
itemData.value = map["itemData"];
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
@ -8,6 +8,8 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
@ -36,7 +38,7 @@ class _ElectronicKeyDetailChangeDateState
|
||||
late List weekDays = [];
|
||||
late String pwdId = '';
|
||||
late String lockId = '';
|
||||
late String fromType = '';// 1 从指纹详情进入
|
||||
late String fromType = ''; // 1 从指纹详情进入
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -67,9 +69,8 @@ class _ElectronicKeyDetailChangeDateState
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
if(fromType == "1"){
|
||||
|
||||
}else{
|
||||
if (fromType == "1") {
|
||||
} else {
|
||||
if (lockId.isNotEmpty && pwdId.isNotEmpty) {
|
||||
updatePwdRequest();
|
||||
} else {
|
||||
@ -158,7 +159,6 @@ class _ElectronicKeyDetailChangeDateState
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
|
||||
@ -85,10 +85,11 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
btnName: TranslationLoader.lanKeys!.sendKey!.tr,
|
||||
onClick: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.sendElectronicKeyManagePage, arguments: {
|
||||
// "lockMainEntity": state.lockMainEntity.value,
|
||||
"keyInfo": state.keyInfo.value
|
||||
}).then((val) {
|
||||
context, Routers.sendElectronicKeyManagePage,
|
||||
arguments: {
|
||||
// "lockMainEntity": state.lockMainEntity.value,
|
||||
"keyInfo": state.keyInfo.value
|
||||
}).then((val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
@ -145,7 +146,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
top: 18.0, left: -19.0, right: -15.0, bottom: 2),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
@ -161,6 +162,8 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -201,14 +204,14 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
),
|
||||
child: _electronicKeyItem('images/controls_user.png',
|
||||
indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () {
|
||||
Navigator.pushNamed(context, Routers.electronicKeyDetailPage,
|
||||
arguments: {"itemData": indexEntity}).then((val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}),
|
||||
Navigator.pushNamed(context, Routers.electronicKeyDetailPage,
|
||||
arguments: {"itemData": indexEntity}).then((val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
@ -267,6 +270,8 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
//使用期限
|
||||
String getUseDateStr(ElectronicKeyListItem indexEntity) {
|
||||
String useDateStr = '';
|
||||
DateTime sendDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
@ -277,14 +282,11 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||
useDateStr = "永久";
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||
useDateStr = "单次";
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr = '循环';
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
class ElectronicKeyPeriodValidityLogic extends BaseGetXController {
|
||||
final ElectronicKeyPeriodValidityState state =
|
||||
ElectronicKeyPeriodValidityState();
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/KeyPeriodValidityModel.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_logic.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
@ -22,35 +24,22 @@ class ElectronicKeyPeriodValidityPage extends StatefulWidget {
|
||||
|
||||
class _ElectronicKeyPeriodValidityPageState
|
||||
extends State<ElectronicKeyPeriodValidityPage> {
|
||||
List validityTextList = [
|
||||
TranslationLoader.lanKeys!.sundayShort!.tr,
|
||||
TranslationLoader.lanKeys!.mondayShort!.tr,
|
||||
TranslationLoader.lanKeys!.tuesdayShort!.tr,
|
||||
TranslationLoader.lanKeys!.wednesdayShort!.tr,
|
||||
TranslationLoader.lanKeys!.thursdayShort!.tr,
|
||||
TranslationLoader.lanKeys!.fridayShort!.tr,
|
||||
TranslationLoader.lanKeys!.saturdayShort!.tr
|
||||
];
|
||||
List validityDataList = []; //自定义数据块
|
||||
List selectIndexList = []; //选中的有效期数组
|
||||
String _selectEffectiveDate = ''; //生效时间
|
||||
String _selectFailureDate = ''; //失效时间
|
||||
late DateTime _effectiveDateTime;
|
||||
late DateTime _failureDateTime;
|
||||
final logic = Get.put(ElectronicKeyPeriodValidityLogic());
|
||||
final state = Get.find<ElectronicKeyPeriodValidityLogic>().state;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
for (var i = 0; i < validityTextList.length; i++) {
|
||||
for (var i = 0; i < state.validityTextList.value.length; i++) {
|
||||
int validityValue = 0;
|
||||
if (i == 0) {
|
||||
validityValue = 7;
|
||||
} else {
|
||||
validityValue = i;
|
||||
}
|
||||
KeyPeriodValidityModel model =
|
||||
KeyPeriodValidityModel(validityTextList[i], i, false, validityValue);
|
||||
validityDataList.add(model);
|
||||
KeyPeriodValidityModel model = KeyPeriodValidityModel(
|
||||
state.validityTextList.value[i], i, false, validityValue);
|
||||
state.validityDataList.value.add(model);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +90,8 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
itemCount: 7,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
KeyPeriodValidityModel model = validityDataList[index];
|
||||
KeyPeriodValidityModel model =
|
||||
state.validityDataList.value[index];
|
||||
return btnItem(model);
|
||||
}))
|
||||
],
|
||||
@ -110,112 +100,116 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
}
|
||||
|
||||
Widget btnItem(KeyPeriodValidityModel model) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
model.isValidity = !model.isValidity;
|
||||
if (model.isValidity) {
|
||||
selectIndexList.add(model.validityValue);
|
||||
} else {
|
||||
selectIndexList.remove(model.validityValue);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
child: Container(
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
margin: EdgeInsets.all(10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: selectIndexList.contains(model.validityValue)
|
||||
? Colors.blue
|
||||
: Colors.white,
|
||||
border: Border.all(width: 1, color: AppColors.greyBackgroundColor),
|
||||
borderRadius: BorderRadius.circular(30.w),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
model.validityText,
|
||||
style: TextStyle(
|
||||
fontSize: 20.sp,
|
||||
color: selectIndexList.contains(model.validityValue)
|
||||
? Colors.white
|
||||
: AppColors.darkGrayTextColor),
|
||||
)),
|
||||
),
|
||||
);
|
||||
return Obx(() => GestureDetector(
|
||||
onTap: () {
|
||||
model.isValidity = !model.isValidity;
|
||||
if (model.isValidity) {
|
||||
state.selectIndexList.value.add(model.validityValue);
|
||||
} else {
|
||||
state.selectIndexList.value.remove(model.validityValue);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
child: Container(
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
margin: EdgeInsets.all(10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: state.selectIndexList.value.contains(model.validityValue)
|
||||
? Colors.blue
|
||||
: Colors.white,
|
||||
border:
|
||||
Border.all(width: 1, color: AppColors.greyBackgroundColor),
|
||||
borderRadius: BorderRadius.circular(30.w),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
model.validityText,
|
||||
style: TextStyle(
|
||||
fontSize: 20.sp,
|
||||
color:
|
||||
state.selectIndexList.value.contains(model.validityValue)
|
||||
? Colors.white
|
||||
: AppColors.darkGrayTextColor),
|
||||
)),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget bottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
// rightTitle: _effectiveTime,
|
||||
// isHaveDirection: true,
|
||||
// isHaveLine: true,
|
||||
// action: () {
|
||||
// Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
// onConfirm: (p) {
|
||||
// _effectiveTime = '${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
|
||||
// setState(() {});
|
||||
// });
|
||||
// }),
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
// rightTitle: _failureTime,
|
||||
// isHaveDirection: true,
|
||||
// action: () {
|
||||
// Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
// onConfirm: (p) {
|
||||
// _failureTime = '${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
|
||||
// setState(() {});
|
||||
// });
|
||||
// }),
|
||||
// Container(height: 10.h),
|
||||
CommonItem(
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveDate!.tr,
|
||||
rightTitle: _selectEffectiveDate,
|
||||
rightTitle: state.selectEffectiveDate.value,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
_effectiveDateTime = DateTime.parse(
|
||||
state.isHaveEffectiveDate.value = true;
|
||||
state.effectiveDateTime.value = DateTime.parse(
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||
_selectEffectiveDate = formatDate(_effectiveDateTime,
|
||||
state.selectEffectiveDate.value = formatDate(
|
||||
state.effectiveDateTime.value,
|
||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
||||
|
||||
setState(() {});
|
||||
});
|
||||
}),
|
||||
CommonItem(
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureDate!.tr,
|
||||
rightTitle: _selectFailureDate,
|
||||
rightTitle: state.selectFailureDate.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
_failureDateTime = DateTime.parse(
|
||||
state.isHaveFailureDate.value = true;
|
||||
state.failureDateTime.value = DateTime.parse(
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||
_selectFailureDate = formatDate(_failureDateTime,
|
||||
state.selectFailureDate.value = formatDate(
|
||||
state.failureDateTime.value,
|
||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
||||
setState(() {});
|
||||
});
|
||||
}),
|
||||
})),
|
||||
Container(height: 40.h),
|
||||
SubmitBtn(
|
||||
Obx(() => SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
isDisabled: (state.selectIndexList.value.isNotEmpty &&
|
||||
state.isHaveEffectiveDate.value == true &&
|
||||
state.isHaveFailureDate.value == true)
|
||||
? true
|
||||
: false,
|
||||
onClick: () {
|
||||
Map<String, dynamic> resultMap = {};
|
||||
resultMap['validityValue'] = selectIndexList;
|
||||
resultMap['starDate'] = _effectiveDateTime;
|
||||
resultMap['endDate'] = _failureDateTime;
|
||||
Navigator.pop(context, resultMap);
|
||||
}),
|
||||
if ((state.selectIndexList.value.isNotEmpty &&
|
||||
state.isHaveEffectiveDate.value == true &&
|
||||
state.isHaveFailureDate.value == true)) {
|
||||
DateTime startDateTime = DateTime(
|
||||
state.effectiveDateTime.value.year,
|
||||
state.effectiveDateTime.value.month,
|
||||
state.effectiveDateTime.value.day,
|
||||
state.effectiveDateTime.value.hour,
|
||||
state.effectiveDateTime.value.minute);
|
||||
DateTime endDateTime = DateTime(
|
||||
state.failureDateTime.value.year,
|
||||
state.failureDateTime.value.month,
|
||||
state.failureDateTime.value.day,
|
||||
state.failureDateTime.value.hour,
|
||||
state.failureDateTime.value.minute);
|
||||
//时间判断
|
||||
if (!startDateTime.isBefore(endDateTime) ||
|
||||
startDateTime.isAtSameMomentAs(endDateTime)) {
|
||||
Toast.show(msg: '失效时间需大于生效时间');
|
||||
} else {
|
||||
Map<String, dynamic> resultMap = {};
|
||||
resultMap['validityValue'] = state.selectIndexList.value;
|
||||
resultMap['starDate'] = state.effectiveDateTime.value;
|
||||
resultMap['endDate'] = state.failureDateTime.value;
|
||||
Navigator.pop(context, resultMap);
|
||||
}
|
||||
}
|
||||
})),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
import '../../../lockMian/entity/lockListInfo_entity.dart';
|
||||
|
||||
class ElectronicKeyPeriodValidityState {
|
||||
TextEditingController searchController = TextEditingController(); //邮箱/手机号输入框
|
||||
final keyInfo = LockListInfoItemEntity().obs;
|
||||
// final lockMainEntity = LockMainEntity().obs;
|
||||
var pageNum = 1.obs; //请求页码
|
||||
final pageSize = 20.obs; //请求每页数据条数
|
||||
final itemDataList = <ElectronicKeyListItem>[].obs;
|
||||
|
||||
final validityTextList = [
|
||||
TranslationLoader.lanKeys!.sundayShort!.tr,
|
||||
TranslationLoader.lanKeys!.mondayShort!.tr,
|
||||
TranslationLoader.lanKeys!.tuesdayShort!.tr,
|
||||
TranslationLoader.lanKeys!.wednesdayShort!.tr,
|
||||
TranslationLoader.lanKeys!.thursdayShort!.tr,
|
||||
TranslationLoader.lanKeys!.fridayShort!.tr,
|
||||
TranslationLoader.lanKeys!.saturdayShort!.tr
|
||||
].obs;
|
||||
final validityDataList = [].obs; //自定义数据块
|
||||
final selectIndexList = [].obs; //选中的有效期数组
|
||||
final selectEffectiveDate = ''.obs; //生效时间
|
||||
final selectFailureDate = ''.obs; //失效时间
|
||||
DateTime dateTime = DateTime.now();
|
||||
final effectiveDateTime = DateTime.now().obs;
|
||||
final failureDateTime = DateTime.now().obs;
|
||||
var isHaveEffectiveDate = false.obs;
|
||||
var isHaveFailureDate = false.obs;
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
@ -9,6 +9,8 @@ import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../../tools/commonItem.dart';
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_utils/get_utils.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
class SendElectronicKeyLogic extends BaseGetXController {
|
||||
@ -14,18 +14,38 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
||||
//发送钥匙请求
|
||||
Future<void> sendElectronicKeyRequest(BuildContext widgetContext) async {
|
||||
String lockID = state.keyInfo.value.lockId.toString();
|
||||
String getKeyType = (int.parse(state.type.value) + 1).toString();
|
||||
if (state.type.value == '0') {
|
||||
state.failureTimestamp.value =
|
||||
state.failureDateTime.value.millisecondsSinceEpoch;
|
||||
state.effectiveTimestamp.value =
|
||||
state.effectiveDateTime.value.millisecondsSinceEpoch;
|
||||
int typeValue = int.parse(state.type.value);
|
||||
switch (typeValue) {
|
||||
case 0:
|
||||
{
|
||||
typeValue = XSConstantMacro.keyTypeTime;
|
||||
state.failureTimestamp.value =
|
||||
state.failureDateTime.value.millisecondsSinceEpoch;
|
||||
state.effectiveTimestamp.value =
|
||||
state.effectiveDateTime.value.millisecondsSinceEpoch;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
typeValue = XSConstantMacro.keyTypeLong;
|
||||
break;
|
||||
case 2:
|
||||
typeValue = XSConstantMacro.keyTypeOnce;
|
||||
break;
|
||||
case 3:
|
||||
typeValue = XSConstantMacro.keyTypeLoop;
|
||||
break;
|
||||
default:
|
||||
typeValue = XSConstantMacro.keyTypeTime;
|
||||
break;
|
||||
}
|
||||
String getKeyType = typeValue.toString();
|
||||
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
createUser: state.isCreateUser.value ? "1" : "0",
|
||||
createUser: state.isCreateUser.value == true ? "1" : "0",
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: '1',
|
||||
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
|
||||
? '1'
|
||||
: '2',
|
||||
endDate: state.failureTimestamp.value.toString(),
|
||||
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
||||
isCameraEnable: '2',
|
||||
@ -38,20 +58,37 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
||||
receiverUsername: state.emailOrPhoneController.text,
|
||||
remarks: '',
|
||||
startDate: state.effectiveTimestamp.value.toString(),
|
||||
weekDays: state.weekdaysList);
|
||||
weekDays: state.weekdaysList.value);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
state.isSendSuccess.value = true;
|
||||
} else {
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
_showDialog(widgetContext, '${entity.errorMsg}');
|
||||
if (isPhoneNumber(state.emailOrPhoneController.text) == true) {
|
||||
_showPhoneDialog(widgetContext, '${entity.errorMsg}');
|
||||
} else {
|
||||
_showEmailDialog(widgetContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isPhoneNumber(String input) {
|
||||
// 手机号正则表达式,这里简化为11位数字
|
||||
final RegExp phoneRegExp = RegExp(r'^\d{11}$');
|
||||
return phoneRegExp.hasMatch(input);
|
||||
}
|
||||
|
||||
bool isEmail(String input) {
|
||||
// 邮箱正则表达式,这里简化为常见格式
|
||||
final RegExp emailRegExp =
|
||||
RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$');
|
||||
return emailRegExp.hasMatch(input);
|
||||
}
|
||||
|
||||
//用户未注册确认弹窗
|
||||
void _showDialog(widgetContext, String errMsg) {
|
||||
void _showPhoneDialog(widgetContext, String errMsg) {
|
||||
showCupertinoDialog(
|
||||
context: widgetContext,
|
||||
builder: (context) {
|
||||
@ -59,13 +96,19 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
||||
title: const Text('接收者号码未注册,请选择号码所在的国家并重新发送'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.cancel!.tr,
|
||||
style: TextStyle(color: AppColors.mainColor),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.selet!.tr),
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.selet!.tr,
|
||||
style: TextStyle(color: AppColors.mainColor),
|
||||
),
|
||||
onPressed: () async {
|
||||
//选择国家代码
|
||||
state.isCreateUser.value = true;
|
||||
@ -84,4 +127,39 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
//用户未注册确认弹窗---邮箱
|
||||
void _showEmailDialog(widgetContext) {
|
||||
showCupertinoDialog(
|
||||
context: widgetContext,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text('是否发送电子钥匙给未注册账号\n${state.emailOrPhoneController.text}'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.cancel!.tr,
|
||||
style: TextStyle(color: AppColors.mainColor),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.sure!.tr,
|
||||
style: TextStyle(color: AppColors.mainColor),
|
||||
),
|
||||
onPressed: () {
|
||||
state.isCreateUser.value = true;
|
||||
Navigator.of(context).pop();
|
||||
|
||||
sendElectronicKeyRequest(widgetContext);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
@ -10,6 +8,8 @@ import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
@ -31,10 +31,17 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
final logic = Get.put(SendElectronicKeyLogic());
|
||||
final state = Get.find<SendElectronicKeyLogic>().state;
|
||||
static const methodChannel = MethodChannel('talkPlugin');
|
||||
bool isDemoMode = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
initState() {
|
||||
super.initState();
|
||||
|
||||
getDemoMode();
|
||||
}
|
||||
|
||||
Future<void> getDemoMode() async {
|
||||
isDemoMode = (await Storage.getBool(ifIsDemoModeOrNot))!;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -217,11 +224,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: state.weekdaysList.isEmpty
|
||||
rightTitle: state.weekdaysList.value.isEmpty
|
||||
? ''
|
||||
: state.weekdaysList
|
||||
.reduce((value, element) => value + ',' + element)
|
||||
.toString(),
|
||||
: state.weekdaysList.value.join(','),
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
@ -262,21 +267,29 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.send!.tr,
|
||||
onClick: () async {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
onClick: () {
|
||||
if (isDemoMode == false) {
|
||||
DateTime startDateTime = DateTime(
|
||||
state.effectiveDateTime.value.year,
|
||||
state.effectiveDateTime.value.month,
|
||||
state.effectiveDateTime.value.day,
|
||||
state.effectiveDateTime.value.hour,
|
||||
state.effectiveDateTime.value.minute);
|
||||
DateTime endDateTime = DateTime(
|
||||
state.failureDateTime.value.year,
|
||||
state.failureDateTime.value.month,
|
||||
state.failureDateTime.value.day,
|
||||
state.failureDateTime.value.hour,
|
||||
state.failureDateTime.value.minute);
|
||||
//发送钥匙请求
|
||||
if (state.emailOrPhoneController.text.isNotEmpty &&
|
||||
state.keyNameController.text.isNotEmpty) {
|
||||
if (int.parse(widget.type) == 0) {
|
||||
//失效时间大于生效时间
|
||||
if (state.failureDateTime.value
|
||||
.compareTo(state.effectiveDateTime.value) ==
|
||||
1) {
|
||||
logic.sendElectronicKeyRequest(context);
|
||||
} else {
|
||||
if (!startDateTime.isBefore(endDateTime) ||
|
||||
startDateTime.isAtSameMomentAs(endDateTime)) {
|
||||
Toast.show(msg: '失效时间需大于生效时间');
|
||||
} else {
|
||||
logic.sendElectronicKeyRequest(context);
|
||||
}
|
||||
} else {
|
||||
logic.sendElectronicKeyRequest(context);
|
||||
@ -285,6 +298,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
Toast.show(msg: '请完善信息');
|
||||
}
|
||||
} else {
|
||||
//演示模式不获取接口
|
||||
Toast.show(msg: '演示模式');
|
||||
}
|
||||
}),
|
||||
@ -295,9 +309,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.massSendElectronicKeyManagePage);
|
||||
@ -406,9 +419,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
|
||||
var entity = await ApiRepository.to.setRoomStatusData(
|
||||
lockId: state.keyInfo.value.lockId!,
|
||||
roomStatus:1,
|
||||
roomStatus: 1,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("标记为已入住成功啦啦啦啦啦");
|
||||
Toast.show(msg: "标记成功");
|
||||
setState(() {});
|
||||
@ -440,6 +453,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
@ -12,7 +12,6 @@ class SendElectronicKeyState {
|
||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||
late Contact contact;
|
||||
final keyInfo = LockListInfoItemEntity().obs;
|
||||
// final lockMainEntity = LockMainEntity().obs;
|
||||
|
||||
final isRemoteUnlock = false.obs; //是否允许远程开锁
|
||||
final isAuthentication = false.obs; //是否可以实名认证
|
||||
@ -38,7 +37,6 @@ class SendElectronicKeyState {
|
||||
|
||||
SendElectronicKeyState() {
|
||||
Map map = Get.arguments;
|
||||
// lockMainEntity.value = map["lockMainEntity"];
|
||||
keyInfo.value = map["keyInfo"];
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/submitBtn.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
|
||||
class AddFaceTipPage extends StatefulWidget {
|
||||
const AddFaceTipPage({Key? key}) : super(key: key);
|
||||
@ -21,7 +22,7 @@ class _AddFaceTipPageState extends State<AddFaceTipPage> {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.addLock!.tr,
|
||||
barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
@ -66,7 +67,9 @@ class _AddFaceTipPageState extends State<AddFaceTipPage> {
|
||||
child: SubmitBtn(
|
||||
btnName: "开始添加", //TranslationLoader.lanKeys!.next!.tr,
|
||||
borderRadius: 20.w,
|
||||
onClick: () {}),
|
||||
onClick: () {
|
||||
Toast.show(msg: "请确保在设备附近,设备未被连接,设备已打开");
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -0,0 +1,38 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import 'addFaceTypeManage_tabbar.dart';
|
||||
|
||||
class AddFaceTypeManagePage extends StatefulWidget {
|
||||
const AddFaceTypeManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFaceTypeManagePage> createState() => _AddFaceTypeManagePageState();
|
||||
}
|
||||
|
||||
class _AddFaceTypeManagePageState extends State<AddFaceTypeManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
AddFaceTypeManageTabbar(initialIndex: index),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../addFaceType_page.dart';
|
||||
|
||||
class AddFaceTypeManageTabbar extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
|
||||
AddFaceTypeManageTabbar({Key? key, required this.initialIndex}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFaceTypeManageTabbar> createState() => _AddFaceTypeManageTabbarState();
|
||||
}
|
||||
|
||||
class _AddFaceTypeManageTabbarState extends State<AddFaceTypeManageTabbar> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, seletType: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, seletType: "1"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, seletType: "2"),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
initialIndex: widget.initialIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
return TabBar(
|
||||
controller: _tabController,
|
||||
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
|
||||
isScrollable: true,
|
||||
indicatorColor: Colors.red,
|
||||
unselectedLabelColor: Colors.black,
|
||||
unselectedLabelStyle: TextStyle(
|
||||
color: AppColors.mainColor,
|
||||
fontSize: 24.sp,
|
||||
),
|
||||
automaticIndicatorColorAdjustment: true,
|
||||
labelColor: AppColors.mainColor,
|
||||
labelStyle: TextStyle(
|
||||
color: AppColors.mainColor,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
indicator: CustomUnderlineTabIndicator(
|
||||
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
|
||||
strokeCap: StrokeCap.round,
|
||||
width: 30.w),
|
||||
);
|
||||
}
|
||||
|
||||
Tab _tab(ItemView item) {
|
||||
return Tab(
|
||||
child: SizedBox(
|
||||
width: 1.sw / 5,
|
||||
child: Text(item.title, textAlign: TextAlign.center)));
|
||||
}
|
||||
|
||||
Widget _pageWidget() {
|
||||
return Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _itemTabs
|
||||
.map((ItemView item) => AddFaceTypePage(seletType: item.seletType,))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemView {
|
||||
const ItemView({required this.title, required this.seletType});
|
||||
|
||||
final String title;
|
||||
final String seletType;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'addFaceType_state.dart';
|
||||
|
||||
class AddFaceTypeLogic extends BaseGetXController{
|
||||
AddFaceTypeState state = AddFaceTypeState();
|
||||
|
||||
}
|
||||
@ -0,0 +1,314 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'addFaceType_logic.dart';
|
||||
|
||||
class AddFaceTypePage extends StatefulWidget {
|
||||
final String seletType;
|
||||
|
||||
const AddFaceTypePage({Key? key, required this.seletType}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFaceTypePage> createState() => _AddFaceTypePageState();
|
||||
}
|
||||
|
||||
class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
final logic = Get.put(AddFaceTypeLogic());
|
||||
final state = Get.find<AddFaceTypeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.seletType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyTimeLimitWidget(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// 循环
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(
|
||||
Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value =
|
||||
result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value =
|
||||
result['endDate'].millisecondsSinceEpoch;
|
||||
print(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
// 密码命名输入框
|
||||
Widget perpetualKeyWidget(
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(rightTitle)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 限时顶部选择日期
|
||||
Widget keyTimeLimitWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.beginTimeTimestamp.value =
|
||||
DateTime.parse(state.beginTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.endTimeTimestamp.value =
|
||||
DateTime.parse(state.endTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.face!.tr,
|
||||
// rightTitle: "",
|
||||
// isTipsImg: false,
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget: SizedBox(
|
||||
// width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||
onClick: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
// print("state.seletType:${state.seletType.value}");
|
||||
if (state.nameController.text.isEmpty) {
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
Get.toNamed(Routers.addFaceTipPage);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 300.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addLock.png',
|
||||
width: 150.w,
|
||||
height: 150.w,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Text(
|
||||
"操作成功,密码为",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
"62689876",
|
||||
style: TextStyle(
|
||||
fontSize: 60.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '分享',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '标记为:已入住',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: true,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
// state.isStressFingerprint.value = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddFaceTypeState{
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = "".obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs;// 结束时间时间戳
|
||||
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'faceList_state.dart';
|
||||
|
||||
class FaceListLogic extends BaseGetXController{
|
||||
FaceListState state = FaceListState();
|
||||
|
||||
}
|
||||
252
star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart
Normal file
252
star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart
Normal file
@ -0,0 +1,252 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'faceList_logic.dart';
|
||||
|
||||
class FaceList extends StatefulWidget {
|
||||
const FaceList({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FaceList> createState() => _FaceListState();
|
||||
}
|
||||
|
||||
class _FaceListState extends State<FaceList> {
|
||||
final logic = Get.put(FaceListLogic());
|
||||
final state = Get.find<FaceListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.face!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName:
|
||||
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.addFaceTypeManagePage);
|
||||
if (data != null) {
|
||||
// 遥控添加
|
||||
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.searchController,
|
||||
autofocus: false,
|
||||
onChanged: (value) {
|
||||
print("onChanged:$value");
|
||||
},
|
||||
onEditingComplete: () {
|
||||
print("onEditingComplete:");
|
||||
},
|
||||
onSubmitted: (value) {
|
||||
// 调用遥控列表
|
||||
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
icon: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.h, bottom: 20.h, right: 20.w, left: 10.w),
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_search.png',
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
String typeImgName = 'images/icon_card.png';
|
||||
|
||||
return const NoData();
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String idStr) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
showIosTipViewDialog(context, idStr);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, String keyId) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
// 遥控删除
|
||||
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(BuildContext context,) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('重置后信息都会清除哦,确认要重置吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
// 遥控重置
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FaceListState{
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
}
|
||||
@ -51,11 +51,6 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
@ -64,7 +59,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.ifConnectScuess.value = true;
|
||||
state.fingerprintNumber.value = reply.data.last.toString();
|
||||
// state.fingerprintNumber.value = reply.data.last.toString();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -75,20 +70,24 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
token: token,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
@ -110,11 +109,6 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
Future<void> _replyAddFingerprintProcess(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("33 status:$status");
|
||||
|
||||
@ -155,11 +149,6 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
Future<void> _replyAddFingerprintConfirmation(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
@ -168,7 +157,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
if(state.isCoerced.value == "2"){
|
||||
if(state.isCoerced.value == "1"){
|
||||
// 非胁迫指纹
|
||||
addFingerprintsData(reply.data[6].toString());
|
||||
}else{
|
||||
@ -199,11 +188,6 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
Future<void> _replyAddStressFingerprint(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
@ -217,6 +201,36 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
case 0x06:
|
||||
//需要权限
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddStressFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
fingerType:1,
|
||||
useCountLimit:1,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
signKey: getSignKeyList
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
@ -255,10 +269,10 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -278,23 +292,28 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
print("StressFingerprintToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddStressFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
fingerType:1,
|
||||
useCountLimit:1,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
signKey: getSignKeyList
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -307,14 +326,14 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
endDate: state.endDate.value,
|
||||
addType:state.addType.value,
|
||||
fingerprintName: state.fingerprintName.value,
|
||||
fingerprintNumber: "123456",
|
||||
fingerprintNumber: fingerprintUserNo,
|
||||
fingerprintType: state.fingerprintType.value,
|
||||
isCoerced: state.isCoerced.value,
|
||||
startDate: state.startDate.value,
|
||||
weekDay: state.weekDay.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
// Toast.show(msg: "添加成功");
|
||||
updateFingerprintUserNoLoadData(entity.data!.fingerprintId.toString(), fingerprintUserNo);
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ class _AddFingerprintPageState extends State<AddFingerprintPage> {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.addLock!.tr,
|
||||
barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
@ -8,7 +8,7 @@ class AddFingerprintState{
|
||||
final endDate = "".obs;
|
||||
final addType = "".obs;
|
||||
final fingerprintName = "".obs;
|
||||
final fingerprintNumber = "".obs;
|
||||
// final fingerprintNumber = "".obs;
|
||||
final fingerprintType = "".obs;
|
||||
final isCoerced = "".obs;
|
||||
final startDate = "".obs;
|
||||
@ -21,9 +21,10 @@ class AddFingerprintState{
|
||||
endDate.value = map["endDate"];
|
||||
addType.value = map["addType"];
|
||||
fingerprintName.value = map["fingerprintName"];
|
||||
fingerprintNumber.value = map["fingerprintNumber"];
|
||||
// fingerprintNumber.value = map["fingerprintNumber"];
|
||||
fingerprintType.value = map["fingerprintType"];
|
||||
isCoerced.value = map["isCoerced"];
|
||||
print("isCoerced.valueisCoerced.value:${isCoerced.value}");
|
||||
startDate.value = map["startDate"];
|
||||
lockId.value = map["lockId"];
|
||||
weekDay.value = map["weekDay"];
|
||||
@ -0,0 +1,45 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import 'addFingerprintTypeManage_tabbar.dart';
|
||||
|
||||
class AddFingerprintTypeManagePage extends StatefulWidget {
|
||||
const AddFingerprintTypeManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFingerprintTypeManagePage> createState() => _AddFingerprintTypeManagePageState();
|
||||
}
|
||||
|
||||
class _AddFingerprintTypeManagePageState extends State<AddFingerprintTypeManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Map map = Get.arguments;
|
||||
var lockId = map["lockId"];
|
||||
var fromType = map["fromType"]; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";
|
||||
if(fromType == 2){
|
||||
fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
AddFingerprintTypeManageTabbar(initialIndex: index, lockId: lockId, fromType: fromType, fromTypeTwoStaffName:fromTypeTwoStaffName),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,108 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../addFingerprintType_page.dart';
|
||||
|
||||
class AddFingerprintTypeManageTabbar extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
var lockId = 0;
|
||||
var fromType = 0; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";// 从添加员工进入 传入员工名字
|
||||
|
||||
AddFingerprintTypeManageTabbar(
|
||||
{Key? key, required this.initialIndex, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFingerprintTypeManageTabbar> createState() => _AddFingerprintTypeManageTabbarState();
|
||||
}
|
||||
|
||||
class _AddFingerprintTypeManageTabbarState extends State<AddFingerprintTypeManageTabbar> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, seletType: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, seletType: "1"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, seletType: "2"),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
initialIndex: widget.initialIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
return TabBar(
|
||||
controller: _tabController,
|
||||
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
|
||||
isScrollable: true,
|
||||
indicatorColor: Colors.red,
|
||||
unselectedLabelColor: Colors.black,
|
||||
unselectedLabelStyle: TextStyle(
|
||||
color: AppColors.mainColor,
|
||||
fontSize: 24.sp,
|
||||
),
|
||||
automaticIndicatorColorAdjustment: true,
|
||||
labelColor: AppColors.mainColor,
|
||||
labelStyle: TextStyle(
|
||||
color: AppColors.mainColor,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
indicator: CustomUnderlineTabIndicator(
|
||||
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
|
||||
strokeCap: StrokeCap.round,
|
||||
width: 30.w),
|
||||
);
|
||||
}
|
||||
|
||||
Tab _tab(ItemView item) {
|
||||
return Tab(
|
||||
child: SizedBox(
|
||||
width: 1.sw / 5,
|
||||
child: Text(item.title, textAlign: TextAlign.center)));
|
||||
}
|
||||
|
||||
Widget _pageWidget() {
|
||||
return Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _itemTabs
|
||||
.map((ItemView item) => AddFingerprintTypePage(
|
||||
seletType: item.seletType,
|
||||
lockId: widget.lockId,
|
||||
fromType: widget.fromType,
|
||||
fromTypeTwoStaffName:widget.fromTypeTwoStaffName
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemView {
|
||||
const ItemView({required this.title, required this.seletType});
|
||||
|
||||
final String title;
|
||||
final String seletType;
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'addFingerprintType_state.dart';
|
||||
|
||||
class AddFingerprintTypeLogic extends BaseGetXController{
|
||||
AddFingerprintState state = AddFingerprintState();
|
||||
|
||||
// 添加指纹
|
||||
void addFingerprintsData() async {
|
||||
var fingerprintType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
var startDate = "";
|
||||
var endDate = "";
|
||||
if (state.seletType.value == "0") {
|
||||
fingerprintType = 1;
|
||||
startDate = "0";
|
||||
endDate = "0";
|
||||
} else if (state.seletType.value == "1") {
|
||||
fingerprintType = 2;
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
if (state.endTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (int.parse(state.beginTimeTimestamp.value) >=
|
||||
int.parse(state.endTimeTimestamp.value)) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
startDate = state.beginTimeTimestamp.value;
|
||||
endDate = state.endTimeTimestamp.value;
|
||||
} else if (state.seletType.value == "2") {
|
||||
if (state.effectiveDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择生效时间");
|
||||
return;
|
||||
}
|
||||
if (state.failureDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择失效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.weekdaysList.value.isEmpty) {
|
||||
Toast.show(msg: "请选择有效日");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (state.effectiveDateTime.value >= state.failureDateTime.value) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
startDate = state.effectiveDateTime.value.toString();
|
||||
endDate = state.failureDateTime.value.toString();
|
||||
fingerprintType = 4;
|
||||
}
|
||||
|
||||
var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫指纹 2:胁迫指纹
|
||||
print("addOtherType startDate:$startDate endDate:$endDate isCoerced:$isCoerced");
|
||||
// 指纹
|
||||
Get.toNamed(Routers.addFingerprintPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"fingerprintName": state.nameController.text,
|
||||
"fingerprintNumber": "123456",
|
||||
"fingerprintType": fingerprintType.toString(),
|
||||
"isCoerced": isCoerced, // 1:非胁迫指纹 2:胁迫指纹
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,330 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'addFingerprintType_logic.dart';
|
||||
|
||||
class AddFingerprintTypePage extends StatefulWidget {
|
||||
final String seletType; // 永久限时循环下标
|
||||
final int lockId;
|
||||
final int fromType; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final String fromTypeTwoStaffName; // 从添加员工进入 传入员工名字
|
||||
|
||||
const AddFingerprintTypePage(
|
||||
{Key? key,
|
||||
required this.seletType,
|
||||
required this.lockId,
|
||||
required this.fromType,
|
||||
required this.fromTypeTwoStaffName})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFingerprintTypePage> createState() => _AddFingerprintTypePageState();
|
||||
}
|
||||
|
||||
class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
||||
final logic = Get.put(AddFingerprintTypeLogic());
|
||||
final state = Get.find<AddFingerprintTypeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
state.seletType.value = widget.seletType;
|
||||
state.lockId.value = widget.lockId;
|
||||
// state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Your code here
|
||||
});
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.seletType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyTimeLimitWidget(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// 循环
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(
|
||||
Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value =
|
||||
result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value =
|
||||
result['endDate'].millisecondsSinceEpoch;
|
||||
print(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
// 密码命名输入框
|
||||
Widget perpetualKeyWidget(
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(rightTitle)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 限时顶部选择日期
|
||||
Widget keyTimeLimitWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.beginTimeTimestamp.value =
|
||||
DateTime.parse(state.beginTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.endTimeTimestamp.value =
|
||||
DateTime.parse(state.endTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||
onClick: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
// print("state.seletType:${state.seletType.value}");
|
||||
if (state.nameController.text.isEmpty) {
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
logic.addFingerprintsData();
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 300.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addLock.png',
|
||||
width: 150.w,
|
||||
height: 150.w,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Text(
|
||||
"操作成功,密码为",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
"62689876",
|
||||
style: TextStyle(
|
||||
fontSize: 60.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '分享',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '标记为:已入住',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isStressFingerprint.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddFingerprintState{
|
||||
final lockId = 0.obs;
|
||||
final seletType = "0".obs;// 0永久 1显示 2循环
|
||||
final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final isStressFingerprint = false.obs;
|
||||
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = "".obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs;// 结束时间时间戳
|
||||
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
AddFingerprintState() {
|
||||
// Map map = Get.arguments;
|
||||
// lockId.value = map["lockId"];
|
||||
// fromType.value = map["fromType"];
|
||||
}
|
||||
}
|
||||
@ -1,52 +1,47 @@
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addFingerprint.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'otherTypeKeyDetail_state.dart';
|
||||
import 'fingerprintDetail_state.dart';
|
||||
|
||||
class OtherTypeKeyDetailLogic extends BaseGetXController{
|
||||
OtherTypeKeyDetailState state = OtherTypeKeyDetailState();
|
||||
class FingerprintDetailLogic extends BaseGetXController{
|
||||
FingerprintDetailState state = FingerprintDetailState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 添加指纹开始(删除单个指纹)
|
||||
if(reply is SenderAddFingerprintReply) {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
// 添加指纹开始(此处用作删除指纹)
|
||||
if((reply is SenderAddFingerprintReply)) {
|
||||
_replyAddFingerprintBegin(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加指纹开始
|
||||
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
|
||||
deletFingerprintsData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -60,15 +55,14 @@ class OtherTypeKeyDetailLogic extends BaseGetXController{
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
String? userID = await Storage.getUid();
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:userID,
|
||||
fingerNo:int.parse(state.typeNumber.value),
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
startTime:state.effectiveDateTime.value,
|
||||
endTime:state.failureDateTime.value,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -93,23 +87,6 @@ class OtherTypeKeyDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑指纹
|
||||
void editFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.editFingerprintsData(
|
||||
fingerprintId: state.keyId.value.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: state.effectiveDateTime.value.toString(),
|
||||
endDate: state.failureDateTime.value.toString(),
|
||||
isCoerced: state.isStressFingerprint.value ? "2" : "1",
|
||||
fingerprintName: state.changeNameController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除指纹
|
||||
Future<void> senderAddFingerprint() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
@ -123,15 +100,15 @@ class OtherTypeKeyDetailLogic extends BaseGetXController{
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
String? userID = await Storage.getUid();
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:userID,
|
||||
fingerNo:int.parse(state.typeNumber.value),
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
startTime:state.effectiveDateTime.value,
|
||||
endTime:state.failureDateTime.value,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -144,38 +121,7 @@ class OtherTypeKeyDetailLogic extends BaseGetXController{
|
||||
// 删除指纹
|
||||
void deletFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
type: "0",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑iC卡
|
||||
void editICCardData() async{
|
||||
var entity = await ApiRepository.to.editICCardData(
|
||||
cardId: state.keyId.value.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: state.effectiveDateTime.value.toString(),
|
||||
endDate: state.failureDateTime.value.toString(),
|
||||
isCoerced: state.isStressFingerprint.value ? "2" : "1",
|
||||
cardName: state.changeNameController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除IC卡
|
||||
void deletICCardData() async{
|
||||
var entity = await ApiRepository.to.deletIcCardData(
|
||||
cardId: state.fingerprintItemData.value.cardId.toString(),
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
type: "0",
|
||||
deleteType:"1"
|
||||
@ -186,6 +132,24 @@ class OtherTypeKeyDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑指纹
|
||||
void editFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.editFingerprintsData(
|
||||
fingerprintId: state.keyId.value.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: state.effectiveDateTime.value.toString(),
|
||||
endDate: state.failureDateTime.value.toString(),
|
||||
isCoerced: state.isStressFingerprint.value ? "2" : "1",
|
||||
fingerprintName: state.changeNameController.text,
|
||||
changeType: "1",
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
@ -199,7 +163,6 @@ class OtherTypeKeyDetailLogic extends BaseGetXController{
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
senderAddFingerprint();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -209,5 +172,4 @@ class OtherTypeKeyDetailLogic extends BaseGetXController{
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,324 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/showTFView.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'fingerprintDetail_logic.dart';
|
||||
|
||||
class FingerprintDetailPage extends StatefulWidget {
|
||||
const FingerprintDetailPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FingerprintDetailPage> createState() => _FingerprintDetailPageState();
|
||||
}
|
||||
|
||||
class _FingerprintDetailPageState extends State<FingerprintDetailPage> {
|
||||
final logic = Get.put(FingerprintDetailLogic());
|
||||
final state = Get.find<FingerprintDetailLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
// actionsList: [
|
||||
// TextButton(
|
||||
// child: Text(TranslationLoader.lanKeys!.share!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),),
|
||||
// onPressed: () {
|
||||
//
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
rightTitle: state.typeNumber.value,
|
||||
isHaveDirection: false,
|
||||
isHaveLine: true)),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: state.typeName.value,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
})),
|
||||
Obx(() => Visibility(
|
||||
visible: (state.keyType.value == 4 || state.keyType.value == 2) ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
allHeight: 70.h,
|
||||
// rightTitle:"2023.09.19 11:27\n2023.09.25 11:27",
|
||||
rightTitle: state.keyType.value == 1 ? "永久" : "${DateTool().dateToYMDHNString(state.effectiveDateTime.value.toString())}\n${DateTool().dateToYMDHNString(state.failureDateTime.value.toString())}",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
// switch(state.type.value){
|
||||
// case 0:
|
||||
// // 卡
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
// 当是指纹的时候
|
||||
if(state.keyType.value == 2){
|
||||
// 限时
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeDatePage, arguments: {
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
});
|
||||
}
|
||||
}else if(state.keyType.value == 4){
|
||||
// 循环
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.keyType.value == 4 ? true : false,
|
||||
child: Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr,
|
||||
rightTitle: state.weekDay.value.join(','),
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
// 当是指纹的时候
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
})))
|
||||
),
|
||||
Container(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.additive!.tr,
|
||||
rightTitle: state.adder.value,
|
||||
action: () {
|
||||
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.addTime!.tr,
|
||||
rightTitle: DateTool().dateToYMDHNString(state.addTime.value.toString()),
|
||||
action: () {
|
||||
|
||||
})),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
// 指纹
|
||||
Get.toNamed(Routers.keyOperationRecordPage, arguments: {
|
||||
'lockId': state.fingerprintItemData.value.lockId.toString(),
|
||||
'fingerprintId': state.fingerprintItemData.value.fingerprintId.toString()
|
||||
});
|
||||
}),
|
||||
// SizedBox(height: 40.h),
|
||||
// addControlsBtn(type),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.delete!.tr,
|
||||
isDelete: true,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
showIosTipViewDialog(context);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isStressFingerprint.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
logic.editFingerprintsData();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Widget addControlsBtn(int type) {
|
||||
// List<Widget> widgetList = [];
|
||||
// List<Map<String, dynamic>> routerList = [];
|
||||
// //卡详情
|
||||
// if (type == 0) {
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置指纹',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 1
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置遥控',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 2
|
||||
// });
|
||||
// } else if (type == 1) {
|
||||
// //指纹详情
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置卡',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 0
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置遥控',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 2
|
||||
// });
|
||||
// } else if (type == 2) {
|
||||
// //遥控详情
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置卡',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 0
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置指纹',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 1
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < routerList.length; i++) {
|
||||
// widgetList.add(SizedBox(
|
||||
// width: ScreenUtil().screenWidth - 40.w,
|
||||
// height: 60.h,
|
||||
// child: OutlinedButton(
|
||||
// style: OutlinedButton.styleFrom(
|
||||
// // backgroundColor: Colors.white,
|
||||
// side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
// onPressed: () {
|
||||
// if (routerList[i]['type'] == 9) {
|
||||
// Navigator.pushNamed(context, Routers.passwordKeyManagePage);
|
||||
// } else {
|
||||
// Navigator.pushNamed(context, Routers.otherTypeKeyManagePage,
|
||||
// arguments: routerList[i]['type']);
|
||||
// }
|
||||
// },
|
||||
// child: Text(
|
||||
// routerList[i]['btnTitle'],
|
||||
// style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp),
|
||||
// )),
|
||||
// ));
|
||||
//
|
||||
// widgetList.add(
|
||||
// SizedBox(
|
||||
// height: 10.h,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// return Column(
|
||||
// children: widgetList,
|
||||
// );
|
||||
// }
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}",
|
||||
tipTitle: "",
|
||||
controller: state.changeNameController,
|
||||
sureClick: () {
|
||||
if(state.changeNameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
Get.back();
|
||||
// 指纹
|
||||
logic.editFingerprintsData();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},);
|
||||
});
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
// 指纹
|
||||
logic.senderAddFingerprint();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class FingerprintDetailState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
|
||||
final typeNumber = "".obs;// 指纹号
|
||||
final typeName = "".obs;// 指纹名字
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
final keyType = 0.obs;// 永久:1;限时2,单次3,循环:4
|
||||
var weekDay = [].obs;// 有效日
|
||||
var adder = "".obs;// 添加者
|
||||
var addTime = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;
|
||||
|
||||
final isStressFingerprint = false.obs;
|
||||
FingerprintDetailState() {
|
||||
Map map = Get.arguments;
|
||||
fingerprintItemData.value = map["fingerprintItemData"];
|
||||
keyId.value = fingerprintItemData.value.fingerprintId!;
|
||||
typeNumber.value = fingerprintItemData.value.fingerprintNumber!;
|
||||
typeName.value = fingerprintItemData.value.fingerprintName!;
|
||||
changeNameController.text = typeName.value;
|
||||
effectiveDateTime.value = fingerprintItemData.value.startDate!;
|
||||
failureDateTime.value = fingerprintItemData.value.endDate!;
|
||||
keyType.value = fingerprintItemData.value.fingerprintType!;
|
||||
adder.value = fingerprintItemData.value.senderUsername!;
|
||||
addTime.value = fingerprintItemData.value.createDate!;
|
||||
isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false;
|
||||
weekDay.value = fingerprintItemData.value.weekDay!;
|
||||
|
||||
}
|
||||
}
|
||||
@ -2,113 +2,46 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addICCard.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addFingerprint.dart';
|
||||
import '../../../../blue/io_protocol/io_checkingCardStatus.dart';
|
||||
import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart';
|
||||
import '../../../../blue/io_protocol/io_queryingFingerprintStatus.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'otherTypeKeyList_state.dart';
|
||||
import 'fingerprintList_state.dart';
|
||||
|
||||
class OtherTypeKeyListLogic extends BaseGetXController{
|
||||
OtherTypeKeyListState state = OtherTypeKeyListState();
|
||||
class FingerprintListLogic extends BaseGetXController{
|
||||
FingerprintListState state = FingerprintListState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
// 添加指纹开始(重置锁里面所有指纹)
|
||||
// 添加指纹开始(此处用作删除指纹)
|
||||
if((reply is SenderAddFingerprintReply) && (state.isDeletFingerprintData == true)) {
|
||||
_replyAddFingerprintBegin(reply);
|
||||
}
|
||||
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderAddICCardReply) && (state.isDeletICCardData == true)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderQueryingFingerprintStatusReply) {
|
||||
// 获取指纹状态
|
||||
_replyQueryingFingerprintStatus(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderCheckingCardStatusReply) {
|
||||
_replyReferEventRecordNumber(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderCheckingUserInfoCountReply){
|
||||
_replyCheckingUserInfoCount(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintStatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletICCardData = false;
|
||||
deletICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
cardNo:255,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 重置锁里面所有指纹
|
||||
// 添加指纹开始
|
||||
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
||||
|
||||
int status = reply.data[2];
|
||||
@ -116,13 +49,13 @@ class OtherTypeKeyListLogic extends BaseGetXController{
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletFingerprintData = false;
|
||||
deletAllFingerprintsData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -134,9 +67,9 @@ class OtherTypeKeyListLogic extends BaseGetXController{
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
fingerNo:255,
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
fingerNo:state.deletFingerNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
@ -331,34 +264,6 @@ class OtherTypeKeyListLogic extends BaseGetXController{
|
||||
});
|
||||
}
|
||||
|
||||
// 查询卡片状态
|
||||
Future<void> senderCheckingCardStatus() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderCheckingCardStatusCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
role:0xff,
|
||||
cardCount:20,
|
||||
cardNo:1,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
@ -386,8 +291,8 @@ class OtherTypeKeyListLogic extends BaseGetXController{
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
// 重置所有指纹
|
||||
Future<void> senderAddFingerprint(String keyId, String userID, int cardNo) async {
|
||||
// 删除指纹
|
||||
Future<void> senderAddFingerprint() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
@ -400,45 +305,9 @@ class OtherTypeKeyListLogic extends BaseGetXController{
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
// keyID:"1",
|
||||
// userID:"DeleteAll!@#",
|
||||
// fingerNo:255,
|
||||
keyID:keyId,
|
||||
userID:userID,
|
||||
fingerNo:cardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 删除卡片
|
||||
Future<void> senderAddICCard(String keyId, String userID, int cardNo) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
// keyID:"1",
|
||||
// userID:"DeleteAll!@#",
|
||||
// cardNo:255,
|
||||
keyID:keyId,
|
||||
userID:userID,
|
||||
cardNo:cardNo,
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
fingerNo:state.deletFingerNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
@ -466,66 +335,36 @@ class OtherTypeKeyListLogic extends BaseGetXController{
|
||||
|
||||
// 重置所有的指纹
|
||||
void deletAllFingerprintsData() async{
|
||||
var fingerprintId = "";
|
||||
var type = "1";
|
||||
if(state.isDeletAll == false){
|
||||
fingerprintId = state.deletKeyID;
|
||||
type = "0";
|
||||
}
|
||||
print("delet fingerprintId $fingerprintId");
|
||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||
fingerprintId: "",
|
||||
fingerprintId: fingerprintId,
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: "1",
|
||||
type: type,
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "重置成功");
|
||||
if(state.isDeletAll == false){
|
||||
Toast.show(msg: "删除成功");
|
||||
}else{
|
||||
Toast.show(msg: "重置成功");
|
||||
}
|
||||
|
||||
state.isDeletFingerprintData = false;
|
||||
getFingerprintsListData();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取IC卡列表
|
||||
void getICCardListData() async{
|
||||
var entity = await ApiRepository.to.getICCardListData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
pageNo: '1',
|
||||
pageSize: '20',
|
||||
searchStr: state.searchController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.fingerprintItemListData.value = entity.data!.list!;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除所有IC卡
|
||||
void deletICCardData() async{
|
||||
var entity = await ApiRepository.to.deletIcCardData(
|
||||
cardId: "",
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: "1",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "重置成功");
|
||||
getICCardListData();
|
||||
}
|
||||
}
|
||||
|
||||
// 监听修改完详情之后刷新列表
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((event) {
|
||||
switch (state.fromType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
getICCardListData();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
getFingerprintsListData();
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
getFingerprintsListData();
|
||||
});
|
||||
}
|
||||
|
||||
@ -543,22 +382,7 @@ class OtherTypeKeyListLogic extends BaseGetXController{
|
||||
|
||||
_initRefreshAction();
|
||||
|
||||
switch (state.fromType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
getICCardListData();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
getFingerprintsListData();
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
getFingerprintsListData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,304 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/left_slide_actions.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'fingerprintListData_entity.dart';
|
||||
import 'fingerprintList_logic.dart';
|
||||
|
||||
class FingerprintListPage extends StatefulWidget {
|
||||
const FingerprintListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FingerprintListPage> createState() => _FingerprintListPageState();
|
||||
}
|
||||
|
||||
class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
final logic = Get.put(FingerprintListLogic());
|
||||
final state = Get.find<FingerprintListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.fingerprint!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.addFingerprintTypeManagePage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getFingerprintsListData();
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(height: 64.h)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.searchController,
|
||||
autofocus: false,
|
||||
onChanged: (value) {
|
||||
print("onChanged:$value");
|
||||
},
|
||||
onEditingComplete: () {
|
||||
print("onEditingComplete:");
|
||||
},
|
||||
onSubmitted: (value) {
|
||||
logic.getFingerprintsListData();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
icon: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.h, bottom: 20.h, right: 20.w, left: 10.w),
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_search.png',
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => state.fingerprintItemListData.value.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index];
|
||||
// 指纹
|
||||
if (index < state.fingerprintItemListData.value.length) {
|
||||
return LeftSlideActions(
|
||||
key: Key(fingerprintItemData.fingerprintName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(fingerprintItemData),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_fingerprint.png',
|
||||
fingerprintItemData.fingerprintName!,
|
||||
fingerprintItemData.fingerprintType! == 1
|
||||
? "永久"
|
||||
: "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}",
|
||||
() async {
|
||||
var data = await Get.toNamed(
|
||||
Routers.fingerprintDetailPage,
|
||||
arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getFingerprintsListData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
)
|
||||
: const NoData());
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(FingerprintItemData fingerprintItemData) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
state.deletKeyID = fingerprintItemData.fingerprintId.toString();
|
||||
state.deletFingerNo = int.parse(fingerprintItemData.fingerprintNumber!);
|
||||
showIosTipViewDialog(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
state.isDeletFingerprintData = true;
|
||||
state.isDeletAll = false;
|
||||
state.deletUserID = (await Storage.getUid())!;
|
||||
logic.senderAddFingerprint();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(BuildContext context) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
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);
|
||||
state.isDeletFingerprintData = true;
|
||||
state.isDeletAll = true;
|
||||
state.deletKeyID = "1";
|
||||
state.deletUserID = "DeleteAll!@#";
|
||||
state.deletFingerNo = 255;
|
||||
logic.senderAddFingerprint();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -4,19 +4,21 @@ import 'package:get/get.dart';
|
||||
|
||||
import 'fingerprintListData_entity.dart';
|
||||
|
||||
class OtherTypeKeyListState{
|
||||
class FingerprintListState{
|
||||
final lockId = 0.obs;
|
||||
final fromType = 0.obs;
|
||||
|
||||
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
||||
var isDeletFingerprintData = false;
|
||||
var isDeletICCardData = false;
|
||||
var isDeletAll = false;
|
||||
var deletKeyID = "";
|
||||
var deletUserID = "DeleteAll!@#";
|
||||
var deletFingerNo = 0;
|
||||
|
||||
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
OtherTypeKeyListState() {
|
||||
FingerprintListState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
fromType.value = map["fromType"];
|
||||
}
|
||||
}
|
||||
@ -31,16 +31,18 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
barTitle: TranslationLoader.lanKeys!.automaticBlocking!.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
Obx(() => TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.save!.tr,
|
||||
state.isJustForShow.value == true ? "" : TranslationLoader.lanKeys!.save!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
// logic.sendAutoLock();
|
||||
if(state.isJustForShow.value == true){
|
||||
return;
|
||||
}
|
||||
logic.sendAutoLock();
|
||||
},
|
||||
),
|
||||
)),
|
||||
],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
@ -60,6 +62,9 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
if(state.isJustForShow.value == true){
|
||||
return;
|
||||
}
|
||||
var list = [
|
||||
"5",
|
||||
"10",
|
||||
@ -110,11 +115,12 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
TextField(
|
||||
Obx(() => TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.timeController,
|
||||
autofocus: false,
|
||||
readOnly: state.isJustForShow.value == true ? false : true,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding:
|
||||
@ -125,7 +131,7 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
)),
|
||||
Container(
|
||||
height: 0.5.h,
|
||||
color: Colors.grey,
|
||||
|
||||
@ -7,6 +7,9 @@ import '../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class AutomaticBlockingState {
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
final lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改
|
||||
|
||||
var isOpen = false.obs;// 是否开启自动落锁
|
||||
var autoLockTime = "5".obs;
|
||||
@ -16,10 +19,17 @@ class AutomaticBlockingState {
|
||||
AutomaticBlockingState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
lockBasicInfo.value = map["lockBasicInfo"];
|
||||
|
||||
isOpen.value = lockSetInfoData.value.lockSettingInfo!.autoLock! == 1 ? true : false;
|
||||
autoLockTime.value = lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString();
|
||||
|
||||
if(lockBasicInfo.value.isLockOwner == 1 || lockBasicInfo.value.keyRight == 1){
|
||||
isJustForShow.value = false;
|
||||
}else{
|
||||
isJustForShow.value = true;
|
||||
}
|
||||
|
||||
if((lockSetInfoData.value.lockSettingInfo!.autoLock! > 0)
|
||||
&& (lockSetInfoData.value.lockSettingInfo!.autoLockSecond! != 5)
|
||||
&& (lockSetInfoData.value.lockSettingInfo!.autoLockSecond! != 10)
|
||||
|
||||
@ -107,15 +107,17 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
}
|
||||
});
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.adminOpenLockPassword!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context,
|
||||
Routers.adminOpenLockPasswordPage);
|
||||
}),
|
||||
Visibility(
|
||||
visible: (state.lockBasicInfo.value.isLockOwner == 1 || state.lockBasicInfo.value.keyRight == 1) ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.adminOpenLockPassword!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.adminOpenLockPasswordPage);
|
||||
}),
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.unlockQRCode!.tr,
|
||||
|
||||
@ -314,6 +314,8 @@ class LockBasicInfo {
|
||||
int? startDate;
|
||||
int? endDate;
|
||||
String? mac;
|
||||
int? keyRight;
|
||||
int? senderUserId;
|
||||
|
||||
LockBasicInfo(
|
||||
{this.keyId,
|
||||
@ -328,7 +330,9 @@ class LockBasicInfo {
|
||||
this.keyType,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.mac});
|
||||
this.mac,
|
||||
this.keyRight,
|
||||
this.senderUserId});
|
||||
|
||||
LockBasicInfo.fromJson(Map<String, dynamic> json) {
|
||||
keyId = json['keyId'];
|
||||
@ -349,6 +353,9 @@ class LockBasicInfo {
|
||||
startDate = json['startDate'];
|
||||
endDate = json['endDate'];
|
||||
mac = json['mac'];
|
||||
keyRight = json['keyRight'];
|
||||
senderUserId = json['senderUserId'];
|
||||
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -368,6 +375,8 @@ class LockBasicInfo {
|
||||
data['startDate'] = startDate;
|
||||
data['endDate'] = endDate;
|
||||
data['mac'] = mac;
|
||||
data['keyRight'] = keyRight;
|
||||
data['senderUserId'] = senderUserId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
@ -19,6 +20,7 @@ import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'checkingInInfoData_entity.dart';
|
||||
import 'lockSet_state.dart';
|
||||
|
||||
@ -248,9 +250,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
|
||||
// 删除用户
|
||||
Future<void> deletUserAction() async {
|
||||
BlueManage().judgeReconnect(
|
||||
BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState connectionState) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -263,13 +263,18 @@ class LockSetLogic extends BaseGetXController {
|
||||
|
||||
IoSenderManage.deletUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: "100001",
|
||||
keyID: "1",
|
||||
delUserID: "100001",
|
||||
authUserID:state.lockBasicInfo.value.senderUserId.toString(),
|
||||
keyID:state.lockBasicInfo.value.keyId.toString(),
|
||||
delUserID:await Storage.getUid(),
|
||||
// authUserID: "100001",
|
||||
// keyID: "1",
|
||||
// delUserID: "100001",
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
}else{
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -296,6 +301,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList
|
||||
);
|
||||
}else{
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -378,6 +385,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
state.lockSettingInfo.value = state.lockSetInfoData.value.lockSettingInfo!;
|
||||
state.lockFeature.value = state.lockSetInfoData.value.lockFeature!;
|
||||
state.lockStatus.value = state.lockSetInfoData.value.lockStatus!;
|
||||
state.lockBasicInfo.value = state.lockSetInfoData.value.lockBasicInfo!;
|
||||
|
||||
state.isAttendance.value = state.lockSettingInfo.value.attendance!;
|
||||
state.isOpenLockNeedOnline.value = state.lockSettingInfo.value.appUnlockOnline!;
|
||||
|
||||
@ -395,6 +404,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
}
|
||||
@ -406,6 +416,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
keyId: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
}
|
||||
@ -425,13 +436,23 @@ class LockSetLogic extends BaseGetXController {
|
||||
// }
|
||||
// if(state.currentDeviceUUid.value[31] == "1"){
|
||||
|
||||
// 已配对
|
||||
// 判断是否是锁的拥有者
|
||||
if(state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1){
|
||||
// 调用删除锁协议
|
||||
factoryDataResetAction();
|
||||
// 判断是否扫描到当前设备
|
||||
if(BlueManage().connectDeviceMacAddress.isNotEmpty){
|
||||
// 调用删除锁协议
|
||||
factoryDataResetAction();
|
||||
}else{
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
}else{
|
||||
// 调用删除钥匙协议
|
||||
deletUserAction();
|
||||
// 判断是否扫描到当前设备
|
||||
if(BlueManage().connectDeviceMacAddress.isNotEmpty){
|
||||
// 调用删除钥匙协议
|
||||
deletUserAction();
|
||||
}else{
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
}
|
||||
|
||||
// }else if(state.currentDeviceUUid.value[31] == "0"){
|
||||
@ -528,6 +549,39 @@ class LockSetLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
void showDeletAlertTipDialog(BuildContext context) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
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();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@ class LockSetState {
|
||||
final lockFeature = LockFeature().obs;
|
||||
final lockSettingInfo = LockSettingInfo().obs;
|
||||
final lockStatus = LockStatus().obs;
|
||||
final lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
final lockId = 0.obs;
|
||||
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/style/default_style.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/style/default_style.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/tools/commonItem.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/style/default_style.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
@ -32,89 +34,91 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Obx(() => ListView(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _normallyOpenModeSwitch())),
|
||||
SizedBox(
|
||||
height: 1.h,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 30.w, right: 30.w, top: 20.w, bottom: 20.w),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w,
|
||||
height: 50.h,
|
||||
child: _normallyOpenModeSwitch())),
|
||||
SizedBox(
|
||||
height: 1.h,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 30.w, right: 30.w, top: 20.w, bottom: 20.w),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.normallyOpenModeTip!.tr,
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Visibility(
|
||||
visible: state.isOpenNormallyOpenMode.value,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.automaticUnLock!.tr,
|
||||
// rightTitle: "",
|
||||
// isHaveLine: false,
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget:
|
||||
// SizedBox(width: 60.w, height: 50.h, child: _autoUnlockSwitch())),
|
||||
// Container(
|
||||
// height: 1.h,
|
||||
// color: AppColors.mainBackgroundColor,
|
||||
// ),
|
||||
// Container(
|
||||
// padding: EdgeInsets.only(
|
||||
// left: 30.w, right: 30.w, top: 20.w, bottom: 20.w),
|
||||
// color: Colors.white,
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// TranslationLoader.lanKeys!.automaticUnLockTip!.tr,
|
||||
// style: TextStyle(fontSize: 20.sp),
|
||||
// )),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// height: 10.h,
|
||||
// color: AppColors.mainBackgroundColor,
|
||||
// ),
|
||||
topWidget(),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
bottomWidget()
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Visibility(
|
||||
visible: state.isOpenNormallyOpenMode.value,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.automaticUnLock!.tr,
|
||||
// rightTitle: "",
|
||||
// isHaveLine: false,
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget:
|
||||
// SizedBox(width: 60.w, height: 50.h, child: _autoUnlockSwitch())),
|
||||
// Container(
|
||||
// height: 1.h,
|
||||
// color: AppColors.mainBackgroundColor,
|
||||
// ),
|
||||
// Container(
|
||||
// padding: EdgeInsets.only(
|
||||
// left: 30.w, right: 30.w, top: 20.w, bottom: 20.w),
|
||||
// color: Colors.white,
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// TranslationLoader.lanKeys!.automaticUnLockTip!.tr,
|
||||
// style: TextStyle(fontSize: 20.sp),
|
||||
// )),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// height: 10.h,
|
||||
// color: AppColors.mainBackgroundColor,
|
||||
// ),
|
||||
topWidget(),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
bottomWidget()
|
||||
],
|
||||
),
|
||||
)),
|
||||
Obx(() => Container(
|
||||
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h),
|
||||
child: state.isJustForShow.value == true ? Container() :SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||
onClick: () {
|
||||
logic.sendAutoLock();
|
||||
}),
|
||||
)),
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h),
|
||||
child: SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||
onClick: () {
|
||||
logic.sendAutoLock();
|
||||
}),
|
||||
),
|
||||
],
|
||||
)));
|
||||
],
|
||||
)));
|
||||
}
|
||||
|
||||
Widget topWidget() {
|
||||
@ -180,9 +184,9 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if(state.weekDays.value.contains(index)){
|
||||
if (state.weekDays.value.contains(index)) {
|
||||
state.weekDays.value.remove(index);
|
||||
}else{
|
||||
} else {
|
||||
state.weekDays.value.add(index);
|
||||
}
|
||||
state.weekDays.value.sort();
|
||||
@ -190,20 +194,26 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
// print("index:$index data:${state.normallyOpenPeriod.value}");
|
||||
},
|
||||
child: Obx(() => Container(
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
margin: EdgeInsets.all(10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: state.weekDays.value.contains(index) ? AppColors.mainColor :Colors.white,
|
||||
border: Border.all(width: 1, color: AppColors.btnDisableColor),
|
||||
borderRadius: BorderRadius.circular(30.w),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
margin: EdgeInsets.all(10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: state.weekDays.value.contains(index)
|
||||
? AppColors.mainColor
|
||||
: Colors.white,
|
||||
border: Border.all(width: 1, color: AppColors.btnDisableColor),
|
||||
borderRadius: BorderRadius.circular(30.w),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
dateStr,
|
||||
style: TextStyle(fontSize: 20.sp, color: state.weekDays.value.contains(index) ? Colors.white : AppColors.darkGrayTextColor),
|
||||
style: TextStyle(
|
||||
fontSize: 20.sp,
|
||||
color: state.weekDays.value.contains(index)
|
||||
? Colors.white
|
||||
: AppColors.darkGrayTextColor),
|
||||
)),
|
||||
)),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -216,16 +226,16 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
"${TranslationLoader.lanKeys!.normallyOpen!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
"${TranslationLoader.lanKeys!.normallyOpen!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: GestureDetector(
|
||||
onTap: () {
|
||||
// 选择全天模式
|
||||
if(state.isAllDay.value == 1){
|
||||
if (state.isAllDay.value == 1) {
|
||||
state.isAllDay.value = 0;
|
||||
}else{
|
||||
} else {
|
||||
state.isAllDay.value = 1;
|
||||
}
|
||||
setState(() {});
|
||||
@ -240,7 +250,9 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
width: 5.w,
|
||||
),
|
||||
Image.asset(
|
||||
state.isAllDay.value == 1 ? 'images/icon_round_selet.png': 'images/icon_round_unSelet.png',
|
||||
state.isAllDay.value == 1
|
||||
? 'images/icon_round_selet.png'
|
||||
: 'images/icon_round_unSelet.png',
|
||||
width: 30.w,
|
||||
height: 30.w,
|
||||
),
|
||||
@ -255,32 +267,34 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
"${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
"${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.beginTimeMinute.value = p.hour!*60 + p.minute!;
|
||||
state.beginTime.value = "${p.hour}:${p.minute!}";
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
state.beginTimeMinute.value =
|
||||
p.hour! * 60 + p.minute!;
|
||||
state.beginTime.value = "${p.hour}:${p.minute!}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
"${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
"${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.endTimeMinute.value = p.hour!*60 + p.minute!;
|
||||
state.endTime.value = "${p.hour}:${p.minute!}";
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
state.endTimeMinute.value =
|
||||
p.hour! * 60 + p.minute!;
|
||||
state.endTime.value = "${p.hour}:${p.minute!}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
|
||||
@ -4,6 +4,8 @@ import '../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class NormallyOpenModeState{
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
final lockBasicInfo = LockBasicInfo().obs;
|
||||
var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改
|
||||
|
||||
// var getPassageModeConfigData = GetPassageModeConfigEntity().obs;
|
||||
var isOpenNormallyOpenMode = false.obs;// 是否开启常开模式 常开模式:1-开启、2-关闭
|
||||
@ -20,6 +22,12 @@ class NormallyOpenModeState{
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
isOpenNormallyOpenMode.value = lockSetInfoData.value.lockSettingInfo!.passageMode! == 1 ? true : false;
|
||||
|
||||
if(lockBasicInfo.value.isLockOwner == 1 || lockBasicInfo.value.keyRight == 1){
|
||||
isJustForShow.value = false;
|
||||
}else{
|
||||
isJustForShow.value = true;
|
||||
}
|
||||
|
||||
if((isOpenNormallyOpenMode.value == true) && (lockSetInfoData.value.lockSettingInfo!.passageModeConfig!.isNotEmpty)){
|
||||
isAllDay.value = lockSetInfoData.value.lockSettingInfo!.passageModeConfig![0].isAllDay!;
|
||||
weekDays.value = lockSetInfoData.value.lockSettingInfo!.passageModeConfig![0].weekDays!;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
||||
@ -10,6 +11,7 @@ import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.dart';
|
||||
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import '../../../blue/io_protocol/io_openLock.dart';
|
||||
import '../../../blue/io_protocol/io_referEventRecordTime.dart';
|
||||
@ -52,6 +54,11 @@ class LockDetailLogic extends BaseGetXController{
|
||||
if(reply is SenderReferEventRecordTimeReply) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
|
||||
// 添加用户
|
||||
if(reply is AddUserReply) {
|
||||
_replyAddUserKey(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -59,7 +66,7 @@ class LockDetailLogic extends BaseGetXController{
|
||||
Future<void> _replyOpenLock(Reply reply) async {
|
||||
var tokenData = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(tokenData);
|
||||
// print("openDoorToken:$tokenData");
|
||||
print("openDoorToken:$tokenData");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[6];
|
||||
@ -121,66 +128,6 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑用户数据解析
|
||||
// Future<void> _replyEditUserKey(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyEditUserKeyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
//
|
||||
// int status = reply.data[6];
|
||||
// print("status:$status");
|
||||
//
|
||||
// switch(status){
|
||||
// case 0x00:
|
||||
// //成功
|
||||
// print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
//
|
||||
// break;
|
||||
// case 0x06:
|
||||
// //无权限
|
||||
// print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.senderEditUser(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// authUserID:await Storage.getUid(),
|
||||
// keyID:"1",
|
||||
// userID:await Storage.getUid(),
|
||||
// openMode:1,
|
||||
// keyType:1,
|
||||
// startDate:0x11223344,
|
||||
// expireDate:0x11223344,
|
||||
// role:255,
|
||||
// password:"123456",
|
||||
// needAuthor:1,
|
||||
// publicKey:publicKeyDataList,
|
||||
// privateKey:getPrivateKeyList,
|
||||
// token: token
|
||||
// );
|
||||
// break;
|
||||
// case 0x07:
|
||||
// //无权限
|
||||
// print("${reply.commandType!.typeValue} 用户无权限");
|
||||
//
|
||||
// break;
|
||||
// case 0x09:
|
||||
// // 权限校验错误
|
||||
// print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// //失败
|
||||
// print("${reply.commandType!.typeValue} 失败");
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 获取锁状态数据解析
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
@ -324,6 +271,78 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 添加用户
|
||||
Future<void> _replyAddUserKey(Reply reply) async {
|
||||
var lockId = reply.data.sublist(2, 42);
|
||||
// print("lockId:$lockId");
|
||||
|
||||
var token = reply.data.sublist(42, 46);
|
||||
List<String> strTokenList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, strTokenList);
|
||||
// print("token:$token");
|
||||
|
||||
int status = reply.data[46];
|
||||
// print("status:$status reply.data:${reply.data}");
|
||||
|
||||
print("status:$status");
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("添加用户数据解析成功");
|
||||
state.lockUserNo = reply.data[47] + 1;
|
||||
// updateLockUserNo();
|
||||
|
||||
if(state.isOpenLockNeedOnline.value == 0){
|
||||
openDoorAction();
|
||||
}else{
|
||||
getLockNetToken();
|
||||
}
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:state.senderUserId.toString(),
|
||||
keyID:state.keyInfos.value.keyId.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
openMode:1,
|
||||
keyType:0,
|
||||
startDate:DateTime.now().millisecondsSinceEpoch,
|
||||
expireDate:0x11223344,
|
||||
role:0,
|
||||
password:"123456",
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("添加用户权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("领锁失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 点击开门事件
|
||||
Future<void> openDoorAction() async {
|
||||
// if(BlueManage().connectDeviceMacAddress.isEmpty){
|
||||
@ -365,45 +384,48 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 编辑用户事件
|
||||
Future<void> editLockUserAction() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
print("publicKey:$publicKey publicKeyDataList:$publicKeyDataList privateKey:$privateKey getPrivateKeyList:$getPrivateKeyList token:$token getTokenList:$getTokenList");
|
||||
IoSenderManage.senderEditUser(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
authUserID:await Storage.getUid(),
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
openMode:1,
|
||||
keyType:1,
|
||||
startDate:0x11223344,
|
||||
expireDate:0x11223344,
|
||||
role:255,
|
||||
password:"123456",
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Future<void> editLockUserAction() async {
|
||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
// if (state == DeviceConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
// print("openDoorTokenPubToken:$getTokenList");
|
||||
//
|
||||
// print("publicKey:$publicKey publicKeyDataList:$publicKeyDataList privateKey:$privateKey getPrivateKeyList:$getPrivateKeyList token:$token getTokenList:$getTokenList");
|
||||
// IoSenderManage.senderEditUser(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// authUserID:await Storage.getUid(),
|
||||
// keyID:"1",
|
||||
// userID:await Storage.getUid(),
|
||||
// openMode:1,
|
||||
// keyType:1,
|
||||
// startDate:0x11223344,
|
||||
// expireDate:0x11223344,
|
||||
// role:255,
|
||||
// password:"123456",
|
||||
// needAuthor:1,
|
||||
// publicKey:publicKeyDataList,
|
||||
// privateKey:getPrivateKeyList,
|
||||
// token: getTokenList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// 备用逻辑,进入管理钥匙界面获取锁状态
|
||||
Future<void> connectBlue(String bluetoothDeviceId, String bluetoothDeviceName) async {
|
||||
// 进来之后首先连接
|
||||
BlueManage().connect(bluetoothDeviceId, bluetoothDeviceName, connectStateCallBack: (DeviceConnectionState state) async {
|
||||
if(EasyLoading.isShow){
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -449,6 +471,44 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
// 添加用户(普通用户接收电子钥匙)
|
||||
Future<void> addUserConnectBlue() async {
|
||||
// 进来之后首先连接
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
// 私钥
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = [0,0,0,0];
|
||||
if(token != null){
|
||||
getTokenList = changeStringListToIntList(token);
|
||||
}
|
||||
print("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}");
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:state.senderUserId.toString(),
|
||||
keyID:state.keyInfos.value.keyId.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
openMode:1,
|
||||
keyType:0,
|
||||
startDate:DateTime.now().millisecondsSinceEpoch,
|
||||
expireDate:0x11223344,
|
||||
role:0,
|
||||
password:"123456",
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
void startScanAction(){
|
||||
BlueManage().startScan(true, (v){
|
||||
// print("startScanAllDevice:${v}");
|
||||
@ -458,7 +518,7 @@ class LockDetailLogic extends BaseGetXController{
|
||||
BlueManage().connectDeviceMacAddress = v[knownDeviceIndex].id;
|
||||
connectBlue(v[knownDeviceIndex].id, state.keyInfos.value.bluetooth!.bluetoothDeviceName!);
|
||||
eventBus.fire(ScanAllDeviceFindCurrentDeviceConnectedEvent(v[knownDeviceIndex].serviceUuids[0].toString()));
|
||||
// BlueManage().stopScan();
|
||||
BlueManage().stopScan();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -468,10 +528,14 @@ class LockDetailLogic extends BaseGetXController{
|
||||
state.lockState.value = 1;
|
||||
state.animationController.forward();
|
||||
|
||||
if(state.isOpenLockNeedOnline.value == 0){
|
||||
openDoorAction();
|
||||
if(state.lockUserNo == 0){
|
||||
addUserConnectBlue();
|
||||
}else{
|
||||
getLockNetToken();
|
||||
if(state.isOpenLockNeedOnline.value == 0){
|
||||
openDoorAction();
|
||||
}else{
|
||||
getLockNetToken();
|
||||
}
|
||||
}
|
||||
|
||||
Future.delayed(const Duration(seconds: 10), () {
|
||||
@ -500,10 +564,21 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 普通用户接收电子钥匙之后 更新锁用户NO
|
||||
void updateLockUserNo() async {
|
||||
LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(keyId: state.keyInfos.value.keyId.toString(), lockUserNo: state.lockUserNo.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if(state.isOpenLockNeedOnline.value == 0){
|
||||
openDoorAction();
|
||||
}else{
|
||||
getLockNetToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate!~/1000);
|
||||
}
|
||||
@ -542,9 +617,18 @@ class LockDetailLogic extends BaseGetXController{
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
||||
|
||||
EasyLoading.show(status: "正在连接设备,请稍等。", maskType: EasyLoadingMaskType.none, dismissOnTap: true);
|
||||
Future.delayed(const Duration(seconds: 12), () {
|
||||
if(EasyLoading.isShow){
|
||||
EasyLoading.dismiss();
|
||||
Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
|
||||
}
|
||||
});
|
||||
|
||||
if(Platform.isIOS){
|
||||
print("有蓝牙权限开始扫描");
|
||||
startScanAction();
|
||||
@ -576,16 +660,6 @@ class LockDetailLogic extends BaseGetXController{
|
||||
// factoryDataResetAction();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
print("锁详情界面销毁了");
|
||||
|
||||
_replySubscription.cancel();
|
||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
||||
}
|
||||
|
||||
///请求录音相机权限
|
||||
Future<bool> getMicrophonePermission() async {
|
||||
// You can request multiple permissions at once.
|
||||
@ -604,4 +678,12 @@ class LockDetailLogic extends BaseGetXController{
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
print("锁详情界面销毁了");
|
||||
|
||||
_replySubscription.cancel();
|
||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
||||
}
|
||||
}
|
||||
@ -3,15 +3,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../network/api_repository.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
// import '../../lockMian/entity/lockInfoEntity.dart';
|
||||
import '../../lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'lockDetail_page.dart';
|
||||
|
||||
class LockDetailMainPage extends StatefulWidget {
|
||||
|
||||
const LockDetailMainPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -19,19 +16,6 @@ class LockDetailMainPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LockDetailMainPageState extends State<LockDetailMainPage> {
|
||||
|
||||
// void getLockInfo() async{
|
||||
// var entity = await ApiRepository.to.getLockInfo(
|
||||
// lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
// pageNo:"1",
|
||||
// );
|
||||
// if(entity.errorCode!.codeIsSuccessful){
|
||||
//
|
||||
// }else{
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
|
||||
@ -25,8 +25,7 @@ class LockDetailPage extends StatefulWidget {
|
||||
State<LockDetailPage> createState() => _LockDetailPageState();
|
||||
}
|
||||
|
||||
class _LockDetailPageState extends State<LockDetailPage>
|
||||
with TickerProviderStateMixin {
|
||||
class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStateMixin, RouteAware {
|
||||
// with RouteAware
|
||||
final logic = Get.put(LockDetailLogic());
|
||||
final state = Get.find<LockDetailLogic>().state;
|
||||
@ -38,6 +37,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
super.initState();
|
||||
|
||||
state.keyInfos.value = widget.lockListInfoItemEntity;
|
||||
state.lockUserNo = state.keyInfos.value.lockUserNo!;
|
||||
state.senderUserId = state.keyInfos.value.senderUserId!;
|
||||
state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!;
|
||||
state.isOpenLockNeedOnline.value = state.keyInfos.value.lockSetting!.appUnlockOnline!;
|
||||
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
|
||||
@ -95,10 +96,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
SizedBox(
|
||||
width: 1.sw - 120.w * 2,
|
||||
child: Center(
|
||||
child: Text(
|
||||
widget.lockListInfoItemEntity!.lockAlias!,
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
|
||||
child:
|
||||
Text(widget.lockListInfoItemEntity.lockAlias!, style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
|
||||
))),
|
||||
Positioned(
|
||||
child: Obx(() => Row(
|
||||
@ -125,14 +124,11 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
child: Obx(() => Stack(
|
||||
children: [
|
||||
Image.asset(
|
||||
state.lockState.value == 4
|
||||
? 'images/main/icon_main_openLockBtn_grey.png'
|
||||
: 'images/main/icon_main_openLockBtn_center.png',
|
||||
state.lockState.value == 4 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png',
|
||||
width: 330.w,
|
||||
height: 330.w,
|
||||
),
|
||||
(state.lockState.value == 1 ||
|
||||
state.lockState.value == 3)
|
||||
(state.lockState.value == 1 || state.lockState.value == 3)
|
||||
? buildRotationTransition()
|
||||
: Positioned(
|
||||
child: Image.asset(
|
||||
@ -268,11 +264,42 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
crossAxisSpacing: 20.w,
|
||||
mainAxisSpacing: 0.h,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: getShowWidget()),
|
||||
children: getBottomWidget()),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getShowWidget() {
|
||||
// 根据权限显示不同的底部按钮
|
||||
List<Widget> getBottomWidget(){
|
||||
if(state.keyInfos.value.isLockOwner == 1 || state.keyInfos.value.keyRight == 1){
|
||||
// 超级管理员、授权管理员
|
||||
return getAllWidget();
|
||||
}else{
|
||||
return getNormalWidget();
|
||||
}
|
||||
}
|
||||
|
||||
// 普通用户
|
||||
List<Widget> getNormalWidget() {
|
||||
var showWidgetArr = [
|
||||
// 操作记录
|
||||
bottomItem('images/main/icon_main_operatingRecord.png',
|
||||
TranslationLoader.lanKeys!.operatingRecord!.tr, () {
|
||||
Get.toNamed(Routers.lockOperatingRecordPage,
|
||||
arguments: {"keyInfo": widget.lockListInfoItemEntity});
|
||||
}),
|
||||
|
||||
// 设置
|
||||
bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () {
|
||||
BlueManage().stopScan();
|
||||
Get.toNamed(Routers.lockSetPage,
|
||||
arguments: {"lockId": widget.lockListInfoItemEntity.lockId});
|
||||
}),
|
||||
];
|
||||
return showWidgetArr;
|
||||
}
|
||||
|
||||
// 授权管理员、超级管理员字段
|
||||
List<Widget> getAllWidget() {
|
||||
var showWidgetArr = <Widget>[];
|
||||
// 考勤
|
||||
if (state.isAttendance.value == 1) {
|
||||
@ -301,9 +328,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
if (state.keyInfos.value.lockFeature!.icCard == 1) {
|
||||
showWidgetArr.add(bottomItem('images/main/icon_main_icCard.png',
|
||||
TranslationLoader.lanKeys!.card!.tr, () {
|
||||
Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
|
||||
Get.toNamed(Routers.cardListPage, arguments: {
|
||||
"lockId": widget.lockListInfoItemEntity.lockId,
|
||||
"fromType": 0
|
||||
});
|
||||
}));
|
||||
}
|
||||
@ -312,9 +338,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
if (state.keyInfos.value.lockFeature!.fingerprint == 1) {
|
||||
showWidgetArr.add(bottomItem('images/main/icon_main_fingerprint.png',
|
||||
TranslationLoader.lanKeys!.fingerprint!.tr, () {
|
||||
Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
|
||||
Get.toNamed(Routers.fingerprintListPage, arguments: {
|
||||
"lockId": widget.lockListInfoItemEntity.lockId,
|
||||
"fromType": 1
|
||||
});
|
||||
}));
|
||||
}
|
||||
@ -323,10 +348,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
if (state.keyInfos.value.lockFeature!.bluetoothRemoteControl == 1) {
|
||||
showWidgetArr.add(bottomItem('images/main/icon_main_remoteControl.png',
|
||||
TranslationLoader.lanKeys!.remoteControl!.tr, () {
|
||||
Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
|
||||
"lockId": widget.lockListInfoItemEntity.lockId,
|
||||
"fromType": 2
|
||||
});
|
||||
Get.toNamed(Routers.remoteControlListPage);
|
||||
}));
|
||||
}
|
||||
|
||||
@ -334,9 +356,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
if (state.keyInfos.value.lockFeature!.d3Face == 1) {
|
||||
showWidgetArr.add(
|
||||
bottomItem('images/main/icon_face.png', TranslationLoader.lanKeys!.humanFace!.tr, () {
|
||||
Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
|
||||
Get.toNamed(Routers.faceList, arguments: {
|
||||
"lockId": widget.lockListInfoItemEntity.lockId,
|
||||
"fromType": 3
|
||||
}); // Toast.show(msg: "功能暂未开放");
|
||||
|
||||
// tokNative('videoTalk',
|
||||
@ -477,22 +498,33 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
// AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
state.animationController.dispose();
|
||||
super.dispose();
|
||||
BlueManage().stopScan();
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
}
|
||||
|
||||
///
|
||||
@override
|
||||
void didPush() {}
|
||||
void didPush() {
|
||||
print("LockDetailPage didPush");
|
||||
}
|
||||
|
||||
/// Called when the current route has been popped off.
|
||||
@override
|
||||
void didPop() {}
|
||||
void didPop() {
|
||||
print("LockDetailPage didPop");
|
||||
}
|
||||
|
||||
/// Called when the current route has been popped off.
|
||||
@override
|
||||
void didPopNext() {}
|
||||
void didPopNext() {
|
||||
print("LockDetailPage didPopNext");
|
||||
}
|
||||
|
||||
/// Called when the current route has been popped off.
|
||||
@override
|
||||
void didPushNext() {}
|
||||
void didPushNext() {
|
||||
print("LockDetailPage didPushNext");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@ -18,6 +17,8 @@ class LockDetailState {
|
||||
Rx<LockListInfoItemEntity> keyInfos = LockListInfoItemEntity().obs;
|
||||
|
||||
String lockNetToken = "";
|
||||
var lockUserNo = 0;
|
||||
var senderUserId = 0;
|
||||
|
||||
var isAttendance = 0.obs;// 是否开启考勤
|
||||
var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
|
||||
|
||||
@ -1,188 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'otherTypeAddKey_state.dart';
|
||||
|
||||
class OtherTypeAddKeyLogic extends BaseGetXController {
|
||||
OtherTypeAddKeyState state = OtherTypeAddKeyState();
|
||||
|
||||
// 添加指纹
|
||||
void addFingerprintsData() async {
|
||||
var fingerprintType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
var startDate = "";
|
||||
var endDate = "";
|
||||
if (state.seletType.value == "0") {
|
||||
fingerprintType = 1;
|
||||
} else if (state.seletType.value == "1") {
|
||||
fingerprintType = 2;
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
if (state.endTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
print(
|
||||
"fasdfasdfasdf:${int.parse(state.beginTimeTimestamp.value)} == ${int.parse(state.endTimeTimestamp.value)}");
|
||||
if (int.parse(state.beginTimeTimestamp.value) >=
|
||||
int.parse(state.endTimeTimestamp.value)) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
startDate = state.beginTimeTimestamp.value;
|
||||
endDate = state.endTimeTimestamp.value;
|
||||
} else if (state.seletType.value == "2") {
|
||||
if (state.effectiveDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择生效时间");
|
||||
return;
|
||||
}
|
||||
if (state.failureDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择失效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.weekdaysList.value.isEmpty) {
|
||||
Toast.show(msg: "请选择有效日");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (state.effectiveDateTime.value >= state.failureDateTime.value) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
startDate = state.effectiveDateTime.value.toString();
|
||||
endDate = state.failureDateTime.value.toString();
|
||||
fingerprintType = 4;
|
||||
}
|
||||
|
||||
print("addOtherType startDate:$startDate endDate:$endDate");
|
||||
switch (state.lockType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
Get.toNamed(Routers.addICCardPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"cardName": state.nameController.text,
|
||||
"cardNumber":
|
||||
(Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
"cardType": fingerprintType.toString(),
|
||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
});
|
||||
|
||||
// var entity = await ApiRepository.to.addICCardData(
|
||||
// lockId: state.lockId.value.toString(),
|
||||
// endDate: endDate,
|
||||
// cardName: state.nameController.text,
|
||||
// cardNumber: (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
// cardType: fingerprintType.toString(),
|
||||
// addType:"1",
|
||||
// startDate: startDate,
|
||||
// isCoerced: state.isStressFingerprint.value ? "1" : "2",
|
||||
// weekDay: state.weekdaysList.value,
|
||||
// );
|
||||
// if(entity.errorCode!.codeIsSuccessful){
|
||||
// Toast.show(msg: "添加成功");
|
||||
// Get.back(result: "addScuess");
|
||||
// }
|
||||
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
Get.toNamed(Routers.addFingerprintPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"fingerprintName": state.nameController.text,
|
||||
"fingerprintNumber": "123456",
|
||||
"fingerprintType": fingerprintType.toString(),
|
||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
});
|
||||
|
||||
/* 根据田总需求 无需tips页面 直接跳转到添加页面
|
||||
Get.toNamed(Routers.addFingerprintTipPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"fingerprintName": state.nameController.text,
|
||||
"fingerprintNumber": "123456",
|
||||
"fingerprintType": fingerprintType.toString(),
|
||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
});
|
||||
*/
|
||||
|
||||
// var entity = await ApiRepository.to.addFingerprintsData(
|
||||
// lockId: state.lockId.value.toString(),
|
||||
// endDate: endDate,
|
||||
// addType:"1",
|
||||
// fingerprintName: state.nameController.text,
|
||||
// fingerprintNumber: (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
// fingerprintType: fingerprintType.toString(),
|
||||
// isCoerced: state.isStressFingerprint.value ? "1" : "2",
|
||||
// startDate: startDate,
|
||||
// weekDay: state.weekdaysList.value,
|
||||
// );
|
||||
// if(entity.errorCode!.codeIsSuccessful){
|
||||
// Toast.show(msg: "添加成功");
|
||||
// Get.back(result: "addScuess");
|
||||
// }
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// 人脸
|
||||
Get.toNamed(Routers.addFaceTipPage);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../otherTypeKeyList/fingerprintListData_entity.dart';
|
||||
|
||||
class OtherTypeKeyDetailState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
final type = 0.obs;// 0卡 1指纹 2遥控
|
||||
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
|
||||
final typeNumber = "".obs;// 指纹号
|
||||
final typeName = "".obs;// 指纹名字
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
final keyType = 0.obs;// 永久:1;限时2,单次3,循环:4
|
||||
var weekDay = [].obs;// 有效日
|
||||
var adder = "".obs;// 添加者
|
||||
var addTime = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;// 添加时间
|
||||
|
||||
final isStressFingerprint = false.obs;
|
||||
OtherTypeKeyDetailState() {
|
||||
Map map = Get.arguments;
|
||||
type.value = map["type"];
|
||||
if(type.value == 0){
|
||||
// 0卡
|
||||
fingerprintItemData.value = map["fingerprintItemData"];
|
||||
keyId.value = fingerprintItemData.value.cardId!;
|
||||
typeNumber.value = fingerprintItemData.value.cardNumber!;
|
||||
typeName.value = fingerprintItemData.value.cardName!;
|
||||
changeNameController.text = typeName.value;
|
||||
effectiveDateTime.value = fingerprintItemData.value.startDate!;
|
||||
failureDateTime.value = fingerprintItemData.value.endDate!;
|
||||
keyType.value = fingerprintItemData.value.cardType!;
|
||||
adder.value = fingerprintItemData.value.senderUsername!;
|
||||
addTime.value = fingerprintItemData.value.createDate!;
|
||||
isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false;
|
||||
weekDay.value = fingerprintItemData.value.weekDay!;
|
||||
}else if(type.value == 1){
|
||||
// 1指纹
|
||||
fingerprintItemData.value = map["fingerprintItemData"];
|
||||
keyId.value = fingerprintItemData.value.fingerprintId!;
|
||||
typeNumber.value = fingerprintItemData.value.fingerprintNumber!;
|
||||
typeName.value = fingerprintItemData.value.fingerprintName!;
|
||||
changeNameController.text = typeName.value;
|
||||
effectiveDateTime.value = fingerprintItemData.value.startDate!;
|
||||
failureDateTime.value = fingerprintItemData.value.endDate!;
|
||||
keyType.value = fingerprintItemData.value.fingerprintType!;
|
||||
adder.value = fingerprintItemData.value.senderUsername!;
|
||||
addTime.value = fingerprintItemData.value.createDate!;
|
||||
isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false;
|
||||
weekDay.value = fingerprintItemData.value.weekDay!;
|
||||
}else if(type.value == 2){
|
||||
// 2遥控
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,486 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/left_slide_actions.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'fingerprintListData_entity.dart';
|
||||
import 'otherTypeKeyList_logic.dart';
|
||||
|
||||
class OtherTypeKeyListPage extends StatefulWidget {
|
||||
const OtherTypeKeyListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<OtherTypeKeyListPage> createState() => _OtherTypeKeyListPageState();
|
||||
}
|
||||
|
||||
class _OtherTypeKeyListPageState extends State<OtherTypeKeyListPage> {
|
||||
final logic = Get.put(OtherTypeKeyListLogic());
|
||||
final state = Get.find<OtherTypeKeyListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: getAppBarTitle(state.fromType.value),
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI(state.fromType.value)),
|
||||
AddBottomWhiteBtn(
|
||||
btnName:
|
||||
'${TranslationLoader.lanKeys!.add!.tr}${getAppBarTitle(state.fromType.value)}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.otherTypeKeyManagePage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"keyType": state.fromType.value,
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
switch (state.fromType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
logic.getICCardListData();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
logic.getFingerprintsListData();
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// 人脸
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String getAppBarTitle(int type) {
|
||||
String title = "";
|
||||
switch (type) {
|
||||
case 0:
|
||||
title = TranslationLoader.lanKeys!.card!.tr;
|
||||
break;
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.fingerprint!.tr;
|
||||
break;
|
||||
case 2:
|
||||
title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
||||
break;
|
||||
case 3:
|
||||
title = TranslationLoader.lanKeys!.face!.tr;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.searchController,
|
||||
autofocus: false,
|
||||
onChanged: (value) {
|
||||
print("onChanged:$value");
|
||||
},
|
||||
onEditingComplete: () {
|
||||
print("onEditingComplete:");
|
||||
},
|
||||
onSubmitted: (value) {
|
||||
switch (state.fromType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
logic.getICCardListData();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
logic.getFingerprintsListData();
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// 人脸
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
icon: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.h, bottom: 20.h, right: 20.w, left: 10.w),
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_search.png',
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI(int type) {
|
||||
// String typeImgName = "";
|
||||
// if (type == 0) {
|
||||
// //卡
|
||||
// typeImgName = 'images/icon_card.png';
|
||||
// } else if (type == 1) {
|
||||
// //指纹
|
||||
// typeImgName = 'images/icon_fingerprint.png';
|
||||
// } else if (type == 2) {
|
||||
// //遥控
|
||||
// typeImgName = 'images/icon_card.png';
|
||||
// }
|
||||
|
||||
return Obx(() => state.fingerprintItemListData.value.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
FingerprintItemData fingerprintItemData =
|
||||
state.fingerprintItemListData.value[index];
|
||||
switch (state.fromType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
if (index < state.fingerprintItemListData.value.length) {
|
||||
return LeftSlideActions(
|
||||
key: Key(fingerprintItemData.cardName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(fingerprintItemData.cardId.toString()),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_card.png',
|
||||
fingerprintItemData.cardName!,
|
||||
fingerprintItemData.cardType! == 1
|
||||
? "永久"
|
||||
: "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}",
|
||||
() async {
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyDetailPage,
|
||||
arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
"type": type,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getICCardListData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
|
||||
return _keyItem(
|
||||
'images/icon_card.png',
|
||||
fingerprintItemData.cardName!,
|
||||
fingerprintItemData.cardType! == 1
|
||||
? "永久"
|
||||
: "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}",
|
||||
() async {
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyDetailPage,
|
||||
arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
"type": type,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getICCardListData();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
if (index < state.fingerprintItemListData.value.length) {
|
||||
return LeftSlideActions(
|
||||
key: Key(fingerprintItemData.fingerprintName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(
|
||||
fingerprintItemData.fingerprintId.toString()),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_fingerprint.png',
|
||||
fingerprintItemData.fingerprintName!,
|
||||
fingerprintItemData.fingerprintType! == 1
|
||||
? "永久"
|
||||
: "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}",
|
||||
() async {
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyDetailPage,
|
||||
arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
"type": type,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getFingerprintsListData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
|
||||
return _keyItem(
|
||||
'images/icon_fingerprint.png',
|
||||
fingerprintItemData.fingerprintName!,
|
||||
fingerprintItemData.fingerprintType! == 1
|
||||
? "永久"
|
||||
: "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}",
|
||||
() async {
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyDetailPage,
|
||||
arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
"type": type,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getFingerprintsListData();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
)
|
||||
: const NoData());
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String idStr) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
showIosTipViewDialog(context, idStr);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, String keyId) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
String? idStr = await Storage.getUid();
|
||||
switch (state.fromType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
state.isDeletICCardData = true;
|
||||
logic.senderAddICCard(keyId, idStr ?? "", 0);
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
state.isDeletFingerprintData = true;
|
||||
logic.senderAddFingerprint(keyId, idStr ?? "", 0);
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(
|
||||
BuildContext context,
|
||||
) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
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);
|
||||
switch (state.fromType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
state.isDeletICCardData = true;
|
||||
logic.senderAddICCard("1", "DeleteAll!@#", 255);
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
// logic.deletAllFingerprintsData();
|
||||
state.isDeletFingerprintData = true;
|
||||
logic.senderAddFingerprint("1", "DeleteAll!@#", 255);
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_tool/io_manager.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'otherTypeKeyManage_tabbar.dart';
|
||||
|
||||
class OtherTypeKeyManagePage extends StatefulWidget {
|
||||
const OtherTypeKeyManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<OtherTypeKeyManagePage> createState() => _OtherTypeKeyManagePageState();
|
||||
}
|
||||
|
||||
class _OtherTypeKeyManagePageState extends State<OtherTypeKeyManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 0卡 1指纹 2钥匙
|
||||
Map map = Get.arguments;
|
||||
var lockId = map["lockId"];
|
||||
var lockKeyType = map["keyType"];
|
||||
var fromType = map["fromType"]; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";
|
||||
if(fromType == 2){
|
||||
fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.addTip!.tr}${getAppBarTitle(lockKeyType)}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
OtherTypeKeyManageTabbar(initialIndex: index, lockType: lockKeyType, lockId: lockId, fromType: fromType, fromTypeTwoStaffName:fromTypeTwoStaffName),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String getAppBarTitle(int type) {
|
||||
String title = "";
|
||||
switch (type) {
|
||||
case 0:
|
||||
title = TranslationLoader.lanKeys!.card!.tr;
|
||||
break;
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.fingerprint!.tr;
|
||||
break;
|
||||
case 2:
|
||||
title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
final PasswordKeyDetailState state = PasswordKeyDetailState();
|
||||
|
||||
//删除密码请求 deleteType:1-蓝牙 2-网关
|
||||
Future<void> deletePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
|
||||
state.itemData.value.lockId.toString(),
|
||||
state.itemData.value.keyboardPwdId.toString(),
|
||||
1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
|
||||
//更新密码请求
|
||||
Future<void> updatePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
|
||||
state.itemData.value.lockId.toString(),
|
||||
state.itemData.value.keyboardPwdId.toString(),
|
||||
state.inputNameController.text,
|
||||
state.inputPwdController.text,
|
||||
'',
|
||||
'',
|
||||
'');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,12 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/showTFView.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
@ -25,25 +22,12 @@ class PasswordKeyDetailPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
PasswordKeyListItem itemData = PasswordKeyListItem();
|
||||
late TextEditingController _inputPwdController;
|
||||
late TextEditingController _inputNameController;
|
||||
static const methodChannel = MethodChannel('talkPlugin');
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_inputPwdController = TextEditingController();
|
||||
_inputNameController = TextEditingController();
|
||||
}
|
||||
final logic = Get.put(PasswordKeyDetailLogic());
|
||||
final state = Get.find<PasswordKeyDetailLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["itemData"] != null)) {
|
||||
itemData = obj["itemData"];
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
@ -68,45 +52,52 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.password!.tr,
|
||||
rightTitle: _inputPwdController.text.isNotEmpty
|
||||
? _inputPwdController.text
|
||||
: itemData.keyboardPwd,
|
||||
rightTitle: state.inputPwdController.text.isNotEmpty
|
||||
? state.inputPwdController.text
|
||||
: state.itemData.value.keyboardPwd,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context, _inputPwdController);
|
||||
showCupertinoAlertDialog(context, state.inputPwdController);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: _inputNameController.text.isNotEmpty
|
||||
? _inputNameController.text
|
||||
: itemData.keyboardPwdName,
|
||||
rightTitle: state.inputNameController.text.isNotEmpty
|
||||
? state.inputNameController.text
|
||||
: state.itemData.value.keyboardPwdName,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context, _inputNameController);
|
||||
showCupertinoAlertDialog(
|
||||
context, state.inputNameController);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: "永久",
|
||||
rightTitle: getUseDateStr(),
|
||||
isHaveDirection: true,
|
||||
allHeight:
|
||||
state.itemData.value.keyboardPwdType == 3 ? 90.h : 65.h,
|
||||
action: () {
|
||||
if (state.itemData.value.keyboardPwdType! > 4 &&
|
||||
state.itemData.value.keyboardPwdType! < 15) {
|
||||
return;
|
||||
}
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyDetailChangeDate,
|
||||
arguments: {
|
||||
'lockId': itemData.lockId.toString(),
|
||||
'pwdId': itemData.keyboardPwdId.toString()
|
||||
'lockId': state.itemData.value.lockId.toString(),
|
||||
'pwdId': state.itemData.value.keyboardPwdId.toString()
|
||||
});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.sender!.tr,
|
||||
rightTitle: itemData.senderUsername,
|
||||
rightTitle: state.itemData.value.senderUsername,
|
||||
isHaveLine: true,
|
||||
action: () {}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.senderTime!.tr,
|
||||
rightTitle: getSenderDate(itemData),
|
||||
rightTitle: getSenderDate(state.itemData.value),
|
||||
action: () {}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
@ -116,8 +107,8 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.keyOperationRecordPage,
|
||||
arguments: {
|
||||
'lockId': itemData.lockId.toString(),
|
||||
'keyId': itemData.keyboardPwdId.toString()
|
||||
'lockId': state.itemData.value.lockId.toString(),
|
||||
'keyId': state.itemData.value.keyboardPwdId.toString()
|
||||
});
|
||||
}),
|
||||
Container(height: 40.h),
|
||||
@ -129,10 +120,10 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
// backgroundColor: Colors.white,
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, Routers.otherTypeKeyManagePage, arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
"fromType": 0
|
||||
});
|
||||
Navigator.pushNamed(context, Routers.cardListPage,
|
||||
arguments: {
|
||||
"lockId": state.itemData.value.lockId,
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
'设置卡',
|
||||
@ -151,13 +142,15 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
// backgroundColor: Colors.white,
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.otherTypeKeyManagePage,arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
"fromType": 1
|
||||
});
|
||||
Navigator.pushNamed(context, Routers.fingerprintListPage,
|
||||
arguments: {
|
||||
"lockId": state.itemData.value.lockId,
|
||||
});
|
||||
},
|
||||
child: Text('设置指纹', style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp),
|
||||
child: Text(
|
||||
'设置指纹',
|
||||
style: TextStyle(
|
||||
color: AppColors.mainColor, fontSize: 24.sp),
|
||||
)),
|
||||
),
|
||||
SizedBox(
|
||||
@ -171,10 +164,11 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
// backgroundColor: Colors.white,
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, Routers.otherTypeKeyManagePage, arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
"fromType": 2
|
||||
});
|
||||
Navigator.pushNamed(
|
||||
context, Routers.remoteControlListPage,
|
||||
arguments: {
|
||||
"lockId": state.itemData.value.lockId,
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
'设置遥控',
|
||||
@ -200,6 +194,83 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
));
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr() {
|
||||
int? getPwdType = state.itemData.value.keyboardPwdType;
|
||||
String useDateStr = '';
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
|
||||
int starHour = startDateStr.hour;
|
||||
int endHour = endDateStr.hour;
|
||||
|
||||
switch (getPwdType) {
|
||||
case 1:
|
||||
//单次 1 只能在开始时间后6小时内使用一次
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
break;
|
||||
case 2:
|
||||
//永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
useDateStr = '永久';
|
||||
break;
|
||||
case 3:
|
||||
//限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
break;
|
||||
case 4:
|
||||
//删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
break;
|
||||
case 5:
|
||||
//周未循环 5 在周未开始和结束时间指定时间段内有效
|
||||
useDateStr = '周末 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 6:
|
||||
//每日循环 6 每天开始和结束时间指定时间段内有效
|
||||
useDateStr = '周日 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 7:
|
||||
//工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
||||
useDateStr = '工作日 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 8:
|
||||
//周一循环 8 每周一开始和结束时间指定时间段内有效
|
||||
useDateStr = '周一 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 9:
|
||||
//周二循环 9 每周二开始和结束时间指定时间段内有效
|
||||
useDateStr = '周二 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 10:
|
||||
//周三循环 10 每周三开始和结束时间指定时间段内有效
|
||||
useDateStr = '周三 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 11:
|
||||
//周四循环 11 每周四开始和结束时间指定时间段内有效
|
||||
useDateStr = '周四 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 12:
|
||||
//周五循环 12 每周五开始和结束时间指定时间段内有效
|
||||
useDateStr = '周五 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 13:
|
||||
//周六循环 13 每周六开始和结束时间指定时间段内有效
|
||||
useDateStr = '周六 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 14:
|
||||
//周天循环 14 每周日开始和结束时间指定时间段内有效
|
||||
useDateStr = '周天 $starHour:00-$endHour:00';
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
//发送时间
|
||||
String getSenderDate(PasswordKeyListItem indexEntity) {
|
||||
String senderDate = '';
|
||||
@ -209,106 +280,13 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
return senderDate;
|
||||
}
|
||||
|
||||
Widget commonItem(String leftTitle, String rightTitle,
|
||||
{bool isHaveDirection = false,
|
||||
bool isHaveLine = false,
|
||||
bool isHaveRightWidget = false,
|
||||
Widget? rightWidget,
|
||||
Function()? action}) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
// height: 80.h,
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.only(
|
||||
left: 20.w, right: 10.w, top: 20.w, bottom: 20.w),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 20.w),
|
||||
Text(
|
||||
leftTitle,
|
||||
style:
|
||||
TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
isHaveRightWidget
|
||||
? rightWidget!
|
||||
: Text(
|
||||
rightTitle,
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.w),
|
||||
isHaveDirection
|
||||
? Image.asset(
|
||||
'images/icon_right.png',
|
||||
width: 50.w,
|
||||
height: 50.w,
|
||||
)
|
||||
: SizedBox(width: 10.w),
|
||||
// SizedBox(width:10.w),
|
||||
],
|
||||
),
|
||||
),
|
||||
isHaveLine
|
||||
? Container(
|
||||
height: 0.5.h,
|
||||
color: Colors.grey,
|
||||
)
|
||||
: Container()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//删除密码请求 deleteType:1-蓝牙 2-网关
|
||||
Future<void> deletePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
|
||||
itemData.lockId.toString(), itemData.keyboardPwdId.toString(), 1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "删除成功");
|
||||
setState(() {
|
||||
Navigator.pop(context, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//更新密码请求
|
||||
Future<void> updatePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
|
||||
itemData.lockId.toString(),
|
||||
itemData.keyboardPwdId.toString(),
|
||||
_inputNameController.text,
|
||||
_inputPwdController.text,
|
||||
'',
|
||||
'',
|
||||
'');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "修改成功");
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(
|
||||
BuildContext context, TextEditingController inputController) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: inputController == _inputNameController
|
||||
title: inputController == state.inputNameController
|
||||
? "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}"
|
||||
: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.password!.tr}",
|
||||
tipTitle: "请输入",
|
||||
@ -316,7 +294,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
if (inputController.text.isNotEmpty) {
|
||||
updatePwdRequest();
|
||||
logic.updatePwdRequest();
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
@ -414,7 +392,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
{
|
||||
Navigator.pop(context);
|
||||
String pwdShareStr =
|
||||
'您好,您的密码是:${itemData.keyboardPwd}\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName}';
|
||||
'您好,您的密码是:${state.itemData.value.keyboardPwd}\n生效时间:${state.itemData.value.startDate}\n类型:永久\n锁名:${state.itemData.value.keyboardPwdName}';
|
||||
tokNative('flutter_sharePassword_to_ios',
|
||||
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
|
||||
print('$result');
|
||||
@ -459,13 +437,12 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
deletePwdRequest();
|
||||
logic.deletePwdRequest();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
|
||||
class PasswordKeyDetailState {
|
||||
final itemData = PasswordKeyListItem().obs;
|
||||
final TextEditingController inputPwdController = TextEditingController();
|
||||
final TextEditingController inputNameController = TextEditingController();
|
||||
|
||||
PasswordKeyDetailState() {
|
||||
Map map = Get.arguments;
|
||||
itemData.value = map["itemData"];
|
||||
}
|
||||
}
|
||||
@ -86,9 +86,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
|
||||
onClick: () {
|
||||
Navigator.pushNamed(context, Routers.passwordKeyManagePage,
|
||||
arguments: {
|
||||
"keyInfo": state.keyInfo.value
|
||||
}).then((val) {
|
||||
arguments: {"keyInfo": state.keyInfo.value}).then((val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
}
|
||||
@ -143,7 +141,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
top: 18.0, left: -19.0, right: -15.0, bottom: 2),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
@ -186,13 +184,13 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
),
|
||||
child: _electronicKeyItem('images/icon_password.png',
|
||||
passwordKeyListItem.keyboardPwdName!, useDateStr, () {
|
||||
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
|
||||
arguments: {"itemData": passwordKeyListItem}).then((val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
}
|
||||
});
|
||||
}),
|
||||
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
|
||||
arguments: {"itemData": passwordKeyListItem}).then((val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
}
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
@ -229,7 +227,8 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, PasswordKeyListItem passwordKeyListItem) {
|
||||
void showIosTipViewDialog(
|
||||
BuildContext context, PasswordKeyListItem passwordKeyListItem) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -238,65 +237,100 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
logic.deletePwdRequest(passwordKeyListItem.lockId.toString(), passwordKeyListItem.keyboardPwdId.toString(), 1);
|
||||
logic.deletePwdRequest(passwordKeyListItem.lockId.toString(),
|
||||
passwordKeyListItem.keyboardPwdId.toString(), 1);
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
//使用期限
|
||||
/**
|
||||
单次 1 只能在开始时间后6小时内使用一次
|
||||
永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
||||
周未循环 5 在周未开始和结束时间指定时间段内有效
|
||||
每日循环 6 每天开始和结束时间指定时间段内有效
|
||||
工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
||||
周一循环 8 每周一开始和结束时间指定时间段内有效
|
||||
周二循环 9 每周二开始和结束时间指定时间段内有效
|
||||
周三循环 10 每周三开始和结束时间指定时间段内有效
|
||||
周四循环 11 每周四开始和结束时间指定时间段内有效
|
||||
周五循环 12 每周五开始和结束时间指定时间段内有效
|
||||
周六循环 13 每周六开始和结束时间指定时间段内有效
|
||||
周天循环 14 每周日开始和结束时间指定时间段内有效
|
||||
*/
|
||||
String getUseDateStr(PasswordKeyListItem indexEntity) {
|
||||
int? getPwdType = indexEntity.keyboardPwdType;
|
||||
String useDateStr = '';
|
||||
if (indexEntity.keyboardPwdType == 3) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyboardPwdType == 2) {
|
||||
//永久
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||
} else if (indexEntity.keyboardPwdType == 1) {
|
||||
//单次
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||
} else if (indexEntity.keyboardPwdType == 4) {
|
||||
//删除
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 清空码';
|
||||
} else {
|
||||
//循环
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 循环';
|
||||
}
|
||||
DateTime sendDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
int starHour = startDateStr.hour;
|
||||
int endHour = endDateStr.hour;
|
||||
|
||||
switch (getPwdType) {
|
||||
case 1:
|
||||
//单次 1 只能在开始时间后6小时内使用一次
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||
break;
|
||||
case 2:
|
||||
//永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||
break;
|
||||
case 3:
|
||||
//限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)} 限时';
|
||||
break;
|
||||
case 4:
|
||||
//删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 清空码';
|
||||
break;
|
||||
case 5:
|
||||
//周未循环 5 在周未开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周末$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 6:
|
||||
//每日循环 6 每天开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周日$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 7:
|
||||
//工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 工作日$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 8:
|
||||
//周一循环 8 每周一开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周一$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 9:
|
||||
//周二循环 9 每周二开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周二$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 10:
|
||||
//周三循环 10 每周三开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周三$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 11:
|
||||
//周四循环 11 每周四开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周四$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 12:
|
||||
//周五循环 12 每周五开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周五$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 13:
|
||||
//周六循环 13 每周六开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周六$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 14:
|
||||
//周天循环 14 每周日开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周天$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user