考勤管理添加迟到或早退标识

hmxc
张萌 3 years ago
parent a9ca0ee61e
commit bfb113ba3c

@ -0,0 +1,59 @@
import 'package:common_utils/common_utils.dart';
import 'package:json_annotation/json_annotation.dart';
part 'today_clock_record_model.g.dart';
@JsonSerializable()
class TodayClockRecordModel {
final int id;
final String? startClockDate;
final String? endClockDate;
final String? cardReplacementDate;
final String? operatorName;
final String clockName;
final String clockTel;
final String createDate;
final String status;
final String? firstTimeStart;
final String? firstTimeEnd;
final String? secondTimeStart;
final String? secondTimeEnd;
TodayClockRecordModel({
required this.id,
required this.startClockDate,
required this.endClockDate,
required this.cardReplacementDate,
required this.operatorName,
required this.clockName,
required this.clockTel,
required this.createDate,
required this.status,
required this.firstTimeStart,
required this.firstTimeEnd,
required this.secondTimeStart,
required this.secondTimeEnd,
});
factory TodayClockRecordModel.fromJson(Map<String, dynamic> json) =>
_$TodayClockRecordModelFromJson(json);
DateTime? get clockInTime => DateUtil.getDateTime(this.startClockDate ?? '');
DateTime? get clockOutTime => DateUtil.getDateTime(this.endClockDate ?? '');
DateTime? get startTime {
if (firstTimeStart != null) {
return DateUtil.getDateTime(firstTimeStart!);
} else if (secondTimeStart != null) {
return DateUtil.getDateTime(secondTimeStart!);
} else {
return null;
}
}
DateTime? get endTime {
if (firstTimeEnd != null) {
return DateUtil.getDateTime(firstTimeEnd!);
} else if (secondTimeEnd != null) {
return DateUtil.getDateTime(secondTimeEnd!);
} else {
return null;
}
}
}

@ -0,0 +1,26 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'today_clock_record_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
TodayClockRecordModel _$TodayClockRecordModelFromJson(
Map<String, dynamic> json) {
return TodayClockRecordModel(
id: json['id'] as int,
startClockDate: json['startClockDate'] as String,
endClockDate: json['endClockDate'] as String,
cardReplacementDate: json['cardReplacementDate'] as String,
operatorName: json['operatorName'] as String,
clockName: json['clockName'] as String,
clockTel: json['clockTel'] as String,
createDate: json['createDate'] as String,
status: json['status'] as String,
firstTimeStart: json['firstTimeStart'] as String,
firstTimeEnd: json['firstTimeEnd'] as String,
secondTimeStart: json['secondTimeStart'] as String,
secondTimeEnd: json['secondTimeEnd'] as String,
);
}

@ -1,185 +0,0 @@
// // Flutter imports:
// import 'package:flutter/material.dart';
// // Project imports:
// import 'package:aku_community_manager/const/resource.dart';
// enum DecorationType {
// ///
// WAIT_HAND_OUT,
// ///&
// HAND_OUT,
// ///
// DONE,
// }
// enum DecorationStatusType {
// PROGRESS,
// DONE,
// }
// enum CHECK_TYPE {
// ELECTRIC,
// WATER,
// WALL,
// DOOR_AND_WINDOWS,
// SECURITY,
// }
// Map<CHECK_TYPE, String> checkTypeMap = {
// CHECK_TYPE.ELECTRIC: '电路',
// CHECK_TYPE.WATER: '水路',
// CHECK_TYPE.WALL: '墙面',
// CHECK_TYPE.DOOR_AND_WINDOWS: '门窗',
// CHECK_TYPE.SECURITY: '安防',
// };
// Map<String, CHECK_TYPE> checkTypeStringMap = {
// '电路': CHECK_TYPE.ELECTRIC,
// '水路': CHECK_TYPE.WATER,
// '墙面': CHECK_TYPE.WALL,
// '门窗': CHECK_TYPE.DOOR_AND_WINDOWS,
// '安防': CHECK_TYPE.SECURITY,
// };
// Map<CHECK_TYPE, String> checkAssetMap = {
// CHECK_TYPE.ELECTRIC: R.ASSETS_MANAGE_CIRCUIT_PNG,
// CHECK_TYPE.WATER: R.ASSETS_MANAGE_WATERWAY_PNG,
// CHECK_TYPE.WALL: R.ASSETS_MANAGE_WALL_PNG,
// CHECK_TYPE.DOOR_AND_WINDOWS: R.ASSETS_MANAGE_WINDOW_PNG,
// CHECK_TYPE.SECURITY: R.ASSETS_MANAGE_SECURITY_PNG,
// };
// @Deprecated('under should be removed')
// class DecorationModel {
// DecorationType type;
// DecorationStatusType statusType;
// DateTime decorationDate;
// UserHomeModel userHomeModel;
// DecorationTeamModel decorationTeamModel;
// CycleCheck cycleCheck;
// WorkFinishCheck workFinishCheck;
// List<CheckInfomation> checkInfomations;
// String get statusTypeValue {
// if (statusType == DecorationStatusType.PROGRESS)
// return '装修中';
// else
// return '装修完成';
// }
// DecorationModel({
// @required this.type,
// @required this.statusType,
// @required this.userHomeModel,
// @required this.decorationTeamModel,
// @required this.decorationDate,
// this.cycleCheck,
// this.workFinishCheck,
// this.checkInfomations,
// });
// }
// @Deprecated('under should be removed')
// ///
// class UserHomeModel {
// String plot;
// String detailAddr;
// String userName;
// String phone;
// UserHomeModel({
// this.plot,
// this.detailAddr,
// this.userName,
// this.phone,
// });
// }
// @Deprecated('under should be removed')
// ///
// class DecorationTeamModel {
// String name;
// String userName;
// String phone;
// DecorationTeamModel({
// this.name,
// this.userName,
// this.phone,
// });
// }
// @Deprecated('under should be removed')
// ///
// class CycleCheck {
// FixerModel authPerson;
// DateTime startDate;
// ///check cycle in days
// int checkCycle;
// List<CHECK_TYPE> checkDetails = [
// CHECK_TYPE.ELECTRIC,
// CHECK_TYPE.WATER,
// CHECK_TYPE.WALL,
// CHECK_TYPE.DOOR_AND_WINDOWS,
// CHECK_TYPE.SECURITY,
// ];
// CycleCheck({
// this.authPerson,
// this.startDate,
// this.checkCycle,
// this.checkDetails,
// });
// }
// @Deprecated('under should be removed')
// class WorkFinishCheck {
// FixerModel authPerson;
// DateTime startDate;
// List<CHECK_TYPE> checkDetails;
// WorkFinishCheck({
// this.authPerson,
// this.startDate,
// this.checkDetails,
// });
// }
// @Deprecated('under should be removed')
// ///
// class CheckInfomation {
// DateTime checkDate;
// List<CheckDetail> details;
// String info;
// String checkType;
// CheckInfomation({
// this.checkDate,
// this.info,
// this.details,
// this.checkType,
// });
// ///
// bool get checkAllResult {
// for (var item in details) {
// if (!item.status) return false;
// }
// return true;
// }
// }
// @Deprecated('under should be removed')
// class CheckDetail {
// CHECK_TYPE type;
// bool status;
// String get assetpath => checkAssetMap[type];
// CheckDetail({
// @required this.type,
// this.status = true,
// });
// String get typeValue => checkTypeMap[type];
// }

@ -1,86 +0,0 @@
enum FIXER_TYPE {
///
AIR_CONDITION,
///
ELECTRIC,
///
CEMENT,
///
PROPERTY,
}
//TODO CLEAN BOTTOM CODES.
// @Deprecated("fixer_model need to be cleaned.")
// class FixerModel {
// String name;
// String phone;
// FixerModel({this.name, this.phone});
// }
// class FixerTypedModel {
// FIXER_TYPE type;
// String get typeName {
// switch (type) {
// case FIXER_TYPE.AIR_CONDITION:
// return '空调组';
// break;
// case FIXER_TYPE.ELECTRIC:
// return '电力组';
// break;
// case FIXER_TYPE.CEMENT:
// return '水泥组';
// break;
// case FIXER_TYPE.PROPERTY:
// return '物业组';
// default:
// return '';
// }
// }
// List<FixerModel> fixers;
// FixerTypedModel({
// this.type,
// this.fixers,
// });
// static List<FixerTypedModel> models = [
// FixerTypedModel(
// type: FIXER_TYPE.AIR_CONDITION,
// fixers: [
// FixerModel(name: '刘能建师傅', phone: '18923747283'),
// FixerModel(name: '李惠政师傅', phone: '18910298345'),
// FixerModel(name: '李慧珍师傅', phone: '17872342382'),
// FixerModel(name: '林 芝师傅', phone: '18292847752'),
// ],
// ),
// FixerTypedModel(
// type: FIXER_TYPE.CEMENT,
// fixers: [
// FixerModel(name: '李雷师傅', phone: '18923747283'),
// FixerModel(name: '林智师傅', phone: '18910298345'),
// FixerModel(name: '刘凯欣师傅', phone: '17872342382'),
// FixerModel(name: '张亮师傅', phone: '18292847752'),
// ],
// ),
// FixerTypedModel(
// type: FIXER_TYPE.ELECTRIC,
// fixers: [
// FixerModel(name: '李建国师傅', phone: '18923747283'),
// FixerModel(name: '李历程师傅', phone: '18910298345'),
// ],
// ),
// ];
// static List<FixerTypedModel> propertyModels = [
// FixerTypedModel(
// type: FIXER_TYPE.PROPERTY,
// fixers: [
// FixerModel(name: '李国师傅', phone: '18923747283'),
// FixerModel(name: '章则林师傅', phone: '18910298345'),
// ],
// ),
// ];
// }

@ -1,49 +0,0 @@
import 'package:common_utils/common_utils.dart';
class TodayClockRecordModel {
int? id;
String? startClockDate;
String? endClockDate;
String? cardReplacementDate;
String? operatorName;
String? clockName;
String? clockTel;
String? createDate;
TodayClockRecordModel(
{required this.id,
this.startClockDate,
this.endClockDate,
this.cardReplacementDate,
this.operatorName,
this.clockName,
this.clockTel,
this.createDate});
TodayClockRecordModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
startClockDate = json['startClockDate'];
endClockDate = json['endClockDate'];
cardReplacementDate = json['cardReplacementDate'];
operatorName = json['operatorName'];
clockName = json['clockName'];
clockTel = json['clockTel'];
createDate = json['createDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['startClockDate'] = this.startClockDate;
data['endClockDate'] = this.endClockDate;
data['cardReplacementDate'] = this.cardReplacementDate;
data['operatorName'] = this.operatorName;
data['clockName'] = this.clockName;
data['clockTel'] = this.clockTel;
data['createDate'] = this.createDate;
return data;
}
DateTime? get clockInTime => DateUtil.getDateTime(this.startClockDate!);
DateTime? get clockOutTime => DateUtil.getDateTime(this.endClockDate!);
}

@ -1,9 +1,11 @@
import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/clock_in_out/today_clock_record_model.dart'; import 'package:aku_community_manager/json_models/clock_in_out/today_clock_record_model.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart'; import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
class ClockFunc { class ClockFunc {
static Future initClockInfo() async { static Future initClockInfo() async {
@ -16,7 +18,7 @@ class ClockFunc {
} }
static Future clockIn(int id, DateTime dateTime) async { static Future clockIn(int id, DateTime dateTime) async {
await NetUtil().post( await NetUtil().post(
API.manage.clockInOut, API.manage.clockInOut,
params: { params: {
"id": id, "id": id,
@ -28,7 +30,7 @@ class ClockFunc {
} }
static Future clockOut(int id, DateTime dateTime) async { static Future clockOut(int id, DateTime dateTime) async {
await NetUtil().post(API.manage.clockInOut, await NetUtil().post(API.manage.clockInOut,
params: { params: {
"id": id, "id": id,
"endClockDate": "endClockDate":
@ -50,4 +52,14 @@ class ClockFunc {
showMessage: true); showMessage: true);
return baseModel.status; return baseModel.status;
} }
static Color lateOrLeaveEarlyColor(
DateTime time, DateTime? checkTime, bool isStart) {
if (checkTime == null) return kTextPrimaryColor;
if (isStart) {
return time.isAfter(checkTime) ? Colors.red : kTextPrimaryColor;
} else {
return time.isBefore(checkTime) ? Colors.red : kTextPrimaryColor;
}
}
} }

@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:aku_community_manager/models/manager/clock_in_out/today_clock_record_model.dart'; import 'package:aku_community_manager/json_models/clock_in_out/today_clock_record_model.dart';
import 'package:aku_community_manager/provider/app_provider.dart'; import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/tools/user_tool.dart'; import 'package:aku_community_manager/tools/user_tool.dart';
@ -65,7 +65,7 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage>
controller: _refreshController, controller: _refreshController,
onRefresh: () async { onRefresh: () async {
UserTool.appProvider.initClock(); UserTool.appProvider.initClock();
_model = await (ClockFunc.initClockInfo() ); _model = await (ClockFunc.initClockInfo());
if (_model != null) { if (_model != null) {
UserTool.appProvider.resetClock(); // UserTool.appProvider.resetClock(); //
if (_model!.startClockDate != null) { if (_model!.startClockDate != null) {
@ -101,9 +101,13 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage>
64.w.heightBox, 64.w.heightBox,
Row( Row(
children: [ children: [
_buildCard(0, time: UserTool.appProvider.clockInTime), _buildCard(0,
time: UserTool.appProvider.clockInTime,
checkTime: _model!.startTime),
Spacer(), Spacer(),
_buildCard(1, time: UserTool.appProvider.clockOutTime) _buildCard(1,
time: UserTool.appProvider.clockOutTime,
checkTime: _model!.endTime)
], //type0.1 ], //type0.1
), ),
150.w.heightBox, 150.w.heightBox,
@ -122,12 +126,12 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage>
DateTime _currentTime = DateTime.now(); DateTime _currentTime = DateTime.now();
switch (UserTool.appProvider.clockStatus) { switch (UserTool.appProvider.clockStatus) {
case WORKCLOCK.NOTIN: case WORKCLOCK.NOTIN:
ClockFunc.clockIn(_model!.id!, _currentTime); ClockFunc.clockIn(_model!.id, _currentTime);
UserTool.appProvider.setClockInTime(_currentTime); UserTool.appProvider.setClockInTime(_currentTime);
BotToast.showText(text: '上班打卡成功'); BotToast.showText(text: '上班打卡成功');
break; break;
case WORKCLOCK.IN: case WORKCLOCK.IN:
ClockFunc.clockOut(_model!.id!, _currentTime); ClockFunc.clockOut(_model!.id, _currentTime);
UserTool.appProvider.setClockOutTime(_currentTime); UserTool.appProvider.setClockOutTime(_currentTime);
BotToast.showText(text: '下班打卡成功'); BotToast.showText(text: '下班打卡成功');
break; break;
@ -172,7 +176,8 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage>
); );
} }
Widget _buildCard(int type, {DateTime? time}) { //type: 0 1
Widget _buildCard(int type, {DateTime? time, DateTime? checkTime}) {
return Container( return Container(
width: 296.w, width: 296.w,
height: 131.w, height: 131.w,
@ -227,7 +232,8 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage>
.text .text
.size(32.sp) .size(32.sp)
.bold .bold
.color(kTextPrimaryColor) .color(ClockFunc.lateOrLeaveEarlyColor(
time, checkTime, type == 0))
.make() .make()
], ],
), ),

Loading…
Cancel
Save