| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- 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 'vehicle_model.dart';
- final vehicleDetailProvider = FutureProvider.autoDispose.family<VehicleModel, String>((ref, id) async {
- await Future.delayed(const Duration(milliseconds: 300));
- return VehicleModel(
- id: id,
- applicationNo: 'VH202605001',
- applicantId: 'u-001',
- applicantName: '张三',
- deptId: 'dept-001',
- deptName: '市场部',
- vehicleType: '轿车',
- purpose: '客户拜访',
- startTime: DateTime(2026, 5, 22, 8, 0),
- endTime: DateTime(2026, 5, 22, 18, 0),
- origin: '公司总部',
- destination: '深圳分公司',
- passengerCount: 3,
- driver: '刘师傅',
- licensePlate: '京A·88888',
- estimatedMileage: 120.0,
- estimatedCost: 500.0,
- reason: '拜访重要客户,需前往深圳',
- status: 'pending',
- createTime: DateTime(2026, 5, 20),
- updateTime: DateTime(2026, 5, 20),
- approvalRecords: [
- ApprovalRecord(
- id: 'ar-vh-001',
- bizId: id,
- bizType: 'vehicle',
- approverId: 'u-mgr',
- approverName: '李四',
- approvalLevel: 1,
- action: 'pending',
- opinion: '',
- approvalTime: DateTime(2026, 5, 20),
- ),
- ],
- );
- });
- class VehicleDetailPage extends ConsumerWidget {
- final String id;
- const VehicleDetailPage({super.key, required this.id});
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final detailAsync = ref.watch(vehicleDetailProvider(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: (v) => 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: v.applicationNo, showArrow: false),
- FormFieldRow(label: '用车目的', value: v.purpose, showArrow: false),
- FormFieldRow(label: '车型', value: v.vehicleType, showArrow: false),
- FormFieldRow(label: '开始时间', value: du.DateUtils.formatDateTime(v.startTime), showArrow: false),
- FormFieldRow(label: '结束时间', value: du.DateUtils.formatDateTime(v.endTime), showArrow: false),
- FormFieldRow(label: '出发地', value: v.origin, showArrow: false),
- FormFieldRow(label: '目的地', value: v.destination, showArrow: false),
- FormFieldRow(label: '乘车人数', value: '${v.passengerCount}人', showArrow: false),
- FormFieldRow(label: '驾驶员', value: v.driver.isEmpty ? '-' : v.driver, showArrow: false),
- FormFieldRow(label: '部门', value: v.deptName, showArrow: false),
- FormFieldRow(label: '申请人', value: v.applicantName, 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: v.status),
- ],
- ),
- ),
- FormFieldRow(label: '用车事由', value: v.reason.isEmpty ? '-' : v.reason, showArrow: false),
- ],
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
|