Browse Source

json序列化格式改变&实现DateTime类型数据驱动

loki.wu 2 years ago
parent
commit
7288afe4cb

File diff suppressed because it is too large
+ 259 - 1911
assets/single_image.json


+ 45 - 522
assets/test.json

@@ -1,522 +1,45 @@
-{
-	"HeadInfos": [],
-	"BlockInfos": [{
-		"Index": null,
-		"Id": "751a3122-4118-4e53-82a9-c6d15b6dbeed",
-		"ElementType": {
-			"Name": "RTTable"
-		},
-		"MeasureTag": null,
-		"Cells": [{}, {
-			"Index": null,
-			"Id": "130a84bd-6adf-4497-8bc7-3be44439d04e",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "c760d81e-ff14-4dcb-8082-bec7fc93382b",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "1790e450-19a6-4000-8895-3dda6a43aef9",
-					"ElementType": {
-						"Name": "InputText"
-					},
-					"MeasureTag": null,
-					"IsReadOnly": false,
-					"Text": "北京协和医院"
-				}]
-			}
-		}, {}, {
-			"Index": null,
-			"Id": "ab834a78-669a-49a2-a30c-2810b7e2e14d",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "d80b3dcd-a7ab-4fea-a4fd-e2dc8cf7718a",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "ab3b3430-0063-4a35-9049-0489d2e784fd",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}]
-			}
-		}]
-	}, {
-		"Index": null,
-		"Id": "17c4e774-4eb9-4853-9638-179716f58d80",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "d723cd84-6ec4-466d-970c-983d5fe52592",
-			"ElementType": {
-				"Name": "Line"
-			},
-			"MeasureTag": null
-		}]
-	}, {
-		"Index": null,
-		"Id": "9566ab39-7054-4b22-8cfe-797f5dca74dc",
-		"ElementType": {
-			"Name": "RTTable"
-		},
-		"MeasureTag": null,
-		"Cells": [{}, {
-			"Index": null,
-			"Id": "711880db-7210-4f0a-8b50-4e8f663ca0a4",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "24d66f5a-66c5-43cb-b6f1-5d969d301811",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "d8b059ef-e16e-4d7c-9751-383c70f3a849",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "97ec1395-3e8d-4ca9-a36a-0baace5646da",
-					"ElementType": {
-						"Name": "InputText"
-					},
-					"MeasureTag": null,
-					"IsReadOnly": false,
-					"Text": "34"
-				}]
-			}
-		}, {}, {
-			"Index": null,
-			"Id": "41741482-283e-469b-bd19-9c1cc1d81432",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "472f3f26-a2b7-4654-bc1f-e3a8e25fd7ff",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "44010909-8ea4-4514-89eb-a873f99848fa",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "f2e65e15-1a55-47ca-9e6c-42f9e8659daf",
-					"ElementType": {
-						"Name": "SingleSelected"
-					},
-					"MeasureTag": null,
-					"SelectedItem": "女"
-				}]
-			}
-		}, {}, {
-			"Index": null,
-			"Id": "03c02be3-a13e-4552-9166-0e9e28799b58",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "28f6a71f-7453-44b3-b58b-ec4cd36a430f",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "f7c983a0-9f3f-493b-87fa-a330659d1887",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "b84a9cbb-1b06-49b4-b8c5-6b2a57e24a58",
-					"ElementType": {
-						"Name": "InputText"
-					},
-					"MeasureTag": null,
-					"IsReadOnly": false,
-					"Text": "22"
-				}]
-			}
-		}, {}, {
-			"Index": null,
-			"Id": "0c50f679-5521-492d-a612-eb137908ac0a",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "055568cd-6da1-4e2b-a4b1-1da1a1aca808",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "a037f6e1-9523-4271-aab2-3da65556963d",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "135ec3fe-1a2b-46dd-98d7-cfbee06e2d66",
-					"ElementType": {
-						"Name": "SingleSelected"
-					},
-					"MeasureTag": null,
-					"SelectedItem": "门诊"
-				}]
-			}
-		}, {}, {
-			"Index": null,
-			"Id": "93595074-4bf7-460e-95e4-b4eb9200108b",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "1f7d513f-a1c2-4b78-ae6e-71e885caa861",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "00871429-03fc-49cc-881f-e0c80d6225f2",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "384adcda-7209-4ee8-b4fa-94dd27c3899f",
-					"ElementType": {
-						"Name": "InputText"
-					},
-					"MeasureTag": null,
-					"IsReadOnly": false,
-					"Text": "2222"
-				}]
-			}
-		}, {}, {
-			"Index": null,
-			"Id": "a4cd95ea-9fad-45d8-bf39-a653295715c3",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "a196aefa-5f66-46cc-a994-4ec6a3d988da",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "cfbeec23-2da4-4b4f-8ff6-914cefa6c8bd",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "457086a8-1129-4847-8e7a-761aae984afd",
-					"ElementType": {
-						"Name": "MultiSelected"
-					},
-					"MeasureTag": null,
-					"Items": ["胎儿", "子宫", "附件", "盆腔", "肝脏", "胆囊", "胆管", "胰腺", "脾脏", "双肾", "输尿管", "膀胱", "前列腺", "乳腺", "肠系膜淋巴结", "甲状腺", "心脏", "外周浅表"],
-					"SelectedItems": ["子宫", "盆腔"]
-				}]
-			}
-		}]
-	}, {
-		"Index": null,
-		"Id": "1478294c-83b5-482b-9544-eda2d62a40a0",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "02818a86-08b2-411c-9e60-aaa0b4dd67e4",
-			"ElementType": {
-				"Name": "Line"
-			},
-			"MeasureTag": null
-		}]
-	}, {
-		"Index": null,
-		"Id": "cc81bba9-8d32-4389-a18e-f64ac3890ec9",
-		"ElementType": {
-			"Name": "ImageList"
-		},
-		"MeasureTag": null,
-		"Column": 2,
-		"HasGap": true,
-		"IsReadOnly": false,
-		"IsSelected": true,
-		"SelectedImages": ["http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/7b691945305c4a548fb0decbd7486d3a.VID"]
-	}, {
-		"Index": null,
-		"Id": "8c230349-282b-45ea-9a82-fa7439359779",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "ba0ee5f3-ec37-42bb-8397-17dcde14a783",
-			"ElementType": {
-				"Name": "Line"
-			},
-			"MeasureTag": null
-		}]
-	}, {
-		"Index": null,
-		"Id": "18d10ed0-f9d0-41bc-91bb-513b67495d2a",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "8ff52703-d28f-4d2e-84af-7a1d9a1e671f",
-			"ElementType": {
-				"Name": "StaticText"
-			},
-			"MeasureTag": null
-		}]
-	}, {
-		"Index": null,
-		"Id": "e132f6e4-9d0c-4876-a60a-727d4ac8c871",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "e9e4b446-2f64-479c-8e15-cdda067cd00b",
-			"ElementType": {
-				"Name": "InputText"
-			},
-			"MeasureTag": null,
-			"IsReadOnly": false,
-			"Text": "测试描述"
-		}]
-	}, {
-		"Index": null,
-		"Id": "1884e6ca-d244-4612-9b8e-92113f06452e",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "6dabd9ea-f751-465f-a442-6a807ec601c3",
-			"ElementType": {
-				"Name": "StaticText"
-			},
-			"MeasureTag": null
-		}]
-	}, {
-		"Index": null,
-		"Id": "4b8fe5ef-e27b-411e-8f0a-64e9f01ddee1",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "8b498af9-fbe4-4bfa-b3eb-2b02ebd785a1",
-			"ElementType": {
-				"Name": "InputText"
-			},
-			"MeasureTag": null,
-			"IsReadOnly": false,
-			"Text": "测试提示"
-		}]
-	}, {
-		"Index": null,
-		"Id": "61ac1bc3-3b57-4fae-b41c-02774d54cc2f",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": []
-	}],
-	"FooterInfos": [{
-		"Index": null,
-		"Id": "776ceee6-5fad-4bd4-b7dc-170780285c09",
-		"ElementType": {
-			"Name": "RTTable"
-		},
-		"MeasureTag": null,
-		"Cells": [{}, {
-			"Index": null,
-			"Id": "74acabd7-c9dd-4b33-a2e1-29bc68ad3213",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "570c172b-565d-4cdf-9fb1-bc0c2ffa6058",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "5e7897db-f179-41b1-8ec7-87f27fee7d16",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "415df52f-3fef-46c5-a39f-c3e3090e79f2",
-					"ElementType": {
-						"Name": "DateTime"
-					},
-					"MeasureTag": null,
-					"Text": null,
-					"DateTimeFormat": "yyyy-MM-dd"
-				}]
-			}
-		}, {}, {
-			"Index": null,
-			"Id": "d1acf321-fd61-474b-a62d-d7d8f317cac2",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "060b7196-35a7-4665-a8e9-4178bb1281da",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "c8c06849-5f7a-4f25-9648-20533ee38d10",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "35fbecf3-7900-479d-8d97-2daf23150be6",
-					"ElementType": {
-						"Name": "InputText"
-					},
-					"MeasureTag": null,
-					"IsReadOnly": false,
-					"Text": "测试医师"
-				}]
-			}
-		}, {}, {
-			"Index": null,
-			"Id": "7e04df27-82e9-4fdd-ba56-c540ae7943ce",
-			"ElementType": {
-				"Name": "RTCell"
-			},
-			"MeasureTag": null,
-			"Blocks": {
-				"Index": null,
-				"Id": "9f777412-27ef-497f-8fdc-1b164eabc38e",
-				"ElementType": {
-					"Name": "Paragraph"
-				},
-				"MeasureTag": null,
-				"ElementInfos": [{
-					"Index": null,
-					"Id": "e8c22148-13ea-4acb-a2f0-1879ab5221bd",
-					"ElementType": {
-						"Name": "StaticText"
-					},
-					"MeasureTag": null
-				}, {
-					"Index": null,
-					"Id": "5c51bdd6-6a10-40d3-8bcf-5a6a952d8ec7",
-					"ElementType": {
-						"Name": "InputText"
-					},
-					"MeasureTag": null,
-					"IsReadOnly": true,
-					"Text": ""
-				}]
-			}
-		}]
-	}, {
-		"Index": null,
-		"Id": "3eb0697f-c9aa-44ec-b8ed-dbc570c31939",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "21bec319-e085-47ab-863e-38a47afa07b0",
-			"ElementType": {
-				"Name": "Line"
-			},
-			"MeasureTag": null
-		}]
-	}, {
-		"Index": null,
-		"Id": "de3031d7-0e15-40d3-ab42-74b36876e8ee",
-		"ElementType": {
-			"Name": "Paragraph"
-		},
-		"MeasureTag": null,
-		"ElementInfos": [{
-			"Index": null,
-			"Id": "3237c3c0-ac80-414b-a588-65e0181b3807",
-			"ElementType": {
-				"Name": "StaticText"
-			},
-			"MeasureTag": null
-		}]
-	}]
-}
+[
+    {
+        "Key": "4abbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "2022-07-06T14:44:57"
+    },
+    {
+        "Key": "5abbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "VAid"
+    },
+    {
+        "Key": "6abbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "VAid"
+    },
+    {
+        "Key": "91bbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "苏灿"
+    },
+    {
+        "Key": "92bbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "26"
+    },
+    {
+        "Key": "93bbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "1"
+    },
+    {
+        "Key": "9fbbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": [
+            "http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E8%83%8E%E5%84%BF2.VID",
+            "http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E8%83%8E%E5%84%BF1.VID"
+        ]
+    },
+    {
+        "Key": "9dbbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "图1 肝脏大小形态正常,包膜光整,实质回声密集增强。内另见一个高回声区,大小约 1.34cm x\r\n     0.91cm ,边界清,内部回声均匀。\r\n图2 内见一个强回声区,大小约 0.69cm x 0.38cm ,后方有声影。余肝实质回声均匀。"
+    },
+    {
+        "Key": "9ebbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "图1 1.符合脂肪肝声像图改变 \r\n    2.肝血管瘤\r\n图2 肝内强回声灶"
+    },
+    {
+        "Key": "7abbaa61-a91d-4399-a3f4-df29117d2d59",
+        "Value": "VINNO"
+    }
+]

+ 48 - 37
lib/main.dart

@@ -130,43 +130,54 @@ class _MyHomePageState extends State<MyHomePage> {
               ],
             ),
           ),
-          Wrap(
-            children: [
-              MaterialButton(
-                  child: Text('testAI'),
-                  onPressed: () {
-                    ReportInfo.instance
-                        .reload('test', DateTime.now(), _aiJson, onSelect);
-                  }),
-              MaterialButton(
-                  child: Text('testDefault'),
-                  onPressed: () {
-                    ReportInfo.instance
-                        .reload('default', DateTime.now(), _jsonStr, onSelect);
-                  }),
-              MaterialButton(
-                  child: Text('testPet'),
-                  onPressed: () {
-                    ReportInfo.instance
-                        .reload('pet', DateTime.now(), _petStr, onSelect);
-                  }),
-              MaterialButton(
-                  child: Text('onClose'),
-                  onPressed: () {
-                    ReportInfo.instance.onClose.emit(this, null);
-                  }),
-              MaterialButton(
-                  child: Text('open'),
-                  onPressed: () {
-                    setState(() {});
-                  }),
-              MaterialButton(
-                  child: Text('testInfo'),
-                  onPressed: () {
-                    final reportMap = jsonDecode(_testStr);
-                    ReportInfo.instance.fromJson(reportMap);
-                  }),
-            ],
+          SizedBox(
+            width: 400,
+            child: Wrap(
+              children: [
+                MaterialButton(
+                    child: Text('testAI'),
+                    onPressed: () {
+                      ReportInfo.instance
+                          .reload('test', DateTime.now(), _aiJson, onSelect);
+                    }),
+                MaterialButton(
+                    child: Text('testDefault'),
+                    onPressed: () {
+                      ReportInfo.instance.reload(
+                          'default', DateTime.now(), _jsonStr, onSelect);
+                    }),
+                MaterialButton(
+                    child: Text('testPet'),
+                    onPressed: () {
+                      ReportInfo.instance
+                          .reload('pet', DateTime.now(), _petStr, onSelect);
+                    }),
+                MaterialButton(
+                    child: Text('onClose'),
+                    onPressed: () {
+                      ReportInfo.instance.onClose.emit(this, null);
+                    }),
+                MaterialButton(
+                    child: Text('open'),
+                    onPressed: () {
+                      setState(() {});
+                    }),
+                MaterialButton(
+                    child: const Text('testInfo'),
+                    onPressed: () {
+                      final reportMap = jsonDecode(_testStr);
+                      ReportInfo.instance.fromJson(reportMap);
+                    }),
+                MaterialButton(
+                    child: const Text('testToJson'),
+                    onPressed: () {
+                      ReportInfo.instance.toJson();
+                      final items = ReportInfo.instance.jsonItems;
+                      final json = jsonEncode(items);
+                      print(json);
+                    }),
+              ],
+            ),
           ),
         ],
       ),

+ 16 - 2
lib/pages/components/datetime.dart

@@ -4,6 +4,7 @@ import 'package:fis_lib_report/converts/text_size_converter.dart';
 import 'package:fis_lib_report/converts/alignment_convert.dart';
 import 'package:fis_lib_report/report/dateTimeElement.dart';
 import 'package:fis_lib_report/report_info/date_time_info.dart';
+import 'package:fis_lib_report/report_info/element_tag_names.dart';
 import 'package:fis_lib_report/report_info/report_info.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
@@ -99,12 +100,25 @@ class _RDateTimeState extends State<RDateTime> {
 
   void _initDatas() {
     final dateTimeElement = widget.dateTimeElement;
-
     final format = dateTimeElement.dateTimeFormat;
-    if (format != null) {
+    final dateTimeInfo =
+        ReportInfo.instance.getElementInfo(dateTimeElement) as DateTimeInfo?;
+
+    if (format != null &&
+        dateTimeElement.tag!.name == TagNames.REPORTTIME &&
+        dateTimeInfo!.text.isEmpty) {
       _dateTimeConvert(
           format, ReportInfo.instance.reportDate!.millisecondsSinceEpoch);
     }
+    if (dateTimeInfo != null && dateTimeInfo != _dateTimeInfo) {
+      _dateTimeInfo = dateTimeInfo;
+      _dateTimeInfo!.onTextChange.addListener((sender, e) {
+        setState(() {
+          final date = DateTime.parse(_dateTimeInfo!.text);
+          _dateTimeConvert(format!, date.millisecondsSinceEpoch);
+        });
+      });
+    }
 
     _fontSize = dateTimeElement.fontSize ?? 15.0;
     //TODO(Loki):常规模板暂未设置fontStyles,后续再支持

+ 18 - 5
lib/report_info/date_time_info.dart

@@ -1,13 +1,27 @@
+import 'package:fis_lib_report/converts/event_type.dart';
 import 'package:fis_lib_report/report/dateTimeElement.dart';
 import 'package:fis_lib_report/report/interfaces/element.dart';
 import 'package:fis_lib_report/report/interfaces/inputText.dart';
 import 'package:fis_lib_report/report/text_element.dart';
+import 'package:fis_lib_report/report_info/report_info.dart';
 import 'package:fis_lib_report/report_info/text_element_info.dart';
 
 class DateTimeInfo extends TextElementInfo {
-  String? text;
+  ///UI绑定的文本
+  String get text => _text;
+  set text(String v) {
+    _text = v;
+    onTextChange.emit(this, v);
+  }
+
+  ///文本改变通知UI变化
+  FEventHandler<String> onTextChange = FEventHandler<String>();
+
+  ///日期格式
   String? dateTimeFormat = 'yyyy-MM-dd';
 
+  String _text = '';
+
   DateTimeInfo.fromElement(DateTimeElement element)
       : super.fromElement(element) {
     dateTimeFormat = element.dateTimeFormat;
@@ -16,10 +30,9 @@ class DateTimeInfo extends TextElementInfo {
   @override
   Map<String, dynamic> toJson() {
     final map = <String, dynamic>{};
-    map.addAll(super.toJson());
-
-    map['Text'] = text;
-    map['DateTimeFormat'] = dateTimeFormat;
+    map['Key'] = id;
+    map['Value'] = text;
+    ReportInfo.instance.jsonItems.add(map);
     return map;
   }
 }

+ 3 - 0
lib/report_info/element_tag_names.dart

@@ -16,4 +16,7 @@ class TagNames {
 
   ///超声提示
   static const String REPORTSUMARY = "ReportSummary";
+
+  ///报告时间
+  static const String REPORTTIME = "ReportTime";
 }

+ 4 - 6
lib/report_info/input_image_list_info.dart

@@ -2,6 +2,7 @@ import 'package:fis_lib_report/converts/event_type.dart';
 import 'package:fis_lib_report/report/inputImageList.dart';
 import 'package:fis_lib_report/report_info/block_element_info_interface.dart';
 import 'package:fis_lib_report/report_info/element_info.dart';
+import 'package:fis_lib_report/report_info/report_info.dart';
 
 class InputImageListInfo extends ElementInfo implements IBlockElementInfo {
   ///列数
@@ -47,12 +48,9 @@ class InputImageListInfo extends ElementInfo implements IBlockElementInfo {
   @override
   Map<String, dynamic> toJson() {
     final map = <String, dynamic>{};
-    map.addAll(super.toJson());
-    map['Column'] = column;
-    map['HasGap'] = hasGap;
-    map['IsReadOnly'] = isReadOnly;
-    map['IsSelected'] = isSelected;
-    map['SelectedImages'] = selectedImages;
+    map['Key'] = tag!.id;
+    map['Value'] = selectedImages;
+    ReportInfo.instance.jsonItems.add(map);
     return map;
   }
 }

+ 6 - 3
lib/report_info/input_text_info.dart

@@ -1,5 +1,8 @@
+import 'dart:convert';
+
 import 'package:fis_lib_report/converts/event_type.dart';
 import 'package:fis_lib_report/report/inputText.dart';
+import 'package:fis_lib_report/report_info/report_info.dart';
 import 'package:fis_lib_report/report_info/text_element_info.dart';
 
 class InputTextInfo extends TextElementInfo {
@@ -30,9 +33,9 @@ class InputTextInfo extends TextElementInfo {
   @override
   Map<String, dynamic> toJson() {
     final map = <String, dynamic>{};
-    map.addAll(super.toJson());
-    map['IsReadOnly'] = isReadOnly;
-    map['Text'] = text;
+    map['Key'] = tag!.id;
+    map['Value'] = text;
+    ReportInfo.instance.jsonItems.add(map);
     return map;
   }
 }

+ 4 - 3
lib/report_info/multi_selected_info.dart

@@ -1,6 +1,7 @@
 import 'package:fis_lib_report/converts/event_type.dart';
 import 'package:fis_lib_report/report/interfaces/element.dart';
 import 'package:fis_lib_report/report/multiSelected.dart';
+import 'package:fis_lib_report/report_info/report_info.dart';
 import 'package:fis_lib_report/report_info/text_element_info.dart';
 
 class MulitiSelectedInfo extends TextElementInfo {
@@ -31,9 +32,9 @@ class MulitiSelectedInfo extends TextElementInfo {
   @override
   Map<String, dynamic> toJson() {
     final map = <String, dynamic>{};
-    map.addAll(super.toJson());
-    map['Items'] = items;
-    map['SelectedItems'] = selectedItems;
+    map['Key'] = tag!.id;
+    map['Value'] = selectedItems;
+    ReportInfo.instance.jsonItems.add(map);
     return map;
   }
 }

+ 4 - 4
lib/report_info/report_base_info.dart

@@ -227,7 +227,7 @@ class ReportBaseInfo {
         return null;
       }
       for (var e in headers) {
-        if (e.id == id) {
+        if (e.tag != null && e.tag!.id == id) {
           return e;
         }
         final elementInfo = _getBaseElementInfoById(e, id);
@@ -236,7 +236,7 @@ class ReportBaseInfo {
         }
       }
       for (var e in blocks) {
-        if (e.id == id) {
+        if (e.tag != null && e.tag!.id == id) {
           return e;
         }
         final elementInfo = _getBaseElementInfoById(e, id);
@@ -245,7 +245,7 @@ class ReportBaseInfo {
         }
       }
       for (var e in footers) {
-        if (e.id == id) {
+        if (e.tag != null && e.tag!.id == id) {
           return e;
         }
         final elementInfo = _getBaseElementInfoById(e, id);
@@ -266,7 +266,7 @@ class ReportBaseInfo {
     if (type!.name == ElementType.paragraph.name) {
       final paragraph = block as ParagraphInfo;
       for (var el in paragraph.elementInfos!) {
-        if (el.tag != null && el.id == id) {
+        if (el.tag != null && el.tag!.id == id) {
           result = el;
           break;
         }

+ 39 - 17
lib/report_info/report_info.dart

@@ -3,6 +3,7 @@ import 'package:fis_lib_report/report/element_type.dart';
 import 'package:fis_lib_report/report/interfaces/block_element.dart';
 import 'package:fis_lib_report/report/interfaces/element.dart';
 import 'package:fis_lib_report/report_info/block_element_info_interface.dart';
+import 'package:fis_lib_report/report_info/date_time_info.dart';
 import 'package:fis_lib_report/report_info/element_info.dart';
 import 'package:fis_lib_report/report_info/element_tag_names.dart';
 import 'package:fis_lib_report/report_info/input_image_info.dart';
@@ -20,6 +21,9 @@ class ReportInfo extends ReportBaseInfo {
 
   ReportInfo._internal();
 
+  ///ReportInfo的key-value的数据集合
+  List<dynamic> jsonItems = [];
+
   ///选择词条按钮点击时触发
   FEventHandler<String> onDiagnosticTap = FEventHandler();
 
@@ -30,23 +34,40 @@ class ReportInfo extends ReportBaseInfo {
   }
 
   ///从Json中加载数据
-  void fromJson(Map<String, dynamic> json) {
-    List<dynamic> jsonBlocks = json['BlockInfos'];
-    if (jsonBlocks.isNotEmpty) {
-      for (var block in jsonBlocks) {
-        _blockElementInfoFromJson(block);
-      }
-    }
-    List<dynamic> jsonHeaders = json['HeadInfos'];
-    if (jsonHeaders.isNotEmpty) {
-      for (var block in jsonHeaders) {
-        _blockElementInfoFromJson(block);
-      }
-    }
-    List<dynamic> jsonFooters = json['FooterInfos'];
-    if (jsonFooters.isNotEmpty) {
-      for (var block in jsonFooters) {
-        _blockElementInfoFromJson(block);
+  void fromJson(List<dynamic> json) {
+    for (var item in json) {
+      final itemJson = item as Map<String, dynamic>;
+      final key = itemJson['Key'];
+      final value = itemJson['Value'];
+      final elementInfo = getElementInfoById(key);
+      if (elementInfo != null) {
+        final elementType = elementInfo.elementType;
+        if (elementType!.name == ElementType.inputText.name) {
+          final inputInfo = elementInfo as InputTextInfo;
+          inputInfo.text = value;
+        } else if (elementType.name == ElementType.singleSelected.name) {
+          final info = elementInfo as SingleSelectedInfo;
+          info.selectedItem = value;
+        } else if (elementType.name == ElementType.multiSelected.name) {
+          final info = elementInfo as MulitiSelectedInfo;
+          List<String> list = [];
+          final items = value as List<dynamic>;
+          for (var i in items) {
+            list.add(i.toString());
+          }
+          info.selectedItems = list;
+        } else if (elementType.name == ElementType.imageList.name) {
+          final imagesInfo = getElementInfoById(key) as InputImageListInfo;
+          final images = value as List<dynamic>;
+          List<String> targetImages = [];
+          for (var i in images) {
+            targetImages.add(i.toString());
+          }
+          imagesInfo.selectedImages = targetImages;
+        } else if (elementType.name == ElementType.dateTime.name) {
+          final info = elementInfo as DateTimeInfo;
+          info.text = value;
+        }
       }
     }
   }
@@ -79,6 +100,7 @@ class ReportInfo extends ReportBaseInfo {
 
   ///ReportInfo转为Json,用于报告存储至Server
   Map<String, dynamic> toJson() {
+    jsonItems.clear();
     final map = <String, dynamic>{};
     try {
       final headInfos = [];

+ 4 - 2
lib/report_info/single_selected_info.dart

@@ -1,5 +1,6 @@
 import 'package:fis_lib_report/converts/event_type.dart';
 import 'package:fis_lib_report/report/singleSelected.dart';
+import 'package:fis_lib_report/report_info/report_info.dart';
 import 'package:fis_lib_report/report_info/text_element_info.dart';
 
 class SingleSelectedInfo extends TextElementInfo {
@@ -31,8 +32,9 @@ class SingleSelectedInfo extends TextElementInfo {
   @override
   Map<String, dynamic> toJson() {
     final map = <String, dynamic>{};
-    map.addAll(super.toJson());
-    map['SelectedItem'] = selectedItem;
+    map['Key'] = tag!.id;
+    map['Value'] = selectedItem;
+    ReportInfo.instance.jsonItems.add(map);
     return map;
   }
 }

Some files were not shown because too many files changed in this diff