Quellcode durchsuchen

1、优化组件

guanxinyi vor 1 Jahr
Ursprung
Commit
8a954e0cf9

+ 59 - 6
lib/pages/check/widgets/configurable_card.dart

@@ -40,6 +40,7 @@ import 'package:vitalapp/pages/check/widgets/exam_table/homecare_bed_history_fro
 import 'package:vitalapp/pages/check/widgets/exam_table/hospitalization_history_from.dart';
 import 'package:vitalapp/pages/check/widgets/exam_table/inoculate_history_from.dart';
 import 'package:vitalapp/pages/check/widgets/exam_table/main_medication_status_from.dart';
+import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_anterior_fontanelle_other.dart';
 import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_height_and_weight.dart';
 import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_radio_input.dart';
 import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_referral.dart';
@@ -417,6 +418,7 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
       'checkBoxIncludeOther': _buildCheckBoxIncludeOther,
       'inputAndRadio': _buildChildHeightAndWeight,
       'anteriorFontanelle': _buildAnteriorFontanelle,
+      'anteriorFontanelleOther': _buildAnteriorFontanelleOther,
       'referral': _buildFollowUpChildReferral,
       'prescriptionType': _buildPrescription,
     };
@@ -626,6 +628,57 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
     );
   }
 
+  /// 前囟其他
+  Widget _buildAnteriorFontanelleOther(FormObject currentFormObject) {
+    List<Option> options = currentFormObject.options ?? [];
+    String currentSelected = formValue[currentFormObject.key!] ?? "";
+    String currentLength = formValue["Fontanel_Length"] ?? "";
+    String currentWidth = formValue["Fontanel_Width"] ?? "";
+
+    void selectRaidoChange(Option e) {
+      currentSelected = e.value ?? '';
+      formValue[currentFormObject.key!] = currentSelected;
+      if (e.value == '1' && options.length == 2) {
+        formValue["Fontanel_Length"] = "";
+        formValue["Fontanel_Width"] = "";
+      }
+      setState(() {});
+    }
+
+    void selectOtherValue(String value) {
+      formValue["Fontanel_Other"] = value;
+      setState(() {});
+    }
+
+    if (currentSelected != '4') {
+      formValue["Fontanel_Other"] = "";
+    }
+
+    void selectInputChange(String inputKey, String? inputValue) {
+      if (inputValue == null) return;
+
+      if (inputKey == "length") {
+        currentLength = inputValue;
+        formValue["Fontanel_Length"] = currentLength;
+      } else if (inputKey == "width") {
+        currentWidth = inputValue;
+        formValue["Fontanel_Width"] = currentWidth;
+      }
+
+      setState(() {});
+    }
+
+    return FollowUpChildAnteriorFontanelleOther(
+      options: options,
+      currentFormObject: currentFormObject,
+      selectRaidoChange: selectRaidoChange,
+      currentSelected: currentSelected,
+      selectInputChange: selectInputChange,
+      selectOtherValue: selectOtherValue,
+      formValue: formValue,
+    );
+  }
+
   /// 转诊建议
   Widget _buildFollowUpChildReferral(FormObject currentFormObject) {
     List<Option> options = currentFormObject.options ?? [];
@@ -1145,7 +1198,7 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
     List<Option> options = currentFormObject.options ?? [];
     String currentSelected =
         formValue[currentFormObject.childrenKey!.first] ?? "";
-    String currentScore = formValue[currentFormObject.childrenKey!.last] ?? "";
+    String currentValue = formValue[currentFormObject.childrenKey!.last] ?? "";
 
     void selectRaidoChange(Option e) {
       currentSelected = e.value ?? '';
@@ -1153,9 +1206,9 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
       setState(() {});
     }
 
-    void changeScore(String? score) {
-      currentScore = score ?? '';
-      formValue[currentFormObject.childrenKey!.last] = currentScore;
+    void changeValue(String? value) {
+      currentValue = value ?? '';
+      formValue[currentFormObject.childrenKey!.last] = currentValue;
       setState(() {});
     }
 
@@ -1164,8 +1217,8 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
       currentFormObject: currentFormObject,
       selectRaidoChange: selectRaidoChange,
       currentSelected: currentSelected,
-      changeScore: changeScore,
-      currentScore: currentScore,
+      changeValue: changeValue,
+      currentValue: currentValue,
     );
   }
 

+ 199 - 0
lib/pages/check/widgets/follow_up_configurable/follow_up_child_anterior_fontanelle_other.dart

@@ -0,0 +1,199 @@
+// ignore_for_file: must_be_immutable
+
+import 'package:flutter/material.dart';
+import 'package:vitalapp/components/dialog_number.dart';
+import 'package:vitalapp/pages/check/models/form.dart';
+import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio_and_select.dart';
+import 'package:vitalapp/pages/check/widgets/exam_title.dart';
+
+/// 前囟特殊组件
+class FollowUpChildAnteriorFontanelleOther extends StatelessWidget {
+  FollowUpChildAnteriorFontanelleOther({
+    super.key,
+    required this.currentFormObject,
+    required this.options,
+    required this.selectRaidoChange,
+    required this.selectInputChange,
+    required this.currentSelected,
+    required this.formValue,
+    required this.selectOtherValue,
+  });
+  final FormObject currentFormObject;
+  final List<Option> options;
+  final Function selectRaidoChange;
+  final Function selectOtherValue;
+  final Function(String, String?) selectInputChange;
+  final String currentSelected;
+  final Map<String, dynamic> formValue;
+
+  Future<void> commonInput(String inputKey) async {
+    String mapKey = "Fontanel_Length";
+    if (inputKey == "width") {
+      mapKey = "Fontanel_Width";
+    }
+    if (formValue[mapKey] == null) {
+      formValue[mapKey] = "";
+    }
+    String? result = await VDialogNumber(
+      title: currentFormObject.label,
+      initialValue: formValue[mapKey],
+    ).show();
+    if (result?.isNotEmpty ?? false) {
+      selectInputChange.call(inputKey, result);
+    }
+  }
+
+  Future<void> commonValue() async {
+    String mapKey = "Fontanel_Other";
+
+    String? result = await VDialogNumber(
+      title: currentFormObject.label,
+      initialValue: formValue[mapKey],
+    ).show();
+    if (result?.isNotEmpty ?? false) {
+      selectOtherValue.call(result);
+    }
+  }
+
+  TextStyle testStyle = const TextStyle(
+    fontSize: 30,
+    color: Colors.black,
+  );
+
+  @override
+  Widget build(BuildContext context) {
+    if (currentFormObject.showLimit ?? true) {
+      return ExamCardRadioSelect(
+        titleText: ExamTitle(
+          label: currentFormObject.label,
+          titleType: '(单选)',
+        ),
+        title: currentFormObject.label ?? '',
+        content: Container(
+          padding: const EdgeInsets.symmetric(
+            horizontal: 5,
+            vertical: 16,
+          ).copyWith(top: 0),
+          alignment: currentFormObject.span == 24
+              ? Alignment.centerLeft
+              : Alignment.center,
+          width: double.infinity,
+          child: Column(
+            children: [
+              Wrap(
+                children: options
+                    .map(
+                      (e) => Container(
+                        padding: const EdgeInsets.all(7),
+                        child: InkWell(
+                          onTap: () {
+                            selectRaidoChange.call(e);
+                          },
+                          borderRadius: BorderRadius.circular(50),
+                          child: Ink(
+                            decoration: BoxDecoration(
+                              border: Border.all(
+                                color: currentSelected == e.value
+                                    ? Colors.blue
+                                    : Colors.black26,
+                              ),
+                              borderRadius: const BorderRadius.all(
+                                Radius.circular(50),
+                              ),
+                              color: currentSelected == e.value
+                                  ? Colors.blue
+                                  : Colors.transparent,
+                            ),
+                            child: Container(
+                              padding: const EdgeInsets.all(15),
+                              alignment: Alignment.center,
+                              width: 250,
+                              child: FittedBox(
+                                child: Text(
+                                  e.label ?? '',
+                                  style: TextStyle(
+                                    fontSize: 20,
+                                    color: currentSelected == e.value
+                                        ? Colors.white
+                                        : Colors.black54,
+                                  ),
+                                ),
+                              ),
+                            ),
+                          ),
+                        ),
+                      ),
+                    )
+                    .toList(),
+              ),
+              if (currentSelected == '4')
+                Container(
+                  padding: EdgeInsets.only(bottom: 16),
+                  child: Center(
+                      child: Row(
+                    children: [
+                      Expanded(
+                        child: TextField(
+                          readOnly: true,
+                          textAlign: TextAlign.center,
+                          controller: TextEditingController(
+                            text: formValue['Fontanel_Other'],
+                          ),
+                          style: const TextStyle(fontSize: 30),
+                          onTap: () => commonValue(),
+                        ),
+                      ),
+                    ],
+                  )),
+                ),
+              Container(
+                padding: EdgeInsets.only(bottom: 16),
+                child: Center(
+                    child: Row(
+                  children: [
+                    Expanded(
+                      child: TextField(
+                        readOnly: true,
+                        textAlign: TextAlign.center,
+                        controller: TextEditingController(
+                          text: formValue['Fontanel_Length'],
+                        ),
+                        style: const TextStyle(fontSize: 30),
+                        onTap: () => commonInput("length"),
+                      ),
+                    ),
+                    Text(
+                      "cm",
+                      style: testStyle,
+                    ),
+                    Text(
+                      "×",
+                      style: testStyle,
+                    ),
+                    Expanded(
+                      child: TextField(
+                        readOnly: true,
+                        textAlign: TextAlign.center,
+                        controller: TextEditingController(
+                          text: formValue['Fontanel_Width'],
+                        ),
+                        style: const TextStyle(fontSize: 30),
+                        onTap: () => commonInput("width"),
+                      ),
+                    ),
+                    Text(
+                      "cm",
+                      style: testStyle,
+                    ),
+                  ],
+                )),
+              )
+            ],
+          ),
+        ),
+      );
+    } else {
+      return Container();
+    }
+  }
+}

+ 80 - 75
lib/pages/check/widgets/follow_up_configurable/follow_up_child_radio_input.dart

@@ -1,7 +1,8 @@
 import 'package:flutter/material.dart';
-import 'package:vitalapp/components/dialog_number.dart';
+import 'package:vitalapp/components/dialog_input.dart';
 import 'package:vitalapp/pages/check/models/form.dart';
-import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_card.dart';
+import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio_and_select.dart';
+import 'package:vitalapp/pages/check/widgets/exam_title.dart';
 
 // ignore: must_be_immutable
 class FollowUpChildRadioInput extends StatelessWidget {
@@ -11,110 +12,114 @@ class FollowUpChildRadioInput extends StatelessWidget {
     required this.options,
     required this.selectRaidoChange,
     required this.currentSelected,
-    required this.changeScore,
-    required this.currentScore,
+    required this.changeValue,
+    required this.currentValue,
   });
   final FormObject currentFormObject;
   final List<Option> options;
   final Function selectRaidoChange;
   final String currentSelected;
-  final Function changeScore;
-  final String currentScore;
+  final Function changeValue;
+  final String currentValue;
 
   Future<void> commonInput() async {
-    String? result = await VDialogNumber(
+    String? result = await VDialogInput(
       title: currentFormObject.label,
-      initialValue: currentScore,
+      initialValue: currentValue,
     ).show();
     if (result?.isNotEmpty ?? false) {
-      changeScore(result);
+      changeValue.call(result);
     }
   }
 
   @override
   Widget build(BuildContext context) {
-    return ExamCard(
+    return ExamCardRadioSelect(
+      titleText: ExamTitle(
+        label: currentFormObject.label,
+        titleType: '(单选)',
+      ),
       title: currentFormObject.label ?? '',
       content: Stack(
         children: [
           Container(
-            padding: const EdgeInsets.symmetric(
-              horizontal: 5,
+            padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 12)
+                .copyWith(
+              top: 0,
             ),
             width: double.infinity,
-            child: Wrap(
-              children: options
-                  .map(
-                    (e) => Container(
-                      padding: const EdgeInsets.all(8),
-                      child: InkWell(
-                        onTap: () => selectRaidoChange(e),
-                        borderRadius: BorderRadius.circular(50),
-                        child: Ink(
-                          decoration: BoxDecoration(
-                            border: Border.all(
-                              color: currentSelected == e.value
-                                  ? Colors.blue
-                                  : Colors.black26,
-                            ),
-                            borderRadius: const BorderRadius.all(
-                              Radius.circular(50),
-                            ),
-                            color: currentSelected == e.value
-                                ? Colors.blue
-                                : Colors.transparent,
-                          ),
-                          child: Container(
-                            padding: const EdgeInsets.all(15),
-                            alignment: Alignment.center,
-                            width: 250,
-                            child: FittedBox(
-                              child: Text(
-                                e.label ?? '',
-                                style: TextStyle(
-                                  fontSize: 20,
+            child: Column(
+              children: [
+                Wrap(
+                  children: options
+                      .map(
+                        (e) => Container(
+                          padding: const EdgeInsets.all(6),
+                          child: InkWell(
+                            onTap: () => selectRaidoChange(e),
+                            borderRadius: BorderRadius.circular(50),
+                            child: Ink(
+                              decoration: BoxDecoration(
+                                border: Border.all(
                                   color: currentSelected == e.value
-                                      ? Colors.white
-                                      : Colors.black54,
+                                      ? Colors.blue
+                                      : Colors.black26,
+                                ),
+                                borderRadius: const BorderRadius.all(
+                                  Radius.circular(50),
+                                ),
+                                color: currentSelected == e.value
+                                    ? Colors.blue
+                                    : Colors.transparent,
+                              ),
+                              child: Container(
+                                padding: const EdgeInsets.all(15),
+                                alignment: Alignment.center,
+                                width: 250,
+                                child: FittedBox(
+                                  child: Text(
+                                    e.label ?? '',
+                                    style: TextStyle(
+                                      fontSize: 20,
+                                      color: currentSelected == e.value
+                                          ? Colors.white
+                                          : Colors.black54,
+                                    ),
+                                  ),
                                 ),
                               ),
                             ),
                           ),
                         ),
-                      ),
+                      )
+                      .toList(),
+                ),
+                if (currentSelected == currentFormObject.buttonName)
+                  Container(
+                    padding: EdgeInsets.symmetric(horizontal: 20),
+                    child: Row(
+                      mainAxisAlignment: MainAxisAlignment.center,
+                      children: [
+                        Text(
+                          '其他:',
+                          style: const TextStyle(fontSize: 20),
+                        ),
+                        Expanded(
+                          child: TextField(
+                            textAlign: TextAlign.center,
+                            readOnly: true,
+                            controller:
+                                TextEditingController(text: currentValue),
+                            style: const TextStyle(fontSize: 30),
+                            onTap: () => commonInput(),
+                          ),
+                        )
+                      ],
                     ),
                   )
-                  .toList(),
+              ],
             ),
           ),
-          if (currentSelected == '3')
-            Positioned(
-              right: 30,
-              child: Container(
-                child: Row(
-                  children: [
-                    // const Text(
-                    //   '总分:',
-                    //   style: TextStyle(
-                    //     fontSize: 30,
-                    //   ),
-                    // ),
-                    const SizedBox(
-                      width: 16,
-                    ),
-                    SizedBox(
-                      width: 100,
-                      child: TextField(
-                        readOnly: true,
-                        controller: TextEditingController(text: currentScore),
-                        style: const TextStyle(fontSize: 30),
-                        onTap: () => commonInput(),
-                      ),
-                    )
-                  ],
-                ),
-              ),
-            )
         ],
       ),
     );