| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import 'package:flutter/material.dart';
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import '../../core/theme/app_colors.dart';
- import '../../core/utils/date_utils.dart' as du;
- import '../../core/utils/responsive.dart';
- import '../../shared/widgets/form_section.dart';
- import '../../shared/widgets/form_field_row.dart';
- import '../../shared/widgets/status_tag.dart';
- import 'overtime_api.dart';
- import 'overtime_model.dart';
- final overtimeDetailProvider = FutureProvider.autoDispose.family<OvertimeModel, String>((ref, id) async {
- return ref.read(overtimeApiProvider).fetchDetail(id);
- });
- class OvertimeDetailPage extends ConsumerWidget {
- final String id;
- const OvertimeDetailPage({super.key, required this.id});
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final detailAsync = ref.watch(overtimeDetailProvider(id));
- final r = ResponsiveHelper.of(context);
- return Scaffold(
- appBar: AppBar(title: const Text('加班详情')),
- body: detailAsync.when(
- loading: () => const Center(child: CircularProgressIndicator()),
- error: (_, __) => const Center(child: Text('加载失败')),
- data: (o) => Center(
- child: ConstrainedBox(
- constraints: BoxConstraints(maxWidth: r.detailTwoColumns ? 700 : double.infinity),
- child: SingleChildScrollView(
- padding: const EdgeInsets.symmetric(vertical: 8),
- child: FormSection(
- title: '加班信息',
- children: [
- FormFieldRow(label: '申请单号', value: o.applicationNo, showArrow: false),
- FormFieldRow(label: '加班类型', value: o.otType, showArrow: false),
- FormFieldRow(label: '补偿方式', value: o.compensationType, showArrow: false),
- FormFieldRow(label: '开始时间', value: du.DateUtils.formatDateTime(o.startTime), showArrow: false),
- FormFieldRow(label: '结束时间', value: du.DateUtils.formatDateTime(o.endTime), showArrow: false),
- FormFieldRow(label: '预估工时', value: '${o.otHours.toStringAsFixed(1)}h', showArrow: false),
- FormFieldRow(label: '部门', value: o.deptName, showArrow: false),
- FormFieldRow(label: '申请人', value: o.applicantName, showArrow: false),
- FormFieldRow(label: '创建时间', value: du.DateUtils.formatDateTime(o.createTime), showArrow: false),
- Padding(
- padding: const EdgeInsets.fromLTRB(14, 0, 14, 12),
- child: Row(
- children: [
- const SizedBox(width: 72, child: Text('状态', style: TextStyle(color: AppColors.textSecondary, fontSize: 13))),
- StatusTag(status: o.status),
- ],
- ),
- ),
- FormFieldRow(label: '加班事由', value: o.reason.isEmpty ? '-' : o.reason, showArrow: false),
- ],
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
|