Browse Source

1、ui细节优化

guanxinyi 1 year ago
parent
commit
8f593ceefa

+ 1 - 1
lib/managers/diagnosis.dart

@@ -6,7 +6,7 @@ import 'package:vnoteapp/store/store.dart';
 class DiagnosisManager implements IDiagnosisManager {
   DiagnosisManager();
 
-  /// 创建诊疗展示
+  /// 创建健康检测
   @override
   Future<String> createDiagnosisAsync(createDiagnosis) async {
     createDiagnosis.token = Store.user.token;

+ 1 - 1
lib/managers/interfaces/diagnosis.dart

@@ -3,7 +3,7 @@ import 'package:fis_jsonrpc/rpc.dart';
 import 'base.dart';
 
 abstract class IDiagnosisManager implements IManager {
-  /// 创建诊疗展示
+  /// 创建健康检测
   Future<String> createDiagnosisAsync(CreateDiagnosisRequest createDiagnosis);
 
   ///获取诊疗记录

+ 0 - 10
lib/pages/check/examination/controller.dart

@@ -53,19 +53,9 @@ class ExaminationController extends GetxController {
     }
   }
 
-  // @override
-  // void onInit() {
-  //   super.onInit();
-  // }
-
   @override
   void onReady() {
     _initData();
     super.onReady();
   }
-
-  // @override
-  // void onClose() {
-  //   super.onClose();
-  // }
 }

+ 4 - 1
lib/pages/check/widgets/configurable_card.dart

@@ -23,6 +23,7 @@ import 'dart:math' as math;
 
 import 'package:vnoteapp/pages/check/widgets/exam_configurable/exam_radio.dart';
 import 'package:vnoteapp/pages/check/widgets/exam_configurable/exam_radio_score.dart';
+import 'package:vnoteapp/pages/check/widgets/device_controller.dart';
 
 const double _width = 170;
 const double _height = 38;
@@ -67,6 +68,8 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
   Map<String, dynamic> deviceCached = {};
   @override
   void initState() {
+    Get.put(DeviceController());
+
     super.initState();
     initTemplate();
   }
@@ -85,7 +88,7 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
     // }
   }
 
-  /// 读取诊疗展示的缓存
+  /// 读取健康检测的缓存
   Future<String?> readCachedRecord(String currentDevice) async {
     if (widget.patientCode.isNull) {
       return null;

+ 12 - 0
lib/pages/check/widgets/device_controller.dart

@@ -0,0 +1,12 @@
+import 'package:get/get.dart';
+import 'package:vnoteapp/managers/interfaces/device.dart';
+import 'package:vnoteapp/managers/interfaces/models/device.dart';
+
+class DeviceController extends GetxController {
+  final _deviceManager = Get.find<IDeviceManager>();
+
+  Future<DeviceModel?> getDevice(String type) async {
+    List<DeviceModel> devices = await _deviceManager.getDeviceList();
+    return devices.firstWhereOrNull((element) => element.type == type);
+  }
+}

+ 33 - 6
lib/pages/home/controller.dart

@@ -24,6 +24,12 @@ class HomeController extends FControllerBase with HomeNavMixin {
     }
   }
 
+  @override
+  void onInit() {
+    initMenus();
+    super.onInit();
+  }
+
   /// 切换活动菜单
   void switchActiveMenu(HomeMenuItem data) {
     CommonUtil.throttle(() {
@@ -55,6 +61,27 @@ class HomeController extends FControllerBase with HomeNavMixin {
   }
 
   void initMenus() {
+    state.menuItems = [
+      HomeMenuItem(
+        title: "主页",
+        routeName: "/dashboard",
+        iconData: Icons.home_outlined,
+        isSelected: true,
+      ),
+      HomeMenuItem(
+        title: "健康检测",
+        routeName: "/medical",
+        iconWidget: _buildImgIcon('diagnosisDisplay.png'),
+      ),
+      HomeMenuItem(
+        title: "设置中心",
+        routeName: "/settings",
+        iconData: Icons.settings,
+      ),
+    ];
+  }
+
+  void updateMenus() {
     state.menuItems = [
       HomeMenuItem(
         title: "主页",
@@ -67,6 +94,11 @@ class HomeController extends FControllerBase with HomeNavMixin {
         routeName: "/patient/detail",
         iconWidget: _buildImgIcon('healthRecord.png'),
       ),
+      HomeMenuItem(
+        title: "医生签约",
+        routeName: "/contract/package_list",
+        iconWidget: _buildImgIcon('doctorSigning.png'),
+      ),
       HomeMenuItem(
         title: "健康体检",
         routeName: "/check/form",
@@ -78,12 +110,7 @@ class HomeController extends FControllerBase with HomeNavMixin {
         iconWidget: _buildImgIcon('populationFollowUp.png'),
       ),
       HomeMenuItem(
-        title: "医生签约",
-        routeName: "/contract/package_list",
-        iconWidget: _buildImgIcon('doctorSigning.png'),
-      ),
-      HomeMenuItem(
-        title: "诊疗展示",
+        title: "健康检测",
         routeName: "/medical",
         iconWidget: _buildImgIcon('diagnosisDisplay.png'),
       ),

+ 1 - 14
lib/pages/home/state.dart

@@ -1,24 +1,11 @@
 import 'dart:collection';
-import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 import 'package:vnoteapp/store/store.dart';
 
 import 'models/menu.dart';
 
 class HomeState {
-  final RxList<HomeMenuItem> _menuItems = RxList([
-    HomeMenuItem(
-      title: "主页",
-      routeName: "/dashboard",
-      iconData: Icons.home_outlined,
-      isSelected: true,
-    ),
-    HomeMenuItem(
-      title: "设置中心",
-      routeName: "/settings",
-      iconData: Icons.settings,
-    ),
-  ]);
+  final RxList<HomeMenuItem> _menuItems = RxList.empty();
 
   /// 版本号
   String get version => "1.0.0.100";

+ 30 - 5
lib/pages/medical/controller.dart

@@ -2,7 +2,9 @@ import 'dart:convert';
 
 import 'package:fis_jsonrpc/rpc.dart';
 import 'package:get/get.dart';
+import 'package:uuid/uuid.dart';
 import 'package:vnoteapp/architecture/defines.dart';
+import 'package:vnoteapp/architecture/storage/text_storage.dart';
 import 'package:vnoteapp/architecture/utils/prompt_box.dart';
 import 'package:vnoteapp/managers/interfaces/cachedRecord.dart';
 import 'package:vnoteapp/managers/interfaces/device.dart';
@@ -19,7 +21,8 @@ class MedicalController extends FControllerBase {
   final _cachedRecordManager = Get.find<ICachedRecordManager>();
   final _deviceManager = Get.find<IDeviceManager>();
   String patientCode = '';
-  String appDataId = '1008611';
+
+  late String appDataId;
   List<MedicalItem> medicalMenuList = [
     MedicalItem(key: 'Temp', diagnosticItem: '体温'),
     MedicalItem(key: 'GLU', diagnosticItem: '血糖'),
@@ -30,12 +33,15 @@ class MedicalController extends FControllerBase {
   Map<String, dynamic> diagnosisDataValue = {};
 
   @override
-  Future<void> onLoad() {
-    // final p = Get.parameters;
-    // patientCode = p["patientCode"]!;
+  Future<void> onLoad() async {
     patientCode = Store.user.currentSelectPatientInfo?.code ?? '';
-    // changeDevice(true);
     Get.put(MedicalController());
+    var cachedAppDataId = await readCachedAppDataId();
+    if (cachedAppDataId != null) {
+      appDataId = cachedAppDataId;
+    } else {
+      await saveCachedAppDataId();
+    }
     return super.onLoad();
   }
 
@@ -56,6 +62,25 @@ class MedicalController extends FControllerBase {
     diagnosisDataValue[state.currentTab] = jsonDecode(value);
   }
 
+  Future<bool?> saveCachedAppDataId() async {
+    appDataId = const Uuid().v4().replaceAll('-', '');
+    print(appDataId);
+    print('🌰');
+    TextStorage cachedRecord = TextStorage(
+      fileName: 'appDataId',
+      directory: "patient/$patientCode",
+    );
+    return cachedRecord.save(appDataId);
+  }
+
+  Future<String?> readCachedAppDataId() async {
+    TextStorage cachedRecord = TextStorage(
+      fileName: 'appDataId',
+      directory: "patient/$patientCode",
+    );
+    return cachedRecord.read();
+  }
+
   Future<void> saveCachedRecord() async {
     await _cachedRecordManager.saveCachedRecord(
       state.currentTab,

+ 1 - 1
lib/pages/medical/state.dart

@@ -16,7 +16,7 @@ class MedicalState {
   String get currentTab => _currentTab.value;
   set currentTab(String val) => _currentTab(val);
 
-  /// 诊疗展示列表
+  /// 健康检测列表
   set medicalMenuList(List<MedicalItem> value) => _medicalMenuList(value);
   List<MedicalItem> get medicalMenuList => _medicalMenuList;
 

+ 95 - 64
lib/pages/medical/view.dart

@@ -7,6 +7,7 @@ import 'package:vnoteapp/pages/medical/widgets/blood_sugar.dart';
 import 'package:vnoteapp/pages/medical/widgets/body_temperature.dart';
 import 'package:vnoteapp/pages/medical/widgets/body_bmi.dart';
 import 'package:vnoteapp/pages/medical/widgets/bool_oxygen.dart';
+import 'package:vnoteapp/store/store.dart';
 
 class MedicalPage extends GetView<MedicalController> {
   const MedicalPage({super.key});
@@ -17,85 +18,115 @@ class MedicalPage extends GetView<MedicalController> {
       backgroundColor: Colors.white,
       // appBar: VAppBar(
       //   titleWidget: const Text(
-      //     "诊疗展示",
+      //     "健康检测",
       //     style: TextStyle(fontSize: 24),
       //   ),
       // ),
-      body: Row(
+      body: Stack(
         children: [
-          Column(
-            mainAxisAlignment: MainAxisAlignment.center,
-            children: controller.state.medicalMenuList
-                .map(
-                  (e) => Material(
-                    borderRadius: const BorderRadius.only(
-                      topRight: Radius.circular(30),
-                      bottomRight: Radius.circular(30),
-                    ),
-                    child: Ink(
-                      decoration: const BoxDecoration(
-                        borderRadius: BorderRadius.only(
+          Row(
+            children: [
+              Column(
+                mainAxisAlignment: MainAxisAlignment.center,
+                children: controller.state.medicalMenuList
+                    .map(
+                      (e) => Material(
+                        borderRadius: const BorderRadius.only(
                           topRight: Radius.circular(30),
                           bottomRight: Radius.circular(30),
                         ),
-                      ),
-                      child: InkWell(
-                          borderRadius: const BorderRadius.only(
-                            topRight: Radius.circular(30),
-                            bottomRight: Radius.circular(30),
-                          ),
-                          onTap: () {
-                            controller.state.currentTab = e.key;
-                          },
-                          child: Obx(
-                            () => _SideBar(
-                              title: e.diagnosticItem,
-                              isActive: controller.state.currentTab == e.key,
+                        child: Ink(
+                          decoration: const BoxDecoration(
+                            borderRadius: BorderRadius.only(
+                              topRight: Radius.circular(30),
+                              bottomRight: Radius.circular(30),
                             ),
-                          )),
-                    ),
-                  ),
-                )
-                .toList(),
-          ),
-          Container(
-            alignment: Alignment.topCenter,
-            margin: const EdgeInsets.all(16).copyWith(top: 0),
-            child: Image.asset(
-              'assets/images/exam/normalMeasurementChart.png',
-              height: double.infinity,
-              fit: BoxFit.fitWidth, // 设置图像的适应方式
-            ),
-          ),
-          Expanded(
-            child: Stack(
-              children: [
-                Container(
-                  padding: const EdgeInsets.all(16),
-                  child: Column(
-                    children: [
-                      _buildContent(),
-                    ],
-                  ),
+                          ),
+                          child: InkWell(
+                              borderRadius: const BorderRadius.only(
+                                topRight: Radius.circular(30),
+                                bottomRight: Radius.circular(30),
+                              ),
+                              onTap: () {
+                                controller.state.currentTab = e.key;
+                              },
+                              child: Obx(
+                                () => _SideBar(
+                                  title: e.diagnosticItem,
+                                  isActive:
+                                      controller.state.currentTab == e.key,
+                                ),
+                              )),
+                        ),
+                      ),
+                    )
+                    .toList(),
+              ),
+              Container(
+                alignment: Alignment.topCenter,
+                margin: const EdgeInsets.all(16).copyWith(top: 0),
+                child: Image.asset(
+                  'assets/images/exam/normalMeasurementChart.png',
+                  height: double.infinity,
+                  fit: BoxFit.fitWidth, // 设置图像的适应方式
                 ),
-                Positioned(
-                    bottom: 100,
-                    right: 16,
-                    child: VButton(
-                      onTap: controller.createDiagnosis,
-                      child: const Text(
-                        '保存',
-                        style: TextStyle(fontSize: 26),
+              ),
+              Expanded(
+                child: Stack(
+                  children: [
+                    Container(
+                      padding: const EdgeInsets.all(16),
+                      child: Column(
+                        children: [
+                          _buildContent(),
+                        ],
                       ),
-                    ))
-              ],
-            ),
-          )
+                    ),
+                    _buildSaveButton(),
+                  ],
+                ),
+              )
+            ],
+          ),
+          _buildGenerateReport(),
         ],
       ),
     );
   }
 
+  Widget _buildGenerateReport() {
+    return Positioned(
+      bottom: 100,
+      left: 16,
+      child: VButton(
+        onTap: controller.saveCachedAppDataId,
+        child: const Text(
+          '生成报告',
+          style: TextStyle(fontSize: 26),
+        ),
+      ),
+    );
+  }
+
+  Widget _buildSaveButton() {
+    return Obx(() {
+      if (Store.user.currentSelectPatientInfo == null) {
+        return const SizedBox();
+      }
+      return Positioned(
+        bottom: 100,
+        right: 16,
+        child: VButton(
+          onTap: controller.createDiagnosis,
+          child: const Text(
+            '保存',
+            style: TextStyle(fontSize: 26),
+          ),
+        ),
+      );
+    });
+  }
+
   Widget _buildContent() {
     return Obx(() {
       switch (controller.state.currentTab) {

+ 1 - 1
lib/pages/patient/detail/controller.dart

@@ -60,7 +60,7 @@ class PatientDetailController extends FControllerBase with HomeNavMixin {
     //
   }
 
-  /// 前往诊疗展示
+  /// 前往健康检测
   void gotoExam() {
     //
     Get.toNamed(

+ 2 - 2
lib/pages/patient/detail/widgets/functions_panel.dart

@@ -71,7 +71,7 @@ class FunctionsPanel extends GetView<PatientDetailController> {
           //   onTap: controller.gotoContract,
           // ),
           // FunctionButton(
-          //   label: "诊疗展示",
+          //   label: "健康检测",
           //   icon: _buildImgIcon("诊疗.png"),
           //   onTap: controller.gotoExam,
           // ),
@@ -86,7 +86,7 @@ class FunctionsPanel extends GetView<PatientDetailController> {
             onTap: controller.gotoContractRecords,
           ),
           // FunctionButton(
-          //   label: "诊疗展示",
+          //   label: "健康检测",
           //   icon: _buildImgIcon("诊疗.png"),
           //   onTap: controller.gotoExam,
           // ),

+ 1 - 1
lib/pages/patient/list/controller.dart

@@ -20,7 +20,7 @@ class PatientListController extends FControllerBase {
     PatientDTO? patientInfoDto = await _patientManager.getDetail(code);
     // String patientInfo = jsonEncode(patientInfoDto);
     Store.user.currentSelectPatientInfo = patientInfoDto;
-    _homeController.initMenus();
+    _homeController.updateMenus();
     Get.back();
     _homeController.switchNavByName('/dashboard');
   }