patient_info.dart 7.2 KB

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