state.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:fis_jsonrpc/services/vitalContractRecord.m.dart';
  2. import 'package:get/get.dart';
  3. import 'package:vitalapp/architecture/defines.dart';
  4. import 'package:vitalapp/global.dart';
  5. import 'package:vitalapp/managers/interfaces/models/patient_model_dto.dart';
  6. import 'package:vitalapp/pages/controllers/paged_state_mixin.dart';
  7. class PatientListState with PagedStateMixin<PatientModelDTO> {
  8. static int _statisticTotalCountCache = 0;
  9. static int _statisticTodayCountCache = 0;
  10. PatientListState() {
  11. if (!kIsOnline) {
  12. _statisticTotalCount.value = _statisticTotalCountCache;
  13. _statisticTodayCount.value = _statisticTodayCountCache;
  14. }
  15. }
  16. final _now = DateTime.now();
  17. final RxInt _currentTabIndex = RxInt(0);
  18. final RxList<String> _offlineCodes = RxList<String>();
  19. final RxInt _statisticTotalCount = RxInt(0);
  20. final RxInt _statisticTodayCount = RxInt(0);
  21. final RxInt _selectBoxFilterFounder = RxInt(0);
  22. final Rx<ContractStateEnum?> _contractStateSelectedItem =
  23. Rx<ContractStateEnum?>(null);
  24. ContractStateEnum? get contractStateSelectedItem =>
  25. _contractStateSelectedItem.value;
  26. set contractStateSelectedItem(ContractStateEnum? val) =>
  27. _contractStateSelectedItem.value = val;
  28. int get selectBoxFilterFounder => _selectBoxFilterFounder.value;
  29. set selectBoxFilterFounder(int val) =>
  30. _selectBoxFilterFounder.updateValue(val);
  31. int get currentTabIndex => _currentTabIndex.value;
  32. set currentTabIndex(int val) => _currentTabIndex.updateValue(val);
  33. /// 离线code列表
  34. List<String> get offlineCodes => _offlineCodes.toList();
  35. set offlineCodes(List<String> val) => _offlineCodes.value = val;
  36. /// 离线数量
  37. int get offlineCount => offlineCodes.length;
  38. /// 查询结果总数
  39. int get queryResultTotalCount => offlineCount + totalCount;
  40. /// 居民总数
  41. int get statisticTotalCount => _statisticTotalCount.value;
  42. set statisticTotalCount(int val) {
  43. _statisticTotalCount.updateValue(val);
  44. _statisticTotalCountCache = val;
  45. }
  46. /// 今日新增数
  47. int get statisticTodayCount => _statisticTodayCount.value;
  48. set statisticTodayCount(int val) {
  49. _statisticTodayCount.updateValue(val);
  50. _statisticTodayCountCache = val;
  51. }
  52. late Rx<DateTime?> startTime =
  53. DateTime(_now.year - 1, _now.month, _now.day).obs; // >= 1年前00:00:00
  54. late Rx<DateTime?> endTime =
  55. DateTime(_now.year, _now.month, _now.day).obs; // < 第二天00:00:00
  56. }