Browse Source

修复reportInfo中没有存入输入值

loki.wu 2 years ago
parent
commit
8ff1e869f7

+ 0 - 1
lib/converts/color_convert.dart

@@ -1,5 +1,4 @@
 import 'package:fis_lib_report/report/rt_color.dart';
-import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 
 class ColorConvert {

+ 2 - 2
lib/pages/components/input_imageList.dart

@@ -149,10 +149,10 @@ class _RInputImageListState extends State<RInputImageList> {
         setState(() {
           if (_images.contains(e)) {
             _images.remove(e);
-            inputImageListInfo!.selectedImages.add(e);
+            inputImageListInfo!.selectedImages.remove(e);
           } else {
             _images.add(e);
-            inputImageListInfo!.selectedImages.remove(e);
+            inputImageListInfo!.selectedImages.add(e);
           }
           _child = _getChild();
         });

+ 6 - 1
lib/pages/components/input_text.dart

@@ -45,11 +45,16 @@ class _RInputTextState extends State<RInputText> {
   @override
   Widget build(BuildContext context) {
     final inputTextInfo = ReportInfo.instance.getElementInfo(widget.inputText);
-    _inputTextInfo = inputTextInfo as InputTextInfo;
+    if (_inputTextInfo != inputTextInfo) {
+      _inputTextInfo = inputTextInfo as InputTextInfo;
+    }
     if (!_inputTextInfo!.isListening!) {
       _initDatas();
       _inputTextInfo!.isListening = true;
     }
+    if (_inputTextInfo!.text != _controller.text) {
+      _controller.text = _inputTextInfo!.text!;
+    }
     return Container(
       //constraints: BoxConstraints(minWidth: _lineWidth!, maxWidth: 480),
       width: _lineWidth,

+ 1 - 1
lib/pages/components/multi_selected.dart

@@ -160,7 +160,7 @@ class _RRMultiSelectedState extends State<RMultiSelected> {
   void _initDatas() {
     final multiSelected = widget.multiSelected;
     final selectInfo = ReportInfo.instance.getElementInfo(multiSelected);
-    if (selectInfo != null) {
+    if (selectInfo != null && _mulitiSelectedInfo != selectInfo) {
       _mulitiSelectedInfo = selectInfo as MulitiSelectedInfo;
     }
     if (multiSelected.items!.isNotEmpty) {

+ 8 - 5
lib/pages/components/single_select.dart

@@ -31,7 +31,7 @@ class _RSingleSelectState extends State<RSingleSelected> {
   Widget build(BuildContext context) {
     singleSelected = widget.singleSelected;
     final selectInfo = ReportInfo.instance.getElementInfo(singleSelected);
-    if (selectInfo != null) {
+    if (selectInfo != null && _singleSelectedInfo != selectInfo) {
       _singleSelectedInfo = selectInfo as SingleSelectedInfo;
     }
     if (singleSelected.items!.isNotEmpty) {
@@ -46,6 +46,10 @@ class _RSingleSelectState extends State<RSingleSelected> {
       borderRadius: BorderRadius.circular(0),
       color: Colors.white,
     );
+    if (_singleSelectedInfo!.selectedItem.isNotEmpty &&
+        _singleSelectedInfo!.selectedItem != _value) {
+      _value = _singleSelectedInfo!.selectedItem;
+    }
     return SizedBox(
       height: 24,
       child: DropdownButtonHideUnderline(
@@ -77,12 +81,11 @@ class _RSingleSelectState extends State<RSingleSelected> {
           items: buildItems(),
           onChanged: (v) {
             setState(() {
+              if (_singleSelectedInfo != null) {
+                _singleSelectedInfo!.selectedItem = v!;
+              }
               _value = v!;
             });
-            if (_singleSelectedInfo != null) {
-              _singleSelectedInfo!.selectedItem = v;
-              ReportInfo.instance;
-            }
           },
         ),
       ),

+ 1 - 0
lib/report_info/input_text_info.dart

@@ -21,6 +21,7 @@ class InputTextInfo extends TextElementInfo {
     final map = <String, dynamic>{};
     map.addAll(super.toJson());
     map['IsReadOnly'] = isReadOnly;
+    map['Text'] = text;
     return map;
   }
 }

+ 1 - 1
lib/report_info/single_selected_info.dart

@@ -9,7 +9,7 @@ class SingleSelectedInfo extends TextElementInfo {
 
   List<String>? items = [];
 
-  String? selectedItem;
+  String selectedItem = '';
 
   SingleSelectedInfo.fromElement(SingleSelected element)
       : super.fromElement(element) {