2023-09-09 18:33:37 +08:00
|
|
|
|
|
|
|
|
import 'package:get/get.dart';
|
2024-08-21 14:12:15 +08:00
|
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
2023-09-09 18:33:37 +08:00
|
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../network/api_repository.dart';
|
|
|
|
|
import '../../../../tools/eventBusEventManage.dart';
|
|
|
|
|
import 'checkInCreatCompany_state.dart';
|
|
|
|
|
|
|
|
|
|
class CheckInCreatCompanyLogic extends BaseGetXController{
|
|
|
|
|
CheckInCreatCompanyState state = CheckInCreatCompanyState();
|
|
|
|
|
|
|
|
|
|
// 设置考勤创建公司
|
2024-08-21 14:12:15 +08:00
|
|
|
Future<void> setCheckInCreateCompany() async{
|
2024-03-28 13:46:35 +08:00
|
|
|
if(state.companyNameController.text.length > 50){
|
2024-08-21 14:12:15 +08:00
|
|
|
showToast('公司名称不能超过30个字符'.tr);
|
2024-03-28 13:46:35 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(state.companyNameController.text.length < 6){
|
2024-08-21 14:12:15 +08:00
|
|
|
showToast('公司名称不能小于6个字符'.tr);
|
2024-03-28 13:46:35 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-21 14:12:15 +08:00
|
|
|
final LoginEntity entity = await ApiRepository.to.setCheckInCreateCompanyData(
|
2023-11-01 17:28:59 +08:00
|
|
|
lockId: state.lockSetInfoData.value.lockId.toString(),
|
2024-08-21 14:12:15 +08:00
|
|
|
attendanceType: state.isCustom.value ? '0' :'1',
|
2023-09-09 18:33:37 +08:00
|
|
|
companyName: state.companyNameController.text,
|
|
|
|
|
workDay: state.weekDays.value,
|
|
|
|
|
workEndTime: state.endTimeTimestamp.value,
|
|
|
|
|
workStartTime: state.beginTimeTimestamp.value,
|
|
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
2024-08-21 14:12:15 +08:00
|
|
|
showToast('创建成功'.tr, something: (){
|
2024-03-28 13:46:35 +08:00
|
|
|
setLockSetGeneralSetting();
|
|
|
|
|
});
|
2023-09-09 18:33:37 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置考勤
|
2024-08-21 14:12:15 +08:00
|
|
|
Future<void> setLockSetGeneralSetting() async{
|
|
|
|
|
final LoginEntity entity = await ApiRepository.to.setCheckInData(
|
2023-11-03 13:58:41 +08:00
|
|
|
lockId: state.lockSetInfoData.value.lockId!,
|
|
|
|
|
attendance:1,
|
2023-09-09 18:33:37 +08:00
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
|
|
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
|
|
|
|
|
2023-11-01 17:28:59 +08:00
|
|
|
state.lockSetInfoData.value.lockSettingInfo!.attendance = 1;
|
|
|
|
|
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
2024-08-21 14:12:15 +08:00
|
|
|
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, '1'));
|
2023-09-09 18:33:37 +08:00
|
|
|
Get.back();
|
2024-08-21 14:12:15 +08:00
|
|
|
showToast('设置成功'.tr);
|
2023-09-09 18:33:37 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-01-23 18:37:03 +08:00
|
|
|
|
|
|
|
|
void ifCanNext() {
|
|
|
|
|
if(state.companyNameController.text.isNotEmpty &&
|
|
|
|
|
state.weekDays.value.isNotEmpty &&
|
|
|
|
|
state.beginTimeTimestamp.value.isNotEmpty &&
|
|
|
|
|
state.endTimeTimestamp.value.isNotEmpty) {
|
|
|
|
|
state.canNext.value = true;
|
|
|
|
|
}else{
|
|
|
|
|
state.canNext.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-09 18:33:37 +08:00
|
|
|
}
|