魏少阳 fe7cb98cf9 1、修改关于时间的3点讨论结果
a,领锁,点击+号时,如果获取网络时间失败,不进入下一页,提示必须联网
b. 开锁时:有网络时间则同步,无网络则不同步时间
c. 同步时间功能:必须有网才同步时间,确定和通通锁不一致
2、修改登录、注册、修改密码选择跟当前ip不是用一个国家的时候,弹窗提示
2024-06-07 10:53:24 +08:00

137 lines
5.0 KiB
Dart
Executable File

import 'dart:async';
import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart';
import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/storage.dart';
import 'checkingInList_state.dart';
class CheckingInListLogic extends BaseGetXController{
CheckingInListState state = CheckingInListState();
// 开启考勤获取是否有公司
Future<void> openCheckingInData() async{
final CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData(
lockId:state.getKeyInfosData.value.lockId.toString(),
);
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();
}
}
// 获取考勤信息列表--早到榜(按日期查询)
Future<void> getCheckInListEarlyArrivalWithDateData() async{
final CheckingInListDayEntity 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!;
}
}
// 获取考勤信息列表--早到榜(按月榜查询)
Future<void> getCheckInListEarlyArrivalWithMonthData() async{
final CheckingInListMonthEntity entity = await ApiRepository.to.getCheckInListEarlyArrivalWithMonthData(
companyId: state.companyId.value,
attendanceDate:state.checkListDateTimestamp.value.toString(),
);
if(entity.errorCode!.codeIsSuccessful){
state.checkingInMonthListData.value = entity.data!;
}
}
// 获取考勤信息列表--迟到榜(按日期查询)
Future<void> getCheckInListLateTimesWithDateData() async{
final CheckingInListDayEntity 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!;
}
}
// 获取考勤信息列表--迟到榜(按月榜查询)
Future<void> getCheckInListLateTimesWithMonthData() async{
final CheckingInListMonthEntity entity = await ApiRepository.to.getCheckInListLateTimesWithMonthData(
companyId: state.companyId.value,
attendanceDate:state.checkListDateTimestamp.value.toString(),
);
if(entity.errorCode!.codeIsSuccessful){
state.checkingInMonthListData.value = entity.data!;
}
}
// 获取考勤信息列表--勤奋榜(按月榜查询)
Future<void> getCheckInListHardworkingData() async{
final CheckingInListMonthEntity 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!;
}
}
late StreamSubscription _teamEvent;
void _initLoadDataAction() {
_teamEvent = eventBus.on<RefreshCheckInListEvent>().listen((RefreshCheckInListEvent event) {
loadDataByType();
});
}
@override
Future<void> onReady() async {
super.onReady();
// 获取是否是演示模式 演示模式不获取接口
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if(isDemoMode == false){
_initLoadDataAction();
openCheckingInData();
}
}
@override
void onClose() {
super.onClose();
_teamEvent.cancel();
}
}