2023-11-03 13:58:41 +08:00
|
|
|
|
2024-03-29 18:32:33 +08:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
2024-01-16 16:52:05 +08:00
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
2024-08-21 14:12:15 +08:00
|
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
2023-11-03 13:58:41 +08:00
|
|
|
|
2024-05-03 17:53:15 +08:00
|
|
|
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart';
|
2023-11-03 13:58:41 +08:00
|
|
|
import '../../../../network/api_repository.dart';
|
|
|
|
|
import '../../../../tools/baseGetXController.dart';
|
2024-03-29 18:32:33 +08:00
|
|
|
import '../../../../tools/eventBusEventManage.dart';
|
2023-11-03 13:58:41 +08:00
|
|
|
import 'lockUserManageList_state.dart';
|
|
|
|
|
|
|
|
|
|
class LockUserManageListLogic extends BaseGetXController {
|
|
|
|
|
final LockUserManageListState state = LockUserManageListState();
|
2024-06-06 17:42:03 +08:00
|
|
|
StreamSubscription? _getElectronicKeyListRefreshUIEvent;
|
2023-11-03 13:58:41 +08:00
|
|
|
|
|
|
|
|
//请求锁用户列表
|
2024-03-20 15:12:35 +08:00
|
|
|
Future<LockUserListEntity> lockUserListRequest() async {
|
2024-06-06 17:42:03 +08:00
|
|
|
final LockUserListEntity entity =
|
2024-03-29 18:32:33 +08:00
|
|
|
await ApiRepository.to.lockUserList(pageNo.toString(), pageSize, state.searchController.text);
|
2024-03-20 15:12:35 +08:00
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
|
|
|
if (pageNo == 1) {
|
|
|
|
|
state.dataList.value = entity.data!;
|
|
|
|
|
pageNo++;
|
|
|
|
|
} else {
|
|
|
|
|
if (entity.data!.isNotEmpty) {
|
2024-06-06 17:42:03 +08:00
|
|
|
state.dataList.addAll(entity.data!);
|
2024-03-20 15:12:35 +08:00
|
|
|
pageNo++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|
2024-03-20 15:12:35 +08:00
|
|
|
return entity;
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除锁用户管理
|
|
|
|
|
Future<void> deletelockUserRequest(int uid) async {
|
2024-08-21 14:12:15 +08:00
|
|
|
final LoginEntity entity = await ApiRepository.to.deletLockUser(uid);
|
2023-11-03 13:58:41 +08:00
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
2024-08-21 14:12:15 +08:00
|
|
|
showToast('删除成功'.tr, something: (){
|
2024-03-20 15:12:35 +08:00
|
|
|
pageNo = 1;
|
|
|
|
|
lockUserListRequest();
|
|
|
|
|
});
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-29 18:32:33 +08:00
|
|
|
/// 刷新电子钥匙列表
|
|
|
|
|
void _getElectronicKeyListRefreshUIAction() {
|
|
|
|
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
|
|
|
|
_getElectronicKeyListRefreshUIEvent = eventBus.on<LockUserManageListRefreshUI>().listen((event) {
|
|
|
|
|
pageNo = 1;
|
|
|
|
|
lockUserListRequest();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-03 13:58:41 +08:00
|
|
|
@override
|
|
|
|
|
void onReady() {
|
|
|
|
|
super.onReady();
|
2024-03-29 18:32:33 +08:00
|
|
|
_getElectronicKeyListRefreshUIAction();
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onClose() {
|
2024-03-29 18:32:33 +08:00
|
|
|
super.onClose();
|
|
|
|
|
_getElectronicKeyListRefreshUIEvent?.cancel();
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|
|
|
|
|
}
|