|
@@ -12,6 +12,7 @@ import 'package:lszlgl/service/print_service.dart';
|
12
|
12
|
import 'package:lszlgl/utils/input_formatter.dart';
|
13
|
13
|
import 'package:lszlgl/utils/location_utils.dart';
|
14
|
14
|
import 'package:lszlgl/widget/button.dart';
|
|
15
|
+import 'package:lszlgl/widget/qypop_widget.dart';
|
15
|
16
|
import '../../../base/base_lifecycle_state.dart';
|
16
|
17
|
import '../../../config/colors.dart';
|
17
|
18
|
import '../../../model/rsp/dict_rsp.dart';
|
|
@@ -39,7 +40,8 @@ class ReapSampleBasicDetailPage extends StatefulWidget {
|
39
|
40
|
State<ReapSampleBasicDetailPage> createState() => _ReapSampleBasicDetailPageState();
|
40
|
41
|
}
|
41
|
42
|
|
42
|
|
-class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasicDetailPage> with AutomaticKeepAliveClientMixin {
|
|
43
|
+class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasicDetailPage>
|
|
44
|
+ with AutomaticKeepAliveClientMixin {
|
43
|
45
|
SampleTaskItem? data;
|
44
|
46
|
late bool isDetail;
|
45
|
47
|
|
|
@@ -57,10 +59,14 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
57
|
59
|
final trxx = null.notifier<CardMenuData?>();
|
58
|
60
|
|
59
|
61
|
final qyddjwd = null.notifier<String?>();
|
|
62
|
+ final otherpeople = null.notifier<String?>();
|
|
63
|
+ final xjCityList = <CardMenuData>[].notifier<List<CardMenuData>>();
|
|
64
|
+ final xjcitysel = null.notifier<CardMenuData?>();
|
|
65
|
+ // final name = null.notifier<String?>();
|
60
|
66
|
|
61
|
|
- final name = null.notifier<String?>();
|
62
|
|
-
|
63
|
|
- List<CardMenuData> personList = [];
|
|
67
|
+ List<OtherPeopleModel> personList = [];
|
|
68
|
+ String otherStr = '';
|
|
69
|
+ bool isXJ = false; // 是否是新疆兵团
|
64
|
70
|
|
65
|
71
|
/// 获取行政区划列表
|
66
|
72
|
Future<List<CardMenuData>?> getDistrictList(num level, {num? id}) async {
|
|
@@ -99,6 +105,18 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
99
|
105
|
MyNavigator.dismissLoading();
|
100
|
106
|
}
|
101
|
107
|
|
|
108
|
+ // 获取新疆兵团 市级列表
|
|
109
|
+ void getXJCityList() async{
|
|
110
|
+ var cityList = await getDistrictList(2, id: 662746);
|
|
111
|
+ if (cityList == null) return;
|
|
112
|
+ xjCityList.value = cityList;
|
|
113
|
+ for (CardMenuData item in cityList) {
|
|
114
|
+ if(item.name == data?.shi){
|
|
115
|
+ xjcitysel.value = item;
|
|
116
|
+ }
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+
|
102
|
120
|
// /// 选中行政区划
|
103
|
121
|
// void onSelectXzqh(ValueNotifier<CardMenuData?> selNotifier, CardMenuData selData) {
|
104
|
122
|
// num level = 100;
|
|
@@ -138,14 +156,15 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
138
|
156
|
var rsp = await MyApi.get().getPersonMenu(data?.jhcyjg ?? data?.zjBaseEnterpriseId ?? 0);
|
139
|
157
|
personList
|
140
|
158
|
..clear()
|
141
|
|
- ..addAll((rsp.data ?? []).map((e) => CardMenuData(e.name, e.id)).toList());
|
|
159
|
+ ..addAll((rsp.data ?? []).map((e) => OtherPeopleModel(name: e.name)).toList());
|
|
160
|
+ personList.removeWhere((item) => item.name == data?.name); // 移除可能存在的默认人员
|
142
|
161
|
// 选中扦样人员
|
143
|
162
|
var nameList = data?.dgryName?.split(',');
|
144
|
163
|
if (nameList != null) {
|
145
|
164
|
for (var person in personList) {
|
146
|
165
|
for (var name in nameList) {
|
147
|
166
|
if (person.name == name) {
|
148
|
|
- person.select = true;
|
|
167
|
+ person.isChose = true;
|
149
|
168
|
break;
|
150
|
169
|
}
|
151
|
170
|
}
|
|
@@ -156,6 +175,34 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
156
|
175
|
}
|
157
|
176
|
}
|
158
|
177
|
|
|
178
|
+ // 选择陪同人员
|
|
179
|
+ void showPopView() {
|
|
180
|
+ showModalBottomSheet(
|
|
181
|
+ isDismissible: false,
|
|
182
|
+ enableDrag: false,
|
|
183
|
+ isScrollControlled: true,
|
|
184
|
+ shape: const RoundedRectangleBorder(
|
|
185
|
+ borderRadius:
|
|
186
|
+ BorderRadius.only(topLeft: Radius.circular(14), topRight: Radius.circular(14))),
|
|
187
|
+ context: context,
|
|
188
|
+ builder: (context) {
|
|
189
|
+ return QyPopWidget(
|
|
190
|
+ pTitleList: personList,
|
|
191
|
+ otherStr: otherStr,
|
|
192
|
+ pTitleCallBack: (val, other) {
|
|
193
|
+ otherStr = other;
|
|
194
|
+ if (val.isEmpty) {
|
|
195
|
+ data?.dgryName = null;
|
|
196
|
+ otherpeople.value = null;
|
|
197
|
+ } else {
|
|
198
|
+ data?.dgryName = val;
|
|
199
|
+ otherpeople.value = val;
|
|
200
|
+ }
|
|
201
|
+ },
|
|
202
|
+ );
|
|
203
|
+ });
|
|
204
|
+ }
|
|
205
|
+
|
159
|
206
|
void getLocation() async {
|
160
|
207
|
bool granted = await LocationUtils.checkLocationAvailable();
|
161
|
208
|
if (!granted) {
|
|
@@ -165,17 +212,25 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
165
|
212
|
LocationUtils.startLocation();
|
166
|
213
|
}
|
167
|
214
|
|
|
215
|
+
|
168
|
216
|
void initLocation() {
|
169
|
217
|
locationListener = LocationUtils.onLocationChanged().listen((value) async {
|
170
|
218
|
logger.d('LocationChanged:${jsonEncode(value)}');
|
171
|
219
|
var lon = (value['longitude'] as double).toStringAsFixed(6);
|
172
|
220
|
var lat = (value['latitude'] as double).toStringAsFixed(6);
|
|
221
|
+ String adCode = value['adCode'] as String;
|
|
222
|
+ if(isXJ){ // 新疆兵团特殊处理
|
|
223
|
+ String jwd = '$lon,$lat';
|
|
224
|
+ qyddjwd.value = jwd;
|
|
225
|
+ data?.qyddjwd = jwd;
|
|
226
|
+ data?.xzqhCode = adCode;
|
|
227
|
+ return ;
|
|
228
|
+ }
|
173
|
229
|
String province = value['province'] as String;
|
174
|
230
|
String city = value['city'] as String;
|
175
|
231
|
String district = value['district'] as String;
|
176
|
232
|
String street = value['street'] as String;
|
177
|
233
|
String streetNumber = value['streetNumber'] as String;
|
178
|
|
- String adCode = value['adCode'] as String;
|
179
|
234
|
if (province == city) {
|
180
|
235
|
city = district;
|
181
|
236
|
district = '';
|
|
@@ -189,10 +244,10 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
189
|
244
|
sheng.value = null;
|
190
|
245
|
shi.value = null;
|
191
|
246
|
qu.value = null;
|
192
|
|
- data?.xiangXzqhName = null;
|
193
|
|
- xian.text = '';
|
194
|
|
- data?.cunXzqhName = null;
|
195
|
|
- cun.text = '';
|
|
247
|
+ // data?.xiangXzqhName = null;
|
|
248
|
+ // xian.text = '';
|
|
249
|
+ // data?.cunXzqhName = null;
|
|
250
|
+ // cun.text = '';
|
196
|
251
|
|
197
|
252
|
MyNavigator.showLoading();
|
198
|
253
|
bool stepSuccess = false;
|
|
@@ -239,10 +294,10 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
239
|
294
|
|
240
|
295
|
if (stepSuccess) {
|
241
|
296
|
// 乡、村
|
242
|
|
- data?.xiangXzqhName = street;
|
243
|
|
- data?.cunXzqhName = streetNumber;
|
244
|
|
- xian.text = street;
|
245
|
|
- cun.text = streetNumber;
|
|
297
|
+ // data?.xiangXzqhName = street;
|
|
298
|
+ // data?.cunXzqhName = streetNumber;
|
|
299
|
+ // xian.text = street;
|
|
300
|
+ // cun.text = streetNumber;
|
246
|
301
|
}
|
247
|
302
|
}
|
248
|
303
|
}
|
|
@@ -258,26 +313,26 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
258
|
313
|
}
|
259
|
314
|
}
|
260
|
315
|
|
261
|
|
- void personSelCallback(List<CardMenuData> selectList) async {
|
262
|
|
- if (selectList.isEmpty) {
|
263
|
|
- data?.dgryName = null;
|
264
|
|
- name.value = null;
|
265
|
|
- return;
|
266
|
|
- }
|
267
|
|
- var names = StringBuffer();
|
268
|
|
- var ids = StringBuffer();
|
269
|
|
- for (int i = 0; i < selectList.length; i++) {
|
270
|
|
- var item = selectList[i];
|
271
|
|
- names.write(item.name);
|
272
|
|
- ids.write(item.value);
|
273
|
|
- if (i < selectList.length - 1) {
|
274
|
|
- names.write(',');
|
275
|
|
- ids.write(',');
|
276
|
|
- }
|
277
|
|
- }
|
278
|
|
- data?.dgryName = names.toString();
|
279
|
|
- name.value = names.toString();
|
280
|
|
- }
|
|
316
|
+ // void personSelCallback(List<CardMenuData> selectList) async {
|
|
317
|
+ // if (selectList.isEmpty) {
|
|
318
|
+ // data?.dgryName = null;
|
|
319
|
+ // name.value = null;
|
|
320
|
+ // return;
|
|
321
|
+ // }
|
|
322
|
+ // var names = StringBuffer();
|
|
323
|
+ // var ids = StringBuffer();
|
|
324
|
+ // for (int i = 0; i < selectList.length; i++) {
|
|
325
|
+ // var item = selectList[i];
|
|
326
|
+ // names.write(item.name);
|
|
327
|
+ // ids.write(item.value);
|
|
328
|
+ // if (i < selectList.length - 1) {
|
|
329
|
+ // names.write(',');
|
|
330
|
+ // ids.write(',');
|
|
331
|
+ // }
|
|
332
|
+ // }
|
|
333
|
+ // data?.dgryName = names.toString();
|
|
334
|
+ // name.value = names.toString();
|
|
335
|
+ // }
|
281
|
336
|
|
282
|
337
|
void showSignature() {
|
283
|
338
|
if (data?.filePictureList?.isEmpty ?? true) {
|
|
@@ -372,7 +427,6 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
372
|
427
|
}
|
373
|
428
|
|
374
|
429
|
Future<void> printPic(String? name) async {
|
375
|
|
-
|
376
|
430
|
Uint8List? bytes = await FileUtils.getBitmapFromContext(ewmKey.currentContext);
|
377
|
431
|
List<String> textList = PrintService.getPrintTextListWithSampleTaskItem(data);
|
378
|
432
|
var args = PrintPageArgs(bytes: bytes!, textList: textList);
|
|
@@ -398,11 +452,6 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
398
|
452
|
|
399
|
453
|
/// 校验数据
|
400
|
454
|
bool verifyData() {
|
401
|
|
- // 扦样/陪同人员
|
402
|
|
- if ((data?.dgryName ?? '').isEmpty) {
|
403
|
|
- MyNavigator.showToast('扦样/陪同人员不能为空');
|
404
|
|
- return false;
|
405
|
|
- }
|
406
|
455
|
// 乡镇
|
407
|
456
|
if ((data?.xiangXzqhName ?? '').isEmpty) {
|
408
|
457
|
MyNavigator.showToast('乡镇不能为空');
|
|
@@ -435,7 +484,7 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
435
|
484
|
bool get wantKeepAlive => true;
|
436
|
485
|
|
437
|
486
|
@override
|
438
|
|
- void onInit() {
|
|
487
|
+ void onInit(){
|
439
|
488
|
data = widget.data;
|
440
|
489
|
isDetail = widget.detail;
|
441
|
490
|
widget.ctrl.verifyData = verifyData;
|
|
@@ -443,16 +492,30 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
443
|
492
|
// 土壤信息
|
444
|
493
|
getTrxxList();
|
445
|
494
|
|
|
495
|
+ if (data?.sheng == '新疆兵团'){
|
|
496
|
+ isXJ = true;
|
|
497
|
+ getXJCityList();
|
|
498
|
+ }
|
446
|
499
|
if (data?.sheng != null) sheng.value = CardMenuData(data?.sheng, data?.shengXzqh);
|
447
|
500
|
if (data?.shi != null) shi.value = CardMenuData(data?.shi, data?.shiXzqh);
|
448
|
501
|
if (data?.qu != null) qu.value = CardMenuData(data?.qu, data?.quXzqh);
|
449
|
502
|
if (data?.xiangXzqhName != null) xian.text = data!.xiangXzqhName!;
|
450
|
503
|
if (data?.cunXzqhName != null) cun.text = data!.cunXzqhName!;
|
451
|
504
|
qyddjwd.value = data?.qyddjwd;
|
452
|
|
- if ((data?.dgryName ?? '0') == '0') {
|
453
|
|
- data?.dgryName = UserService.get().getUser()?.nickname;
|
|
505
|
+
|
|
506
|
+ if ((data?.name ?? '0') == '0') {
|
|
507
|
+ data?.name = UserService.get().getUser()?.nickname;
|
|
508
|
+ }
|
|
509
|
+ var nameList = data?.dgryName?.split(',');
|
|
510
|
+ if (nameList != null) {
|
|
511
|
+ nameList.removeWhere((item) => item == data?.name);
|
|
512
|
+ if (nameList.isNotEmpty) {
|
|
513
|
+ data?.dgryName = nameList.join(',');
|
|
514
|
+ } else {
|
|
515
|
+ data?.dgryName = null;
|
|
516
|
+ }
|
454
|
517
|
}
|
455
|
|
- name.value = data?.dgryName;
|
|
518
|
+ otherpeople.value = data?.dgryName;
|
456
|
519
|
// 编辑数据
|
457
|
520
|
if (!isDetail) {
|
458
|
521
|
initLocation();
|
|
@@ -482,19 +545,40 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
|
482
|
545
|
return Column(
|
483
|
546
|
children: [
|
484
|
547
|
CardItemWidget('样品单号', rightText: data?.qyrwdh, bottomLine: true),
|
485
|
|
- name.builder(
|
486
|
|
- (v) => CardWidgets.buildMenuDialog(
|
487
|
|
- isDetail,
|
488
|
|
- '扦样/陪同人员',
|
489
|
|
- v,
|
490
|
|
- personList,
|
491
|
|
- personSelCallback,
|
492
|
|
- multiple: true,
|
493
|
|
- selectCountMax: 3,
|
494
|
|
- ),
|
495
|
|
- ),
|
|
548
|
+ CardItemWidget('扦样人员', rightText: data?.name, bottomLine: true),
|
|
549
|
+
|
|
550
|
+ otherpeople.builder((v) => CardItemWidget(
|
|
551
|
+ '陪同人员',
|
|
552
|
+ rightText: v,
|
|
553
|
+ bottomLine: true,
|
|
554
|
+ onTap: isDetail ? null : showPopView,
|
|
555
|
+ trailing: isDetail ? null : const Icon(Icons.arrow_drop_down, size: 24, color: Color(0xFF01B2C8),),
|
|
556
|
+ )),
|
|
557
|
+ //
|
|
558
|
+ // name.builder(
|
|
559
|
+ // (v) => CardWidgets.buildMenuDialog(
|
|
560
|
+ // isDetail,
|
|
561
|
+ // '扦样/陪同人员',
|
|
562
|
+ // v,
|
|
563
|
+ // personList,
|
|
564
|
+ // personSelCallback,
|
|
565
|
+ // multiple: true,
|
|
566
|
+ // selectCountMax: 3,
|
|
567
|
+ // ),
|
|
568
|
+ // ),
|
496
|
569
|
sheng.builder((v) => CardItemWidget('省份', rightText: v?.name, bottomLine: true)),
|
|
570
|
+ if(!isXJ)
|
497
|
571
|
shi.builder((v) => CardItemWidget('市/州', rightText: v?.name, bottomLine: true)),
|
|
572
|
+
|
|
573
|
+ if(isXJ)
|
|
574
|
+ CardWidgets.buildMenu(
|
|
575
|
+ isDetail,
|
|
576
|
+ '市/州',
|
|
577
|
+ xjCityList,
|
|
578
|
+ xjcitysel,
|
|
579
|
+ (_, sel) => data?.shiXzqh = sel.value,
|
|
580
|
+ ),
|
|
581
|
+
|
498
|
582
|
qu.builder((v) => CardItemWidget('区县', rightText: v?.name, bottomLine: true)),
|
499
|
583
|
// xian.builder((v) => CardItemWidget('乡镇', rightText: v?.name, bottomLine: true)),
|
500
|
584
|
// cun.builder((v) => CardItemWidget('村', rightText: v?.name, bottomLine: true)),
|