Browse Source

修改待扦样打印灰屏、用药数据校验。发布22版。

liujq 5 months ago
parent
commit
d72d8155a4

+ 31 - 2
lib/page/sample_task/reap_sample_detail/reap_sample_medicine_detail_page.dart

@@ -1,5 +1,6 @@
1 1
 import 'package:flutter/material.dart';
2 2
 import 'package:lszlgl/base/base_lifecycle_state.dart';
3
+import 'package:lszlgl/config/colors.dart';
3 4
 import 'package:lszlgl/widget/card_item.dart';
4 5
 
5 6
 import '../../../model/rsp/sample_task_rsp.dart';
@@ -78,7 +79,29 @@ class _ReapSampleMedicineDetailPageState extends BaseLifecycleState<ReapSampleMe
78 79
 
79 80
   /// 校验数据
80 81
   bool verifyData() {
81
-    return true;
82
+    if (data?.codeUseMedicineList == null){
83
+      return true;
84
+    } else {
85
+      for(UseMedicineItem item in data?.codeUseMedicineList ?? <UseMedicineItem>[]){
86
+        if((item.synypz ?? '').isEmpty){
87
+          MyNavigator.showToast('农药品种不能为空');
88
+          return false;
89
+        }
90
+        if(item.synysl == null){
91
+          MyNavigator.showToast('农药数量不能为空');
92
+          return false;
93
+        }
94
+        if((item.sysj ?? '').isEmpty){
95
+          MyNavigator.showToast('施药时间不能为空');
96
+          return false;
97
+        }
98
+        if((item.syff ?? '').isEmpty){
99
+          MyNavigator.showToast('施药方法不能为空');
100
+          return false;
101
+        }
102
+      }
103
+      return true;
104
+    }
82 105
   }
83 106
 
84 107
   @override
@@ -104,7 +127,13 @@ class _ReapSampleMedicineDetailPageState extends BaseLifecycleState<ReapSampleMe
104 127
           data?.codeUseMedicineList?.length ?? 0,
105 128
           (index) => buildItem(index, data!.codeUseMedicineList![index]),
106 129
         ).toList(),
130
+        if((data?.codeUseMedicineList?.isNotEmpty ?? false) && !isDetail )
131
+          const Padding(
132
+            padding: EdgeInsets.only(top: 10),
133
+            child:  Text('长按上方可删除',style: TextStyle(fontSize: 12,color: MyColor.c_666666)),
134
+          ),
107 135
         buildAdd(),
136
+
108 137
       ],
109 138
     );
110 139
   }
@@ -146,7 +175,7 @@ class _ReapSampleMedicineDetailPageState extends BaseLifecycleState<ReapSampleMe
146 175
                     ),
147 176
                     CardWidgets.buildEdit(
148 177
                       detail,
149
-                      '使用农药的数量(公斤或毫升/每亩地)',
178
+                      '使用农药的数量(毫升/每亩地)',
150 179
                       item.synysl?.toString(),
151 180
                       backgroundColor: null,
152 181
                       inputType: const TextInputType.numberWithOptions(decimal: true),

+ 21 - 1
lib/utils/location_utils.dart

@@ -1,3 +1,5 @@
1
+import 'dart:async';
2
+
1 3
 import 'package:amap_flutter_location/amap_flutter_location.dart';
2 4
 import 'package:amap_flutter_location/amap_location_option.dart';
3 5
 import 'package:app_settings/app_settings.dart';
@@ -63,6 +65,7 @@ class LocationUtils {
63 65
   ///销毁定位
64 66
   static void destroy() {
65 67
     location.destroy();
68
+    cancelLocationListener();
66 69
     _location = null;
67 70
   }
68 71
 
@@ -111,8 +114,25 @@ class LocationUtils {
111 114
   /// `errorCode`: 错误码,当定位失败时才会返回对应的错误码, 具体错误请参考:https://lbs.amap.com/api/android-location-sdk/guide/utilities/errorcode
112 115
   ///
113 116
   /// `errorInfo`: 错误信息, 当定位失败时才会返回
117
+  // static Stream<Map<String, Object>> onLocationChanged() {
118
+  //   return location.onLocationChanged().asBroadcastStream();
119
+  // }
114 120
   static Stream<Map<String, Object>> onLocationChanged() {
115
-    return location.onLocationChanged();
121
+    if (_locationChange == null) {
122
+      _locationChange = StreamController.broadcast();
123
+      _locationListener = location.onLocationChanged().listen((event) => _locationChange?.add(event));
124
+    }
125
+    return _locationChange!.stream;
126
+  }
127
+
128
+  static StreamController<Map<String, Object>>? _locationChange;
129
+  static StreamSubscription<Map<String, Object>>? _locationListener;
130
+
131
+  static void cancelLocationListener() {
132
+    _locationListener?.cancel();
133
+    _locationListener = null;
134
+    _locationChange?.close();
135
+    _locationChange = null;
116 136
   }
117 137
 
118 138
   /// 检查定位是否可用

+ 1 - 1
pubspec.yaml

@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
16 16
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
17 17
 # In Windows, build-name is used as the major, minor, and patch parts
18 18
 # of the product and file versions while build-number is used as the build suffix.
19
-version: 0.0.21+21
19
+version: 0.0.22+22
20 20
 
21 21
 environment:
22 22
   sdk: '>=3.1.5 <4.0.0'