diff --git a/star_lock/images/icon_unHaveData.png b/star_lock/images/icon_unHaveData.png index 9ca9b958..d20b493c 100644 Binary files a/star_lock/images/icon_unHaveData.png and b/star_lock/images/icon_unHaveData.png differ diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 472d1f5f..769732d3 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -110,11 +110,13 @@ "dailyCharts":"Daily Charts", "monthlyLeaderboard":"Monthly Leader board", "noAttendanceRecord":"No Attendance Record", + "attendanceRecord":"Attendance Record", "everyoneIsVeryMotivated":"Everyone Is Very Motivated", "workingHoursWereNotReleased":"Working Hours Were Not Released", "beLate":"Be Late", "leaveEarly":"Leave Early", "noCardPunched":"No Card Punched", + "holidayInfo":"Holiday Info", "basicInformation":"Basic Information", "wirelessKeyboard":"Wireless Keyboard", @@ -400,5 +402,7 @@ "configuringWiFi":"Configuring WiFi", "pleaseEnterWifiName":"Please Enter Wifi Name", "wifiPwd":"WiFi password", - "pleaseEnterWifiPwd":"Please Enter WiFi Password" + "pleaseEnterWifiPwd":"Please Enter WiFi Password", + "edit":"Edit", + "stressFingerprint":"Stress Fingerprint" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 9bc856b7..6f9d2f91 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -110,11 +110,13 @@ "dailyCharts":"dailyCharts", "monthlyLeaderboard":"monthlyLeaderboard", "noAttendanceRecord":"noAttendanceRecord", + "attendanceRecord":"attendanceRecord", "everyoneIsVeryMotivated":"everyoneIsVeryMotivated", "workingHoursWereNotReleased":"workingHoursWereNotReleased", "beLate":"beLate", "leaveEarly":"leaveEarly", "noCardPunched":"noCardPunched", + "holidayInfo":"holidayInfo", "basicInformation":"basicInformation", "wirelessKeyboard":"wirelessKeyboard", @@ -400,5 +402,8 @@ "configuringWiFi":"configuringWiFi", "pleaseEnterWifiName":"pleaseEnterWifiName", "wifiPwd":"wifiPwd", - "pleaseEnterWifiPwd":"pleaseEnterWifiPwd" + "pleaseEnterWifiPwd":"pleaseEnterWifiPwd", + "edit":"edit", + "stressFingerprint":"stressFingerprint" + } \ No newline at end of file diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 9a22f24c..a680f955 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -110,11 +110,13 @@ "dailyCharts":"日榜", "monthlyLeaderboard":"月榜", "noAttendanceRecord":"无考勤记录", + "attendanceRecord":"考勤记录", "everyoneIsVeryMotivated":"大家干劲十足", "workingHoursWereNotReleased":"工作时长未出炉", "beLate":"迟到", "leaveEarly":"早退", "noCardPunched":"未打卡", + "holidayInfo":"假日信息", "basicInformation":"基本信息", "wirelessKeyboard":"无线键盘", @@ -403,5 +405,7 @@ "configuringWiFi":"配置WiFi", "pleaseEnterWifiName":"请输入WiFi名字", "wifiPwd":"WiFi名字", - "pleaseEnterWifiPwd":"请输入WiFi密码" + "pleaseEnterWifiPwd":"请输入WiFi密码", + "edit":"编辑", + "stressFingerprint":"胁迫指纹" } \ No newline at end of file diff --git a/star_lock/ios/Podfile b/star_lock/ios/Podfile index 10dd89a0..9ed9ebf9 100644 --- a/star_lock/ios/Podfile +++ b/star_lock/ios/Podfile @@ -35,5 +35,63 @@ end post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) + + # Start of the permission_handler configuration + target.build_configurations.each do |config| + + # You can enable the permissions needed here. For example to enable camera + # permission, just remove the `#` character in front so it looks like this: + # + # ## dart: PermissionGroup.camera + # 'PERMISSION_CAMERA=1' + # + # Preprocessor definitions can be found in: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [ + '$(inherited)', + + ## dart: PermissionGroup.calendar + # 'PERMISSION_EVENTS=1', + + ## dart: PermissionGroup.reminders + # 'PERMISSION_REMINDERS=1', + + ## dart: PermissionGroup.contacts + # 'PERMISSION_CONTACTS=1', + + ## dart: PermissionGroup.camera + # 'PERMISSION_CAMERA=1', + + ## dart: PermissionGroup.microphone + # 'PERMISSION_MICROPHONE=1', + + ## dart: PermissionGroup.speech + # 'PERMISSION_SPEECH_RECOGNIZER=1', + + ## dart: PermissionGroup.photos + # 'PERMISSION_PHOTOS=1', + + ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse] + # 'PERMISSION_LOCATION=1', + + ## dart: PermissionGroup.notification + # 'PERMISSION_NOTIFICATIONS=1', + + ## dart: PermissionGroup.mediaLibrary + # 'PERMISSION_MEDIA_LIBRARY=1', + + ## dart: PermissionGroup.sensors + # 'PERMISSION_SENSORS=1', + + ## dart: PermissionGroup.bluetooth + # 'PERMISSION_BLUETOOTH=1', + + ## dart: PermissionGroup.appTrackingTransparency + # 'PERMISSION_APP_TRACKING_TRANSPARENCY=1', + + ## dart: PermissionGroup.criticalAlerts + # 'PERMISSION_CRITICAL_ALERTS=1' + ] + end + # End of the permission_handler configuration end end diff --git a/star_lock/ios/Podfile.lock b/star_lock/ios/Podfile.lock index bed9bd9a..14a8c1c0 100644 --- a/star_lock/ios/Podfile.lock +++ b/star_lock/ios/Podfile.lock @@ -20,6 +20,9 @@ PODS: - fluttertoast (0.0.2): - Flutter - Toast + - FMDB (2.7.5): + - FMDB/standard (= 2.7.5) + - FMDB/standard (2.7.5) - geocoding_ios (1.0.5): - Flutter - google_maps_flutter_ios (0.0.1): @@ -49,6 +52,9 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS + - sqflite (0.0.3): + - Flutter + - FMDB (>= 2.7.5) - SwiftProtobuf (1.22.0) - Toast (4.0.0) - url_launcher_ios (0.0.1): @@ -71,6 +77,7 @@ DEPENDENCIES: - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - reactive_ble_mobile (from `.symlinks/plugins/reactive_ble_mobile/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) + - sqflite (from `.symlinks/plugins/sqflite/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) SPEC REPOS: @@ -78,6 +85,7 @@ SPEC REPOS: - AMap3DMap - AMapFoundation - AMapLocation + - FMDB - GoogleMaps - Protobuf - SwiftProtobuf @@ -116,6 +124,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/reactive_ble_mobile/ios" shared_preferences_foundation: :path: ".symlinks/plugins/shared_preferences_foundation/darwin" + sqflite: + :path: ".symlinks/plugins/sqflite/ios" url_launcher_ios: :path: ".symlinks/plugins/url_launcher_ios/ios" @@ -130,6 +140,7 @@ SPEC CHECKSUMS: Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907 fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c + FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a geocoding_ios: a389ea40f6f548de6e63006a2e31bf66ff80769a google_maps_flutter_ios: abdac20d6ce8931f6ebc5f46616df241bfaa2cfd GoogleMaps: 025272d5876d3b32604e5c080dc25eaf68764693 @@ -141,10 +152,11 @@ SPEC CHECKSUMS: Protobuf: c6bc59bbab3d38a71c67f62d7cb7ca8f8ea4eca1 reactive_ble_mobile: 9ce6723d37ccf701dbffd202d487f23f5de03b4c shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 + sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a SwiftProtobuf: 40bd808372cb8706108f22d28f8ab4a6b9bc6989 Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 -PODFILE CHECKSUM: 2f695eae20a86ca77f41095e9bd74ba52bd6304c +PODFILE CHECKSUM: 99f32fc524867f7069762a97e548b5edf4ebf43f COCOAPODS: 1.12.1 diff --git a/star_lock/ios/Runner.xcodeproj/project.pbxproj b/star_lock/ios/Runner.xcodeproj/project.pbxproj index 9f133cf6..5ea99da8 100644 --- a/star_lock/ios/Runner.xcodeproj/project.pbxproj +++ b/star_lock/ios/Runner.xcodeproj/project.pbxproj @@ -375,14 +375,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = ZJ29NYHTV5; + DEVELOPMENT_TEAM = 7NLFRKNVY3; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; + PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock123"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; @@ -506,14 +506,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = ZJ29NYHTV5; + DEVELOPMENT_TEAM = 7NLFRKNVY3; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; + PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock123"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; @@ -530,14 +530,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = ZJ29NYHTV5; + DEVELOPMENT_TEAM = 7NLFRKNVY3; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; + PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock123"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; diff --git a/star_lock/ios/Runner/Info.plist b/star_lock/ios/Runner/Info.plist index c9c9e8bf..9300b494 100644 --- a/star_lock/ios/Runner/Info.plist +++ b/star_lock/ios/Runner/Info.plist @@ -24,13 +24,13 @@ ???? CFBundleVersion $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + NSAppTransportSecurity NSAllowsArbitraryLoads - LSRequiresIPhoneOS - NSBluetoothAlwaysUsageDescription The app uses bluetooth to find, connect and transfer data between different devices NSBluetoothPeripheralUsageDescription @@ -39,16 +39,16 @@ 这是你的自拍照 NSContactsUsageDescription Reason we need access to the contact list + NSLocationAlwaysAndWhenInUseUsageDescription + 应用在前台和后台的时候可以搜到更新的位置信息 + NSLocationAlwaysUsageDescription + 应用在后台的时候可以搜到更新的位置信息 + NSLocationWhenInUseUsageDescription + 应用在前台的时候可以搜到更新的位置信息 NSMicrophoneUsageDescription 用于音频插件 NSPhotoLibraryUsageDescription 用于相册 - NSLocationWhenInUseUsageDescription - 应用在前台的时候可以搜到更新的位置信息 - NSLocationAlwaysUsageDescription - 应用在后台的时候可以搜到更新的位置信息 - NSLocationAlwaysAndWhenInUseUsageDescription - 应用在前台和后台的时候可以搜到更新的位置信息 UIApplicationSupportsIndirectInputEvents UIBackgroundModes diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index 7df05e49..230a3d0b 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -1,8 +1,12 @@ + + +import 'package:get/get.dart'; +import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart'; +import 'package:star_lock/login/register/starLock_register_binding.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart'; import 'package:star_lock/login/register/starLock_register_binding.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart'; -import 'package:star_lock/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart'; import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart'; @@ -23,14 +27,17 @@ import 'login/forgetPassword/starLock_forgetPassword_page.dart'; import 'login/login/starLock_login_page.dart'; import 'login/register/starLock_register_page.dart'; import 'login/seletCountryRegion/seletCountryRegion_page.dart'; -import 'main/lockDetail/checkingIn/checkingInAddHolidays/checkingInAddHolidays_page.dart'; import 'main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart'; +import 'main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart'; +import 'main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart'; +import 'main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart'; import 'main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart'; import 'main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart'; -import 'main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_page.dart'; -import 'main/lockDetail/checkingIn/checkingInSetHolidays/checkingInSetHolidays_page.dart'; import 'main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart'; import 'main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart'; +import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart'; +import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart'; +import 'main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart'; import 'main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart'; import 'main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart'; import 'main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_page.dart'; @@ -203,6 +210,7 @@ abstract class Routers { static const checkingInSetPage = '/CheckingInSetPage'; // 考勤设置 static const checkingInStaffManagePage = '/CheckingInStaffManagePage'; // 员工管理 static const checkingInAddStaffPage = '/CheckingInAddStaffPage'; // 添加员工 + static const checkingInStaffDetailPage = '/CheckingInStaffDetailPage'; // 编辑员工 static const checkingInSetWorkTimePage = '/CheckingInSetWorkTimePage'; // 工作时间设置 static const checkingInSetWorkdaySet = '/CheckingInSetWorkdaySet'; // 工作日设置 @@ -210,6 +218,7 @@ abstract class Routers { '/CheckingInSetHolidaysPage'; // 节假日设置 static const checkingInAddHolidaysPage = '/CheckingInAddHolidaysPage'; // 添加假日 static const checkingInDetailPage = '/CheckingInDetailPage'; // 考勤详情 + static const checkingInDeletHolidaysPage = '/CheckingInDeletHolidaysPage'; // 删除考勤 static const mineSetPage = '/MineSetPage'; // 我的设置 static const mineMultiLanguagePage = '/MineMultiLanguagePage'; // 我的设置 @@ -572,6 +581,10 @@ abstract class AppRouters { name: Routers.checkingInAddHolidaysPage, page: () => const CheckingInAddHolidaysPage(), ), + GetPage( + name: Routers.checkingInDeletHolidaysPage, + page: () => const CheckingInDeletHolidaysPage(), + ), GetPage( name: Routers.checkingInDetailPage, page: () => const CheckingInDetailPage(), @@ -757,8 +770,9 @@ abstract class AppRouters { GetPage( name: Routers.lockUserListPage, page: () => const LockUserListPage()), GetPage( - name: Routers.checkInCreatCompanyPage, - page: () => const CheckInCreatCompanyPage()), + name: Routers.checkInCreatCompanyPage, page: () => const CheckInCreatCompanyPage()), + GetPage( + name: Routers.checkingInStaffDetailPage, page: () => const CheckingInStaffDetailPage()), GetPage( name: Routers.administratorDetailsPage, page: () => const AdministratorDetailsPage()), diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 5bb1bd81..d286d403 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -89,18 +89,20 @@ class BlueManage{ } /// 连接监听状态 - Future connect(String deviceMAC, String deviceName, {ConnectStateCallBack? connectStateCallBack, bool? isFrist = false}) async { + Future connect(String deviceMAC, String deviceName, {ConnectStateCallBack? connectStateCallBack, bool? isFrist = false ,bool isShowLoading = true}) async { connectDeviceMacAddress = deviceMAC; connectDeviceName = deviceName; print("connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName"); - EasyLoading.show(); - Future.delayed(const Duration(seconds: 30), () { //asynchronous delay - print("30s之后 菊花没有隐藏的话,强制隐藏菊花"); - if(EasyLoading.isShow){ - EasyLoading.dismiss(); - } - }); + if(isShowLoading){ + EasyLoading.show(); + Future.delayed(const Duration(seconds: 10), () { //asynchronous delay + print("10s之后 菊花没有隐藏的话,强制隐藏菊花"); + if(EasyLoading.isShow){ + EasyLoading.dismiss(); + } + }); + } _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 100000)).listen((connectionStateUpdate) async { // 获取状态 deviceConnectionState = connectionStateUpdate.connectionState; @@ -177,18 +179,20 @@ class BlueManage{ } // 重新连接 - Future judgeReconnect(String deviceMAC, String deviceName, ConnectStateCallBack? connectStateCallBack) async { + Future judgeReconnect(String deviceMAC, String deviceName, ConnectStateCallBack? connectStateCallBack, {bool isShowLoading = true}) async { if(deviceConnectionState == DeviceConnectionState.connected){ - EasyLoading.show(); - Future.delayed(const Duration(seconds: 30), () { //asynchronous delay - print("30s之后 菊花没有隐藏的话,强制隐藏菊花"); - if(EasyLoading.isShow){ - EasyLoading.dismiss(); - } - }); + if(isShowLoading){ + EasyLoading.show(); + Future.delayed(const Duration(seconds: 10), () { //asynchronous delay + print("10s之后 菊花没有隐藏的话,强制隐藏菊花"); + if(EasyLoading.isShow){ + EasyLoading.dismiss(); + } + }); + } connectStateCallBack!(deviceConnectionState!); }else{ - connect(deviceMAC, deviceName, connectStateCallBack: (state){ + connect(deviceMAC, deviceName, isShowLoading: false, connectStateCallBack: (state){ connectStateCallBack!(deviceConnectionState!); }); } diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart new file mode 100644 index 00000000..51e47ff1 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart @@ -0,0 +1,81 @@ +class CheckingInDetailEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + CheckingInDetailEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + CheckingInDetailEntity.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? noPunchTimes; + int? lateTimes; + int? earlyTimes; + List? monthList; + + Data({this.noPunchTimes, this.lateTimes, this.earlyTimes, this.monthList}); + + Data.fromJson(Map json) { + noPunchTimes = json['noPunchTimes']; + lateTimes = json['lateTimes']; + earlyTimes = json['earlyTimes']; + if (json['monthList'] != null) { + monthList = []; + json['monthList'].forEach((v) { + monthList!.add(MonthList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['noPunchTimes'] = noPunchTimes; + data['lateTimes'] = lateTimes; + data['earlyTimes'] = earlyTimes; + if (monthList != null) { + data['monthList'] = monthList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class MonthList { + int? openingTimeStart; + int? openingTimeEnd; + int? colorType; + + MonthList({this.openingTimeStart, this.openingTimeEnd, this.colorType}); + + MonthList.fromJson(Map json) { + openingTimeStart = json['openingTimeStart']; + openingTimeEnd = json['openingTimeEnd']; + colorType = json['colorType']; + } + + Map toJson() { + final Map data = {}; + data['openingTimeStart'] = openingTimeStart; + data['openingTimeEnd'] = openingTimeEnd; + data['colorType'] = colorType; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_logic.dart new file mode 100644 index 00000000..7dbbd897 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_logic.dart @@ -0,0 +1,52 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import 'checkingInDetail_state.dart'; + +typedef BlockLoadSuccssCallback = void Function(); +class CheckingInDetailLogic extends BaseGetXController{ + CheckingInDetailState state = CheckingInDetailState(); + + // 获取考勤详情 + Future getCheckInDetailData(BlockLoadSuccssCallback loadSuccssCallback) async{ + var entity = await ApiRepository.to.getCheckInDetailData( + companyId: state.companyId.value, + attendanceDate:state.checkDate.value.toString(), + staffId: state.staffId.value.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + state.lateTimes.value = entity.data!.lateTimes.toString(); + state.earlyTimes.value = entity.data!.earlyTimes.toString(); + state.noPunchTimes.value = entity.data!.noPunchTimes.toString(); + + state.monthListData.value = entity.data!.monthList!; + loadSuccssCallback(); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + // getCheckInDetailData(); + } + + @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/checkingInDetail/checkingInDetail_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart index 6a0a09d1..cee73291 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'checkingInDetail_logic.dart'; class CheckingInDetailPage extends StatefulWidget { const CheckingInDetailPage({Key? key}) : super(key: key); @@ -14,6 +15,10 @@ class CheckingInDetailPage extends StatefulWidget { } class _CheckingInDetailPageState extends State { + + final logic = Get.put(CheckingInDetailLogic()); + final state = Get.find().state; + int _year = DateTime.now().year; int _month = DateTime.now().month; int _day = DateTime.now().day; @@ -23,46 +28,40 @@ class _CheckingInDetailPageState extends State { @override void initState() { // TODO: implement initState + super.initState(); + //设置默认当前月日期 _setDatas(year: _year, month: _month); - //设置模拟数据,日历月事件,可根据接口返回的结果 - _loadAttendanceMonthRecord("$_year-$_month"); - //日历日事件 - _loadAttendanceDayRecord("$_year-$_month-$_day"); + logic.getCheckInDetailData((){ + //设置模拟数据,日历月事件,可根据接口返回的结果 + _loadAttendanceMonthRecord("$_year-$_month"); + }); - super.initState(); + //设置模拟数据,日历月事件,可根据接口返回的结果 + // _loadAttendanceMonthRecord("$_year-$_month"); + //日历日事件 + // _loadAttendanceDayRecord("$_year-$_month-$_day"); } //加载月历事件,请求接口 _loadAttendanceMonthRecord(String dateTime) async { - CalendarModel bean1 = - CalendarModel(year: _year, month: _month, day: 1, workType: "2"); - CalendarModel bean2 = - CalendarModel(year: _year, month: _month, day: 2, workType: "1"); - CalendarModel bean3 = - CalendarModel(year: _year, month: _month, day: 3, workType: "2"); - CalendarModel bean4 = - CalendarModel(year: _year, month: _month, day: 4, workType: "0"); - CalendarModel bean5 = - CalendarModel(year: _year, month: _month, day: 5, workType: "0"); - CalendarModel bean6 = - CalendarModel(year: _year, month: _month, day: 6, workType: "1"); - _listDatas.add(bean1); - _listDatas.add(bean2); - _listDatas.add(bean3); - _listDatas.add(bean4); - _listDatas.add(bean5); - _listDatas.add(bean6); + // print("_datas.length:${_datas.length} state.monthListData:${state.monthListData.length}"); + // 显示的上个月的天数 + var placeholderDays = _getPlaceholderDays(year: _year, month: _month); + // 当月多少天 + var currentMonthDays = _getCurrentMonthDays(year: _year, month: _month); + // var changeList = _datas.sublist(placeholderDays, placeholderDays + currentMonthDays); + // print("_datas.length:${_datas.length} placeholderDays:$placeholderDays currentMonthDays:$currentMonthDays"); setState(() { + // 因为_datas这个月上个月都包含的都有 遍历把本月的赋值 for (int i = 0; i < _datas.length; i++) { - for (int j = 0; j < _listDatas.length; j++) { - if (_datas[i].year == _listDatas[j].year && - _datas[i].month == _listDatas[j].month && - _datas[i].day == _listDatas[j].day) { - _datas[i].workType = _listDatas[j].workType; - } + // 因为i从0开始 所以i>=上个月的天数 且小于上个月跟本月天数之和 + if((i >= placeholderDays) && (i < (placeholderDays + currentMonthDays))){ + // print("i:$i placeholderDays:$placeholderDays currentMonthDays:$currentMonthDays state.monthListData.length:${state.monthListData.length}"); + _datas[i].workType = state.monthListData[i-placeholderDays].colorType.toString(); + // print("_datas[i].workType:${_datas[i].workType} i:$i"); } } }); @@ -72,6 +71,12 @@ class _CheckingInDetailPageState extends State { _loadAttendanceDayRecord(String dateTime) async { //可根据接口返回的内容在日历下面打卡信息或者其余内容 print("点击的是$dateTime"); + state.checkDate.value = DateTime.parse(dateTime).millisecondsSinceEpoch; + print("点击的是$dateTime state.checkDate.value:${state.checkDate.value}"); + logic.getCheckInDetailData((){ + //设置模拟数据,日历月事件,可根据接口返回的结果 + _loadAttendanceMonthRecord("$_year-$_month"); + }); } @override @@ -123,35 +128,18 @@ class _CheckingInDetailPageState extends State { }, child: Container( // margin: EdgeInsets.only(left: 20.w), - child: Image( - width: 30.w, - height: 30.w, - image: const AssetImage("images/icon_left_black.png"), - ), + child: Image(width: 50.w, height: 30.w, image: const AssetImage("images/icon_left_black.png"),), ), ), - SizedBox( - width: 60.w, - ), - Text("$_year-$_month", - style: TextStyle( - fontSize: 28.sp, - color: Colors.black, - fontWeight: FontWeight.w500)), - SizedBox( - width: 60.w, - ), + SizedBox(width: 60.w,), + Text("$_year-$_month", style: TextStyle(fontSize: 28.sp, color: Colors.black, fontWeight: FontWeight.w500)), + SizedBox(width: 60.w), GestureDetector( onTap: () { _nextMonth(); }, child: Container( - // margin: EdgeInsets.only(right: 20.sp), - child: Image( - width: 30.w, - height: 30.w, - image: const AssetImage("images/icon_right_black.png"), - ), + child: Image(width: 50.w, height: 30.w, image: const AssetImage("images/icon_right_black.png")), ), ), ], @@ -220,29 +208,42 @@ class _CheckingInDetailPageState extends State { //子组件宽高长度比例 childAspectRatio: 1), itemBuilder: (context, index) { + // print("_datas[index].workType:${_datas[index].workType}"); + Color backColor = Colors.white; + // Color textColor = const Color(0xFFFFFFFF); + if(_datas[index].workType == "1"){ + backColor = const Color(0xFFE83523); + // textColor = Colors.white; + }else if( _datas[index].workType == "2"){ + backColor = const Color(0xFFEDB459); + // textColor = Colors.white; + }else if( _datas[index].workType == "3"){ + backColor = const Color(0xFF666666); + // textColor = Colors.white; + } return GestureDetector( onTap: () { - setState(() { - if (_datas[index].month == _month) { - //判断点击的是否是当月日期,只对当前月点击的日期做处理 - for (int i = 0; i < _datas.length; i++) { - if (i == index) { - //切换至选中的日期 - _day = _datas[i].day!; - _datas[i].isSelect = true; - - //加载选中的日期事件 - _loadAttendanceDayRecord( - "${_datas[i].year}-${_datas[i].month}-${_datas[i].day}"); - } else { - _datas[i].isSelect = false; - } - } - } else { - //不是当月的不做处理 - // _datas[index].is_select=false; - } - }); + // setState(() { + // if (_datas[index].month == _month) { + // //判断点击的是否是当月日期,只对当前月点击的日期做处理 + // for (int i = 0; i < _datas.length; i++) { + // if (i == index) { + // //切换至选中的日期 + // _day = _datas[i].day!; + // _datas[i].isSelect = true; + // + // //加载选中的日期事件 + // _loadAttendanceDayRecord( + // "${_datas[i].year}-${_datas[i].month}-${_datas[i].day}"); + // } else { + // _datas[i].isSelect = false; + // } + // } + // } else { + // //不是当月的不做处理 + // // _datas[index].is_select=false; + // } + // }); }, child: Container( child: Column( @@ -251,12 +252,10 @@ class _CheckingInDetailPageState extends State { width: 40.w, height: 40.w, //设置底部背景 - decoration: _datas[index].isSelect! - ? const BoxDecoration( - color: Color(0xFF2C91F6), - shape: BoxShape.circle, - ) - : const BoxDecoration(), + decoration: BoxDecoration( + color: backColor, + shape: BoxShape.circle, + ), child: Center( child: Text( //不是当前月不显示值 @@ -265,7 +264,7 @@ class _CheckingInDetailPageState extends State { : "", textAlign: TextAlign.center, //设置选中字体颜色,以及周末和工作日颜色 - style: _datas[index].isSelect! + style: (int.parse(_datas[index].workType!) > 0) ? TextStyle( fontSize: 24.sp, color: const Color(0xFFFFFFFF)) : (index % 7 == 5 || index % 7 == 6 @@ -280,19 +279,19 @@ class _CheckingInDetailPageState extends State { ), const SizedBox(height: 5), //设置底部小圆点,非当前月的不显示,设置为透明,其余的根据状态判断显示 - _datas[index].month == _month && - _datas[index].workType != "" && - _datas[index].workType != "0" - ? Container( - height: 6.0, - width: 6.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: _datas[index].workType == "1" - ? const Color(0xFFF48835) - : const Color(0xFF2C91F6)), - ) - : Container(), + // _datas[index].month == _month && + // _datas[index].workType != "" && + // _datas[index].workType != "0" + // ? Container( + // height: 6.0, + // width: 6.0, + // decoration: BoxDecoration( + // shape: BoxShape.circle, + // color: _datas[index].workType == "1" + // ? const Color(0xFFF48835) + // : const Color(0xFF2C91F6)), + // ) + // : Container(), ], ), ), @@ -322,9 +321,9 @@ class _CheckingInDetailPageState extends State { ), ], ), - _bottomStatisticsItemWidget(Colors.red, "迟到", "0"), - _bottomStatisticsItemWidget(Colors.orange, "早退", "0"), - _bottomStatisticsItemWidget(Colors.grey, "未打卡", "0"), + _bottomStatisticsItemWidget(const Color(0xFFE83523), "迟到", state.lateTimes.value), + _bottomStatisticsItemWidget(const Color(0xFFEDB459), "早退", state.earlyTimes.value), + _bottomStatisticsItemWidget(const Color(0xFF666666), "未打卡", state.noPunchTimes.value), ], ); } @@ -374,9 +373,9 @@ class _CheckingInDetailPageState extends State { // 获取行数 int _getRowsForMonthYear({int? year, int? month}) { - //当前月天数 + // 当前月天数 var currentMonthDays = _getCurrentMonthDays(year: year, month: month); - // + // 这个月1号前面有几天 var placeholderDays = _getPlaceholderDays(year: year, month: month); int rows = (currentMonthDays + placeholderDays) ~/ 7; @@ -434,7 +433,7 @@ class _CheckingInDetailPageState extends State { month: lastMonth, day: firstDay + i + 1, isSelect: false, - workType: "")); + workType: "0")); } /// 本月显示 @@ -446,14 +445,14 @@ class _CheckingInDetailPageState extends State { month: month, day: i + 1, isSelect: true, - workType: "")); + workType: "0")); } else { _datas.add(CalendarModel( year: year, month: month, day: i + 1, isSelect: false, - workType: "")); + workType: "0")); } } @@ -472,7 +471,7 @@ class _CheckingInDetailPageState extends State { month: nextMonth, day: i + 1, isSelect: false, - workType: "")); + workType: "0")); } } @@ -489,9 +488,9 @@ class _CheckingInDetailPageState extends State { _datas.clear(); _setDatas(year: _year, month: _month); //更新月历事件 - _loadAttendanceMonthRecord("$_year-$_month"); + // _loadAttendanceMonthRecord("$_year-$_month"); //更新日事件 - _loadAttendanceDayRecord("$_year-$_month-$_day"); + _loadAttendanceDayRecord("$_year-${_month.toString().padLeft(2,'0')}-${_day.toString().padLeft(2,'0')}"); }); } @@ -533,7 +532,8 @@ class _CheckingInDetailPageState extends State { //更新月历事件 _loadAttendanceMonthRecord("$_year-$_month"); //更新日事件 - _loadAttendanceDayRecord("$_year-$_month-$_day"); + // _loadAttendanceDayRecord("$_year-$_month-$_day"); + _loadAttendanceDayRecord("$_year-${_month.toString().padLeft(2,'0')}-${_day.toString().padLeft(2,'0')}"); }); } } @@ -543,7 +543,7 @@ class CalendarModel { int? year; int? month; int? day; - String? workType = ""; //日期事件,0,休息,1,异常,2,正常 + String? workType = ""; //日期事件,0休息,1迟到,2早退,3未打卡 bool? isSelect = false; CalendarModel( diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_state.dart new file mode 100644 index 00000000..9451c293 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_state.dart @@ -0,0 +1,26 @@ + +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; +import 'checkingInDetail_entity.dart'; + +class CheckingInDetailState{ + + final getKeyInfosData = KeyInfos().obs; + final companyId = "".obs; + final staffId = 0.obs; + + final checkDate = DateTime.now().millisecondsSinceEpoch.obs; + + var lateTimes = "".obs;// 迟到 + var earlyTimes = "".obs;// 早退 + var noPunchTimes = "".obs;// 未打车 + final monthListData = [].obs; + CheckingInDetailState() { + Map map = Get.arguments; + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; + staffId.value = map["staffId"]; + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_logic.dart new file mode 100644 index 00000000..bca27b16 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_logic.dart @@ -0,0 +1,55 @@ + + +import 'package:date_format/date_format.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; +import '../../../../../network/api_repository.dart'; +import 'checkingInAddHolidays_state.dart'; + +class CheckingInAddHolidaysLogic extends BaseGetXController{ + CheckingInAddHolidaysState state = CheckingInAddHolidaysState(); + + // 添加假期 + void editStaffLoadData() async{ + if(state.staffNameController.text.isEmpty){ + Toast.show(msg: "请输入姓名"); + return; + } + + var entity = await ApiRepository.to.addHolidaysData( + companyId: state.companyId.value, + fillClassDate: state.makeUpWorkDate.value.isNotEmpty ? DateTime.parse(state.makeUpWorkDate.value).millisecondsSinceEpoch.toString() : "", + vacationEndDate: DateTime.parse(state.endDate.value).millisecondsSinceEpoch.toString(), + vacationName: state.staffNameController.text, + vacationStartDate: DateTime.parse(state.beginDate.value).millisecondsSinceEpoch.toString() + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "添加成功"); + Get.back(result: "addScuess"); + } + } + + @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/checkingInAddHolidays/checkingInAddHolidays_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart similarity index 70% rename from star_lock/lib/main/lockDetail/checkingIn/checkingInAddHolidays/checkingInAddHolidays_page.dart rename to star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart index dfc511e8..e88f95e0 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInAddHolidays/checkingInAddHolidays_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart @@ -1,13 +1,15 @@ +import 'package:date_format/date_format.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/commonItem.dart'; -import '../../../../tools/showCalendar.dart'; -import '../../../../tools/submitBtn.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/commonItem.dart'; +import '../../../../../tools/showCalendar.dart'; +import '../../../../../tools/submitBtn.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import 'checkingInAddHolidays_logic.dart'; class CheckingInAddHolidaysPage extends StatefulWidget { const CheckingInAddHolidaysPage({Key? key}) : super(key: key); @@ -18,6 +20,9 @@ class CheckingInAddHolidaysPage extends StatefulWidget { } class _CheckingInAddHolidaysPageState extends State { + final logic = Get.put(CheckingInAddHolidaysLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -35,9 +40,9 @@ class _CheckingInAddHolidaysPageState extends State { isHaveRightWidget: true, rightWidget: getTFWidget( "(${TranslationLoader.lanKeys!.mustFillIn!.tr})")), - CommonItem( + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.startDate!.tr, - rightTitle: "(${TranslationLoader.lanKeys!.mustFillIn!.tr})", + rightTitle: state.beginDate.value.isEmpty ? "(${TranslationLoader.lanKeys!.mustFillIn!.tr})" : state.beginDate.value, isHaveLine: true, isHaveDirection: false, action: () async { @@ -47,14 +52,16 @@ class _CheckingInAddHolidaysPageState extends State { return ShowCalendar( datePickerMode: DatePickerMode.day, seletAction: (dateTime) { - print("111111$dateTime"); - Navigator.of(context).pop(true); + String beginDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]); + state.beginDate.value = beginDate; + Get.back(); + // Navigator.of(context).pop(true); }); }); - }), - CommonItem( + })), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.endDate!.tr, - rightTitle: "(${TranslationLoader.lanKeys!.mustFillIn!.tr})", + rightTitle: state.endDate.value.isEmpty ? "(${TranslationLoader.lanKeys!.mustFillIn!.tr})" : state.endDate.value, isHaveLine: true, isHaveDirection: false, action: () async { @@ -64,13 +71,15 @@ class _CheckingInAddHolidaysPageState extends State { return ShowCalendar( datePickerMode: DatePickerMode.day, seletAction: (dateTime) { - Navigator.of(context).pop(true); + String endDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]); + state.endDate.value = endDate; + Get.back(); }); }); - }), - CommonItem( + })), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.coverDate!.tr, - rightTitle: "", + rightTitle: state.makeUpWorkDate.value, isHaveLine: false, isHaveDirection: false, action: () async { @@ -80,10 +89,12 @@ class _CheckingInAddHolidaysPageState extends State { return ShowCalendar( datePickerMode: DatePickerMode.day, seletAction: (dateTime) { - Navigator.of(context).pop(true); + String makeUpWorkDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]); + state.makeUpWorkDate.value = makeUpWorkDate; + Get.back(); }); }); - }), + })), SizedBox( height: 50.w, ), @@ -92,7 +103,9 @@ class _CheckingInAddHolidaysPageState extends State { borderRadius: 20.w, margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () {}), + onClick: () { + logic.editStaffLoadData(); + }), ], ), ); @@ -109,7 +122,7 @@ class _CheckingInAddHolidaysPageState extends State { child: TextField( //输入框一行 maxLines: 1, - // controller: _controller, + controller: state.staffNameController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart similarity index 54% rename from star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_state.dart rename to star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart index 4f4546f4..d9fbfbe9 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_state.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart @@ -1,18 +1,19 @@ + import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import '../../../lockMian/entity/lockInfoEntity.dart'; - -class CheckingInAddStaffState{ - final getKeyInfosData = KeyInfos().obs; - final companyId = "".obs; - +class CheckingInAddHolidaysState{ final TextEditingController staffNameController = TextEditingController(); - CheckingInAddStaffState() { + final companyId = "".obs; + final beginDate = "".obs; + final endDate = "".obs; + final makeUpWorkDate = "".obs; + + CheckingInAddHolidaysState() { 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/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_logic.dart new file mode 100644 index 00000000..1ade72e0 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_logic.dart @@ -0,0 +1,22 @@ + +import 'package:get/get.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../../network/api_repository.dart'; +import '../../../../../tools/toast.dart'; +import 'checkingInDeletHolidays_state.dart'; + +class CheckingInDeletHolidaysLogic extends BaseGetXController{ + CheckingInDeletHolidaysState state = CheckingInDeletHolidaysState(); + + // 删除假期 + void deletStaffLoadData() async{ + var entity = await ApiRepository.to.deletHolidaysData( + vacationId: state.listItem.value.vacationId.toString() + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "删除成功"); + Get.back(result: "deletScuess"); + } + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart new file mode 100644 index 00000000..6fad2d16 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart @@ -0,0 +1,76 @@ + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/commonItem.dart'; +import '../../../../../tools/dateTool.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import 'checkingInDeletHolidays_logic.dart'; + +class CheckingInDeletHolidaysPage extends StatefulWidget { + const CheckingInDeletHolidaysPage({Key? key}) : super(key: key); + + @override + State createState() => _CheckingInDeletHolidaysPageState(); +} + +class _CheckingInDeletHolidaysPageState extends State { + final logic = Get.put(CheckingInDeletHolidaysLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.holidayInfo!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + child: Text( + TranslationLoader.lanKeys!.delete!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: () { + logic.deletStaffLoadData(); + }, + ), + // GestureDetector( + // onTap: () async { + // logic.deletStaffLoadData(); + // }, + // child: Image.asset( + // 'images/icon_add_white.png', + // width: 36.w, + // height: 36.w, + // )), + // SizedBox( + // width: 30.w, + // ), + ],), + body: Obx(() => Column( + children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.name!.tr, + rightTitle: state.listItem.value.vacationName, + isHaveLine: true), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.startDate!.tr, + rightTitle: DateTool().dateToYMDString(state.listItem.value.vacationStartDate.toString()), + isHaveLine: true), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.endDate!.tr, + rightTitle: DateTool().dateToYMDString(state.listItem.value.vacationEndDate.toString()), + isHaveLine: true), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.coverDate!.tr, + rightTitle: (state.listItem.value.fillClassDate!.isNotEmpty) ? DateTool().dateToYMDString(state.listItem.value.fillClassDate.toString()) : "", + isHaveLine: true), + ], + ))); + } +} diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_state.dart new file mode 100644 index 00000000..d380556c --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_state.dart @@ -0,0 +1,12 @@ + +import 'package:get/get.dart'; +import '../checkingInSetHolidays/checkingInSetHolidays_entity.dart'; + +class CheckingInDeletHolidaysState{ + final listItem = ListItem().obs; + + CheckingInDeletHolidaysState() { + Map map = Get.arguments; + listItem.value = map["listItem"]; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_entity.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_entity.dart new file mode 100644 index 00000000..7ec08c84 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_entity.dart @@ -0,0 +1,111 @@ +class CheckingInSetHolidaysInfoDataEntity { + int? errorCode; + String? description; + String? errorMsg; + HolidaysListData? data; + + CheckingInSetHolidaysInfoDataEntity({this.errorCode, this.description, this.errorMsg, this.data}); + + CheckingInSetHolidaysInfoDataEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? HolidaysListData.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 HolidaysListData { + List? holidayList; + + HolidaysListData({this.holidayList}); + + HolidaysListData.fromJson(Map json) { + if (json['list'] != null) { + holidayList = []; + json['list'].forEach((v) { + holidayList!.add(HolidaysMonthListData.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + if (holidayList != null) { + data['list'] = holidayList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class HolidaysMonthListData { + List? listItem; + + HolidaysMonthListData({this.listItem}); + + HolidaysMonthListData.fromJson(List json) { + listItem = []; + for (var v in json) { + listItem!.add(ListItem.fromJson(v)); + } + } + + Map toJson() { + final Map data = {}; + if (listItem != null) { + data['listItem'] = listItem!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ListItem { + int? vacationEndDate; + String? vacationName; + int? vacationStartDate; + int? vacationYear; + String? fillClassDate; + int? month; + int? vacationId; + + ListItem( + {this.vacationEndDate, + this.vacationName, + this.vacationStartDate, + this.vacationYear, + this.fillClassDate, + this.month, + this.vacationId}); + + ListItem.fromJson(Map json) { + vacationEndDate = json['vacationEndDate']; + vacationName = json['vacationName']; + vacationStartDate = json['vacationStartDate']; + vacationYear = json['vacationYear']; + fillClassDate = json['fillClassDate']; + month = json['month']; + vacationId = json['vacationId']; + } + + Map toJson() { + final Map data = {}; + data['vacationEndDate'] = vacationEndDate; + data['vacationName'] = vacationName; + data['vacationStartDate'] = vacationStartDate; + data['vacationYear'] = vacationYear; + data['fillClassDate'] = fillClassDate; + data['month'] = month; + data['vacationId'] = vacationId; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_logic.dart new file mode 100644 index 00000000..7c506e68 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_logic.dart @@ -0,0 +1,45 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../../network/api_repository.dart'; +import 'checkingInSetHolidays_state.dart'; + +class CheckingInSetHolidaysLogic extends BaseGetXController{ + CheckingInSetHolidaysState state = CheckingInSetHolidaysState(); + + // 获取员工列表 + void editStaffLoadData() async{ + var entity = await ApiRepository.to.holidaysListData( + companyId: state.companyId.value, + vacationYear: state.seletYear.value.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + state.holidaysListData.value = entity.data!.holidayList!; + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + editStaffLoadData(); + } + + @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/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart new file mode 100644 index 00000000..3b6480e2 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart @@ -0,0 +1,291 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_pickers/pickers.dart'; +import 'package:flutter_pickers/style/default_style.dart'; +import 'package:flutter_pickers/style/picker_style.dart'; +import 'package:flutter_pickers/time_picker/model/date_mode.dart'; +import 'package:flutter_pickers/time_picker/model/pduration.dart'; +import 'package:flutter_pickers/time_picker/model/suffix.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/tools/noData.dart'; + +import '../../../../../appRouters.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/dateTool.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import 'checkingInSetHolidays_entity.dart'; +import 'checkingInSetHolidays_logic.dart'; + +class CheckingInSetHolidaysPage extends StatefulWidget { + const CheckingInSetHolidaysPage({Key? key}) : super(key: key); + + @override + State createState() => + _CheckingInSetHolidaysPageState(); +} + +class _CheckingInSetHolidaysPageState extends State { + final logic = Get.put(CheckingInSetHolidaysLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + haveTitleWidget: true, + titleWidget: titleWidget(), + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + GestureDetector( + onTap: () async { + var data = await Get.toNamed(Routers.checkingInAddHolidaysPage, arguments: { + "companyId": state.companyId.value + }); + if(data != null) { + logic.editStaffLoadData(); + } + }, + child: Image.asset( + 'images/icon_add_white.png', + width: 36.w, + height: 36.w, + )), + SizedBox( + width: 30.w, + ), + ], + ), + body: Obx(() { + return state.holidaysListData.value!.isNotEmpty ? ListView.builder( + itemCount: state.holidaysListData.value!.length, + itemBuilder: (c, index) { + HolidaysMonthListData holidaysMonthListData = state.holidaysListData.value![index]; + return _checkingInListMouthItem(holidaysMonthListData); + }):const NoData(); + }) + ); + } + + Widget _checkingInListMouthItem(HolidaysMonthListData holidaysMonthListData) { + return GestureDetector( + child: Container( + height: 140.h*holidaysMonthListData.listItem!.length + 20.w, + padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), + child: Row( + children: [ + Container( + color: colorWithMonth(int.parse(holidaysMonthListData.listItem![0].month.toString())), + width: 100.w, + height: 140.h*holidaysMonthListData.listItem!.length, + child: Center( + child: Text( + "${holidaysMonthListData.listItem![0].month}\n${TranslationLoader.lanKeys!.month!.tr}", + textAlign: TextAlign.center, + style: TextStyle(fontSize: 28.sp, color: Colors.white), + ))), + SizedBox( + height: 140.h*holidaysMonthListData.listItem!.length, + width: 1.sw - 100.w - 20.w*2, + child: ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: holidaysMonthListData.listItem!.length, + itemBuilder: (c, index) { + ListItem listItem = holidaysMonthListData.listItem![index]; + return _checkingInListItem(index, listItem.vacationName, DateTool().dateToYMDString(listItem.vacationStartDate.toString()), DateTool().dateToYMDString(listItem.vacationEndDate.toString()), listItem.fillClassDate!.isNotEmpty ? DateTool().dateToYMDString(listItem.fillClassDate.toString()):"", () async { + var data = await Get.toNamed(Routers.checkingInDeletHolidaysPage, arguments: { + "listItem": listItem + }); + if(data != null) { + logic.editStaffLoadData(); + } + }); + }), + ), + ], + ), + ), + ); + } + + Widget _checkingInListItem(int index, String? lockTypeTitle, String? vacationStartDate, String? vacationEndDate, String? makeUpClass, Function() action) { + return GestureDetector( + onTap: action, + child: Column( + children: [ + Container( + color:Colors.white, + height: 140.h, + padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h), + child: Row( + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + lockTypeTitle!, + style: TextStyle(fontSize: 24.sp), + ), + ], + ), + SizedBox(height: 10.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "${TranslationLoader.lanKeys!.libertyDay!.tr}:$vacationStartDate - $vacationEndDate", + style: TextStyle(fontSize: 20.sp), + ), + ], + ), + SizedBox(height: 5.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "${TranslationLoader.lanKeys!.coverDate!.tr}:$makeUpClass", + style: TextStyle(fontSize: 20.sp), + ), + ], + ), + ], + ), + ), + SizedBox(width: 20.h), + ], + ), + ), + Container(color: AppColors.mainBackgroundColor, height: 1.h) + ], + ), + ); + } + + Widget titleWidget() { + return GestureDetector( + onTap: () { + showListType(); + }, + child: Obx(() => Container( + width: 300.w, + height: 50.h, + color: AppColors.mainColor, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "${state.seletYear.value}${TranslationLoader.lanKeys!.year!.tr}", + style: TextStyle(color: Colors.white, fontSize: 26.sp), + ), + SizedBox( + width: 5.w, + ), + Image.asset( + 'images/main/icon_lockDetail_checkIn_topTitle.png', + width: 22.w, + height: 16.w, + ) + ], + ), + )), + ); + } + + void showListType() { + Pickers.showDatePicker( + context, + // 模式,详见下方 + mode: DateMode.Y, + // 后缀 默认Suffix.normal(),为空的话Suffix() + suffix: Suffix(years: ' 年'), + // 样式 详见下方样式 + pickerStyle: PickerStyle( + cancelButton: GestureDetector( + onTap: () { + Get.back(); + }, + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(left: 22, right: 12), + child: Text(TranslationLoader.lanKeys!.cancel!.tr, + style: const TextStyle(color: Colors.black, fontSize: 16.0)), + ), + ), + commitButton: GestureDetector( + onTap: () { + Get.back(); + }, + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(left: 22, right: 12), + child: Text(TranslationLoader.lanKeys!.sure!.tr, + style: const TextStyle(color: Colors.black, fontSize: 16.0)), + ), + ), + ), + // 默认选中 + selectDate: PDuration(year: 2023), + minDate: PDuration(year: 1900), + maxDate: PDuration(year: 2100), + onConfirm: (p) { + state.seletYear.value = p.year!; + logic.editStaffLoadData(); + print("longer >>> 返回数据:${p.year}"); + }, + ); + } + + Color colorWithMonth(int month){ + Color colorType; + switch (month){ + case 1: + colorType = const Color(0xFFb8d152); + break; + case 2: + colorType = const Color(0xFF8bb639); + break; + case 3: + colorType = const Color(0xFF5fb15a); + break; + case 4: + colorType = const Color(0xFFeeb582); + break; + case 5: + colorType = const Color(0xFFf3b749); + break; + case 6: + colorType = const Color(0xFFe4893c); + break; + case 7: + colorType = const Color(0xFFafb5d7); + break; + case 8: + colorType = const Color(0xFF9a95b2); + break; + case 9: + colorType = const Color(0xFF585da6); + break; + case 10: + colorType = const Color(0xFFe696a9); + break; + case 11: + colorType = const Color(0xFFb9706c); + break; + case 12: + colorType = const Color(0xFFc8474e); + break; + default: + colorType = const Color(0xFF333333); + break; + } + // print("colorType:$colorType"); + return colorType; + } +} diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart new file mode 100644 index 00000000..5356c435 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart @@ -0,0 +1,18 @@ + + +import 'package:get/get.dart'; + +import 'checkingInSetHolidays_entity.dart'; + +class CheckingInSetHolidaysState{ + final companyId = "".obs; + final mouth = "".obs; + final seletYear = DateTime.now().year.obs; + final holidaysListData = [].obs; + + CheckingInSetHolidaysState() { + Map map = Get.arguments; + companyId.value = map["companyId"]; + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart new file mode 100644 index 00000000..9bfbaaaa --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart @@ -0,0 +1,109 @@ +class CheckingInListDayEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + CheckingInListDayEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + CheckingInListDayEntity.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? noPunchTimes; + int? lateTimes; + int? earlyTimes; + List? attendanceRecordList; + + Data( + {this.noPunchTimes, + this.lateTimes, + this.earlyTimes, + this.attendanceRecordList}); + + Data.fromJson(Map json) { + noPunchTimes = json['noPunchTimes']; + lateTimes = json['lateTimes']; + earlyTimes = json['earlyTimes']; + if (json['attendanceRecordList'] != null) { + attendanceRecordList = []; + json['attendanceRecordList'].forEach((v) { + attendanceRecordList!.add(AttendanceRecordDayList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['noPunchTimes'] = noPunchTimes; + data['lateTimes'] = lateTimes; + data['earlyTimes'] = earlyTimes; + if (attendanceRecordList != null) { + data['attendanceRecordList'] = + attendanceRecordList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class AttendanceRecordDayList { + String? headurl; + int? isSelf; + String? staffName; + int? staffId; + int? attendanceType; + int? openingTimeEnd; + int? openingTimeStart; + int? colorType; + + AttendanceRecordDayList( + {this.headurl, + this.isSelf, + this.staffName, + this.staffId, + this.attendanceType, + this.openingTimeEnd, + this.openingTimeStart, + this.colorType}); + + AttendanceRecordDayList.fromJson(Map json) { + headurl = json['headurl']; + isSelf = json['isSelf']; + staffName = json['staffName']; + staffId = json['staffId']; + attendanceType = json['attendanceType']; + openingTimeEnd = json['openingTimeEnd']; + openingTimeStart = json['openingTimeStart']; + colorType = json['colorType']; + } + + Map toJson() { + final Map data = {}; + data['headurl'] = headurl; + data['isSelf'] = isSelf; + data['staffName'] = staffName; + data['staffId'] = staffId; + data['attendanceType'] = attendanceType; + data['openingTimeEnd'] = openingTimeEnd; + data['openingTimeStart'] = openingTimeStart; + data['colorType'] = colorType; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart new file mode 100644 index 00000000..859c5002 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart @@ -0,0 +1,81 @@ +class CheckingInListMonthEntity { + int? errorCode; + String? description; + String? errorMsg; + List? data; + + CheckingInListMonthEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + CheckingInListMonthEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] != null) { + data = []; + json['data'].forEach((v) { + data!.add(AttendanceRecordMonthList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class AttendanceRecordMonthList { + String? headurl; + int? isSelf; + String? staffName; + int? staffId; + int? attendanceType; + String? countryCode; + int? openingTimeStart; + String? attendanceWay; + int? avgTime; + + AttendanceRecordMonthList( + {this.headurl, + this.isSelf, + this.staffName, + this.staffId, + this.attendanceType, + this.countryCode, + this.openingTimeStart, + this.attendanceWay, + this.avgTime}); + + AttendanceRecordMonthList.fromJson(Map json) { + headurl = json['headurl']; + isSelf = json['isSelf']; + staffName = json['staffName']; + staffId = json['staffId']; + attendanceType = json['attendanceType']; + countryCode = json['countryCode']; + openingTimeStart = json['openingTimeStart']; + attendanceWay = json['attendanceWay']; + avgTime = json['avgTime']; + } + + Map toJson() { + final Map data = {}; + data['headurl'] = headurl; + data['isSelf'] = isSelf; + data['staffName'] = staffName; + data['staffId'] = staffId; + data['attendanceType'] = attendanceType; + data['countryCode'] = countryCode; + data['openingTimeStart'] = openingTimeStart; + data['attendanceWay'] = attendanceWay; + data['avgTime'] = avgTime; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart index 01915d42..30c0e197 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart @@ -1,5 +1,6 @@ +import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../network/api_repository.dart'; import 'checkingInList_state.dart'; @@ -14,6 +15,88 @@ class CheckingInListLogic extends BaseGetXController{ ); if(entity.errorCode!.codeIsSuccessful){ state.companyId.value = entity.data!.companyId.toString(); + getCheckInListEarlyArrivalWithDateData(); + } + } + + void loadDataByType(){ + if(state.isDay.value == true && (state.listType.value == "1")){ + // 早到日榜 + getCheckInListEarlyArrivalWithDateData(); + }else if(state.isDay.value == false && (state.listType.value == "1")){ + // 早到月榜 + getCheckInListEarlyArrivalWithMonthData(); + }else if(state.isDay.value == true && (state.listType.value == "2")){ + // 迟到日榜 + getCheckInListLateTimesWithDateData(); + }else if(state.isDay.value == false && (state.listType.value == "2")){ + // 迟到月榜 + getCheckInListLateTimesWithMonthData(); + }else { + // 勤奋榜 + getCheckInListHardworkingData(); + } + } + + // 获取考勤信息列表--早到榜(按日期查询) + void getCheckInListEarlyArrivalWithDateData() async{ + var entity = await ApiRepository.to.getCheckInListEarlyArrivalWithDateData( + companyId: state.companyId.value, + attendanceDate:state.checkListDateTimestamp.value.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + state.lateTimes.value = entity.data!.lateTimes.toString(); + state.earlyTimes.value = entity.data!.earlyTimes.toString(); + state.noPunchTimes.value = entity.data!.noPunchTimes.toString(); + state.checkingInDayListData.value = entity.data!.attendanceRecordList!; + } + } + + // 获取考勤信息列表--早到榜(按月榜查询) + void getCheckInListEarlyArrivalWithMonthData() async{ + var entity = await ApiRepository.to.getCheckInListEarlyArrivalWithMonthData( + companyId: state.companyId.value, + attendanceDate:state.checkListDateTimestamp.value.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + state.checkingInMonthListData.value = entity.data!; + } + } + + // 获取考勤信息列表--迟到榜(按日期查询) + void getCheckInListLateTimesWithDateData() async{ + var entity = await ApiRepository.to.getCheckInListLateTimesWithDateData( + companyId: state.companyId.value, + attendanceDate:state.checkListDateTimestamp.value.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + state.lateTimes.value = entity.data!.lateTimes.toString(); + state.earlyTimes.value = entity.data!.earlyTimes.toString(); + state.noPunchTimes.value = entity.data!.noPunchTimes.toString(); + state.checkingInDayListData.value = entity.data!.attendanceRecordList!; + } + } + + // 获取考勤信息列表--迟到榜(按月榜查询) + void getCheckInListLateTimesWithMonthData() async{ + var entity = await ApiRepository.to.getCheckInListLateTimesWithMonthData( + companyId: state.companyId.value, + attendanceDate:state.checkListDateTimestamp.value.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + state.checkingInMonthListData.value = entity.data!; + } + } + + // 获取考勤信息列表--勤奋榜(按月榜查询) + void getCheckInListHardworkingData() async{ + var entity = await ApiRepository.to.getCheckInListHardworkingData( + companyId: state.companyId.value, + attendanceDate:state.checkListDateTimestamp.value.toString(), + type: state.isDay.value == true ? "1" : "2", + ); + if(entity.errorCode!.codeIsSuccessful){ + state.checkingInMonthListData.value = entity.data!; } } 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 ce9921a5..ca8c11f2 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart @@ -1,13 +1,17 @@ +import 'package:date_format/date_format.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/noData.dart'; import '../../../../tools/showBottomSheetTool.dart'; import '../../../../tools/showCalendar.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'checkingInListDay_entity.dart'; import 'checkingInList_logic.dart'; class CheckingInListPage extends StatefulWidget { @@ -35,27 +39,18 @@ class _CheckingInListPageState extends State { onTap: () { Get.toNamed(Routers.checkingInSetPage, arguments: { "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value }); }, - child: Image.asset( - 'images/main/icon_lockDetail_checkIn_set.png', - width: 36.w, - height: 36.w, - )), - SizedBox( - width: 30.w, - ), + child: Image.asset('images/main/icon_lockDetail_checkIn_set.png', width: 36.w, height: 36.w,)), + SizedBox(width: 30.w), ], ), body: Column( children: [ topInfo(), - SizedBox( - height: 10.h, - ), + SizedBox(height: 10.h), middleDayInfo(), - Expanded(child: bottomList()) + Expanded(child: getBottomList()) ], ), ); @@ -68,60 +63,74 @@ class _CheckingInListPageState extends State { color: Colors.white, child: Column( children: [ - SizedBox( - height: 30.h, - ), - Image.asset('images/main/icon_checkInRankingListTop.png', - width: 120.w, height: 120.w), - SizedBox( - height: 10.h, - ), - Text(TranslationLoader.lanKeys!.noAttendanceRecord!.tr, - style: TextStyle(fontSize: 24.sp)), - SizedBox( - height: 30.h, - ), + SizedBox(height: 30.h), + Image.asset('images/main/icon_checkInRankingListTop.png', width: 120.w, height: 120.w), + SizedBox(height: 10.h), + Text(TranslationLoader.lanKeys!.noAttendanceRecord!.tr, style: TextStyle(fontSize: 24.sp)), + SizedBox(height: 30.h), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // SizedBox(width: 30.w,), Row( children: [ - SizedBox( - width: 40.w, - ), - Container( - // width: 150.w, - height: 70.h, - // color: Colors.red, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text(TranslationLoader.lanKeys!.dailyCharts!.tr, - style: TextStyle( - color: AppColors.mainColor, fontSize: 22.sp)), - Container( - width: 20.w, - height: 2.h, - color: AppColors.mainColor) - ], + SizedBox(width: 20.w,), + GestureDetector( + onTap: (){ + setState(() { + setState(() { + state.isDay.value = true; + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(state.checkListDateTimestamp.value); + String beginDate = formatDate(dateTime, [mm,'-',dd]); + state.checkListDate.value = beginDate; + logic.loadDataByType(); + }); + }); + }, + child: Container( + width: 90.w, + height: 70.h, + color: Colors.white, + child: Obx(() => Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text(TranslationLoader.lanKeys!.dailyCharts!.tr, style: TextStyle(color: state.isDay.value ? AppColors.mainColor : Colors.black, fontSize: 22.sp)), + Visibility( + visible: state.isDay.value, + child: Container( + width: 20.w, + height: 2.h, + color: state.isDay.value ? AppColors.mainColor : Colors.black + ), + ) + ], + )), ), ), - SizedBox( - width: 40.w, - ), - SizedBox( - // width: 100.w, - height: 70.h, - // color: Colors.red, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text(TranslationLoader.lanKeys!.monthlyLeaderboard!.tr, - style: TextStyle( - color: Colors.black, fontSize: 22.sp)), - Container(width: 20.w, height: 2.h, color: Colors.black) - ], + // SizedBox(width: 20.w,), + GestureDetector( + onTap: (){ + setState(() { + state.isDay.value = false; + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(state.checkListDateTimestamp.value); + String beginDate = formatDate(dateTime, [mm]); + state.checkListDate.value = beginDate; + logic.loadDataByType(); + }); + }, + child: Container( + width: 90.w, + height: 70.h, + color: Colors.white, + child: Obx(() => Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text(TranslationLoader.lanKeys!.monthlyLeaderboard!.tr, style: TextStyle(color: !state.isDay.value ? AppColors.mainColor : Colors.black, fontSize: 22.sp)), + Visibility( + visible: !state.isDay.value, + child: Container(width: 20.w, height: 2.h, color: !state.isDay.value ? AppColors.mainColor : Colors.black)) + ], + )), ), ), ], @@ -134,25 +143,22 @@ class _CheckingInListPageState extends State { return ShowCalendar( datePickerMode: DatePickerMode.day, seletAction: (dateTime) { - Navigator.of(context).pop(true); + setState(() { + state.checkListDateTimestamp.value = dateTime.millisecondsSinceEpoch; + String beginDate = formatDate(dateTime, state.isDay.value ? [mm,'-',dd] : [mm]); + state.checkListDate.value = beginDate; + logic.loadDataByType(); + Get.back(); + }); }); }); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - "07-12", - style: TextStyle(color: Colors.black, fontSize: 22.sp), - ), - Image.asset( - 'images/icon_grayPullDown.png', - width: 50.w, - height: 30.w, - ), - SizedBox( - width: 10.w, - ), + Text(state.checkListDate.value, style: TextStyle(color: Colors.black, fontSize: 22.sp),), + Image.asset('images/icon_grayPullDown.png', width: 50.w, height: 30.w,), + SizedBox(width: 10.w,), ], ), ) @@ -165,8 +171,8 @@ class _CheckingInListPageState extends State { } Widget middleDayInfo() { - return Visibility( - visible: true, + return Obx(() => Visibility( + visible: state.isDay.value, child: Container( height: 80.h, color: Colors.white, @@ -177,71 +183,83 @@ class _CheckingInListPageState extends State { Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - SizedBox( - height: 5.h, - ), - Text("0", - style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.beLate!.tr, - style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox( - height: 5.h, - ), + SizedBox(height: 5.h), + Text(state.lateTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.beLate!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), ], ), Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - SizedBox( - height: 5.h, - ), - Text("0", - style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.leaveEarly!.tr, - style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox( - height: 5.h, - ), + SizedBox(height: 5.h), + Text(state.earlyTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.leaveEarly!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), ], ), Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - SizedBox( - height: 5.h, - ), - Text("0", - style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.noCardPunched!.tr, - style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox( - height: 5.h, - ), + SizedBox(height: 5.h), + Text(state.noPunchTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.noCardPunched!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), ], ), ], ), ), - ); + )); } - Widget bottomList() { - return ListView.separated( - itemCount: 10, + Widget getBottomList(){ + if((state.isDay.value == true && (state.listType.value == "1")) || (state.isDay.value == true && (state.listType.value == "2"))){ + return bottomDayList(); + }else{ + return bottomMonthList(); + } + } + + Widget bottomDayList() { + return Obx(() => state.checkingInDayListData.value.isNotEmpty ? ListView.separated( + itemCount: state.checkingInDayListData.value.length, itemBuilder: (c, index) { - return _checkingInListItem('images/controls_user.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { - Navigator.pushNamed(context, Routers.checkingInDetailPage); + AttendanceRecordDayList attendanceRecordList= state.checkingInDayListData.value[index]; + return _checkingInListItem(index, attendanceRecordList.headurl, attendanceRecordList.staffName,() { + Get.toNamed(Routers.checkingInDetailPage, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value, + "staffId": attendanceRecordList.staffId, + }); + }); + }, + separatorBuilder: (context, index) { + return const Divider(height: 1, color: AppColors.greyLineColor); + }, + ) :const NoData()); + } + + Widget bottomMonthList() { + return Obx(() => state.checkingInMonthListData.value.isNotEmpty ? ListView.separated( + itemCount: state.checkingInMonthListData.value.length, + itemBuilder: (c, index) { + AttendanceRecordMonthList attendanceRecordList= state.checkingInMonthListData.value[index]; + return _checkingInListItem(index, attendanceRecordList.headurl, attendanceRecordList.staffName, () { + Get.toNamed(Routers.checkingInDetailPage, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value, + "staffId": attendanceRecordList.staffId, + }); }); }, separatorBuilder: (context, index) { return const Divider(height: 1, color: AppColors.greyLineColor); }, - ); + ) :const NoData()); } - Widget _checkingInListItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { + Widget _checkingInListItem(int index, String? headUrl, String? name, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -253,21 +271,10 @@ class _CheckingInListPageState extends State { ), child: Row( children: [ - SizedBox( - width: 30.w, - ), - Text( - "1", - style: TextStyle(fontSize: 20.sp), - ), - SizedBox( - width: 20.w, - ), - Image.asset( - 'images/controls_user.png', - width: 40.w, - height: 40.w, - ), + SizedBox(width: 30.w,), + Text("1", style: TextStyle(fontSize: 20.sp),), + SizedBox(width: 20.w,), + Image.asset('images/controls_user.png', width: 40.w, height: 40.w,), // Container( // width: 60.h, // height: 60.h, @@ -283,21 +290,12 @@ class _CheckingInListPageState extends State { // height: 30.w, // color: Colors.white, // )), - SizedBox( - width: 20.w, - ), + SizedBox(width: 20.w), Expanded( - child: Text( - lockTypeTitle, - style: TextStyle(fontSize: 24.sp), - ), + child: Text(name!, style: TextStyle(fontSize: 24.sp),), ), SizedBox(width: 20.h), - Image.asset( - "images/icon_right_grey.png", - width: 21.w, - height: 21.w, - ), + Image.asset("images/icon_right_grey.png", width: 21.w, height: 21.w,), SizedBox(width: 20.h), ], ), @@ -310,24 +308,19 @@ class _CheckingInListPageState extends State { onTap: () { showListType(); }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - TranslationLoader.lanKeys!.earlyArrivalList!.tr, - style: TextStyle(color: Colors.white, fontSize: 26.sp), - ), - SizedBox( - width: 5.w, - ), - Image.asset( - 'images/main/icon_lockDetail_checkIn_topTitle.png', - width: 22.w, - height: 16.w, - fit: BoxFit.fill, - ) - ], - ), + child: Obx(() => Container( + width: 200.w, + height: 60.h, + color: AppColors.mainColor, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(state.listTypeStr.value, style: TextStyle(color: Colors.white, fontSize: 26.sp),), + SizedBox(width: 5.w,), + Image.asset('images/main/icon_lockDetail_checkIn_topTitle.png', width: 22.w, height: 16.w, fit: BoxFit.fill,) + ], + ), + )), ); } @@ -350,6 +343,19 @@ class _CheckingInListPageState extends State { //adapter: PickerAdapter(), data: list, //选择事件的回调 - clickCallBack: (int index, var str) {}); + clickCallBack: (int index, var str) { + setState(() { + state.listTypeStr.value = str.toString(); + state.isDay.value = true; + if(index == 0){ + state.listType.value = "1"; + }else if(index == 1){ + state.listType.value = "2"; + }else if(index == 2){ + state.listType.value = "3"; + } + logic.loadDataByType(); + }); + }); } } diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart index b421ae73..badbede3 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart @@ -1,14 +1,31 @@ +import 'package:date_format/date_format.dart'; import 'package:get/get.dart'; +import '../../../../translations/trans_lib.dart'; import '../../../lockMian/entity/lockInfoEntity.dart'; +import 'checkingInListDay_entity.dart'; +import 'checkingInListMonth_entity.dart'; class CheckingInListState{ final getKeyInfosData = KeyInfos().obs; final companyId = "".obs; + final listType = "1".obs;// 1早到榜 2迟到榜 3勤奋榜 + final listTypeStr = TranslationLoader.lanKeys!.earlyArrivalList!.tr.obs;// 1早到榜 2迟到榜 3勤奋榜 + final isDay = true.obs;// 日榜还是月榜 + final checkListDateTimestamp = DateTime.now().millisecondsSinceEpoch.obs;// 查询日期时间戳 + final checkListDate = formatDate(DateTime.now(), [mm,'-',dd]).obs;// 查询日期 + + final checkingInDayListData = [].obs; + final checkingInMonthListData = [].obs; + + var lateTimes = "".obs;// 迟到 + var earlyTimes = "".obs;// 早退 + var noPunchTimes = "".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_entity.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart new file mode 100644 index 00000000..5ff3067f --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart @@ -0,0 +1,69 @@ + +class CheckingInSetEntity { + int? errorCode; + String? description; + String? errorMsg; + CheckingInSetInfo? data; + + CheckingInSetEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + CheckingInSetEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? CheckingInSetInfo.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 CheckingInSetInfo { + int? staffNum; + int? workEndTime; + int? attendanceType; + int? companyId; + String? companyName; + int? workStartTime; + List? workDay; + + CheckingInSetInfo( + {this.staffNum, + this.workEndTime, + this.attendanceType, + this.companyId, + this.companyName, + this.workStartTime, + this.workDay}); + + CheckingInSetInfo.fromJson(Map json) { + staffNum = json['staffNum']; + workEndTime = json['workEndTime']; + attendanceType = json['attendanceType']; + companyId = json['companyId']; + companyName = json['companyName']; + workStartTime = json['workStartTime']; + workDay = json['workDay'].cast(); + } + + Map toJson() { + final Map data = {}; + data['staffNum'] = staffNum; + data['workEndTime'] = workEndTime; + data['attendanceType'] = attendanceType; + data['companyId'] = companyId; + data['companyName'] = companyName; + data['workStartTime'] = workStartTime; + data['workDay'] = workDay; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart index 28898c8b..ae72c6a9 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart @@ -1,9 +1,93 @@ +import 'package:get/get.dart'; + +import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; +import '../../../../tools/dateTool.dart'; +import '../../../../tools/toast.dart'; import 'checkingInSet_state.dart'; class CheckingInSetLogic extends BaseGetXController{ CheckingInSetState state = CheckingInSetState(); + // 开启考勤获取是否有公司 + 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(); + getCheckInSetInfoData(); + } + } + // 获取获取考勤设置信息 + void getCheckInSetInfoData() async{ + var entity = await ApiRepository.to.getCheckInSetInfoData( + companyId: state.companyId.value, + ); + if(entity.errorCode!.codeIsSuccessful){ + state.checkingInSetInfo.value = entity.data!; + + state.beginTime.value = DateTool().dateToHNString(state.checkingInSetInfo.value.workStartTime.toString()); + state.endTime.value = DateTool().dateToHNString(state.checkingInSetInfo.value.workEndTime.toString()); + state.beginTimeTimestamp.value = state.checkingInSetInfo.value.workStartTime.toString(); + state.endTimeTimestamp.value = state.checkingInSetInfo.value.workEndTime.toString(); + + state.weekDays.value = state.checkingInSetInfo.value.workDay!; + state.weekDaysStr.value = state.weekDays.value.join(","); + + state.staffNumber.value = state.checkingInSetInfo.value.staffNum!.toString(); + state.companyName.value = state.checkingInSetInfo.value.companyName!; + state.changeNameController.text = state.companyName.value; + } + } + + // 编辑考勤设置信息 + void editCheckInSetInfoData() async{ + var entity = await ApiRepository.to.editCheckInSetInfoData( + attendanceType: state.checkingInSetInfo.value.attendanceType.toString(), + companyId: state.checkingInSetInfo.value.companyId.toString(), + type: "1", + companyName: state.changeNameController.text, + workEndTime: state.checkingInSetInfo.value.workEndTime.toString(), + workStartTime: state.checkingInSetInfo.value.workStartTime.toString(), + workDay:state.checkingInSetInfo.value.workDay!, + ); + if(entity.errorCode!.codeIsSuccessful){ + state.companyName.value = state.changeNameController.text; + print("state.checkingInSetInfo.value.companyName:${state.checkingInSetInfo.value.companyName}"); + Toast.show(msg: "修改成功"); + } + } + + // late StreamSubscription _teamEvent; + // void _initLoadDataAction() { + // _teamEvent = eventBus.on().listen((event) { + // getStaffList(); + // }); + // } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + // _initLoadDataAction(); + openCheckingInData(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + } + + @override + void onClose() { + // TODO: implement onClose + // _teamEvent.cancel(); + } } \ 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 4d4ea511..cd76e01a 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/tools/toast.dart'; import '../../../../appRouters.dart'; import '../../../../tools/commonItem.dart'; @@ -22,8 +23,6 @@ class _CheckingInSetPageState extends State { final logic = Get.put(CheckingInSetLogic()); final state = Get.find().state; - final TextEditingController _changeNameController = TextEditingController(); - @override Widget build(BuildContext context) { return Scaffold( @@ -35,18 +34,18 @@ class _CheckingInSetPageState extends State { backgroundColor: AppColors.mainColor), body: Column( children: [ - CommonItem( + Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.company!.tr}${TranslationLoader.lanKeys!.name!.tr}", - rightTitle: "深圳市志超科技", + "${TranslationLoader.lanKeys!.company!.tr}${TranslationLoader.lanKeys!.name!.tr}", + rightTitle: state.companyName.value ?? "", isHaveLine: true, isHaveDirection: true, action: () { showCupertinoAlertDialog(context); - }), - CommonItem( + })), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.staff!.tr, - rightTitle: "0", + rightTitle: state.staffNumber.value, isHaveLine: true, isHaveDirection: true, action: () { @@ -54,32 +53,61 @@ class _CheckingInSetPageState extends State { "getKeyInfosData": state.getKeyInfosData.value, "companyId": state.companyId.value }); - }), - CommonItem( + })), + Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.work!.tr}${TranslationLoader.lanKeys!.time!.tr}", - rightTitle: "9:00 - 18:00", + "${TranslationLoader.lanKeys!.work!.tr}${TranslationLoader.lanKeys!.time!.tr}", + rightTitle: (state.beginTime.value.isNotEmpty) ? "${state.beginTime.value} - ${state.endTime.value}" : "", isHaveLine: true, isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.checkingInSetWorkTimePage); - }), - CommonItem( + action: () async { + var data = await Get.toNamed(Routers.checkingInSetWorkTimePage, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value, + "pushType": "2", + "checkingInSetInfo": state.checkingInSetInfo.value, + }); + if(data != null) { + setState(() { + // state.beginTime.value = data["beginTime"]; + // state.endTime.value = data["endTime"]; + // state.beginTimeTimestamp.value = data["beginTimeTimestamp"]; + // state.endTimeTimestamp.value = data["endTimeTimestamp"]; + logic.getCheckInSetInfoData(); + }); + } + })), + Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.workday!.tr}${TranslationLoader.lanKeys!.set!.tr}", - rightTitle: "1,2,3,4,5", + "${TranslationLoader.lanKeys!.workday!.tr}${TranslationLoader.lanKeys!.set!.tr}", + rightTitle: state.weekDaysStr.value, isHaveLine: true, isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.checkingInSetWorkdaySet); - }), + action: () async { + var data = await Get.toNamed(Routers.checkingInSetWorkdaySet, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value, + "pushType": "2", + "checkingInSetInfo": state.checkingInSetInfo.value, + }); + if(data != null) { + setState(() { + // state.isCustom.value = data["attendanceType"]; + // state.weekDays.value = data["weekDays"]; + // state.weekDaysStr.value = state.weekDays.value.join(","); + logic.getCheckInSetInfoData(); + }); + } + })), CommonItem( leftTitel: TranslationLoader.lanKeys!.holidays!.tr, rightTitle: "", isHaveLine: false, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.checkingInSetHolidaysPage); + Get.toNamed(Routers.checkingInSetHolidaysPage, arguments: { + "companyId": state.companyId.value + }); }), SizedBox( height: 30.h, @@ -103,14 +131,19 @@ class _CheckingInSetPageState extends State { context: context, builder: (BuildContext context) { return ShowTFView( - title: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", + title: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.company!.tr}", tipTitle: "", - controller: _changeNameController, + controller: state.changeNameController, sureClick: () { - + if(state.changeNameController.text.isEmpty){ + Toast.show(msg: "请输入公司姓名"); + return; + } + Get.back(); + logic.editCheckInSetInfoData(); }, cancelClick: () { - Navigator.pop(context); + Get.back(); },); }); } diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart index e4e37428..8af65e4c 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart @@ -1,15 +1,32 @@ +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../lockMian/entity/lockInfoEntity.dart'; +import 'checkingInSet_entity.dart'; class CheckingInSetState{ final getKeyInfosData = KeyInfos().obs; final companyId = "".obs; + var isCustom = true.obs; + + var weekDays = [].obs;// 工作天数 + var weekDaysStr = "".obs;// 拼接显示的字符串天数 + + var beginTime = "".obs;// 开始时间 + var endTime = "".obs;// 结束时间 + var beginTimeTimestamp = "".obs;// 开始时间时间戳 + var endTimeTimestamp = "".obs;// 结束时间时间戳 + + var staffNumber = "".obs;// 员工数量 + var companyName = "".obs;// 公司名称 + + final TextEditingController changeNameController = TextEditingController(); + + final checkingInSetInfo = CheckingInSetInfo().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 deleted file mode 100644 index e9bde8f1..00000000 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_logic.dart +++ /dev/null @@ -1,47 +0,0 @@ - -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/checkingInSetHolidays/checkingInSetHolidays_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetHolidays/checkingInSetHolidays_page.dart deleted file mode 100644 index 6e752337..00000000 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetHolidays/checkingInSetHolidays_page.dart +++ /dev/null @@ -1,218 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_pickers/pickers.dart'; -import 'package:flutter_pickers/style/default_style.dart'; -import 'package:flutter_pickers/style/picker_style.dart'; -import 'package:flutter_pickers/time_picker/model/date_mode.dart'; -import 'package:flutter_pickers/time_picker/model/pduration.dart'; -import 'package:flutter_pickers/time_picker/model/suffix.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../appRouters.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/showBottomSheetTool.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; - -class CheckingInSetHolidaysPage extends StatefulWidget { - const CheckingInSetHolidaysPage({Key? key}) : super(key: key); - - @override - State createState() => - _CheckingInSetHolidaysPageState(); -} - -class _CheckingInSetHolidaysPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - haveTitleWidget: true, - titleWidget: titleWidget(), - haveBack: true, - backgroundColor: AppColors.mainColor, - actionsList: [ - GestureDetector( - onTap: () { - Navigator.pushNamed( - context, Routers.checkingInAddHolidaysPage); - }, - child: Image.asset( - 'images/icon_add_white.png', - width: 36.w, - height: 36.w, - )), - SizedBox( - width: 30.w, - ), - ], - ), - body: ListView.builder( - itemCount: 10, - itemBuilder: (c, index) { - return _checkingInListItem('images/icon_lock.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { - // Navigator.pushNamed(context, Routers.electronicKeyDetailPage); - }); - })); - } - - Widget _checkingInListItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { - return GestureDetector( - onTap: action, - child: Container( - height: 140.h, - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10.w), - ), - child: Row( - children: [ - Container( - color: const Color(0xFFAFB5D7), - width: 100.w, - height: 140.h, - child: Center( - child: Text( - "7\n${TranslationLoader.lanKeys!.month!.tr}", - textAlign: TextAlign.center, - style: TextStyle(fontSize: 28.sp, color: Colors.white), - ))), - SizedBox( - width: 20.w, - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - // color: Colors.red, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - lockTypeTitle, - style: TextStyle(fontSize: 24.sp), - ), - ], - ), - ), - SizedBox(height: 10.h), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - "${TranslationLoader.lanKeys!.libertyDay!.tr}:2023.6.21 11.15-2023.6.21 11.15", - style: TextStyle(fontSize: 20.sp), - ), - ], - ), - ), - SizedBox(height: 5.h), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - "${TranslationLoader.lanKeys!.coverDate!.tr}:2023.6.21 11.15", - style: TextStyle(fontSize: 20.sp), - ), - ], - ), - ), - ], - ), - ), - SizedBox(width: 20.h), - ], - ), - ), - ); - } - - Widget titleWidget() { - return GestureDetector( - onTap: () { - showListType(); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "${DateTime.now().year}${TranslationLoader.lanKeys!.year!.tr}", - style: TextStyle(color: Colors.white, fontSize: 26.sp), - ), - SizedBox( - width: 5.w, - ), - Image.asset( - 'images/main/icon_lockDetail_checkIn_topTitle.png', - width: 22.w, - height: 16.w, - ) - ], - ), - ); - } - - void showListType() { - Pickers.showDatePicker( - context, - // 模式,详见下方 - mode: DateMode.Y, - // 后缀 默认Suffix.normal(),为空的话Suffix() - suffix: Suffix(years: ' 年'), - // 样式 详见下方样式 - pickerStyle: PickerStyle( - cancelButton: GestureDetector( - onTap: () {}, - child: Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 22, right: 12), - child: Text(TranslationLoader.lanKeys!.cancel!.tr, - style: const TextStyle(color: Colors.black, fontSize: 16.0)), - ), - ), - commitButton: GestureDetector( - onTap: () {}, - child: Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 22, right: 12), - child: Text(TranslationLoader.lanKeys!.sure!.tr, - style: const TextStyle(color: Colors.black, fontSize: 16.0)), - ), - ), - ), - // 默认选中 - selectDate: PDuration(year: 2023), - minDate: PDuration(year: 1900), - maxDate: PDuration(year: 2100), - onConfirm: (p) { - print('longer >>> 返回数据:$p'); - }, - // onChanged: (p) => print(p), - ); - // var list = [TranslationLoader.lanKeys.earlyArrivalList.tr, TranslationLoader.lanKeys.lateList.tr, TranslationLoader.lanKeys.hardWorkingList.tr]; - // ShowBottomSheetTool().showSingleRowPicker( - // //上下文 - // context, - // //默认的索引 - // normalIndex: 0, - // title: "", - // cancelTitle: TranslationLoader.lanKeys.cancel.tr, - // sureTitle: TranslationLoader.lanKeys.sure.tr, - // //要显示的列表 - // //可自定义数据适配器 - // //adapter: PickerAdapter(), - // data: list, - // //选择事件的回调 - // clickCallBack: (int index, var str) { - // - // } - // ); - } -} diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart deleted file mode 100644 index dd1ada47..00000000 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart +++ /dev/null @@ -1,117 +0,0 @@ -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/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; -import 'checkingInStaffList_logic.dart'; - -class CheckingInStaffListPage extends StatefulWidget { - const CheckingInStaffListPage({Key? key}) : super(key: key); - - @override - State createState() => - _CheckingInStaffListPageState(); -} - -class _CheckingInStaffListPageState extends State { - final logic = Get.put(CheckingInStaffManageLogic()); - final state = Get.find().state; - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.greyBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.staff!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - actionsList: [ - GestureDetector( - onTap: () { - Navigator.pushNamed(context, Routers.checkingInAddStaffPage, - arguments: { - "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value - }); - }, - child: Image.asset( - 'images/icon_add_white.png', - width: 36.w, - height: 36.w, - )), - SizedBox( - width: 30.w, - ), - ], - ), - body: Container( - color: Colors.white, - child: ListView.separated( - itemCount: 10, - itemBuilder: (c, index) { - return _checkingInStaffManageItem('images/icon_lock.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { - // Navigator.pushNamed(context, Routers.electronicKeyDetailPage); - }); - }, - separatorBuilder: (context, index) { - return const Divider( - height: 1, indent: 20, color: AppColors.greyLineColor); - }, - ), - )); - } - - Widget _checkingInStaffManageItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { - return GestureDetector( - onTap: action, - child: Container( - height: 60.h, - margin: - EdgeInsets.only(left: 10.w, right: 10.w, top: 10.h, bottom: 10.h), - // decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: BorderRadius.circular(10.w), - // ), - child: Row( - children: [ - SizedBox( - width: 30.w, - ), - Image.asset( - 'images/controls_user.png', - width: 40.w, - height: 40.w, - ), - // Container( - // width: 60.h, - // height: 60.h, - // decoration: BoxDecoration( - // color: AppColors.mainColor, - // border: Border.all(width: 1, color: AppColors.mainColor), - // borderRadius: BorderRadius.circular(30.h), - // ), - // padding: EdgeInsets.all(10.w), - // child: Image.asset( - // 'images/controls_user.png', - // width: 40.w, - // height: 40.w, - // color: Colors.white, - // )), - SizedBox( - width: 30.w, - ), - Text( - lockTypeTitle, - style: TextStyle(fontSize: 24.sp), - ), - ], - ), - ), - ); - } -} diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart index c558ce5f..01ea5ccf 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart @@ -1,9 +1,29 @@ +import 'package:get/get.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/toast.dart'; import 'checkingInSetWorkTime_state.dart'; class CheckingInSetWorkTimeLogic extends BaseGetXController{ CheckingInSetWorkTimeState state = CheckingInSetWorkTimeState(); + // 编辑考勤设置信息 + void editCheckInSetInfoData() async{ + var entity = await ApiRepository.to.editCheckInSetInfoData( + attendanceType: state.checkingInSetInfo.value.attendanceType.toString(), + companyId: state.checkingInSetInfo.value.companyId.toString(), + type: "2", + companyName: state.checkingInSetInfo.value.companyName ?? "", + workEndTime: state.endTimeTimestamp.value.toString(), + workStartTime: state.beginTimeTimestamp.value.toString(), + workDay:state.checkingInSetInfo.value.workDay!, + ); + if(entity.errorCode!.codeIsSuccessful){ + Get.back(result: "scuess"); + // Toast.show(msg: "修改成功"); + } + } + } \ 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 33fcaa7b..d6801b82 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart @@ -64,16 +64,30 @@ 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(state.beginTimeTimestamp.value.isEmpty){ + Toast.show(msg: "请选择开始时间"); + return; + } + + if(state.endTimeTimestamp.value.isEmpty){ + Toast.show(msg: "请选择结束时间"); + return; + } + 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, - }); + if(state.pushType.value == "2"){ + logic.editCheckInSetInfoData(); + }else{ + 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 index eb5c80df..29c639a9 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart @@ -1,10 +1,33 @@ import 'package:get/get.dart'; +import '../../../../tools/dateTool.dart'; +import '../../../lockMian/entity/lockInfoEntity.dart'; +import '../checkingInSet/checkingInSet_entity.dart'; + class CheckingInSetWorkTimeState{ + final getKeyInfosData = KeyInfos().obs; + final checkingInSetInfo = CheckingInSetInfo().obs; + final companyId = "".obs; + var beginTime = "".obs;// 开始时间 var endTime = "".obs;// 结束时间 var beginTimeTimestamp = "".obs;// 开始时间时间戳 var endTimeTimestamp = "".obs;// 结束时间时间戳 + var pushType = "".obs;// 2考勤设置信息选择时间 + + CheckingInSetWorkTimeState() { + Map map = Get.arguments; + pushType.value = map["pushType"]; + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; + checkingInSetInfo.value = map["checkingInSetInfo"]; + + beginTime.value = DateTool().dateToHNString(checkingInSetInfo.value.workStartTime.toString()); + endTime.value = DateTool().dateToHNString(checkingInSetInfo.value.workEndTime.toString()); + beginTimeTimestamp.value = checkingInSetInfo.value.workStartTime.toString(); + endTimeTimestamp.value = checkingInSetInfo.value.workEndTime.toString(); + } + } \ 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 index af0fccba..7cdf017c 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart @@ -1,9 +1,65 @@ +import 'package:get/get.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; import 'checkingInSetWorkdaySet_state.dart'; class CheckingInSetWorkdaySetLogic extends BaseGetXController{ CheckingInSetWorkdaySetState state = CheckingInSetWorkdaySetState(); + // 编辑考勤设置信息 + void editCheckInSetInfoData() async{ + var entity = await ApiRepository.to.editCheckInSetInfoData( + attendanceType: (state.isCustom.value == true) ? "0" : "1", + companyId: state.checkingInSetInfo.value.companyId.toString(), + type: "2", + companyName: state.checkingInSetInfo.value.companyName ?? "", + workEndTime: state.checkingInSetInfo.value.workEndTime.toString(), + workStartTime: state.checkingInSetInfo.value.workStartTime.toString(), + workDay:state.weekDays.value, + ); + if(entity.errorCode!.codeIsSuccessful){ + Get.back(result: "scuess"); + // Toast.show(msg: "修改成功"); + } + } + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + Map map = Get.arguments; + state.pushType.value = map["pushType"]; + if(state.pushType.value == "2"){ + state.getKeyInfosData.value = map["getKeyInfosData"]; + state.companyId.value = map["companyId"]; + state.checkingInSetInfo.value = map["checkingInSetInfo"]; + + state.weekDays.value = state.checkingInSetInfo.value.workDay!; + state.isCustom.value = (state.checkingInSetInfo.value.attendanceType! == 0) ? true : false; + if(state.isCustom.value == false){ + if(state.checkingInSetInfo.value.workDay!.length == 5){ + state.isSingledayWeekend.value = 1; + }else if(state.checkingInSetInfo.value.workDay!.length == 6){ + state.isSingledayWeekend.value = 0; + } + } + } + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + // _teamEvent.cancel(); + } } \ 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 503b3f07..cdac3263 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart @@ -33,16 +33,21 @@ class _CheckingInSetWorkdaySetState extends State { body: ListView( children: [ topBtnWidget(), - Obx(() => Visibility(visible: state.isCustom.value == true, child: bottomCustomSeletBtn())), + Obx(() => Visibility(visible: state.isCustom.value, 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: () { - Get.back(result: { - "attendanceType":state.isCustom.value, - "weekDays":state.weekDays.value, - }); + if(state.pushType.value == "2"){ + logic.editCheckInSetInfoData(); + }else{ + Get.back(result: { + "attendanceType":state.isCustom.value, + "weekDays":state.weekDays.value, + }); + } + }), ), ], @@ -127,7 +132,7 @@ class _CheckingInSetWorkdaySetState extends State { rightWidget: GestureDetector( onTap: () { setState(() { - state.isSingledayWeekend.value = 0; + state.isSingledayWeekend.value = 1; state.weekDays.value = [1, 2 , 3, 4, 5, 6]; }); }, @@ -147,7 +152,7 @@ class _CheckingInSetWorkdaySetState extends State { rightWidget: GestureDetector( onTap: () { setState(() { - state.isSingledayWeekend.value = 1; + state.isSingledayWeekend.value = 2; state.weekDays.value = [1, 2 , 3, 4, 5]; }); }, @@ -206,22 +211,22 @@ class _CheckingInSetWorkdaySetState extends State { 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,), - ], - )) + 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: Obx(() => 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 index 3a232c6e..1b478ee9 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart @@ -2,9 +2,37 @@ import 'package:get/get.dart'; -class CheckingInSetWorkdaySetState{ - var isCustom = true.obs; - var isSingledayWeekend = 2.obs; // 0单休 1双休 - var weekDays = [].obs;// 工作天数 +import '../../../lockMian/entity/lockInfoEntity.dart'; +import '../checkingInSet/checkingInSet_entity.dart'; +class CheckingInSetWorkdaySetState{ + var isCustom = true.obs; // 自定义 + var isSingledayWeekend = 2.obs; // 0单休 1双休 + var weekDays = [].obs;// 工作天数 + + final getKeyInfosData = KeyInfos().obs; + final checkingInSetInfo = CheckingInSetInfo().obs; + final companyId = "".obs; + + var pushType = "".obs;// 2考勤设置信息选择时间 1考勤创建公司 + + CheckingInSetWorkdaySetState() { + Map map = Get.arguments; + pushType.value = map["pushType"]; + if(pushType.value == "2"){ + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; + checkingInSetInfo.value = map["checkingInSetInfo"]; + + weekDays.value = checkingInSetInfo.value.workDay!; + isCustom.value = (checkingInSetInfo.value.attendanceType! == 0) ? true : false; + if(isCustom.value == false){ + if(checkingInSetInfo.value.workDay!.length == 5){ + isSingledayWeekend.value = 1; + }else if(checkingInSetInfo.value.workDay!.length == 6){ + isSingledayWeekend.value = 0; + } + } + } + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSeletKey_entity.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSeletKey_entity.dart new file mode 100644 index 00000000..5c1e4e40 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSeletKey_entity.dart @@ -0,0 +1,52 @@ + +class CheckingInAddStaffSeletKeyEntity { + int? errorCode; + String? description; + String? errorMsg; + List? data; + + CheckingInAddStaffSeletKeyEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + CheckingInAddStaffSeletKeyEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] != null) { + data = []; + json['data'].forEach((v) { + data!.add(CheckingInAddStaffKeyEntity.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class CheckingInAddStaffKeyEntity { + String? attendanceWay; + String? staffName; + + CheckingInAddStaffKeyEntity({this.attendanceWay, this.staffName}); + + CheckingInAddStaffKeyEntity.fromJson(Map json) { + attendanceWay = json['attendanceWay']; + staffName = json['staffName']; + } + + Map toJson() { + final Map data = {}; + data['attendanceWay'] = attendanceWay; + data['staffName'] = staffName; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart new file mode 100644 index 00000000..74dd5dde --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart @@ -0,0 +1,171 @@ + +import 'package:get/get.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; +import '../../../../../network/api_repository.dart'; +import '../../../../../tools/eventBusEventManage.dart'; +import 'checkingInAddStaffSeletKey_entity.dart'; +import 'checkingInAddStaff_state.dart'; + +typedef KeyClickCallback = void Function(List seletKeyList); +class CheckingInAddStaffLogic extends BaseGetXController{ + CheckingInAddStaffState state = CheckingInAddStaffState(); + + // 添加员工 + void addStaffLoadData() async{ + var attendanceWay = ""; + var usernameType = "1"; + switch(int.parse(state.seletPrintingMethodType.value)){ + case 1: + // 打卡方式APP + if(state.appUnHaveAccount.value){ + // 当没有账号的时候 + attendanceWay = state.staffAccountController.text; + + if(attendanceWay.contains("@")){ + usernameType = "2"; + } + + if(attendanceWay.isEmpty){ + Toast.show(msg: "请输入员工账号"); + return; + } + }else { + attendanceWay = state.seletKey.value; + + if(attendanceWay.isEmpty){ + Toast.show(msg: "请选择员工钥匙"); + return; + } + } + + break; + case 2: + + break; + case 3: + + break; + case 4: + + break; + } + + if(state.staffNameController.text.isEmpty){ + Toast.show(msg: "请输入姓名"); + return; + } + + var entity = await ApiRepository.to.addStaffData( + attendanceType: state.seletPrintingMethodType.value, + attendanceWay: attendanceWay, + companyId: state.companyId.value, + have: state.appUnHaveAccount.value ? "2" : "1", + staffName: state.staffNameController.text, + countryCode: state.countryCode.value, + usernameType:usernameType, + ); + if(entity.errorCode!.codeIsSuccessful){ + Get.back(result: "addScuess"); + }else if(entity.errorCode! == 425){ + Toast.show(msg: entity.errorMsg!); + } + } + + // 考勤设置添加员工-选择钥匙 + void addStaffSeletKey(KeyClickCallback kyClickCallback) async{ + var entity = await ApiRepository.to.addStaffSeletKeyData( + companyId: state.companyId.value, + type:"1", + ); + if(entity.errorCode!.codeIsSuccessful){ + state.keyEntity.value = entity.data!; + kyClickCallback(state.keyEntity.value); + } + } + + // 编辑员工 + void editStaffLoadData() async{ + var attendanceWay = ""; + var usernameType = "1"; + switch(int.parse(state.seletPrintingMethodType.value)){ + case 1: + // 打卡方式APP + if(state.appUnHaveAccount.value){ + // 当没有账号的时候 + attendanceWay = state.staffAccountController.text; + + if(attendanceWay.contains("@")){ + usernameType = "2"; + } + + if(attendanceWay.isEmpty){ + Toast.show(msg: "请输入员工账号"); + return; + } + }else { + attendanceWay = state.seletKey.value; + + if(attendanceWay.isEmpty){ + Toast.show(msg: "请选择员工钥匙"); + return; + } + } + + break; + case 2: + + break; + case 3: + + break; + case 4: + + break; + } + + if(state.staffNameController.text.isEmpty){ + Toast.show(msg: "请输入姓名"); + return; + } + + var entity = await ApiRepository.to.editStaffData( + attendanceType: state.seletPrintingMethodType.value, + attendanceWay: attendanceWay, + staffId: state.staffListItemData.value.staffId.toString(), + have: state.appUnHaveAccount.value ? "2" : "1", + staffName: state.staffNameController.text, + countryCode: state.countryCode.value, + usernameType:usernameType, + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshCheckInStaffListDataEvent()); + Get.close(2); + }else if(entity.errorCode! == 425){ + Toast.show(msg: entity.errorMsg!); + } + } + + @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/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart similarity index 50% rename from star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_page.dart rename to star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index 229b949b..0ee9a749 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -2,12 +2,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/commonItem.dart'; -import '../../../../tools/showBottomSheetTool.dart'; -import '../../../../tools/submitBtn.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; +import '../../../../../appRouters.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/commonItem.dart'; +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 { @@ -38,15 +39,16 @@ class _CheckingInAddStaffPageState extends State { isHaveLine: true, isHaveRightWidget: true, rightWidget: - getTFWidget(TranslationLoader.lanKeys!.pleaseEnter!.tr)), - CommonItem( + getTFWidget(TranslationLoader.lanKeys!.pleaseEnter!.tr, state.staffNameController)), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.punchingMode!.tr, - rightTitle: "APP", + rightTitle: state.seletPrintingMethodStr.value, isHaveLine: false, isHaveDirection: true, action: () { - _showSeletClockInType(); - }), + var list = ["APP", "密码", "卡", "指纹"]; + _showSeletClockInType(list, "1"); + })), SizedBox( height: 10.h, ), @@ -58,34 +60,72 @@ class _CheckingInAddStaffPageState extends State { isHaveRightWidget: true, rightWidget: Row( children: [ - whetherTheEmployeeHasAKeyWidget("有", () {}), - SizedBox( - width: 30.w, - ), - whetherTheEmployeeHasAKeyWidget("无", () {}), + whetherTheEmployeeHasAKeyWidget("无", state.appUnHaveAccount.value, () { + setState(() { + state.appUnHaveAccount.value = true; + }); + }), + SizedBox(width: 30.w,), + whetherTheEmployeeHasAKeyWidget("有", !state.appUnHaveAccount.value, () { + setState(() { + state.appUnHaveAccount.value = false; + }); + }), ], )), - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: - getTFWidget(TranslationLoader.lanKeys!.pleaseEnter!.tr)), - ), - Visibility( - visible: true, + Obx(() => Visibility( + visible: state.appUnHaveAccount.value, + child: Column( + children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: + getTFWidget(TranslationLoader.lanKeys!.pleaseEnter!.tr, state.staffAccountController)), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + isHaveDirection: true, + rightWidget: Text( + '${state.countryName.value} +${state.countryCode.value}', + textAlign: TextAlign.end, + style: + TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + ), + action: () async { + var result = await Navigator.pushNamed( + context, Routers.seletCountryRegionPage); + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + setState(() {}); + }, + ), + ], + ), + )), + Obx(() => Visibility( + visible: !state.appUnHaveAccount.value, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.selectKey!.tr, - rightTitle: "", + rightTitle: state.seletKey.value, isHaveLine: false, isHaveDirection: true, action: () { - _showSeletClockInType(); + logic.addStaffSeletKey((v){ + var list = []; + for (var element in v) { + list.add(element.attendanceWay); + } + _showSeletClockInType(list, "2"); + }); + }), - ), + )), SizedBox( height: 50.w, ), @@ -94,13 +134,19 @@ class _CheckingInAddStaffPageState extends State { borderRadius: 20.w, margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () {}), + onClick: () { + if(state.isAdd.value == "2"){ + logic.editStaffLoadData(); + }else{ + logic.addStaffLoadData(); + } + }), ], ), ); } - Widget getTFWidget(String tfStr) { + Widget getTFWidget(String tfStr, TextEditingController tf) { return SizedBox( height: 50.h, width: 300.w, @@ -111,7 +157,7 @@ class _CheckingInAddStaffPageState extends State { child: TextField( //输入框一行 maxLines: 1, - controller: state.staffNameController, + controller: tf, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( @@ -129,13 +175,8 @@ class _CheckingInAddStaffPageState extends State { ); } - void _showSeletClockInType() { - var list = [ - "APP", - "密码", - "卡", - "指纹", - ]; + // type 1 打卡方式 2选择钥匙 + void _showSeletClockInType(List list, String type) { ShowBottomSheetTool().showSingleRowPicker( //上下文 context, @@ -149,16 +190,24 @@ class _CheckingInAddStaffPageState extends State { //adapter: PickerAdapter(), data: list, //选择事件的回调 - clickCallBack: (int index, var str) {}); + clickCallBack: (int index, var str) { + print("object:$index str:$str"); + if(type == "1"){ + state.seletPrintingMethodType.value = (index+1).toString(); + state.seletPrintingMethodStr.value = str.toString(); + }else{ + state.seletKey.value = str.toString(); + } + }); } - Widget whetherTheEmployeeHasAKeyWidget(String title, Function action) { + Widget whetherTheEmployeeHasAKeyWidget(String title, bool appUnHaveAccount, Function() action) { return GestureDetector( - onTap: () {}, + onTap: action, child: Row( children: [ Image.asset( - 'images/icon_round_unSelet.png', + appUnHaveAccount ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 26.w, height: 26.w, ), diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart new file mode 100644 index 00000000..9d54e524 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart @@ -0,0 +1,64 @@ + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../../lockMian/entity/lockInfoEntity.dart'; +import '../checkingInSetStaffList/checkingInStaffList_entity.dart'; +import 'checkingInAddStaffSeletKey_entity.dart'; + +class CheckingInAddStaffState{ + final getKeyInfosData = KeyInfos().obs; + final companyId = "".obs; + final staffListItemData = CheckingInAddStaffListItemEntity().obs; + + final TextEditingController staffNameController = TextEditingController(); + final TextEditingController staffAccountController = TextEditingController(); + + final seletPrintingMethodType = "1".obs;// 选择打卡类型 + final seletPrintingMethodStr = "APP".obs;// 选择打卡类型字符串 + + final countryName = "中国".obs; + final countryCode = "86".obs; + + final appUnHaveAccount = true.obs;// 默认没有账号 + final keyEntity = [].obs;// 选择钥匙数据 + final seletKey = "".obs; + + final isAdd = "1".obs; // 1添加 2编辑 + + CheckingInAddStaffState() { + Map map = Get.arguments; + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; + + isAdd.value = map["isAdd"]; + if(isAdd.value == "2"){ + staffListItemData.value = map["staffListItem"]; + staffNameController.text = staffListItemData.value.staffName!; + + seletPrintingMethodType.value = staffListItemData.value.attendanceType.toString(); + switch(staffListItemData.value.attendanceType){ + case 1: + seletPrintingMethodStr.value = "APP"; + break; + case 2: + seletPrintingMethodStr.value = "密码"; + break; + case 3: + seletPrintingMethodStr.value = "卡"; + break; + case 4: + seletPrintingMethodStr.value = "指纹"; + break; + } + + if(staffListItemData.value.attendanceWay!.isNotEmpty){ + appUnHaveAccount.value = false; + seletKey.value = staffListItemData.value.attendanceWay!; + }else{ + appUnHaveAccount.value = true; + } + } + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart new file mode 100644 index 00000000..d52c0140 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart @@ -0,0 +1,69 @@ +class CheckingInAddStaffListEntity { + int? errorCode; + String? description; + String? errorMsg; + List? data; + + CheckingInAddStaffListEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + CheckingInAddStaffListEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] != null) { + data = []; + json['data'].forEach((v) { + data!.add(CheckingInAddStaffListItemEntity.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class CheckingInAddStaffListItemEntity { + String? headurl; + String? staffName; + int? staffId; + int? attendanceType; + String? countryCode; + String? attendanceWay; + + CheckingInAddStaffListItemEntity( + {this.headurl, + this.staffName, + this.staffId, + this.attendanceType, + this.countryCode, + this.attendanceWay}); + + CheckingInAddStaffListItemEntity.fromJson(Map json) { + headurl = json['headurl']; + staffName = json['staffName']; + staffId = json['staffId']; + attendanceType = json['attendanceType']; + countryCode = json['countryCode']; + attendanceWay = json['attendanceWay']; + } + + Map toJson() { + final Map data = {}; + data['headurl'] = headurl; + data['staffName'] = staffName; + data['staffId'] = staffId; + data['attendanceType'] = attendanceType; + data['countryCode'] = countryCode; + data['attendanceWay'] = attendanceWay; + return data; + } +} \ 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/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart similarity index 66% rename from star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_logic.dart rename to star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart index d4b4fcb5..eb193fbc 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart @@ -1,8 +1,9 @@ +import 'dart:async'; -import 'package:date_format/date_format.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import '../../../../network/api_repository.dart'; +import '../../../../../network/api_repository.dart'; +import '../../../../../tools/eventBusEventManage.dart'; import 'checkingInStaffList_state.dart'; class CheckingInStaffManageLogic extends BaseGetXController{ @@ -15,10 +16,17 @@ class CheckingInStaffManageLogic extends BaseGetXController{ lockId:state.getKeyInfosData.value.lockId.toString(), ); if(entity.errorCode!.codeIsSuccessful){ - + state.staffListData.value = entity.data!; } } + late StreamSubscription _teamEvent; + void _initLoadDataAction() { + _teamEvent = eventBus.on().listen((event) { + getStaffList(); + }); + } + @override void onReady() { // TODO: implement onReady @@ -26,6 +34,8 @@ class CheckingInStaffManageLogic extends BaseGetXController{ print("onReady()"); getStaffList(); + + _initLoadDataAction(); } @override @@ -39,6 +49,6 @@ class CheckingInStaffManageLogic extends BaseGetXController{ @override void onClose() { // TODO: implement onClose - + _teamEvent.cancel(); } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart new file mode 100644 index 00000000..83642832 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -0,0 +1,98 @@ +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/customNetworkImage.dart'; +import '../../../../../tools/noData.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import 'checkingInStaffList_entity.dart'; +import 'checkingInStaffList_logic.dart'; + +class CheckingInStaffListPage extends StatefulWidget { + const CheckingInStaffListPage({Key? key}) : super(key: key); + + @override + State createState() => + _CheckingInStaffListPageState(); +} + +class _CheckingInStaffListPageState extends State { + final logic = Get.put(CheckingInStaffManageLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.greyBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.staff!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + GestureDetector( + onTap: () async { + var data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value, + "isAdd": "1", + }); + if(data != null) { + logic.getStaffList(); + } + }, + child: Image.asset( + 'images/icon_add_white.png', + width: 36.w, + height: 36.w, + )), + SizedBox( + width: 30.w, + ), + ], + ), + body: Container( + color: Colors.white, + child: Obx(() => state.staffListData.value.isNotEmpty ? ListView.separated( + itemCount: state.staffListData.value.length, + itemBuilder: (c, index) { + CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index]; + return _checkingInStaffManageItem(staffListItem, () { + Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { + "staffListItem": staffListItem, + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value, + }); + }); + }, + separatorBuilder: (context, index) { + return const Divider( + height: 1, indent: 20, color: AppColors.greyLineColor); + }, + ) :const NoData()), + )); + } + + Widget _checkingInStaffManageItem(CheckingInAddStaffListItemEntity staffListItem, Function() action) { + return GestureDetector( + onTap: action, + child: Container( + height: 60.h, + width: 1.sw, + color: Colors.white, + margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 10.h, bottom: 10.h), + child: Row( + children: [ + SizedBox(width: 30.w,), + CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w), + // Image.asset('images/controls_user.png', width: 40.w, height: 40.w), + SizedBox(width: 30.w,), + Text(staffListItem.staffName!, style: TextStyle(fontSize: 24.sp)), + ], + ), + ), + ); + } +} diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart similarity index 57% rename from star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_state.dart rename to star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart index 25fe8982..6019d433 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_state.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart @@ -1,16 +1,20 @@ import 'package:get/get.dart'; -import '../../../lockMian/entity/lockInfoEntity.dart'; +import '../../../../lockMian/entity/lockInfoEntity.dart'; +import 'checkingInStaffList_entity.dart'; class CheckingInStaffManageState{ final getKeyInfosData = KeyInfos().obs; final companyId = "".obs; + final staffListData = [].obs; + CheckingInStaffManageState() { Map map = Get.arguments; getKeyInfosData.value = map["getKeyInfosData"]; companyId.value = map["companyId"]; + // print("companyId.value:${companyId.value}"); } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_logic.dart new file mode 100644 index 00000000..0402fabd --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_logic.dart @@ -0,0 +1,9 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; +import 'checkingInStaffDetail_state.dart'; + +class CheckingInStaffDetailLogic extends BaseGetXController{ + CheckingInStaffDetailState state = CheckingInStaffDetailState(); + + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart new file mode 100644 index 00000000..9d7afd94 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart @@ -0,0 +1,70 @@ + +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/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import 'checkingInStaffDetail_logic.dart'; + +class CheckingInStaffDetailPage extends StatefulWidget { + const CheckingInStaffDetailPage({Key? key}) : super(key: key); + + @override + State createState() => _CheckingInStaffDetailPageState(); +} + +class _CheckingInStaffDetailPageState extends State { + final logic = Get.put(CheckingInStaffDetailLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.staff!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + child: Text( + TranslationLoader.lanKeys!.edit!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: () { + Get.toNamed(Routers.checkingInAddStaffPage, arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value, + "staffListItem": state.staffListItemData.value, + "isAdd": "2", + }); + }, + ), + ],), + body: Column( + children: [ + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.name!.tr, + rightTitle: state.staffListItemData.value.staffName, + isHaveLine: true)), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.punchingMode!.tr, + rightTitle: state.attendanceType.value, + isHaveLine: true)), + Obx(() => CommonItem( + leftTitel: "APP", + rightTitle: state.staffListItemData.value.attendanceWay, + isHaveLine: true)), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.attendanceRecord!.tr, + rightTitle: "", + isHaveDirection: true), + ], + ), + ); + } +} diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_state.dart new file mode 100644 index 00000000..bdff3ff6 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_state.dart @@ -0,0 +1,36 @@ + +import 'package:get/get.dart'; + +import '../../../../lockMian/entity/lockInfoEntity.dart'; +import '../checkingInSetStaffList/checkingInStaffList_entity.dart'; + +class CheckingInStaffDetailState{ + final getKeyInfosData = KeyInfos().obs; + final companyId = "".obs; + + final staffListItemData = CheckingInAddStaffListItemEntity().obs; + + var attendanceType = "".obs; + + CheckingInStaffDetailState() { + Map map = Get.arguments; + staffListItemData.value = map["staffListItem"]; + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; + + switch(staffListItemData.value.attendanceType){ + case 1: + attendanceType.value = "APP"; + break; + case 2: + attendanceType.value = "密码"; + break; + case 3: + attendanceType.value = "卡"; + break; + case 4: + attendanceType.value = "指纹"; + break; + } + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart index 76918278..1c9e7830 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart @@ -133,7 +133,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ privateKey:getPrivateKeyList, ); } - }); + }, isShowLoading: false); } // 自动落锁 diff --git a/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_page.dart b/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_page.dart index 04f19f23..ab6161c0 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/checkInCreatCompany/checkInCreatCompany_page.dart @@ -66,7 +66,6 @@ class _CheckInCreatCompanyPageState extends State { setState(() { state.isCustom.value = data["attendanceType"]; state.weekDays.value = data["weekDays"]; - state.weekDaysStr.value = ""; state.weekDaysStr.value = state.weekDays.value.join(","); }); } 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 a44c56fb..2b4df7ae 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart @@ -53,7 +53,7 @@ class LockTimeLogic extends BaseGetXController{ (0xff & lockTime[2]) << 8 | (0xFF & lockTime[3])); - String dataEime = DateTool().dateToString("${value}"); + String dataEime = DateTool().dateToYMDHNSString("${value}"); state.dateTime.value = dataEime; print("lockTime:$lockTime value:$value dataEime:$dataEime"); break; @@ -126,7 +126,7 @@ class LockTimeLogic extends BaseGetXController{ privateKey:getPrivateKeyList, ); } - }); + }, isShowLoading: false); } // 校验时间 @@ -171,7 +171,7 @@ class LockTimeLogic extends BaseGetXController{ lockId: state.getKeyInfosData.value.lockId.toString(), ); if(entity.errorCode!.codeIsSuccessful){ - String dataEime = DateTool().dateToString("${int.parse(entity.data!.date.toString())~/1000}"); + String dataEime = DateTool().dateToYMDHNSString("${int.parse(entity.data!.date.toString())~/1000}"); state.dateTime.value = dataEime; sendTiming(); } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 668e4c3a..867d7287 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -407,7 +407,7 @@ class LockDetailLogic extends BaseGetXController{ privateKey:getPrivateKeyList, ); } - }); + }, isShowLoading: false); } @override @@ -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 f3c484cd..d0685cc5 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -261,10 +261,11 @@ class _LockDetailPageState extends State with RouteAware { bottomItem('images/main/icon_main_electronicKey.png', TranslationLoader.lanKeys!.electronicKey!.tr, () { Get.toNamed(Routers.electronicKeyListPage, arguments: { - "lockMainEntity": widget.lockMainEntity, - "keyInfo": widget.keyInfo - }); - }), + "lockMainEntity": widget.lockMainEntity, + "keyInfo": widget.keyInfo + }); + }), + // 密码 bottomItem('images/main/icon_main_password.png', TranslationLoader.lanKeys!.password!.tr, () { @@ -273,20 +274,29 @@ class _LockDetailPageState extends State with RouteAware { "keyInfo": widget.keyInfo }); }), + // ic卡 - bottomItem('images/main/icon_main_icCard.png', - TranslationLoader.lanKeys!.card!.tr, () { - Get.toNamed(Routers.otherTypeKeyListPage, arguments: 0); - }), + bottomItem('images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, () { + Get.toNamed(Routers.otherTypeKeyListPage, arguments: { + "lockId": widget.keyInfo.lockId, + "fromType": 0 + }); + }), + // 指纹 - bottomItem('images/main/icon_main_fingerprint.png', - TranslationLoader.lanKeys!.fingerprint!.tr, () { - Get.toNamed(Routers.otherTypeKeyListPage, arguments: 1); + bottomItem('images/main/icon_main_fingerprint.png', TranslationLoader.lanKeys!.fingerprint!.tr, () { + Get.toNamed(Routers.otherTypeKeyListPage, arguments: { + "lockId": widget.keyInfo.lockId, + "fromType": 1 + }); }), + // 遥控 - bottomItem('images/main/icon_main_remoteControl.png', - TranslationLoader.lanKeys!.remoteControl!.tr, () { - Get.toNamed(Routers.otherTypeKeyListPage, arguments: 2); + bottomItem('images/main/icon_main_remoteControl.png', TranslationLoader.lanKeys!.remoteControl!.tr, () { + Get.toNamed(Routers.otherTypeKeyListPage, arguments: { + "lockId": widget.keyInfo.lockId, + "fromType": 2 + }); }), ]; showWidgetArr.addAll(defaultWidgetArr); diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_logic.dart index b81418f1..e0c729ec 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_logic.dart @@ -1,21 +1,33 @@ -import 'dart:async'; +import 'package:get/get.dart'; -import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; -import 'package:star_lock/blue/io_protocol/io_addFingerprint.dart'; -import 'package:star_lock/blue/io_type.dart'; - -import '../../../../blue/blue_manage.dart'; -import '../../../../blue/io_reply.dart'; -import '../../../../blue/io_protocol/io_senderCustomPasswords.dart'; -import '../../../../blue/io_tool/io_manager.dart'; -import '../../../../blue/io_tool/io_tool.dart'; -import '../../../../blue/io_tool/manager_event_bus.dart'; -import '../../../../blue/sender_manage.dart'; +import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; -import '../../../../tools/storage.dart'; +import '../../../../tools/toast.dart'; +import 'otherTypeAddKey_state.dart'; class OtherTypeAddKeyLogic extends BaseGetXController { + OtherTypeAddKeyState state = OtherTypeAddKeyState(); + + // 获取指纹列表 + void addFingerprintsData() async{ + + var entity = await ApiRepository.to.addFingerprintsData( + lockId: state.lockId.value.toString(), + endDate: state.fromType.value == 0 ? "0" : state.endTimeTimestamp.toString(), + addType:"1", + fingerprintName: state.nameController.text, + fingerprintNumber: "123456", + fingerprintType: state.fromType.value == 2 ? "4" : "1", + isCoerced: state.isStressFingerprint.value ? "1" : "0", + startDate: state.fromType.value == 0 ? "0" : state.beginTimeTimestamp.toString(), + cyclicConfig: '', + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "添加成功"); + Get.back(result: "addScuess"); + } + } @override void onReady() { diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_page.dart index 78f6bb37..c3c7f40d 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_page.dart @@ -1,4 +1,7 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_pickers/pickers.dart'; +import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; @@ -6,20 +9,24 @@ import 'package:star_lock/appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; +import '../../../../tools/toast.dart'; import '../../../../translations/trans_lib.dart'; +import 'otherTypeAddKey_logic.dart'; class OtherTypeAddKeyPage extends StatefulWidget { final String seletType; final int lockType; // 0卡 1指纹 2钥匙 + final int lockId; // 0卡 1指纹 2钥匙 const OtherTypeAddKeyPage( - {Key? key, required this.seletType, required this.lockType}) : super(key: key); + {Key? key, required this.seletType, required this.lockType, required this.lockId}) : super(key: key); @override State createState() => _OtherTypeAddKeyPageState(); } class _OtherTypeAddKeyPageState extends State { - final TextEditingController _controller = TextEditingController(); + final logic = Get.put(OtherTypeAddKeyLogic()); + final state = Get.find().state; @override Widget build(BuildContext context) { @@ -35,10 +42,7 @@ class _OtherTypeAddKeyPageState extends State { return Column( children: [ perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, _controller), - SizedBox( - height: 30.h, - ), + TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController), keyBottomWidget() ], ); @@ -49,11 +53,9 @@ class _OtherTypeAddKeyPageState extends State { return Column( children: [ perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, _controller), + TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController), keyTimeLimitWidget(), - SizedBox( - height: 30.h, - ), + SizedBox(height: 10.h), keyBottomWidget() ], ); @@ -64,17 +66,21 @@ class _OtherTypeAddKeyPageState extends State { return Column( children: [ perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, _controller), + TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController), CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, rightTitle: "", isHaveDirection: true, action: () { - // _showDatePicker(); + // Map result = await Get.toNamed(Routers.electronicKeyPeriodValidityPage); + // // result as Map; + // weekdaysList = result['validityValue']; + // _effectiveDateTime = result['starDate']; + // _failureDateTime = result['endDate']; + // print( + // '得到的有效期数据:$weekdaysList $_effectiveDateTime $_failureDateTime'); }), - SizedBox( - height: 30.h, - ), + SizedBox(height: 10.h), keyBottomWidget() ], ); @@ -104,20 +110,36 @@ class _OtherTypeAddKeyPageState extends State { Widget keyTimeLimitWidget() { return Column( children: [ - CommonItem( + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: "2020.06.20 11:49", + rightTitle: state.beginTime.value, isHaveLine: true, isHaveDirection: true, - action: () { - // _showDatePicker(); - }), + action: () async { + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + setState(() { + state.beginTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}'; + state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).toString(); + }); + }); + }); + })), CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, rightTitle: "2020.06.20 11:49", isHaveDirection: true, action: () { - // _showDatePicker(); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + setState(() { + state.endTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}'; + state.endTimeTimestamp.value = DateTime.parse(state.beginTime.value).toString(); + }); + }); + }); }), Container(height: 10.h), ], @@ -127,10 +149,24 @@ class _OtherTypeAddKeyPageState extends State { Widget keyBottomWidget() { return Column( children: [ + CommonItem( + leftTitel: "胁迫指纹", + rightTitle: "", + isTipsImg: false, + isHaveRightWidget: true, + rightWidget: SizedBox( + width: 60.w, height: 50.h, child: _isStressFingerprint())), + SizedBox(height: 30.h), SubmitBtn(btnName: TranslationLoader.lanKeys!.next!.tr, onClick: () { - if(widget.lockType == 1){ - Get.toNamed(Routers.addFingerprintTipPage); + if(state.nameController.text.isEmpty){ + Toast.show(msg: "请输入姓名"); + return; } + + // if(widget.lockType == 1){ + Get.toNamed(Routers.addFingerprintTipPage); + // } + // logic.addFingerprintsData(); }), ], ); @@ -236,7 +272,7 @@ class _OtherTypeAddKeyPageState extends State { child: TextField( //输入框一行 maxLines: 1, - // controller: _controller, + controller: state.nameController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( @@ -256,4 +292,20 @@ class _OtherTypeAddKeyPageState extends State { ), ); } + + //isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹 + CupertinoSwitch _isStressFingerprint() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: state.isStressFingerprint.value, + onChanged: (value) { + setState(() { + state.isStressFingerprint.value = value; + }); + }, + ); + } + } diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_state.dart index e69de29b..30835b22 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_state.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_state.dart @@ -0,0 +1,22 @@ + + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class OtherTypeAddKeyState{ + final lockId = 0.obs; + final fromType = 0.obs; + final isStressFingerprint = false.obs; + + var beginTime = "".obs;// 开始时间 + var endTime = "".obs;// 结束时间 + var beginTimeTimestamp = "".obs;// 开始时间时间戳 + var endTimeTimestamp = "".obs;// 结束时间时间戳 + + final TextEditingController nameController = TextEditingController(); + OtherTypeAddKeyState() { + Map map = Get.arguments; + lockId.value = map["lockId"]; + fromType.value = map["fromType"]; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_logic.dart new file mode 100644 index 00000000..60fbe6a8 --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_logic.dart @@ -0,0 +1,11 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import 'otherTypeKeyDetail_state.dart'; + +class OtherTypeKeyDetailLogic extends BaseGetXController{ + OtherTypeKeyDetailState state = OtherTypeKeyDetailState(); + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart index 833aa55f..9415e50e 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart @@ -9,6 +9,7 @@ import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'otherTypeKeyDetail_logic.dart'; class OtherTypeKeyDetailPage extends StatefulWidget { const OtherTypeKeyDetailPage({Key? key}) : super(key: key); @@ -18,6 +19,9 @@ class OtherTypeKeyDetailPage extends StatefulWidget { } class _OtherTypeKeyDetailPageState extends State { + final logic = Get.put(OtherTypeKeyDetailLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { var type = ModalRoute.of(context)?.settings.arguments as int; @@ -25,25 +29,22 @@ class _OtherTypeKeyDetailPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: - "${getAppBarTitle(type)}${TranslationLoader.lanKeys!.number!.tr}", + barTitle: "${getAppBarTitle(type)}${TranslationLoader.lanKeys!.number!.tr}", haveBack: true, backgroundColor: AppColors.mainColor, actionsList: [ TextButton( - child: Text( - TranslationLoader.lanKeys!.share!.tr, - style: TextStyle(color: Colors.white, fontSize: 24.sp), - ), - onPressed: () {}, + child: Text(TranslationLoader.lanKeys!.share!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),), + onPressed: () { + + }, ), ], ), body: Column( children: [ CommonItem( - leftTitel: - "${getAppBarTitle(type)}${TranslationLoader.lanKeys!.number!.tr}", + leftTitel: "${getAppBarTitle(type)}${TranslationLoader.lanKeys!.number!.tr}", rightTitle: "98765432", isHaveDirection: true, isHaveLine: true, @@ -63,41 +64,41 @@ class _OtherTypeKeyDetailPageState extends State { rightTitle: "永久", isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.electronicKeyDetailChangeDate); + Navigator.pushNamed(context, Routers.electronicKeyDetailChangeDate); }), Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.additive!.tr, rightTitle: "15080825640", - action: () {}), + action: () { + + }), CommonItem( leftTitel: TranslationLoader.lanKeys!.addTime!.tr, rightTitle: "2020.06.21 11:49", - action: () {}), + action: () { + + }), Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr, rightTitle: "", isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.keyOperationRecordPage); + Get.toNamed(Routers.keyOperationRecordPage); }), - SizedBox( - height: 40.h, - ), + SizedBox(height: 40.h), addControlsBtn(type), - SizedBox( - height: 30.h, - ), + SizedBox(height: 30.h), SubmitBtn( btnName: TranslationLoader.lanKeys!.delete!.tr, isDelete: true, borderRadius: 20.w, - margin: EdgeInsets.only( - left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), + margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () {}), + onClick: () { + + }), ], ), ); diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_state.dart new file mode 100644 index 00000000..73a22aef --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_state.dart @@ -0,0 +1,4 @@ + +class OtherTypeKeyDetailState{ + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart new file mode 100644 index 00000000..5db8a804 --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart @@ -0,0 +1,123 @@ +class FingerprintListDataEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + FingerprintListDataEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + FingerprintListDataEntity.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 = Map(); + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + List? list; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + Data({this.list, this.pageNo, this.pageSize, this.pages, this.total}); + + Data.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(FingerprintItemData.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class FingerprintItemData { + int? status; + int? lockId; + int? createDate; + String? fingerprintName; + int? endDate; + String? userId; + String? nickName; + int? isCoerced; + int? startDate; + String? fingerprintNumber; + int? fingerprintType; + int? fingerprintId; + + FingerprintItemData( + {this.status, + this.lockId, + this.createDate, + this.fingerprintName, + this.endDate, + this.userId, + this.nickName, + this.isCoerced, + this.startDate, + this.fingerprintNumber, + this.fingerprintType, + this.fingerprintId}); + + FingerprintItemData.fromJson(Map json) { + status = json['status']; + lockId = json['lockId']; + createDate = json['createDate']; + fingerprintName = json['fingerprintName']; + endDate = json['endDate']; + userId = json['userId']; + nickName = json['nickName']; + isCoerced = json['isCoerced']; + startDate = json['startDate']; + fingerprintNumber = json['fingerprintNumber']; + fingerprintType = json['fingerprintType']; + fingerprintId = json['fingerprintId']; + } + + Map toJson() { + final Map data = {}; + data['status'] = status; + data['lockId'] = lockId; + data['createDate'] = createDate; + data['fingerprintName'] = fingerprintName; + data['endDate'] = endDate; + data['userId'] = userId; + data['nickName'] = nickName; + data['isCoerced'] = isCoerced; + data['startDate'] = startDate; + data['fingerprintNumber'] = fingerprintNumber; + data['fingerprintType'] = fingerprintType; + data['fingerprintId'] = fingerprintId; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart index 6bbab42b..467d885c 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart @@ -12,6 +12,7 @@ import '../../../../blue/io_tool/io_manager.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; +import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; import '../../../../tools/storage.dart'; import 'otherTypeKeyList_state.dart'; @@ -257,7 +258,20 @@ class OtherTypeKeyListLogic extends BaseGetXController{ privateKey:getPrivateKeyList, ); } - }); + }, isShowLoading: false); + } + + // 获取指纹列表 + void getFingerprintsListData() async{ + var entity = await ApiRepository.to.getFingerprintsListData( + lockId: state.lockId.value.toString(), + pageNo: '1', + pageSize: '20', + searchStr: '', + ); + if(entity.errorCode!.codeIsSuccessful){ + state.fingerprintItemListData.value = entity.data!.list!; + } } @override @@ -267,6 +281,8 @@ class OtherTypeKeyListLogic extends BaseGetXController{ print("onReady()"); _initReplySubscription(); + + getFingerprintsListData(); } @override diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart index 872f0df3..4308fd43 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart @@ -4,9 +4,12 @@ import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/dateTool.dart'; +import '../../../../tools/noData.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'fingerprintListData_entity.dart'; import 'otherTypeKeyList_logic.dart'; class OtherTypeKeyListPage extends StatefulWidget { @@ -22,11 +25,10 @@ class _OtherTypeKeyListPageState extends State { @override Widget build(BuildContext context) { - var type = ModalRoute.of(context)?.settings.arguments as int; return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: getAppBarTitle(type), + barTitle: getAppBarTitle(state.fromType.value), haveBack: true, backgroundColor: AppColors.mainColor, actionsList: [ @@ -45,13 +47,18 @@ class _OtherTypeKeyListPageState extends State { SizedBox( height: 20.h, ), - Expanded(child: _buildMainUI(type)), + Expanded(child: _buildMainUI(state.fromType.value)), AddBottomWhiteBtn( btnName: - '${TranslationLoader.lanKeys!.add!.tr}${getAppBarTitle(type)}', - onClick: () { - Navigator.pushNamed(context, Routers.otherTypeKeyManagePage, - arguments: type); + '${TranslationLoader.lanKeys!.add!.tr}${getAppBarTitle(state.fromType.value)}', + onClick: () async { + var data = await Get.toNamed(Routers.otherTypeKeyManagePage, arguments: { + "lockId": state.lockId.value, + "fromType": state.fromType.value + }); + if(data != null) { + logic.getFingerprintsListData(); + } }, ), SizedBox( @@ -128,12 +135,12 @@ class _OtherTypeKeyListPageState extends State { typeImgName = 'images/icon_card.png'; } - return ListView.separated( - itemCount: 5, + return Obx(() => state.fingerprintItemListData.value.isNotEmpty ? ListView.separated( + itemCount: state.fingerprintItemListData.value.length, itemBuilder: (c, index) { - return _electronicKeyItem( - typeImgName, "张三", "2023.6.21 11.15", "2023.6.21 11.15", () { - Navigator.pushNamed(context, Routers.otherTypeKeyDetailPage, + FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index]; + return _keyItem(typeImgName, fingerprintItemData.fingerprintName!, fingerprintItemData.fingerprintType! == 1 ? "永久" : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", () { + Get.toNamed(Routers.otherTypeKeyDetailPage, arguments: type); }); }, @@ -143,11 +150,10 @@ class _OtherTypeKeyListPageState extends State { color: AppColors.greyLineColor, ); }, - ); + ) :const NoData()); } - Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { + Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -159,17 +165,9 @@ class _OtherTypeKeyListPageState extends State { ), child: Row( children: [ - SizedBox( - width: 30.w, - ), - Image.asset( - lockTypeIcon, - width: 60.w, - height: 60.w, - ), - SizedBox( - width: 20.w, - ), + SizedBox(width: 30.w), + Image.asset(lockTypeIcon, width: 60.w, height: 60.w), + SizedBox(width: 20.w), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -177,11 +175,7 @@ class _OtherTypeKeyListPageState extends State { Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - Text( - lockTypeTitle, - style: TextStyle( - fontSize: 24.sp, color: AppColors.blackColor), - ), + Text(lockTypeTitle, style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)), ], ), SizedBox(height: 5.h), @@ -189,12 +183,7 @@ class _OtherTypeKeyListPageState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - Text( - "2023.6.21 18:26 永久", - style: TextStyle( - fontSize: 18.sp, - color: AppColors.placeholderTextColor), - ), + Text(showTime, style: TextStyle(fontSize: 18.sp, color: AppColors.placeholderTextColor)), ], ), ), diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart index 39014a42..6bde10b8 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart @@ -1,4 +1,17 @@ +import 'package:get/get.dart'; + +import 'fingerprintListData_entity.dart'; + class OtherTypeKeyListState{ + final lockId = 0.obs; + final fromType = 0.obs; + final fingerprintItemListData = [].obs; + + OtherTypeKeyListState() { + Map map = Get.arguments; + lockId.value = map["lockId"]; + fromType.value = map["fromType"]; + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_page.dart index 63d3bd79..5b44f0a5 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:star_lock/blue/io_tool/io_manager.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/titleAppBar.dart'; @@ -19,7 +20,10 @@ class _OtherTypeKeyManagePageState extends State { @override Widget build(BuildContext context) { // 0卡 1指纹 2钥匙 - var lockType = ModalRoute.of(context)?.settings.arguments as int; + Map map = Get.arguments; + var lockId = map["lockId"]; + var lockType = map["fromType"]; + return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -29,7 +33,7 @@ class _OtherTypeKeyManagePageState extends State { backgroundColor: AppColors.mainColor), body: Column( children: [ - OtherTypeKeyManageTabbar(initialIndex: index, lockType: lockType), + OtherTypeKeyManageTabbar(initialIndex: index, lockType: lockType, lockId: lockId), ], ), ); diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_tabbar.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_tabbar.dart index fafb9f8a..2ed18add 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_tabbar.dart @@ -10,8 +10,9 @@ import '../otherTypeAddKey/otherTypeAddKey_page.dart'; class OtherTypeKeyManageTabbar extends StatefulWidget { var initialIndex = 1; var lockType = 0; + var lockId = 0; // 0卡 1指纹 2钥匙 OtherTypeKeyManageTabbar( - {Key? key, required this.initialIndex, required this.lockType}) + {Key? key, required this.initialIndex, required this.lockType, required this.lockId}) : super(key: key); @override @@ -89,6 +90,7 @@ class _OtherTypeKeyManageTabbarState extends State .map((ItemView item) => OtherTypeAddKeyPage( seletType: item.seletType, lockType: widget.lockType, + lockId: widget.lockId, )) .toList(), ), diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 43bf6048..dc104426 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -286,7 +286,7 @@ class SaveLockLogic extends BaseGetXController { privateKey:getPrivateKeyList, ); } - }); + }, isShowLoading: false); } @override diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index d9f934fa..f7007b6e 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -61,8 +61,24 @@ abstract class Api { final String setLockPickingReminderDataURL = '/key/updateMonitorFlag'; // 设置开锁提醒 + final String getAttendanceRecordListByDateURL = '/attendanceRecord/listByDate'; // 获取考勤列表-早到榜日榜 + final String getAttendanceRecordListByMonthURL = '/attendanceRecord/earlyListByMonth'; // 获取考勤列表-早到榜月榜 + final String getAttendanceRecordListLateTimesByDateURL = '/attendanceRecord/lateListByDate'; // 获取考勤列表-迟到榜日榜 + final String getAttendanceRecordListLateTimesByMonthURL = '/attendanceRecord/lateEarlyListByMonth'; // 获取考勤列表-迟到榜月榜 + final String getAttendanceRecordHardworkingListURL = '/attendanceRecord/listForHardworking'; // 获取考勤列表- + final String getAttendanceRecordDtailURL = '/attendanceRecord/listByMonth'; // 获取考勤详情 final String getStaffListURL = '/staff/list'; // 获取员工列表 final String addStaffURL = '/staff/add'; // 添加员工 + final String editStaffURL = '/staff/update'; // 编辑员工 + final String addStaffSeletKeyURL = '/staff/attendanceList'; // 考勤设置添加员工-选择钥匙 + final String addHolidaysURL = '/vacation/add'; // 添加假期 + final String holidaysListURL = '/vacation/list'; // 假期列表 + final String holidaysDeleteURL = '/vacation/delete'; // 假期删除 + final String getCheckInSetInfoURL = '/attendanceCompany/query'; // 获取考勤设置信息 + final String editCheckInSetInfoURL = '/attendanceCompany/update'; // 修改考勤设置信息 + + final String getFingerprintListURL = '/fingerprint/list'; // 指纹列表 + final String addFingerprintURL = '/fingerprint/add'; // 添加指纹 final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息 final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 35025db7..e84b3b6f 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -115,8 +115,7 @@ class ApiProvider extends BaseProvider { 'pageSize': pageSize, 'startDate': startDate, 'keyRight': keyRight - }), - isShowLoading: true); + })); Future sendElectronicKey( String createUser, @@ -253,8 +252,7 @@ class ApiProvider extends BaseProvider { 'keyboardPwdId': keyboardPwdId, 'cardId': cardId, 'fingerprintId': fingerprintId - }), - isShowLoading: true); + })); // 绑定蓝牙管理员 Future bindingBlueAdmin( @@ -346,8 +344,7 @@ class ApiProvider extends BaseProvider { 'operatorUid': operatorUid, 'startDate': startDate, 'timezoneRawOffSet': timezoneRawOffSet - }), - isShowLoading: true); + })); Future addKeyboardPwd( String lockId, @@ -403,8 +400,7 @@ class ApiProvider extends BaseProvider { jsonEncode({'lockId': lockId, 'groupId': groupId})); Future lockGroupList(String type) => - post(lockGroupListURL.toUrl, jsonEncode({'type': type}), - isShowLoading: true); + post(lockGroupListURL.toUrl, jsonEncode({'type': type})); Future deleteElectronicKey(String keyId) => post(deleteElectronicKeyURL.toUrl, jsonEncode({'keyId': keyId})); @@ -570,7 +566,8 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'lockId': lockId, }), - isShowLoading: false); + isUnShowLoading: true + ); // 设置考勤时创建公司 Future setCheckInCreateCompanyData( @@ -631,31 +628,218 @@ class ApiProvider extends BaseProvider { 'usernameType': usernameType, })); + // 编辑员工 addHolidaysData + Future editStaffData( + String attendanceType, + String attendanceWay, + String staffId, + String have, + String staffName, + String countryCode, + String usernameType) => + post( + editStaffURL.toUrl, + jsonEncode({ + 'attendanceType': attendanceType, + 'attendanceWay': attendanceWay, + 'staffId': staffId, + 'have': have, + 'staffName': staffName, + 'countryCode': countryCode, + 'usernameType': usernameType, + })); + + // 添加员工选择钥匙 + Future addStaffSeletKeyData( + String companyId, + String type) => + post( + addStaffSeletKeyURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'type': type, + })); + + // 添加假期 + Future addHolidaysData( + String companyId, + String fillClassDate, + String vacationEndDate, + String vacationName, + String vacationStartDate) => + post( + addHolidaysURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'fillClassDate': fillClassDate, + 'vacationEndDate': vacationEndDate, + 'vacationName': vacationName, + 'vacationStartDate': vacationStartDate, + })); + + // 假期列表 + Future holidaysListData( + String companyId, + String vacationYear) => + post( + holidaysListURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'vacationYear': vacationYear, + })); + + // 删除假期 + Future deletHolidaysData( + String vacationId) => + post( + holidaysDeleteURL.toUrl, + jsonEncode({ + 'vacationId': vacationId, + })); + + // 获取考勤设置信息 + Future getCheckInSetInfoData( + String companyId) => + post( + getCheckInSetInfoURL.toUrl, + jsonEncode({ + 'companyId': companyId, + })); + + // 修改考勤设置信息 + Future editCheckInSetInfoData( + String attendanceType, + String companyId, + String type, + String companyName, + String workEndTime, + String workStartTime, + List workDay) => + post( + editCheckInSetInfoURL.toUrl, + jsonEncode({ + 'attendanceType': attendanceType, + 'companyId': companyId, + 'type': type, + 'companyName': companyName, + 'workEndTime': workEndTime, + 'workStartTime': workStartTime, + 'workDay': workDay, + })); + + // 获取考勤列表 -- 早到榜日榜 + Future getCheckInListEarlyArrivalWithDateData(String companyId, String attendanceDate) => + post( + getAttendanceRecordListByDateURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'attendanceDate': attendanceDate, + })); + + // 获取考勤列表 -- 早到榜月榜 + Future getCheckInListEarlyArrivalWithMonthData(String companyId, String attendanceDate) => + post( + getAttendanceRecordListByMonthURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'attendanceDate': attendanceDate, + })); + + // 获取考勤列表 -- 迟到榜日榜 + Future getCheckInListLateTimesWithDateData(String companyId, String attendanceDate) => + post( + getAttendanceRecordListLateTimesByDateURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'attendanceDate': attendanceDate, + })); + + // 获取考勤列表 -- 迟到榜月榜 + Future getCheckInListLateTimesWithMonthData(String companyId, String attendanceDate) => + post( + getAttendanceRecordListLateTimesByMonthURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'attendanceDate': attendanceDate, + })); + + // 获取考勤列表 -- 勤奋榜 + Future getCheckInListHardworkingData(String companyId, String attendanceDate, String type) => + post( + getAttendanceRecordHardworkingListURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'attendanceDate': attendanceDate, + 'type': type, + })); + + // 获取考勤详情 + Future getCheckInDetailData(String companyId, String attendanceDate, String staffId) => + post( + getAttendanceRecordDtailURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'attendanceDate': attendanceDate, + 'staffId': staffId, + })); + + // 获取指纹列表 + Future getFingerprintsListData(String lockId, String pageNo, String pageSize, String searchStr) => + post( + getFingerprintListURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'pageNo': pageNo, + 'pageSize': pageSize, + 'searchStr': searchStr, + })); + + // 添加指纹 + Future addFingerprintsData( + String lockId, + String endDate, + String addType, + String fingerprintName, + String fingerprintNumber, + String fingerprintType, + String isCoerced, + String startDate, + String cyclicConfig,) => + post( + addFingerprintURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'endDate': endDate, + 'addType': addType, + 'fingerprintName': fingerprintName, + 'fingerprintNumber': fingerprintNumber, + 'fingerprintType': fingerprintType, + 'isCoerced': isCoerced, + 'startDate': startDate, + 'cyclicConfig': cyclicConfig, + })); + Future listLockByGroup(String type, String keyGroupId) => post( listLockByGroupURL.toUrl, jsonEncode({'type': type, 'keyGroupId': keyGroupId})); Future getKeyDetail(String lockId) => - post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId}), - isShowLoading: true); + post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId})); Future lockUserList( String pageNo, String pageSize, String searchStr) => post( lockUserListURL.toUrl, jsonEncode( - {'pageNo': pageNo, 'pageSize': pageSize, 'searchStr': searchStr}), - isShowLoading: true); + {'pageNo': pageNo, 'pageSize': pageSize, 'searchStr': searchStr})); Future keyListByUser(String pageNo, String pageSize, String uid) => post(keyListByUserURL.toUrl, - jsonEncode({'pageNo': pageNo, 'pageSize': pageSize, 'uid': uid}), - isShowLoading: true); + jsonEncode({'pageNo': pageNo, 'pageSize': pageSize, 'uid': uid})); Future authorizedAdminList(String pageNo, String pageSize) => post( authorizedAdminListURL.toUrl, - jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}), - isShowLoading: true); + jsonEncode({'pageNo': pageNo, 'pageSize': pageSize})); Future canSendKey( String endDate, List keyGroupIdList, List lockIdList) => diff --git a/star_lock/lib/network/api_provider_base.dart b/star_lock/lib/network/api_provider_base.dart index 13b7ad68..a81089fa 100644 --- a/star_lock/lib/network/api_provider_base.dart +++ b/star_lock/lib/network/api_provider_base.dart @@ -28,9 +28,9 @@ class BaseProvider extends GetConnect with Api { Map? query, Decoder? decoder, Progress? uploadProgress, - bool? isShowLoading}) async { + bool? isUnShowLoading = false}) async { // print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}"); - if(isShowLoading == true) EasyLoading.show(); + if(isUnShowLoading == false) 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 2f6fbb09..2f3f776c 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -14,10 +14,18 @@ import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; import '../login/register/entity/SendValidationCodeEntity.dart'; +import '../main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart'; +import '../main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_entity.dart'; +import '../main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart'; +import '../main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart'; +import '../main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart'; +import '../main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSeletKey_entity.dart'; +import '../main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.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/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart'; import '../main/lockMian/entity/lockInfoEntity.dart'; import '../mine/addLock/saveLock/entity/SaveLockEntity.dart'; import 'api_provider.dart'; @@ -671,13 +679,83 @@ class ApiRepository { 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 getCheckInListEarlyArrivalWithDateData( + { + required String companyId, + required String attendanceDate, + }) async { + final res = + await apiProvider.getCheckInListEarlyArrivalWithDateData(companyId, attendanceDate); + return CheckingInListDayEntity.fromJson(res.body); + } + + // 获取考勤列表 - 早到榜月榜 + Future getCheckInListEarlyArrivalWithMonthData( + { + required String companyId, + required String attendanceDate, + }) async { + final res = + await apiProvider.getCheckInListEarlyArrivalWithMonthData(companyId, attendanceDate); + return CheckingInListMonthEntity.fromJson(res.body); + } + + // 获取考勤列表 - 迟到榜日榜 + Future getCheckInListLateTimesWithDateData( + { + required String companyId, + required String attendanceDate, + }) async { + final res = + await apiProvider.getCheckInListLateTimesWithDateData(companyId, attendanceDate); + return CheckingInListDayEntity.fromJson(res.body); + } + + // 获取考勤列表 - 迟到榜月榜 + Future getCheckInListLateTimesWithMonthData( + { + required String companyId, + required String attendanceDate, + }) async { + final res = + await apiProvider.getCheckInListLateTimesWithMonthData(companyId, attendanceDate); + return CheckingInListMonthEntity.fromJson(res.body); + } + + // 获取考勤列表 - 勤奋榜 + Future getCheckInListHardworkingData( + { + required String companyId, + required String attendanceDate, + required String type, + }) async { + final res = + await apiProvider.getCheckInListHardworkingData(companyId, attendanceDate, type); + return CheckingInListMonthEntity.fromJson(res.body); + } + + // 获取考勤详情 + Future getCheckInDetailData( + { + required String companyId, + required String attendanceDate, + required String staffId, + }) async { + final res = + await apiProvider.getCheckInDetailData(companyId, attendanceDate, staffId); + return CheckingInDetailEntity.fromJson(res.body); + } + + // 获取员工列表 + Future getStaffListData( + { + required String companyId, + required String lockId, + }) async { + final res = + await apiProvider.getStaffListData(companyId, lockId); + return CheckingInAddStaffListEntity.fromJson(res.body); } // 添加员工 @@ -694,4 +772,123 @@ class ApiRepository { companyId, have, staffName, countryCode, usernameType); return LoginEntity.fromJson(res.body); } + + // 编辑员工 + Future editStaffData( + { + required String attendanceType, + required String attendanceWay, + required String staffId, + required String have, + required String staffName, + required String countryCode, + required String usernameType, + }) async { + final res = + await apiProvider.editStaffData(attendanceType, attendanceWay, staffId, have, staffName, countryCode, usernameType); + return LoginEntity.fromJson(res.body); + } + + // 添加员工选择钥匙 + Future addStaffSeletKeyData( + { + required String companyId, + required String type, + }) async { + final res = + await apiProvider.addStaffSeletKeyData(companyId, type); + return CheckingInAddStaffSeletKeyEntity.fromJson(res.body); + } + + // 添加假期 + Future addHolidaysData( + { + required String companyId, + required String fillClassDate, + required String vacationEndDate, + required String vacationName, + required String vacationStartDate, + }) async { + final res = + await apiProvider.addHolidaysData(companyId, fillClassDate, vacationEndDate, vacationName, vacationStartDate); + return LoginEntity.fromJson(res.body); + } + + // 假期列表 + Future holidaysListData( + { + required String companyId, + required String vacationYear, + }) async { + final res = + await apiProvider.holidaysListData(companyId, vacationYear); + return CheckingInSetHolidaysInfoDataEntity.fromJson(res.body); + } + + // 删除假期 + Future deletHolidaysData( + { + required String vacationId + }) async { + final res = + await apiProvider.deletHolidaysData(vacationId); + return LoginEntity.fromJson(res.body); + } + + // 获取考勤设置信息 + Future getCheckInSetInfoData( + { + required String companyId, + }) async { + final res = + await apiProvider.getCheckInSetInfoData(companyId); + return CheckingInSetEntity.fromJson(res.body); + } + + // 修改考勤设置信息 + Future editCheckInSetInfoData( + { + required String attendanceType, + required String companyId, + required String type, + required String companyName, + required String workEndTime, + required String workStartTime, + required List workDay, + }) async { + final res = + await apiProvider.editCheckInSetInfoData(attendanceType, companyId, type, companyName, workEndTime, workStartTime, workDay); + return CheckingInSetEntity.fromJson(res.body); + } + + // 获取指纹列表 + Future getFingerprintsListData( + { + required String lockId, + required String pageNo, + required String pageSize, + required String searchStr, + }) async { + final res = + await apiProvider.getFingerprintsListData(lockId, pageNo, pageSize, searchStr); + return FingerprintListDataEntity.fromJson(res.body); + } + + // 添加指纹 + Future addFingerprintsData( + { + required String lockId, + required String endDate, + required String addType, + required String fingerprintName, + required String fingerprintNumber, + required String fingerprintType, + required String isCoerced, + required String startDate, + required String cyclicConfig, + }) async { + final res = + await apiProvider.addFingerprintsData(lockId, endDate, addType, fingerprintName, fingerprintNumber, fingerprintType, isCoerced, startDate, cyclicConfig); + return CheckingInListMonthEntity.fromJson(res.body); + } } diff --git a/star_lock/lib/network/request_interceptor.dart b/star_lock/lib/network/request_interceptor.dart index 84c70a45..f77d4faa 100644 --- a/star_lock/lib/network/request_interceptor.dart +++ b/star_lock/lib/network/request_interceptor.dart @@ -4,6 +4,7 @@ import 'package:get/get.dart'; import 'package:get/get_connect/http/src/request/request.dart'; import 'package:star_lock/login/login/entity/LoginData.dart'; +import '../login/login/entity/LoginData.dart'; import '../login/login/entity/LoginEntity.dart'; import '../tools/platform_info_services.dart'; import '../tools/storage.dart'; @@ -19,10 +20,7 @@ FutureOr requestInterceptor(Request request) async { String? xToken = ''; final data = await Storage.getString('userLoginData'); if (data != null && data.isNotEmpty) { - LoginData loginData = LoginData.fromJson(jsonDecode(data)); - xToken = loginData.accessToken; - - // xToken = LoginEntity.fromJson(jsonDecode(data)).data!.accessToken; + xToken = LoginData.fromJson(jsonDecode(data)).accessToken; } request.headers['Authorization'] = "Bearer ${xToken ?? ''}"; return request; diff --git a/star_lock/lib/tools/commonItem.dart b/star_lock/lib/tools/commonItem.dart index 0c5b8d68..50eac58f 100644 --- a/star_lock/lib/tools/commonItem.dart +++ b/star_lock/lib/tools/commonItem.dart @@ -59,7 +59,7 @@ class CommonItem extends StatelessWidget { isHaveRightWidget! ? rightWidget! : Text( - rightTitle!, + rightTitle ?? "", textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, maxLines: 1, diff --git a/star_lock/lib/tools/customNetworkImage.dart b/star_lock/lib/tools/customNetworkImage.dart new file mode 100644 index 00000000..a7827be7 --- /dev/null +++ b/star_lock/lib/tools/customNetworkImage.dart @@ -0,0 +1,34 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +/* +* 显示网络图片 并加缓存 +* */ + +class CustomNetworkImage extends StatelessWidget { + final String url; + final double width; + final double height; + final BoxFit boxFit; + const CustomNetworkImage({Key? key, required this.url, required this.width, required this.height, this.boxFit=BoxFit.cover}) : super(key: key); + + @override + Widget build(BuildContext context) { + return CachedNetworkImage( + width: width, + height: height, + fit: boxFit, + imageUrl: url, + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, + fit: boxFit, + colorFilter: const ColorFilter.mode(Colors.transparent, BlendMode.colorBurn)), + ), + ), + errorWidget: (context, url, error) => Icon(Icons.error,size: 40.sp) + ); + } +} diff --git a/star_lock/lib/tools/dateTool.dart b/star_lock/lib/tools/dateTool.dart index ae6dd6cb..be4f6473 100644 --- a/star_lock/lib/tools/dateTool.dart +++ b/star_lock/lib/tools/dateTool.dart @@ -24,7 +24,7 @@ class DateTool { return "$year.$month.$day $hour:$minute"; } - String dateToString(String timeDate){ + String dateToYMDHNSString(String timeDate){ int time = int.parse(timeDate); DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); @@ -32,4 +32,27 @@ class DateTool { return appointmentDate; } + + String dateToYMDHNString(String timeDate){ + int time = int.parse(timeDate); + DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); + + String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd,' ',HH,':',nn]); + + return appointmentDate; + } + + String dateToYMDString(String timeDate){ + int time = int.parse(timeDate); + DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); + String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd]); + return appointmentDate; + } + + String dateToHNString(String timeDate){ + int time = int.parse(timeDate); + DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); + String appointmentDate = formatDate(nowDate, [HH,':',nn]); + return appointmentDate; + } } \ No newline at end of file diff --git a/star_lock/lib/tools/eventBusEventManage.dart b/star_lock/lib/tools/eventBusEventManage.dart index b3981bfa..3ab53173 100644 --- a/star_lock/lib/tools/eventBusEventManage.dart +++ b/star_lock/lib/tools/eventBusEventManage.dart @@ -9,6 +9,11 @@ class RefreshLockListInfoDataEvent{ RefreshLockListInfoDataEvent(); } +/// 刷新考勤员工列表 +class RefreshCheckInStaffListDataEvent{ + RefreshCheckInStaffListDataEvent(); +} + /// 传递当前锁信息 class PassCurrentLockInformationEvent{ KeyInfos keyInfo; diff --git a/star_lock/lib/tools/noData.dart b/star_lock/lib/tools/noData.dart index cf4cf53a..11829f91 100644 --- a/star_lock/lib/tools/noData.dart +++ b/star_lock/lib/tools/noData.dart @@ -10,7 +10,7 @@ class NoData extends StatelessWidget { width: 1.sw, height: 1.sh - ScreenUtil().statusBarHeight, child: Center( - child: Image.asset('images/noData.png',width: 300.w,height: 240.w), + child: Image.asset('images/icon_unHaveData.png',width: 300.w,height: 240.w), ), ); } diff --git a/star_lock/lib/translations/lanKeyEntity.dart b/star_lock/lib/translations/lanKeyEntity.dart index b8bcbaf7..543a9043 100644 --- a/star_lock/lib/translations/lanKeyEntity.dart +++ b/star_lock/lib/translations/lanKeyEntity.dart @@ -185,7 +185,7 @@ class LanKeyEntity { this.workingHoursWereNotReleased, this.beLate, this.leaveEarly, - this.noCardPunched, + this.noCardPunched, this.holidayInfo, this.lanEnglish, this.lanChinese, this.multilingual, @@ -387,6 +387,8 @@ class LanKeyEntity { this.wifiPwd, this.pleaseEnterWifiPwd, this.wifiDistributionNetwork, + this.attendanceRecord, + this.edit }); LanKeyEntity.fromJson(dynamic json) { @@ -581,6 +583,7 @@ class LanKeyEntity { beLate = json['beLate']; leaveEarly = json['leaveEarly']; noCardPunched = json['noCardPunched']; + holidayInfo = json['holidayInfo']; lanEnglish = json['lanEnglish']; lanChinese = json['lanChinese']; @@ -806,6 +809,8 @@ class LanKeyEntity { wifiPwd = json['wifiPwd']; pleaseEnterWifiPwd = json['pleaseEnterWifiPwd']; wifiDistributionNetwork = json['wifiDistributionNetwork']; + attendanceRecord = json['attendanceRecord']; + edit = json['edit']; } String? starLock; String? clickUnlockAndHoldDownClose; @@ -957,6 +962,7 @@ class LanKeyEntity { String? beLate; String? leaveEarly; String? noCardPunched; + String? holidayInfo; String? basicInformation; String? wirelessKeyboard; @@ -1211,7 +1217,8 @@ class LanKeyEntity { String? wifiPwd; String? pleaseEnterWifiPwd; String? wifiDistributionNetwork; - + String? attendanceRecord; + String? edit; Map toJson() { final map = {}; map['starLock'] = starLock; @@ -1404,6 +1411,7 @@ class LanKeyEntity { map['beLate'] = beLate; map['leaveEarly'] = leaveEarly; map['noCardPunched'] = noCardPunched; + map['holidayInfo'] = holidayInfo; map['lanEnglish'] = lanEnglish; map['lanChinese'] = lanChinese; @@ -1627,6 +1635,8 @@ class LanKeyEntity { map['wifiPwd'] = wifiPwd; map['pleaseEnterWifiPwd'] = pleaseEnterWifiPwd; map['wifiDistributionNetwork'] = wifiDistributionNetwork; + map['attendanceRecord'] = attendanceRecord; + map['edit'] = edit; return map; } } diff --git a/star_lock/macos/Flutter/GeneratedPluginRegistrant.swift b/star_lock/macos/Flutter/GeneratedPluginRegistrant.swift index f3092101..127e12ed 100644 --- a/star_lock/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/star_lock/macos/Flutter/GeneratedPluginRegistrant.swift @@ -12,6 +12,7 @@ import network_info_plus import package_info_plus import path_provider_foundation import shared_preferences_foundation +import sqflite import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -22,5 +23,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 467485ca..b294cf15 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -104,6 +104,9 @@ dependencies: # 允许App发现网络的相关信息并且进行相应的配置 network_info_plus: ^4.0.2 + + #网络图片缓存 + cached_network_image: ^3.2.0 dev_dependencies: flutter_test: sdk: flutter