Explorar o código

增加收获扦样任务单页-品种信息校验数据逻辑;

maqiang hai 7 meses
pai
achega
e09759759a

+ 9 - 8
lib/page/sample_task/reap_sample_detail/reap_sample_basic_detail_page.dart

@@ -79,7 +79,6 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
79 79
 
80 80
   /// 获取土壤信息列表
81 81
   Future<void> getTrxxList() async {
82
-    MyNavigator.showLoading();
83 82
     try {
84 83
       var rsp = await MyApi.get().trxxList();
85 84
       List<CardMenuData> list = [];
@@ -391,22 +390,22 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
391 390
   /// 校验数据
392 391
   bool verifyData() {
393 392
     // 扦样/陪同人员
394
-    if ((data?.dgryName ?? '').isNotEmpty) {
393
+    if ((data?.dgryName ?? '').isEmpty) {
395 394
       MyNavigator.showToast('扦样/陪同人员不能为空');
396 395
       return false;
397 396
     }
398 397
     // 乡镇
399
-    if ((data?.xiangXzqhName ?? '').isNotEmpty) {
398
+    if ((data?.xiangXzqhName ?? '').isEmpty) {
400 399
       MyNavigator.showToast('乡镇不能为空');
401 400
       return false;
402 401
     }
403 402
     // 村
404
-    if ((data?.cunXzqhName ?? '').isNotEmpty) {
403
+    if ((data?.cunXzqhName ?? '').isEmpty) {
405 404
       MyNavigator.showToast('村不能为空');
406 405
       return false;
407 406
     }
408 407
     // 扦样地点经纬度
409
-    if ((data?.qyddjwd ?? '').isNotEmpty) {
408
+    if ((data?.qyddjwd ?? '').isEmpty) {
410 409
       MyNavigator.showToast('扦样地点经纬度不能为空');
411 410
       return false;
412 411
     }
@@ -431,10 +430,7 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
431 430
     data = widget.data;
432 431
     isDetail = widget.detail;
433 432
     widget.ctrl.verifyData = verifyData;
434
-  }
435 433
 
436
-  @override
437
-  void onFirstShow(Duration timeStamp) {
438 434
     // 土壤信息
439 435
     getTrxxList();
440 436
 
@@ -456,6 +452,11 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
456 452
   }
457 453
 
458 454
   @override
455
+  void onFirstShow(Duration timeStamp) {
456
+    MyNavigator.showLoading();
457
+  }
458
+
459
+  @override
459 460
   void onDestroy() {
460 461
     LocationUtils.stopLocation();
461 462
     LocationUtils.destroy();

+ 2 - 3
lib/page/sample_task/reap_sample_detail/reap_sample_task_page.dart

@@ -96,7 +96,7 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
96 96
         return;
97 97
       }
98 98
     }
99
-    SampleTaskItem req = (pageStatus.value.data ?? SampleTaskItem());
99
+    SampleTaskItem req = pageStatus.value.data!;
100 100
     // 去签名
101 101
     var args = SignaturePageArgs(count: req.dgryName?.split(',').length ?? 0);
102 102
     List<Uint8List?>? list = await MyRouter.startSignature(args: args);
@@ -323,9 +323,8 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
323 323
       child: GestureDetector(
324 324
         behavior: HitTestBehavior.opaque,
325 325
         onTap: () {
326
-          tabIndex.value = index;
327 326
           if ((pageCtrl.page?.toInt() ?? 0) == index) return;
328
-          pageCtrl.jumpToPage(index);
327
+          pageCtrl.animateToPage(index, duration: const Duration(milliseconds: 200), curve: Curves.linear);
329 328
         },
330 329
         child: Container(
331 330
           alignment: Alignment.center,

+ 66 - 7
lib/page/sample_task/reap_sample_detail/reap_sample_variety_detail_page.dart

@@ -60,7 +60,6 @@ class _ReapSampleVarietyDetailPageState extends BaseLifecycleState<ReapSampleVar
60 60
 
61 61
   /// 获取粮食信息列表
62 62
   Future<void> getLsxxList() async {
63
-    MyNavigator.showLoading();
64 63
     try {
65 64
       var rsp = await MyApi.get().lsxxList(data?.cypzName ?? '');
66 65
       List<CardMenuData> list = [];
@@ -127,14 +126,20 @@ class _ReapSampleVarietyDetailPageState extends BaseLifecycleState<ReapSampleVar
127 126
             '删除',
128 127
             alignment: null,
129 128
             backgroundColor: const Color(0xFFCE615A),
130
-            onTap: () => MyNavigator.dismiss(tag: 'delete', result: true),
129
+            onTap: () {
130
+              if (data!.codeSamplingNonghuList!.length > 1) {
131
+                MyNavigator.dismiss(tag: 'delete', result: true);
132
+              } else {
133
+                MyNavigator.showToast('必须有一条扦样农户信息');
134
+                MyNavigator.dismiss(tag: 'delete');
135
+              }
136
+            },
131 137
           ),
132 138
           MyButton('取消', alignment: null, onTap: () => MyNavigator.dismiss(tag: 'delete')),
133 139
         ],
134 140
       ),
135 141
     );
136 142
     if (!(delete ?? false)) return;
137
-
138 143
     setState(() {
139 144
       data?.codeSamplingNonghuList?.remove(item);
140 145
     });
@@ -142,6 +147,56 @@ class _ReapSampleVarietyDetailPageState extends BaseLifecycleState<ReapSampleVar
142 147
 
143 148
   /// 校验数据
144 149
   bool verifyData() {
150
+    // 粮食品类
151
+    if ((data?.lspz ?? '').isEmpty) {
152
+      MyNavigator.showToast('粮食品类不能为空');
153
+      return false;
154
+    }
155
+    // 是否优质品种
156
+    if (data?.sfyzpz == null) {
157
+      MyNavigator.showToast('是否优质品种不能为空');
158
+      return false;
159
+    }
160
+    // 品种优质类型
161
+    if (data?.sfyzpz == 0 && data?.yzpzlx == null) {
162
+      MyNavigator.showToast('品种优质类型不能为空');
163
+      return false;
164
+    }
165
+    debugPrint('天气情况: ${data?.tqqk}');
166
+    // 天气情况
167
+    if ((data?.tqqk ?? 0) == 0) {
168
+      MyNavigator.showToast('天气情况不能为空');
169
+      return false;
170
+    }
171
+    // 收获时间
172
+    if ((data?.shsj ?? '').isEmpty) {
173
+      MyNavigator.showToast('收获时间不能为空');
174
+      return false;
175
+    }
176
+    // 扦样时间
177
+    if ((data?.qysj ?? '').isEmpty) {
178
+      MyNavigator.showToast('扦样时间不能为空');
179
+      return false;
180
+    }
181
+    // 农户信息
182
+    for (var item in data?.codeSamplingNonghuList ?? <NonghuItem>[]) {
183
+      if (item.qysl == null) {
184
+        MyNavigator.showToast('扦样数量不能为空');
185
+        return false;
186
+      }
187
+      if (item.qydbsl == null) {
188
+        MyNavigator.showToast('扦样代表数量不能为空');
189
+        return false;
190
+      }
191
+      if ((item.lxfs ?? '').isEmpty) {
192
+        MyNavigator.showToast('联系方式不能为空');
193
+        return false;
194
+      }
195
+      if ((item.bdcnhhhzs ?? '').isEmpty) {
196
+        MyNavigator.showToast('被调查农户或合作社不能为空');
197
+        return false;
198
+      }
199
+    }
145 200
     return true;
146 201
   }
147 202
 
@@ -154,10 +209,7 @@ class _ReapSampleVarietyDetailPageState extends BaseLifecycleState<ReapSampleVar
154 209
     isDetail = widget.detail;
155 210
     widget.ctrl.verifyData = verifyData;
156 211
     arrowDown = Image.asset(imgItemArrowDown, width: 20, color: const Color(0xFF01B2C8));
157
-  }
158 212
 
159
-  @override
160
-  void onFirstShow(Duration timeStamp) {
161 213
     // 粮食品类菜单数据
162 214
     getLsxxList();
163 215
     // 是否优选品种
@@ -182,11 +234,18 @@ class _ReapSampleVarietyDetailPageState extends BaseLifecycleState<ReapSampleVar
182 234
       return menu;
183 235
     }).toList();
184 236
     if (!isDetail && (data?.codeSamplingNonghuList ?? []).isEmpty) {
185
-      data?.codeSamplingNonghuList = [NonghuItem()];
237
+      setState(() {
238
+        data?.codeSamplingNonghuList = [NonghuItem()];
239
+      });
186 240
     }
187 241
   }
188 242
 
189 243
   @override
244
+  void onFirstShow(Duration timeStamp) {
245
+    MyNavigator.showLoading();
246
+  }
247
+
248
+  @override
190 249
   Widget build(BuildContext context) {
191 250
     super.build(context);
192 251
     return SingleChildScrollView(child: buildList());

+ 1 - 1
pubspec.yaml

@@ -39,7 +39,7 @@ dependencies:
39 39
   cupertino_icons: ^1.0.2
40 40
 
41 41
   # 弹框
42
-  flutter_smart_dialog: ^4.9.7+4
42
+  flutter_smart_dialog: 4.9.6
43 43
   # 轮播图
44 44
   card_swiper: ^3.0.1
45 45
   # 缓存网络图片