Browse Source

1、更新jsonrpc

guanxinyi 1 year ago
parent
commit
6b150385cb

+ 8 - 3
lib/components/dialog_select.dart

@@ -45,9 +45,14 @@ class VDialogSelect<T, TValue> extends StatelessWidget {
     return VAlertDialog(
       width: 460,
       title: title,
-      content: Column(
-        mainAxisSize: MainAxisSize.min,
-        children: _buildOptions(context),
+      content: Scrollbar(
+        thumbVisibility: true,
+        child: SingleChildScrollView(
+          child: Column(
+            mainAxisSize: MainAxisSize.min,
+            children: _buildOptions(context),
+          ),
+        ),
       ),
       showCancel: true,
     );

+ 1 - 1
lib/components/select.dart

@@ -27,7 +27,7 @@ class VSelect<T, TValue> extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    CoolDropdownItem<TValue>? defaultItem = null;
+    CoolDropdownItem<TValue>? defaultItem;
     List<CoolDropdownItem<TValue>> items = source.map((e) {
       final itemValue = valueGetter(e);
       bool isSelected = value == itemValue;

+ 6 - 2
lib/pages/check/widgets/configurable_card.dart

@@ -229,6 +229,7 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
 
       children: currentTemplate.asMap().entries.map(
         (e) {
+          /// TODO 这边需要改下
           MaterialColor currentColors = Colors.grey;
           e.value.children?.forEach((element) {
             if (formValue.containsKey(element.key)) {
@@ -424,6 +425,7 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
           formValue[highPressureKey] ?? '',
           formValue[lowPressureKey] ?? ''
         ];
+        formValue['Left'] = '111';
         setState(() {});
       }
     }
@@ -455,12 +457,14 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
   }
 
   Widget _buildRadioScore(FormObject currentFormObject) {
+    print(currentFormObject.toJson());
     List<Option> options = currentFormObject.options ?? [];
-    String currentSelected = formValue[currentFormObject.children?.first] ?? "";
+    String currentSelected =
+        formValue[currentFormObject.childrenKey!.first] ?? "";
 
     void selectRaidoChange(Option e) {
       currentSelected = e.value ?? '';
-      formValue[currentFormObject.key!] = currentSelected;
+      formValue[currentFormObject.childrenKey!.first] = currentSelected;
       setState(() {});
     }
 

+ 144 - 59
lib/pages/check/widgets/exam_configurable/exam_body_temperature.dart

@@ -4,6 +4,7 @@ import 'package:vnote_device_plugin/devices/temp.dart';
 import 'package:vnoteapp/components/alert_dialog.dart';
 import 'package:vnoteapp/pages/check/models/form.dart';
 import 'package:vnoteapp/pages/check/widgets/exam_configurable/exam_card.dart';
+import 'package:vnoteapp/store/store.dart';
 
 class ExamBodyTemperature extends StatefulWidget {
   const ExamBodyTemperature({
@@ -73,7 +74,14 @@ class _ExamBodyTemperatureState extends State<ExamBodyTemperature> {
     // });
 
     final result = await Get.dialog(
-        Temperature(currentFormObject: widget.currentFormObject));
+      Temperature(
+        currentFormObject: widget.currentFormObject,
+        temperature: widget.currentInputValue,
+      ),
+      barrierDismissible: false,
+    );
+    widget.specialInput?.call(result);
+    print(result);
   }
 }
 
@@ -81,8 +89,11 @@ class Temperature extends StatefulWidget {
   const Temperature({
     super.key,
     required this.currentFormObject,
+    this.temperature,
   });
   final FormObject currentFormObject;
+  final String? temperature;
+
   @override
   State<Temperature> createState() => _TemperatureState();
 }
@@ -92,106 +103,180 @@ class _TemperatureState extends State<Temperature> {
     mac: '44:A6:E5:16:62:33',
     model: 'DT-8836',
   );
-  TextEditingController specialInputController = TextEditingController();
-
+  late TextEditingController specialInputController =
+      TextEditingController(text: widget.temperature ?? '00.0');
+  bool connectFailState = false;
+  bool connectSuccessState = false;
+  bool isConnect = false;
   @override
   void initState() {
     connect();
+
     worker.successEvent.addListener(_onSuccess);
+    worker.connectFailEvent.addListener(_onConnectFail);
+    worker.connectSuccessEvent.addListener(_onConnectSuccess);
 
     super.initState();
   }
 
   Future<void> connect() async {
+    connectFailState = false;
+    isConnect = true;
+    connectSuccessState = false;
+    setState(() {});
     await worker.connect();
   }
 
   Future<void> disconnect() async {
+    worker.connectFailEvent.removeListener(_onConnectFail);
+    worker.connectSuccessEvent.removeListener(_onConnectSuccess);
     await worker.disconnect();
   }
 
   @override
   void dispose() {
-    disconnect();
     super.dispose();
   }
 
   void _onSuccess(_, double e) {
     setState(() {
       specialInputController.text = e.toString();
+      connectFailState = false;
+      connectSuccessState = false;
+      isConnect = false;
+      disconnect();
     });
   }
 
+  void _onConnectFail(sender, e) {
+    print('连接设备失败');
+    connectFailState = true;
+    connectSuccessState = false;
+    isConnect = false;
+    setState(() {});
+  }
+
+  void _onConnectSuccess(sender, e) {
+    connectSuccessState = true;
+    connectFailState = false;
+    isConnect = false;
+    setState(() {});
+  }
+
   @override
   Widget build(BuildContext context) {
     return VAlertDialog(
       title: widget.currentFormObject.label ?? '',
       width: 600,
       contentPadding: const EdgeInsets.symmetric(vertical: 12, horizontal: 24),
-      content: Row(
+      content: Column(
+        mainAxisSize: MainAxisSize.min,
+        crossAxisAlignment: CrossAxisAlignment.start,
         children: [
-          Container(
-            width: 400,
-            padding: const EdgeInsets.only(left: 15),
-            child: TextFormField(
-              keyboardType: TextInputType.number,
-              style: const TextStyle(
-                fontSize: 100, // 设置字体大小
-              ),
-              showCursor: false,
-              controller: specialInputController,
-              decoration: const InputDecoration(
-                labelStyle: TextStyle(
-                  fontSize: 100, // 设置标签的字体大小
+          connectFailState
+              ? const Text(
+                  '设备连接失败',
+                  style: TextStyle(
+                    color: Colors.red,
+                    fontSize: 25,
+                  ),
+                  textAlign: TextAlign.left,
+                )
+              : const SizedBox(),
+          connectSuccessState
+              ? const Text(
+                  '设备连接成功',
+                  style: TextStyle(
+                    color: Colors.green,
+                    fontSize: 25,
+                  ),
+                  textAlign: TextAlign.left,
+                )
+              : const SizedBox(),
+          Row(
+            children: [
+              Container(
+                width: 350,
+                padding: const EdgeInsets.only(left: 15),
+                child: TextFormField(
+                  keyboardType: TextInputType.number,
+                  style: const TextStyle(
+                    fontSize: 100, // 设置字体大小
+                  ),
+                  showCursor: false,
+                  controller: specialInputController,
+                  decoration: const InputDecoration(
+                    labelStyle: TextStyle(
+                      fontSize: 100, // 设置标签的字体大小
+                    ),
+                  ),
                 ),
               ),
-            ),
-          ),
-          specialInputController.text == ''
-              ? const Expanded(
-                  child: Row(children: [
-                    Expanded(
-                      child: Text(
-                        '测量中',
-                        style: TextStyle(
-                          fontSize: 40,
-                          color: Colors.blue,
+              isConnect
+                  ? const Expanded(
+                      child: Row(children: [
+                        Expanded(
+                          child: Text(
+                            '设备连接中',
+                            style: TextStyle(
+                              fontSize: 40,
+                              color: Colors.blue,
+                            ),
+                          ),
                         ),
-                      ),
-                    ),
-                    CircularProgressIndicator(
-                      valueColor: AlwaysStoppedAnimation(
-                        Colors.blue,
-                      ),
-                    ),
-                    SizedBox(
-                      width: 20,
-                    ),
-                  ]),
-                )
-              : TextButton(
-                  onPressed: () {
-                    /// TODO
-                  },
-                  child: Container(
-                    padding: const EdgeInsets.symmetric(horizontal: 30),
-                    decoration: const BoxDecoration(
-                      borderRadius: BorderRadius.all(
-                        Radius.circular(
-                          30,
+                        CircularProgressIndicator(
+                          valueColor: AlwaysStoppedAnimation(
+                            Colors.blue,
+                          ),
+                        ),
+                        SizedBox(
+                          width: 20,
+                        ),
+                      ]),
+                    )
+                  : Expanded(
+                      child: TextButton(
+                        onPressed: () async {
+                          /// TODO
+                          await connect();
+                          worker.connectFailEvent.addListener(_onConnectFail);
+                          worker.connectSuccessEvent
+                              .addListener(_onConnectSuccess);
+
+                          /// TODO 后面需要改,这边暂时演示用
+                          Future.delayed(const Duration(milliseconds: 8000),
+                              () {
+                            if (!connectSuccessState) {
+                              connectFailState = true;
+                              Store.app.busy = false;
+                            }
+                          });
+                        },
+                        child: Container(
+                          padding: const EdgeInsets.symmetric(horizontal: 30),
+                          decoration: const BoxDecoration(
+                            borderRadius: BorderRadius.all(
+                              Radius.circular(
+                                30,
+                              ),
+                            ),
+                            color: Colors.blue,
+                          ),
+                          child: const Text(
+                            '测量',
+                            style: TextStyle(fontSize: 40, color: Colors.white),
+                          ),
                         ),
                       ),
-                      color: Colors.blue,
                     ),
-                    child: const Text(
-                      '测量',
-                      style: TextStyle(fontSize: 40, color: Colors.white),
-                    ),
-                  ),
-                ),
+            ],
+          ),
         ],
       ),
-      showCancel: false,
+      showCancel: true,
+      onConfirm: () {
+        Get.back(result: specialInputController.text);
+      },
     );
   }
 }

+ 21 - 14
lib/pages/check/widgets/exam_configurable/exam_input.dart

@@ -1,3 +1,12 @@
+/*
+ * @Descripttion: 
+ * @version: 
+ * @Author: guanxiaoxin
+ * @Date: 2023-10-07 14:24:20
+ * @LastEditors: guanxiaoxin
+ * @LastEditTime: 2023-10-09 13:06:06
+ * @FilePath: \VNoteApp\lib\pages\check\widgets\exam_configurable\exam_input.dart
+ */
 import 'package:flutter/material.dart';
 import 'package:vnoteapp/pages/check/models/form.dart';
 import 'package:vnoteapp/pages/check/widgets/exam_configurable/exam_card.dart';
@@ -34,21 +43,19 @@ class _ExamInputState extends State<ExamInput> {
           left: 40,
         ),
         constraints: const BoxConstraints(minHeight: 150),
-        child: Expanded(
-          child: RichText(
-            text: TextSpan(
-              text: widget.currentInputValue,
-              style: const TextStyle(
-                fontSize: 80,
-                color: Colors.black,
-              ),
-              children: [
-                TextSpan(
-                  text: widget.currentFormObject.append ?? '',
-                  style: const TextStyle(fontSize: 25),
-                )
-              ],
+        child: RichText(
+          text: TextSpan(
+            text: widget.currentInputValue,
+            style: const TextStyle(
+              fontSize: 80,
+              color: Colors.black,
             ),
+            children: [
+              TextSpan(
+                text: widget.currentFormObject.append ?? '',
+                style: const TextStyle(fontSize: 25),
+              )
+            ],
           ),
         ),
       ),

+ 1 - 5
lib/pages/check/widgets/exam_configurable/exam_number_input.dart

@@ -30,11 +30,7 @@ class _ExamNumberInputState extends State<ExamNumberInput> {
     return ExamCard(
       title: widget.currentFormObject.label ?? '',
       clickCard: () {
-        if (widget.currentFormObject.buttonName?.isNotEmpty ?? false) {
-          _buildSpecialInput(widget.currentFormObject);
-        } else {
-          widget.commonInput?.call();
-        }
+        widget.commonInput?.call();
       },
       content: Container(
         alignment: Alignment.bottomRight,

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

@@ -1,13 +1,20 @@
+/*
+ * @Descripttion: 
+ * @version: 
+ * @Author: guanxiaoxin
+ * @Date: 2023-09-14 16:37:47
+ * @LastEditors: guanxiaoxin
+ * @LastEditTime: 2023-10-09 09:17:52
+ * @FilePath: \VNoteApp\lib\pages\home\controller.dart
+ */
 import 'dart:async';
 
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 import 'package:vnoteapp/architecture/defines.dart';
-import 'package:vnoteapp/architecture/utils/prompt_box.dart';
 import 'package:vnoteapp/managers/interfaces/account.dart';
 import 'package:vnoteapp/pages/controllers/home_nav_mixin.dart';
 import 'package:vnoteapp/pages/home/models/menu.dart';
-import 'package:vnoteapp/store/store.dart';
 
 import 'state.dart';
 
@@ -78,21 +85,21 @@ class HomeController extends FControllerBase with HomeNavMixin {
         routeName: "/settings",
         iconData: Icons.settings,
       ),
-      HomeMenuItem(
-        title: "虚拟菜单01",
-        routeName: "/mock01",
-        iconData: Icons.flood,
-      ),
-      HomeMenuItem(
-        title: "虚拟菜单02",
-        routeName: "/mock02",
-        iconData: Icons.flag,
-      ),
-      HomeMenuItem(
-        title: "虚拟菜单03",
-        routeName: "/mock03",
-        iconData: Icons.run_circle,
-      ),
+      // HomeMenuItem(
+      //   title: "虚拟菜单01",
+      //   routeName: "/mock01",
+      //   iconData: Icons.flood,
+      // ),
+      // HomeMenuItem(
+      //   title: "虚拟菜单02",
+      //   routeName: "/mock02",
+      //   iconData: Icons.flag,
+      // ),
+      // HomeMenuItem(
+      //   title: "虚拟菜单03",
+      //   routeName: "/mock03",
+      //   iconData: Icons.run_circle,
+      // ),
     ];
   }
 }

+ 2 - 2
pubspec.yaml

@@ -49,7 +49,7 @@ dependencies:
   vnote_device_plugin:
     git:
       url: http://git.ius.plus:88/Project-VNOTE/FlutterDevicePlugin.git
-      ref: 2f56e5
+      ref: 230cd0a7
     # path: ..\FlutterDevicePlugin
   particles_flutter: 0.1.4
   cool_dropdown: 2.1.0
@@ -71,7 +71,7 @@ dependencies_overrides:
   fis_jsonrpc:
     git:
       url: http://git.ius.plus:88/Project-VNOTE/FlutterJsonRPC.git
-      ref: "a1deb41"
+      ref: "a123f8a"
   # fis_ui:
   #   git:
   #     url: http://git.ius.plus:88/Project-Wing/fis_lib_ui.git