message_model.dart 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. class MessageModel {
  2. final String id;
  3. final String title;
  4. final String content;
  5. final String msgType;
  6. final String? bizType;
  7. final String? bizId;
  8. final bool isRead;
  9. final DateTime createTime;
  10. const MessageModel({
  11. required this.id,
  12. required this.title,
  13. this.content = '',
  14. this.msgType = 'system',
  15. this.bizType,
  16. this.bizId,
  17. this.isRead = false,
  18. required this.createTime,
  19. });
  20. factory MessageModel.fromJson(Map<String, dynamic> json) => MessageModel(
  21. id: json['id'] as String,
  22. title: json['title'] as String,
  23. content: json['content'] as String? ?? '',
  24. msgType: json['msgType'] as String? ?? 'system',
  25. bizType: json['bizType'] as String?,
  26. bizId: json['bizId'] as String?,
  27. isRead: json['isRead'] as bool? ?? false,
  28. createTime: DateTime.parse(json['createTime'] as String),
  29. );
  30. static final mockMessages = [
  31. // 审批待办
  32. MessageModel(
  33. id: '1',
  34. title: '张三提交了差旅报销,待审批',
  35. content: '报销金额 ¥2,380.00',
  36. msgType: 'approval_notice',
  37. bizType: 'expense',
  38. bizId: 'exp-001',
  39. isRead: false,
  40. createTime: DateTime(2026, 6, 4, 9, 30),
  41. ),
  42. // 审批待办
  43. MessageModel(
  44. id: '2',
  45. title: '李四的加班申请待审批',
  46. content: '加班时长 4小时',
  47. msgType: 'approval_notice',
  48. bizType: 'overtime',
  49. bizId: 'ot-001',
  50. isRead: false,
  51. createTime: DateTime(2026, 6, 3, 14, 0),
  52. ),
  53. // 审批结果 — 通过
  54. MessageModel(
  55. id: '3',
  56. title: '您的差旅报销已通过',
  57. content: 'BX-20260602-001 已通过审批',
  58. msgType: 'approval_result',
  59. bizType: 'expense',
  60. bizId: 'exp-002',
  61. isRead: true,
  62. createTime: DateTime(2026, 6, 2, 10, 0),
  63. ),
  64. // 审批结果 — 拒绝
  65. MessageModel(
  66. id: '4',
  67. title: '您的加班申请已被拒绝',
  68. content: '原因:与部门预算冲突',
  69. msgType: 'approval_result',
  70. bizType: 'overtime',
  71. bizId: 'ot-002',
  72. isRead: false,
  73. createTime: DateTime(2026, 6, 2, 11, 30),
  74. ),
  75. // 撤回通知
  76. MessageModel(
  77. id: '5',
  78. title: '王五撤回了用车申请',
  79. content: 'YC-20260601-003 已撤回',
  80. msgType: 'withdraw_notice',
  81. bizType: 'vehicle',
  82. bizId: 'vcl-003',
  83. isRead: false,
  84. createTime: DateTime(2026, 6, 1, 16, 45),
  85. ),
  86. // 系统公告
  87. MessageModel(
  88. id: '6',
  89. title: '【通知公告】2026年端午放假安排',
  90. content: '6月8日至6月10日放假,共3天',
  91. msgType: 'announcement',
  92. bizType: 'announcement',
  93. bizId: 'an-001',
  94. isRead: false,
  95. createTime: DateTime(2026, 6, 1, 14, 0),
  96. ),
  97. // 系统公告(已读)
  98. MessageModel(
  99. id: '7',
  100. title: '关于启用新版报销流程的通知',
  101. content: '自2026年7月1日起全面启用新版报销系统',
  102. msgType: 'announcement',
  103. bizType: 'announcement',
  104. bizId: 'an-002',
  105. isRead: true,
  106. createTime: DateTime(2026, 5, 28, 9, 0),
  107. ),
  108. // 过期提醒
  109. MessageModel(
  110. id: '8',
  111. title: '您的差旅申请已过期,预算已释放',
  112. content: '申请单 BXSQ-20260501-002 有效期已截止',
  113. msgType: 'expiry_reminder',
  114. bizType: 'expense_application',
  115. bizId: 'ea-002',
  116. isRead: false,
  117. createTime: DateTime(2026, 6, 1, 8, 0),
  118. ),
  119. ];
  120. }