fix:调整操作记录中UI(未完成)
This commit is contained in:
parent
c32f052cb0
commit
f48e7c8274
@ -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++;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user