base.dart 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. import 'package:fis_common/index.dart';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:get/get.dart';
  5. import 'package:intl/intl.dart';
  6. import 'package:vitalapp/architecture/utils/datetime.dart';
  7. import 'package:vitalapp/architecture/utils/prompt_box.dart';
  8. import 'package:vitalapp/components/cell.dart';
  9. import 'package:vitalapp/components/dialog_check.dart';
  10. import 'package:vitalapp/components/dialog_date.dart';
  11. import 'package:vitalapp/components/dialog_input.dart';
  12. import 'package:vitalapp/components/dialog_profile_time_input.dart';
  13. import 'package:vitalapp/components/dialog_select.dart';
  14. import 'package:vitalapp/consts/nations.dart';
  15. import 'package:vitalapp/consts/rpc_enum_labels.dart';
  16. import 'package:vitalapp/helper/id_card_helper.dart';
  17. import 'package:vitalapp/pages/patient/info/controller.dart';
  18. import 'package:vitalapp/pages/patient/info/patientInfoRecord.dart';
  19. import 'package:fis_common/index.dart';
  20. import 'detail_infos.dart';
  21. import 'health_infos.dart';
  22. class PatientInfoBaseView extends GetView<PatientInfoController> {
  23. const PatientInfoBaseView({super.key});
  24. @override
  25. Widget build(BuildContext context) {
  26. final scrollerController = ScrollController();
  27. return Scrollbar(
  28. child: SingleChildScrollView(
  29. controller: scrollerController,
  30. padding: const EdgeInsets.only(left: 16, right: 16, bottom: 50),
  31. child: _HealthInfoPanel(),
  32. ),
  33. );
  34. }
  35. }
  36. class _HealthInfoPanel extends GetView<PatientInfoController> {
  37. @override
  38. Widget build(BuildContext context) {
  39. return VListFormCellGroup(
  40. children: [
  41. VListFormCellGroup(
  42. formTitle: "基本信息",
  43. children: _buildBaseInfo(),
  44. ),
  45. DetailInfos(),
  46. HealthInfos(),
  47. ],
  48. );
  49. }
  50. List<Widget> _buildBaseInfo() {
  51. final state = controller.state;
  52. return [
  53. Obx(
  54. () => VListFormCell(
  55. label: "姓名",
  56. content: controller.state.name,
  57. onTap: () async {
  58. final result = await VDialogInput(
  59. title: "姓名",
  60. initialValue: controller.state.name,
  61. placeholder: "请填写姓名",
  62. ).show();
  63. if (result != null) {
  64. controller.state.name = result;
  65. }
  66. },
  67. endIcon: _buildEndIcon(),
  68. ),
  69. ),
  70. Obx(
  71. () => VListFormCell(
  72. label: "手机号码",
  73. content: controller.state.phoneNo,
  74. onTap: () async {
  75. final result = await VDialogInput(
  76. title: "手机号码",
  77. initialValue: controller.state.phoneNo,
  78. placeholder: "请填写手机号码",
  79. ).show();
  80. if (result != null) {
  81. controller.state.phoneNo = result;
  82. }
  83. },
  84. endIcon: _buildEndIcon(),
  85. ),
  86. ),
  87. Obx(
  88. () => VListFormCell(
  89. label: "紧急联系手机号",
  90. content: controller.state.emergencyPhone,
  91. onTap: () async {
  92. final result = await VDialogInput(
  93. title: "紧急联系手机号",
  94. initialValue: controller.state.emergencyPhone,
  95. placeholder: "请填写紧急联系手机号",
  96. ).show();
  97. if (result != null) {
  98. controller.state.emergencyPhone = result;
  99. }
  100. },
  101. ),
  102. ),
  103. Obx(
  104. () => VListFormCell(
  105. label: "性别",
  106. content: RpcEnumLabels.gender[state.gender],
  107. onTap: () async {
  108. final result = await VDialogSelect<GenderEnum, GenderEnum>(
  109. title: "选择性别",
  110. source: const [
  111. GenderEnum.Male,
  112. GenderEnum.Female,
  113. GenderEnum.Unknown,
  114. GenderEnum.Unspecified
  115. ],
  116. valueGetter: (data) => data,
  117. labelGetter: (data) => RpcEnumLabels.gender[data] ?? "",
  118. initialValue: state.gender,
  119. ).show();
  120. if (result != null) {
  121. controller.state.gender = result;
  122. }
  123. },
  124. endIcon: _buildEndIcon(),
  125. ),
  126. ),
  127. Obx(
  128. () => VListFormCell(
  129. label: "民族",
  130. content: state.nation,
  131. onTap: () async {
  132. final result = await VDialogSelect<String, String>(
  133. title: "选择民族",
  134. source: Nations.china,
  135. valueGetter: (data) => data,
  136. labelGetter: (data) => data,
  137. initialValue: state.nation,
  138. ).show();
  139. if (result != null) {
  140. controller.state.nation = result;
  141. }
  142. },
  143. endIcon: _buildEndIcon(),
  144. ),
  145. ),
  146. Obx(
  147. () => VListFormCell(
  148. label: "证件号",
  149. content: controller.state.cardNo,
  150. onTap: () async {
  151. // print("点击修改证件号");
  152. // final result = await VDialogInput(
  153. // title: "证件号",
  154. // initialValue: controller.state.cardNo,
  155. // placeholder: "请填写证件号",
  156. // ).show();
  157. // if (result != null && result is String) {
  158. // // 校验身份证号
  159. // bool validate = IdCardHelper.validateIDCard(result);
  160. // if (!validate) {
  161. // PromptBox.toast("身份证号码格式错误");
  162. // return;
  163. // }
  164. // controller.state.cardNo = result;
  165. // }
  166. },
  167. endIcon: _buildEndIcon(isEdit: false),
  168. ),
  169. ),
  170. Obx(
  171. () => VListFormCell(
  172. label: "出生日期",
  173. content: controller.state.birthday != null
  174. ? DataTimeUtils.formatDateString(controller.state.birthday!)
  175. : "",
  176. onTap: () async {
  177. final result = await VDialogDate(
  178. title: "设置出生日期",
  179. initialValue: controller.state.birthday,
  180. maxValue: DateTime.now(),
  181. ).show();
  182. if (result != null) {
  183. controller.state.birthday = result;
  184. }
  185. },
  186. endIcon: _buildEndIcon(),
  187. ),
  188. ),
  189. Obx(
  190. () => VListFormCell(
  191. label: "年龄",
  192. content: controller.state.age,
  193. endIcon: _buildEndIcon(isEdit: false),
  194. onTap: () {},
  195. ),
  196. ),
  197. Obx(
  198. () => VListFormCell(
  199. label: "现住地址",
  200. content: controller.state.address,
  201. onTap: () async {
  202. final result = await VDialogInput(
  203. title: "现住地址",
  204. initialValue: controller.state.address,
  205. placeholder: "请填写现住地址",
  206. ).show();
  207. if (result != null) {
  208. controller.state.address = result;
  209. }
  210. },
  211. endIcon: _buildEndIcon(),
  212. ),
  213. ),
  214. Obx(
  215. () => VListFormCell(
  216. label: "户籍地址",
  217. content: controller.state.permanentResidenceAddress,
  218. onTap: () async {
  219. final result = await VDialogInput(
  220. title: "户籍地址",
  221. initialValue: controller.state.permanentResidenceAddress,
  222. placeholder: "请填写户籍地址",
  223. ).show();
  224. if (result != null) {
  225. controller.state.permanentResidenceAddress = result;
  226. }
  227. },
  228. endIcon: _buildEndIcon(),
  229. ),
  230. ),
  231. Obx(
  232. () => VListFormCell(
  233. label: "建档单位",
  234. content: controller.state.createdOrgName,
  235. endIcon: _buildEndIcon(isEdit: false),
  236. onTap: () {},
  237. ),
  238. ),
  239. Obx(
  240. () => VListFormCell(
  241. label: "建档人",
  242. content: controller.state.createdDoctorName,
  243. endIcon: _buildEndIcon(isEdit: false),
  244. onTap: () {},
  245. ),
  246. ),
  247. Obx(
  248. () => VListFormCell(
  249. label: "建档时间",
  250. content: controller.state.createTime,
  251. endIcon: _buildEndIcon(isEdit: false),
  252. onTap: () {},
  253. ),
  254. ),
  255. ];
  256. }
  257. Widget _buildEndIcon({bool isEdit = true}) {
  258. return Container(
  259. margin: EdgeInsets.only(left: isEdit ? 15 : 35),
  260. child: isEdit ? Icon(Icons.edit_outlined) : SizedBox(),
  261. );
  262. }
  263. }