| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- 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 '../../shared/widgets/loading_widget.dart';
- import 'expense_application_model.dart';
- final expenseApplicationDetailProvider =
- FutureProvider.autoDispose.family<ExpenseApplicationModel, String>(
- (ref, id) async {
- // mock detail — 返回硬编码数据
- return ExpenseApplicationModel(
- id: id,
- applicationNo: 'BXSQ-20240501-001',
- applicantId: 'U001',
- applicantName: '张三',
- deptId: 'D001',
- deptName: '销售部',
- expenseType: '差旅费',
- estimatedAmount: 3500.00,
- purpose: '上海出差拜访客户',
- remark: '',
- status: 'pending',
- currentApproverId: 'U100',
- approvalChain: ['U100', 'U200'],
- createTime: DateTime(2024, 5, 1, 14, 30),
- updateTime: DateTime(2024, 5, 1, 14, 30),
- );
- });
- class ExpenseApplicationDetailPage extends ConsumerWidget {
- final String id;
- const ExpenseApplicationDetailPage({super.key, required this.id});
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final detailAsync = ref.watch(expenseApplicationDetailProvider(id));
- final r = ResponsiveHelper.of(context);
- return Scaffold(
- appBar: AppBar(title: const Text('报销申请详情')),
- body: detailAsync.when(
- loading: () => const LoadingWidget(),
- error: (_, _) => const Center(child: Text('加载失败')),
- data: (model) => Center(
- child: ConstrainedBox(
- constraints:
- BoxConstraints(maxWidth: r.detailTwoColumns ? 700 : double.infinity),
- child: SingleChildScrollView(
- padding: const EdgeInsets.symmetric(vertical: 8),
- child: Column(
- children: [
- FormSection(
- title: '基本信息',
- children: [
- FormFieldRow(
- label: '申请单号',
- value: model.applicationNo,
- showArrow: false),
- FormFieldRow(
- label: '费用类型',
- value: model.expenseType,
- showArrow: false),
- FormFieldRow(
- label: '预计金额',
- value: '¥${model.estimatedAmount.toStringAsFixed(2)}',
- showArrow: false),
- FormFieldRow(
- label: '部门',
- value: model.deptName,
- showArrow: false),
- FormFieldRow(
- label: '申请人',
- value: model.applicantName,
- showArrow: false),
- FormFieldRow(
- label: '创建时间',
- value: du.DateUtils.formatDateTime(model.createTime),
- showArrow: false),
- FormFieldRow(
- label: '状态',
- value: '',
- showArrow: false,
- onTap: null),
- 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: model.status),
- ],
- ),
- ),
- FormFieldRow(
- label: '用途说明',
- value: model.purpose.isEmpty ? '-' : model.purpose,
- showArrow: false),
- FormFieldRow(
- label: '备注',
- value: model.remark.isEmpty ? '-' : model.remark,
- showArrow: false),
- ],
- ),
- ],
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
|