|
@@ -1,3 +1,5 @@
|
|
|
+import 'dart:html';
|
|
|
+
|
|
|
import 'package:fis_lib_report/converts/event_type.dart';
|
|
|
import 'package:fis_lib_report/report/element_tag.dart';
|
|
|
import 'package:fis_lib_report/report/element_type.dart';
|
|
@@ -10,10 +12,13 @@ import 'package:fis_lib_report/report/rt_page_size.dart';
|
|
|
import 'package:fis_lib_report/report/rt_table.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/element_tag_names.dart';
|
|
|
import 'package:fis_lib_report/report_info/input_image_info.dart';
|
|
|
import 'package:fis_lib_report/report_info/input_image_list_info.dart';
|
|
|
+import 'package:fis_lib_report/report_info/input_text_info.dart';
|
|
|
import 'package:fis_lib_report/report_info/paragraph_info.dart';
|
|
|
import 'package:fis_lib_report/report_info/rt_table_info.dart';
|
|
|
+import 'package:fis_lib_report/report_info/single_selected_info.dart';
|
|
|
|
|
|
class ReportInfo {
|
|
|
static ReportInfo? _reportInfo;
|
|
@@ -44,29 +49,55 @@ class ReportInfo {
|
|
|
|
|
|
ReportInfo._internal();
|
|
|
|
|
|
+ //报告页大小
|
|
|
RTPageSize? pageSize;
|
|
|
|
|
|
- double currentHeight = 0;
|
|
|
-
|
|
|
+//报告者
|
|
|
String? reporter;
|
|
|
|
|
|
+ //报告病人名
|
|
|
+ String? patientName;
|
|
|
+
|
|
|
+ ///病人Id
|
|
|
+ String? patinentId;
|
|
|
+
|
|
|
+ ///病人年龄
|
|
|
+ String? patientAge;
|
|
|
+
|
|
|
+ ///病人性别
|
|
|
+ String? patientSex;
|
|
|
+
|
|
|
+ ///报告日期
|
|
|
DateTime? reportDate;
|
|
|
|
|
|
+ ///报告模板
|
|
|
ReportTemplateDocument? reportTemplate;
|
|
|
|
|
|
+ ///重载
|
|
|
FEventHandler<ReportEventArgs> onReload = FEventHandler();
|
|
|
|
|
|
+ ///重载完成时触发
|
|
|
FEventHandler onReloadFinsh = FEventHandler();
|
|
|
|
|
|
+ ///关闭页面,释放监听
|
|
|
FEventHandler onClose = FEventHandler();
|
|
|
|
|
|
+ ///ReportInfo全局单例
|
|
|
static ReportInfo get instance {
|
|
|
_reportInfo ??= ReportInfo._internal();
|
|
|
return _reportInfo!;
|
|
|
}
|
|
|
|
|
|
- void init(ReportTemplateDocument reportTemplate, DateTime reportDate,
|
|
|
- String reporter) {
|
|
|
+ ///初始化ReportInfo
|
|
|
+ void init(
|
|
|
+ ReportTemplateDocument reportTemplate,
|
|
|
+ DateTime reportDate,
|
|
|
+ String reporter, {
|
|
|
+ String? patientName,
|
|
|
+ String? patinentId,
|
|
|
+ String? patientAge,
|
|
|
+ String? patientSex,
|
|
|
+ }) {
|
|
|
try {
|
|
|
this.reportTemplate = reportTemplate;
|
|
|
this.reportDate = reportDate;
|
|
@@ -86,11 +117,36 @@ class ReportInfo {
|
|
|
footers.add(_initBlockElement(element));
|
|
|
}
|
|
|
pageSize = reportTemplate.pageSize;
|
|
|
+ final nameInputInfo = getElementInfoByTagName(TagNames.PATIENT_NAME_TAG);
|
|
|
+ if (patientName != null &&
|
|
|
+ patientName.isNotEmpty &&
|
|
|
+ nameInputInfo != null) {
|
|
|
+ final inputInfo = nameInputInfo as InputTextInfo;
|
|
|
+ inputInfo.text = patientName;
|
|
|
+ }
|
|
|
+ final ageInputInfo = getElementInfoByTagName(TagNames.PATIENT_AGE_TAG);
|
|
|
+ if (patientAge != null && patientAge.isNotEmpty && ageInputInfo != null) {
|
|
|
+ final inputInfo = ageInputInfo as InputTextInfo;
|
|
|
+ inputInfo.text = patientAge;
|
|
|
+ }
|
|
|
+ final idInputInfo = getElementInfoByTagName(TagNames.PATIENT_ID_TAG);
|
|
|
+ if (patinentId != null && patinentId.isNotEmpty && idInputInfo != null) {
|
|
|
+ final inputInfo = idInputInfo as InputTextInfo;
|
|
|
+ inputInfo.text = patinentId;
|
|
|
+ }
|
|
|
+ final sexSelectedInfo = getElementInfoByTagName(TagNames.PATIENT_SEX_TAG);
|
|
|
+ if (patientSex != null &&
|
|
|
+ patientSex.isNotEmpty &&
|
|
|
+ sexSelectedInfo != null) {
|
|
|
+ final selectedInfo = sexSelectedInfo as SingleSelectedInfo;
|
|
|
+ selectedInfo.selectedItem = patientSex;
|
|
|
+ }
|
|
|
} catch (e) {
|
|
|
print(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ ///ReportInfo转为Json,用于报告存储至Server
|
|
|
Map<String, dynamic> toJson() {
|
|
|
final map = <String, dynamic>{};
|
|
|
try {
|
|
@@ -123,6 +179,7 @@ class ReportInfo {
|
|
|
this, ReportEventArgs(reportDate, reporter, jsonStr, onSelect));
|
|
|
}
|
|
|
|
|
|
+ ///获取二级ElementInfo(布局组件,非最基础的组件)
|
|
|
IBlockElementInfo? getBlockElement(IBlockElement block) {
|
|
|
final id = block.id;
|
|
|
for (var element in headers) {
|
|
@@ -142,20 +199,7 @@ class ReportInfo {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- IBlockElementInfo _initBlockElement(IBlockElement element) {
|
|
|
- final _type = element.elementType!;
|
|
|
- if (_type.name == ElementType.rtTable!.name) {
|
|
|
- final table = element as RTTable;
|
|
|
- return RTTableInfo.fromElement(table);
|
|
|
- } else if (_type.name == ElementType.paragraph!.name) {
|
|
|
- final paragraph = element as Paragraph;
|
|
|
- return ParagraphInfo.fromElement(paragraph);
|
|
|
- } else {
|
|
|
- final inputImageList = element as InputImageList;
|
|
|
- return InputImageListInfo.fromElement(inputImageList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ ///获取报告模板中当前处于选中状态的图像输入框
|
|
|
void selectedInputImage(String imageUrl) {
|
|
|
for (var element in headers) {
|
|
|
if (_checkImageisSelected(element, imageUrl)) {
|
|
@@ -174,6 +218,43 @@ class ReportInfo {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ ///跟据TagName获取Elementnt
|
|
|
+ ElementInfo? getElementInfoByTagName(String tagName) {
|
|
|
+ try {
|
|
|
+ for (var e in headers) {
|
|
|
+ if (e.tag != null && e.tag!.name == tagName) {
|
|
|
+ return e;
|
|
|
+ }
|
|
|
+ final elementInfo = _getBaseElementInfoByTagName(e, tagName);
|
|
|
+ if (elementInfo != null) {
|
|
|
+ return elementInfo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var e in blocks) {
|
|
|
+ if (e.tag != null && e.tag!.name == tagName) {
|
|
|
+ return e;
|
|
|
+ }
|
|
|
+ final elementInfo = _getBaseElementInfoByTagName(e, tagName);
|
|
|
+ if (elementInfo != null) {
|
|
|
+ return elementInfo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var e in footers) {
|
|
|
+ if (e.tag != null && e.tag!.name == tagName) {
|
|
|
+ return e;
|
|
|
+ }
|
|
|
+ final elementInfo = _getBaseElementInfoByTagName(e, tagName);
|
|
|
+ if (elementInfo != null) {
|
|
|
+ return elementInfo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ print(e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ ///跟据UI组件获取ReportInfo中的组件
|
|
|
ElementInfo? getElementInfo(IElement element) {
|
|
|
try {
|
|
|
for (var e in headers) {
|
|
@@ -200,6 +281,20 @@ class ReportInfo {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ IBlockElementInfo _initBlockElement(IBlockElement element) {
|
|
|
+ final _type = element.elementType!;
|
|
|
+ if (_type.name == ElementType.rtTable!.name) {
|
|
|
+ final table = element as RTTable;
|
|
|
+ return RTTableInfo.fromElement(table);
|
|
|
+ } else if (_type.name == ElementType.paragraph!.name) {
|
|
|
+ final paragraph = element as Paragraph;
|
|
|
+ return ParagraphInfo.fromElement(paragraph);
|
|
|
+ } else {
|
|
|
+ final inputImageList = element as InputImageList;
|
|
|
+ return InputImageListInfo.fromElement(inputImageList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
bool _checkImageisSelected(IBlockElementInfo block, String url) {
|
|
|
if (block is InputImageListInfo) {
|
|
|
final inputImage = block;
|
|
@@ -221,6 +316,7 @@ class ReportInfo {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ ///获取基础组件信息
|
|
|
ElementInfo? _getBaseElementInfo(IBlockElementInfo block, IElement element) {
|
|
|
ElementInfo? result;
|
|
|
final type = block.elementType;
|
|
@@ -252,6 +348,39 @@ class ReportInfo {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ ///获取基础组件信息
|
|
|
+ ElementInfo? _getBaseElementInfoByTagName(
|
|
|
+ IBlockElementInfo block, String tagName) {
|
|
|
+ ElementInfo? result;
|
|
|
+ final type = block.elementType;
|
|
|
+ if (type!.name == ElementType.paragraph!.name) {
|
|
|
+ final paragraph = block as ParagraphInfo;
|
|
|
+ for (var el in paragraph.elementInfos!) {
|
|
|
+ if (el.tag != null && el.tag!.name == tagName) {
|
|
|
+ result = el;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (result == null) {
|
|
|
+ if (type.name == ElementType.rtTable!.name) {
|
|
|
+ final table = block as RTTableInfo;
|
|
|
+ final cells = table.cells!;
|
|
|
+ for (var cell in cells.values) {
|
|
|
+ for (var b in cell.blocks!) {
|
|
|
+ final info = _getBaseElementInfoByTagName(b, tagName);
|
|
|
+ if (info != null) {
|
|
|
+ result = info;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
Map<String, dynamic> _getElementInfo(IBlockElementInfo element) {
|
|
|
final _type = element.elementType!;
|
|
|
if (_type.name == ElementType.rtTable!.name) {
|