diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index 4366b083..46f6c130 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -76,7 +76,7 @@ import 'main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkin import 'main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart'; import 'main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicManageKey/massSendElectronicKeyManage_page.dart'; import 'main/lockDetail/face/addFace/addFace_page.dart'; -import 'main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart'; +import 'main/lockDetail/face/addFaceType/addFaceType_page.dart'; import 'main/lockDetail/face/faceList/faceList_page.dart'; import 'main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart'; import 'main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart'; @@ -117,7 +117,7 @@ import 'main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart'; import 'main/lockDetail/monitoring/monitoringRealTimeScreen/monitoringRealTimeScreen_page.dart'; import 'main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart'; import 'main/lockDetail/realTimePicture/realTimePicture_page.dart'; -import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_page.dart'; +import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_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'; @@ -412,8 +412,7 @@ abstract class Routers { static const videoLogDownLoadPage = '/VideoLogDownLoadPage'; // 视频下载列表 static const remoteControlListPage = '/RemoteControlListPage'; // 遥控列表 - static const addRemoteControlManagePage = - '/AddRemoteControlManagePage'; // 添加遥控 + static const addRemoteControlPage = '/AddRemoteControlPage'; // 添加遥控 static const cardListPage = '/CardListPage'; // 卡列表 // static const addCardTypeManagePage = '/AddCardTypeManagePage'; // 添加卡 @@ -423,7 +422,7 @@ abstract class Routers { static const addFingerprintTypePage = '/AddFingerprintTypePage'; // 添加指纹 static const fingerprintDetailPage = '/FingerprintDetailPage'; // 指纹详情 static const faceListPage = '/FaceListPage'; // 人脸列表 - static const addFaceTypeManagePage = '/AddFaceTypeManagePage'; // 添加人脸 + static const addFaceTypePage = '/AddFaceTypePage'; // 添加人脸 static const faceDetailPage = '/faceDetailPage'; // 人脸详情 static const irisListPage = '/IrisListPage'; // 虹膜列表 @@ -1006,8 +1005,8 @@ abstract class AppRouters { name: Routers.remoteControlListPage, page: () => const RemoteControlListPage()), GetPage( - name: Routers.addRemoteControlManagePage, - page: () => const AddRemoteControlManagePage()), + name: Routers.addRemoteControlPage, + page: () => const AddRemoteControlPage()), GetPage(name: Routers.cardListPage, page: () => const CardListPage()), // GetPage( // name: Routers.addCardTypeManagePage, @@ -1027,8 +1026,8 @@ abstract class AppRouters { page: () => const FingerprintDetailPage()), GetPage(name: Routers.faceListPage, page: () => const FaceListPage()), GetPage( - name: Routers.addFaceTypeManagePage, - page: () => const AddFaceTypeManagePage()), + name: Routers.addFaceTypePage, + page: () => const AddFaceTypePage()), GetPage( name: Routers.passwordKeyDetailChangeDatePage, page: () => const PasswordKeyDetailChangeDatePage()), diff --git a/star_lock/lib/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index 83eb71d6..bcb1612e 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -86,6 +86,7 @@ class IoSenderManage { List? publicKey, List? privateKey, List? token, + bool? isBeforeAddUser, CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: AddUserCommand( @@ -103,7 +104,7 @@ class IoSenderManage { publicKey: publicKey, privateKey: privateKey, token: token), - isBeforeAddUser: true, + isBeforeAddUser: isBeforeAddUser!, callBack: callBack); } @@ -214,6 +215,7 @@ class IoSenderManage { {String? lockID, String? userID, List? privateKey, + bool? isBeforeAddUser, CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: GetStarLockStatuInfoCommand( @@ -221,6 +223,7 @@ class IoSenderManage { userID: userID, privateKey: privateKey, ), + isBeforeAddUser: isBeforeAddUser!, callBack: callBack); } diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index d8749f88..1948cf27 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -180,7 +180,7 @@ class _CheckingInAddStaffPageState extends State { } break; case 5: - Get.toNamed(Routers.addFaceTypeManagePage, arguments: { + Get.toNamed(Routers.addFaceTypePage, arguments: { "lockId": state.getKeyInfosData.value.lockId, "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 "fromTypeTwoStaffName": state.staffNameController.text diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart index d02c47c9..b791b9c6 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart @@ -16,16 +16,17 @@ class AddFaceTypeLogic extends BaseGetXController { var startTime = ""; var endTime = ""; if (state.selectType.value == "0") { + print("永久卡永久卡永久卡"); faceType = 1; startDate = "0"; endDate = "0"; startTime = "0"; endTime = "0"; } else if (state.selectType.value == "1") { + print("限时卡限时卡限时卡"); faceType = 2; - startDate = - DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); - endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + startDate = DateTool().dateToTimestamp(state.timeLimitBeginTime.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.timeLimitEndTime.value, 1).toString(); startTime = "0"; endTime = "0"; @@ -48,16 +49,18 @@ class AddFaceTypeLogic extends BaseGetXController { return; } } else if (state.selectType.value == "2") { - if (state.beginTime.value.isEmpty) { + print("循环卡循环卡循环卡"); + if (state.cycleBeginTime.value.isEmpty) { showToast("请选择有效期".tr); return; } - startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); - endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + startDate = DateTool().dateToTimestamp(state.cycleBeginTime.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString(); startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString(); endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString(); faceType = 4; } + // 人脸 Get.toNamed(Routers.addFacePage, arguments: { "lockId": state.lockId.value, diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index fd5d2787..fd745afb 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -9,106 +9,111 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/CustomUnderlineTabIndicator.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/storage.dart'; import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; import 'addFaceType_logic.dart'; class AddFaceTypePage extends StatefulWidget { - final String selectType; // 永久限时循环下标 - final int lockId; - final int fromType; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - final String fromTypeTwoStaffName; // 从添加员工进入 传入员工名字 - - const AddFaceTypePage( - {Key? key, - required this.selectType, - required this.lockId, - required this.fromType, - required this.fromTypeTwoStaffName}) - : super(key: key); + const AddFaceTypePage({Key? key}) : super(key: key); @override State createState() => _AddFaceTypePageState(); } -class _AddFaceTypePageState extends State { +class _AddFaceTypePageState extends State with SingleTickerProviderStateMixin { final logic = Get.put(AddFaceTypeLogic()); final state = Get.find().state; - @override - Widget build(BuildContext context) { - state.selectType.value = widget.selectType; - state.lockId.value = widget.lockId; - if (widget.fromTypeTwoStaffName.isNotEmpty) { - state.nameController.text = widget.fromTypeTwoStaffName; - } - state.fromType.value = widget.fromType; - - return indexChangeWidget(); - } - @override void initState() { // TODO: implement initState super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) { - if (state.selectType.value == "1") { - state.beginTime.value = DateTool().dateToYMDHNString( - DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 - state.endTime.value = DateTool().dateToYMDHNString( - DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 - } else { - state.beginTime.value = ""; //默认为当前时间 - state.endTime.value = ""; //默认为当前时间 + state.tabController = TabController( + vsync: this, + length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, + initialIndex: 0); + state.tabController.addListener(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + state.selectType.value = state.tabController.index.toString(); + }); + + if (state.tabController.animation!.value == state.tabController.index) { + FocusScope.of(context).requestFocus(FocusNode()); } }); } + @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: [ + _tabBar(), + _pageWidget(), + ], + ), + ); + } + Widget indexChangeWidget() { - switch (int.parse(widget.selectType)) { + switch (int.parse(state.selectType.value)) { case 0: { // 永久 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyBottomWidget() - ], + return SingleChildScrollView( + child: 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(), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyTimeLimitWidget(), + keyBottomWidget() + ], + ), ); } case 2: { // 循环 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyCyclicDate(), - SizedBox(height: 10.h), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyCyclicDate(), + SizedBox(height: 10.h), + keyBottomWidget() + ], + ), ); } default: @@ -138,24 +143,24 @@ class _AddFaceTypePageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: state.beginTime.value, + rightTitle: state.timeLimitBeginTime.value, isHaveLine: true, isHaveDirection: true, action: () async { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - }); + state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: state.endTime.value, + rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - }); + state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Container(height: 10.h), ], @@ -168,47 +173,44 @@ class _AddFaceTypePageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "${state.beginTime.value}\n${state.endTime.value}", + rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", isHaveDirection: true, isHaveLine: true, action: () async { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, 'starTime': state.effectiveDateTime.value, 'endTime': state.failureDateTime.value }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; - Get.log( - '得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}'); } })), Obx(() => Visibility( visible: state.weekdaysList.isNotEmpty ? true : false, child: CommonItem( - leftTitel: "有效日", + leftTitel: "有效日".tr, rightTitle: state.weekdaysList.value.join(",").toString(), isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; } @@ -217,25 +219,22 @@ class _AddFaceTypePageState extends State { visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( leftTitel: "有效时间".tr, - rightTitle: - "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", isHaveDirection: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; - Get.back(result: result); } }))), ], @@ -338,4 +337,69 @@ class _AddFaceTypePageState extends State { }, ); } + + final List _itemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + ]; + + final List _fromCheckInTypeItemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ]; + + TabBar _tabBar() { + return TabBar( + controller: state.tabController, + onTap: (index) { + FocusScope.of(context).requestFocus(FocusNode()); + }, + tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.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: state.tabController, + children: + state.fromType.value == 1 + ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() + : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + ), + ); + } + +} + +class ItemView { + const ItemView({required this.title, required this.selectType}); + + final String title; + final String selectType; } diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart index 3ee24ba5..a5abea0e 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart @@ -1,30 +1,33 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import '../../../../tools/dateTool.dart'; + class AddFaceTypeState { final lockId = 0.obs; final selectType = "0".obs; // 0永久 1显示 2循环 final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - var fromTypeTwoStaffName = "".obs; // 考勤添加人脸员工名字 final isStressFingerprint = false.obs; final isAdministrator = false.obs; // 是否是管理员 - var beginTime = "".obs; // 开始时间 - var endTime = "".obs; // 结束时间 - var effectiveDateTime = "".obs; // 生效时间 - var failureDateTime = "".obs; // 失效时间 + var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间 + var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间 + var cycleBeginTime = "".obs;// 循环开始时间 + var cycleEndTime = "".obs;// 循环结束时间 + var effectiveDateTime = "".obs;// 生效时间 + var failureDateTime = "".obs;// 失效时间 var weekdaysList = [].obs; + var fromTypeTwoStaffName = "".obs; // 从添加员工进入 传入员工名字 final TextEditingController nameController = TextEditingController(); + late TabController tabController; AddFaceTypeState() { - // Map map = Get.arguments; - // lockId.value = map["lockId"]; - // fromType.value = map["fromType"]; - // if(fromType.value == 2){ - // fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 - // // nameController.text = fromTypeTwoStaffName.value; - // } - - // print("lockId:${lockId.value} fromType:${fromType.value}"); + Map map = Get.arguments; + lockId.value = map["lockId"]; + fromType.value = map["fromType"]; + // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + if(fromType.value == 2){ + fromTypeTwoStaffName.value = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 + } } } diff --git a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart index 39b4ac16..96c43b4a 100644 --- a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -79,7 +79,7 @@ class _FaceListPageState extends State { '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}', onClick: () async { var data = - await Get.toNamed(Routers.addFaceTypeManagePage, arguments: { + await Get.toNamed(Routers.addFaceTypePage, arguments: { "lockId": state.lockId.value, "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index d591bdf9..8a8a76a0 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -72,44 +72,50 @@ class _AddFingerprintTypePageState extends State with Si { // 永久 // return sendElectronicKeySucceed(); - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyBottomWidget() - ], + return SingleChildScrollView( + child: 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() - ], + return SingleChildScrollView( + child: 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), - keyCyclicDate(), - SizedBox(height: 10.h), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyCyclicDate(), + SizedBox(height: 10.h), + keyBottomWidget() + ], + ), ); } default: diff --git a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart index 79174f46..96bac6cb 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart @@ -74,10 +74,10 @@ class LockEscalationLogic extends BaseGetXController { if (deviceConnectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); - String lockID = CommonDataManage.shareManager() - ?.currentLockSetInfoData + String lockID = CommonDataManage.shareManager()?.currentLockSetInfoData .lockId ?.toString() ?? ''; diff --git a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart index e9b094ae..0bf6b189 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart @@ -8,34 +8,67 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/CustomUnderlineTabIndicator.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/dateTool.dart'; import '../../../../tools/storage.dart'; import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; import 'addRemoteControl_logic.dart'; class AddRemoteControlPage extends StatefulWidget { - final String selectType; - - const AddRemoteControlPage({Key? key, required this.selectType}) + const AddRemoteControlPage({Key? key}) : super(key: key); @override State createState() => _AddRemoteControlPageState(); } -class _AddRemoteControlPageState extends State { +class _AddRemoteControlPageState extends State with SingleTickerProviderStateMixin { final logic = Get.put(AddRemoteControlLoigc()); final state = Get.find().state; + @override + void initState() { + // TODO: implement initState + super.initState(); + + state.tabController = TabController( + vsync: this, + length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, + initialIndex: 0); + state.tabController.addListener(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + state.selectType.value = state.tabController.index.toString(); + }); + + if (state.tabController.animation!.value == state.tabController.index) { + FocusScope.of(context).requestFocus(FocusNode()); + } + }); + } + @override Widget build(BuildContext context) { - return indexChangeWidget(); + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: + "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + _tabBar(), + _pageWidget(), + ], + ), + ); } Widget indexChangeWidget() { - switch (int.parse(widget.selectType)) { + switch (int.parse(state.selectType.value)) { case 0: { // 永久 @@ -68,37 +101,18 @@ class _AddRemoteControlPageState extends State { 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 { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); - if(result != null && result.isNotEmpty){ - state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; - state.effectiveDateTime.value = result['starTime']; - state.failureDateTime.value = result['endTime']; - Get.log('得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}'); - } - }), - SizedBox(height: 10.h), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyCyclicDate(), + SizedBox(height: 10.h), + keyBottomWidget() + ], + ), ); } default: @@ -127,29 +141,104 @@ class _AddRemoteControlPageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: state.beginTime.value, + rightTitle: state.timeLimitBeginTime.value, isHaveLine: true, isHaveDirection: true, action: () async { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - }); + state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: state.endTime.value, + rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - }); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Container(height: 10.h), ], ); } + // 循环顶部选择日期 + Widget keyCyclicDate() { + return Column( + children: [ + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, + rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", + isHaveDirection: true, + isHaveLine: true, + action: () async { + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { + state.weekdaysList.value = result['validityValue']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; + state.effectiveDateTime.value = result['starTime']; + state.failureDateTime.value = result['endTime']; + } + })), + Obx(() => Visibility( + visible: state.weekdaysList.isNotEmpty ? true : false, + child: CommonItem( + leftTitel: "有效日".tr, + rightTitle: state.weekdaysList.value.join(",").toString(), + isHaveDirection: true, + isHaveLine: true, + action: () async { + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { + state.weekdaysList.value = result['validityValue']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; + state.effectiveDateTime.value = result['starTime']; + state.failureDateTime.value = result['endTime']; + } + }))), + Obx(() => Visibility( + visible: state.effectiveDateTime.value.isNotEmpty, + child: CommonItem( + leftTitel: "有效时间".tr, + rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + isHaveDirection: true, + action: () async { + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { + state.weekdaysList.value = result['validityValue']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; + state.effectiveDateTime.value = result['starTime']; + state.failureDateTime.value = result['endTime']; + } + }))), + ], + ); + } + Widget keyBottomWidget() { return Column( children: [ @@ -310,4 +399,69 @@ class _AddRemoteControlPageState extends State { }, ); } + + final List _itemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + ]; + + final List _fromCheckInTypeItemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ]; + + TabBar _tabBar() { + return TabBar( + controller: state.tabController, + onTap: (index) { + FocusScope.of(context).requestFocus(FocusNode()); + }, + tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.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: state.tabController, + children: + state.fromType.value == 1 + ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() + : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + ), + ); + } + +} + +class ItemView { + const ItemView({required this.title, required this.selectType}); + + final String title; + final String selectType; } diff --git a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart index 433df90a..6f7ba940 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart @@ -2,13 +2,39 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; -class AddRemoteControlState{ +import '../../../../tools/dateTool.dart'; - var beginTime = "".obs;// 开始时间 - var endTime = "".obs;// 结束时间 +class AddRemoteControlState{ + final lockId = 0.obs; + final selectType = "0".obs;// 0永久 1显示 2循环 + final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + final isStressFingerprint = false.obs; + final isAdministrator = false.obs;// 是否是管理员 + + var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间 + var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间 + var cycleBeginTime = "".obs;// 循环开始时间 + var cycleEndTime = "".obs;// 循环结束时间 var effectiveDateTime = "".obs;// 生效时间 var failureDateTime = "".obs;// 失效时间 var weekdaysList = [].obs; + var fromTypeTwoStaffName = "".obs; // 从添加员工进入 传入员工名字 final TextEditingController nameController = TextEditingController(); + late TabController tabController; + AddRemoteControlState() { + Map map = Get.arguments; + if(map["lockId"]!=null){ + lockId.value = map["lockId"]; + } + + if(map["fromType"]!=null){ + fromType.value = map["fromType"]; + // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + if(fromType.value == 2){ + fromTypeTwoStaffName.value = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 + } + } + } + } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart b/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart index 41cf9980..b5527846 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/commonDataManage.dart'; import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/noData.dart'; import '../../../../tools/showIosTipView.dart'; @@ -69,7 +70,10 @@ class _RemoteControlListPageState extends State { '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.remoteControl!.tr}', onClick: () async { var data = - await Get.toNamed(Routers.addRemoteControlManagePage); + await Get.toNamed(Routers.addRemoteControlPage, arguments: { + "lockId": CommonDataManage().currentLockSetInfoData.lockId, + "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + }); if (data != null) { // 遥控添加 diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index 09f14344..6821a58f 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -298,6 +298,7 @@ class NearbyLockLogic extends BaseGetXController { IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), + isBeforeAddUser: true, privateKey: getPrivateKeyList, ); @@ -343,6 +344,7 @@ class NearbyLockLogic extends BaseGetXController { IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), + isBeforeAddUser: true, privateKey: getPrivateKeyList, ); } else if (state == BluetoothConnectionState.disconnected) { diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 7313befe..a00cf97f 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -86,7 +86,8 @@ class SaveLockLogic extends BaseGetXController { needAuthor: 1, publicKey: publicKeyDataList, privateKey: getPrivateKeyList, - token: token); + token: token, + isBeforeAddUser: true); break; case 0x07: //无权限 @@ -234,7 +235,8 @@ class SaveLockLogic extends BaseGetXController { needAuthor:1, publicKey:publicKeyDataList, privateKey:getPrivateKeyList, - token: getTokenList + token: getTokenList, + isBeforeAddUser: true ); } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading();