chooseVisitTimeContent_state.dart 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import 'package:shared/utils/date_time_utils.dart';
  2. import 'package:widgets/load_state_layout.dart';
  3. import 'visitTimeType.dart';
  4. class ChooseVisitTimeContentState{
  5. // 当前所选中的所有时间段集合
  6. List<VisitTimeContentItem> get allSelectedTimeList => visitTimeList.where((item) => item.isChecked??false).toList();
  7. //页面 LoadView 状态的展示
  8. LoadState loadingState;
  9. String? errorMessage;
  10. // 是否可多选
  11. bool? isMultiSelect;
  12. List<VisitTimeContentItem> visitTimeList = [];
  13. String currentDate = DateTimeUtils.formatDate(DateTime.now(), format: "yyyy-MM-dd");
  14. ChooseVisitTimeContentState({
  15. this.loadingState = LoadState.State_Loading,
  16. this.errorMessage,
  17. this.isMultiSelect = false,
  18. required this.currentDate,
  19. List<VisitTimeContentItem>? visitTimeList,
  20. }) {
  21. this.visitTimeList = visitTimeList ?? [];
  22. }
  23. ChooseVisitTimeContentState copyWith({
  24. LoadState? loadingState,
  25. String? errorMessage,
  26. bool? isMultiSelect,
  27. List<VisitTimeContentItem>? visitTimeList,
  28. String? currentDate,
  29. }) {
  30. return ChooseVisitTimeContentState(
  31. loadingState: loadingState ?? this.loadingState,
  32. errorMessage: errorMessage ?? this.errorMessage,
  33. isMultiSelect: isMultiSelect ?? this.isMultiSelect,
  34. visitTimeList: visitTimeList ?? this.visitTimeList,
  35. currentDate: currentDate ?? this.currentDate,
  36. );
  37. }
  38. }
  39. class VisitTimeContentItem{
  40. int? id;
  41. String? timeText;
  42. String? time;
  43. bool? urgent;
  44. bool? holiday;
  45. bool? night;
  46. bool? isChecked;
  47. bool? enable;
  48. VisitTimeContentItem({
  49. this.id,
  50. this.timeText,
  51. this.time,
  52. this.urgent,
  53. this.holiday,
  54. this.night,
  55. this.isChecked = false,
  56. this.enable = false,
  57. });
  58. VisitTimeContentItem copyWith({
  59. String? name,
  60. int? id,
  61. Map<String, dynamic>? type,
  62. bool? isChecked,
  63. bool? enable,
  64. }){
  65. return VisitTimeContentItem(
  66. id: id??this.id,
  67. timeText: timeText??this.timeText,
  68. time: time??this.time,
  69. urgent: urgent??this.urgent,
  70. holiday: holiday??this.holiday,
  71. night: night??this.night,
  72. isChecked: isChecked??this.isChecked,
  73. enable: enable??this.enable,
  74. );
  75. }
  76. }