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
97313115
Commit
97313115
authored
Jun 09, 2026
by
张宏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
。
parent
e4085511
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
28 deletions
+28
-28
alert_list_repository.dart
lib/repositories/alert_list_repository.dart
+6
-2
alert_list_service.dart
lib/services/alert_list_service.dart
+5
-2
abnormal_list_cubit.dart
lib/views/home/abnormal_list/cubit/abnormal_list_cubit.dart
+17
-12
abnormal_list_state.dart
lib/views/home/abnormal_list/cubit/abnormal_list_state.dart
+0
-12
index_view.dart
lib/views/home/abnormal_list/index_view.dart
+0
-0
No files found.
lib/repositories/alert_list_repository.dart
View file @
97313115
...
...
@@ -4,9 +4,13 @@ import '../models/bo/alert_list_bo.dart';
class
AlertListRepository
{
/// 获取告警列表
Future
<
ResponseModel
<
AlertListBO
>>
getList
()
{
Future
<
ResponseModel
<
AlertListBO
>>
getList
({
required
int
pageSize
,
required
int
pageNum
,
})
{
return
DioRequest
.
instance
.
get
<
AlertListBO
>(
'/app/alert/list'
,
'/app/alert/list'
,
queryParameters:
{
'pageSize'
:
pageSize
,
'pageNum'
:
pageNum
},
fromJsonT:
(
data
)
=>
AlertListBO
.
fromJson
(
data
as
Map
<
String
,
dynamic
>),
);
...
...
lib/services/alert_list_service.dart
View file @
97313115
...
...
@@ -7,8 +7,11 @@ class AlertListService {
AlertListService
({
required
AlertListRepository
repository
})
:
_repository
=
repository
;
Future
<
AlertListBO
>
getList
()
async
{
final
result
=
await
_repository
.
getList
();
Future
<
AlertListBO
>
getList
({
required
int
pageSize
,
required
int
pageNum
})
async
{
final
result
=
await
_repository
.
getList
(
pageSize:
pageSize
,
pageNum:
pageNum
,
);
if
(
result
.
success
&&
result
.
data
!=
null
)
{
return
result
.
data
!;
}
...
...
lib/views/home/abnormal_list/cubit/abnormal_list_cubit.dart
View file @
97313115
...
...
@@ -9,29 +9,34 @@ import 'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_sta
class
AbnormalListCubit
extends
Cubit
<
AbnormalListState
>
{
final
AlertListService
_service
;
static
const
int
_pageSize
=
20
;
AbnormalListCubit
()
:
_service
=
AlertListService
(
repository:
AlertListRepository
(),
),
super
(
const
AbnormalListState
())
{
loadList
();
}
super
(
const
AbnormalListState
());
Future
<
void
>
loadList
()
async
{
emit
(
const
AbnormalListState
(
isLoading:
true
));
try
{
final
alertList
=
await
_service
.
getList
();
emit
(
AbnormalListState
(
alarmList:
alertList
.
rows
.
map
((
e
)
=>
AlarmItem
.
fromAlertListItemBO
(
e
)).
toList
(),
/// 供 PagingController.fetchPage 回调使用,每次加载新的一页
Future
<
List
<
AlarmItem
>>
fetchPage
(
int
pageKey
)
async
{
final
alertList
=
await
_service
.
getList
(
pageSize:
_pageSize
,
pageNum:
pageKey
,
);
// 首頁時更新 tab 统计数
if
(
pageKey
==
1
)
{
emit
(
state
.
copyWith
(
allCount:
alertList
.
tabCount
.
all
,
pendingCount:
alertList
.
tabCount
.
pending
,
processedCount:
alertList
.
tabCount
.
processed
,
falseAlarmCount:
alertList
.
tabCount
.
falseAlarm
,
));
}
catch
(
e
)
{
emit
(
AbnormalListState
(
error:
e
.
toString
()));
}
return
alertList
.
rows
.
map
((
e
)
=>
AlarmItem
.
fromAlertListItemBO
(
e
))
.
toList
();
}
void
setFilter
(
AlarmStatus
filter
)
{
...
...
lib/views/home/abnormal_list/cubit/abnormal_list_state.dart
View file @
97313115
...
...
@@ -61,7 +61,6 @@ class AbnormalListState extends Equatable {
final
bool
isLoading
;
final
String
?
error
;
final
AlarmStatus
currentFilter
;
final
List
<
AlarmItem
>
alarmList
;
final
int
allCount
;
final
int
pendingCount
;
final
int
processedCount
;
...
...
@@ -71,7 +70,6 @@ class AbnormalListState extends Equatable {
this
.
isLoading
=
false
,
this
.
error
,
this
.
currentFilter
=
AlarmStatus
.
all
,
this
.
alarmList
=
const
[],
this
.
allCount
=
0
,
this
.
pendingCount
=
0
,
this
.
processedCount
=
0
,
...
...
@@ -82,7 +80,6 @@ class AbnormalListState extends Equatable {
bool
?
isLoading
,
String
?
error
,
AlarmStatus
?
currentFilter
,
List
<
AlarmItem
>?
alarmList
,
int
?
allCount
,
int
?
pendingCount
,
int
?
processedCount
,
...
...
@@ -92,7 +89,6 @@ class AbnormalListState extends Equatable {
isLoading:
isLoading
??
this
.
isLoading
,
error:
error
,
currentFilter:
currentFilter
??
this
.
currentFilter
,
alarmList:
alarmList
??
this
.
alarmList
,
allCount:
allCount
??
this
.
allCount
,
pendingCount:
pendingCount
??
this
.
pendingCount
,
processedCount:
processedCount
??
this
.
processedCount
,
...
...
@@ -100,19 +96,11 @@ class AbnormalListState extends Equatable {
);
}
List
<
AlarmItem
>
get
filteredList
{
if
(
currentFilter
==
AlarmStatus
.
all
)
{
return
alarmList
;
}
return
alarmList
.
where
((
item
)
=>
item
.
status
==
currentFilter
).
toList
();
}
@override
List
<
Object
?>
get
props
=>
[
isLoading
,
error
,
currentFilter
,
alarmList
,
allCount
,
pendingCount
,
processedCount
,
...
...
lib/views/home/abnormal_list/index_view.dart
View file @
97313115
This diff is collapsed.
Click to expand it.
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