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!,
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++;
}

View File

@ -192,7 +192,8 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> 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<DoorLockLogPage> 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<DoorLockLogPage> with RouteAware {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'${formatTimestampToDateTimeYYYYMMDD(timelineData.operateDate!)}',
style: TextStyle(
fontSize: 20.sp,
)),
// 使 SingleChildScrollView
SingleChildScrollView(
scrollDirection: Axis.horizontal, //
@ -569,7 +581,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> 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<DoorLockLogPage> 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);
},
);
});

View File

@ -17,7 +17,9 @@ class DoorLockLogState {
final Rx<LockListInfoItemEntity> keyInfos = LockListInfoItemEntity().obs;
final RxList<DoorLockLogDataItem> lockLogItemList =
<DoorLockLogDataItem>[].obs;
final RxList<DoorLockLogDataItem> eventList =
final RxList<DoorLockLogDataItem> weekEventList =
<DoorLockLogDataItem>[].obs;
final RxList<DoorLockLogDataItem> dayEventList =
<DoorLockLogDataItem>[].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;