Browse Source

添加齿列

gavin.chen 1 year ago
parent
commit
0114fbea74

+ 52 - 24
lib/pages/check/widgets/exam_configurable/exam_dentition.dart

@@ -18,10 +18,10 @@ class ExamDentition extends StatefulWidget {
 class _ExamDentitionState extends State<ExamDentition> {
   Set<int> status = {};
 
-  Map<int, List<int>> dentitionDetail = {
-    1: [],
-    2: [],
-    3: [],
+  Map<int, Set<int>> dentitionDetail = {
+    1: {},
+    2: {},
+    3: {},
   };
 
   Map _value = {};
@@ -48,18 +48,30 @@ class _ExamDentitionState extends State<ExamDentition> {
         }
       }
     }
-    final detailValue = _value['detail'] ?? {};
-    if (detailValue is Map) {
-      for (var item in detailValue.entries) {
-        if (item.key is int && item.key >= 1 && item.key <= 3) {
-          dentitionDetail[item.key] = [];
-          if (item.value is List) {
-            for (var index in item.value) {
-              if (index is int && index >= 1 && index <= 32) {
-                dentitionDetail[item.key]!.add(index);
-              }
-            }
-          }
+    final detailA = _value['detail_a'] ?? [];
+    if (detailA is List) {
+      for (var i = 0; i < detailA.length; i++) {
+        final item = detailA[i];
+        if (item is int && item >= 1 && item <= 32) {
+          dentitionDetail[1]!.add(item);
+        }
+      }
+    }
+    final detailB = _value['detail_b'] ?? [];
+    if (detailB is List) {
+      for (var i = 0; i < detailB.length; i++) {
+        final item = detailB[i];
+        if (item is int && item >= 1 && item <= 32) {
+          dentitionDetail[2]!.add(item);
+        }
+      }
+    }
+    final detailC = _value['detail_c'] ?? [];
+    if (detailC is List) {
+      for (var i = 0; i < detailC.length; i++) {
+        final item = detailC[i];
+        if (item is int && item >= 1 && item <= 32) {
+          dentitionDetail[3]!.add(item);
         }
       }
     }
@@ -83,14 +95,14 @@ class _ExamDentitionState extends State<ExamDentition> {
 
   void resetAllDentitionDetail() {
     dentitionDetail = {
-      1: [],
-      2: [],
-      3: [],
+      1: {},
+      2: {},
+      3: {},
     };
   }
 
   void resetDentitionDetail(int parentIndex) {
-    dentitionDetail[parentIndex] = [];
+    dentitionDetail[parentIndex] = {};
   }
 
   // 切换状态
@@ -107,9 +119,17 @@ class _ExamDentitionState extends State<ExamDentition> {
       status.remove(0);
     }
     setState(() {});
+    final detailA = dentitionDetail[1]!.toList();
+    final detailB = dentitionDetail[2]!.toList();
+    final detailC = dentitionDetail[3]!.toList();
+    detailA.sort((a, b) => a - b);
+    detailB.sort((a, b) => a - b);
+    detailC.sort((a, b) => a - b);
     widget.onValueChange.call({
       'status': status.toList(),
-      'detail': dentitionDetail,
+      'detail_a': detailA,
+      'detail_b': detailB,
+      'detail_c': detailC,
     });
   }
 
@@ -121,9 +141,17 @@ class _ExamDentitionState extends State<ExamDentition> {
       dentitionDetail[parentIndex]!.add(index);
     }
     setState(() {});
+    final detailA = dentitionDetail[1]!.toList();
+    final detailB = dentitionDetail[2]!.toList();
+    final detailC = dentitionDetail[3]!.toList();
+    detailA.sort((a, b) => a - b);
+    detailB.sort((a, b) => a - b);
+    detailC.sort((a, b) => a - b);
     widget.onValueChange.call({
       'status': status.toList(),
-      'detail': dentitionDetail,
+      'detail_a': detailA,
+      'detail_b': detailB,
+      'detail_c': detailC,
     });
   }
 
@@ -193,7 +221,7 @@ class _ExamDentitionState extends State<ExamDentition> {
     );
   }
 
-  Widget _buildDentitionDetail(MapEntry<int, List<int>> detailInfo) {
+  Widget _buildDentitionDetail(MapEntry<int, Set<int>> detailInfo) {
     if (!status.contains(detailInfo.key)) {
       return Container();
     }
@@ -222,7 +250,7 @@ class _ExamDentitionState extends State<ExamDentition> {
     );
   }
 
-  Widget _buildDentitionItem(int parentIndex, List<int> selectedIndexs) {
+  Widget _buildDentitionItem(int parentIndex, Set<int> selectedIndexs) {
     final onTap = (int index) {
       onSelectDentition(parentIndex, index);
     };

+ 0 - 1
lib/pages/check/widgets/new_configurable_card.dart

@@ -675,7 +675,6 @@ class NewConfigurableFormState extends State<NewConfigurableCard> {
   Widget _buildDentition(FormObject currentFormObject) {
     Map currentValue = formValue[currentFormObject.key!] ?? {};
     void onValueChange(Map value) {
-      print(value);
       currentValue = value;
       formValue[currentFormObject.key!] = currentValue;
       setState(() {});