| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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/models/approval_status.dart';
- import '../../shared/widgets/form_section.dart';
- import '../../shared/widgets/form_field_row.dart';
- import '../../shared/widgets/status_tag.dart';
- import 'overtime_model.dart';
- final overtimeDetailProvider = FutureProvider.autoDispose.family<OvertimeModel, String>((ref, id) async {
- await Future.delayed(const Duration(milliseconds: 300));
- return OvertimeModel(
- id: id,
- applicationNo: 'OT202605001',
- applicantId: 'u-001',
- applicantName: '张三',
- deptId: 'dept-001',
- deptName: '市场部',
- otDate: DateTime(2026, 5, 20),
- startTime: DateTime(2026, 5, 20, 18, 0),
- endTime: DateTime(2026, 5, 20, 21, 0),
- otHours: 3.0,
- otType: '工作日加班',
- compensationType: '加班费',
- reason: '项目上线前紧急测试',
- status: 'pending',
- createTime: DateTime(2026, 5, 20),
- updateTime: DateTime(2026, 5, 20),
- approvalRecords: [
- ApprovalRecord(
- id: 'ar-ot-001',
- bizId: id,
- bizType: 'overtime',
- approverId: 'u-mgr',
- approverName: '李四',
- approvalLevel: 1,
- action: 'pending',
- opinion: '',
- approvalTime: DateTime(2026, 5, 20),
- ),
- ],
- );
- });
- 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),
- ],
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
|