home_controller.dart 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import 'package:flutter_riverpod/flutter_riverpod.dart';
  2. /// 系统 Banner 模型
  3. class SysBanner {
  4. final String id;
  5. final String imageUrl;
  6. final String? linkUrl;
  7. final String? title;
  8. const SysBanner({
  9. required this.id,
  10. required this.imageUrl,
  11. this.linkUrl,
  12. this.title,
  13. });
  14. static const mockBanners = [
  15. SysBanner(id: '1', imageUrl: 'assets/img/banner_1.png', title: 'OA系统升级通知'),
  16. SysBanner(id: '2', imageUrl: 'assets/img/banner_2.png', linkUrl: 'https://example.com', title: '2026年度预算管理'),
  17. SysBanner(id: '3', imageUrl: 'assets/img/banner_3.png', title: '端午节放假安排'),
  18. ];
  19. }
  20. /// 工作台首页聚合数据模型
  21. ///
  22. /// 角色权限优先级:admin > finance > manager > employee
  23. /// 数据全部使用 mock,角色从权限派生。
  24. class HomeSummary {
  25. /// 用户角色:admin / finance / manager / employee
  26. final String userRole;
  27. // ── 员工版:个人快捷看板 ──
  28. final double monthlyReimbursement; // 本月累计报销(本人已付款总额 ¥)
  29. final int monthlySubmittedCount; // 本月已提单据(本人提交总数 笔)
  30. // ── 经理版:待审批 + 部门范围 ──
  31. final int pendingApprovalCount; // 待审批数(红色角标)
  32. final double deptMonthlyReimbursement; // 部门本月累计报销
  33. final int deptMonthlySubmittedCount; // 部门本月已提单据
  34. final int deptPendingDocuments; // 部门在途单据
  35. // ── 财务/管理员版 ──
  36. final double paidTotal; // 本月已支付总额
  37. final double pendingPaymentTotal; // 待付款总额
  38. final double abnormalReturns; // 本周异常退回
  39. const HomeSummary({
  40. this.userRole = 'employee',
  41. this.monthlyReimbursement = 0,
  42. this.monthlySubmittedCount = 0,
  43. this.pendingApprovalCount = 0,
  44. this.deptMonthlyReimbursement = 0,
  45. this.deptMonthlySubmittedCount = 0,
  46. this.deptPendingDocuments = 0,
  47. this.paidTotal = 0,
  48. this.pendingPaymentTotal = 0,
  49. this.abnormalReturns = 0,
  50. });
  51. }
  52. /// Banner Provider — 返回模拟 Banner 列表
  53. final bannerProvider = Provider<List<SysBanner>>((ref) {
  54. return SysBanner.mockBanners;
  55. });
  56. /// 首页数据 Provider — 返回模拟 HomeSummary
  57. ///
  58. /// 修改 userRole 可测试不同角色视图:
  59. /// 'employee' → 员工版
  60. /// 'manager' → 经理版
  61. /// 'finance' → 财务版
  62. /// 'admin' → 管理员版
  63. final homeSummaryProvider = FutureProvider<HomeSummary>((ref) async {
  64. return const HomeSummary(
  65. userRole: 'admin',
  66. // 员工版数据
  67. monthlyReimbursement: 12800.50,
  68. monthlySubmittedCount: 8,
  69. // 经理版数据
  70. pendingApprovalCount: 5,
  71. deptMonthlyReimbursement: 156800.00,
  72. deptMonthlySubmittedCount: 42,
  73. deptPendingDocuments: 15,
  74. // 财务/管理员版数据
  75. paidTotal: 896500.00,
  76. pendingPaymentTotal: 283200.50,
  77. abnormalReturns: 12800.00,
  78. );
  79. });