patient_info.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // ignore_for_file: must_be_immutable
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:get/get.dart';
  5. import 'package:vitalapp/architecture/utils/datetime.dart';
  6. import 'package:vitalapp/components/cell.dart';
  7. import 'package:vitalapp/components/dialog_date.dart';
  8. import 'package:vitalapp/components/dialog_input.dart';
  9. import 'package:vitalapp/components/dialog_select.dart';
  10. import 'package:vitalapp/consts/nations.dart';
  11. import 'package:vitalapp/consts/rpc_enum_labels.dart';
  12. import 'package:vitalapp/pages/patient/create/controller.dart';
  13. class PatientInfo extends GetView<CreatePatientController> {
  14. PatientInfo({super.key, this.isNotScanCode = true});
  15. bool? isNotScanCode;
  16. @override
  17. Widget build(BuildContext context) {
  18. return Container(
  19. padding: const EdgeInsets.only(bottom: 80),
  20. child: _buildContent(),
  21. );
  22. }
  23. Widget _buildContent() {
  24. return SingleChildScrollView(
  25. child: Column(
  26. children: [_buildVListFormCellGroup()],
  27. ),
  28. );
  29. }
  30. Widget _buildVListFormCellGroup() {
  31. final state = controller.state;
  32. return Obx(
  33. () => VListFormCellGroup(
  34. children: [
  35. VListFormCell(
  36. labelWidget: RichText(
  37. text: const TextSpan(
  38. text: '* ',
  39. style: TextStyle(color: Colors.red, fontSize: 20),
  40. children: [
  41. TextSpan(
  42. text: '证件号',
  43. style: TextStyle(color: Colors.black, fontSize: 20),
  44. ),
  45. ],
  46. ),
  47. ),
  48. content: controller.state.cardNo,
  49. onTap: () async {
  50. final result = await VDialogInput(
  51. title: "证件号",
  52. initialValue: controller.state.cardNo,
  53. placeholder: "请填写证件号",
  54. ).show();
  55. if (result != null) {
  56. controller.state.cardNo = result.toString().toUpperCase();
  57. controller.setGender(result);
  58. }
  59. },
  60. ),
  61. VListFormCell(
  62. labelWidget: RichText(
  63. text: const TextSpan(
  64. text: '* ',
  65. style: TextStyle(color: Colors.red, fontSize: 20),
  66. children: [
  67. TextSpan(
  68. text: '姓名',
  69. style: TextStyle(color: Colors.black, fontSize: 20),
  70. ),
  71. ],
  72. ),
  73. ),
  74. content: controller.state.name,
  75. onTap: () async {
  76. final result = await VDialogInput(
  77. title: "姓名",
  78. initialValue: controller.state.name,
  79. placeholder: "请填写姓名",
  80. ).show();
  81. if (result != null) {
  82. controller.state.name = result.toString().trim();
  83. }
  84. },
  85. ),
  86. VListFormCell(
  87. label: "性别",
  88. content: () {
  89. if (state.gender == null) {
  90. return "";
  91. } else {
  92. return RpcEnumLabels.gender[state.gender];
  93. }
  94. }(),
  95. onTap: () async {
  96. final result = await VDialogSelect<GenderEnum, GenderEnum>(
  97. title: "选择性别",
  98. source: const [
  99. GenderEnum.Male,
  100. GenderEnum.Female,
  101. GenderEnum.Unknown,
  102. GenderEnum.Unspecified
  103. ],
  104. valueGetter: (data) => data,
  105. labelGetter: (data) => RpcEnumLabels.gender[data] ?? "",
  106. initialValue: state.gender,
  107. ).show();
  108. if (result != null) {
  109. controller.state.gender = result;
  110. }
  111. },
  112. ),
  113. VListFormCell(
  114. label: "民族",
  115. content: state.nation,
  116. onTap: () async {
  117. final result = await VDialogSelect<String, String>(
  118. title: "选择民族",
  119. source: Nations.china,
  120. valueGetter: (data) => data,
  121. labelGetter: (data) => data,
  122. initialValue: state.nation,
  123. ).show();
  124. if (result != null) {
  125. controller.state.nation = result;
  126. }
  127. },
  128. ),
  129. VListFormCell(
  130. label: "出生日期",
  131. content: controller.state.birthday != null
  132. ? DataTimeUtils.formatDateString(controller.state.birthday!)
  133. : "",
  134. onTap: () async {
  135. final result = await VDialogDate(
  136. title: "设置出生日期",
  137. initialValue: controller.state.birthday,
  138. maxValue: DateTime.now(),
  139. ).show();
  140. if (result != null) {
  141. controller.state.birthday = result;
  142. }
  143. },
  144. ),
  145. VListFormCell(
  146. label: "年龄",
  147. content: controller.state.age.toString(),
  148. ),
  149. VListFormCell(
  150. label: "手机号码",
  151. content: controller.state.phoneNo,
  152. onTap: () async {
  153. final result = await VDialogInput(
  154. title: "手机号码",
  155. initialValue: controller.state.phoneNo,
  156. placeholder: "请填写手机号码",
  157. ).show();
  158. if (result != null) {
  159. controller.state.phoneNo = result;
  160. }
  161. },
  162. ),
  163. VListFormCell(
  164. label: "同步户籍地址到现住地址",
  165. labelWidth: 250,
  166. contentWidget: Container(
  167. child: Switch(
  168. onChanged: (value) {
  169. controller.onSyncAddressCheckChanged(value);
  170. },
  171. value: controller.state.isSyncAddresses,
  172. ),
  173. ),
  174. ),
  175. VListFormCell(
  176. label: "户籍地址",
  177. content: controller.state.censusRegister,
  178. onTap: () async {
  179. final result = await VDialogInput(
  180. title: "户籍地址",
  181. initialValue: controller.state.censusRegister,
  182. placeholder: "请填写户籍地址",
  183. ).show();
  184. if (result != null) {
  185. controller.onCensusRegisterChanged(result);
  186. }
  187. },
  188. ),
  189. VListFormCell(
  190. label: "现住地址",
  191. content: controller.state.address,
  192. onTap: () async {
  193. final result = await VDialogInput(
  194. title: "现住地址",
  195. initialValue: controller.state.address,
  196. placeholder: "请填写现住地址",
  197. ).show();
  198. if (result != null) {
  199. controller.state.address = result;
  200. }
  201. },
  202. ),
  203. ],
  204. ),
  205. );
  206. }
  207. }