Просмотр исходного кода

居民列表筛选条件优化

finlay 10 месяцев назад
Родитель
Сommit
122ba7f2b1

+ 5 - 70
lib/pages/patient/list/view.dart

@@ -191,13 +191,11 @@ class PatientListPage extends GetView<PatientListController> {
                 const SizedBox(
                   height: 20,
                 ),
-                Obx(
-                  () => Row(
-                    children: [
-                      _tabRadio(title: "仅当前医生建档", value: 0),
-                      _tabRadio(title: "当前团队所有居民", value: 1)
-                    ],
-                  ),
+                ScopeEnquiryResidents(
+                  selectRaidoChange: (int value) {
+                    controller.state.selectBoxFilterFounder = value;
+                  },
+                  selectIndex: controller.state.selectBoxFilterFounder,
                 ),
                 const SizedBox(
                   height: 20,
@@ -242,35 +240,6 @@ class PatientListPage extends GetView<PatientListController> {
                             .first;
                   },
                 ),
-                // Row(
-                //   children: [
-
-                //     Obx(
-                //       () => DropdownButton<ContractStateEnum>(
-                //         value: controller.state.contractStateSelectedItem,
-                //         onChanged: (value) {
-                //           controller.state.contractStateSelectedItem = value;
-                //         },
-                //         focusColor: Colors.white,
-                //         items: [
-                //           DropdownMenuItem<ContractStateEnum>(
-                //             value: null,
-                //             child: Text("全选"),
-                //           ),
-                //           ...ContractStateEnum.values
-                //               .map<DropdownMenuItem<ContractStateEnum>>(
-                //                   (ContractStateEnum value) {
-                //             return DropdownMenuItem<ContractStateEnum>(
-                //               value: value,
-                //               child: Text(
-                //                   controller.ContractStateMap[value.name]!),
-                //             );
-                //           }).toList()
-                //         ],
-                //       ),
-                //     ),
-                //   ],
-                // ),
               ],
             ),
           ),
@@ -279,40 +248,6 @@ class PatientListPage extends GetView<PatientListController> {
     );
   }
 
-  Widget _tabRadio({
-    required String title,
-    required dynamic value,
-  }) {
-    return InkWell(
-      onTap: () {
-        controller.changeFilterFounder(value);
-      },
-      child: Container(
-        margin: EdgeInsets.only(right: 15),
-        child: Row(
-          children: [
-            Radio(
-              value: value,
-              groupValue: controller.state.selectBoxFilterFounder,
-              onChanged: (v) {
-                controller.changeFilterFounder(value);
-              },
-            ),
-            Text(
-              title,
-              style: TextStyle(
-                fontSize: 16,
-                color: controller.state.selectBoxFilterFounder == value
-                    ? const Color(0xff2c77e5)
-                    : const Color(0xff4c4948),
-              ),
-            ),
-          ],
-        ),
-      ),
-    );
-  }
-
   Widget _buildListView() {
     final scrollController = ScrollController();
     scrollController.addListener(

+ 57 - 0
lib/pages/patient/list/widgets/crowd_select_label.dart

@@ -228,3 +228,60 @@ class _ContractStateSelectLabelState
     );
   }
 }
+
+class ScopeEnquiryResidents extends StatefulWidget {
+  final Function selectRaidoChange;
+  final int? selectIndex;
+
+  const ScopeEnquiryResidents({
+    super.key,
+    required this.selectRaidoChange,
+    this.selectIndex,
+  });
+  @override
+  State<StatefulWidget> createState() => _ScopeEnquiryResidentsState();
+}
+
+class _ScopeEnquiryResidentsState extends State<ScopeEnquiryResidents> {
+  int selectIndex = 0;
+  @override
+  void initState() {
+    super.initState();
+    if (widget.selectIndex != null) {
+      selectIndex = widget.selectIndex!;
+    } else {
+      selectIndex = 0;
+    }
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Wrap(
+      spacing: 16,
+      runSpacing: 12,
+      children: [
+        buildItem(LabelDTO(code: "0", labelName: "仅当前医生建档"), context),
+        buildItem(LabelDTO(code: "1", labelName: "当前团队所有居民"), context),
+      ],
+    );
+  }
+
+  Widget buildItem(LabelDTO dto, BuildContext context) {
+    return InkWell(
+      child: VCheckBoxButton(
+        key: GlobalKey(),
+        label: dto.labelName ?? '',
+        isChecked: selectIndex.toString() == dto.code,
+        // isAllChecked: selectContractState == "0",
+        onChanged: (value) {
+          // if (selectContractState == "0" && dto.code != "0") {
+          //   return;
+          // }
+          selectIndex = int.parse(dto.code!);
+          widget.selectRaidoChange(selectIndex);
+          setState(() {});
+        },
+      ),
+    );
+  }
+}