expense_application_detail_page.dart 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import '../../core/theme/app_colors.dart';
  4. import '../../core/utils/date_utils.dart' as du;
  5. import '../../core/utils/responsive.dart';
  6. import '../../shared/widgets/form_section.dart';
  7. import '../../shared/widgets/form_field_row.dart';
  8. import '../../shared/widgets/status_tag.dart';
  9. import '../../shared/widgets/loading_widget.dart';
  10. import 'expense_application_model.dart';
  11. final expenseApplicationDetailProvider =
  12. FutureProvider.autoDispose.family<ExpenseApplicationModel, String>(
  13. (ref, id) async {
  14. // mock detail — 返回硬编码数据
  15. return ExpenseApplicationModel(
  16. id: id,
  17. applicationNo: 'BXSQ-20240501-001',
  18. applicantId: 'U001',
  19. applicantName: '张三',
  20. deptId: 'D001',
  21. deptName: '销售部',
  22. expenseType: '差旅费',
  23. estimatedAmount: 3500.00,
  24. purpose: '上海出差拜访客户',
  25. remark: '',
  26. status: 'pending',
  27. currentApproverId: 'U100',
  28. approvalChain: ['U100', 'U200'],
  29. createTime: DateTime(2024, 5, 1, 14, 30),
  30. updateTime: DateTime(2024, 5, 1, 14, 30),
  31. );
  32. });
  33. class ExpenseApplicationDetailPage extends ConsumerWidget {
  34. final String id;
  35. const ExpenseApplicationDetailPage({super.key, required this.id});
  36. @override
  37. Widget build(BuildContext context, WidgetRef ref) {
  38. final detailAsync = ref.watch(expenseApplicationDetailProvider(id));
  39. final r = ResponsiveHelper.of(context);
  40. return Scaffold(
  41. appBar: AppBar(title: const Text('报销申请详情')),
  42. body: detailAsync.when(
  43. loading: () => const LoadingWidget(),
  44. error: (_, _) => const Center(child: Text('加载失败')),
  45. data: (model) => Align(alignment: Alignment.topCenter,
  46. child: ConstrainedBox(
  47. constraints:
  48. BoxConstraints(maxWidth: r.detailTwoColumns ? 700 : double.infinity),
  49. child: SingleChildScrollView(
  50. padding: const EdgeInsets.symmetric(vertical: 8),
  51. child: Column(
  52. children: [
  53. FormSection(
  54. title: '基本信息',
  55. children: [
  56. FormFieldRow(
  57. label: '申请单号',
  58. value: model.applicationNo,
  59. showArrow: false),
  60. FormFieldRow(
  61. label: '费用类型',
  62. value: model.expenseType,
  63. showArrow: false),
  64. FormFieldRow(
  65. label: '预计金额',
  66. value: '¥${model.estimatedAmount.toStringAsFixed(2)}',
  67. showArrow: false),
  68. FormFieldRow(
  69. label: '部门',
  70. value: model.deptName,
  71. showArrow: false),
  72. FormFieldRow(
  73. label: '申请人',
  74. value: model.applicantName,
  75. showArrow: false),
  76. FormFieldRow(
  77. label: '创建时间',
  78. value: du.DateUtils.formatDateTime(model.createTime),
  79. showArrow: false),
  80. FormFieldRow(
  81. label: '状态',
  82. value: '',
  83. showArrow: false,
  84. onTap: null),
  85. Padding(
  86. padding: const EdgeInsets.fromLTRB(14, 0, 14, 12),
  87. child: Row(
  88. children: [
  89. const SizedBox(
  90. width: 72,
  91. child: Text('状态',
  92. style: TextStyle(
  93. color: AppColors.textSecondary,
  94. fontSize: 13))),
  95. StatusTag(status: model.status),
  96. ],
  97. ),
  98. ),
  99. FormFieldRow(
  100. label: '用途说明',
  101. value: model.purpose.isEmpty ? '-' : model.purpose,
  102. showArrow: false),
  103. FormFieldRow(
  104. label: '备注',
  105. value: model.remark.isEmpty ? '-' : model.remark,
  106. showArrow: false),
  107. ],
  108. ),
  109. ],
  110. ),
  111. ),
  112. ),
  113. ),
  114. ),
  115. );
  116. }
  117. }