Browse Source

新疆兵团定位特殊处理;扦样陪同人员选择。

liujq 4 months ago
parent
commit
c87f73d78a

+ 0 - 44
lib/main.dart

@@ -116,50 +116,6 @@ class MyApp extends StatelessWidget {
116 116
   }
117 117
 }
118 118
 
119
-class MyHomePage extends StatefulWidget {
120
-  const MyHomePage({super.key, required this.title});
121 119
 
122
-  final String title;
123 120
 
124
-  @override
125
-  State<MyHomePage> createState() => _MyHomePageState();
126
-}
127
-
128
-class _MyHomePageState extends State<MyHomePage> {
129
-  int _counter = 0;
130
-
131
-  void _incrementCounter() {
132
-    setState(() {
133
-      _counter++;
134
-    });
135
-  }
136 121
 
137
-  @override
138
-  Widget build(BuildContext context) {
139
-    return Scaffold(
140
-      appBar: AppBar(
141
-        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
142
-        title: Text(widget.title),
143
-      ),
144
-      body: Center(
145
-        child: Column(
146
-          mainAxisAlignment: MainAxisAlignment.center,
147
-          children: <Widget>[
148
-            const Text(
149
-              'You have pushed the button this many times:',
150
-            ),
151
-            Text(
152
-              '$_counter',
153
-              style: Theme.of(context).textTheme.headlineMedium,
154
-            ),
155
-          ],
156
-        ),
157
-      ),
158
-      floatingActionButton: FloatingActionButton(
159
-        onPressed: _incrementCounter,
160
-        tooltip: 'Increment',
161
-        child: const Icon(Icons.add),
162
-      ),
163
-    );
164
-  }
165
-}

+ 3 - 0
lib/model/rsp/sample_task_rsp.dart

@@ -253,6 +253,9 @@ class SampleTaskItem {
253 253
     map['xiangXzqhName'] = xiangXzqhName;
254 254
     map['cunXzqhName'] = cunXzqhName;
255 255
 
256
+    // 新疆兵团
257
+    map['shiXzqh'] = shiXzqh;
258
+
256 259
     map['qyddjwd'] = qyddjwd;
257 260
     map['zzmj'] = zzmj;
258 261
     map['trdllx'] = trdllx;

+ 33 - 25
lib/page/login/login_page.dart

@@ -1,8 +1,11 @@
1 1
 import 'dart:convert';
2 2
 
3 3
 import 'package:dio/dio.dart';
4
+import 'package:flutter/cupertino.dart';
4 5
 import 'package:flutter/foundation.dart';
5 6
 import 'package:flutter/material.dart';
7
+import 'package:flutter/painting.dart';
8
+import 'package:flutter/widgets.dart';
6 9
 import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
7 10
 import 'package:lszlgl/base/base_lifecycle_state.dart';
8 11
 import 'package:lszlgl/config/app_config.dart';
@@ -243,37 +246,38 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
243 246
         child: Column(
244 247
           children: [
245 248
             const SizedBox(height: 56),
246
-            buildEdit(
247
-                ctrl: accountCtrl,
248
-                hint: '请输入登录账号',
249
-                icon: imgLoginAccount,
250
-                action: TextInputAction.next,
251
-                rightIcon: ValueListenableBuilder(
249
+            MenuAnchor(
250
+              builder: (_,MenuController ctrl, Widget? child){
251
+                return buildEdit(
252
+                    ctrl: accountCtrl,
253
+                    hint: '请输入登录账号',
254
+                    icon: imgLoginAccount,
255
+                    action: TextInputAction.next,
256
+                    onTap: ctrl.open,
257
+                    textChanged: (String v){
258
+                      ctrl.close();
259
+                    }
260
+                );
261
+              },
262
+              menuChildren: [
263
+                ValueListenableBuilder(
252 264
                     valueListenable: _account,
253
-                    builder: (ctx, Map<String,dynamic> ac, child){
265
+                    builder:(ctx,Map<String,dynamic> ac,child){
254 266
                       if(ac.isNotEmpty){
255
-                        return PopupMenuButton(
256
-                            icon: const Icon(
257
-                              Icons.arrow_drop_down_circle_outlined,
258
-                              size: 18,
259
-                              color: Color(0xFFBBBBBB),
260
-                            ),
261
-                            itemBuilder: (context) => [
262
-                              PopupMenuItem<String>(
263
-                                child: Text("账号:${ac['phone']}"),
264
-                                onTap: (){
265
-                                  accountCtrl.text = ac['phone'];
266
-                                  pwdCtrl.text =ac['pwd'];
267
-                                },
268
-                              ),
269
-                            ]
267
+                        return  MenuItemButton(
268
+                          child: Text("账号:${ac['phone']}"),
269
+                          onPressed: (){
270
+                            accountCtrl.text = ac['phone'];
271
+                            pwdCtrl.text =ac['pwd'];
272
+                            FocusManager.instance.primaryFocus?.unfocus();
273
+                          },
270 274
                         );
271 275
                       }else{
272 276
                         return const SizedBox.shrink();
273 277
                       }
274
-                    }
275
-                )
276
-                ),
278
+                    } ),
279
+              ],
280
+            ),
277 281
             const SizedBox(height: 32),
278 282
             ValueListenableBuilder(
279 283
                 valueListenable: _showPwd,
@@ -321,6 +325,8 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
321 325
     bool obscure = false,
322 326
     ValueChanged? onSubmit,
323 327
     Widget? rightIcon,
328
+    VoidCallback? onTap,
329
+    ValueChanged<String>? textChanged
324 330
   }) {
325 331
     return TextField(
326 332
       controller: ctrl,
@@ -347,6 +353,8 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
347 353
       textInputAction: action,
348 354
       obscureText: obscure,
349 355
       onSubmitted: onSubmit,
356
+      onTap: onTap,
357
+      onChanged: textChanged,
350 358
     );
351 359
   }
352 360
 

+ 140 - 56
lib/page/sample_task/reap_sample_detail/reap_sample_basic_detail_page.dart

@@ -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)),

+ 7 - 1
lib/page/sample_task/reap_sample_detail/reap_sample_task_page.dart

@@ -99,7 +99,13 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
99 99
     }
100 100
     SampleTaskItem req = pageStatus.value.data!;
101 101
     // 去签名
102
-    var args = SignaturePageArgs(count: req.dgryName?.split(',').length ?? 0);
102
+    int? sCount = req.dgryName?.split(',').length;
103
+    if(sCount == null){
104
+      sCount = 1;
105
+    }else{
106
+      sCount = sCount + 1 ;
107
+    }
108
+    var args = SignaturePageArgs(count: sCount );
103 109
     List<Uint8List?>? list = await MyRouter.startSignature(args: args);
104 110
     if (list == null || list.isEmpty) return;
105 111
     MyNavigator.showLoading(msg: '提交中...');

+ 23 - 24
lib/page/user_center/user_center_page.dart

@@ -92,32 +92,31 @@ class _UserCenterPageState extends BaseLifecycleState<UserCenterPage> with Autom
92 92
             boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.1), offset: const Offset(0, 5), blurRadius: 4)],
93 93
             image: const DecorationImage(image: AssetImage(imgHomeListBg), fit: BoxFit.fill),
94 94
           ),
95
-          child: Row(
96
-            crossAxisAlignment: CrossAxisAlignment.start,
95
+          child: Stack(
97 96
             children: [
98
-              Expanded(
99
-                child: Row(
100
-                  children: [
101
-                    buildUserAvatar(user?.avatar ?? ''),
102
-                    Column(
103
-                      crossAxisAlignment: CrossAxisAlignment.start,
104
-                      mainAxisSize: MainAxisSize.min,
105
-                      children: [
106
-                        Text(
107
-                          user?.nickname ?? '',
108
-                          style: const TextStyle(fontSize: 14, color: Color(0xFF333333), fontWeight: FontWeight.w500),
109
-                        ),
110
-                        const SizedBox(height: 14),
111
-                        Text(
112
-                          user?.username ?? '',
113
-                          style: const TextStyle(fontSize: 14, color: Color(0xFF333333), fontWeight: FontWeight.w500),
114
-                        ),
115
-                      ],
116
-                    ),
117
-                  ],
118
-                ),
97
+              Row(
98
+                children: [
99
+                  buildUserAvatar(user?.avatar ?? ''),
100
+                  Column(
101
+                    crossAxisAlignment: CrossAxisAlignment.start,
102
+                    mainAxisSize: MainAxisSize.min,
103
+                    children: [
104
+                      Text(
105
+                        user?.nickname ?? '',
106
+                        style: const TextStyle(fontSize: 14, color: Color(0xFF333333), fontWeight: FontWeight.w500),
107
+                      ),
108
+                      const SizedBox(height: 14),
109
+                      Text(
110
+                        user?.username ?? '',
111
+                        style: const TextStyle(fontSize: 14, color: Color(0xFF333333), fontWeight: FontWeight.w500),
112
+                      ),
113
+                    ],
114
+                  ),
115
+                ],
119 116
               ),
120
-              buildDeptText(user?.dept?.name ?? ''),
117
+              Positioned(
118
+                  right: 0,
119
+                  child: buildDeptText(user?.dept?.name ?? '')),
121 120
             ],
122 121
           ),
123 122
         ),

+ 143 - 0
lib/widget/qypop_widget.dart

@@ -0,0 +1,143 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:lszlgl/base/base_lifecycle_state.dart';
3
+
4
+class QyPopWidget extends StatefulWidget {
5
+  final List pTitleList;
6
+  final String otherStr;
7
+  final Function(String nameStr, String otherStr) pTitleCallBack;
8
+  const QyPopWidget(
9
+      {super.key, required this.pTitleList, required this.otherStr, required this.pTitleCallBack});
10
+
11
+  @override
12
+  State<QyPopWidget> createState() => _QyPopWidgetState();
13
+}
14
+
15
+class _QyPopWidgetState extends State<QyPopWidget> {
16
+  late TextEditingController ctrl;
17
+  final ScrollController sctrl = ScrollController();
18
+
19
+  @override
20
+  void initState() {
21
+    super.initState();
22
+    ctrl = TextEditingController(text: widget.otherStr); // 赋值
23
+  }
24
+
25
+  @override
26
+  Widget build(BuildContext context) {
27
+    return PopScope(
28
+      canPop: false, // 关闭系统返回,防止选中数据出错
29
+      child: GestureDetector(
30
+        behavior: HitTestBehavior.translucent,
31
+        onTap: () {
32
+          FocusManager.instance.primaryFocus?.unfocus();
33
+        },
34
+        child: SafeArea(
35
+          child: SingleChildScrollView(
36
+              controller: sctrl,
37
+              padding: EdgeInsets.fromLTRB(12, 22, 12, MediaQuery.of(context).viewInsets.bottom),
38
+              child: Column(
39
+                mainAxisSize: MainAxisSize.min, //
40
+                crossAxisAlignment: CrossAxisAlignment.stretch,
41
+                children: [
42
+                  const Text(
43
+                    '请选择或填写扦样陪同人员(最多2人)',
44
+                    style: TextStyle(fontSize: 15),
45
+                    textAlign: TextAlign.center,
46
+                  ),
47
+                  const SizedBox(height: 16),
48
+                  Wrap(
49
+                    spacing: 10,
50
+                    children: List.generate(
51
+                        widget.pTitleList.length,
52
+                        (i) => ActionChip(
53
+                            backgroundColor: Colors.grey[200],
54
+                            padding: const EdgeInsets.all(6),
55
+                            side: BorderSide.none,
56
+                            shape: const RoundedRectangleBorder(
57
+                                borderRadius: BorderRadius.all(Radius.circular(18))),
58
+                            label: Text(
59
+                              widget.pTitleList[i].name,
60
+                              style: widget.pTitleList[i].isChose
61
+                                  ? const TextStyle(fontSize: 14, color: Color(0xFF25A6EE))
62
+                                  : const TextStyle(fontSize: 14, color: Colors.grey),
63
+                            ),
64
+                            onPressed: () {
65
+                              setState(() {
66
+                                widget.pTitleList[i].isChose = !widget.pTitleList[i].isChose;
67
+                              });
68
+                            })),
69
+                  ),
70
+                  const SizedBox(height: 12),
71
+                  TextField(
72
+                    controller: ctrl,
73
+                    style: const TextStyle(fontSize: 14),
74
+                    decoration: const InputDecoration(
75
+                        border: InputBorder.none,
76
+                        icon: Text('其他陪同人员:'),
77
+                        hintText: '多人请用逗号隔开',
78
+                        isDense: true),
79
+                    onTap: () {
80
+                      Future.delayed(const Duration(milliseconds: 600), () {
81
+                        sctrl.animateTo(
82
+                          sctrl.position.maxScrollExtent,
83
+                          duration: const Duration(milliseconds: 400),
84
+                          curve: Curves.easeOut,
85
+                        );
86
+                      });
87
+                    },
88
+                  ),
89
+                  const Divider(color: Color(0xFFE7E7E7), height: 8, thickness: 1),
90
+                  const SizedBox(height: 12),
91
+                  TextButton(
92
+                      style: ButtonStyle(
93
+                        backgroundColor: WidgetStateProperty.all(const Color(0xFF25A6EE)),
94
+                        foregroundColor: WidgetStateProperty.all(Colors.white),
95
+                      ),
96
+                      onPressed: () {
97
+                        String finalVal = '';
98
+                        for (OtherPeopleModel model in widget.pTitleList) {
99
+                          if (model.isChose) {
100
+                            finalVal = '$finalVal${model.name},';
101
+                          }
102
+                        }
103
+                        String inputVal = ctrl.text;
104
+                        if (inputVal.isNotEmpty) {
105
+                          List<String> result = inputVal.split(RegExp(r'[,,.。;;\s]'));
106
+                          result.removeWhere((val) => val == '');
107
+                          inputVal = result.join(',');
108
+                          if (inputVal.isNotEmpty) {
109
+                            // 判断只输入符号出现问题
110
+                            finalVal = '$finalVal$inputVal,';
111
+                          }
112
+                        }
113
+
114
+                        FocusManager.instance.primaryFocus?.unfocus();
115
+                        if (finalVal.isNotEmpty) {
116
+                          String vals = finalVal.substring(0, finalVal.length - 1);
117
+                          List<String> li = vals.split(',');
118
+                          if (li.length > 2) {
119
+                            MyNavigator.showToast('最多两个陪同人员');
120
+                            return;
121
+                          }
122
+                          widget.pTitleCallBack.call(vals, inputVal);
123
+                        } else {
124
+                          // 输入为空 选择为空
125
+                          widget.pTitleCallBack.call('', inputVal);
126
+                        }
127
+                        Navigator.pop(context);
128
+                      },
129
+                      child: const Text('确 定')),
130
+                ],
131
+              )),
132
+        ),
133
+      ),
134
+    );
135
+  }
136
+}
137
+
138
+class OtherPeopleModel {
139
+  String? name;
140
+  bool isChose;
141
+
142
+  OtherPeopleModel({this.name, this.isChose = false});
143
+}

+ 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.22+22
19
+version: 0.0.23+23
20 20
 
21 21
 environment:
22 22
   sdk: '>=3.1.5 <4.0.0'