From 3d781581a835683947f08f30342a66a8810b6f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Sat, 9 Sep 2023 18:33:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=80=83=E5=8B=A4=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=91=98=E5=B7=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- star_lock/lib/appRouters.dart | 10 +- star_lock/lib/blue/blue_manage.dart | 2 +- star_lock/lib/main.dart | 3 +- .../checkingInList/checkingInList_logic.dart | 43 +++ .../checkingInList/checkingInList_page.dart | 9 +- .../checkingInList/checkingInList_state.dart | 14 + .../checkingInSet/checkingInSet_logic.dart | 9 + .../checkingInSet/checkingInSet_page.dart | 22 +- .../checkingInSet/checkingInSet_state.dart | 15 + .../checkingInAddStaff_logic.dart | 47 +++ .../checkingInAddStaff_page.dart | 13 +- .../checkingInAddStaff_state.dart | 18 + .../checkingInStaffList_logic.dart | 44 +++ .../checkingInStaffList_page.dart} | 19 +- .../checkingInStaffList_state.dart | 16 + .../checkingInSetWorkTime_logic.dart | 9 + .../checkingInSetWorkTime_page.dart | 49 ++- .../checkingInSetWorkTime_state.dart | 10 + .../checkingInSetWorkdaySet_logic.dart | 9 + .../checkingInSetWorkdaySet_page.dart | 315 ++++++++---------- .../checkingInSetWorkdaySet_state.dart | 10 + .../checkInCreatCompany_logic.dart | 45 +++ .../checkInCreatCompany_page.dart | 119 +++++++ .../checkInCreatCompany_state.dart | 24 ++ .../lcokSet/diagnose/diagnose_logic.dart | 40 +++ .../lcokSet/diagnose/diagnose_page.dart | 8 +- .../lcokSet/diagnose/diagnose_state.dart | 8 + .../lockSet/CheckingInInfoDataEntity.dart | 60 ++++ .../lcokSet/lockSet/lockSet_logic.dart | 51 +++ .../lcokSet/lockSet/lockSet_page.dart | 116 ++++++- .../lcokSet/lockSet/lockSet_state.dart | 5 + .../lcokSet/lockTime/lockTime_logic.dart | 2 - .../lockDetail/lockDetail_logic.dart | 6 +- .../lockDetail/lockDetail_page.dart | 54 ++- star_lock/lib/network/api.dart | 8 + star_lock/lib/network/api_provider.dart | 88 +++++ star_lock/lib/network/api_provider_base.dart | 4 +- star_lock/lib/network/api_repository.dart | 79 +++++ .../lib/network/request_interceptor_log.dart | 1 - star_lock/lib/tools/appRouteObserver.dart | 21 ++ star_lock/lib/tools/showIosTipView.dart | 76 +++++ 42 files changed, 1266 insertions(+), 237 deletions(-) create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_logic.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_state.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_logic.dart rename star_lock/lib/main/lockDetail/checkingIn/{checkingInSetStaffManage/checkingInStaffManage_page.dart => checkingInSetStaffList/checkingInStaffList_page.dart} (83%) create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_state.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart create mode 100644 star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart create mode 100644 star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_logic.dart create mode 100644 star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_page.dart create mode 100644 star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_state.dart create mode 100644 star_lock/lib/main/lockDetail/lcokSet/lockSet/CheckingInInfoDataEntity.dart create mode 100644 star_lock/lib/tools/appRouteObserver.dart create mode 100644 star_lock/lib/tools/showIosTipView.dart diff --git a/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3..f3d88ace 100644 --- a/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -40,7 +40,7 @@ const CheckingInStaffManagePage(), + page: () => const CheckingInStaffListPage(), ), GetPage( name: Routers.checkingInAddStaffPage, @@ -753,7 +755,9 @@ abstract class AppRouters { name: Routers.massSendReceiverPage, page: () => const MassSendReceiverPage()), GetPage( - name: Routers.lockUserListPage, page: () => const LockUserListPage()) + name: Routers.lockUserListPage, page: () => const LockUserListPage()), + GetPage( + name: Routers.checkInCreatCompanyPage, page: () => const CheckInCreatCompanyPage()) ]; } diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 74bc8691..5bb1bd81 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -101,7 +101,7 @@ class BlueManage{ EasyLoading.dismiss(); } }); - _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 15)).listen((connectionStateUpdate) async { + _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 100000)).listen((connectionStateUpdate) async { // 获取状态 deviceConnectionState = connectionStateUpdate.connectionState; print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}'); diff --git a/star_lock/lib/main.dart b/star_lock/lib/main.dart index 83d51d8e..7202e3ad 100644 --- a/star_lock/lib/main.dart +++ b/star_lock/lib/main.dart @@ -13,6 +13,7 @@ import 'package:star_lock/translations/trans_lib.dart'; import 'appRouters.dart'; import 'baseWidget.dart'; +import 'tools/appRouteObserver.dart'; import 'tools/store_service.dart'; void main() async { @@ -46,7 +47,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { GetMaterialApp _initMaterialApp() => GetMaterialApp( title: 'Star Lock', - navigatorObservers: [routeObserver], + navigatorObservers: [routeObserver, AppRouteObserver().routeObserver], translations: TranslationMessage(), supportedLocales: appDept.deptSupportedLocales, localizationsDelegates: const [ diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart new file mode 100644 index 00000000..01915d42 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart @@ -0,0 +1,43 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import 'checkingInList_state.dart'; + +class CheckingInListLogic extends BaseGetXController{ + CheckingInListState state = CheckingInListState(); + + // 开启考勤获取是否有公司 + void openCheckingInData() async{ + var entity = await ApiRepository.to.openCheckingInData( + lockId:state.getKeyInfosData.value.lockId.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + state.companyId.value = entity.data!.companyId.toString(); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + openCheckingInData(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart index 5b3f45a7..ce9921a5 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart @@ -8,6 +8,7 @@ import '../../../../tools/showBottomSheetTool.dart'; import '../../../../tools/showCalendar.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'checkingInList_logic.dart'; class CheckingInListPage extends StatefulWidget { const CheckingInListPage({Key? key}) : super(key: key); @@ -17,6 +18,9 @@ class CheckingInListPage extends StatefulWidget { } class _CheckingInListPageState extends State { + final logic = Get.put(CheckingInListLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -29,7 +33,10 @@ class _CheckingInListPageState extends State { actionsList: [ GestureDetector( onTap: () { - Navigator.pushNamed(context, Routers.checkingInSetPage); + Get.toNamed(Routers.checkingInSetPage, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value + }); }, child: Image.asset( 'images/main/icon_lockDetail_checkIn_set.png', diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart new file mode 100644 index 00000000..b421ae73 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart @@ -0,0 +1,14 @@ + + +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class CheckingInListState{ + final getKeyInfosData = KeyInfos().obs; + final companyId = "".obs; + + CheckingInListState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart new file mode 100644 index 00000000..28898c8b --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart @@ -0,0 +1,9 @@ + +import '../../../../tools/baseGetXController.dart'; +import 'checkingInSet_state.dart'; + +class CheckingInSetLogic extends BaseGetXController{ + CheckingInSetState state = CheckingInSetState(); + + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart index 00c9668f..4d4ea511 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart @@ -9,6 +9,7 @@ import '../../../../tools/showTFView.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'checkingInSet_logic.dart'; class CheckingInSetPage extends StatefulWidget { const CheckingInSetPage({Key? key}) : super(key: key); @@ -18,6 +19,9 @@ class CheckingInSetPage extends StatefulWidget { } class _CheckingInSetPageState extends State { + final logic = Get.put(CheckingInSetLogic()); + final state = Get.find().state; + final TextEditingController _changeNameController = TextEditingController(); @override @@ -46,7 +50,10 @@ class _CheckingInSetPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.checkingInStaffManagePage); + Get.toNamed(Routers.checkingInStaffManagePage, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value + }); }), CommonItem( leftTitel: @@ -96,10 +103,15 @@ class _CheckingInSetPageState extends State { context: context, builder: (BuildContext context) { return ShowTFView( - title: - "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", - tipTitle: "", - controller: _changeNameController); + title: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", + tipTitle: "", + controller: _changeNameController, + sureClick: () { + + }, + cancelClick: () { + Navigator.pop(context); + },); }); } } diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart new file mode 100644 index 00000000..e4e37428 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart @@ -0,0 +1,15 @@ + +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class CheckingInSetState{ + final getKeyInfosData = KeyInfos().obs; + final companyId = "".obs; + + CheckingInSetState() { + Map map = Get.arguments; + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_logic.dart new file mode 100644 index 00000000..e9bde8f1 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_logic.dart @@ -0,0 +1,47 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import 'checkingInAddStaff_state.dart'; + +class CheckingInAddStaffLogic extends BaseGetXController{ + CheckingInAddStaffState state = CheckingInAddStaffState(); + + // 添加员工 + void addStaffLoadData() async{ + var entity = await ApiRepository.to.addStaffData( + attendanceType: '', + attendanceWay: '', + companyId: state.companyId.value, + have: '', + staffName: '', + countryCode: '', + usernameType: '', + ); + if(entity.errorCode!.codeIsSuccessful){ + + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_page.dart index 49becf66..229b949b 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -8,6 +8,7 @@ import '../../../../tools/showBottomSheetTool.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'checkingInAddStaff_logic.dart'; class CheckingInAddStaffPage extends StatefulWidget { const CheckingInAddStaffPage({Key? key}) : super(key: key); @@ -17,6 +18,9 @@ class CheckingInAddStaffPage extends StatefulWidget { } class _CheckingInAddStaffPageState extends State { + final logic = Get.put(CheckingInAddStaffLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -97,7 +101,7 @@ class _CheckingInAddStaffPageState extends State { } Widget getTFWidget(String tfStr) { - return Container( + return SizedBox( height: 50.h, width: 300.w, // color: Colors.red, @@ -107,7 +111,7 @@ class _CheckingInAddStaffPageState extends State { child: TextField( //输入框一行 maxLines: 1, - // controller: _controller, + controller: state.staffNameController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( @@ -127,7 +131,10 @@ class _CheckingInAddStaffPageState extends State { void _showSeletClockInType() { var list = [ - "15080825640", + "APP", + "密码", + "卡", + "指纹", ]; ShowBottomSheetTool().showSingleRowPicker( //上下文 diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_state.dart new file mode 100644 index 00000000..4f4546f4 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_state.dart @@ -0,0 +1,18 @@ + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class CheckingInAddStaffState{ + final getKeyInfosData = KeyInfos().obs; + final companyId = "".obs; + + final TextEditingController staffNameController = TextEditingController(); + + CheckingInAddStaffState() { + Map map = Get.arguments; + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_logic.dart new file mode 100644 index 00000000..d4b4fcb5 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_logic.dart @@ -0,0 +1,44 @@ + + +import 'package:date_format/date_format.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import 'checkingInStaffList_state.dart'; + +class CheckingInStaffManageLogic extends BaseGetXController{ + CheckingInStaffManageState state = CheckingInStaffManageState(); + + // 获取员工列表 + void getStaffList() async{ + var entity = await ApiRepository.to.getStaffListData( + companyId: state.companyId.value, + lockId:state.getKeyInfosData.value.lockId.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + getStaffList(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffManage/checkingInStaffManage_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart similarity index 83% rename from star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffManage/checkingInStaffManage_page.dart rename to star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart index 44e842f2..4b5ff299 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffManage/checkingInStaffManage_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart @@ -6,16 +6,20 @@ import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'checkingInStaffList_logic.dart'; -class CheckingInStaffManagePage extends StatefulWidget { - const CheckingInStaffManagePage({Key? key}) : super(key: key); +class CheckingInStaffListPage extends StatefulWidget { + const CheckingInStaffListPage({Key? key}) : super(key: key); @override - State createState() => - _CheckingInStaffManagePageState(); + State createState() => + _CheckingInStaffListPageState(); } -class _CheckingInStaffManagePageState extends State { +class _CheckingInStaffListPageState extends State { + final logic = Get.put(CheckingInStaffManageLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -27,7 +31,10 @@ class _CheckingInStaffManagePageState extends State { actionsList: [ GestureDetector( onTap: () { - Navigator.pushNamed(context, Routers.checkingInAddStaffPage); + Navigator.pushNamed(context, Routers.checkingInAddStaffPage, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value + }); }, child: Image.asset( 'images/icon_add_white.png', diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_state.dart new file mode 100644 index 00000000..25fe8982 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_state.dart @@ -0,0 +1,16 @@ + +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class CheckingInStaffManageState{ + final getKeyInfosData = KeyInfos().obs; + final companyId = "".obs; + + CheckingInStaffManageState() { + Map map = Get.arguments; + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart new file mode 100644 index 00000000..c558ce5f --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart @@ -0,0 +1,9 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; + +import 'checkingInSetWorkTime_state.dart'; + +class CheckingInSetWorkTimeLogic extends BaseGetXController{ + CheckingInSetWorkTimeState state = CheckingInSetWorkTimeState(); + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart index 16e9a868..33fcaa7b 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart @@ -1,12 +1,16 @@ 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/toast.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'checkingInSetWorkTime_logic.dart'; class CheckingInSetWorkTimePage extends StatefulWidget { const CheckingInSetWorkTimePage({Key? key}) : super(key: key); @@ -16,6 +20,8 @@ class CheckingInSetWorkTimePage extends StatefulWidget { } class _CheckingInSetWorkTimePageState extends State { + final logic = Get.put(CheckingInSetWorkTimeLogic()); + final state = Get.find().state; @override Widget build(BuildContext context) { @@ -29,16 +35,28 @@ class _CheckingInSetWorkTimePageState extends State { Widget buildMainUI(){ return Column( children: [ - CommonItem(leftTitel:TranslationLoader.lanKeys!.officeHours!.tr, rightTitle:"11:49", isHaveDirection: true, isHaveLine: true, action:(){ - // ShowSeletDateTime().showDatePicker(context, '2100-01-01 00:00', '1900-01-01 00:00', getNowDate(),'yyyy-MMMM-dd HH:mm', (dateTime, List index) { - // - // }); - }), - CommonItem(leftTitel:TranslationLoader.lanKeys!.closingTime!.tr, rightTitle:"11:49", isHaveDirection: true, action:(){ - // ShowSeletDateTime().showDatePicker(context, '00:00', '00:00', getNowDate(),'HH:mm', (dateTime, List index) { - // - // }); - }), + 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')}"; + }); + }); + })), + 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')}"; + }); + }); + })), SizedBox(height: 30.h,), SubmitBtn(btnName: TranslationLoader.lanKeys!.sure!.tr, borderRadius: 20.w, @@ -46,7 +64,16 @@ class _CheckingInSetWorkTimePageState extends State { margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { - + if(int.parse(state.beginTimeTimestamp.value) > int.parse(state.endTimeTimestamp.value)){ + Toast.show(msg: "结束时间不能大于开始时间"); + return; + } + Get.back(result: { + "beginTime":state.beginTime.value, + "beginTimeTimestamp":state.beginTimeTimestamp.value, + "endTime":state.endTime.value, + "endTimeTimestamp":state.endTimeTimestamp.value, + }); } ), ], diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart new file mode 100644 index 00000000..eb5c80df --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart @@ -0,0 +1,10 @@ + +import 'package:get/get.dart'; + +class CheckingInSetWorkTimeState{ + var beginTime = "".obs;// 开始时间 + var endTime = "".obs;// 结束时间 + var beginTimeTimestamp = "".obs;// 开始时间时间戳 + var endTimeTimestamp = "".obs;// 结束时间时间戳 + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart new file mode 100644 index 00000000..af0fccba --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart @@ -0,0 +1,9 @@ +import 'package:star_lock/tools/baseGetXController.dart'; + +import 'checkingInSetWorkdaySet_state.dart'; + +class CheckingInSetWorkdaySetLogic extends BaseGetXController{ + CheckingInSetWorkdaySetState state = CheckingInSetWorkdaySetState(); + + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart index 9b39d497..503b3f07 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart @@ -7,6 +7,7 @@ import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'checkingInSetWorkdaySet_logic.dart'; class CheckingInSetWorkdaySet extends StatefulWidget { const CheckingInSetWorkdaySet({Key? key}) : super(key: key); @@ -17,6 +18,9 @@ class CheckingInSetWorkdaySet extends StatefulWidget { } class _CheckingInSetWorkdaySetState extends State { + final logic = Get.put(CheckingInSetWorkdaySetLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -29,15 +33,17 @@ class _CheckingInSetWorkdaySetState extends State { body: ListView( children: [ topBtnWidget(), - Visibility(visible: true, child: bottomCustomSeletBtn()), - Visibility(visible: false, child: bottomOddOrEvenDaysOffSeletBtn()), - SizedBox( - height: 50.h, - ), + Obx(() => Visibility(visible: state.isCustom.value == true, child: bottomCustomSeletBtn())), + Obx(() => Visibility(visible: !state.isCustom.value, child: bottomOddOrEvenDaysOffSeletBtn())), + SizedBox(height: 50.h,), Container( margin: EdgeInsets.only(left: 20.w, right: 20.w), - child: SubmitBtn( - btnName: TranslationLoader.lanKeys!.sure!.tr, onClick: () {}), + child: SubmitBtn(btnName: TranslationLoader.lanKeys!.sure!.tr, onClick: () { + Get.back(result: { + "attendanceType":state.isCustom.value, + "weekDays":state.weekDays.value, + }); + }), ), ], ), @@ -50,44 +56,55 @@ class _CheckingInSetWorkdaySetState extends State { height: 100.h, // color: Colors.red, padding: EdgeInsets.all(10.w), - child: Row( + child: Obx(() => Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - width: (1.sw - 5.w * 2) / 2, - height: 100.h, - color: AppColors.mainColor, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Center( - child: Text(TranslationLoader.lanKeys!.custom!.tr, - style: - TextStyle(fontSize: 26.sp, color: Colors.white))), - ], + GestureDetector( + onTap: (){ + setState(() { + state.isCustom.value = true; + }); + }, + child: Container( + width: (1.sw - 5.w * 2) / 2, + height: 100.h, + color: state.isCustom.value ? AppColors.mainColor : AppColors.btnDisableColor, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center(child: Text(TranslationLoader.lanKeys!.custom!.tr, style: TextStyle(fontSize: 26.sp, color: Colors.white))), + ], + ), ), ), // SizedBox(width: 10.w,), - Container( - width: (1.sw - 10 * 3) / 2, - height: 100.h, - color: AppColors.btnDisableColor, - padding: EdgeInsets.all(10.w), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Center( - child: Text( - TranslationLoader.lanKeys!.oddOrEvenDaysOff!.tr, - style: TextStyle(fontSize: 26.sp, color: Colors.white), - textAlign: TextAlign.center, - ))), - ], + GestureDetector( + onTap: (){ + setState(() { + state.isCustom.value = false; + }); + }, + child: Container( + width: (1.sw - 10 * 3) / 2, + height: 100.h, + color: state.isCustom.value ? AppColors.btnDisableColor : AppColors.mainColor, + padding: EdgeInsets.all(10.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Center( + child: Text( + TranslationLoader.lanKeys!.oddOrEvenDaysOff!.tr, + style: TextStyle(fontSize: 26.sp, color: Colors.white), + textAlign: TextAlign.center, + ))), + ], + ), ), ), ], - ), + )), ); } @@ -101,42 +118,46 @@ class _CheckingInSetWorkdaySetState extends State { rightTitle: "", allHeight: 60.h, isHaveLine: true), - CommonItem( + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.singleDayWeekend!.tr, rightTitle: "", allHeight: 60.h, isHaveLine: true, isHaveRightWidget: true, rightWidget: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + state.isSingledayWeekend.value = 0; + state.weekDays.value = [1, 2 , 3, 4, 5, 6]; + }); + }, child: Row( children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), + Image.asset(state.isSingledayWeekend.value == 0 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w,), ], ), - )), - CommonItem( + ) + )), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.twoDaysOff!.tr, rightTitle: "", allHeight: 60.h, isHaveLine: false, isHaveRightWidget: true, rightWidget: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + state.isSingledayWeekend.value = 1; + state.weekDays.value = [1, 2 , 3, 4, 5]; + }); + }, child: Row( children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), + Image.asset(state.isSingledayWeekend.value == 1 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w,), ], ), - )), + ) + )), ], ), ); @@ -145,136 +166,66 @@ class _CheckingInSetWorkdaySetState extends State { Widget bottomCustomSeletBtn() { return Container( padding: EdgeInsets.only(left: 10.w, right: 10.w), - child: Column( - children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.monday!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.tuesday!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.wednesday!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.thursday!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.friday!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.saturday!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.sunday!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - ], + height: 420.h, + child: ListView.builder( + itemCount: 7, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (c, index) { + index += 1; + String dateStr; + switch (index) { + case 1: + dateStr = TranslationLoader.lanKeys!.monday!.tr; + break; + case 2: + dateStr = TranslationLoader.lanKeys!.tuesday!.tr; + break; + case 3: + dateStr = TranslationLoader.lanKeys!.wednesday!.tr; + break; + case 4: + dateStr = TranslationLoader.lanKeys!.thursday!.tr; + break; + case 5: + dateStr = TranslationLoader.lanKeys!.friday!.tr; + break; + case 6: + dateStr = TranslationLoader.lanKeys!.saturday!.tr; + break; + case 7: + dateStr = TranslationLoader.lanKeys!.sunday!.tr; + break; + default: + dateStr = ""; + break; + } + return CommonItem( + leftTitel: dateStr, + rightTitle: "", + allHeight: 60.h, + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: GestureDetector( + onTap: () { + setState(() { + state.isSingledayWeekend.value = 2; + if(state.weekDays.value.contains(index)){ + state.weekDays.value.remove(index); + }else{ + state.weekDays.value.add(index); + } + state.weekDays.value.sort(); + }); + }, + child: Row( + children: [ + Image.asset(state.weekDays.value.contains(index) ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w,), + ], + )) + ); + } ), ); } + } diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart new file mode 100644 index 00000000..3a232c6e --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart @@ -0,0 +1,10 @@ + + +import 'package:get/get.dart'; + +class CheckingInSetWorkdaySetState{ + var isCustom = true.obs; + var isSingledayWeekend = 2.obs; // 0单休 1双休 + var weekDays = [].obs;// 工作天数 + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_logic.dart new file mode 100644 index 00000000..cc70346f --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_logic.dart @@ -0,0 +1,45 @@ + +import 'package:get/get.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'checkInCreatCompany_state.dart'; + +class CheckInCreatCompanyLogic extends BaseGetXController{ + CheckInCreatCompanyState state = CheckInCreatCompanyState(); + + // 设置考勤创建公司 + void setCheckInCreateCompany() async{ + var entity = await ApiRepository.to.setCheckInCreateCompanyData( + lockId: state.getKeyInfosData.value.lockId.toString(), + attendanceType: state.isCustom.value ? "0" :"1", + companyName: state.companyNameController.text, + workDay: state.weekDays.value, + workEndTime: state.endTimeTimestamp.value, + workStartTime: state.beginTimeTimestamp.value, + ); + if(entity.errorCode!.codeIsSuccessful){ + setLockSetGeneralSetting(); + } + } + + // 设置考勤 + void setLockSetGeneralSetting() async{ + var entity = await ApiRepository.to.setLockSetGeneralSettingData( + lockId: state.getKeyInfosData.value.lockId.toString(), + changeType:"1", + isOn:"1", + type:"1", + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + + state.getKeyInfosData.value.isAttendance = 1; + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Get.back(); + Toast.show(msg: "设置成功"); + } + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_page.dart b/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_page.dart new file mode 100644 index 00000000..04f19f23 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_page.dart @@ -0,0 +1,119 @@ + +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/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; +import '../../../../translations/trans_lib.dart'; +import 'checkInCreatCompany_logic.dart'; + +class CheckInCreatCompanyPage extends StatefulWidget { + const CheckInCreatCompanyPage({Key? key}) : super(key: key); + + @override + State createState() => _CheckInCreatCompanyPageState(); +} + +class _CheckInCreatCompanyPageState extends State { + final logic = Get.put(CheckInCreatCompanyLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: "创建公司", + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + CommonItem( + leftTitel: "${TranslationLoader.lanKeys!.company!.tr}${TranslationLoader.lanKeys!.name!.tr}", + rightTitle: "", + isHaveRightWidget: true, + rightWidget: getTFWidget(false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)), + Obx(() => CommonItem( + leftTitel: + "${TranslationLoader.lanKeys!.work!.tr}${TranslationLoader.lanKeys!.time!.tr}", + rightTitle: (state.beginTime.value.isNotEmpty) ? "${state.beginTime.value} - ${state.endTime.value}" : "", + isHaveLine: true, + isHaveDirection: true, + action: () async { + var data = await Get.toNamed(Routers.checkingInSetWorkTimePage); + if(data != null) { + setState(() { + state.beginTime.value = data["beginTime"]; + state.endTime.value = data["endTime"]; + state.beginTimeTimestamp.value = data["beginTimeTimestamp"]; + state.endTimeTimestamp.value = data["endTimeTimestamp"]; + }); + } + })), + Obx(() => CommonItem( + leftTitel: + "${TranslationLoader.lanKeys!.workday!.tr}${TranslationLoader.lanKeys!.set!.tr}", + rightTitle: state.weekDaysStr.value, + isHaveLine: true, + isHaveDirection: true, + action: () async { + var data = await Get.toNamed(Routers.checkingInSetWorkdaySet); + if(data != null) { + setState(() { + state.isCustom.value = data["attendanceType"]; + state.weekDays.value = data["weekDays"]; + state.weekDaysStr.value = ""; + state.weekDaysStr.value = state.weekDays.value.join(","); + }); + } + })), + SizedBox( + height: 30.h, + ), + SubmitBtn( + btnName: TranslationLoader.lanKeys!.sure!.tr, + borderRadius: 20.w, + fontSize: 32.sp, + isDelete: false, + margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w), + padding: EdgeInsets.only(top: 20.w, bottom: 20.w), + onClick: () { + logic.setCheckInCreateCompany(); + }), + ], + ), + ); + } + + Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) { + return SizedBox( + height: 50.h, + width: 320.w, + child: Row( + children: [ + Expanded( + child: TextField( + controller:state.companyNameController, + //输入框一行 + maxLines: 1, + autofocus: false, + textAlign: TextAlign.end, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, + hintStyle: TextStyle(fontSize: 22.sp), + //不需要输入框下划线 + border: InputBorder.none, + ), + ), + ) + ], + ), + ); + } +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_state.dart b/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_state.dart new file mode 100644 index 00000000..539b205a --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_state.dart @@ -0,0 +1,24 @@ + +import 'package:flutter/cupertino.dart'; +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class CheckInCreatCompanyState{ + var getKeyInfosData = KeyInfos().obs; + + TextEditingController companyNameController = TextEditingController(); + + var isCustom = true.obs; + + var weekDays = [].obs;// 工作天数 + var weekDaysStr = "".obs;// 拼接显示的字符串天数 + + var beginTime = "".obs;// 开始时间 + var endTime = "".obs;// 结束时间 + var beginTimeTimestamp = "".obs;// 开始时间时间戳 + var endTimeTimestamp = "".obs;// 结束时间时间戳 + CheckInCreatCompanyState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_logic.dart index 2dacce4a..506b4d2a 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_logic.dart @@ -1,9 +1,49 @@ import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; import 'diagnose_state.dart'; class DiagnoseLogic extends BaseGetXController{ DiagnoseState state = DiagnoseState(); + // 诊断 + Future setLockDiagnose() async{ + var entity = await ApiRepository.to.setLockDiagnoseData( + lockId: state.getKeyInfosData.value.lockId.toString(), + electricQuantity:"23", + firmwareRevision:"1.0", // 1-开启、2-关闭; + hardwareRevision:"1.3", // 4 重置键开关 + lockDate:"1689410557000", + modelNum:"123456", + pwdInfo:"123456", + timestamp:"1689410559456000", + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "操作成功"); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + } + + @override + void onClose() { + // TODO: implement onClose + } + } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_page.dart b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_page.dart index 993484b1..6aad1dec 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_page.dart @@ -6,6 +6,7 @@ import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'diagnose_logic.dart'; class DiagnosePage extends StatefulWidget { const DiagnosePage({Key? key}) : super(key: key); @@ -15,6 +16,9 @@ class DiagnosePage extends StatefulWidget { } class _DiagnosePageState extends State { + final logic = Get.put(DiagnoseLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -47,7 +51,9 @@ class _DiagnosePageState extends State { fontSize: 32.sp, // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), - onClick: () {}), + onClick: () { + logic.setLockDiagnose(); + }), ], ), )); diff --git a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_state.dart b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_state.dart index 442da472..19cfc7ff 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_state.dart @@ -1,4 +1,12 @@ +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + class DiagnoseState{ + var getKeyInfosData = KeyInfos().obs; + DiagnoseState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/CheckingInInfoDataEntity.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/CheckingInInfoDataEntity.dart new file mode 100644 index 00000000..a691d473 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/CheckingInInfoDataEntity.dart @@ -0,0 +1,60 @@ +class CheckingInInfoDataEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + CheckingInInfoDataEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + CheckingInInfoDataEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + int? workEndTime; + int? attendanceType; + int? companyId; + int? workStartTime; + List? workDay; + + Data( + {this.workEndTime, + this.attendanceType, + this.companyId, + this.workStartTime, + this.workDay}); + + Data.fromJson(Map json) { + workEndTime = json['workEndTime']; + attendanceType = json['attendanceType']; + companyId = json['companyId']; + workStartTime = json['workStartTime']; + workDay = json['workDay']; + } + + Map toJson() { + final Map data = {}; + data['workEndTime'] = workEndTime; + data['attendanceType'] = attendanceType; + data['companyId'] = companyId; + data['workStartTime'] = workStartTime; + data['workDay'] = workDay; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart index 63b8bd81..10ad29cc 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -16,9 +16,13 @@ import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; +import '../../../../tools/toast.dart'; +import 'CheckingInInfoDataEntity.dart'; import 'lockSet_state.dart'; typedef BlockSetStateCallback = void Function(); +typedef BlockSetCheckInCallback = void Function(CheckingInInfoDataEntity checkingInInfoDataEntity); + class LockSetLogic extends BaseGetXController{ final LockSetState state = LockSetState(); @@ -32,6 +36,53 @@ class LockSetLogic extends BaseGetXController{ } } + // 开启考勤获取是否有公司 + void openCheckingInData(BlockSetCheckInCallback blockSetCheckInCallback) async{ + var entity = await ApiRepository.to.openCheckingInData( + lockId:state.getKeyInfosData.value.lockId.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + blockSetCheckInCallback(entity); + } + } + + // 设置是否打开考勤 + void setLockSetGeneralSetting(String isOn) async{ + var entity = await ApiRepository.to.setLockSetGeneralSettingData( + lockId: state.getKeyInfosData.value.lockId.toString(), + changeType:"1", + isOn:isOn, + type:"1", + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + + state.getKeyInfosData.value.isAttendance = int.parse(isOn); + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "设置成功"); + }else{ + + } + } + + // 设置是否打开开锁提醒 + void setLockPickingReminder() async{ + var entity = await ApiRepository.to.setLockPickingReminderData( + lockId: state.getKeyInfosData.value.lockId.toString(), + keyId:state.getKeyInfosData.value.keyId.toString(), + monitorFlag:state.isLockPickingReminder.value == 1 ? "1" : "2", // 1开启,2关闭 + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + + state.getKeyInfosData.value.monitorFlag = state.isLockPickingReminder.value; + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "设置成功"); + }else{ + + } + } + // 下级界面修改成功后传递数据 StreamSubscription? _passCurrentLockInformationEvent; void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index 58045c35..06668bda 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -7,8 +7,10 @@ import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/showIosTipView.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../tools/toast.dart'; @@ -22,7 +24,7 @@ class LockSetPage extends StatefulWidget { State createState() => _LockSetPageState(); } -class _LockSetPageState extends State { +class _LockSetPageState extends State with RouteAware { final logic = Get.put(LockSetLogic()); final state = Get.find().state; StreamSubscription? _passCurrentLockInformationEvent; @@ -193,7 +195,7 @@ class _LockSetPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.diagnosePage); + Get.toNamed(Routers.diagnosePage, arguments: state.getKeyInfosData.value); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.uploadData!.tr, @@ -228,13 +230,17 @@ class _LockSetPageState extends State { rightTitle: "", isHaveLine: true, isHaveDirection: true, - action: () {}), + action: () { + Toast.show(msg: "功能暂未开放"); + }), CommonItem( leftTitel: "Google Home", rightTitle: "", isHaveLine: true, isHaveDirection: true, - action: () {}), + action: () { + Toast.show(msg: "功能暂未开放"); + }), SizedBox( height: 10.h, ), @@ -260,13 +266,13 @@ class _LockSetPageState extends State { rightTitle: "", isHaveLine: true, isHaveRightWidget: true, - rightWidget: SizedBox(width: 60.w, child: _switch())), + rightWidget: SizedBox(width: 60.w, child: _openCheckInSwitch())), CommonItem( leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, rightTitle: "", isHaveLine: false, isHaveRightWidget: true, - rightWidget: SizedBox(width: 60.w, child: _switch())), + rightWidget: SizedBox(width: 60.w, child: _lockRemindSwitch())), SizedBox( height: 30.h, ), @@ -287,18 +293,108 @@ class _LockSetPageState extends State { )); } - CupertinoSwitch _switch() { - bool _isOn = false; + CupertinoSwitch _openCheckInSwitch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: _isOn, + value: (state.getKeyInfosData.value.isAttendance == 1) ? true : false, onChanged: (value) { setState(() { - _isOn = value; + int isOnStr; + if(value == true){ + isOnStr = 1; + }else{ + isOnStr = 2; + } + + logic.openCheckingInData((checkingInInfoDataEntity){ + if(checkingInInfoDataEntity.data!.companyId == 0){ + showCupertinoAlertDialog(context); + }else{ + logic.setLockSetGeneralSetting(isOnStr.toString()); + } + }); }); }, ); } + + CupertinoSwitch _lockRemindSwitch() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: state.isLockPickingReminder.value == 1 ? true : false, + onChanged: (value) { + setState(() { + state.isLockPickingReminder.value = state.isLockPickingReminder.value == 1 ? 2 : 1; + logic.setLockPickingReminder(); + }); + }, + ); + } + + void showCupertinoAlertDialog( + BuildContext context, + ) { + showDialog( + context: context, + builder: (BuildContext context) { + return ShowIosTipView( + title: "提示", + tipTitle: "创建公司号,考勤功能才能使用", + sureClick: () { + // + Navigator.pop(context); + Get.toNamed(Routers.checkInCreatCompanyPage, arguments: state.getKeyInfosData.value); + }, + cancelClick: () { + Navigator.pop(context); + }, + ); + }, + ); + } + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 界面从上一个界面进入 当前界面即将出现 + @override + void didPush() { + print("lockSet===didPush"); + } + + /// 界面返回上一个界面 当前界面即将消失 + @override + void didPop() { + print("lockSet===didPop"); + } + + /// 当前界面从下一级返回 当前界面即将出现 + @override + void didPopNext() { + print("lockSet===didPopNext"); + } + + /// 当前界面进入下一个界面 当前界面即将消失 + @override + void didPushNext() { + print("lockSet===didPushNext"); + } + } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart index e57c619c..4f272e93 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart @@ -6,7 +6,12 @@ import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; class LockSetState { final getKeyInfosData = KeyInfos().obs; + var isAttendance = 1.obs;// 是否开启考勤 + var isLockPickingReminder = 1.obs;// 是否开启开锁提醒 + LockSetState() { getKeyInfosData.value = Get.arguments as KeyInfos; + isAttendance.value = getKeyInfosData.value.isAttendance!; + isLockPickingReminder.value = getKeyInfosData.value.monitorFlag!; } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart index 19462cc6..a44c56fb 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart @@ -1,7 +1,5 @@ - import 'dart:async'; -import 'dart:convert'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 0f770745..668e4c3a 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -417,9 +417,9 @@ class LockDetailLogic extends BaseGetXController{ print("onReady()"); _initReplySubscription(); - // BlueManage().startScan((v){ - // - // }); + BlueManage().startScan((v){ + + }); } @override diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index b5b69cdc..cb1db5ac 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -8,6 +8,7 @@ import '../../../app_settings/app_colors.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_tool/io_manager.dart'; import '../../../blue/io_tool/io_tool.dart'; +import '../../../tools/appRouteObserver.dart'; import '../../../tools/storage.dart'; import '../../../translations/trans_lib.dart'; import '../../lockMian/entity/lockInfoEntity.dart'; @@ -29,7 +30,7 @@ class LockDetailPage extends StatefulWidget { State createState() => _LockDetailPageState(); } -class _LockDetailPageState extends State { +class _LockDetailPageState extends State with RouteAware{ final logic = Get.put(LockDetailLogic()); final state = Get.find().state; @@ -189,10 +190,12 @@ class _LockDetailPageState extends State { var showWidgetArr = []; // 考勤 - showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png', - TranslationLoader.lanKeys!.checkingIn!.tr, () { - Get.toNamed( Routers.checkingInListPage); - })); + if(state.keyInfos.value.isAttendance == 1){ + showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png', + TranslationLoader.lanKeys!.checkingIn!.tr, () { + Get.toNamed(Routers.checkingInListPage, arguments: state.keyInfos.value); + })); + } var defaultWidgetArr = [ // 电子钥匙 @@ -292,4 +295,45 @@ class _LockDetailPageState extends State { )), ); } + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// + @override + void didPush() { + + } + + /// Called when the current route has been popped off. + @override + void didPop() { + + } + + /// Called when the current route has been popped off. + @override + void didPopNext() { + + } + + /// Called when the current route has been popped off. + @override + void didPushNext() { + + } + } diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 8924547d..7738c5fc 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -50,8 +50,16 @@ abstract class Api { final String configPassageModeUrl = '/room/configPassageMode'; // 配置锁的常开模式 final String updateSettingUrl = '/room/updateSetting'; // 锁声音/防撬报警/重置键/考勤 final String roomQueryDateUrl = '/room/queryDate'; // 获取网关时间 + final String lockDiagnoseUrl = '/room/uploadLockInfo'; // 锁诊断 final String getServerDatetimeUrl = '/check/getServerDatetime'; // 获取服务器当前时间 final String getLockVersionInfoUrl = '/room/update'; // 获取锁当前版本信息 + final String openCheckingInURL = '/attendanceCompany/isExistenceCompany'; // 开启考勤获取是否有公司 + final String setCheckInCreateCompanyURL = '/attendanceCompany/add'; // 设置考勤时创建公司 + final String setLockPickingReminderDataURL = '/key/updateMonitorFlag'; // 设置开锁提醒 + + final String getStaffListURL = '/staff/list'; // 获取员工列表 + final String addStaffURL = '/staff/add'; // 添加员工 + final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息 final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表 final String canSendKeyURL = '/keyUser/canSendKey'; //群发钥匙检查 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index a9210ad5..a6aa7b91 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -499,6 +499,29 @@ class ApiProvider extends BaseProvider { 'lockId': lockId, })); + // 锁诊断 + Future setLockDiagnoseData( + String lockId, + String electricQuantity, + String firmwareRevision, + String hardwareRevision, + String lockDate, + String modelNum, + String pwdInfo, + String timestamp) => + post( + lockDiagnoseUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'electricQuantity': electricQuantity, + 'firmwareRevision': firmwareRevision, + 'hardwareRevision': hardwareRevision, + 'lockDate': lockDate, + 'modelNum': modelNum, + 'pwdInfo': pwdInfo, + 'timestamp': timestamp, + })); + // 获取锁版本信息 Future getLockVersionInfoLoadData(String lockId) => post( @@ -506,6 +529,71 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'lockId': lockId,})); + // 开启考勤获取考勤信息 + Future openCheckingInGetData(String lockId) => post( + openCheckingInURL.toUrl, + jsonEncode({ + 'lockId': lockId, + }), + isShowLoading: false + ); + + // 设置考勤时创建公司 + Future setCheckInCreateCompanyData( + String lockId, + String attendanceType, + String companyName, + List workDay, + String workEndTime, + String workStartTime) => post(setCheckInCreateCompanyURL.toUrl, jsonEncode({ + 'lockId': lockId, + 'attendanceType': attendanceType, + 'companyName': companyName, + 'workDay': workDay, + 'workEndTime': workEndTime, + 'workStartTime': workStartTime, + })); + + // 获取开锁提醒 + Future setLockPickingReminderData(String lockId, String keyId, String monitorFlag) => + post( + setLockPickingReminderDataURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyId': keyId, + 'monitorFlag': monitorFlag, + })); + + // 获取员工列表 + Future getStaffListData(String companyId, String lockId) => + post( + getStaffListURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'lockId': lockId, + })); + + // 添加员工 + Future addStaffData( + String attendanceType, + String attendanceWay, + String companyId, + String have, + String staffName, + String countryCode, + String usernameType) => + post( + addStaffURL.toUrl, + jsonEncode({ + 'attendanceType': attendanceType, + 'attendanceWay': attendanceWay, + 'companyId': companyId, + 'have': have, + 'staffName': staffName, + 'countryCode': countryCode, + 'usernameType': usernameType, + })); + Future listLockByGroup(String type, String keyGroupId) => post( listLockByGroupURL.toUrl, jsonEncode({'type': type, 'keyGroupId': keyGroupId})); diff --git a/star_lock/lib/network/api_provider_base.dart b/star_lock/lib/network/api_provider_base.dart index 25157403..13b7ad68 100644 --- a/star_lock/lib/network/api_provider_base.dart +++ b/star_lock/lib/network/api_provider_base.dart @@ -27,8 +27,10 @@ class BaseProvider extends GetConnect with Api { Map? headers, Map? query, Decoder? decoder, - Progress? uploadProgress}) async { + Progress? uploadProgress, + bool? isShowLoading}) async { // print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}"); + if(isShowLoading == true) EasyLoading.show(); print('哈喽请求body体为:${body}'); var res = await super.post(url, body, diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 8d78bc59..76b65986 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -13,6 +13,7 @@ import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; import '../login/register/entity/SendValidationCodeEntity.dart'; import '../main/lockDetail/lcokSet/configuringWifi/configuringWifiEntity.dart'; +import '../main/lockDetail/lcokSet/lockSet/CheckingInInfoDataEntity.dart'; import '../main/lockDetail/lcokSet/lockTime/GetServerDatetimeEntity.dart'; import '../main/lockDetail/lcokSet/normallyOpenMode/GetPassageModeConfigEntity.dart'; import '../main/lockMian/entity/lockInfoEntity.dart'; @@ -499,6 +500,23 @@ class ApiRepository { return GetServerDatetimeEntity.fromJson(res.body); } + // 锁诊断上传数据 + Future setLockDiagnoseData( + { + required String lockId, + required String electricQuantity, + required String firmwareRevision, + required String hardwareRevision, + required String lockDate, + required String modelNum, + required String pwdInfo, + required String timestamp, + }) async { + final res = + await apiProvider.setLockDiagnoseData(lockId, electricQuantity, firmwareRevision, hardwareRevision, lockDate, modelNum, pwdInfo, timestamp); + return LoginEntity.fromJson(res.body); + } + // 获取锁版本信息 Future getLockVersionInfoData( { @@ -535,4 +553,65 @@ class ApiRepository { await apiProvider.canSendKey(endDate, keyGroupIdList, lockIdList); return KeyDetailEntity.fromJson(res.body); } + + // 开启考勤 获取考勤信息 + Future openCheckingInData({required String lockId}) async { + final res = await apiProvider.openCheckingInGetData(lockId); + return CheckingInInfoDataEntity.fromJson(res.body); + } + + // 设置考勤时创建公司 + Future setCheckInCreateCompanyData( + { + required String lockId, + required String attendanceType, + required String companyName, + required List workDay, + required String workEndTime, + required String workStartTime + }) async { + final res = + await apiProvider.setCheckInCreateCompanyData(lockId, attendanceType, companyName, workDay, workEndTime, workStartTime); + return LoginEntity.fromJson(res.body); + } + + // 设置锁开锁提醒 + Future setLockPickingReminderData( + { + required String lockId, + required String keyId, + required String monitorFlag, + }) async { + final res = + await apiProvider.setLockPickingReminderData(lockId, keyId, monitorFlag); + return LoginEntity.fromJson(res.body); + } + + // 获取员工 + Future getStaffListData( + { + required String companyId, + required String lockId, + }) async { + final res = + await apiProvider.getStaffListData(companyId, lockId); + return LoginEntity.fromJson(res.body); + } + + // 添加员工 + Future addStaffData( + { + required String attendanceType, + required String attendanceWay, + required String companyId, + required String have, + required String staffName, + required String countryCode, + required String usernameType, + }) async { + final res = + await apiProvider.addStaffData(attendanceType, attendanceWay, companyId, have, staffName, countryCode, usernameType); + return LoginEntity.fromJson(res.body); + } + } diff --git a/star_lock/lib/network/request_interceptor_log.dart b/star_lock/lib/network/request_interceptor_log.dart index a3f40889..5b5fe430 100644 --- a/star_lock/lib/network/request_interceptor_log.dart +++ b/star_lock/lib/network/request_interceptor_log.dart @@ -7,6 +7,5 @@ FutureOr requestLogInterceptor(Request request) async { Get.log( 'GET HTTP REQUEST \n${request.url} \n${request.headers} ${request.toString()} '); Get.log(request.headers.toString()); - EasyLoading.show(); return request; } diff --git a/star_lock/lib/tools/appRouteObserver.dart b/star_lock/lib/tools/appRouteObserver.dart new file mode 100644 index 00000000..061c6378 --- /dev/null +++ b/star_lock/lib/tools/appRouteObserver.dart @@ -0,0 +1,21 @@ + +import 'package:flutter/material.dart'; + +class AppRouteObserver { + //这是实际上的路由监听器 + static final RouteObserver> _routeObserver = + RouteObserver>(); + //这是个单例 + static final AppRouteObserver _appRouteObserver = + AppRouteObserver._internal(); + + AppRouteObserver._internal() {} + //通过单例的get方法轻松获取路由监听器 + RouteObserver> get routeObserver { + return _routeObserver; + } + + factory AppRouteObserver() { + return _appRouteObserver; + } +} \ No newline at end of file diff --git a/star_lock/lib/tools/showIosTipView.dart b/star_lock/lib/tools/showIosTipView.dart new file mode 100644 index 00000000..72b470f0 --- /dev/null +++ b/star_lock/lib/tools/showIosTipView.dart @@ -0,0 +1,76 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +import '../translations/trans_lib.dart'; + +class ShowIosTipView extends StatelessWidget { + String? title; + String? tipTitle; + Function()? sureClick; + Function()? cancelClick; + + ShowIosTipView( + {Key? key, + this.title, + this.tipTitle, + this.sureClick, + this.cancelClick}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Card( + color: const Color(0x00FFFFFF), + child: Builder( + builder: (context) { + return Theme( + data: ThemeData.light(), + child: CupertinoAlertDialog( + title: Text(title!), + content: Column( + children: [ + const SizedBox( + height: 10, + ), + Column( + children: [ + Text(tipTitle!, style: TextStyle(fontSize: 24.sp)) + ], + ) + ], + ), + actions: [ + CupertinoDialogAction( + child: Text( + TranslationLoader.lanKeys!.cancel!.tr, + style: const TextStyle(color: Colors.black), + ), + onPressed: () { + // Navigator.pop(context); + // print("取消"); + if (cancelClick != null) { + cancelClick!(); + } + }, + ), + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.sure!.tr, + style: const TextStyle(color: Colors.black)), + onPressed: () { + if (sureClick != null) { + sureClick!(); + } + // Navigator.pop(context); + // print("确定"); + }, + ), + ], + ), + ); + } + ), + ); + } +}