From bfb113ba3c38c24c7507ae8dc32a57dd37619018 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Tue, 10 Aug 2021 18:13:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E7=AE=A1=E7=90=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=BF=9F=E5=88=B0=E6=88=96=E6=97=A9=E9=80=80=E6=A0=87?= =?UTF-8?q?=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../today_clock_record_model.dart | 59 ++++++ .../today_clock_record_model.g.dart | 26 +++ .../decoration/decoration_model.dart | 185 ------------------ lib/mock_models/fix/fixer_model.dart | 86 -------- .../today_clock_record_model.dart | 49 ----- .../manage_pages/clock_in_out/clock_func.dart | 18 +- .../clock_in_out/clock_in_out_main_page.dart | 22 ++- 7 files changed, 114 insertions(+), 331 deletions(-) create mode 100644 lib/json_models/clock_in_out/today_clock_record_model.dart create mode 100644 lib/json_models/clock_in_out/today_clock_record_model.g.dart delete mode 100644 lib/mock_models/decoration/decoration_model.dart delete mode 100644 lib/mock_models/fix/fixer_model.dart delete mode 100644 lib/models/manager/clock_in_out/today_clock_record_model.dart diff --git a/lib/json_models/clock_in_out/today_clock_record_model.dart b/lib/json_models/clock_in_out/today_clock_record_model.dart new file mode 100644 index 0000000..be7f907 --- /dev/null +++ b/lib/json_models/clock_in_out/today_clock_record_model.dart @@ -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 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; + } + } +} diff --git a/lib/json_models/clock_in_out/today_clock_record_model.g.dart b/lib/json_models/clock_in_out/today_clock_record_model.g.dart new file mode 100644 index 0000000..35f6a1c --- /dev/null +++ b/lib/json_models/clock_in_out/today_clock_record_model.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'today_clock_record_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +TodayClockRecordModel _$TodayClockRecordModelFromJson( + Map 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, + ); +} diff --git a/lib/mock_models/decoration/decoration_model.dart b/lib/mock_models/decoration/decoration_model.dart deleted file mode 100644 index 53ca575..0000000 --- a/lib/mock_models/decoration/decoration_model.dart +++ /dev/null @@ -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 checkTypeMap = { -// CHECK_TYPE.ELECTRIC: '电路', -// CHECK_TYPE.WATER: '水路', -// CHECK_TYPE.WALL: '墙面', -// CHECK_TYPE.DOOR_AND_WINDOWS: '门窗', -// CHECK_TYPE.SECURITY: '安防', -// }; - -// Map checkTypeStringMap = { -// '电路': CHECK_TYPE.ELECTRIC, -// '水路': CHECK_TYPE.WATER, -// '墙面': CHECK_TYPE.WALL, -// '门窗': CHECK_TYPE.DOOR_AND_WINDOWS, -// '安防': CHECK_TYPE.SECURITY, -// }; - -// Map 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 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 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 checkDetails; -// WorkFinishCheck({ -// this.authPerson, -// this.startDate, -// this.checkDetails, -// }); -// } - -// @Deprecated('under should be removed') - -// ///周期检查细节 -// class CheckInfomation { -// DateTime checkDate; -// List 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]; -// } diff --git a/lib/mock_models/fix/fixer_model.dart b/lib/mock_models/fix/fixer_model.dart deleted file mode 100644 index 52bfec1..0000000 --- a/lib/mock_models/fix/fixer_model.dart +++ /dev/null @@ -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 fixers; -// FixerTypedModel({ -// this.type, -// this.fixers, -// }); - -// static List 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 propertyModels = [ -// FixerTypedModel( -// type: FIXER_TYPE.PROPERTY, -// fixers: [ -// FixerModel(name: '李国师傅', phone: '18923747283'), -// FixerModel(name: '章则林师傅', phone: '18910298345'), -// ], -// ), -// ]; -// } diff --git a/lib/models/manager/clock_in_out/today_clock_record_model.dart b/lib/models/manager/clock_in_out/today_clock_record_model.dart deleted file mode 100644 index 4adba7c..0000000 --- a/lib/models/manager/clock_in_out/today_clock_record_model.dart +++ /dev/null @@ -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 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 toJson() { - final Map data = new Map(); - 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!); -} diff --git a/lib/ui/manage_pages/clock_in_out/clock_func.dart b/lib/ui/manage_pages/clock_in_out/clock_func.dart index 8647d90..3dfb85f 100644 --- a/lib/ui/manage_pages/clock_in_out/clock_func.dart +++ b/lib/ui/manage_pages/clock_in_out/clock_func.dart @@ -1,9 +1,11 @@ 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/net_util.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; class ClockFunc { static Future initClockInfo() async { @@ -16,7 +18,7 @@ class ClockFunc { } static Future clockIn(int id, DateTime dateTime) async { - await NetUtil().post( + await NetUtil().post( API.manage.clockInOut, params: { "id": id, @@ -28,7 +30,7 @@ class ClockFunc { } static Future clockOut(int id, DateTime dateTime) async { - await NetUtil().post(API.manage.clockInOut, + await NetUtil().post(API.manage.clockInOut, params: { "id": id, "endClockDate": @@ -50,4 +52,14 @@ class ClockFunc { showMessage: true); 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; + } + } } diff --git a/lib/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart b/lib/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart index 92be570..0cb928c 100644 --- a/lib/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart +++ b/lib/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart @@ -1,6 +1,6 @@ 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/style/app_style.dart'; import 'package:aku_community_manager/tools/user_tool.dart'; @@ -65,7 +65,7 @@ class _ClockInOutMainPageState extends State controller: _refreshController, onRefresh: () async { UserTool.appProvider.initClock(); - _model = await (ClockFunc.initClockInfo() ); + _model = await (ClockFunc.initClockInfo()); if (_model != null) { UserTool.appProvider.resetClock(); //若成功获取今日打卡信息,则先重置打卡状态 if (_model!.startClockDate != null) { @@ -101,9 +101,13 @@ class _ClockInOutMainPageState extends State 64.w.heightBox, Row( children: [ - _buildCard(0, time: UserTool.appProvider.clockInTime), + _buildCard(0, + time: UserTool.appProvider.clockInTime, + checkTime: _model!.startTime), Spacer(), - _buildCard(1, time: UserTool.appProvider.clockOutTime) + _buildCard(1, + time: UserTool.appProvider.clockOutTime, + checkTime: _model!.endTime) ], //上班打卡为‘type’0.下班打卡为1 ), 150.w.heightBox, @@ -122,12 +126,12 @@ class _ClockInOutMainPageState extends State DateTime _currentTime = DateTime.now(); switch (UserTool.appProvider.clockStatus) { case WORKCLOCK.NOTIN: - ClockFunc.clockIn(_model!.id!, _currentTime); + ClockFunc.clockIn(_model!.id, _currentTime); UserTool.appProvider.setClockInTime(_currentTime); BotToast.showText(text: '上班打卡成功'); break; case WORKCLOCK.IN: - ClockFunc.clockOut(_model!.id!, _currentTime); + ClockFunc.clockOut(_model!.id, _currentTime); UserTool.appProvider.setClockOutTime(_currentTime); BotToast.showText(text: '下班打卡成功'); break; @@ -172,7 +176,8 @@ class _ClockInOutMainPageState extends State ); } - Widget _buildCard(int type, {DateTime? time}) { +//type: 0 上班 1 下班 + Widget _buildCard(int type, {DateTime? time, DateTime? checkTime}) { return Container( width: 296.w, height: 131.w, @@ -227,7 +232,8 @@ class _ClockInOutMainPageState extends State .text .size(32.sp) .bold - .color(kTextPrimaryColor) + .color(ClockFunc.lateOrLeaveEarlyColor( + time, checkTime, type == 0)) .make() ], ),