import 'package:fis_jsonrpc/rpc.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:vnoteapp/architecture/utils/datetime.dart'; import 'package:vnoteapp/components/cell.dart'; import 'package:vnoteapp/components/dialog_date.dart'; import 'package:vnoteapp/components/dialog_input.dart'; import 'package:vnoteapp/components/dialog_select.dart'; import 'package:vnoteapp/consts/nations.dart'; import 'package:vnoteapp/consts/rpc_enum_labels.dart'; import 'package:vnoteapp/pages/patient/create/controller.dart'; class PatientInfo extends GetView { const PatientInfo({super.key}); @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.only(bottom: 80), child: _buildContent(), ); } Widget _buildContent() { return SingleChildScrollView( child: Column( children: [_buildVListFormCellGroup()], ), ); } Widget _buildVListFormCellGroup() { final state = controller.state; return Obx( () => VListFormCellGroup( children: [ VListFormCell( label: "证件类型", content: RpcEnumLabels.cardType[state.cardType], onTap: () async { final result = await VDialogSelect( title: "选择证件类型", source: CardTypeEnum.values, valueGetter: (data) => data, labelGetter: (data) => RpcEnumLabels.cardType[data] ?? "", initialValue: state.cardType, ).show(); if (result != null) { controller.state.cardType = result; } }, ), VListFormCell( labelWidget: RichText( text: const TextSpan( text: '* ', style: TextStyle(color: Colors.red, fontSize: 20), children: [ TextSpan( text: '证件号', style: TextStyle(color: Colors.black, fontSize: 20), ), ], ), ), content: controller.state.cardNo, onTap: () async { final result = await VDialogInput( title: "证件号", initialValue: controller.state.cardNo, placeholder: "请填写证件号", ).show(); if (result != null) { controller.state.cardNo = result; } }, ), VListFormCell( labelWidget: RichText( text: const TextSpan( text: '* ', style: TextStyle(color: Colors.red, fontSize: 20), children: [ TextSpan( text: '姓名', style: TextStyle(color: Colors.black, fontSize: 20), ), ], ), ), content: controller.state.name, onTap: () async { final result = await VDialogInput( title: "姓名", initialValue: controller.state.name, placeholder: "请填写姓名", ).show(); if (result != null) { controller.state.name = result; } }, ), VListFormCell( label: "性别", content: RpcEnumLabels.gender[state.gender], onTap: () async { final result = await VDialogSelect( title: "选择性别", source: const [ GenderEnum.Male, GenderEnum.Female, GenderEnum.Unknown, GenderEnum.Unspecified ], valueGetter: (data) => data, labelGetter: (data) => RpcEnumLabels.gender[data] ?? "", initialValue: state.gender, ).show(); if (result != null) { controller.state.gender = result; } }, ), VListFormCell( label: "民族", content: state.nation, onTap: () async { final result = await VDialogSelect( title: "选择民族", source: Nations.china, valueGetter: (data) => data, labelGetter: (data) => data, initialValue: state.nation, ).show(); if (result != null) { controller.state.nation = result; } }, ), VListFormCell( label: "出生日期", content: controller.state.birthday != null ? DataTimeUtils.formatDateString(controller.state.birthday!) : "", onTap: () async { final result = await VDialogDate( title: "设置出生日期", initialValue: controller.state.birthday, maxValue: DateTime.now(), ).show(); if (result != null) { controller.state.birthday = result; } }, ), VListFormCell( label: "年龄", content: controller.state.age.toString(), ), VListFormCell( label: "手机号码", content: controller.state.phoneNo, onTap: () async { final result = await VDialogInput( title: "手机号码", initialValue: controller.state.phoneNo, placeholder: "请填写手机号码", ).show(); if (result != null) { controller.state.phoneNo = result; } }, ), VListFormCell( label: "同步户籍地址到现住地址", labelWidth: 250, contentWidget: Container( child: Switch( onChanged: (value) { controller.onSyncAddressCheckChanged(value); }, value: controller.state.isSyncAddresses, ), ), ), VListFormCell( label: "户籍地址", content: controller.state.censusRegister, onTap: () async { final result = await VDialogInput( title: "户籍地址", initialValue: controller.state.censusRegister, placeholder: "请填写户籍地址", ).show(); if (result != null) { controller.onCensusRegisterChanged(result); } }, ), VListFormCell( label: "现住地址", content: controller.state.address, onTap: () async { final result = await VDialogInput( title: "现住地址", initialValue: controller.state.address, placeholder: "请填写现住地址", ).show(); if (result != null) { controller.state.address = result; } }, ), ], ), ); } }