diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index 599850bf..f667fd50 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -236,13 +236,15 @@ class DoorLockLogLogic extends BaseGetXController { lockId: state.keyInfos.value.lockId!, lockEventType: state.dropdownValue.value, pageNo: pageNo, - pageSize: 1000, + pageSize: 100, startDate: state.startDate.value, endDate: state.endDate.value); if (entity.errorCode!.codeIsSuccessful) { // 更新数据列表 state.lockLogItemList.addAll(entity.data!.itemList!); state.lockLogItemList.refresh(); + state.weekEventList.addAll(entity.data!.itemList!); + state.weekEventList.refresh(); // 更新页码 pageNo++; } diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index 00578350..fbdb1aac 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -192,7 +192,8 @@ class _DoorLockLogPageState extends State with RouteAware { color: Colors.white, borderRadius: BorderRadius.circular(16.w), ), - child: Obx(() => EasyRefreshTool( + child: Obx( + () => EasyRefreshTool( onRefresh: () async { logic.mockNetworkDataRequest(isRefresh: true); }, @@ -216,14 +217,19 @@ class _DoorLockLogPageState extends State with RouteAware { ), ), ) - : NoData())), + : NoData(), + ), + ), ); } - String formatTimestampToHHmm(int timestampMs) { - // 1. 将毫秒时间戳转换为秒(DateTime 需要秒级时间戳) - int timestampSec = timestampMs ~/ 1000; + String formatTimestampToDateTimeYYYYMMDD(int timestampMs) { + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestampMs); + DateFormat formatter = DateFormat('MM${'月'.tr}dd${'日'.tr}'); // 格式:2025-08-18 14:30 + return formatter.format(dateTime); + } + String formatTimestampToHHmm(int timestampMs) { // 2. 创建 DateTime 对象 DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestampMs); @@ -368,6 +374,12 @@ class _DoorLockLogPageState extends State with RouteAware { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + '${formatTimestampToDateTimeYYYYMMDD(timelineData.operateDate!)}', + style: TextStyle( + + fontSize: 20.sp, + )), // 使用 SingleChildScrollView 实现横向滚动 SingleChildScrollView( scrollDirection: Axis.horizontal, // 横向滚动 @@ -569,7 +581,7 @@ class _DoorLockLogPageState extends State with RouteAware { Widget _buildWeekCalendar() { return Obx(() { - final list = state.lockLogItemList.value; + final list = state.weekEventList.value; final dateSet = list .map((e) => DateTime.fromMillisecondsSinceEpoch(e.operateDate!)) .map((dt) => dt.withoutTime) // 转为年月日 @@ -579,9 +591,21 @@ class _DoorLockLogPageState extends State with RouteAware { hasData: (DateTime date) { return dateSet.contains(date.withoutTime); }, - onDateSelected: (DateTime date) {}, - onWeekChanged: (DateTime start, DateTime end) { + onDateSelected: (DateTime date) async { + print('外部收到选中: $date'); + state.operateDate = date.millisecondsSinceEpoch; + state.startDate.value = + DateTime(date.year, date.month, date.day).millisecondsSinceEpoch; + state.endDate.value = + DateTime(date.year, date.month, date.day, 23, 59, 59, 999) + .millisecondsSinceEpoch; + await logic.mockNetworkDataRequest(isRefresh: true); + }, + onWeekChanged: (DateTime start, DateTime end) { + state.startDate.value = start.millisecondsSinceEpoch; + state.endDate.value = end.millisecondsSinceEpoch; + logic.mockNetworkDataRequest(isRefresh: true); }, ); }); diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart index 0732970f..69ab634f 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart @@ -17,7 +17,9 @@ class DoorLockLogState { final Rx keyInfos = LockListInfoItemEntity().obs; final RxList lockLogItemList = [].obs; - final RxList eventList = + final RxList weekEventList = + [].obs; + final RxList dayEventList = [].obs; final AdvancedCalendarController calendarControllerToday = AdvancedCalendarController.today(); @@ -28,14 +30,13 @@ class DoorLockLogState { DateTime(2024, 10, 10), ]; -// 获取当前月份的第一天 00:00:00.000 - final RxInt startDate = DateTime(DateTime.now().year, DateTime.now().month, 1) - .millisecondsSinceEpoch - .obs; - -// 获取当前月份的最后一天 23:59:59.999 + final RxInt startDate = + DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day) + .millisecondsSinceEpoch + .obs; final RxInt endDate = DateTime( - DateTime.now().year, DateTime.now().month + 1, 0, 23, 59, 59, 999) + DateTime.now().year, DateTime.now().month, DateTime.now().day + 1) + .subtract(const Duration(milliseconds: 1)) .millisecondsSinceEpoch .obs;