Jelajahi Sumber

fix: 0017876: 【体检系统】【预约】在web客户端-预约管理中,已预约的人点击“解除预约”,无任何响应

loki.wu 1 tahun lalu
induk
melakukan
762b9e3e1d

+ 21 - 0
lib/managers/appointment.dart

@@ -90,6 +90,27 @@ class AppointmentManager implements IAppointmentManager {
     }
   }
 
+  ///解除预约
+  Future<bool> cancelHealthExam(
+    String code,
+    String identityCard,
+  ) async {
+    try {
+      final result =
+          await rpc.vitalHealthExamBooking.cancelHealthExamBookingAsync(
+        CancelHealthExamBookingRequest(
+          token: Store.user.token,
+          code: code,
+          identityCard: identityCard,
+        ),
+      );
+      return result;
+    } catch (e) {
+      logger.e("AppointmentManager deleteHealthExam ex:$e");
+      return false;
+    }
+  }
+
   /// 根据身份证获取预约信息
   @override
   Future<HealthExamPersonDTO?> getExamBookingByIDCardAsync({

+ 6 - 0
lib/managers/interfaces/appointment.dart

@@ -15,6 +15,12 @@ abstract class IAppointmentManager implements IManager {
     SaveHealthExamBookingRequest saveHealthExamBookingRequest,
   );
 
+  ///解除预约
+  Future<bool> cancelHealthExam(
+    String code,
+    String identityCard,
+  );
+
   /// 查询体检详情
   Future<HealthExamBookingDTO?> getHealthExamBookingAsync({
     required String code,

+ 9 - 0
lib/pages/medical_checkup_station/appointment/controller/form.dart

@@ -52,6 +52,15 @@ class AppointmentFormController {
     return true;
   }
 
+  ///解除预约
+  Future<bool> cancelHealthExam(
+    String code,
+    String identityCard,
+  ) async {
+    return await appointmentController.appointmentManager
+        .cancelHealthExam(code, identityCard);
+  }
+
   String? _validateForm(AppointmentModel model) {
     if (model.appointmentName.isEmpty) {
       return "请填写预约体检名称";

+ 35 - 39
lib/pages/medical_checkup_station/appointment/controller/list.dart

@@ -142,13 +142,10 @@ class AppointmentListController {
                     appointmentController
                         .appointmentModelList[index].appointmentCode!,
                   );
-                  onDeleteExaminerEvent.addListener(deleteExaminer);
-
                   await Get.dialog(MedicalExaminer(
                     examiner: appointment,
-                    onDeleteExaminerEvent: onDeleteExaminerEvent,
+                    onTapChangeBind: deleteExaminer,
                   ));
-                  onDeleteExaminerEvent.removeListener(deleteExaminer);
                 },
                 child: Text(
                   "${rowData.appointPersons?.length ?? 0}",
@@ -269,43 +266,42 @@ class AppointmentListController {
     });
   }
 
-  void deleteExaminer(sender, e) async {
-    if (e != null) {
-      Get.dialog(
-        VAlertDialog(
-          title: "提示",
-          width: 260,
-          content: Container(
-            height: 32,
-            padding: const EdgeInsets.symmetric(horizontal: 24),
-            alignment: Alignment.center,
-            child: const Text(
-              "确定解除预约?",
-              style: TextStyle(fontSize: 20),
-            ),
+  Future<bool> deleteExaminer(String e) async {
+    bool? result = await Get.dialog<bool>(
+      VAlertDialog(
+        title: "提示",
+        width: 260,
+        content: Container(
+          height: 32,
+          padding: const EdgeInsets.symmetric(horizontal: 24),
+          alignment: Alignment.center,
+          child: const Text(
+            "确定解除预约?",
+            style: TextStyle(fontSize: 20),
           ),
-          onConfirm: () async {
-            Get.back();
-            List<HealthExamPersonDTO>? appointPersons = appointment
-                .appointPersons
-                ?.where((element) => element.name != e)
-                .toList();
-            appointment.appointPersons = appointPersons;
-            bool result = await appointmentController.formController
-                .saveHealthExamBooking(
-              appointment,
-              isEdit: true,
-              isdelete: true,
-            );
-            if (result) {
-              PromptBox.toast('解除成功');
-            }
-          },
         ),
-        barrierDismissible: false,
-        barrierColor: Colors.black.withOpacity(.4),
-      );
-    }
+        onConfirm: () async {
+          List<HealthExamPersonDTO>? appointPersons = appointment.appointPersons
+              ?.where((element) => element.identityCard != e)
+              .toList();
+          appointment.appointPersons = appointPersons;
+          bool result =
+              await appointmentController.formController.cancelHealthExam(
+            appointment.appointmentCode!,
+            e,
+          );
+          if (result) {
+            await appointmentController.listController
+                .getHealthExamBookingPageAsync();
+            PromptBox.toast('解除成功');
+          }
+          Get.back(result: result);
+        },
+      ),
+      barrierDismissible: false,
+      barrierColor: Colors.black.withOpacity(.4),
+    );
+    return result ?? false;
   }
 
   String getStartAndEndTime(DateTime? startTime, DateTime? endTime) {

+ 28 - 8
lib/pages/medical_checkup_station/appointment/widgets/medical_examiner.dart

@@ -6,14 +6,31 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
 import 'package:vitalapp/pages/medical_checkup_station/appointment/state/list.dart';
 import 'package:vitalapp/pages/medical_checkup_station/appointment/widgets/examiner_card.dart';
 
-class MedicalExaminer extends StatelessWidget {
+class MedicalExaminer extends StatefulWidget {
   MedicalExaminer({
     super.key,
     this.examiner,
-    this.onDeleteExaminerEvent,
+    this.onTapChangeBind,
   });
-  AppointmentModel? examiner;
-  FEventHandler<String>? onDeleteExaminerEvent;
+  final AppointmentModel? examiner;
+  final Future<bool> Function(String)? onTapChangeBind;
+
+  @override
+  State<StatefulWidget> createState() {
+    return MedicalExaminerState();
+  }
+
+  // Widget _build
+}
+
+class MedicalExaminerState extends State<MedicalExaminer> {
+  @override
+  void didUpdateWidget(covariant MedicalExaminer oldWidget) {
+    super.didUpdateWidget(oldWidget);
+    if (widget.examiner != oldWidget.examiner) {
+      setState(() {});
+    }
+  }
 
   @override
   Widget build(BuildContext context) {
@@ -34,12 +51,17 @@ class MedicalExaminer extends StatelessWidget {
             crossAxisCount: 2,
             mainAxisSpacing: 16,
             crossAxisSpacing: 16,
-            children: examiner?.appointPersons
+            children: widget.examiner?.appointPersons
                     ?.map((e) => ExaminerCard(
                           name: e.name ?? '',
                           onTapChangeBind: (value) async {
                             print(value);
-                            onDeleteExaminerEvent?.emit(this, e.name ?? '');
+                            var result = await widget.onTapChangeBind?.call(
+                              e.identityCard ?? '',
+                            );
+                            if (result ?? false) {
+                              setState(() {});
+                            }
                           },
                         ))
                     .toList() ??
@@ -49,6 +71,4 @@ class MedicalExaminer extends StatelessWidget {
       ),
     );
   }
-
-  // Widget _build
 }

+ 2 - 2
pubspec.lock

@@ -383,8 +383,8 @@ packages:
     dependency: "direct main"
     description:
       path: "."
-      ref: "4c93643"
-      resolved-ref: "4c93643dc07a329cd06d5cf36e06cee4876c126b"
+      ref: "4590ea8b0c3a7790ba695e0f80c4fa5e9c809f60"
+      resolved-ref: "4590ea8b0c3a7790ba695e0f80c4fa5e9c809f60"
       url: "http://git.ius.plus:88/Project-Wing/fis_lib_jsonrpc.git"
     source: git
     version: "0.0.1"

+ 1 - 1
pubspec.yaml

@@ -158,7 +158,7 @@ dependency_overrides:
   fis_jsonrpc:
     git:
       url: http://git.ius.plus:88/Project-Wing/fis_lib_jsonrpc.git
-      ref: 4c93643
+      ref: 4590ea8b0c3a7790ba695e0f80c4fa5e9c809f60
     #path: ../fis_lib_jsonrpc
   fis_theme:
     git: