Browse Source

加入扫一扫

gavin.chen 1 year ago
parent
commit
63c5a6f5f7
3 changed files with 53 additions and 37 deletions
  1. 24 17
      lib/pages/home/controller.dart
  2. 29 15
      lib/pages/home/view.dart
  3. 0 5
      lib/store/modules/user.dart

+ 24 - 17
lib/pages/home/controller.dart

@@ -12,6 +12,7 @@ import 'package:vitalapp/components/appbar.dart';
 import 'package:vitalapp/global.dart';
 import 'package:vitalapp/helper/goto_helper.dart';
 import 'package:vitalapp/managers/interfaces/account.dart';
+import 'package:vitalapp/managers/interfaces/device.dart';
 import 'package:vitalapp/managers/interfaces/patient.dart';
 import 'package:vitalapp/pages/controllers/home_nav_mixin.dart';
 import 'package:vitalapp/pages/home/models/menu.dart';
@@ -47,8 +48,6 @@ class HomeController extends FControllerBase with HomeNavMixin {
 
   final state = HomeState();
 
-  /// 当前选中路由
-  int currentIndex = -1;
   List<HomeMenuItem> homeMenuItems = [
     HomeMenuItem(
       key: 'ZY',
@@ -348,22 +347,30 @@ class HomeController extends FControllerBase with HomeNavMixin {
   }
 
   void onScanData(String code) async {
-    print('$code');
-    RegisterPersonInfoDTO? registerPersonInfo =
-        await _patientManager.getRegisterPersonInfoByPhysicalExamNumberAsync(
-      physicalExamNumber: code,
-    );
-    PatientDTO? patientInfo = PatientDTO();
-    if (registerPersonInfo != null &&
-        registerPersonInfo.physicalExamNumber != null) {
-      patientInfo.code = registerPersonInfo.code;
-      patientInfo.patientName = registerPersonInfo.name;
-      Store.user.currentSelectRegisterPersonInfo = registerPersonInfo;
-      Store.user.currentSelectPatientInfo = patientInfo;
+    try {
+      print('$code');
+      final deviceManager = Get.find<IDeviceManager>();
+      deviceManager.onScanCode.emit(this, code);
+      Get.back();
+    } catch (e) {
+      print(e);
     }
-    Get.back();
-    onScanSwitchPage(state.currentSelectMenu);
-    print(state.currentSelectMenu);
+
+    // RegisterPersonInfoDTO? registerPersonInfo =
+    //     await _patientManager.getRegisterPersonInfoByPhysicalExamNumberAsync(
+    //   physicalExamNumber: code,
+    // );
+    // PatientDTO? patientInfo = PatientDTO();
+    // if (registerPersonInfo != null &&
+    //     registerPersonInfo.physicalExamNumber != null) {
+    //   patientInfo.code = registerPersonInfo.code;
+    //   patientInfo.patientName = registerPersonInfo.name;
+    //   Store.user.currentSelectRegisterPersonInfo = registerPersonInfo;
+    //   Store.user.currentSelectPatientInfo = patientInfo;
+    // }
+    // Get.back();
+    // onScanSwitchPage(state.currentSelectMenu);
+    // print(state.currentSelectMenu);
   }
 
   void onScanSwitchPage(String routeName) {

+ 29 - 15
lib/pages/home/view.dart

@@ -327,21 +327,35 @@ class HomePage extends GetView<HomeController> {
               height: 60,
             ),
           ),
-        if (!kIsWeb && Store.user.kIsVitalStation)
-          IconButton(
-            onPressed: () {
-              Get.to(
-                () => QRViewExample(
-                  onPressed: controller.onScanData,
-                ),
-              );
-            },
-            icon: Icon(
-              FIcons.fis_scan,
-              size: 40,
-              color: Colors.white,
-            ),
-          ),
+        Obx(() {
+          print("currentRouter" + controller.state.currentSelectMenu);
+          String currentRouter = controller.state.currentSelectMenu;
+          if ([
+                "/basicCheck",
+                "/electrocardiogram",
+                "/ncg",
+                "/bloodTest",
+                "/biochemistryTest",
+                "/remedicalRecordView"
+              ].contains(currentRouter) &&
+              !kIsWeb) {
+            return IconButton(
+              onPressed: () {
+                Get.to(
+                  () => QRViewExample(
+                    onPressed: controller.onScanData,
+                  ),
+                );
+              },
+              icon: Icon(
+                FIcons.fis_scan,
+                size: 40,
+                color: Colors.white,
+              ),
+            );
+          }
+          return SizedBox();
+        }),
         HeaderPatientPlace(),
         Padding(
           padding: EdgeInsets.symmetric(horizontal: 8),

+ 0 - 5
lib/store/modules/user.dart

@@ -71,11 +71,6 @@ class UserState extends StateModuleBase {
   /// 医生签名
   String get signature => _userInfo?.signature ?? "";
 
-  bool get kIsVitalStation => [
-        VitalProjectTypeEnum.VitalStation,
-        VitalProjectTypeEnum.VitalCloud,
-      ].contains(_projectType.value);
-
   ///头像
   String get headImageToken => _headImageToken.value;
   set headImageToken(String val) => _headImageToken.value = val;