123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/components/cell.dart';
- import 'package:vitalapp/components/dialog_input.dart';
- import 'package:vitalapp/components/dialog_number.dart';
- import 'package:vitalapp/pages/check/models/form.dart';
- import 'alert_dialog.dart';
- class VDialogGxyMedication extends StatefulWidget {
- final String? title;
- final String? description;
- final String? placeholder;
- final int? maxLines;
- final double? inputHeight;
- final bool Function(String)? onConfirmVerification;
- final bool showCancel;
- final MedicationModel? medicationModel;
- const VDialogGxyMedication({
- Key? key,
- this.title,
- this.description,
- this.placeholder,
- this.maxLines = 1,
- this.inputHeight = 56,
- this.onConfirmVerification,
- this.showCancel = false,
- this.medicationModel,
- }) : super(key: key);
- Future<MedicationModel?> show<MedicationModel>() =>
- VAlertDialog.showDialog<MedicationModel>(this);
- @override
- _VDialogGxyMedicationState createState() => _VDialogGxyMedicationState();
- }
- class _VDialogGxyMedicationState extends State<VDialogGxyMedication> {
- MedicationModel medicationModel = MedicationModel();
- @override
- void initState() {
- super.initState();
- if (widget.medicationModel != null) {
- medicationModel = widget.medicationModel!;
- }
- }
- @override
- Widget build(BuildContext context) {
- return VAlertDialog(
- title: "主要用药情况填写",
- width: 600,
- content: Container(
- height: 280,
- padding: const EdgeInsets.symmetric(horizontal: 24),
- alignment: Alignment.center,
- child: VListFormCellGroup(
- children: [
- _buildFormCell(
- label: '药物名称',
- content: medicationModel.name,
- onTap: () async {
- final result = await _showInputDialog(
- title: '药物名称',
- initialValue: medicationModel.name ?? '',
- );
- setState(() {
- medicationModel.name = result;
- });
- },
- ),
- _buildFormCell(
- label: '用法(每日次数)',
- content: medicationModel.usage,
- onTap: () async {
- final result = await _showNumberDialog(
- title: '用法(每日次数)',
- initialValue: medicationModel.usage ?? '',
- );
- setState(() {
- medicationModel.usage = result;
- });
- },
- ),
- // _buildFormCell(
- // label: '频率:每日(月)',
- // content: medicationModel.monthOrDay,
- // onTap: () async {
- // String? result = await VDialogSelect<String, String>(
- // source: [
- // "每月",
- // "每日",
- // ],
- // labelGetter: (data) => data,
- // valueGetter: (data) => data,
- // ).show();
- // setState(() {
- // medicationModel.monthOrDay = result;
- // });
- // },
- // ),
- _buildFormCell(
- label: '每次',
- content: medicationModel.dosages,
- onTap: () async {
- final result = await _showInputDialog(
- title: '每次',
- initialValue: medicationModel.dosages ?? '',
- );
- setState(() {
- medicationModel.dosages = result;
- });
- },
- ),
- ],
- ),
- ),
- onConfirm: () {
- Get.back(result: medicationModel);
- },
- );
- }
- Future<String?> _showInputDialog({
- required String title,
- required String initialValue,
- }) async {
- final result = await VDialogInput(
- title: title,
- initialValue: initialValue,
- ).show();
- return result;
- }
- Future<String?> _showNumberDialog({
- required String title,
- required String initialValue,
- }) async {
- final result = await VDialogNumber(
- title: title,
- initialValue: initialValue,
- ).show();
- return result;
- }
- Widget _buildFormCell({
- required String label,
- String? content,
- required VoidCallback onTap,
- }) {
- return VListFormCell(
- label: label,
- content: content ?? '',
- onTap: onTap,
- );
- }
- }
|