event_manage.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import 'package:app_business/service/api.dart';
  2. import 'package:app_business/view/home/dialog_event_register.dart';
  3. import 'package:pretty_qr_code/pretty_qr_code.dart';
  4. import 'package:track_common/widget.dart';
  5. import 'package:track_common/widget/prelude.dart';
  6. import 'event_manage_controller.dart';
  7. class EventManage extends GetView<EventManagerController> {
  8. const EventManage({super.key});
  9. @override
  10. Widget build(BuildContext context) {
  11. return Level2View(
  12. level1: level1(),
  13. level2: level2(),
  14. level1Title: '赛事列表',
  15. level1Action: wDate(context),
  16. level2Title: '用户列表',
  17. level2SubTitle: Obx(() => Text(
  18. controller.selected?.name != null
  19. ? '(${controller.selected!.name})'
  20. : '',
  21. style: const TextStyle(color: Colors.grey, fontSize: 14.22),
  22. )));
  23. }
  24. Widget wDate(BuildContext context) {
  25. return GestureDetector(
  26. onTap: () => _onTapDate(context),
  27. child: Obx(() => Container(
  28. height: 22.04,
  29. padding: const EdgeInsets.symmetric(horizontal: 8),
  30. decoration: BoxDecoration(
  31. border:
  32. Border.all(color: const Color(0xffe3e3e3), width: 0.71),
  33. borderRadius: BorderRadius.circular(2.13)),
  34. child: Text(controller.dateStr),
  35. )));
  36. }
  37. Future<void> _onTapDate(BuildContext context) async {
  38. final date = await showDatePicker(
  39. context: context,
  40. initialDate: controller.filterDate.value,
  41. firstDate: DateTime.now(),
  42. lastDate: DateTime.now().add(365.days));
  43. if (date != null) {
  44. controller.filterDate.value = date;
  45. controller.flushList();
  46. }
  47. }
  48. Widget level1() {
  49. return Obx(() => ListView(
  50. children: controller.eventList
  51. .map((e) => EventTitle(
  52. data: e,
  53. selected: controller.selectedId.value == e.id,
  54. onTap: () => controller.selectedId.value = e.id,
  55. ))
  56. .toList()));
  57. }
  58. Widget level2() {
  59. return Column(
  60. children: [
  61. Expanded(
  62. child: Obx(
  63. () => LineChart(titles: rightTitles(), children: rightUsers())))
  64. ],
  65. );
  66. }
  67. Iterable<LineChartTitle> rightTitles() {
  68. return [
  69. // LineChartTitle(
  70. // title: Checkbox(value: true, onChanged: (v) {}), width: 32),
  71. const LineChartTitle(title: Text('序号'), width: 42),
  72. const LineChartTitle(title: Text('用户名'), width: 70),
  73. const LineChartTitle(title: Text('手机号'), flex: 1),
  74. const LineChartTitle(title: Text('签到时间'), flex: 1),
  75. const LineChartTitle(title: Text('删除'), width: 67),
  76. ];
  77. }
  78. Iterable<LineChartElem> rightUsers() {
  79. return controller.userList.indexed.map((e) {
  80. final (i, one) = e;
  81. return LineChartElem([
  82. // Checkbox(value: false, onChanged: (v) {}),
  83. Text('${i + 1}'),
  84. Text(one.name),
  85. Text(one.phone),
  86. Text(one.checkTime),
  87. SizedBox(
  88. width: 51.2,
  89. height: 22.76,
  90. child: SmallButton(
  91. color: const Color(0xffff0000),
  92. onPressed: () {
  93. controller.deleteSignIn(one);
  94. },
  95. child: const Text('删除'),
  96. ))
  97. ]);
  98. });
  99. }
  100. }
  101. class EventTitle extends GetView<EventManagerController> {
  102. final bool selected;
  103. final EventInManage data;
  104. final VoidCallback onTap;
  105. const EventTitle(
  106. {super.key,
  107. required this.selected,
  108. required this.data,
  109. required this.onTap});
  110. @override
  111. Widget build(BuildContext context) {
  112. var children = <Widget>[
  113. AppTitleList(
  114. title: data.name,
  115. tail: Text('${data.userList.length}'),
  116. isSelected: selected,
  117. onTap: onTap,
  118. )
  119. ];
  120. if (selected) {
  121. children.add(const SizedBox(height: 2));
  122. children.add(Container(
  123. decoration: const BoxDecoration(
  124. color: Color(0xfff1f1f1),
  125. borderRadius: BorderRadius.only(
  126. bottomLeft: Radius.circular(14.22),
  127. bottomRight: Radius.circular(14.22))),
  128. padding: const EdgeInsets.all(16.3),
  129. width: 221.87,
  130. child: Column(
  131. mainAxisSize: MainAxisSize.min,
  132. children: [
  133. Row(
  134. children: [
  135. DarkButton(
  136. onPressed: data.isAllowDel
  137. ? () => controller.deleteEvent(data)
  138. : null,
  139. child: const Text('删除')),
  140. const Spacer(),
  141. DarkButton(
  142. color: Colors.blue,
  143. onPressed: data.isAllowEdit
  144. ? () async {
  145. final r = await showEventEditDialog(
  146. controller.mapId!,
  147. EventRegisterInfo()..name = data.name);
  148. if (r != null) {
  149. controller.eventEdit(data.id, r);
  150. }
  151. }
  152. : null,
  153. child: const Text('修改')),
  154. ],
  155. ),
  156. const SizedBox(height: 24),
  157. SizedBox.square(
  158. dimension: 128, child: PrettyQrView.data(data: data.qrCode)),
  159. const SizedBox(height: 12),
  160. const Text(
  161. '用彩图奔跑APP扫码签到',
  162. style: TextStyle(color: Colors.red, fontSize: 14.22),
  163. )
  164. ],
  165. ),
  166. ));
  167. }
  168. return Column(
  169. mainAxisSize: MainAxisSize.min,
  170. children: children,
  171. );
  172. }
  173. }