104 lines
3.4 KiB
Dart
104 lines
3.4 KiB
Dart
|
|
import 'dart:async';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../../network/api_repository.dart';
|
|
import '../../../../tools/baseGetXController.dart';
|
|
import '../../../../tools/dateTool.dart';
|
|
import '../../../../tools/eventBusEventManage.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.isCustom.value = (state.checkingInSetInfo.value.attendanceType! == 0) ? true : false;
|
|
|
|
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;
|
|
showToast("修改成功");
|
|
}
|
|
}
|
|
|
|
// 删除公司
|
|
void deletCompanyData() async{
|
|
var entity = await ApiRepository.to.deletCompanyData(
|
|
companyId:state.checkingInSetInfo.value.companyId!,
|
|
);
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, "0"));
|
|
Get.close(2);
|
|
}
|
|
}
|
|
|
|
late StreamSubscription _teamEvent;
|
|
void _initLoadDataAction() {
|
|
_teamEvent = eventBus.on<RefreshCheckInSetDataEvent>().listen((event) {
|
|
getCheckInSetInfoData();
|
|
});
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
// TODO: implement onReady
|
|
super.onReady();
|
|
|
|
_initLoadDataAction();
|
|
openCheckingInData();
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
// TODO: implement onInit
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
// TODO: implement onClose
|
|
_teamEvent.cancel();
|
|
}
|
|
} |