|
|
@@ -1,5 +1,8 @@
|
|
1
|
1
|
import 'package:flutter/material.dart';
|
|
|
2
|
+import 'package:lszlgl/network/api.dart';
|
|
2
|
3
|
import '../../../base/base_lifecycle_state.dart';
|
|
|
4
|
+import '../../../config/colors.dart';
|
|
|
5
|
+import '../../../model/rsp/district_rsp.dart';
|
|
3
|
6
|
import '../../../model/rsp/sample_task_rsp.dart';
|
|
4
|
7
|
import '../../../service/dict_service.dart';
|
|
5
|
8
|
import '../../../widget/button.dart';
|
|
|
@@ -8,8 +11,15 @@ import '../../../widget/card_item.dart';
|
|
8
|
11
|
/// 收获扦样-基础信息
|
|
9
|
12
|
class ReapSampleBasicDetailPage extends StatefulWidget {
|
|
10
|
13
|
final SampleTaskItem? data;
|
|
|
14
|
+ final bool detail;
|
|
|
15
|
+ final VoidCallback? nextCallback;
|
|
11
|
16
|
|
|
12
|
|
- const ReapSampleBasicDetailPage(this.data, {super.key});
|
|
|
17
|
+ const ReapSampleBasicDetailPage(
|
|
|
18
|
+ this.data, {
|
|
|
19
|
+ super.key,
|
|
|
20
|
+ this.detail = true,
|
|
|
21
|
+ this.nextCallback,
|
|
|
22
|
+ });
|
|
13
|
23
|
|
|
14
|
24
|
@override
|
|
15
|
25
|
State<ReapSampleBasicDetailPage> createState() => _ReapSampleBasicDetailPageState();
|
|
|
@@ -19,9 +29,120 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
|
19
|
29
|
with AutomaticKeepAliveClientMixin {
|
|
20
|
30
|
SampleTaskItem? data;
|
|
21
|
31
|
|
|
|
32
|
+ late Widget arrowDown;
|
|
|
33
|
+ final sfList = <DistrictRsp>[].notifier<List<DistrictRsp>>();
|
|
|
34
|
+ final sqList = <DistrictRsp>[].notifier<List<DistrictRsp>>();
|
|
|
35
|
+ final qxList = <DistrictRsp>[].notifier<List<DistrictRsp>>();
|
|
|
36
|
+ final xzList = <DistrictRsp>[].notifier<List<DistrictRsp>>();
|
|
|
37
|
+ final czList = <DistrictRsp>[].notifier<List<DistrictRsp>>();
|
|
|
38
|
+ final sf = null.notifier<int?>();
|
|
|
39
|
+ final sq = null.notifier<int?>();
|
|
|
40
|
+ final qx = null.notifier<int?>();
|
|
|
41
|
+ final xz = null.notifier<int?>();
|
|
|
42
|
+ final cz = null.notifier<int?>();
|
|
|
43
|
+
|
|
|
44
|
+ final dllx = null.notifier<int?>();
|
|
|
45
|
+
|
|
22
|
46
|
@override
|
|
23
|
47
|
void onInit() {
|
|
24
|
48
|
data = widget.data;
|
|
|
49
|
+ arrowDown = Image.asset(imgItemArrowDown, width: 20);
|
|
|
50
|
+ // 省
|
|
|
51
|
+ districtList(1);
|
|
|
52
|
+ // 市
|
|
|
53
|
+ if (data?.shengXzqh != null) {
|
|
|
54
|
+ districtList(2, id: data?.shengXzqh);
|
|
|
55
|
+ }
|
|
|
56
|
+ // 区
|
|
|
57
|
+ if (data?.shiXzqh != null) {
|
|
|
58
|
+ districtList(3, id: data?.shiXzqh);
|
|
|
59
|
+ }
|
|
|
60
|
+ // 县
|
|
|
61
|
+ if (data?.quXzqh != null) {
|
|
|
62
|
+ districtList(4, id: data?.quXzqh);
|
|
|
63
|
+ }
|
|
|
64
|
+ // 村
|
|
|
65
|
+ if (data?.xiangXzqh != null) {
|
|
|
66
|
+ districtList(5, id: data?.xiangXzqh);
|
|
|
67
|
+ }
|
|
|
68
|
+ }
|
|
|
69
|
+
|
|
|
70
|
+ Future<void> districtList(num level, {num? id}) async {
|
|
|
71
|
+ MyNavigator.showLoading();
|
|
|
72
|
+ try {
|
|
|
73
|
+ var rsp = await Api().districtList(level, id: id);
|
|
|
74
|
+ if (level == 1) {
|
|
|
75
|
+ sfList.value = rsp.data ?? [];
|
|
|
76
|
+ } else if (level == 2) {
|
|
|
77
|
+ sqList.value = rsp.data ?? [];
|
|
|
78
|
+ } else if (level == 3) {
|
|
|
79
|
+ qxList.value = rsp.data ?? [];
|
|
|
80
|
+ } else if (level == 4) {
|
|
|
81
|
+ xzList.value = rsp.data ?? [];
|
|
|
82
|
+ } else if (level == 5) {
|
|
|
83
|
+ czList.value = rsp.data ?? [];
|
|
|
84
|
+ }
|
|
|
85
|
+ } catch (e) {}
|
|
|
86
|
+ MyNavigator.dismissLoading();
|
|
|
87
|
+ }
|
|
|
88
|
+
|
|
|
89
|
+ void onSelect(ValueNotifier<int?> selNotifier, int index) {
|
|
|
90
|
+ late DistrictRsp item;
|
|
|
91
|
+ if (selNotifier == sf) {
|
|
|
92
|
+ item = sfList.value[index];
|
|
|
93
|
+ data?.sheng = item.uname;
|
|
|
94
|
+ data?.shengXzqh = item.id;
|
|
|
95
|
+ sq.value = null;
|
|
|
96
|
+ qx.value = null;
|
|
|
97
|
+ xz.value = null;
|
|
|
98
|
+ cz.value = null;
|
|
|
99
|
+ sqList.value = [];
|
|
|
100
|
+ qxList.value = [];
|
|
|
101
|
+ xzList.value = [];
|
|
|
102
|
+ czList.value = [];
|
|
|
103
|
+ } else if (selNotifier == sq) {
|
|
|
104
|
+ item = sqList.value[index];
|
|
|
105
|
+ data?.shi = item.uname;
|
|
|
106
|
+ data?.shiXzqh = item.id;
|
|
|
107
|
+ qx.value = null;
|
|
|
108
|
+ xz.value = null;
|
|
|
109
|
+ cz.value = null;
|
|
|
110
|
+ qxList.value = [];
|
|
|
111
|
+ xzList.value = [];
|
|
|
112
|
+ czList.value = [];
|
|
|
113
|
+ } else if (selNotifier == qx) {
|
|
|
114
|
+ item = qxList.value[index];
|
|
|
115
|
+ data?.qu = item.uname;
|
|
|
116
|
+ data?.quXzqh = item.id;
|
|
|
117
|
+ xz.value = null;
|
|
|
118
|
+ cz.value = null;
|
|
|
119
|
+ xzList.value = [];
|
|
|
120
|
+ czList.value = [];
|
|
|
121
|
+ } else if (selNotifier == xz) {
|
|
|
122
|
+ item = xzList.value[index];
|
|
|
123
|
+ data?.xian = item.uname;
|
|
|
124
|
+ data?.xiangXzqh = item.id;
|
|
|
125
|
+ cz.value = null;
|
|
|
126
|
+ czList.value = [];
|
|
|
127
|
+ } else if (selNotifier == cz) {
|
|
|
128
|
+ item = sfList.value[index];
|
|
|
129
|
+ widget.data?.cun = item.uname;
|
|
|
130
|
+ data?.cun = item.uname;
|
|
|
131
|
+ data?.cunXzqh = item.id;
|
|
|
132
|
+ }
|
|
|
133
|
+ if ((item.ulevel ?? 100) < 5) {
|
|
|
134
|
+ districtList((item.ulevel ?? 100) + 1, id: item.id ?? 0);
|
|
|
135
|
+ }
|
|
|
136
|
+ }
|
|
|
137
|
+
|
|
|
138
|
+ Future<void> updateTask() async {
|
|
|
139
|
+ // widget.nextCallback?.call();
|
|
|
140
|
+ MyNavigator.showLoading();
|
|
|
141
|
+ try {
|
|
|
142
|
+ var rsp = await Api().updateSampleTask(data?.toJson() ?? {});
|
|
|
143
|
+ MyNavigator.showToast((rsp.data ?? false) ? '提交成功' : '提交失败');
|
|
|
144
|
+ } catch (e) {}
|
|
|
145
|
+ MyNavigator.dismissLoading();
|
|
25
|
146
|
}
|
|
26
|
147
|
|
|
27
|
148
|
@override
|
|
|
@@ -41,28 +162,81 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
|
41
|
162
|
Widget buildList() {
|
|
42
|
163
|
return Column(
|
|
43
|
164
|
children: [
|
|
44
|
|
- CardItemWidget('扦样任务单号', rightText: data?.qyrwdh, bottomLine: true),
|
|
45
|
|
- CardItemWidget('扦样单位', rightText: data?.dwmc, bottomLine: true),
|
|
46
|
|
- CardItemWidget('扦样人员', rightText: data?.name, bottomLine: true),
|
|
|
165
|
+ CardItemWidget(
|
|
|
166
|
+ '扦样任务单号',
|
|
|
167
|
+ rightText: data?.qyrwdh,
|
|
|
168
|
+ bottomLine: true,
|
|
|
169
|
+ ),
|
|
|
170
|
+ CardItemWidget(
|
|
|
171
|
+ '扦样单位',
|
|
|
172
|
+ rightText: data?.dwmc,
|
|
|
173
|
+ bottomLine: true,
|
|
|
174
|
+ ),
|
|
|
175
|
+ CardItemWidget(
|
|
|
176
|
+ '扦样人员',
|
|
|
177
|
+ rightText: data?.name,
|
|
|
178
|
+ bottomLine: true,
|
|
|
179
|
+ ),
|
|
47
|
180
|
CardItemWidget(
|
|
48
|
181
|
'监测类别',
|
|
49
|
182
|
rightText: DictService.getLabel(DictType.jclb, value: data?.jclb),
|
|
50
|
183
|
bottomLine: true,
|
|
51
|
184
|
),
|
|
52
|
|
- CardItemWidget('省份', rightText: data?.sheng, bottomLine: true),
|
|
53
|
|
- CardItemWidget('市区', rightText: data?.shi, bottomLine: true),
|
|
54
|
|
- CardItemWidget('区县', rightText: data?.qu, bottomLine: true),
|
|
55
|
|
- CardItemWidget('乡镇', rightText: data?.xian, bottomLine: true),
|
|
56
|
|
- CardItemWidget('村', rightText: data?.cun, bottomLine: true),
|
|
57
|
|
- CardItemWidget('扦样地点经纬度', rightText: data?.qyddjwd, bottomLine: true),
|
|
58
|
|
- CardItemWidget('种植面积(亩地)', rightText: data?.zzmj?.toString(), bottomLine: true),
|
|
|
185
|
+ CardItemWidget(
|
|
|
186
|
+ '省份',
|
|
|
187
|
+ rightText: widget.detail ? data?.sheng : null,
|
|
|
188
|
+ rightChild: widget.detail ? null : buildMenu(sfList, sf, onSelect),
|
|
|
189
|
+ bottomLine: true,
|
|
|
190
|
+ ),
|
|
|
191
|
+ CardItemWidget(
|
|
|
192
|
+ '市区',
|
|
|
193
|
+ rightText: widget.detail ? data?.shi : null,
|
|
|
194
|
+ rightChild: widget.detail ? null : buildMenu(sqList, sq, onSelect),
|
|
|
195
|
+ bottomLine: true,
|
|
|
196
|
+ ),
|
|
|
197
|
+ CardItemWidget(
|
|
|
198
|
+ '区县',
|
|
|
199
|
+ rightText: widget.detail ? data?.qu : null,
|
|
|
200
|
+ rightChild: widget.detail ? null : buildMenu(qxList, qx, onSelect),
|
|
|
201
|
+ bottomLine: true,
|
|
|
202
|
+ ),
|
|
|
203
|
+ CardItemWidget(
|
|
|
204
|
+ '乡镇',
|
|
|
205
|
+ rightText: widget.detail ? data?.xian : null,
|
|
|
206
|
+ rightChild: widget.detail ? null : buildMenu(xzList, xz, onSelect),
|
|
|
207
|
+ bottomLine: true,
|
|
|
208
|
+ ),
|
|
|
209
|
+ CardItemWidget(
|
|
|
210
|
+ '村',
|
|
|
211
|
+ rightText: widget.detail ? data?.cun : null,
|
|
|
212
|
+ rightChild: widget.detail ? null : buildMenu(czList, cz, onSelect),
|
|
|
213
|
+ bottomLine: true,
|
|
|
214
|
+ ),
|
|
|
215
|
+ CardItemWidget(
|
|
|
216
|
+ '扦样地点经纬度',
|
|
|
217
|
+ rightText: data?.qyddjwd,
|
|
|
218
|
+ bottomLine: true,
|
|
|
219
|
+ ),
|
|
|
220
|
+ CardItemWidget(
|
|
|
221
|
+ '种植面积(亩地)',
|
|
|
222
|
+ rightText: data?.zzmj?.toString(),
|
|
|
223
|
+ bottomLine: true,
|
|
|
224
|
+ ),
|
|
59
|
225
|
CardItemWidget(
|
|
60
|
226
|
'土壤地理类型',
|
|
61
|
227
|
rightText: DictService.getLabel(DictType.jclb, value: data?.trdllx),
|
|
62
|
228
|
bottomLine: true,
|
|
63
|
229
|
),
|
|
64
|
|
- CardItemWidget('被调查农户或合作社', rightText: data?.bdcnhhhzs, bottomLine: true),
|
|
65
|
|
- CardItemWidget('联系方式', rightText: data?.lxfs, bottomLine: true),
|
|
|
230
|
+ CardItemWidget(
|
|
|
231
|
+ '被调查农户或合作社',
|
|
|
232
|
+ rightText: data?.bdcnhhhzs,
|
|
|
233
|
+ bottomLine: true,
|
|
|
234
|
+ ),
|
|
|
235
|
+ CardItemWidget(
|
|
|
236
|
+ '联系方式',
|
|
|
237
|
+ rightText: data?.lxfs,
|
|
|
238
|
+ bottomLine: true,
|
|
|
239
|
+ ),
|
|
66
|
240
|
],
|
|
67
|
241
|
);
|
|
68
|
242
|
}
|
|
|
@@ -72,8 +246,88 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
|
72
|
246
|
color: const Color(0xFFF1F7F6),
|
|
73
|
247
|
padding: const EdgeInsets.all(12),
|
|
74
|
248
|
child: MyButton(
|
|
75
|
|
- '重新录入',
|
|
76
|
|
- onTap: () => MyRouter.startReapSampleTask(),
|
|
|
249
|
+ widget.detail ? '重新录入' : '下一步',
|
|
|
250
|
+ onTap: () => widget.detail ? MyRouter.startReapSampleTask() : updateTask(),
|
|
|
251
|
+ ),
|
|
|
252
|
+ );
|
|
|
253
|
+ }
|
|
|
254
|
+
|
|
|
255
|
+ Widget buildMenu(
|
|
|
256
|
+ ValueNotifier<List<DistrictRsp>> listNotifier,
|
|
|
257
|
+ ValueNotifier<int?> selNotifier,
|
|
|
258
|
+ Function(ValueNotifier<int?>, int) onItemTap,
|
|
|
259
|
+ ) {
|
|
|
260
|
+ return listNotifier.builder(
|
|
|
261
|
+ (list) => selNotifier.builder(
|
|
|
262
|
+ (sel) {
|
|
|
263
|
+ return MenuAnchor(
|
|
|
264
|
+ style: const MenuStyle(
|
|
|
265
|
+ padding: MaterialStatePropertyAll(EdgeInsets.zero),
|
|
|
266
|
+ alignment: Alignment.bottomRight,
|
|
|
267
|
+ ),
|
|
|
268
|
+ builder: (_, ctrl, __) => buildMenuText(ctrl, list, sel),
|
|
|
269
|
+ menuChildren: List.generate(list.length, (index) {
|
|
|
270
|
+ return buildMenuItem(
|
|
|
271
|
+ list[index],
|
|
|
272
|
+ index == sel,
|
|
|
273
|
+ () {
|
|
|
274
|
+ if (selNotifier.value == index) return;
|
|
|
275
|
+ selNotifier.value = index;
|
|
|
276
|
+ onItemTap.call(selNotifier, index);
|
|
|
277
|
+ },
|
|
|
278
|
+ );
|
|
|
279
|
+ }).toList(),
|
|
|
280
|
+ );
|
|
|
281
|
+ },
|
|
|
282
|
+ ),
|
|
|
283
|
+ );
|
|
|
284
|
+ }
|
|
|
285
|
+
|
|
|
286
|
+ Widget buildMenuText(MenuController ctrl, List<DistrictRsp> list, int? index) {
|
|
|
287
|
+ return GestureDetector(
|
|
|
288
|
+ behavior: HitTestBehavior.opaque,
|
|
|
289
|
+ onTap: () {
|
|
|
290
|
+ if (list.isEmpty) {
|
|
|
291
|
+ MyNavigator.showToast('请先选择上级选项');
|
|
|
292
|
+ return;
|
|
|
293
|
+ }
|
|
|
294
|
+ if (ctrl.isOpen) {
|
|
|
295
|
+ ctrl.close();
|
|
|
296
|
+ } else {
|
|
|
297
|
+ ctrl.open();
|
|
|
298
|
+ }
|
|
|
299
|
+ },
|
|
|
300
|
+ child: Row(
|
|
|
301
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
302
|
+ children: [
|
|
|
303
|
+ Expanded(
|
|
|
304
|
+ child: Text(
|
|
|
305
|
+ index == null ? '' : list[index].uname ?? '',
|
|
|
306
|
+ textAlign: TextAlign.right,
|
|
|
307
|
+ style: const TextStyle(
|
|
|
308
|
+ color: Color(0xFF01B2C8),
|
|
|
309
|
+ fontSize: 14,
|
|
|
310
|
+ fontWeight: FontWeight.w500,
|
|
|
311
|
+ ),
|
|
|
312
|
+ ),
|
|
|
313
|
+ ),
|
|
|
314
|
+ const SizedBox(width: 8),
|
|
|
315
|
+ arrowDown,
|
|
|
316
|
+ ],
|
|
|
317
|
+ ),
|
|
|
318
|
+ );
|
|
|
319
|
+ }
|
|
|
320
|
+
|
|
|
321
|
+ Widget buildMenuItem(DistrictRsp value, bool isSelect, VoidCallback? onPressed) {
|
|
|
322
|
+ return MenuItemButton(
|
|
|
323
|
+ onPressed: onPressed,
|
|
|
324
|
+ child: Container(
|
|
|
325
|
+ constraints: const BoxConstraints(minWidth: 120),
|
|
|
326
|
+ alignment: Alignment.center,
|
|
|
327
|
+ child: Text(
|
|
|
328
|
+ value.uname ?? '',
|
|
|
329
|
+ style: TextStyle(color: isSelect ? const Color(0xFF01B2C8) : MyColor.c_666666),
|
|
|
330
|
+ ),
|
|
77
|
331
|
),
|
|
78
|
332
|
);
|
|
79
|
333
|
}
|