view.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. import 'package:fis_jsonrpc/rpc.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vnoteapp/components/button.dart';
  5. import 'package:vnoteapp/components/checkbox.dart';
  6. import 'package:vnoteapp/components/date_picker.dart';
  7. import 'package:vnoteapp/components/form.dart';
  8. import 'package:vnoteapp/components/input.dart';
  9. import 'package:vnoteapp/components/panel.dart';
  10. import 'package:vnoteapp/components/select.dart';
  11. import 'package:vnoteapp/consts/nations.dart';
  12. import 'package:vnoteapp/consts/rpc_enum_labels.dart';
  13. import 'package:vnoteapp/pages/controllers/crowd_labels.dart';
  14. import 'package:vnoteapp/pages/patient/create/controller.dart';
  15. export './view_new.dart';
  16. class CreatePatientPage extends GetView<CreatePatientController> {
  17. const CreatePatientPage({super.key});
  18. @override
  19. Widget build(BuildContext context) {
  20. const panelSpace = SizedBox(height: 10);
  21. return Container(
  22. padding: const EdgeInsets.all(8),
  23. color: Colors.grey.shade200,
  24. alignment: Alignment.bottomLeft,
  25. child: Scrollbar(
  26. thumbVisibility: true,
  27. child: ListView(
  28. shrinkWrap: true,
  29. children: [
  30. VPanel(child: _SignDistrict()),
  31. panelSpace,
  32. VPanel(child: _InfoFormView()),
  33. panelSpace,
  34. VPanel(
  35. padding: const EdgeInsets.only(top: 16, bottom: 8),
  36. child: _PersonTagsView(),
  37. ),
  38. const SizedBox(height: 30),
  39. _buildOpRow(),
  40. ],
  41. ),
  42. ),
  43. );
  44. }
  45. Widget _buildOpRow() {
  46. return Obx(
  47. () {
  48. if (controller.state.isCreateOnly) {
  49. return Row(
  50. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  51. children: [
  52. VButton(
  53. label: "返 回",
  54. type: VButtonType.cancel,
  55. onTap: () {
  56. Get.back(id: 1001);
  57. },
  58. ),
  59. VButton(
  60. label: "保 存",
  61. type: VButtonType.primary,
  62. onTap: controller.gotoPatientDetail,
  63. ),
  64. ],
  65. );
  66. }
  67. return Row(
  68. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  69. children: [
  70. VButton(
  71. label: "下一步",
  72. type: VButtonType.primary,
  73. onTap: controller.gotoSignContract,
  74. ),
  75. VButton(
  76. label: "存为档案",
  77. type: VButtonType.primary,
  78. onTap: controller.gotoPatientDetail,
  79. ),
  80. ],
  81. );
  82. },
  83. );
  84. }
  85. }
  86. class _InfoFormView extends GetView<CreatePatientController> {
  87. static const labelWidth = 85.0;
  88. static const itemWidth = 200.0;
  89. static const cellSpace = SizedBox(width: 25);
  90. @override
  91. Widget build(BuildContext context) {
  92. const rowSpace = SizedBox(height: 20);
  93. return Container(
  94. alignment: Alignment.bottomLeft,
  95. padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
  96. child: Column(
  97. mainAxisSize: MainAxisSize.min,
  98. crossAxisAlignment: CrossAxisAlignment.start,
  99. children: [
  100. _buildCardRow(),
  101. rowSpace,
  102. _buildRow(
  103. Row(
  104. mainAxisSize: MainAxisSize.min,
  105. mainAxisAlignment: MainAxisAlignment.start,
  106. children: [
  107. _buildName(),
  108. cellSpace,
  109. _buildGender(),
  110. cellSpace,
  111. _buildNation(),
  112. ],
  113. ),
  114. ),
  115. rowSpace,
  116. _buildBirthdayRow(),
  117. rowSpace,
  118. _buildCensusRegisterRow(),
  119. rowSpace,
  120. _buildAddressRow(),
  121. rowSpace,
  122. _buildRow(
  123. Row(
  124. mainAxisSize: MainAxisSize.min,
  125. mainAxisAlignment: MainAxisAlignment.start,
  126. children: [
  127. _buildPhoneNo(),
  128. const SizedBox(width: 5),
  129. _buildPersonalNo(),
  130. ],
  131. ),
  132. ),
  133. ],
  134. ),
  135. );
  136. }
  137. Widget _buildCardRow() {
  138. return _buildRow(
  139. VFormCell(
  140. labelWidth: labelWidth,
  141. label: "证件号:",
  142. isExpanded: false,
  143. child: Row(
  144. mainAxisSize: MainAxisSize.min,
  145. mainAxisAlignment: MainAxisAlignment.start,
  146. children: [
  147. SizedBox(
  148. width: itemWidth,
  149. child: VInput(
  150. placeholder: "请输入证件号",
  151. onChanged: (value) {
  152. controller.state.cardNo = value;
  153. },
  154. ),
  155. ),
  156. cellSpace,
  157. SizedBox(
  158. width: 140,
  159. child: VSelect<CardTypeEnum, CardTypeEnum>(
  160. source: CardTypeEnum.values,
  161. value: CardTypeEnum.Identity,
  162. labelGetter: (e) => RpcEnumLabels.cardType[e]!,
  163. valueGetter: (e) => e,
  164. onChanged: (value) {
  165. controller.state.cardType = value;
  166. },
  167. ),
  168. ),
  169. cellSpace,
  170. SizedBox(
  171. width: 90,
  172. child: VButton(
  173. label: "读卡",
  174. onTap: () {
  175. controller.onReadCardClicked();
  176. },
  177. ),
  178. ),
  179. ],
  180. ),
  181. ),
  182. );
  183. }
  184. Widget _buildName() {
  185. return VFormCell(
  186. labelWidth: labelWidth,
  187. isExpanded: false,
  188. label: "姓名:",
  189. child: SizedBox(
  190. width: itemWidth,
  191. height: 40,
  192. child: VInput(
  193. placeholder: "请输入姓名",
  194. onChanged: (value) {
  195. controller.state.name = value;
  196. },
  197. ),
  198. ),
  199. );
  200. }
  201. Widget _buildGender() {
  202. return VFormCell(
  203. labelWidth: 60,
  204. isExpanded: false,
  205. label: "性别:",
  206. child: SizedBox(
  207. width: itemWidth,
  208. child: VSelect<GenderEnum, GenderEnum>(
  209. source: const [
  210. GenderEnum.Male,
  211. GenderEnum.Female,
  212. GenderEnum.Unknown,
  213. GenderEnum.Unspecified
  214. ],
  215. value: GenderEnum.Male,
  216. labelGetter: (e) => RpcEnumLabels.gender[e]!,
  217. valueGetter: (e) => e,
  218. onChanged: (value) {
  219. controller.state.gender = value;
  220. },
  221. ),
  222. ),
  223. );
  224. }
  225. Widget _buildNation() {
  226. return VFormCell(
  227. labelWidth: 60,
  228. isExpanded: false,
  229. label: "民族:",
  230. child: SizedBox(
  231. width: itemWidth,
  232. child: VSelect<String, String>(
  233. source: Nations.china,
  234. value: Nations.china.first,
  235. labelGetter: (e) => e,
  236. valueGetter: (e) => e,
  237. onChanged: (value) {
  238. controller.state.nation = value;
  239. },
  240. ),
  241. ),
  242. );
  243. }
  244. Widget _buildPhoneNo() {
  245. return VFormCell(
  246. labelWidth: labelWidth,
  247. isExpanded: false,
  248. label: "手机号码:",
  249. child: SizedBox(
  250. width: itemWidth,
  251. child: VInput(
  252. placeholder: "请输入手机号码",
  253. onChanged: (value) {
  254. controller.state.phoneNo = value;
  255. },
  256. ),
  257. ),
  258. );
  259. }
  260. Widget _buildPersonalNo() {
  261. return VFormCell(
  262. labelWidth: 85,
  263. isExpanded: false,
  264. label: "个人编号:",
  265. child: SizedBox(
  266. width: itemWidth,
  267. child: VInput(
  268. placeholder: "请输入个人编号",
  269. onChanged: (value) {
  270. controller.state.personalNo = value;
  271. },
  272. ),
  273. ),
  274. );
  275. }
  276. Widget _buildBirthdayRow() {
  277. return _buildRow(
  278. Row(
  279. mainAxisSize: MainAxisSize.min,
  280. mainAxisAlignment: MainAxisAlignment.start,
  281. children: [
  282. VFormCell(
  283. labelWidth: labelWidth,
  284. isExpanded: false,
  285. label: "出生日期:",
  286. child: SizedBox(
  287. width: itemWidth,
  288. child: Obx(
  289. () => VDatePicker(
  290. value: controller.state.birthday,
  291. onChanged: (value) {
  292. controller.state.birthday = value;
  293. },
  294. ),
  295. ),
  296. ),
  297. ),
  298. cellSpace,
  299. VFormCell(
  300. labelWidth: 60,
  301. isExpanded: false,
  302. label: "年龄:",
  303. child: SizedBox(
  304. width: itemWidth,
  305. child: Obx(
  306. () => VInput(
  307. initialValue: controller.state.age.toString(),
  308. ),
  309. ),
  310. ),
  311. ),
  312. ],
  313. ),
  314. );
  315. }
  316. Widget _buildAddressRow() {
  317. return _buildRow(
  318. Row(
  319. mainAxisSize: MainAxisSize.min,
  320. children: [
  321. VFormCell(
  322. labelWidth: labelWidth,
  323. isExpanded: false,
  324. label: "现 住 址:",
  325. child: SizedBox(
  326. width: 400,
  327. child: Obx(
  328. () => VInput(
  329. initialValue: controller.state.address,
  330. placeholder: "请输入现住址",
  331. onChanged: (value) {
  332. controller.state.address = value;
  333. },
  334. ),
  335. ),
  336. ),
  337. ),
  338. const SizedBox(width: 8),
  339. VCheckBox(
  340. label: "同户籍地址",
  341. onChanged: (value) {
  342. controller.onSyncAddressCheckChanged(value);
  343. },
  344. ),
  345. ],
  346. ),
  347. );
  348. }
  349. Widget _buildCensusRegisterRow() {
  350. return _buildRow(
  351. VFormCell(
  352. labelWidth: labelWidth,
  353. isExpanded: false,
  354. label: "户籍地址:",
  355. child: SizedBox(
  356. width: 400,
  357. child: VInput(
  358. initialValue: controller.state.censusRegister,
  359. placeholder: "请输入户籍地址",
  360. onChanged: (value) {
  361. controller.onCensusRegisterChanged(value);
  362. },
  363. ),
  364. ),
  365. ),
  366. );
  367. }
  368. Widget _buildRow(Widget cell) {
  369. return SizedBox(
  370. height: 40,
  371. child: cell,
  372. );
  373. }
  374. }
  375. class _PersonTagsView extends GetView<CrowdLabelsController> {
  376. @override
  377. Widget build(BuildContext context) {
  378. return Container(
  379. alignment: Alignment.bottomLeft,
  380. child: Column(
  381. mainAxisSize: MainAxisSize.min,
  382. crossAxisAlignment: CrossAxisAlignment.start,
  383. children: [
  384. Padding(
  385. padding: const EdgeInsets.only(left: 12, bottom: 8),
  386. child: Text(
  387. "人群分类",
  388. style: TextStyle(
  389. color: Theme.of(context).primaryColor,
  390. fontSize: 24,
  391. ),
  392. ),
  393. ),
  394. Divider(thickness: 1, color: Colors.grey.shade300),
  395. Padding(
  396. padding: const EdgeInsets.all(12.0),
  397. child: _buildBaseClassRow(),
  398. ),
  399. Padding(
  400. padding: const EdgeInsets.all(12.0),
  401. child: _buildDiseaseRow(),
  402. ),
  403. ],
  404. ),
  405. );
  406. }
  407. /// 基本人群分类
  408. Widget _buildBaseClassRow() {
  409. return Obx(
  410. () => VCheckBoxGroup<LabelDTO, String>(
  411. source: controller.state.normalOptions,
  412. labelGetter: (data) => data.labelName!,
  413. valueGetter: (data) => data.code!,
  414. itemSpace: 36,
  415. onChanged: (value) {
  416. controller.onNormalSelectedChanged(value);
  417. },
  418. ),
  419. );
  420. }
  421. /// 特殊病分类
  422. Widget _buildDiseaseRow() {
  423. return Obx(
  424. () => VCheckBoxGroup<LabelDTO, String>(
  425. source: controller.state.diseaseOptions,
  426. labelGetter: (data) => data.labelName!,
  427. valueGetter: (data) => data.code!,
  428. itemSpace: 36,
  429. onChanged: (value) {
  430. controller.onDiseaseSelectedChanged(value);
  431. },
  432. ),
  433. );
  434. }
  435. }
  436. class _SignDistrict extends GetView<CreatePatientController> {
  437. @override
  438. Widget build(BuildContext context) {
  439. return Padding(
  440. padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
  441. child: Row(
  442. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  443. children: [
  444. Row(
  445. mainAxisSize: MainAxisSize.min,
  446. crossAxisAlignment: CrossAxisAlignment.end,
  447. children: [
  448. Text(
  449. "签约区域",
  450. style: TextStyle(
  451. color: Theme.of(context).primaryColor,
  452. fontSize: 28,
  453. fontWeight: FontWeight.bold,
  454. ),
  455. ),
  456. const SizedBox(width: 24),
  457. Column(
  458. children: [
  459. Text(
  460. "重庆市沙坪坝区童家桥街道",
  461. style: TextStyle(
  462. color: Theme.of(context).primaryColor,
  463. fontSize: 16,
  464. ),
  465. ),
  466. const SizedBox(height: 4),
  467. ],
  468. ),
  469. ],
  470. ),
  471. SizedBox(
  472. width: 140,
  473. height: 40,
  474. child: VSelect(
  475. source: const [
  476. "磁器口社区",
  477. "蝴蝶湾社区",
  478. "尖沙咀社区",
  479. ],
  480. value: "尖沙咀社区",
  481. labelGetter: (e) => e,
  482. valueGetter: (e) => e,
  483. onChanged: (value) {
  484. //TODO:
  485. },
  486. ),
  487. ),
  488. ],
  489. ),
  490. );
  491. }
  492. }