outing_log_detail_page.dart 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 'outing_log_model.dart';
  9. final outingLogDetailProvider = FutureProvider.autoDispose.family<OutingLogModel, String>((ref, id) async {
  10. return OutingLogModel(
  11. id: id,
  12. visitNo: 'VL202605001',
  13. salespersonId: 'u-001',
  14. salespersonName: '张三',
  15. deptId: 'dept-001',
  16. deptName: '市场部',
  17. customerName: '华软科技',
  18. visitDate: DateTime(2026, 5, 20),
  19. visitStartTime: DateTime(2026, 5, 20, 9, 0),
  20. visitEndTime: DateTime(2026, 5, 20, 11, 30),
  21. visitType: '常规拜访',
  22. visitPurpose: '产品演示及方案交流',
  23. visitLocation: '深圳市南山区科技园',
  24. visitSummary: '向客户展示了公司最新产品功能,客户对数据看板功能比较感兴趣,约定下周安排试用。',
  25. nextVisitTime: DateTime(2026, 5, 27),
  26. status: '已完成',
  27. createTime: DateTime(2026, 5, 20),
  28. updateTime: DateTime(2026, 5, 20),
  29. );
  30. });
  31. class OutingLogDetailPage extends ConsumerWidget {
  32. final String id;
  33. const OutingLogDetailPage({super.key, required this.id});
  34. @override
  35. Widget build(BuildContext context, WidgetRef ref) {
  36. final detailAsync = ref.watch(outingLogDetailProvider(id));
  37. final r = ResponsiveHelper.of(context);
  38. return Scaffold(
  39. appBar: AppBar(title: const Text('日志详情')),
  40. body: detailAsync.when(
  41. loading: () => const Center(child: CircularProgressIndicator()),
  42. error: (_, __) => const Center(child: Text('加载失败')),
  43. data: (log) => Align(alignment: Alignment.topCenter,
  44. child: ConstrainedBox(
  45. constraints: BoxConstraints(maxWidth: r.detailTwoColumns ? 700 : double.infinity),
  46. child: SingleChildScrollView(
  47. padding: const EdgeInsets.symmetric(vertical: 8),
  48. child: FormSection(
  49. title: '外出日志',
  50. children: [
  51. FormFieldRow(label: '拜访单号', value: log.visitNo, showArrow: false),
  52. FormFieldRow(label: '日期', value: du.DateUtils.formatDate(log.visitDate), showArrow: false),
  53. FormFieldRow(label: '拜访客户', value: log.customerName.isEmpty ? '-' : log.customerName, showArrow: false),
  54. FormFieldRow(label: '联系人', value: log.contactName.isEmpty ? '-' : log.contactName, showArrow: false),
  55. FormFieldRow(label: '拜访方式', value: log.visitType, showArrow: false),
  56. FormFieldRow(label: '拜访地点', value: log.visitLocation.isEmpty ? '-' : log.visitLocation, showArrow: false),
  57. FormFieldRow(label: '拜访结果', value: log.visitResult.isEmpty ? '-' : log.visitResult, showArrow: false),
  58. FormFieldRow(label: '打卡校验', value: log.checkInStatus, showArrow: false),
  59. FormFieldRow(label: '创建人', value: log.salespersonName, showArrow: false),
  60. FormFieldRow(label: '创建时间', value: du.DateUtils.formatDateTime(log.createTime), showArrow: false),
  61. const SizedBox(height: 8),
  62. const Padding(
  63. padding: EdgeInsets.symmetric(horizontal: 14),
  64. child: Text('日志内容', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: AppColors.textSecondary)),
  65. ),
  66. Padding(
  67. padding: const EdgeInsets.all(14),
  68. child: Text(log.visitSummary.isEmpty ? '-' : log.visitSummary, style: const TextStyle(color: AppColors.textPrimary, fontSize: 14, height: 1.6)),
  69. ),
  70. ],
  71. ),
  72. ),
  73. ),
  74. ),
  75. ),
  76. );
  77. }
  78. }