93 lines
3.1 KiB
Dart

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<RefreshCheckInStaffListDataEvent>().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();
}
}