|
@@ -411,6 +411,13 @@ class _OvertimeApplyDetailDialogState extends State<OvertimeApplyDetailDialog> {
|
|
|
_buildJbDatePicker(colors),
|
|
_buildJbDatePicker(colors),
|
|
|
const SizedBox(height: 12),
|
|
const SizedBox(height: 12),
|
|
|
_buildStartTimePicker(colors),
|
|
_buildStartTimePicker(colors),
|
|
|
|
|
+ if (_startTime.isNotEmpty &&
|
|
|
|
|
+ _endTime.isNotEmpty &&
|
|
|
|
|
+ _startTime.compareTo(_endTime) >= 0)
|
|
|
|
|
+ Padding(
|
|
|
|
|
+ padding: const EdgeInsets.only(top: 8),
|
|
|
|
|
+ child: _buildTimeErrorHint(),
|
|
|
|
|
+ ),
|
|
|
const SizedBox(height: 12),
|
|
const SizedBox(height: 12),
|
|
|
_buildEndTimePicker(colors),
|
|
_buildEndTimePicker(colors),
|
|
|
const SizedBox(height: 12),
|
|
const SizedBox(height: 12),
|
|
@@ -748,7 +755,18 @@ class _OvertimeApplyDetailDialogState extends State<OvertimeApplyDetailDialog> {
|
|
|
colors: colors,
|
|
colors: colors,
|
|
|
required: true,
|
|
required: true,
|
|
|
showDayOfWeek: true,
|
|
showDayOfWeek: true,
|
|
|
- onPick: (d) => setState(() => _jbDate = d),
|
|
|
|
|
|
|
+ onPick: (d) {
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ _jbDate = d;
|
|
|
|
|
+ if (_startTime.isNotEmpty) {
|
|
|
|
|
+ _startTime = '$d ${_fmtTime(_startTime)}';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (_endTime.isNotEmpty) {
|
|
|
|
|
+ _endTime = '$d ${_fmtTime(_endTime)}';
|
|
|
|
|
+ }
|
|
|
|
|
+ _autoCalcHours();
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -807,6 +825,26 @@ class _OvertimeApplyDetailDialogState extends State<OvertimeApplyDetailDialog> {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ Widget _buildTimeErrorHint() {
|
|
|
|
|
+ final tdTheme = TDTheme.of(context);
|
|
|
|
|
+ return Row(
|
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
+ children: [
|
|
|
|
|
+ Icon(
|
|
|
|
|
+ Icons.warning_amber_rounded,
|
|
|
|
|
+ size: 14,
|
|
|
|
|
+ color: tdTheme.warningColor5,
|
|
|
|
|
+ ),
|
|
|
|
|
+ const SizedBox(width: 4),
|
|
|
|
|
+ TDText(
|
|
|
|
|
+ _l10n.get('endTimeMustLater'),
|
|
|
|
|
+ font: tdTheme.fontBodySmall,
|
|
|
|
|
+ textColor: tdTheme.warningColor5,
|
|
|
|
|
+ ),
|
|
|
|
|
+ ],
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
String _fmtTime(String dt) {
|
|
String _fmtTime(String dt) {
|
|
|
if (dt.length >= 16) return dt.substring(11, 16);
|
|
if (dt.length >= 16) return dt.substring(11, 16);
|
|
|
return dt;
|
|
return dt;
|
|
@@ -816,9 +854,11 @@ class _OvertimeApplyDetailDialogState extends State<OvertimeApplyDetailDialog> {
|
|
|
if (_startTime.isEmpty || _endTime.isEmpty) return;
|
|
if (_startTime.isEmpty || _endTime.isEmpty) return;
|
|
|
final st = DateTime.tryParse(_startTime);
|
|
final st = DateTime.tryParse(_startTime);
|
|
|
final et = DateTime.tryParse(_endTime);
|
|
final et = DateTime.tryParse(_endTime);
|
|
|
- if (st == null || et == null || et.isBefore(st)) return;
|
|
|
|
|
|
|
+ if (st == null || et == null) return;
|
|
|
|
|
|
|
|
- final totalHours = et.difference(st).inMinutes / 60.0;
|
|
|
|
|
|
|
+ double totalHours = et.difference(st).inMinutes / 60.0;
|
|
|
|
|
+ // 跨午夜:结束时间早于开始时间 → 加 24 小时
|
|
|
|
|
+ if (totalHours < 0) totalHours += 24;
|
|
|
|
|
|
|
|
if (totalHours > 0) {
|
|
if (totalHours > 0) {
|
|
|
_hoursCtrl.text = ((totalHours * 2).ceil() / 2.0).toStringAsFixed(1);
|
|
_hoursCtrl.text = ((totalHours * 2).ceil() / 2.0).toStringAsFixed(1);
|