Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart_hotel_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张宏
smart_hotel_app
Commits
378c338a
Commit
378c338a
authored
Jun 10, 2026
by
张宏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3
parent
66f73066
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
service_index_cubit.dart
lib/views/service/index/cubit/service_index_cubit.dart
+17
-6
room_management_block.dart
lib/views/service/index/widget/room_management_block.dart
+1
-0
No files found.
lib/views/service/index/cubit/service_index_cubit.dart
View file @
378c338a
...
@@ -7,6 +7,7 @@ import 'package:smart_hotel_app/models/bo/room_bo.dart';
...
@@ -7,6 +7,7 @@ import 'package:smart_hotel_app/models/bo/room_bo.dart';
class
ServiceIndexCubit
extends
Cubit
<
ServiceIndexState
>
{
class
ServiceIndexCubit
extends
Cubit
<
ServiceIndexState
>
{
final
RoomService
_roomService
;
final
RoomService
_roomService
;
final
Map
<
String
,
List
<
Map
<
String
,
dynamic
>>>
_roomCache
=
{};
final
Map
<
String
,
List
<
Map
<
String
,
dynamic
>>>
_roomCache
=
{};
List
<
FloorAreaBO
>
_floorAreasCache
=
[];
ServiceIndexCubit
()
ServiceIndexCubit
()
:
_roomService
=
RoomService
(
repository:
RoomRepository
()),
:
_roomService
=
RoomService
(
repository:
RoomRepository
()),
...
@@ -18,21 +19,18 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
...
@@ -18,21 +19,18 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
await
loadFloorAndAreas
();
await
loadFloorAndAreas
();
}
}
/// 加载楼层和区域信息
/// 加载楼层和区域信息
(仅进入页面时调用一次)
Future
<
void
>
loadFloorAndAreas
()
async
{
Future
<
void
>
loadFloorAndAreas
()
async
{
emit
(
state
.
copyWith
(
isLoading:
true
,
error:
null
));
emit
(
state
.
copyWith
(
isLoading:
true
,
error:
null
));
try
{
try
{
final
floorAreas
=
await
_roomService
.
getFloorAreas
();
final
floorAreas
=
await
_roomService
.
getFloorAreas
();
_floorAreasCache
=
floorAreas
;
final
floors
=
floorAreas
.
map
((
f
)
=>
{
f
.
floorId
:
f
.
floorId
.
toString
()}).
toList
();
final
floors
=
floorAreas
.
map
((
f
)
=>
{
f
.
floorId
:
f
.
floorId
.
toString
()}).
toList
();
final
areas
=
<
String
>{};
for
(
final
f
in
floorAreas
)
{
areas
.
addAll
(
f
.
areas
);
}
emit
(
state
.
copyWith
(
emit
(
state
.
copyWith
(
isLoading:
false
,
isLoading:
false
,
floors:
floors
,
floors:
floors
,
areas:
areas
.
toList
(),
));
));
// 默认选中第一个楼层,加载其房间数据
// 默认选中第一个楼层,加载其房间数据
...
@@ -40,6 +38,7 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
...
@@ -40,6 +38,7 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
final
firstFloor
=
floors
.
first
;
final
firstFloor
=
floors
.
first
;
final
firstFloorId
=
firstFloor
.
keys
.
first
;
final
firstFloorId
=
firstFloor
.
keys
.
first
;
final
firstFloorLabel
=
firstFloor
.
values
.
first
;
final
firstFloorLabel
=
firstFloor
.
values
.
first
;
_updateAreasForFloor
(
firstFloorLabel
);
selectFloor
(
firstFloorLabel
);
selectFloor
(
firstFloorLabel
);
await
loadRooms
(
floorId:
firstFloorId
);
await
loadRooms
(
floorId:
firstFloorId
);
}
}
...
@@ -48,6 +47,15 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
...
@@ -48,6 +47,15 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
}
}
}
}
/// 根据选中的楼层更新 areas
void
_updateAreasForFloor
(
String
floorLabel
)
{
final
matched
=
_floorAreasCache
.
where
(
(
f
)
=>
f
.
floorId
.
toString
()
==
floorLabel
,
);
final
areas
=
matched
.
isNotEmpty
?
matched
.
first
.
areas
:
<
String
>[];
emit
(
state
.
copyWith
(
areas:
areas
));
}
/// 加载房间状态列表
/// 加载房间状态列表
Future
<
void
>
loadRooms
({
Future
<
void
>
loadRooms
({
int
?
floorId
,
int
?
floorId
,
...
@@ -137,6 +145,9 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
...
@@ -137,6 +145,9 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
void
selectFloor
(
String
?
floor
)
{
void
selectFloor
(
String
?
floor
)
{
emit
(
state
.
copyWith
(
selectedFloor:
floor
));
emit
(
state
.
copyWith
(
selectedFloor:
floor
));
if
(
floor
!=
null
)
{
_updateAreasForFloor
(
floor
);
}
}
}
void
selectType
(
String
?
type
)
{
void
selectType
(
String
?
type
)
{
...
...
lib/views/service/index/widget/room_management_block.dart
View file @
378c338a
...
@@ -125,6 +125,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
...
@@ -125,6 +125,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
}
else
{
}
else
{
_selectedFloor
=
floorName
;
_selectedFloor
=
floorName
;
}
}
_selectedType
=
null
;
_searchController
.
clear
();
_searchController
.
clear
();
_searchText
=
''
;
_searchText
=
''
;
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment