report_model.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /// 报表汇总数据
  2. class ReportSummary {
  3. final double totalAmount;
  4. final int totalCount;
  5. final int approvedCount;
  6. final double approvedAmount;
  7. const ReportSummary({
  8. this.totalAmount = 0,
  9. this.totalCount = 0,
  10. this.approvedCount = 0,
  11. this.approvedAmount = 0,
  12. });
  13. factory ReportSummary.fromJson(Map<String, dynamic> json) {
  14. return ReportSummary(
  15. totalAmount: (json['totalAmount'] as num?)?.toDouble() ?? 0,
  16. totalCount: json['totalCount'] as int? ?? 0,
  17. approvedCount: json['approvedCount'] as int? ?? 0,
  18. approvedAmount: (json['approvedAmount'] as num?)?.toDouble() ?? 0,
  19. );
  20. }
  21. }
  22. /// 月度报表数据
  23. class ReportMonthlyItem {
  24. final int month;
  25. final double amount;
  26. final double approvedAmount;
  27. final int count;
  28. const ReportMonthlyItem({
  29. this.month = 0,
  30. this.amount = 0,
  31. this.approvedAmount = 0,
  32. this.count = 0,
  33. });
  34. factory ReportMonthlyItem.fromJson(Map<String, dynamic> json) {
  35. return ReportMonthlyItem(
  36. month: json['month'] as int? ?? 0,
  37. amount: (json['amount'] as num?)?.toDouble() ?? 0,
  38. approvedAmount: (json['approvedAmount'] as num?)?.toDouble() ?? 0,
  39. count: json['count'] as int? ?? 0,
  40. );
  41. }
  42. }
  43. /// 报表明细项
  44. class ReportDetailItem {
  45. final String billNo;
  46. final String? billDate;
  47. final double amount;
  48. final bool isApproved;
  49. final String reason;
  50. const ReportDetailItem({
  51. this.billNo = '',
  52. this.billDate,
  53. this.amount = 0,
  54. this.isApproved = false,
  55. this.reason = '',
  56. });
  57. factory ReportDetailItem.fromJson(Map<String, dynamic> json) {
  58. return ReportDetailItem(
  59. billNo: json['billNo'] as String? ?? '',
  60. billDate: json['billDate'] as String?,
  61. amount: (json['amount'] as num?)?.toDouble() ?? 0,
  62. isApproved: json['isApproved'] as bool? ?? false,
  63. reason: json['reason'] as String? ?? '',
  64. );
  65. }
  66. }
  67. /// 报表完整数据
  68. class ReportData {
  69. final ReportSummary summary;
  70. final List<ReportMonthlyItem> monthly;
  71. final List<ReportDetailItem> details;
  72. const ReportData({
  73. this.summary = const ReportSummary(),
  74. this.monthly = const [],
  75. this.details = const [],
  76. });
  77. factory ReportData.fromJson(Map<String, dynamic> json) {
  78. return ReportData(
  79. summary: json['summary'] != null
  80. ? ReportSummary.fromJson(json['summary'] as Map<String, dynamic>)
  81. : const ReportSummary(),
  82. monthly: (json['monthly'] as List<dynamic>?)
  83. ?.map((e) => ReportMonthlyItem.fromJson(e as Map<String, dynamic>))
  84. .toList() ??
  85. [],
  86. details: (json['details'] as List<dynamic>?)
  87. ?.map((e) => ReportDetailItem.fromJson(e as Map<String, dynamic>))
  88. .toList() ??
  89. [],
  90. );
  91. }
  92. }