exam_check_guidance.dart 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:vitalapp/architecture/types/index.dart';
  4. import 'package:vitalapp/components/button.dart';
  5. import 'package:vitalapp/pages/check/models/form.dart';
  6. import 'package:vitalapp/pages/check/prescription/examination_prescription.dart';
  7. import 'package:vitalapp/pages/check/prescription/prescription_form_keys.dart';
  8. import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio_and_select.dart';
  9. import 'package:vitalapp/pages/check/widgets/exam_title.dart';
  10. class ExamCheckBoxGuidance extends StatelessWidget {
  11. static final _borderRadius = BorderRadius.circular(16.0);
  12. ExamCheckBoxGuidance({
  13. super.key,
  14. required this.currentFormObject,
  15. required this.options,
  16. required this.selectCheckBoxChange,
  17. required this.currentSelectedCheckBox,
  18. required this.physicalExamNumber,
  19. required this.patientCode,
  20. required this.createPrescription,
  21. required this.prescriptionList,
  22. this.disbaleOthers = false,
  23. });
  24. final FormObject currentFormObject;
  25. final List<Option> options;
  26. final Function selectCheckBoxChange;
  27. final List<dynamic> currentSelectedCheckBox;
  28. final String? physicalExamNumber;
  29. final String? patientCode;
  30. final ValueCallback<Map> createPrescription;
  31. final List prescriptionList;
  32. /// 禁用其他选项(除已选)
  33. final bool disbaleOthers;
  34. @override
  35. Widget build(BuildContext context) {
  36. String label = currentFormObject.label ?? '';
  37. return ExamCardRadioSelect(
  38. titleText: ExamTitle(
  39. label: label,
  40. titleType: '(多选)',
  41. ),
  42. title: label,
  43. content: Container(
  44. padding: EdgeInsets.symmetric(vertical: 16).copyWith(top: 0),
  45. child: Column(
  46. crossAxisAlignment: CrossAxisAlignment.end,
  47. children: [
  48. Container(
  49. width: 130,
  50. height: 54,
  51. alignment: Alignment.centerRight,
  52. child: VButton(
  53. onTap: () async {
  54. var prescription = await Get.dialog(
  55. ExaminationPrescription(
  56. physicalExamNumber: physicalExamNumber,
  57. patientCode: patientCode,
  58. prescription: "",
  59. prescriptionTitle: "",
  60. ),
  61. );
  62. if (prescription != null) {
  63. createPrescription.call(prescription);
  64. }
  65. },
  66. label: '新增处方',
  67. ),
  68. ),
  69. Center(
  70. child: Wrap(
  71. children: options
  72. .map(
  73. (e) => _buildItem(context, e),
  74. )
  75. .toList(),
  76. ),
  77. ),
  78. if (prescriptionList.isNotEmpty)
  79. Wrap(
  80. children: [
  81. SizedBox(width: 30),
  82. Container(
  83. margin: EdgeInsets.only(bottom: 8, top: 8),
  84. child: Text(
  85. '处方列表',
  86. style: TextStyle(
  87. fontSize: 26,
  88. fontWeight: FontWeight.bold,
  89. ),
  90. ),
  91. ),
  92. SizedBox(width: 16),
  93. ...prescriptionList.map(
  94. (e) => InkWell(
  95. radius: 8,
  96. onTap: () async {
  97. var prescription = await Get.dialog(
  98. ExaminationPrescription(
  99. physicalExamNumber: physicalExamNumber,
  100. patientCode: patientCode,
  101. prescription: e['prescription'],
  102. prescriptionTitle:
  103. '${PrescriptionFormKeys.AllFormKeys[e['prescription']]}',
  104. isEdit: true,
  105. ),
  106. );
  107. if (prescription != null) {
  108. createPrescription.call(prescription);
  109. }
  110. },
  111. child: Container(
  112. decoration: BoxDecoration(
  113. border: Border.all(
  114. color: Colors.black26,
  115. ),
  116. borderRadius: _borderRadius,
  117. ),
  118. margin: EdgeInsets.all(8),
  119. padding: const EdgeInsets.all(8),
  120. child: Text(
  121. '${PrescriptionFormKeys.AllFormKeys[e['prescription']]}',
  122. style: TextStyle(
  123. fontSize: 20,
  124. fontWeight: FontWeight.bold,
  125. ),
  126. ),
  127. ),
  128. ),
  129. ),
  130. ],
  131. ),
  132. ],
  133. ),
  134. ),
  135. );
  136. }
  137. Widget _buildItem(BuildContext context, Option e) {
  138. Color bgColor;
  139. Color txtColor;
  140. Color borderColor;
  141. if (currentSelectedCheckBox.contains(e.value)) {
  142. // 已选中
  143. final primaryColor = Theme.of(context).primaryColor;
  144. bgColor = primaryColor;
  145. txtColor = Colors.white;
  146. borderColor = primaryColor;
  147. } else {
  148. // 非选中的
  149. if (disbaleOthers) {
  150. // 含有独占选项时
  151. bgColor = Colors.grey.shade400;
  152. txtColor = Colors.white;
  153. borderColor = Colors.grey.shade400;
  154. } else {
  155. // 不含有独占选项时
  156. bgColor = Colors.transparent;
  157. txtColor = Colors.black54;
  158. borderColor = Colors.black26;
  159. }
  160. }
  161. return Container(
  162. padding: const EdgeInsets.all(8),
  163. child: InkWell(
  164. onTap: () => selectCheckBoxChange(e),
  165. borderRadius: _borderRadius,
  166. child: Ink(
  167. decoration: BoxDecoration(
  168. border: Border.all(
  169. color: borderColor,
  170. ),
  171. borderRadius: _borderRadius,
  172. color: bgColor,
  173. ),
  174. child: Container(
  175. padding: const EdgeInsets.all(15),
  176. alignment: Alignment.center,
  177. width: 250,
  178. child: FittedBox(
  179. child: Text(
  180. e.label ?? '',
  181. style: TextStyle(
  182. fontSize: 20,
  183. color: txtColor,
  184. ),
  185. ),
  186. ),
  187. ),
  188. ),
  189. ),
  190. );
  191. }
  192. }