123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- 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<CreatePatientController> {
- 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<CardTypeEnum, CardTypeEnum>(
- 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<GenderEnum, GenderEnum>(
- 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<String, String>(
- 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;
- }
- },
- ),
- ],
- ),
- );
- }
- }
|