fix:调整获取卡片时会刷新多个列表的问题

This commit is contained in:
liyi 2025-04-11 10:06:09 +08:00
parent 807c71b614
commit c4191dbc95
2 changed files with 39 additions and 28 deletions

View File

@ -28,6 +28,7 @@ class CardListLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) { EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
@ -69,11 +70,15 @@ class CardListLogic extends BaseGetXController {
userID: (await Storage.getUid())!, userID: (await Storage.getUid())!,
cardNo: state.deletCardNo, cardNo: state.deletCardNo,
useCountLimit: 0xffff, useCountLimit: 0xffff,
operate: state.isDeletAll == true ? 3 : 2, // 0: 1 2: 3 operate: state.isDeletAll == true ? 3 : 2,
// 0: 1 2: 3
isAdmin: 0, isAdmin: 0,
isForce: 0, // isForce: 0,
isRound: 0, // //
weekRound: 0, // isRound: 0,
//
weekRound: 0,
//
startDate: 0x11223344, startDate: 0x11223344,
endDate: 0x11223344, endDate: 0x11223344,
startTime: '0', startTime: '0',
@ -116,11 +121,15 @@ class CardListLogic extends BaseGetXController {
userID: (await Storage.getUid())!, userID: (await Storage.getUid())!,
cardNo: state.deletCardNo, cardNo: state.deletCardNo,
useCountLimit: 0xffff, useCountLimit: 0xffff,
operate: state.isDeletAll == true ? 3 : 2, // 0: 1 2: 3 operate: state.isDeletAll == true ? 3 : 2,
// 0: 1 2: 3
isAdmin: 0, isAdmin: 0,
isForce: 0, // isForce: 0,
isRound: 0, // //
weekRound: 0, // isRound: 0,
//
weekRound: 0,
//
startDate: 0x11223344, startDate: 0x11223344,
endDate: 0x11223344, endDate: 0x11223344,
startTime: '0', startTime: '0',
@ -193,6 +202,7 @@ class CardListLogic extends BaseGetXController {
// //
late StreamSubscription _teamEvent; late StreamSubscription _teamEvent;
void _initRefreshAction() { void _initRefreshAction() {
_teamEvent = eventBus _teamEvent = eventBus
.on<OtherTypeRefreshListEvent>() .on<OtherTypeRefreshListEvent>()
@ -240,6 +250,7 @@ class CardListLogic extends BaseGetXController {
_initRefreshAction(); _initRefreshAction();
} }
await getICCardListData(isRefresh: true);
} }
@override @override

View File

@ -31,24 +31,24 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
final CardListLogic logic = Get.put(CardListLogic()); final CardListLogic logic = Get.put(CardListLogic());
final CardListState state = Get.find<CardListLogic>().state; final CardListState state = Get.find<CardListLogic>().state;
Future<void> getHttpData({required bool isRefresh}) async { // Future<void> logic.getICCardListData({required bool isRefresh}) async {
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); // final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) { // if (isDemoMode == false) {
logic // logic
.getICCardListData(isRefresh: isRefresh) // .getICCardListData(isRefresh: isRefresh)
.then((FingerprintListDataEntity value) { // .then((FingerprintListDataEntity value) {
if (mounted) { // if (mounted) {
setState(() {}); // setState(() {});
} // }
}); // });
} // }
} // }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
getHttpData(isRefresh: true); // logic.getICCardListData(isRefresh: true);
} }
@override @override
@ -92,17 +92,17 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
), ),
body: EasyRefreshTool( body: EasyRefreshTool(
onRefresh: () { onRefresh: () {
getHttpData(isRefresh: true); logic.getICCardListData(isRefresh: true);
}, },
onLoad: () { onLoad: () {
getHttpData(isRefresh: false); logic.getICCardListData(isRefresh: false);
}, },
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
KeySearchWidget( KeySearchWidget(
editingController: state.searchController, editingController: state.searchController,
onSubmittedAction: () { onSubmittedAction: () {
getHttpData(isRefresh: true); logic.getICCardListData(isRefresh: true);
}, },
), ),
SizedBox(height: 20.h), SizedBox(height: 20.h),
@ -115,10 +115,10 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
'fromType': 1 // 1 2 'fromType': 1 // 1 2
})! })!
.then((value) { .then((value) {
getHttpData(isRefresh: true); logic.getICCardListData(isRefresh: true);
}); });
// if (data != null) { // if (data != null) {
// getHttpData(isRefresh: true); // logic.getICCardListData(isRefresh: true);
// } // }
}, },
), ),
@ -180,9 +180,9 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
arguments: <String, FingerprintItemData>{ arguments: <String, FingerprintItemData>{
'fingerprintItemData': fingerprintItemData, 'fingerprintItemData': fingerprintItemData,
})! })!
.then((value) => getHttpData(isRefresh: true)); .then((value) => logic.getICCardListData(isRefresh: true));
// if (data != null) { // if (data != null) {
// getHttpData(isRefresh: true); // logic.getICCardListData(isRefresh: true);
// } // }
}), }),
); );