message_model.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. MessageModel(id: '1', title: '张三的报销申请待审批', content: '报销金额 ¥2,380.00', msgType: 'approval_notice', bizType: 'expense', bizId: 'exp-001', isRead: false, createTime: DateTime(2024, 5, 22, 9, 30)),
  32. MessageModel(id: '2', title: '李四的加班申请待审批', content: '加班时长 4小时', msgType: 'approval_notice', bizType: 'overtime', bizId: 'ot-001', isRead: false, createTime: DateTime(2024, 5, 21, 14, 0)),
  33. MessageModel(id: '3', title: '报销单审批已通过', content: 'BX-20240428-002 已通过', msgType: 'approval_result', bizType: 'expense', bizId: 'exp-002', isRead: true, createTime: DateTime(2024, 5, 20, 10, 0)),
  34. MessageModel(id: '4', title: '关于启用新版报销流程的通知', content: '', msgType: 'announcement', bizType: 'announcement', bizId: 'an-002', isRead: false, createTime: DateTime(2024, 5, 19, 14, 0)),
  35. ];
  36. }