fix:调整操作记录中UI(未完成)

This commit is contained in:
liyi 2025-08-18 18:17:41 +08:00
parent c32f052cb0
commit f48e7c8274
3 changed files with 44 additions and 17 deletions

View File

@ -236,13 +236,15 @@ class DoorLockLogLogic extends BaseGetXController {
lockId: state.keyInfos.value.lockId!, lockId: state.keyInfos.value.lockId!,
lockEventType: state.dropdownValue.value, lockEventType: state.dropdownValue.value,
pageNo: pageNo, pageNo: pageNo,
pageSize: 1000, pageSize: 100,
startDate: state.startDate.value, startDate: state.startDate.value,
endDate: state.endDate.value); endDate: state.endDate.value);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// //
state.lockLogItemList.addAll(entity.data!.itemList!); state.lockLogItemList.addAll(entity.data!.itemList!);
state.lockLogItemList.refresh(); state.lockLogItemList.refresh();
state.weekEventList.addAll(entity.data!.itemList!);
state.weekEventList.refresh();
// //
pageNo++; pageNo++;
} }

View File

@ -192,7 +192,8 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(16.w), borderRadius: BorderRadius.circular(16.w),
), ),
child: Obx(() => EasyRefreshTool( child: Obx(
() => EasyRefreshTool(
onRefresh: () async { onRefresh: () async {
logic.mockNetworkDataRequest(isRefresh: true); logic.mockNetworkDataRequest(isRefresh: true);
}, },
@ -216,14 +217,19 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
), ),
), ),
) )
: NoData())), : NoData(),
),
),
); );
} }
String formatTimestampToHHmm(int timestampMs) { String formatTimestampToDateTimeYYYYMMDD(int timestampMs) {
// 1. DateTime DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestampMs);
int timestampSec = timestampMs ~/ 1000; DateFormat formatter = DateFormat('MM${''.tr}dd${''.tr}'); // 2025-08-18 14:30
return formatter.format(dateTime);
}
String formatTimestampToHHmm(int timestampMs) {
// 2. DateTime // 2. DateTime
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestampMs); DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestampMs);
@ -368,6 +374,12 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text(
'${formatTimestampToDateTimeYYYYMMDD(timelineData.operateDate!)}',
style: TextStyle(
fontSize: 20.sp,
)),
// 使 SingleChildScrollView // 使 SingleChildScrollView
SingleChildScrollView( SingleChildScrollView(
scrollDirection: Axis.horizontal, // scrollDirection: Axis.horizontal, //
@ -569,7 +581,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
Widget _buildWeekCalendar() { Widget _buildWeekCalendar() {
return Obx(() { return Obx(() {
final list = state.lockLogItemList.value; final list = state.weekEventList.value;
final dateSet = list final dateSet = list
.map((e) => DateTime.fromMillisecondsSinceEpoch(e.operateDate!)) .map((e) => DateTime.fromMillisecondsSinceEpoch(e.operateDate!))
.map((dt) => dt.withoutTime) // .map((dt) => dt.withoutTime) //
@ -579,9 +591,21 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
hasData: (DateTime date) { hasData: (DateTime date) {
return dateSet.contains(date.withoutTime); return dateSet.contains(date.withoutTime);
}, },
onDateSelected: (DateTime date) {}, onDateSelected: (DateTime date) async {
onWeekChanged: (DateTime start, DateTime end) { 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);
}, },
); );
}); });

View File

@ -17,7 +17,9 @@ class DoorLockLogState {
final Rx<LockListInfoItemEntity> keyInfos = LockListInfoItemEntity().obs; final Rx<LockListInfoItemEntity> keyInfos = LockListInfoItemEntity().obs;
final RxList<DoorLockLogDataItem> lockLogItemList = final RxList<DoorLockLogDataItem> lockLogItemList =
<DoorLockLogDataItem>[].obs; <DoorLockLogDataItem>[].obs;
final RxList<DoorLockLogDataItem> eventList = final RxList<DoorLockLogDataItem> weekEventList =
<DoorLockLogDataItem>[].obs;
final RxList<DoorLockLogDataItem> dayEventList =
<DoorLockLogDataItem>[].obs; <DoorLockLogDataItem>[].obs;
final AdvancedCalendarController calendarControllerToday = final AdvancedCalendarController calendarControllerToday =
AdvancedCalendarController.today(); AdvancedCalendarController.today();
@ -28,14 +30,13 @@ class DoorLockLogState {
DateTime(2024, 10, 10), DateTime(2024, 10, 10),
]; ];
// 00:00:00.000 final RxInt startDate =
final RxInt startDate = DateTime(DateTime.now().year, DateTime.now().month, 1) DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day)
.millisecondsSinceEpoch .millisecondsSinceEpoch
.obs; .obs;
// 23:59:59.999
final RxInt endDate = DateTime( 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 .millisecondsSinceEpoch
.obs; .obs;