rt_grid.dart 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import 'package:fis_lib_report/report/cellPostion.dart';
  2. import 'package:fis_lib_report/report/element.dart';
  3. import 'package:fis_lib_report/report/element_type.dart';
  4. import 'package:fis_lib_report/report/interfaces/cell.dart';
  5. import 'package:fis_lib_report/report/interfaces/element.dart';
  6. import 'package:fis_lib_report/report/interfaces/grid.dart';
  7. import 'package:fis_lib_report/report/interfaces/position_layout.dart';
  8. import 'package:fis_lib_report/report/interfaces/report_element.dart';
  9. import 'package:fis_lib_report/report/rt_Cell.dart';
  10. class RTGrid extends Element implements IGrid {
  11. @override
  12. List<RTColumnDefinition>? columnDefinitions = [];
  13. @override
  14. List<IElement>? elements = [];
  15. @override
  16. List<RTRowDefinition>? rowDefinitions = [];
  17. bool? isDelete;
  18. bool? isInsertColumn;
  19. int? deleteRowIndex;
  20. int? deleteColumnIndex;
  21. double? divideWidth;
  22. bool? isMergeCell;
  23. int? mergeDeleteStartColumnIndex;
  24. int? mergeDeleteEndColumnIndex;
  25. Map<CellPostion, ICell>? cells = {};
  26. RTGrid(IReportElement parent) : super.fromParent(parent) {
  27. horizontalAlignment = HorizontalLayout.Left;
  28. elementType = ElementType.rtGrid;
  29. columnDefinitions = [];
  30. rowDefinitions = [];
  31. cells = {};
  32. }
  33. RTGrid.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
  34. horizontalAlignment = HorizontalLayout.Left;
  35. List<dynamic> jsonColumnDefinitions = json["ColumnDefinitions"] ?? [];
  36. jsonColumnDefinitions.forEach((map) {
  37. if (map is Map<String, dynamic>) {
  38. final rtcolumn = RTColumnDefinition.fromJson(map);
  39. columnDefinitions!.add(rtcolumn);
  40. }
  41. });
  42. isDelete = json['IsDelete'];
  43. isInsertColumn = json['IsInsertColumn'];
  44. deleteRowIndex = json['DeleteRowIndex'];
  45. deleteColumnIndex = json['DeleteColumnIndex'];
  46. divideWidth = json['DivideWidth'];
  47. isMergeCell = json['IsMergeCell'];
  48. mergeDeleteStartColumnIndex = json['MergeDeleteStartColumnIndex'];
  49. mergeDeleteEndColumnIndex = json['MergeDeleteEndColumnIndex'];
  50. List<dynamic> jsonRowDefinitions = json['RowDefinitions'] ?? [];
  51. jsonRowDefinitions.forEach((map) {
  52. if (map is Map<String, dynamic>) {
  53. final rtRow = RTRowDefinition.fromJson(map);
  54. rowDefinitions!.add(rtRow);
  55. }
  56. });
  57. //TODO(Loki): elements init
  58. List<dynamic> jsonCells = json['Cells'];
  59. int index = 0;
  60. CellPostion key = new CellPostion();
  61. jsonCells.forEach((map) {
  62. if (index.isEven) {
  63. key = CellPostion.fromJson(map);
  64. cells![key] = new ICell();
  65. } else {
  66. final jsonType = map['ElementType'];
  67. final type = ElementType.fromJson(jsonType);
  68. if (type.name == ElementType.rtCell!.name) {
  69. final cell = RTCell.fromJson(map);
  70. cells![key] = cell;
  71. }
  72. }
  73. index++;
  74. });
  75. }
  76. }