view.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. import 'package:fis_common/index.dart';
  2. import 'package:fis_i18n/i18n.dart';
  3. import 'package:fis_lib_business_components/index.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:get/get.dart';
  6. import 'package:fis_ui/base_define/page.dart';
  7. import 'package:fis_ui/index.dart';
  8. import 'package:fis_jsonrpc/rpc.dart';
  9. import 'package:vitalapp/managers/interfaces/models/image_report_list_params.dart';
  10. import 'package:vitalapp/managers/interfaces/report.dart';
  11. import 'package:vitalapp/pages/image_report_inner_view/widgets/expansion_panel.dart';
  12. import 'package:fis_measure/process/workspace/rpc_bridge.dart';
  13. import 'controller.dart';
  14. import 'widgets/cloud_image_item.dart';
  15. import 'widgets/icon_tab_list.dart';
  16. import 'widgets/image_zoom_preview_plugin.dart';
  17. import 'widgets/report_cards_view.dart';
  18. class ImageReportInnerView extends GetView<ImagereportinnerviewController>
  19. implements FPage {
  20. @override
  21. String get pageName => 'ImageReportInnerView';
  22. final double _verticalSpacing = 20.0;
  23. const ImageReportInnerView({Key? key, required this.args}) : super(key: key);
  24. /// 页面入参
  25. final ImageReportListParams args;
  26. @override
  27. Widget build(BuildContext context) {
  28. return GetBuilder<ImagereportinnerviewController>(
  29. init: ImagereportinnerviewController(args),
  30. //tag: args.recordCode,
  31. dispose: (_) {
  32. print('ImagereportinnerviewController dispose');
  33. },
  34. id: MainViewId,
  35. builder: (_) {
  36. return Column(
  37. children: [
  38. FSizedBox(
  39. height: _verticalSpacing,
  40. ),
  41. IconTabList(
  42. {
  43. i18nBook.remedical.cloudImageShort.t: Icons.cloud_outlined,
  44. i18nBook.measure.measureImageShort.t: Icons.straighten_outlined,
  45. i18nBook.remedical.checkReportShort.t: FIcons.report_a4,
  46. },
  47. selectedValue: [
  48. i18nBook.remedical.cloudImageShort.t,
  49. i18nBook.measure.measureImageShort.t,
  50. i18nBook.remedical.checkReportShort.t
  51. ][controller.selectedTabIndex],
  52. onPressed: (v) {
  53. controller.selectedTabIndex = v;
  54. if (v <= 1) {
  55. controller.loadImages();
  56. } else {
  57. controller.loadReports();
  58. }
  59. },
  60. ),
  61. FExpanded(child: _buildGridView()),
  62. const FSizedBox(height: 8),
  63. Row(
  64. mainAxisAlignment: MainAxisAlignment.center,
  65. children: [
  66. ElevatedButton(
  67. onPressed: () {
  68. if (controller.selectedTabIndex == 2) {
  69. controller.loadReports();
  70. } else {
  71. controller.loadImages();
  72. }
  73. },
  74. style: ButtonStyle(
  75. fixedSize: MaterialStateProperty.all<Size>(
  76. Size(140, 25),
  77. ),
  78. ),
  79. child: FText(i18nBook.common.refresh.t),
  80. ),
  81. if (controller.isCanWriteReport) ...[
  82. FSizedBox(
  83. width: 30,
  84. ),
  85. ElevatedButton(
  86. onPressed: () {
  87. controller.reportManager.openReportEdit(
  88. controller.patientCode,
  89. recordCode: controller.recordCode,
  90. referralRecordCode:
  91. controller.isReferral ? controller.recordCode : "",
  92. );
  93. },
  94. style: ButtonStyle(
  95. fixedSize: MaterialStateProperty.all<Size>(
  96. Size(140, 25),
  97. ),
  98. ),
  99. child: FText(i18nBook.remedical.writeReport.t),
  100. ),
  101. ],
  102. ],
  103. ),
  104. const FSizedBox(height: 8),
  105. ],
  106. );
  107. },
  108. );
  109. }
  110. FWidget _buildGridView() {
  111. if (controller.selectedTabIndex == 0) {
  112. return _cloudImages();
  113. } else if (controller.selectedTabIndex == 1) {
  114. return _buildAllMeasureImages();
  115. } else {
  116. return FReportCardsView();
  117. }
  118. }
  119. FWidget _cloudImages() {
  120. final decoration = BoxDecoration(
  121. border: Border.all(
  122. color: Colors.grey,
  123. width: 0.5,
  124. ),
  125. );
  126. List<FWidget> normalChildren = [];
  127. List<FWidget> expansionPanelChildren = [];
  128. var remedicalItemList = controller.remedicalListResult?.remedicalItemList;
  129. if (remedicalItemList?.isNotEmpty ?? false) {
  130. for (var remedicalItem in remedicalItemList!) {
  131. var applicationCategory = controller.languageConfigManager
  132. .getApplicationLanguageValue(
  133. remedicalItem.applicationCategory ?? '');
  134. var application = controller.languageConfigManager
  135. .getApplicationLanguageValue(remedicalItem.application ?? '');
  136. if (remedicalItem.patientScanTypeDesc.isNotNullOrEmpty) {
  137. ///左颈动脉图像集合
  138. var carotidLeftImages = remedicalItem.remedicalList
  139. ?.where((element) =>
  140. element.carotidResult?.carotidScanType ==
  141. CarotidScanTypeEnum.CarotidLeft)
  142. .toList() ??
  143. [];
  144. ///右颈动脉图像集合
  145. var carotidRightImages = remedicalItem.remedicalList
  146. ?.where((element) =>
  147. element.carotidResult?.carotidScanType ==
  148. CarotidScanTypeEnum.CarotidRight)
  149. .toList() ??
  150. [];
  151. ///非颈动脉(或未识别左右颈)图像集合
  152. var notCarotidImages = remedicalItem.remedicalList
  153. ?.where(
  154. (element) => ![
  155. CarotidScanTypeEnum.CarotidRight,
  156. CarotidScanTypeEnum.CarotidLeft
  157. ].contains(element.carotidResult?.carotidScanType),
  158. )
  159. .toList() ??
  160. [];
  161. expansionPanelChildren.add(
  162. FExpansionPanel(
  163. body: FColumn(
  164. children: [
  165. if (carotidLeftImages.isNotEmpty ||
  166. carotidRightImages.isNotEmpty) ...[
  167. _buildCarotidTabs(carotidLeftImages.isNotEmpty,
  168. carotidRightImages.isNotEmpty),
  169. ],
  170. if (controller.carotidVAS ==
  171. CarotidScanTypeEnum.CarotidLeft &&
  172. carotidLeftImages.isNotEmpty) ...[
  173. FContainer(
  174. decoration: decoration,
  175. padding: EdgeInsets.all(5),
  176. margin: EdgeInsets.only(bottom: 5),
  177. child: _buildGridCloudImagesView(carotidLeftImages),
  178. ),
  179. ] else if (controller.carotidVAS ==
  180. CarotidScanTypeEnum.CarotidRight &&
  181. carotidRightImages.isNotEmpty) ...[
  182. FContainer(
  183. decoration: decoration,
  184. padding: EdgeInsets.all(5),
  185. margin: EdgeInsets.only(bottom: 5),
  186. child: _buildGridCloudImagesView(carotidRightImages),
  187. ),
  188. ],
  189. _buildGridCloudImagesView(
  190. notCarotidImages,
  191. ),
  192. ],
  193. ),
  194. title: application.isNullOrEmpty
  195. ? applicationCategory
  196. : '$applicationCategory-$application',
  197. ),
  198. );
  199. } else {
  200. normalChildren.add(
  201. _buildGridCloudImagesView(remedicalItem.remedicalList ?? []),
  202. );
  203. }
  204. }
  205. } else {
  206. return _noDataWidget();
  207. }
  208. return FListView(
  209. shrinkWrap: true,
  210. children: [...expansionPanelChildren, ...normalChildren],
  211. );
  212. }
  213. FWidget _buildGridCloudImagesView(List<RemedicalInfoDTO> images) {
  214. if (images.isEmpty) {
  215. return FSizedBox();
  216. }
  217. List<RemedicalInfoDTO> allCloudImages = controller.allCloudImages;
  218. return FGridView(
  219. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  220. crossAxisCount: 2,
  221. ),
  222. shrinkWrap: true,
  223. children: images.map((imageInfo) {
  224. var result = CloudImageItem(
  225. allCloudImages.indexOf(imageInfo),
  226. imageInfo,
  227. onTap: () {},
  228. onDoubleTap: () {
  229. _handleDoubleClick(
  230. imageInfo.terminalImages?.imageUrl ?? '',
  231. images.indexOf(imageInfo),
  232. imageInfo.remedicalCode ?? '',
  233. imageInfo.remedicalCode,
  234. );
  235. },
  236. description: '',
  237. //TODO(Loki):翻译
  238. // translation_delegate_helper.translateDescription(
  239. // imageInfo.application,
  240. // imageInfo.applicationCategory,
  241. // ),
  242. isSelected: false,
  243. //imageWidth: 300,
  244. );
  245. return result;
  246. }).toList(),
  247. );
  248. }
  249. FWidget _noDataWidget() {
  250. return NoDataWidget();
  251. }
  252. void _handleDoubleClick(String imageUrl, int index, String remedicalCode,
  253. String? remedicalAISelectedInfoCode) {
  254. final reportManager = Get.find<IReportManager>();
  255. RPCBridge.ins.source = VidImageSource.Remedical;
  256. reportManager.enterVidMeasurePage(
  257. imageUrl: imageUrl,
  258. imageindex: index,
  259. remedicalCode: remedicalCode,
  260. patientCode: controller.patientCode,
  261. recordCode: controller.recordCode,
  262. remedicalAISelectedInfoCode: remedicalAISelectedInfoCode,
  263. );
  264. }
  265. FWidget _buildIndex(int index) {
  266. return FPositioned(
  267. left: 15,
  268. top: 15,
  269. child: FText(
  270. (index + 1).toString(),
  271. style: TextStyle(color: Colors.white),
  272. ),
  273. );
  274. }
  275. FWidget _buildAllMeasureImages() {
  276. if (controller.measureImages.isNotEmpty) {
  277. return FColumn(
  278. mainAxisAlignment: MainAxisAlignment.start,
  279. children: [
  280. if (controller.measureImages.isNotEmpty) ...[
  281. if (controller.isExpandMeasureImages) ...[
  282. FContainer(
  283. constraints: BoxConstraints(
  284. maxHeight: Get.height * 0.9,
  285. ),
  286. margin: EdgeInsets.symmetric(horizontal: 10),
  287. color: Colors.grey[200],
  288. child: _buildMeasureImages(),
  289. ),
  290. ],
  291. ],
  292. ],
  293. );
  294. }
  295. return _noDataWidget();
  296. }
  297. FWidget _buildMeasureImages() {
  298. return FGridView(
  299. shrinkWrap: true,
  300. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  301. crossAxisCount: 2,
  302. ),
  303. children: controller.measureImages
  304. .map(
  305. (imageInfo) => FStack(
  306. children: [
  307. FPositioned(
  308. top: 0,
  309. bottom: 0,
  310. right: 0,
  311. left: 0,
  312. child: FContainer(
  313. margin: EdgeInsets.all(2),
  314. color: Colors.black,
  315. child: FImage.network(imageInfo.measuredFileToken ?? ''),
  316. ),
  317. ),
  318. _buildIndex(controller.measureImages.indexOf(imageInfo)),
  319. FPositioned(
  320. right: 15,
  321. top: 15,
  322. child: FImageZoomInPlugin(
  323. imageUrl: imageInfo.measuredFileToken,
  324. child: FIcon(
  325. Icons.zoom_in,
  326. color: Colors.white,
  327. size: 32,
  328. ),
  329. ),
  330. ),
  331. ],
  332. ),
  333. )
  334. .toList(),
  335. );
  336. }
  337. FWidget _buildCarotidTabs(
  338. bool carotidLeftIsNotEmpty, bool carotidRightIsNotEmpty) {
  339. return FContainer(
  340. margin: EdgeInsets.only(top: 5, left: 0),
  341. child: FRow(
  342. children: [
  343. if (carotidLeftIsNotEmpty) ...[
  344. _buildInkWell(
  345. CarotidScanTypeEnum.CarotidLeft,
  346. ),
  347. ],
  348. if (carotidRightIsNotEmpty) ...[
  349. _buildInkWell(
  350. CarotidScanTypeEnum.CarotidRight,
  351. )
  352. ],
  353. ],
  354. ),
  355. );
  356. }
  357. FWidget _buildInkWell(
  358. CarotidScanTypeEnum carotidScanType,
  359. ) {
  360. final isChooseLeftCarotid = controller.carotidVAS == carotidScanType;
  361. final isLeftCarotid = carotidScanType == CarotidScanTypeEnum.CarotidLeft;
  362. return FInkWell(
  363. onTap: () {
  364. controller.carotidVAS = carotidScanType;
  365. controller.update([MainViewId]);
  366. },
  367. child: FContainer(
  368. decoration: BoxDecoration(
  369. border: Border.all(
  370. width: 0.5,
  371. color: Colors.grey,
  372. ),
  373. color: isChooseLeftCarotid
  374. ? const Color(0xff2c77e5)
  375. : Colors.transparent,
  376. borderRadius: isLeftCarotid
  377. ? BorderRadius.only(
  378. topLeft: Radius.circular(4),
  379. )
  380. : BorderRadius.only(
  381. topRight: Radius.circular(4),
  382. ),
  383. ),
  384. padding: EdgeInsets.symmetric(
  385. horizontal: 20,
  386. vertical: 5,
  387. ),
  388. child: FText(
  389. isLeftCarotid
  390. ? i18nBook.remedical.leftNeck.t
  391. : i18nBook.remedical.rightNeck.t,
  392. style: TextStyle(
  393. color: isChooseLeftCarotid ? Colors.white : Colors.black,
  394. ),
  395. ),
  396. ),
  397. );
  398. }
  399. }