import 'package:get/get.dart'; 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(); // 设置考勤创建公司 void setCheckInCreateCompany() async{ if(state.companyNameController.text.length > 50){ showToast("公司名称不能超过30个字符".tr); return; } if(state.companyNameController.text.length < 6){ showToast("公司名称不能小于6个字符".tr); return; } var entity = await ApiRepository.to.setCheckInCreateCompanyData( lockId: state.lockSetInfoData.value.lockId.toString(), attendanceType: state.isCustom.value ? "0" :"1", companyName: state.companyNameController.text, workDay: state.weekDays.value, workEndTime: state.endTimeTimestamp.value, workStartTime: state.beginTimeTimestamp.value, ); if(entity.errorCode!.codeIsSuccessful){ showToast("创建成功".tr, something: (){ setLockSetGeneralSetting(); }); } } // 设置考勤 void setLockSetGeneralSetting() async{ var entity = await ApiRepository.to.setCheckInData( lockId: state.lockSetInfoData.value.lockId!, attendance:1, ); if(entity.errorCode!.codeIsSuccessful){ eventBus.fire(RefreshLockListInfoDataEvent()); state.lockSetInfoData.value.lockSettingInfo!.attendance = 1; eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, "1")); Get.back(); showToast("设置成功".tr); } } 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; } } }