app-starlock/lib/main/lockDetail/lockSet/checkInCreatCompany/checkInCreatCompany_logic.dart

67 lines
2.2 KiB
Dart
Raw Normal View History

import 'package:get/get.dart';
import 'package:star_lock/login/login/entity/LoginEntity.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();
// 设置考勤创建公司
Future<void> setCheckInCreateCompany() async{
if(state.companyNameController.text.length > 50){
showToast('公司名称不能超过30个字符'.tr);
return;
}
if(state.companyNameController.text.length < 6){
showToast('公司名称不能小于6个字符'.tr);
return;
}
final LoginEntity entity = await ApiRepository.to.setCheckInCreateCompanyData(
2023-11-01 17:28:59 +08:00
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();
});
}
}
// 设置考勤
Future<void> setLockSetGeneralSetting() async{
final LoginEntity entity = await ApiRepository.to.setCheckInData(
lockId: state.lockSetInfoData.value.lockId!,
attendance:1,
);
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));
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, '1'));
Get.back();
showToast('设置成功'.tr);
}
}
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;
}
}
}