167 lines
5.5 KiB
Dart
Executable File
167 lines
5.5 KiB
Dart
Executable File
import 'package:date_format/date_format.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart';
|
|
import 'package:star_lock/tools/pickers/pickers.dart';
|
|
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
|
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../tools/commonItem.dart';
|
|
import '../../../../../tools/showCalendar.dart';
|
|
import '../../../../../tools/submitBtn.dart';
|
|
import '../../../../../tools/titleAppBar.dart';
|
|
import 'checkingInAddHolidays_logic.dart';
|
|
|
|
class CheckingInAddHolidaysPage extends StatefulWidget {
|
|
const CheckingInAddHolidaysPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<CheckingInAddHolidaysPage> createState() =>
|
|
_CheckingInAddHolidaysPageState();
|
|
}
|
|
|
|
class _CheckingInAddHolidaysPageState extends State<CheckingInAddHolidaysPage> {
|
|
final CheckingInAddHolidaysLogic logic =
|
|
Get.put(CheckingInAddHolidaysLogic());
|
|
final CheckingInAddHolidaysState state =
|
|
Get.find<CheckingInAddHolidaysLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '添加假日'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Column(
|
|
children: <Widget>[
|
|
CommonItem(
|
|
leftTitel: '姓名'.tr,
|
|
rightTitle: '',
|
|
isHaveLine: true,
|
|
isHaveRightWidget: true,
|
|
setHeight: false,
|
|
rightWidget: getTFWidget('(${"必填".tr})', maxSize: 50)),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '开始日期'.tr,
|
|
rightTitle: state.beginDate.value.isEmpty
|
|
? '(${'必填'.tr})'
|
|
: state.beginDate.value,
|
|
isHaveLine: true,
|
|
isHaveDirection: false,
|
|
action: () async {
|
|
Pickers.showDatePicker(context,
|
|
selectDate: PDuration.now(),
|
|
mode: DateMode.YMD, onConfirm: (PDuration p) {
|
|
state.beginDate.value = formatDate(p);
|
|
});
|
|
})),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '结束日期'.tr,
|
|
rightTitle: state.endDate.value.isEmpty
|
|
? '(${"必填".tr})'
|
|
: state.endDate.value,
|
|
isHaveLine: true,
|
|
isHaveDirection: false,
|
|
action: () async {
|
|
Pickers.showDatePicker(context,
|
|
selectDate: PDuration.now(),
|
|
mode: DateMode.YMD, onConfirm: (PDuration p) {
|
|
state.endDate.value = formatDate(p);
|
|
});
|
|
})),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '补班日期'.tr,
|
|
rightTitle: state.makeUpWorkDate.value,
|
|
isHaveLine: false,
|
|
isHaveDirection: false,
|
|
action: () async {
|
|
Pickers.showDatePicker(context,
|
|
selectDate: PDuration.now(),
|
|
mode: DateMode.YMD, onConfirm: (PDuration p) {
|
|
state.makeUpWorkDate.value = formatDate(p);
|
|
});
|
|
})),
|
|
SizedBox(
|
|
height: 50.w,
|
|
),
|
|
SubmitBtn(
|
|
btnName: '确定'.tr,
|
|
borderRadius: 20.w,
|
|
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
|
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
|
onClick: () {
|
|
logic.editStaffLoadData();
|
|
}),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget getTFWidget(String tfStr, {int maxSize = 30}) {
|
|
return Expanded(
|
|
child: TextField(
|
|
//输入框一行
|
|
maxLines: 2,
|
|
minLines: 1,
|
|
controller: state.staffNameController,
|
|
autofocus: false,
|
|
textAlign: TextAlign.end,
|
|
decoration: InputDecoration(
|
|
//输入里面输入文字内边距设置
|
|
contentPadding: const EdgeInsets.only(bottom: 3),
|
|
hintText: tfStr,
|
|
hintStyle: TextStyle(
|
|
fontSize: 22.sp, color: AppColors.darkGrayTextColor, height: 1),
|
|
//不需要输入框下划线
|
|
border: InputBorder.none,
|
|
isCollapsed: true,
|
|
),
|
|
inputFormatters: <TextInputFormatter>[
|
|
LengthLimitingTextInputFormatter(maxSize),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget whetherTheEmployeeHasAKeyWidget(String title, Function action) {
|
|
return GestureDetector(
|
|
onTap: () {},
|
|
child: Row(
|
|
children: <Widget>[
|
|
Image.asset(
|
|
'images/icon_round_unSelect.png',
|
|
width: 40.w,
|
|
height: 40.w,
|
|
),
|
|
SizedBox(
|
|
width: 5.w,
|
|
),
|
|
Text(title),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
String formatDate(PDuration p) {
|
|
if (p == null) {
|
|
throw ArgumentError('Input must be a valid DateTime object');
|
|
}
|
|
|
|
String formatPart(int part) {
|
|
return part.toString().padLeft(2, '0');
|
|
}
|
|
|
|
String monthFormatted = formatPart(p.month!);
|
|
String dayFormatted = formatPart(p.day!);
|
|
String hourFormatted = formatPart(p.hour!);
|
|
String minuteFormatted = formatPart(p.minute!);
|
|
|
|
return '${p.year}-${monthFormatted}-${dayFormatted}';
|
|
}
|
|
}
|