add_patient.dart 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  1. import 'package:eitc_erm_app/utils/Component.dart';
  2. import 'package:eitc_erm_app/utils/Constants.dart';
  3. import 'package:eitc_erm_app/utils/Utils.dart';
  4. import 'package:eitc_erm_app/utils/logger.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter/services.dart';
  7. import 'package:http/http.dart' as http;
  8. import 'bean/dropdown_list.dart';
  9. import 'bean/normal_response3.dart';
  10. import 'bean/user_list.dart';
  11. /*void main() {
  12. WidgetsFlutterBinding.ensureInitialized();
  13. runApp(AddPatient());
  14. }*/
  15. UserListEntity mUserListEntity = new UserListEntity();
  16. int mWhichPatient = 0;
  17. bool isEdit = false;
  18. class AddPatient extends StatefulWidget {
  19. AddPatient({required Key key, required userListEntity, required whichPatient})
  20. : super(key: key) {
  21. mUserListEntity = userListEntity;
  22. mWhichPatient = whichPatient;
  23. mWhichPatient == -1 ? isEdit = false : isEdit = true;
  24. logd(isEdit.toString() + ' =================');
  25. }
  26. @override
  27. State<StatefulWidget> createState() => AddPatientState();
  28. }
  29. class AddPatientState extends State<AddPatient> {
  30. int selectedRadioValue = 0;
  31. bool switchSelected = true;
  32. String relationship = "请选择与本人的关系";
  33. String passport = "请选择证件类型";
  34. String previous = "请选择既往病史";
  35. String family = "请选择家族病史";
  36. TextEditingController nameController = TextEditingController();
  37. TextEditingController passportController = TextEditingController();
  38. TextEditingController mobileController = TextEditingController();
  39. TextEditingController allergyController = TextEditingController();
  40. TextEditingController homeAddressController = TextEditingController();
  41. bool mobileCanEdit = true;
  42. List selectItem0 = [];
  43. List selectItem1 = [];
  44. List selectItem2 = [];
  45. List selectItem3 = [];
  46. void getDropdownList() {
  47. for (int i = 0; i < 4; i++) {
  48. dropdownList(i);
  49. }
  50. }
  51. Future<DropdownList?> dropdownList(int i) async {
  52. String url =
  53. '${Global.BaseUrl}system/dropdownList?dictType=erm_personal_relationship';
  54. logd(url);
  55. switch (i) {
  56. case 1:
  57. url = '${Global.BaseUrl}system/type/erm_document_type';
  58. break;
  59. case 2:
  60. url = '${Global.BaseUrl}system/dropdownList?dictType=erm_past_history';
  61. break;
  62. case 3:
  63. url =
  64. '${Global.BaseUrl}system/dropdownList?dictType=erm_family_history';
  65. break;
  66. }
  67. final response =
  68. await http.get(Uri.parse(url), headers: jsonHeaders(withToken: true));
  69. if (response.statusCode == 200) {
  70. final json = decodeBodyToJson(response.bodyBytes);
  71. logd("下拉列表$json");
  72. DropdownList mDropdownList = DropdownList.fromJson(json);
  73. if (mDropdownList.code == Global.responseSuccessCode) {
  74. switch (i) {
  75. case 0:
  76. mDropdownList.data?.forEach((item) {
  77. selectItem0.add(item.dictValue);
  78. });
  79. break;
  80. case 1:
  81. mDropdownList.data?.forEach((item) {
  82. selectItem1.add(item.dictValue);
  83. });
  84. break;
  85. case 2:
  86. mDropdownList.data?.forEach((item) {
  87. selectItem2.add(item.dictValue);
  88. });
  89. break;
  90. case 3:
  91. mDropdownList.data?.forEach((item) {
  92. selectItem3.add(item.dictValue);
  93. });
  94. break;
  95. }
  96. if (mounted) {
  97. setState(() {});
  98. }
  99. } else {
  100. Component.toast(mDropdownList.msg.toString(), 0);
  101. return null;
  102. }
  103. return mDropdownList;
  104. } else {
  105. Component.toast("出错了,请稍后再试!", 0);
  106. return null;
  107. }
  108. }
  109. @override
  110. void initState() {
  111. super.initState();
  112. getDropdownList();
  113. if (isEdit) {
  114. relationship =
  115. mUserListEntity.data![mWhichPatient].userRelationship.toString();
  116. nameController.text =
  117. mUserListEntity.data![mWhichPatient].patientName.toString();
  118. int? passportInt = mUserListEntity.data![mWhichPatient].documentType;
  119. switch (passportInt) {
  120. case 0:
  121. passport = "身份证";
  122. break;
  123. case 1:
  124. passport = "护照";
  125. break;
  126. case 2:
  127. passport = "港澳通行证";
  128. break;
  129. }
  130. if (relationship == "本人") {
  131. mobileCanEdit = false;
  132. } else {
  133. mobileCanEdit = true;
  134. }
  135. passportController.text =
  136. mUserListEntity.data![mWhichPatient].identificationCard.toString();
  137. previous = mUserListEntity.data![mWhichPatient].pastHistory.toString();
  138. logd("------------------------ " +
  139. mUserListEntity.data![mWhichPatient].pastHistory.toString());
  140. family = mUserListEntity.data![mWhichPatient].familyHistory.toString();
  141. if (!mUserListEntity.data![mWhichPatient].allergyHistory
  142. .toString()
  143. .isEmpty) {
  144. selectedRadioValue = 1;
  145. allergyController.text =
  146. mUserListEntity.data![mWhichPatient].allergyHistory.toString();
  147. }
  148. mobileController.text =
  149. mUserListEntity.data![mWhichPatient].patientPhone.toString();
  150. homeAddressController.text =
  151. mUserListEntity.data![mWhichPatient].homeAddress.toString();
  152. if (mUserListEntity.data![mWhichPatient].isDefault == 1) {
  153. switchSelected = true;
  154. } else {
  155. switchSelected = false;
  156. }
  157. }
  158. }
  159. final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
  160. String _errorText = '';
  161. Future<void> _validateInputs() async {
  162. final FormState? form = _formKey.currentState;
  163. /*if (form!.validate()) {
  164. _errorText = '';
  165. } else {
  166. _errorText = '输入不能为空';
  167. }
  168. form.save();*/
  169. setState(() {
  170. if (relationship == "请选择与本人的关系") {
  171. _errorText = "请选择与本人的关系";
  172. return;
  173. } else if (passport == "请选择证件类型") {
  174. _errorText = "请选择证件类型";
  175. return;
  176. } else if (previous == "请选择既往病史") {
  177. _errorText = "请选择既往病史";
  178. return;
  179. } else if (family == "请选择家族病史") {
  180. _errorText = "请选择家族病史";
  181. return;
  182. } else if (nameController.text == '') {
  183. _errorText = "请填写姓名";
  184. return;
  185. } else if (passportController.text == '') {
  186. _errorText = "请填写证件号码";
  187. return;
  188. } else if (mobileController.text == '') {
  189. _errorText = "请填写手机号码";
  190. return;
  191. } else if (selectedRadioValue == 1 && allergyController.text == '') {
  192. _errorText = "请填写过敏史";
  193. return;
  194. } else if (!Utils.validateIDCard(passportController.text)) {
  195. _errorText = "请输入正确的身份证号码";
  196. return;
  197. } else if (!Utils.isChinaPhoneLegal(mobileController.text)) {
  198. _errorText = "请输入正确的手机号码";
  199. return;
  200. } else {
  201. _errorText = "";
  202. }
  203. });
  204. if (_errorText.isNotEmpty) {
  205. return;
  206. }
  207. logd("${previous} ${family} ${allergyController.text} ");
  208. int passportType = 0;
  209. if (passport == "身份证") {
  210. passportType = 0;
  211. } else if (passport == "护照") {
  212. passportType = 1;
  213. } else if (passport == "港澳通行证") {
  214. passportType = 2;
  215. }
  216. int isDefault = 1;
  217. if (switchSelected) {
  218. isDefault = 1;
  219. } else {
  220. isDefault = 0;
  221. }
  222. String patientId =
  223. isEdit ? mUserListEntity.data![mWhichPatient].patientId.toString() : "";
  224. var params = {
  225. 'patientId': patientId,
  226. 'userRelationship': relationship,
  227. 'documentType': passportType,
  228. 'pastHistory': previous,
  229. 'familyHistory': family,
  230. 'patientName': nameController.text,
  231. 'identificationCard': passportController.text,
  232. 'patientPhone': mobileController.text,
  233. 'allergyHistory': allergyController.text,
  234. 'homeAddress': homeAddressController.text,
  235. 'isDefault': isDefault,
  236. };
  237. logd(params);
  238. Map<String, String> headers = jsonHeaders(withToken: true);
  239. var response = await http.post(Uri.parse('${Global.BaseUrl}user'),
  240. body: encodeBody(params), headers: headers);
  241. if (isEdit) {
  242. response = await http.put(Uri.parse('${Global.BaseUrl}user'),
  243. body: encodeBody(params), headers: headers);
  244. }
  245. logd(response.body.toString());
  246. if (response.statusCode == 200) {
  247. final json = decodeBodyToJson(response.bodyBytes);
  248. logd("新增/编辑就诊人结果=$json");
  249. NormalResponse3 mNormalResponse = NormalResponse3.fromJson(json);
  250. if (mNormalResponse.code == Global.responseSuccessCode) {
  251. Component.toast(isEdit ? "保存成功!" : "添加成功!", 2);
  252. Navigator.pop(context, "success");
  253. } else {
  254. Component.toast(mNormalResponse.msg.toString(), 0);
  255. }
  256. } else {
  257. Component.toast("出错了,请稍后再试!", 0);
  258. return;
  259. }
  260. }
  261. @override
  262. Widget build(BuildContext context) {
  263. return Scaffold(
  264. appBar: AppBar(
  265. title: Text(isEdit ? '编辑就诊人' : '添加就诊人',
  266. style: const TextStyle(
  267. color: Colors.white,
  268. )),
  269. centerTitle: true,
  270. elevation: 0.5,
  271. backgroundColor: Global.StatusBarColor,
  272. leading: IconButton(
  273. tooltip: '返回上一页',
  274. icon: const Icon(
  275. Icons.arrow_back_ios,
  276. color: Colors.white,
  277. ),
  278. onPressed: () {
  279. Navigator.of(context).pop();
  280. //_nextPage(-1);
  281. },
  282. ),
  283. ),
  284. body: SingleChildScrollView(
  285. child: Form(
  286. key: _formKey,
  287. child: Column(children: [
  288. const Padding(
  289. padding: EdgeInsets.all(10),
  290. child: Text(
  291. "请认真填写就诊人信息",
  292. style: TextStyle(
  293. color: Colors.orange,
  294. ),
  295. )),
  296. if (_errorText.isNotEmpty)
  297. Container(
  298. color: Colors.red,
  299. padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 3),
  300. child: Text(
  301. _errorText,
  302. style: const TextStyle(color: Colors.white),
  303. ),
  304. ),
  305. Padding(
  306. padding: const EdgeInsets.all(10),
  307. child: GestureDetector(
  308. onTap: () {
  309. selectItem(selectItem0, 0);
  310. },
  311. child: Row(
  312. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  313. children: <Widget>[
  314. const Text(
  315. "关系",
  316. style: TextStyle(
  317. color: Colors.grey,
  318. ),
  319. ),
  320. Row(
  321. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  322. children: <Widget>[
  323. Text(
  324. relationship,
  325. style: const TextStyle(
  326. color: Colors.black,
  327. ),
  328. ),
  329. const Icon(
  330. Icons.chevron_right,
  331. color: Colors.grey,
  332. ),
  333. ])
  334. ]),
  335. ),
  336. ),
  337. const Divider(
  338. color: Colors.grey,
  339. thickness: 1,
  340. indent: 10,
  341. endIndent: 10,
  342. ),
  343. // new Line(),
  344. Padding(
  345. padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
  346. child: Container(
  347. alignment: Alignment.center,
  348. height: 45,
  349. child: Row(
  350. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  351. children: <Widget>[
  352. const Text(
  353. "姓名 ",
  354. style: TextStyle(
  355. color: Colors.grey,
  356. ),
  357. ),
  358. Expanded(
  359. child: TextFormField(
  360. maxLines: 1,
  361. onSaved: (value) {},
  362. textAlign: TextAlign.right,
  363. controller: nameController,
  364. inputFormatters: [
  365. FilteringTextInputFormatter.singleLineFormatter,
  366. LengthLimitingTextInputFormatter(4)
  367. ],
  368. decoration: const InputDecoration(
  369. hintText: ('请填写姓名'),
  370. hintStyle: TextStyle(
  371. color: Color(0xff999999),
  372. fontSize: 13,
  373. ),
  374. alignLabelWithHint: true,
  375. border:
  376. OutlineInputBorder(borderSide: BorderSide.none),
  377. ),
  378. ),
  379. ),
  380. ]),
  381. ),
  382. ),
  383. const Divider(
  384. color: Colors.grey,
  385. thickness: 1,
  386. indent: 10,
  387. endIndent: 10,
  388. ),
  389. Padding(
  390. padding: const EdgeInsets.all(10),
  391. child: GestureDetector(
  392. onTap: () {
  393. // selectItem(['身份证', '护照', '港澳通行证'], 1);
  394. selectItem(selectItem1, 1);
  395. },
  396. child: Row(
  397. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  398. children: <Widget>[
  399. const Text(
  400. "证件类型",
  401. style: TextStyle(
  402. color: Colors.grey,
  403. ),
  404. ),
  405. Row(
  406. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  407. children: <Widget>[
  408. Text(
  409. passport,
  410. style: const TextStyle(
  411. color: Colors.black,
  412. ),
  413. ),
  414. const Icon(
  415. Icons.chevron_right,
  416. color: Colors.grey,
  417. ),
  418. ])
  419. ]),
  420. ),
  421. ),
  422. const Divider(
  423. color: Colors.grey,
  424. thickness: 1,
  425. indent: 10,
  426. endIndent: 10,
  427. ),
  428. Padding(
  429. padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
  430. child: Container(
  431. alignment: Alignment.center,
  432. height: 50,
  433. child: Row(
  434. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  435. children: <Widget>[
  436. const Text(
  437. "证件号码",
  438. style: TextStyle(
  439. color: Colors.grey,
  440. ),
  441. ),
  442. Expanded(
  443. child: TextFormField(
  444. controller: passportController,
  445. maxLines: 1,
  446. onSaved: (value) {},
  447. textAlign: TextAlign.right,
  448. inputFormatters: [
  449. FilteringTextInputFormatter.singleLineFormatter,
  450. LengthLimitingTextInputFormatter(18)
  451. ],
  452. decoration: const InputDecoration(
  453. hintText: ('请输入证件号码'),
  454. hintStyle: TextStyle(
  455. color: Color(0xff999999),
  456. fontSize: 13,
  457. ),
  458. alignLabelWithHint: true,
  459. border:
  460. OutlineInputBorder(borderSide: BorderSide.none),
  461. ),
  462. ),
  463. ),
  464. ]),
  465. ),
  466. ),
  467. const Divider(
  468. color: Colors.grey,
  469. thickness: 1,
  470. indent: 10,
  471. endIndent: 10,
  472. ),
  473. Padding(
  474. padding: const EdgeInsets.all(10),
  475. child: GestureDetector(
  476. onTap: () {
  477. selectItem(selectItem2, 2);
  478. },
  479. child: Row(
  480. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  481. children: <Widget>[
  482. const Text(
  483. "既往病史",
  484. style: TextStyle(
  485. color: Colors.grey,
  486. ),
  487. ),
  488. Row(
  489. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  490. children: <Widget>[
  491. Text(
  492. previous,
  493. style: const TextStyle(
  494. color: Colors.black,
  495. ),
  496. ),
  497. const Icon(
  498. Icons.chevron_right,
  499. color: Colors.grey,
  500. ),
  501. ])
  502. ]),
  503. ),
  504. ),
  505. const Divider(
  506. color: Colors.grey,
  507. thickness: 1,
  508. indent: 10,
  509. endIndent: 10,
  510. ),
  511. Padding(
  512. padding: const EdgeInsets.all(10),
  513. child: GestureDetector(
  514. onTap: () {
  515. selectItem(selectItem3, 3);
  516. },
  517. child: Row(
  518. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  519. children: <Widget>[
  520. const Text(
  521. "家族病史",
  522. style: TextStyle(
  523. color: Colors.grey,
  524. ),
  525. ),
  526. Row(
  527. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  528. children: <Widget>[
  529. Text(
  530. family,
  531. style: const TextStyle(
  532. color: Colors.black,
  533. ),
  534. ),
  535. const Icon(
  536. Icons.chevron_right,
  537. color: Colors.grey,
  538. ),
  539. ])
  540. ]),
  541. ),
  542. ),
  543. const Divider(
  544. color: Colors.grey,
  545. thickness: 1,
  546. indent: 10,
  547. endIndent: 10,
  548. ),
  549. Padding(
  550. padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
  551. child: Row(
  552. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  553. children: <Widget>[
  554. const Text(
  555. "过敏史",
  556. style: TextStyle(
  557. color: Colors.grey,
  558. ),
  559. ),
  560. Row(
  561. children: <Widget>[
  562. const Text("无"),
  563. Radio(
  564. value: 0,
  565. onChanged: (value) {
  566. setState(() {
  567. allergyController.text = "";
  568. selectedRadioValue = value!;
  569. });
  570. },
  571. groupValue: selectedRadioValue,
  572. ),
  573. const SizedBox(
  574. width: 20,
  575. ),
  576. const Text("有"),
  577. Radio(
  578. value: 1,
  579. onChanged: (value) {
  580. setState(() {
  581. this.selectedRadioValue = value!;
  582. });
  583. },
  584. groupValue: selectedRadioValue,
  585. ),
  586. ],
  587. ),
  588. ]),
  589. ),
  590. Visibility(
  591. visible: selectedRadioValue == 1,
  592. child: Padding(
  593. padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
  594. child: Row(
  595. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  596. children: <Widget>[
  597. const Text(
  598. "",
  599. style: TextStyle(
  600. color: Colors.grey,
  601. ),
  602. ),
  603. Expanded(
  604. child: TextFormField(
  605. controller: allergyController,
  606. maxLines: 1,
  607. onSaved: (value) {},
  608. textAlign: TextAlign.right,
  609. inputFormatters: [
  610. FilteringTextInputFormatter.singleLineFormatter,
  611. LengthLimitingTextInputFormatter(18)
  612. ],
  613. decoration: const InputDecoration(
  614. hintText: ('请填写过敏史'),
  615. hintStyle: TextStyle(
  616. color: Color(0xff999999),
  617. fontSize: 13,
  618. ),
  619. alignLabelWithHint: true,
  620. border:
  621. OutlineInputBorder(borderSide: BorderSide.none),
  622. ),
  623. ),
  624. ),
  625. ]),
  626. ),
  627. ),
  628. const Divider(
  629. color: Colors.grey,
  630. thickness: 1,
  631. indent: 10,
  632. endIndent: 10,
  633. ),
  634. Padding(
  635. padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
  636. child: Container(
  637. alignment: Alignment.center,
  638. height: 50,
  639. child: Row(
  640. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  641. children: <Widget>[
  642. const Text(
  643. "手机号",
  644. style: TextStyle(
  645. color: Colors.grey,
  646. ),
  647. ),
  648. Expanded(
  649. child: TextFormField(
  650. enabled: mobileCanEdit,
  651. controller: mobileController,
  652. maxLines: 1,
  653. onSaved: (value) {},
  654. textAlign: TextAlign.right,
  655. inputFormatters: [
  656. FilteringTextInputFormatter.digitsOnly,
  657. LengthLimitingTextInputFormatter(11)
  658. ],
  659. decoration: const InputDecoration(
  660. hintText: ('请输入手机号码'),
  661. hintStyle: TextStyle(
  662. color: Color(0xff999999),
  663. fontSize: 13,
  664. ),
  665. alignLabelWithHint: true,
  666. border:
  667. OutlineInputBorder(borderSide: BorderSide.none),
  668. ),
  669. ),
  670. ),
  671. ]),
  672. ),
  673. ),
  674. const Divider(
  675. color: Colors.grey,
  676. thickness: 1,
  677. indent: 10,
  678. endIndent: 10,
  679. ),
  680. Padding(
  681. padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
  682. child: Container(
  683. alignment: Alignment.center,
  684. height: 50,
  685. child: Row(
  686. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  687. children: <Widget>[
  688. const Text(
  689. "就诊人地址",
  690. style: TextStyle(
  691. color: Colors.grey,
  692. ),
  693. ),
  694. Expanded(
  695. child: TextFormField(
  696. controller: homeAddressController,
  697. maxLines: 1,
  698. onSaved: (value) {},
  699. textAlign: TextAlign.right,
  700. // inputFormatters: [
  701. // FilteringTextInputFormatter.digitsOnly,
  702. // LengthLimitingTextInputFormatter(11)
  703. // ],
  704. decoration: const InputDecoration(
  705. hintText: ('选填'),
  706. hintStyle: TextStyle(
  707. color: Color(0xff999999),
  708. fontSize: 13,
  709. ),
  710. alignLabelWithHint: true,
  711. border:
  712. OutlineInputBorder(borderSide: BorderSide.none),
  713. ),
  714. ),
  715. ),
  716. ]),
  717. ),
  718. ),
  719. const Divider(
  720. color: Colors.grey,
  721. thickness: 1,
  722. indent: 10,
  723. endIndent: 10,
  724. ),
  725. Padding(
  726. padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
  727. child: Row(
  728. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  729. children: <Widget>[
  730. const Text(
  731. "设为默认就诊人",
  732. style: TextStyle(
  733. color: Colors.grey,
  734. ),
  735. ),
  736. Switch(
  737. value: switchSelected,
  738. onChanged: (value) {
  739. setState(() {
  740. switchSelected = value;
  741. });
  742. },
  743. ),
  744. ]),
  745. ),
  746. Padding(
  747. padding: const EdgeInsets.symmetric(horizontal: 20),
  748. child: SizedBox(
  749. width: double.infinity,
  750. child: ElevatedButton(
  751. style: const ButtonStyle(
  752. backgroundColor: WidgetStatePropertyAll(Colors.blue),
  753. ),
  754. onPressed: () {
  755. _validateInputs();
  756. },
  757. child: const Text("确定",
  758. style: TextStyle(color: Colors.white, fontSize: 15)),
  759. ),
  760. )),
  761. const SizedBox(
  762. height: 10,
  763. )
  764. ]),
  765. ),
  766. ),
  767. );
  768. }
  769. selectItem(List list, int item) {
  770. showModalBottomSheet(
  771. context: context,
  772. builder: (BuildContext context) {
  773. return Container(
  774. width: double.infinity,
  775. height: list.length * 50,
  776. child: Column(
  777. children: List.generate(
  778. list.length,
  779. (index) => GestureDetector(
  780. onTap: () {
  781. setState(() {
  782. switch (item) {
  783. case 0:
  784. relationship = list[index];
  785. if (relationship == "本人") {
  786. mobileCanEdit = false;
  787. mobileController.text = Global.loginPhoneNo;
  788. } else {
  789. mobileCanEdit = true;
  790. mobileController.text = "";
  791. }
  792. break;
  793. case 1:
  794. passport = list[index];
  795. break;
  796. case 2:
  797. previous = list[index];
  798. break;
  799. case 3:
  800. family = list[index];
  801. break;
  802. }
  803. });
  804. Navigator.pop(context);
  805. },
  806. child: Padding(
  807. padding: const EdgeInsets.all(10),
  808. child: Text(
  809. '${list[index]}',
  810. style: TextStyle(fontSize: 18),
  811. ),
  812. ),
  813. ),
  814. ),
  815. ),
  816. );
  817. },
  818. );
  819. }
  820. }