浏览代码

0018841: 【一体机】【居民列表】【筛选】居民列表页面中的筛选框中,UI修改点

finlay 10 月之前
父节点
当前提交
22a6f4d2c8

+ 13 - 3
lib/pages/patient/list/controller.dart

@@ -289,9 +289,19 @@ class PatientListController extends FControllerBase
       keyword: state.searchString,
       startTime: state.startTime.value,
       endTime: state.endTime.value?.add(const Duration(days: 1)),
-      crowdLabels: crowdLabelsController.state.selectedCodes.length == 0
-          ? null
-          : crowdLabelsController.state.selectedCodes,
+      crowdLabels: crowdLabelsController.state.isAllSelect
+          ? [
+              "RQFL_ET",
+              "RQFL_YF",
+              "RQFL_LNR",
+              "CJJB_GXY",
+              "CJJB_TNB",
+              "CJJB_YZJSBZA",
+              "CJJB_FJH"
+            ]
+          : crowdLabelsController.state.selectedCodes.length == 0
+              ? null
+              : crowdLabelsController.state.selectedCodes,
       createdBySelf: state.selectBoxFilterFounder == 0,
       contractState: state.contractStateSelectedItem,
     );

+ 55 - 33
lib/pages/patient/list/view.dart

@@ -215,41 +215,62 @@ class PatientListPage extends GetView<PatientListController> {
                 const SizedBox(
                   height: 20,
                 ),
-                Row(
-                  children: [
-                    const Text(
-                      '签约状态:',
-                      style: TextStyle(fontSize: 20),
-                    ),
-                    const SizedBox(
-                      width: 20,
-                    ),
-                    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()
-                        ],
-                      ),
-                    ),
+                const Text(
+                  '签约状态:',
+                  style: TextStyle(fontSize: 20),
+                ),
+                const SizedBox(
+                  height: 20,
+                ),
+                ContractStateSelectLabelView(
+                  ContractStateEnums: [
+                    ContractStateEnum.Signed,
+                    ContractStateEnum.Unsigned,
+                    ContractStateEnum.Voided,
+                    ContractStateEnum.Refused,
                   ],
+                  selectContractState:
+                      controller.state.contractStateSelectedItem,
+                  selectRaidoChange: (String value) {
+                    if (value == "0") {
+                      controller.state.contractStateSelectedItem = null;
+                      return;
+                    }
+                    controller.state.contractStateSelectedItem =
+                        ContractStateEnum.values
+                            .where((element) => element.name == value)
+                            .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()
+                //         ],
+                //       ),
+                //     ),
+                //   ],
+                // ),
               ],
             ),
           ),
@@ -280,6 +301,7 @@ class PatientListPage extends GetView<PatientListController> {
             Text(
               title,
               style: TextStyle(
+                fontSize: 16,
                 color: controller.state.selectBoxFilterFounder == value
                     ? const Color(0xff2c77e5)
                     : const Color(0xff4c4948),

+ 98 - 3
lib/pages/patient/list/widgets/crowd_select_label.dart

@@ -61,7 +61,11 @@ class _CrowdSelectLabelState extends State<CrowdSelectLabelView> {
         isChecked: controller.state.isAllSelect
             ? controller.state.isAllSelect
             : controller.state.selectedCodes.contains(dto.code),
+        isAllChecked: controller.state.isAllSelect,
         onChanged: (value) {
+          if (controller.state.isAllSelect && dto.code != "0") {
+            return;
+          }
           controller.onItemCheckChanged(dto.code!);
           if (controller.state.selectedCodes.length == 7) {
             controller.state.isAllSelect = true;
@@ -81,6 +85,9 @@ class VCheckBoxButton extends StatefulWidget {
   /// 是否默认选中
   final bool? isChecked;
 
+  /// 是否默认选中
+  final bool? isAllChecked;
+
   /// 选中状态变更
   final ValueChanged<bool>? onChanged;
 
@@ -89,6 +96,7 @@ class VCheckBoxButton extends StatefulWidget {
     required this.label,
     this.isChecked,
     this.onChanged,
+    this.isAllChecked,
   });
   @override
   State<StatefulWidget> createState() => _VCheckBoxState();
@@ -96,12 +104,16 @@ class VCheckBoxButton extends StatefulWidget {
 
 class _VCheckBoxState extends State<VCheckBoxButton> {
   bool _isChecked = false;
+  bool _isAllChecked = false;
 
   @override
   void initState() {
     if (widget.isChecked != null) {
       _isChecked = widget.isChecked!;
     }
+    if (widget.isAllChecked != null) {
+      _isAllChecked = widget.isAllChecked!;
+    }
     super.initState();
   }
 
@@ -127,9 +139,15 @@ class _VCheckBoxState extends State<VCheckBoxButton> {
               alignment: Alignment.center,
               height: height,
               decoration: BoxDecoration(
-                color: _isChecked ? primaryColor : Colors.white,
+                color: (_isAllChecked && widget.label != "全选")
+                    ? Colors.grey
+                    : _isChecked
+                        ? primaryColor
+                        : Colors.white,
                 borderRadius: BorderRadius.circular(borderRadius),
-                border: _isChecked ? null : Border.all(color: primaryColor),
+                border: ((_isAllChecked && widget.label != "全选") || _isChecked)
+                    ? null
+                    : Border.all(color: primaryColor),
               ),
               child: Row(
                 mainAxisSize: MainAxisSize.min,
@@ -138,7 +156,11 @@ class _VCheckBoxState extends State<VCheckBoxButton> {
                   Text(
                     widget.label,
                     style: TextStyle(
-                      color: _isChecked ? Colors.white : primaryColor,
+                      color: (_isAllChecked && widget.label != "全选")
+                          ? Colors.black
+                          : _isChecked
+                              ? Colors.white
+                              : primaryColor,
                       fontSize: 16,
                     ),
                   ),
@@ -151,3 +173,76 @@ class _VCheckBoxState extends State<VCheckBoxButton> {
     );
   }
 }
+
+class ContractStateSelectLabelView extends StatefulWidget {
+  final List<ContractStateEnum> ContractStateEnums;
+  final Function selectRaidoChange;
+  final ContractStateEnum? selectContractState;
+
+  const ContractStateSelectLabelView(
+      {super.key,
+      required this.ContractStateEnums,
+      required this.selectRaidoChange,
+      this.selectContractState});
+  @override
+  State<StatefulWidget> createState() => _ContractStateSelectLabelState();
+}
+
+class _ContractStateSelectLabelState
+    extends State<ContractStateSelectLabelView> {
+  late List<ContractStateEnum> ContractStateEnums;
+  String selectContractState = "0";
+
+  final Map<String, String> ContractStateMap = {
+    "All": "未选择",
+    "Unsigned": "未签约",
+    "Cancelled": "已取消",
+    "Expired": "已过期",
+    "Signed": "已签约",
+    "Voided": "已解约",
+    "Refused": "已拒绝",
+  };
+  @override
+  void initState() {
+    super.initState();
+    ContractStateEnums = widget.ContractStateEnums;
+    if (widget.selectContractState != null) {
+      selectContractState = widget.selectContractState!.name;
+    } else {
+      selectContractState = "0";
+    }
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Wrap(
+      spacing: 16,
+      runSpacing: 12,
+      children: [
+        buildItem(LabelDTO(code: "0", labelName: "全选"), context),
+        ...ContractStateEnums.map((ContractStateEnum e) => buildItem(
+            LabelDTO(code: e.name, labelName: ContractStateMap[e.name]),
+            context)).toList(),
+      ],
+    );
+  }
+
+  Widget buildItem(LabelDTO dto, BuildContext context) {
+    return InkWell(
+      child: VCheckBoxButton(
+        key: GlobalKey(),
+        label: dto.labelName ?? '',
+        isChecked: selectContractState == dto.code,
+        // isAllChecked: selectContractState == "0",
+        onChanged: (value) {
+          // if (selectContractState == "0" && dto.code != "0") {
+          //   return;
+          // }
+          selectContractState = dto.code ?? '0';
+          widget.selectRaidoChange(dto.code);
+          setState(() {});
+        },
+      ),
+    );
+  }
+}