|
@@ -6,7 +6,6 @@ import 'package:lszlgl/main.dart';
|
6
|
6
|
import 'package:lszlgl/utils/input_formatter.dart';
|
7
|
7
|
import 'package:lszlgl/utils/location_utils.dart';
|
8
|
8
|
import 'package:lszlgl/widget/button.dart';
|
9
|
|
-import 'package:lszlgl/widget/menu_dialog.dart';
|
10
|
9
|
import '../../../base/base_lifecycle_state.dart';
|
11
|
10
|
import '../../../model/rsp/dict_rsp.dart';
|
12
|
11
|
import '../../../model/rsp/sample_task_rsp.dart';
|
|
@@ -50,11 +49,11 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
50
|
49
|
|
51
|
50
|
final name = null.notifier<String?>();
|
52
|
51
|
|
53
|
|
- late List<CardMenuData> personList;
|
|
52
|
+ List<CardMenuData> personList = [];
|
54
|
53
|
|
55
|
54
|
/// 获取行政区划列表
|
56
|
|
- Future<List<CardMenuData>?> getDistrictList(num level, {num? id}) async {
|
57
|
|
- MyNavigator.showLoading();
|
|
55
|
+ Future<List<CardMenuData>?> getDistrictList(num level, {num? id, bool showLoading = true}) async {
|
|
56
|
+ if (showLoading) MyNavigator.showLoading();
|
58
|
57
|
try {
|
59
|
58
|
var rsp = await MyApi.get().districtList(level, id: id);
|
60
|
59
|
List<CardMenuData> list = (rsp.data ?? []).map((e) => CardMenuData(e.uname, e.id)).toList();
|
|
@@ -63,12 +62,12 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
63
|
62
|
} else if (level == 5) {
|
64
|
63
|
cunList.value = list;
|
65
|
64
|
}
|
66
|
|
- MyNavigator.dismissLoading();
|
|
65
|
+ if (showLoading) MyNavigator.dismissLoading();
|
67
|
66
|
return list;
|
68
|
67
|
} catch (e) {
|
69
|
68
|
logger.e(e);
|
70
|
69
|
}
|
71
|
|
- MyNavigator.dismissLoading();
|
|
70
|
+ if (showLoading) MyNavigator.dismissLoading();
|
72
|
71
|
return null;
|
73
|
72
|
}
|
74
|
73
|
|
|
@@ -113,30 +112,26 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
113
|
112
|
}
|
114
|
113
|
|
115
|
114
|
/// 获取编辑数据
|
116
|
|
- void getEditData() {
|
117
|
|
- // 市
|
118
|
|
- if (data?.shengXzqh != null) {
|
119
|
|
- getDistrictList(2, id: data?.shengXzqh);
|
120
|
|
- }
|
121
|
|
- // 区
|
122
|
|
- if (data?.shiXzqh != null) {
|
123
|
|
- getDistrictList(3, id: data?.shiXzqh);
|
124
|
|
- }
|
|
115
|
+ void getEditData() async {
|
|
116
|
+ MyNavigator.showLoading();
|
125
|
117
|
// 县
|
126
|
118
|
if (data?.quXzqh != null) {
|
127
|
|
- getDistrictList(4, id: data?.quXzqh);
|
|
119
|
+ await getDistrictList(4, id: data?.quXzqh, showLoading: false);
|
128
|
120
|
}
|
129
|
121
|
// 村
|
130
|
122
|
if (data?.xiangXzqh != null) {
|
131
|
|
- getDistrictList(5, id: data?.xiangXzqh);
|
|
123
|
+ await getDistrictList(5, id: data?.xiangXzqh, showLoading: false);
|
132
|
124
|
}
|
|
125
|
+ MyNavigator.dismissLoading();
|
133
|
126
|
}
|
134
|
127
|
|
135
|
128
|
void getPersonData() async {
|
136
|
129
|
try {
|
137
|
130
|
// 获取扦样人员列表
|
138
|
131
|
var rsp = await MyApi.get().getPersonMenu(data?.jhcyjg ?? 29964);
|
139
|
|
- personList = (rsp.data ?? []).map((e) => CardMenuData(e.name, e.id)).toList();
|
|
132
|
+ personList
|
|
133
|
+ ..clear()
|
|
134
|
+ ..addAll((rsp.data ?? []).map((e) => CardMenuData(e.name, e.id)).toList());
|
140
|
135
|
// 选中扦样人员
|
141
|
136
|
var nameList = data?.name?.split(',');
|
142
|
137
|
if (nameList != null) {
|
|
@@ -191,44 +186,50 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
191
|
186
|
cun.value = null;
|
192
|
187
|
cunList.value = [];
|
193
|
188
|
|
|
189
|
+ MyNavigator.showLoading();
|
194
|
190
|
bool stepSuccess = false;
|
195
|
191
|
// 省
|
196
|
|
- var provinceList = await getDistrictList(1);
|
197
|
|
- if (provinceList == null) return;
|
198
|
|
- for (CardMenuData item in provinceList) {
|
199
|
|
- if (item.name == province) {
|
200
|
|
- data?.shengXzqh = item.value;
|
201
|
|
- sheng.value = item;
|
202
|
|
- stepSuccess = true;
|
203
|
|
- break;
|
204
|
|
- }
|
205
|
|
- }
|
206
|
|
- if (!stepSuccess) return;
|
207
|
|
- stepSuccess = false;
|
208
|
|
- // 市
|
209
|
|
- var cityList = await getDistrictList(2, id: data?.shengXzqh);
|
210
|
|
- if (cityList == null) return;
|
211
|
|
- for (CardMenuData item in cityList) {
|
212
|
|
- if (item.name == city) {
|
213
|
|
- data?.shiXzqh = item.value;
|
214
|
|
- shi.value = item;
|
215
|
|
- stepSuccess = true;
|
216
|
|
- break;
|
|
192
|
+ var provinceList = await getDistrictList(1, showLoading: false);
|
|
193
|
+ if (provinceList != null) {
|
|
194
|
+ for (CardMenuData item in provinceList) {
|
|
195
|
+ if (item.name == province) {
|
|
196
|
+ data?.shengXzqh = item.value;
|
|
197
|
+ sheng.value = item;
|
|
198
|
+ stepSuccess = true;
|
|
199
|
+ break;
|
|
200
|
+ }
|
217
|
201
|
}
|
218
|
|
- }
|
219
|
|
- if (!stepSuccess) return;
|
220
|
|
- stepSuccess = false;
|
221
|
|
- // 区
|
222
|
|
- var districtList = await getDistrictList(3, id: data?.shiXzqh);
|
223
|
|
- if (districtList == null) return;
|
224
|
|
- for (CardMenuData item in districtList) {
|
225
|
|
- if (item.name == district) {
|
226
|
|
- data?.quXzqh = item.value;
|
227
|
|
- qu.value = item;
|
228
|
|
- getDistrictList(4, id: item.value);
|
229
|
|
- break;
|
|
202
|
+ if (stepSuccess) {
|
|
203
|
+ stepSuccess = false;
|
|
204
|
+ // 市
|
|
205
|
+ var cityList = await getDistrictList(2, id: data?.shengXzqh, showLoading: false);
|
|
206
|
+ if (cityList == null) return;
|
|
207
|
+ for (CardMenuData item in cityList) {
|
|
208
|
+ if (item.name == city) {
|
|
209
|
+ data?.shiXzqh = item.value;
|
|
210
|
+ shi.value = item;
|
|
211
|
+ stepSuccess = true;
|
|
212
|
+ break;
|
|
213
|
+ }
|
|
214
|
+ }
|
|
215
|
+ if (stepSuccess) {
|
|
216
|
+ stepSuccess = false;
|
|
217
|
+ // 区
|
|
218
|
+ var districtList = await getDistrictList(3, id: data?.shiXzqh, showLoading: false);
|
|
219
|
+ if (districtList == null) return;
|
|
220
|
+ for (CardMenuData item in districtList) {
|
|
221
|
+ if (item.name == district) {
|
|
222
|
+ data?.quXzqh = item.value;
|
|
223
|
+ qu.value = item;
|
|
224
|
+ getDistrictList(4, id: item.value, showLoading: false);
|
|
225
|
+ break;
|
|
226
|
+ }
|
|
227
|
+ }
|
|
228
|
+ }
|
230
|
229
|
}
|
231
|
230
|
}
|
|
231
|
+ MyNavigator.dismissLoading();
|
|
232
|
+
|
232
|
233
|
String jwd = '$lon,$lat';
|
233
|
234
|
qyddjwd.value = jwd;
|
234
|
235
|
data?.qyddjwd = jwd;
|
|
@@ -238,9 +239,7 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
238
|
239
|
}
|
239
|
240
|
}
|
240
|
241
|
|
241
|
|
- void showPersonMenu() async {
|
242
|
|
- List<CardMenuData>? selectList = await showMenuDialog(personList, selectCountMax: 3, isScrollControlled: true);
|
243
|
|
- if (selectList == null) return;
|
|
242
|
+ void personSelCallback(List<CardMenuData> selectList) async {
|
244
|
243
|
if (selectList.isEmpty) {
|
245
|
244
|
data?.dgryName = null;
|
246
|
245
|
name.value = null;
|
|
@@ -304,15 +303,7 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
304
|
303
|
children: [
|
305
|
304
|
CardItemWidget('扦样任务单号', rightText: data?.qyrwdh, bottomLine: true),
|
306
|
305
|
CardItemWidget('扦样单位', rightText: data?.dwmc, bottomLine: true),
|
307
|
|
- name.builder(
|
308
|
|
- (v) => CardItemWidget(
|
309
|
|
- '扦样人员',
|
310
|
|
- rightText: v,
|
311
|
|
- bottomLine: true,
|
312
|
|
- trailing: isDetail || v != null ? null : Image.asset(imgItemArrowDown, width: 20),
|
313
|
|
- onTap: isDetail ? null : showPersonMenu,
|
314
|
|
- ),
|
315
|
|
- ),
|
|
306
|
+ name.builder((v) => CardWidgets.buildMenuDialog(isDetail, '扦样人员', v, personList, personSelCallback, multiple: true)),
|
316
|
307
|
CardItemWidget('监测类别', rightText: DictService.getLabel(DictType.jclb, value: data?.jclb), bottomLine: true),
|
317
|
308
|
sheng.builder((v) => CardItemWidget('省份', rightText: v?.name, bottomLine: true)),
|
318
|
309
|
shi.builder((v) => CardItemWidget('市区', rightText: v?.name, bottomLine: true)),
|