周睿 hace 1 año
padre
commit
8616427f8a

+ 5 - 0
app_business/lib/service/api.dart

@@ -245,6 +245,11 @@ class ApiService extends IService {
     await stub.allMatchChackInsForceResume(
         pb.IdArrRequest()..idArr.addAll(checkIdList));
   }
+
+  Future<void> eventUserDelAll(Iterable<int> checkIdList) async {
+    await stub
+        .allMatchChackInsDel(pb.IdArrRequest()..idArr.addAll(checkIdList));
+  }
 }
 
 class EventRegisterInfo {

+ 63 - 43
app_business/lib/view/home/event_manage/event_manage.dart

@@ -1,6 +1,7 @@
 import 'package:app_business/service/api.dart';
 import 'package:app_business/view/home/dialog_event_register.dart';
 import 'package:pretty_qr_code/pretty_qr_code.dart';
+import 'package:track_common/model/event_state.dart';
 import 'package:track_common/widget.dart';
 import 'package:track_common/widget/prelude.dart';
 
@@ -27,44 +28,52 @@ class EventManage extends GetView<EventManagerController> {
                 )),
             const Spacer(),
             SizedBox(
-              height: 27.73,
-              width: 260,
-              child: Row(
-                mainAxisSize: MainAxisSize.min,
-                mainAxisAlignment: MainAxisAlignment.spaceBetween,
-                children: [
-                  SizedBox(
-                      width: 70,
-                      child: SmallButton(
-                        isOutline: true,
-                        color: Colors.orange,
-                        onPressed: controller.userRestartAll,
-                        child: const Text('一键重赛'),
-                      )),
-                  SizedBox(
-                      width: 70,
-                      child: SmallButton(
-                        isOutline: true,
-                        color: Colors.blue,
-                        onPressed: controller.routeAllocAll,
-                        child: const Text('一键分发'),
-                      )),
-                  SizedBox(
-                      width: 70,
-                      child: SmallButton(
-                        isOutline: true,
-                        color: Colors.green,
-                        onPressed: controller.userStartAll,
-                        child: const Text('一键开始'),
-                      ))
-                ],
-              ),
+              // height: 27.73,
+              width: 360,
+              child: wTopButtons(context),
             ),
             const SizedBox(width: 20)
           ],
         ));
   }
 
+  Widget wTopButtons(BuildContext context) {
+    return Obx(() {
+      var enable = true;
+
+      if (controller.selected?.state == EventState.idle) {
+        enable = false;
+      }
+
+      return Row(
+        mainAxisSize: MainAxisSize.min,
+        mainAxisAlignment: MainAxisAlignment.spaceBetween,
+        children: [
+          AppButton.outlined(
+            color: Colors.orange,
+            onPressed: enable ? controller.userRestartAll : null,
+            child: const Text('一键重赛'),
+          ),
+          AppButton.outlined(
+            color: Colors.blue,
+            onPressed: enable ? controller.routeAllocAll : null,
+            child: const Text('一键分发'),
+          ),
+          AppButton.outlined(
+            color: Colors.green,
+            onPressed: enable ? controller.userStartAll : null,
+            child: const Text('一键开始'),
+          ),
+          AppButton.outlined(
+            color: Colors.red,
+            onPressed: enable ? controller.userDelAll : null,
+            child: const Text('一键删除'),
+          )
+        ],
+      );
+    });
+  }
+
   Widget wDate(BuildContext context) {
     return GestureDetector(
         onTap: () => _onTapDate(context),
@@ -180,17 +189,7 @@ class EventManage extends GetView<EventManagerController> {
       }
 
       return LineChartElem([
-        Checkbox(
-            value: controller.selectedUser.value.contains(one.checkId),
-            onChanged: (v) {
-              controller.selectedUser.update((val) {
-                if (v == true) {
-                  val?.add(one.checkId);
-                } else {
-                  val?.remove(one.checkId);
-                }
-              });
-            }),
+        _CheckBox(one),
         Text('${i + 1}'),
         Text(one.name),
         Text(one.phone),
@@ -253,6 +252,27 @@ class EventManage extends GetView<EventManagerController> {
   }
 }
 
+class _CheckBox extends GetView<EventManagerController> {
+  const _CheckBox(this.one);
+
+  final UserInManage one;
+
+  @override
+  Widget build(BuildContext context) {
+    return Obx(() => Checkbox(
+        value: controller.selectedUser.value.contains(one.checkId),
+        onChanged: (v) {
+          controller.selectedUser.update((val) {
+            if (v == true) {
+              val?.add(one.checkId);
+            } else {
+              val?.remove(one.checkId);
+            }
+          });
+        }));
+  }
+}
+
 class _RouteSelectDialog extends GetView<EventManagerController> {
   const _RouteSelectDialog({required this.list});
   final Iterable<RouteInfo> list;

+ 9 - 0
app_business/lib/view/home/event_manage/event_manage_controller.dart

@@ -190,6 +190,15 @@ class EventManagerController extends GetxController {
     await _api.eventUserRestartAll(idList);
   }
 
+  Future<void> userDelAll() async {
+    final idList = selectedUser.value.toList();
+    if (idList.isEmpty) {
+      Get.snackbar('操作失败', '请选择1个以上的用户');
+      return;
+    }
+    await _api.eventUserDelAll(idList);
+  }
+
   Future<void> deleteSignIn(UserInManage user) async {
     Get.dialog(AppDialog(
         title: const Text('删除签到'),

+ 1 - 0
libs/track_common/lib/view/home/field_control/field_control.dart

@@ -212,6 +212,7 @@ class EventInfoView extends GetView<FieldControlController> {
     }
 
     return Container(
+      margin: EdgeInsets.only(bottom: 12),
       decoration: BoxDecoration(
           color: const Color(0xffe0e0e0),
           borderRadius: BorderRadius.circular(5)),