main.dart 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. import 'dart:convert';
  2. import 'package:fis_lib_report/converts/event_type.dart';
  3. import 'package:fis_lib_report/converts/pt_to_px_converter.dart';
  4. import 'package:fis_lib_report/report_edit.dart';
  5. import 'package:fis_lib_report/report_info/report_info.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter/services.dart';
  8. import 'package:fis_jsonrpc/rpc.dart';
  9. import 'package:fis_lib_business_components/index.dart';
  10. import 'package:fis_i18n/i18n.dart';
  11. void main() {
  12. runApp(const MyApp());
  13. }
  14. class MyApp extends StatelessWidget {
  15. const MyApp({Key? key}) : super(key: key);
  16. // This widget is the root of your application.
  17. @override
  18. Widget build(BuildContext context) {
  19. return MaterialApp(
  20. title: 'Flutter Demo',
  21. theme: ThemeData(
  22. // This is the theme of your application.
  23. //
  24. // Try running your application with "flutter run". You'll see the
  25. // application has a blue toolbar. Then, without quitting the app, try
  26. // changing the primarySwatch below to Colors.green and then invoke
  27. // "hot reload" (press "r" in the console where you ran "flutter run",
  28. // or simply save your changes to "hot reload" in a Flutter IDE).
  29. // Notice that the counter didn't reset back to zero; the application
  30. // is not restarted.
  31. primarySwatch: Colors.blue,
  32. ),
  33. home: const MyHomePage(title: 'Flutter Demo Home Page'),
  34. );
  35. }
  36. }
  37. class MyHomePage extends StatefulWidget {
  38. const MyHomePage({Key? key, required this.title}) : super(key: key);
  39. final String title;
  40. @override
  41. State<MyHomePage> createState() => _MyHomePageState();
  42. }
  43. class _MyHomePageState extends State<MyHomePage> {
  44. String _jsonStr = '';
  45. List<String> _demoImags = [];
  46. final EdgeInsetsGeometry _padding =
  47. EdgeInsets.all(PtToPxConverter.ptToPx(56.83));
  48. late FEventHandler<String> onSelect;
  49. String _aiJson = '';
  50. String _petStr = '';
  51. String _testStr = '';
  52. String _reportInfoStr = '';
  53. @override
  54. initState() {
  55. onSelect = FEventHandler<String>();
  56. rootBundle.loadString('assets/default.json').then((jsonStr) {
  57. setState(() {
  58. _jsonStr = jsonStr;
  59. });
  60. });
  61. rootBundle.loadString('assets/single_image.json').then((jsonStr) {
  62. _aiJson = jsonStr;
  63. });
  64. rootBundle.loadString('assets/pet.json').then((jsonStr) {
  65. _petStr = jsonStr;
  66. });
  67. rootBundle.loadString('assets/test.json').then((jsonStr) {
  68. _testStr = jsonStr;
  69. });
  70. rootBundle.loadString('assets/report_info.json').then((jsonStr) {
  71. _reportInfoStr = jsonStr;
  72. });
  73. super.initState();
  74. }
  75. @override
  76. Widget build(BuildContext context) {
  77. const curLocale = Locale('zh', 'CN');
  78. var bookOptions = [
  79. FTrKeybookOption.ChineseOption,
  80. FTrKeybookOption.EnglishOption,
  81. ];
  82. FI18n.init((locale) => locale, bookOptions)
  83. .then((value) => FI18n.load(curLocale).then(
  84. (value) => setState(() {
  85. _demoImags = [
  86. 'http://cdn-bj.fis.plus/db38b8d36a7b48ada3effe0a53ea8993.jpg',
  87. 'http://cdn-bj.fis.plus/480e058b1eef47f9a9e333c3a54697eb.jpg',
  88. 'http://cdn-bj.fis.plus/0abdd310057e43c9b0d3fbe8ff854f1d.jpg',
  89. 'http://cdn-bj.fis.plus/cafd704360a24234b3c6630b771d6d42.jpg',
  90. 'http://cdn-bj.fis.plus/b93f044024a4426d90ea21a5ca8f71d1.jpg',
  91. "http://cdn-bj.fis.plus/36cd135e1b144c55a189fdde52085a5c.jpg",
  92. "http://cdn-bj.fis.plus/452e838ed56c46c7a41e59c5553db504.jpg",
  93. "http://cdn-bj.fis.plus/238f463a8bc74984b3368163417f1d70.jpg",
  94. "http://cdn-bj.fis.plus/dbf5eb4fec814001b6b91e36af5aec76.jpg",
  95. 'http://cdn-bj.fis.plus/2163bb64ebfa42cca5958b9cdbb4248d.jpg',
  96. 'http://cdn-bj.fis.plus/0743d4884601465c837f18fe0c54a7f2.jpg',
  97. 'http://cdn-bj.fis.plus/d4b4a2421e7d4b4189031ca736a52312.jpg',
  98. ];
  99. }),
  100. ));
  101. return Scaffold(
  102. backgroundColor: Colors.white,
  103. body: Row(
  104. children: [
  105. if (_jsonStr.isNotEmpty && _demoImags.isNotEmpty)
  106. Expanded(
  107. child: FReportEditPage(
  108. reporter: 'Loki',
  109. reportDate: DateTime.now(),
  110. jsonStr: _jsonStr,
  111. onSelect: onSelect,
  112. revoke: i18nBook.common.revoke.t,
  113. selectEntry: i18nBook.remedical.selectWord.t,
  114. selectImageHint: i18nBook.remedical.clickAndSelectImage.t,
  115. ),
  116. ),
  117. const SizedBox(width: 40),
  118. Container(
  119. decoration: _buildDecoration(),
  120. padding: _padding,
  121. alignment: Alignment.center,
  122. height: 800,
  123. width: 600,
  124. child: Wrap(
  125. children: [
  126. ..._demoImags.map((element) {
  127. return Container(
  128. width: 150,
  129. height: 100,
  130. margin: const EdgeInsets.all(15),
  131. child: ContentImage(
  132. fileDataType: RemedicalFileDataTypeEnum.Image,
  133. terminalImage: TerminalImage(
  134. coverImageUrl: element,
  135. previewUrl: element,
  136. imageUrl: element,
  137. ),
  138. onChangeImage: () {
  139. onSelect.emit(this, element);
  140. },
  141. ),
  142. );
  143. })
  144. ],
  145. ),
  146. ),
  147. SizedBox(
  148. width: 400,
  149. child: Wrap(
  150. children: [
  151. MaterialButton(
  152. child: const Text('testAI'),
  153. onPressed: () {
  154. ReportInfo.instance.reload(
  155. 'test',
  156. DateTime.now(),
  157. _aiJson,
  158. onSelect,
  159. i18nBook.common.revoke.t,
  160. i18nBook.remedical.selectWord.t,
  161. i18nBook.remedical.clickAndSelectImage.t);
  162. }),
  163. MaterialButton(
  164. child: const Text('testDefault'),
  165. onPressed: () {
  166. ReportInfo.instance.reload(
  167. 'default',
  168. DateTime.now(),
  169. _jsonStr,
  170. onSelect,
  171. i18nBook.common.revoke.t,
  172. i18nBook.remedical.selectWord.t,
  173. i18nBook.remedical.clickAndSelectImage.t);
  174. }),
  175. MaterialButton(
  176. child: const Text('testPet'),
  177. onPressed: () {
  178. ReportInfo.instance.reload(
  179. 'pet',
  180. DateTime.now(),
  181. _petStr,
  182. onSelect,
  183. i18nBook.common.revoke.t,
  184. i18nBook.remedical.selectWord.t,
  185. i18nBook.remedical.clickAndSelectImage.t);
  186. }),
  187. MaterialButton(
  188. child: const Text('onClose'),
  189. onPressed: () {
  190. ReportInfo.instance.onClose.emit(this, null);
  191. }),
  192. MaterialButton(
  193. child: const Text('open'),
  194. onPressed: () {
  195. setState(() {});
  196. }),
  197. MaterialButton(
  198. child: const Text('testCustomTemplate'),
  199. onPressed: () {
  200. ReportInfo.instance.reload(
  201. 'testCustomTemplate',
  202. DateTime.now(),
  203. _testStr,
  204. onSelect,
  205. i18nBook.common.revoke.t,
  206. i18nBook.remedical.selectWord.t,
  207. '');
  208. }),
  209. MaterialButton(
  210. child: const Text('testInfo'),
  211. onPressed: () {
  212. final reportMap = jsonDecode(_reportInfoStr);
  213. ReportInfo.instance.fromJson(reportMap);
  214. }),
  215. MaterialButton(
  216. child: const Text('testToJson'),
  217. onPressed: () {
  218. ReportInfo.instance.toJson();
  219. final items = ReportInfo.instance.jsonItems;
  220. final json = jsonEncode(items);
  221. print(json);
  222. }),
  223. MaterialButton(
  224. child: const Text('testDiagnostic'),
  225. onPressed: () {
  226. ReportInfo.instance.insertDiagnostic(
  227. '主动脉极度扩张,主动脉窦扩张形成主动脉窦瘤,主动脉瓣呈囊袋状。 心底短轴显示主动脉瓣的对合不良。 多普勒超声显示舒张期返流束,起自主动脉瓣射向左心室达心尖部。 二尖瓣与主动脉瓣均脱垂。左心室扩张,呈容量负荷过重。左心功能正常。',
  228. '符合冠心病间隔梗塞后的超声表现并伴室壁瘤形成,左心功能不全');
  229. }),
  230. MaterialButton(
  231. child: const Text('setMockDatas'),
  232. onPressed: () {
  233. ReportInfo.instance.setMockDatas.emit(this, '');
  234. }),
  235. ],
  236. ),
  237. ),
  238. ],
  239. ),
  240. );
  241. }
  242. BoxDecoration _buildDecoration() {
  243. return BoxDecoration(
  244. border: Border.all(
  245. width: 0.5,
  246. color: const Color.fromARGB(255, 83, 83, 83),
  247. ),
  248. color: Colors.white);
  249. }
  250. }