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
e0fb3687
Commit
e0fb3687
authored
Jun 29, 2026
by
胡曲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bugs
parent
7ba2abc6
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
73 additions
and
71 deletions
+73
-71
abnormal_detail_view.dart
lib/views/home/abnormal/abnormal_detail_view.dart
+16
-7
abnormal_list_cubit.dart
lib/views/home/abnormal_list/cubit/abnormal_list_cubit.dart
+7
-38
home_index_cubit.dart
lib/views/home/index/cubit/home_index_cubit.dart
+13
-5
index_view.dart
lib/views/home/index/index_view.dart
+2
-2
voltage_operate_block.dart
lib/views/home/index/widget/voltage_operate_block.dart
+9
-2
inspection_topology_cubit.dart
.../inspection_topology/cubit/inspection_topology_cubit.dart
+1
-1
report_index_cubit.dart
lib/views/report/index/cubit/report_index_cubit.dart
+10
-4
index_view.dart
lib/views/report/index/index_view.dart
+1
-1
service_index_cubit.dart
lib/views/service/index/cubit/service_index_cubit.dart
+13
-10
index_view.dart
lib/views/service/index/index_view.dart
+1
-1
No files found.
lib/views/home/abnormal/abnormal_detail_view.dart
View file @
e0fb3687
...
@@ -27,17 +27,24 @@ class AbnormalDetailView extends StatelessWidget {
...
@@ -27,17 +27,24 @@ class AbnormalDetailView extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
BlocProvider
(
return
BlocProvider
(
create:
(
_
)
=>
AbnormalCubit
(
alertId:
alertId
),
create:
(
_
)
=>
AbnormalCubit
(
alertId:
alertId
),
child:
Scaffold
(
child:
Builder
(
backgroundColor:
const
Color
.
fromRGBO
(
242
,
243
,
245
,
1
),
builder:
(
context
)
=>
PopScope
(
appBar:
AppBar
(
canPop:
false
,
onPopInvokedWithResult:
(
didPop
,
_
)
{
if
(!
didPop
)
{
final
cubit
=
context
.
read
<
AbnormalCubit
>();
Navigator
.
of
(
context
).
pop
(
cubit
.
state
.
isHandled
);
}
},
child:
Scaffold
(
backgroundColor:
const
Color
.
fromRGBO
(
242
,
243
,
245
,
1
),
appBar:
AppBar
(
backgroundColor:
Colors
.
white
,
backgroundColor:
Colors
.
white
,
elevation:
0
,
elevation:
0
,
leading:
IconButton
(
leading:
IconButton
(
icon:
const
Icon
(
Icons
.
arrow_back_ios
,
icon:
const
Icon
(
Icons
.
arrow_back_ios
,
color:
Color
.
fromRGBO
(
100
,
116
,
139
,
1
)),
color:
Color
.
fromRGBO
(
100
,
116
,
139
,
1
)),
onPressed:
()
{
onPressed:
()
=>
context
.
maybePop
(),
context
.
popRoute
();
},
),
),
title:
Text
(
title:
Text
(
'查看告警详情'
,
'查看告警详情'
,
...
@@ -49,7 +56,7 @@ class AbnormalDetailView extends StatelessWidget {
...
@@ -49,7 +56,7 @@ class AbnormalDetailView extends StatelessWidget {
),
),
centerTitle:
true
,
centerTitle:
true
,
),
),
body:
BlocBuilder
<
AbnormalCubit
,
AbnormalState
>(
body:
BlocBuilder
<
AbnormalCubit
,
AbnormalState
>(
builder:
(
context
,
state
)
{
builder:
(
context
,
state
)
{
if
(
state
.
isLoading
)
{
if
(
state
.
isLoading
)
{
return
const
Center
(
child:
CircularProgressIndicator
(
color:
Color
.
fromRGBO
(
66
,
165
,
245
,
1.0
)));
return
const
Center
(
child:
CircularProgressIndicator
(
color:
Color
.
fromRGBO
(
66
,
165
,
245
,
1.0
)));
...
@@ -90,6 +97,8 @@ class AbnormalDetailView extends StatelessWidget {
...
@@ -90,6 +97,8 @@ class AbnormalDetailView extends StatelessWidget {
);
);
},
},
),
),
),
),
),
),
);
);
}
}
...
...
lib/views/home/abnormal_list/cubit/abnormal_list_cubit.dart
View file @
e0fb3687
...
@@ -81,44 +81,13 @@ class AbnormalListCubit extends Cubit<AbnormalListState> {
...
@@ -81,44 +81,13 @@ class AbnormalListCubit extends Cubit<AbnormalListState> {
Future
<
void
>
onAlarmItemTap
(
AlarmItem
item
,
BuildContext
context
)
async
{
Future
<
void
>
onAlarmItemTap
(
AlarmItem
item
,
BuildContext
context
)
async
{
final
alertId
=
int
.
tryParse
(
item
.
id
)
??
0
;
final
alertId
=
int
.
tryParse
(
item
.
id
)
??
0
;
final
handled
=
await
context
.
pushRoute
(
await
context
.
pushRoute
(
AbnormalDetailRoute
(
alertId:
alertId
,
alarmStatus:
item
.
status
),
AbnormalDetailRoute
(
alertId:
alertId
,
alarmStatus:
item
.
status
),
);
).
then
((
value
)
{
// if (handled != null && handled is bool && handled == true) {
if
(
value
!=
null
&&
value
is
bool
&&
value
)
{
// _updateItemStatus(item.id);
// 详情页已处理,返回刷新数据
// }
_pagingController
?.
refresh
();
}
}
});
/// 在分页列表中定位并更新单条记录的状态(不重新请求接口)
void
_updateItemStatus
(
String
alertId
)
{
final
state
=
_pagingController
?.
value
;
if
(
state
==
null
)
return
;
final
pages
=
state
.
pages
;
if
(
pages
==
null
)
return
;
var
found
=
false
;
final
newPages
=
pages
.
map
((
page
)
{
if
(
found
)
return
page
;
final
index
=
page
.
indexWhere
((
i
)
=>
i
.
id
==
alertId
);
if
(
index
==
-
1
)
return
page
;
found
=
true
;
final
newPage
=
List
<
AlarmItem
>.
from
(
page
);
newPage
[
index
]
=
AlarmItem
(
id:
newPage
[
index
].
id
,
title:
newPage
[
index
].
title
,
deviceInfo:
newPage
[
index
].
deviceInfo
,
alarmTime:
newPage
[
index
].
alarmTime
,
processTime:
newPage
[
index
].
processTime
,
status:
AlarmStatus
.
processed
,
level:
newPage
[
index
].
level
,
alertIcon:
newPage
[
index
].
alertIcon
,
);
return
newPage
;
}).
toList
();
if
(
found
)
{
_pagingController
?.
value
=
state
.
copyWith
(
pages:
newPages
);
}
}
}
}
}
lib/views/home/index/cubit/home_index_cubit.dart
View file @
e0fb3687
...
@@ -12,6 +12,8 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
...
@@ -12,6 +12,8 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
final
AlertDashboardService
_service
;
final
AlertDashboardService
_service
;
final
AlertDetailService
_alertDetailService
;
final
AlertDetailService
_alertDetailService
;
DateTime
?
_lastLoadTime
;
HomeIndexCubit
({
HomeIndexCubit
({
AlertDashboardService
?
service
,
AlertDashboardService
?
service
,
AlertDetailService
?
alertDetailService
,
AlertDetailService
?
alertDetailService
,
...
@@ -24,10 +26,11 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
...
@@ -24,10 +26,11 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
repository:
AlertDetailRepository
(),
repository:
AlertDetailRepository
(),
),
),
super
(
const
HomeIndexState
())
{
super
(
const
HomeIndexState
())
{
loadDa
shboard
();
loadDa
ta
();
}
}
Future
<
void
>
loadDashboard
()
async
{
Future
<
void
>
loadData
()
async
{
_lastLoadTime
=
DateTime
.
now
();
emit
(
state
.
copyWith
(
isLoading:
true
,
error:
null
));
emit
(
state
.
copyWith
(
isLoading:
true
,
error:
null
));
try
{
try
{
final
dashboard
=
await
_service
.
getDashboard
();
final
dashboard
=
await
_service
.
getDashboard
();
...
@@ -37,8 +40,13 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
...
@@ -37,8 +40,13 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
}
}
}
}
Future
<
void
>
reloadDashboard
()
async
{
/// 切回页面时调用,距上次加载不足 30 秒则跳过
loadDashboard
();
void
reloadDataIfStale
()
{
if
(
_lastLoadTime
!=
null
&&
DateTime
.
now
().
difference
(
_lastLoadTime
!)
<
const
Duration
(
seconds:
30
))
{
return
;
}
loadData
();
}
}
/// 处理告警
/// 处理告警
...
@@ -48,7 +56,7 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
...
@@ -48,7 +56,7 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
try
{
try
{
await
_alertDetailService
.
handleAlert
(
alertId:
alertId
);
await
_alertDetailService
.
handleAlert
(
alertId:
alertId
);
emit
(
state
.
copyWith
(
isHandlingAlert:
false
));
emit
(
state
.
copyWith
(
isHandlingAlert:
false
));
await
reloadDashboard
();
await
loadData
();
}
catch
(
e
)
{
}
catch
(
e
)
{
emit
(
state
.
copyWith
(
isHandlingAlert:
false
,
error:
e
.
toString
()));
emit
(
state
.
copyWith
(
isHandlingAlert:
false
,
error:
e
.
toString
()));
rethrow
;
rethrow
;
...
...
lib/views/home/index/index_view.dart
View file @
e0fb3687
...
@@ -45,7 +45,7 @@ class _HomeViewState extends State<HomeView> with AutoRouteAwareStateMixin<HomeV
...
@@ -45,7 +45,7 @@ class _HomeViewState extends State<HomeView> with AutoRouteAwareStateMixin<HomeV
if
(!
mounted
)
return
;
if
(!
mounted
)
return
;
if
(
_tabsRouter
?.
activeIndex
==
0
)
{
if
(
_tabsRouter
?.
activeIndex
==
0
)
{
context
.
read
<
HomeIndexCubit
>().
reloadDa
shboard
();
context
.
read
<
HomeIndexCubit
>().
reloadDa
taIfStale
();
}
}
}
}
...
@@ -77,7 +77,7 @@ class _HomeViewState extends State<HomeView> with AutoRouteAwareStateMixin<HomeV
...
@@ -77,7 +77,7 @@ class _HomeViewState extends State<HomeView> with AutoRouteAwareStateMixin<HomeV
SizedBox
(
height:
16
.
h
),
SizedBox
(
height:
16
.
h
),
ElevatedButton
(
ElevatedButton
(
onPressed:
()
=>
onPressed:
()
=>
context
.
read
<
HomeIndexCubit
>().
reloadDashboard
(),
context
.
read
<
HomeIndexCubit
>().
loadData
(),
child:
const
Text
(
'重试'
),
child:
const
Text
(
'重试'
),
),
),
],
],
...
...
lib/views/home/index/widget/voltage_operate_block.dart
View file @
e0fb3687
...
@@ -135,8 +135,15 @@ class VoltageOperateBlock extends StatelessWidget {
...
@@ -135,8 +135,15 @@ class VoltageOperateBlock extends StatelessWidget {
),
),
Expanded
(
Expanded
(
child:
GestureDetector
(
child:
GestureDetector
(
onTap:
()
{
onTap:
()
async
{
context
.
pushRoute
(
AbnormalDetailRoute
(
alertId:
alertId
,
alarmStatus:
AlarmStatus
.
pending
));
await
context
.
pushRoute
(
AbnormalDetailRoute
(
alertId:
alertId
,
alarmStatus:
AlarmStatus
.
pending
)
).
then
((
value
)
{
if
(
value
!=
null
&&
value
is
bool
&&
value
)
{
context
.
read
<
HomeIndexCubit
>().
loadData
();
}
});
},
},
child:
Container
(
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
vertical:
20
.
h
),
padding:
EdgeInsets
.
symmetric
(
vertical:
20
.
h
),
...
...
lib/views/home/inspection_topology/cubit/inspection_topology_cubit.dart
View file @
e0fb3687
...
@@ -37,7 +37,7 @@ class InspectionTopologyCubit extends Cubit<InspectionTopologyState> {
...
@@ -37,7 +37,7 @@ class InspectionTopologyCubit extends Cubit<InspectionTopologyState> {
void
_emitFromTopology
(
DeviceTopologyBO
topology
)
{
void
_emitFromTopology
(
DeviceTopologyBO
topology
)
{
final
info
=
topology
.
deviceInfo
;
final
info
=
topology
.
deviceInfo
;
final
treeNodes
=
topology
.
treeNodes
;
final
treeNodes
=
topology
.
treeNodes
.
take
(
11
).
toList
()
;
if
(
treeNodes
.
isEmpty
)
{
if
(
treeNodes
.
isEmpty
)
{
emit
(
InspectionTopologyState
(
emit
(
InspectionTopologyState
(
...
...
lib/views/report/index/cubit/report_index_cubit.dart
View file @
e0fb3687
...
@@ -9,11 +9,11 @@ import 'package:smart_hotel_app/views/report/index/cubit/report_index_state.dart
...
@@ -9,11 +9,11 @@ import 'package:smart_hotel_app/views/report/index/cubit/report_index_state.dart
class
ReportIndexCubit
extends
Cubit
<
ReportIndexState
>
{
class
ReportIndexCubit
extends
Cubit
<
ReportIndexState
>
{
final
DashboardService
_service
;
final
DashboardService
_service
;
DateTime
?
_lastLoadTime
;
ReportIndexCubit
({
DashboardService
?
service
})
ReportIndexCubit
({
DashboardService
?
service
})
:
_service
=
service
??
DashboardService
(
repository:
DashboardRepository
()),
:
_service
=
service
??
DashboardService
(
repository:
DashboardRepository
()),
super
(
const
ReportIndexState
())
{
super
(
const
ReportIndexState
());
// loadData();
}
Future
<
void
>
loadData
()
async
{
Future
<
void
>
loadData
()
async
{
emit
(
state
.
copyWith
(
isLoading:
true
,
clearError:
true
));
emit
(
state
.
copyWith
(
isLoading:
true
,
clearError:
true
));
...
@@ -25,7 +25,13 @@ class ReportIndexCubit extends Cubit<ReportIndexState> {
...
@@ -25,7 +25,13 @@ class ReportIndexCubit extends Cubit<ReportIndexState> {
}
}
}
}
Future
<
void
>
reloadData
()
async
{
/// 切回页面时调用,距上次加载不足 30 秒则跳过
void
reloadDataIfStale
()
{
if
(
_lastLoadTime
!=
null
&&
DateTime
.
now
().
difference
(
_lastLoadTime
!)
<
const
Duration
(
seconds:
30
))
{
return
;
}
_lastLoadTime
=
DateTime
.
now
();
loadData
();
loadData
();
}
}
...
...
lib/views/report/index/index_view.dart
View file @
e0fb3687
...
@@ -43,7 +43,7 @@ class _ReportIndexViewState extends State<ReportIndexView> with AutoRouteAwareSt
...
@@ -43,7 +43,7 @@ class _ReportIndexViewState extends State<ReportIndexView> with AutoRouteAwareSt
if
(!
mounted
)
return
;
if
(!
mounted
)
return
;
if
(
_tabsRouter
?.
activeIndex
==
2
)
{
if
(
_tabsRouter
?.
activeIndex
==
2
)
{
context
.
read
<
ReportIndexCubit
>().
reloadData
();
context
.
read
<
ReportIndexCubit
>().
reloadData
IfStale
();
}
}
}
}
...
...
lib/views/service/index/cubit/service_index_cubit.dart
View file @
e0fb3687
...
@@ -11,23 +11,26 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
...
@@ -11,23 +11,26 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
final
RoomStatisticsService
_statisticsService
;
final
RoomStatisticsService
_statisticsService
;
List
<
FloorAreaBO
>
_floorAreasCache
=
[];
List
<
FloorAreaBO
>
_floorAreasCache
=
[];
DateTime
?
_lastLoadTime
;
ServiceIndexCubit
()
ServiceIndexCubit
()
:
_roomService
=
RoomService
(
repository:
RoomRepository
()),
:
_roomService
=
RoomService
(
repository:
RoomRepository
()),
_statisticsService
=
RoomStatisticsService
(
_statisticsService
=
RoomStatisticsService
(
repository:
RoomStatisticsRepository
(),
repository:
RoomStatisticsRepository
(),
),
),
super
(
const
ServiceIndexState
())
{
super
(
const
ServiceIndexState
());
// _init();
}
// Future<void> _init() async {
/// 切回页面时调用,距上次加载不足 30 秒则跳过
// await Future.wait([
void
reloadDataIfStale
()
{
// loadStatistics(),
if
(
_lastLoadTime
!=
null
&&
// loadFloorAndAreas(),
DateTime
.
now
().
difference
(
_lastLoadTime
!)
<
const
Duration
(
seconds:
30
))
{
// ]);
return
;
// }
}
_lastLoadTime
=
DateTime
.
now
();
loadData
();
}
Future
<
void
>
reloadAll
()
async
{
Future
<
void
>
loadData
()
async
{
emit
(
state
.
copyWith
(
isLoading:
true
,
error:
null
));
emit
(
state
.
copyWith
(
isLoading:
true
,
error:
null
));
try
{
try
{
await
Future
.
wait
([
await
Future
.
wait
([
...
...
lib/views/service/index/index_view.dart
View file @
e0fb3687
...
@@ -40,7 +40,7 @@ class _ServiceIndexViewState extends State<ServiceIndexView> with AutoRouteAware
...
@@ -40,7 +40,7 @@ class _ServiceIndexViewState extends State<ServiceIndexView> with AutoRouteAware
if
(!
mounted
)
return
;
if
(!
mounted
)
return
;
if
(
_tabsRouter
?.
activeIndex
==
1
)
{
if
(
_tabsRouter
?.
activeIndex
==
1
)
{
context
.
read
<
ServiceIndexCubit
>().
reload
All
();
context
.
read
<
ServiceIndexCubit
>().
reload
DataIfStale
();
}
}
}
}
...
...
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