Browse Source

设置界面

周睿 1 năm trước cách đây
mục cha
commit
8e1c8a323d

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

@@ -251,6 +251,23 @@ class ApiService extends IService {
         .allMatchChackInsDel(pb.IdArrRequest()..idArr.addAll(checkIdList));
   }
 
+  Future<void> eventSettingsRulesSave(Iterable<Rule> rules) async {
+    await stub.toActivityRulesSave(pb.ToActivityRulesSaveRequest()
+      ..list.addAll(rules.map((e) {
+        final one = pb.ToActivityRulesSaveInfo()..arrId = e.id;
+        final vt = e.value;
+        if (vt is RuleValueBool) {
+          one.arValue = vt.value ? 'true' : 'false';
+        }
+
+        if (vt is RuleValueArrStr) {
+          one.arValue = vt.value;
+        }
+
+        return one;
+      })));
+  }
+
   Stream<CooperationInfo> cooperationInfo() async* {
     while (true) {
       await 1.seconds.delay();
@@ -279,3 +296,20 @@ class EventRegisterInfo {
   var stopAt = DateTime.now();
   String? password;
 }
+
+class Rule {
+  var id = 0;
+  var name = '';
+  RuleValue value = RuleValueBool();
+}
+
+class RuleValue {}
+
+class RuleValueBool extends RuleValue {
+  var value = false;
+}
+
+class RuleValueArrStr extends RuleValue {
+  var value = '';
+  var options = <String>[];
+}

+ 6 - 20
app_business/lib/view/home/event_manage/dialog_settings.dart

@@ -3,23 +3,6 @@ import 'dart:collection';
 import 'package:app_business/service/api.dart';
 import 'package:track_common/widget.dart';
 
-class Rule {
-  var id = 0;
-  var name = '';
-  RuleValue value = RuleValueBool();
-}
-
-class RuleValue {}
-
-class RuleValueBool extends RuleValue {
-  var value = false;
-}
-
-class RuleValueArrStr extends RuleValue {
-  var value = '';
-  var options = <String>[];
-}
-
 class SettingsController extends GetxController {
   final rules = HashMap<int, Rule>().obs;
 
@@ -36,7 +19,7 @@ class SettingsController extends GetxController {
             ..id = e.arrId
             ..name = e.arName
             ..value = e.arType == 1
-                ? (RuleValueBool()..value = e.isLock)
+                ? (RuleValueBool()..value = e.arValue == 'true')
                 : (RuleValueArrStr()
                   ..value = e.arValue
                   ..options =
@@ -70,7 +53,10 @@ class DialogSettings extends GetView<SettingsController> {
                         width: double.infinity,
                         height: 38,
                         child: const Text('确认'),
-                        onPressed: () {}))
+                        onPressed: () {
+                          final r = controller.rules.value.values;
+                          Get.back(result: r);
+                        }))
               ],
             ),
           );
@@ -130,7 +116,7 @@ class _RuleElem extends GetView<SettingsController> {
     return Row(
       mainAxisSize: MainAxisSize.min,
       children: [
-        SizedBox(width: 84, child: Text(data.name, textAlign: TextAlign.end)),
+        SizedBox(width: 110, child: Text(data.name, textAlign: TextAlign.end)),
         const SizedBox(width: 22),
         option!,
       ],

+ 9 - 2
app_business/lib/view/home/event_manage/event_manage.dart

@@ -397,7 +397,14 @@ class EventTitle extends GetView<EventManagerController> {
                         onPressed: data.isAllowEdit
                             ? () async {
                                 final r = await showEventSettingsDialog(data);
-                                if (r != null) {}
+                                if (r != null) {
+                                  final msg =
+                                      await controller.eventSettingsEdit(r);
+                                  if (context.mounted) {
+                                    ScaffoldMessenger.of(context).showSnackBar(
+                                        SnackBar(content: Text(msg)));
+                                  }
+                                }
                               }
                             : null,
                         child: const Text('设置')),
@@ -437,6 +444,6 @@ class EventTitle extends GetView<EventManagerController> {
   }
 }
 
-Future<EventRegisterInfo?> showEventSettingsDialog(EventInManage event) async {
+Future<Iterable<Rule>?> showEventSettingsDialog(EventInManage event) async {
   return await Get.dialog(const DialogSettings(), arguments: event.id);
 }

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

@@ -154,6 +154,15 @@ class EventManagerController extends GetxController {
       ..name = e.cName);
   }
 
+  Future<String> eventSettingsEdit(Iterable<Rule> rules) async {
+    try {
+      await _api.eventSettingsRulesSave(rules);
+      return '设置成功';
+    } catch (e) {
+      return '设置失败:$e';
+    }
+  }
+
   Future<void> routeAlloc(UserInManage user, RouteInfo route) async {
     debug('选择路线 ${route.name}');
     await _api.eventUserAllocRoute(user.checkId, route.id);