67 lines
2.0 KiB
Dart
Executable File
67 lines
2.0 KiB
Dart
Executable File
|
|
import 'dart:async';
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
|
|
|
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart';
|
|
import '../../../../network/api_repository.dart';
|
|
import '../../../../tools/baseGetXController.dart';
|
|
import '../../../../tools/eventBusEventManage.dart';
|
|
import 'lockUserManageList_state.dart';
|
|
|
|
class LockUserManageListLogic extends BaseGetXController {
|
|
final LockUserManageListState state = LockUserManageListState();
|
|
StreamSubscription? _getElectronicKeyListRefreshUIEvent;
|
|
|
|
//请求锁用户列表
|
|
Future<LockUserListEntity> lockUserListRequest() async {
|
|
final LockUserListEntity entity =
|
|
await ApiRepository.to.lockUserList(pageNo.toString(), pageSize, state.searchController.text);
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
if (pageNo == 1) {
|
|
state.dataList.value = entity.data!;
|
|
pageNo++;
|
|
} else {
|
|
if (entity.data!.isNotEmpty) {
|
|
state.dataList.addAll(entity.data!);
|
|
pageNo++;
|
|
}
|
|
}
|
|
}
|
|
return entity;
|
|
}
|
|
|
|
//删除锁用户管理
|
|
Future<void> deletelockUserRequest(int uid) async {
|
|
final LoginEntity entity = await ApiRepository.to.deletLockUser(uid);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
showToast('删除成功'.tr, something: (){
|
|
pageNo = 1;
|
|
lockUserListRequest();
|
|
});
|
|
}
|
|
}
|
|
|
|
/// 刷新电子钥匙列表
|
|
void _getElectronicKeyListRefreshUIAction() {
|
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
|
_getElectronicKeyListRefreshUIEvent = eventBus.on<LockUserManageListRefreshUI>().listen((event) {
|
|
pageNo = 1;
|
|
lockUserListRequest();
|
|
});
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
_getElectronicKeyListRefreshUIAction();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
super.onClose();
|
|
_getElectronicKeyListRefreshUIEvent?.cancel();
|
|
}
|
|
} |