|
@@ -1,28 +1,26 @@
|
|
import 'dart:typed_data';
|
|
import 'dart:typed_data';
|
|
|
|
|
|
-import 'package:domain/entity/response/attendance_entity.dart';
|
|
|
|
-import 'package:domain/entity/response/check_success_entity.dart';
|
|
|
|
-import 'package:domain/repository/job_repository.dart';
|
|
|
|
|
|
+import 'package:domain/entity/response/u_k_attendance_entity.dart';
|
|
|
|
+import 'package:domain/entity/response/u_k_security_attendance_option_entity.dart';
|
|
|
|
+import 'package:domain/repository/uk_attendance_repository.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get/get.dart';
|
|
-import 'package:plugin_basic/service/user_service.dart';
|
|
|
|
import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
|
|
import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
|
|
-import 'package:plugin_platform/engine/toast/toast_engine.dart';
|
|
|
|
import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
|
|
import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
|
|
|
|
+import 'package:plugin_platform/http/http_result.dart';
|
|
import 'package:shared/utils/date_time_utils.dart';
|
|
import 'package:shared/utils/date_time_utils.dart';
|
|
import 'package:shared/utils/log_utils.dart';
|
|
import 'package:shared/utils/log_utils.dart';
|
|
import 'package:widgets/load_state_layout.dart';
|
|
import 'package:widgets/load_state_layout.dart';
|
|
-import 'package:widgets/picker/date_picker_util.dart';
|
|
|
|
import 'package:widgets/widget_export.dart';
|
|
import 'package:widgets/widget_export.dart';
|
|
|
|
|
|
import '../../job/job_applied_staff_detail/applied_staff_detail_page.dart';
|
|
import '../../job/job_applied_staff_detail/applied_staff_detail_page.dart';
|
|
import 'e_attendance_list_state.dart';
|
|
import 'e_attendance_list_state.dart';
|
|
-import 'widget/attendance_sign_in_out.dart';
|
|
|
|
import 'widget/job_list_filter.dart';
|
|
import 'widget/job_list_filter.dart';
|
|
|
|
|
|
class EAttendanceListController extends GetxController with DioCancelableMixin {
|
|
class EAttendanceListController extends GetxController with DioCancelableMixin {
|
|
- final JobRepository _jobRepository = Get.find();
|
|
|
|
|
|
+ final UKAttendanceRepository _attendanceRepository = Get.find();
|
|
final EAttendanceListState state = EAttendanceListState();
|
|
final EAttendanceListState state = EAttendanceListState();
|
|
|
|
|
|
|
|
+ var _curPage = 1;
|
|
var _needShowPlaceholder = true;
|
|
var _needShowPlaceholder = true;
|
|
|
|
|
|
//页面PlaceHolder的展示
|
|
//页面PlaceHolder的展示
|
|
@@ -38,16 +36,24 @@ class EAttendanceListController extends GetxController with DioCancelableMixin {
|
|
// Refresh 控制器
|
|
// Refresh 控制器
|
|
final EasyRefreshController refreshController = EasyRefreshController(
|
|
final EasyRefreshController refreshController = EasyRefreshController(
|
|
controlFinishRefresh: true,
|
|
controlFinishRefresh: true,
|
|
- controlFinishLoad: false,
|
|
|
|
|
|
+ controlFinishLoad: true,
|
|
);
|
|
);
|
|
|
|
|
|
// Refresh 刷新事件
|
|
// Refresh 刷新事件
|
|
Future onRefresh() async {
|
|
Future onRefresh() async {
|
|
|
|
+ _curPage = 1;
|
|
|
|
+ fetchAttendanceList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Refresh 加载事件
|
|
|
|
+ Future loadMore() async {
|
|
|
|
+ _curPage++;
|
|
fetchAttendanceList();
|
|
fetchAttendanceList();
|
|
}
|
|
}
|
|
|
|
|
|
// 重试请求
|
|
// 重试请求
|
|
Future retryRequest() async {
|
|
Future retryRequest() async {
|
|
|
|
+ _curPage = 1;
|
|
_needShowPlaceholder = true;
|
|
_needShowPlaceholder = true;
|
|
fetchAttendanceList();
|
|
fetchAttendanceList();
|
|
}
|
|
}
|
|
@@ -58,77 +64,76 @@ class EAttendanceListController extends GetxController with DioCancelableMixin {
|
|
changeLoadingState(LoadState.State_Loading);
|
|
changeLoadingState(LoadState.State_Loading);
|
|
}
|
|
}
|
|
|
|
|
|
- //获取到数据
|
|
|
|
- var result = await _jobRepository.fetchAttendanceList(
|
|
|
|
- state.keyword,
|
|
|
|
- DateTimeUtils.formatDate(state.selectedStartDate, format: "yyyy-MM-dd"),
|
|
|
|
- DateTimeUtils.formatDate(state.selectedEndDate, format: "yyyy-MM-dd"),
|
|
|
|
- cancelToken: cancelToken,
|
|
|
|
- );
|
|
|
|
|
|
+ // 并发执行两个请求
|
|
|
|
+ var futures = [
|
|
|
|
+ _attendanceRepository.fetchAttendanceList(
|
|
|
|
+ startDate: DateTimeUtils.formatDate(state.selectedStartDate, format: "yyyy-MM-dd"),
|
|
|
|
+ endDate: DateTimeUtils.formatDate(state.selectedEndDate, format: "yyyy-MM-dd"),
|
|
|
|
+ keyword: state.selectedStaffName,
|
|
|
|
+ departmentId: state.selectedDepartmentId,
|
|
|
|
+ curPage: _curPage,
|
|
|
|
+ cancelToken: cancelToken,
|
|
|
|
+ ),
|
|
|
|
+ state.indexOptions == null
|
|
|
|
+ ? _attendanceRepository.fetchAttendanceOptions(
|
|
|
|
+ cancelToken: cancelToken,
|
|
|
|
+ )
|
|
|
|
+ : Future(() => HttpResult(isSuccess: true).convert(data: state.indexOptions!)),
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ //拿到结果
|
|
|
|
+ var results = await Future.wait(futures);
|
|
|
|
+ var listResult = results[0] as HttpResult<UKAttendanceEntity>;
|
|
|
|
+ var optionResult = results[1] as HttpResult<UKSecurityAttendanceOptionEntity>;
|
|
|
|
+
|
|
|
|
+ //选项数据
|
|
|
|
+ if (state.indexOptions == null && optionResult.isSuccess) {
|
|
|
|
+ state.indexOptions = optionResult.data!;
|
|
|
|
+ }
|
|
|
|
|
|
- //处理数据
|
|
|
|
- if (result.isSuccess) {
|
|
|
|
- handleList(result.data?.rows);
|
|
|
|
- refreshController.finishRefresh(IndicatorResult.success);
|
|
|
|
|
|
+ // 处理数据
|
|
|
|
+ if (listResult.isSuccess) {
|
|
|
|
+ handleList(listResult.data?.rows);
|
|
} else {
|
|
} else {
|
|
- errorMessage = result.errorMsg;
|
|
|
|
|
|
+ errorMessage = listResult.errorMsg;
|
|
changeLoadingState(LoadState.State_Error);
|
|
changeLoadingState(LoadState.State_Error);
|
|
- refreshController.finishRefresh(IndicatorResult.fail);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- //最后赋值
|
|
|
|
|
|
+ // 最后赋值
|
|
_needShowPlaceholder = false;
|
|
_needShowPlaceholder = false;
|
|
}
|
|
}
|
|
|
|
|
|
// 处理数据与展示的逻辑
|
|
// 处理数据与展示的逻辑
|
|
- void handleList(List<AttendanceList>? list) {
|
|
|
|
|
|
+ void handleList(List<UKAttendanceRows>? list) {
|
|
if (list != null && list.isNotEmpty) {
|
|
if (list != null && list.isNotEmpty) {
|
|
//有数据,判断是刷新还是加载更多的数据
|
|
//有数据,判断是刷新还是加载更多的数据
|
|
- state.datas.clear();
|
|
|
|
- state.datas.addAll(list);
|
|
|
|
- //更新状态
|
|
|
|
- changeLoadingState(LoadState.State_Success);
|
|
|
|
- } else {
|
|
|
|
- //展示无数据的布局
|
|
|
|
- state. datas.clear();
|
|
|
|
- changeLoadingState(LoadState.State_Empty);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// 签到签出
|
|
|
|
- void requestCheckInCheckOut(bool isCheckIn, AttendanceList item, ByteData byteData) async {
|
|
|
|
- //请求接口
|
|
|
|
-
|
|
|
|
- var result = await _jobRepository.submitCheckInOut(
|
|
|
|
- item.appliedId.toString(),
|
|
|
|
- byteData,
|
|
|
|
- isCheckIn: isCheckIn,
|
|
|
|
- cancelToken: cancelToken,
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- if (result.isSuccess) {
|
|
|
|
- CheckSuccessEntity entity = result.data!;
|
|
|
|
- if (isCheckIn) {
|
|
|
|
- item.checkInImg = entity.checkImg;
|
|
|
|
- item.checkInTime = entity.checkTime;
|
|
|
|
|
|
+ if (_curPage == 1) {
|
|
|
|
+ //刷新的方式
|
|
|
|
+ state.datas.clear();
|
|
|
|
+ state.datas.addAll(list);
|
|
|
|
+ refreshController.finishRefresh();
|
|
|
|
+
|
|
|
|
+ //更新展示的状态
|
|
|
|
+ changeLoadingState(LoadState.State_Success);
|
|
} else {
|
|
} else {
|
|
- item.checkOutImg = entity.checkImg;
|
|
|
|
- item.checkOutTime = entity.checkTime;
|
|
|
|
|
|
+ //加载更多
|
|
|
|
+ state.datas.addAll(list);
|
|
|
|
+ refreshController.finishLoad();
|
|
|
|
+ update();
|
|
}
|
|
}
|
|
- //更新状态
|
|
|
|
- update();
|
|
|
|
} else {
|
|
} else {
|
|
- errorMessage = result.errorMsg;
|
|
|
|
- ToastEngine.show(errorMessage ?? "Network Load Error".tr);
|
|
|
|
|
|
+ if (_curPage == 1) {
|
|
|
|
+ //展示无数据的布局
|
|
|
|
+ state.datas.clear();
|
|
|
|
+ changeLoadingState(LoadState.State_Empty);
|
|
|
|
+ refreshController.finishRefresh();
|
|
|
|
+ } else {
|
|
|
|
+ //展示加载完成,没有更多数据了
|
|
|
|
+ refreshController.finishLoad(IndicatorResult.noMore);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //执行搜索
|
|
|
|
- void doSearch(String keyword) {
|
|
|
|
- state.keyword = keyword;
|
|
|
|
- refreshController.callRefresh();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@override
|
|
@override
|
|
void onReady() async {
|
|
void onReady() async {
|
|
super.onReady();
|
|
super.onReady();
|
|
@@ -141,37 +146,17 @@ class EAttendanceListController extends GetxController with DioCancelableMixin {
|
|
state.datas.clear();
|
|
state.datas.clear();
|
|
}
|
|
}
|
|
|
|
|
|
- /// 用户签到
|
|
|
|
- void userSignIn(AttendanceList item) {
|
|
|
|
- DialogEngine.show(
|
|
|
|
- widget: AttendanceSignInOut(
|
|
|
|
- confirmAction: (byteData) {
|
|
|
|
- requestCheckInCheckOut(true, item, byteData);
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// 用户签出
|
|
|
|
- void userSignOut(AttendanceList item) {
|
|
|
|
- DialogEngine.show(
|
|
|
|
- widget: AttendanceSignInOut(
|
|
|
|
- confirmAction: (byteData) {
|
|
|
|
- requestCheckInCheckOut(false, item, byteData);
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/// 展示标题栏的 Filter 弹窗
|
|
/// 展示标题栏的 Filter 弹窗
|
|
void showFilterDialog() {
|
|
void showFilterDialog() {
|
|
|
|
+ if (state.indexOptions == null) return;
|
|
|
|
+
|
|
DialogEngine.show(
|
|
DialogEngine.show(
|
|
widget: JobListFilter(
|
|
widget: JobListFilter(
|
|
selectedStartDate: state.selectedStartDate,
|
|
selectedStartDate: state.selectedStartDate,
|
|
selectedEndDate: state.selectedEndDate,
|
|
selectedEndDate: state.selectedEndDate,
|
|
staffName: state.selectedStaffName,
|
|
staffName: state.selectedStaffName,
|
|
selectedDepartmentId: state.selectedDepartmentId,
|
|
selectedDepartmentId: state.selectedDepartmentId,
|
|
|
|
+ departmentList: state.indexOptions?.departmentList,
|
|
onFilterAction: (startDate, endDate, staffName, departmentId) {
|
|
onFilterAction: (startDate, endDate, staffName, departmentId) {
|
|
Log.d("startDate:$startDate endDate:$endDate staffName:$staffName departmentId:$departmentId");
|
|
Log.d("startDate:$startDate endDate:$endDate staffName:$staffName departmentId:$departmentId");
|
|
|
|
|
|
@@ -189,9 +174,9 @@ class EAttendanceListController extends GetxController with DioCancelableMixin {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- //查看UK员工的详情
|
|
|
|
- void gotoStaffDetailPage(AttendanceList data) {
|
|
|
|
- UKAppliedStaffDetailPage.startInstance(data.staffId.toString());
|
|
|
|
|
|
+ // 去查看员工的详情
|
|
|
|
+ void gotoStaffDetailPage(UKAttendanceRows data) {
|
|
|
|
+ UKAppliedStaffDetailPage.startInstance(data.memberId);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|