78 lines
2.3 KiB
Dart
Executable File
78 lines
2.3 KiB
Dart
Executable File
|
|
import 'dart:async';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
|
import '../../../../network/api_repository.dart';
|
|
import '../../../../tools/baseGetXController.dart';
|
|
import '../../../../tools/eventBusEventManage.dart';
|
|
import 'lockGroupList_state.dart';
|
|
|
|
class LockGroupListLogic extends BaseGetXController {
|
|
final LockGroupListState state = LockGroupListState();
|
|
|
|
//分组列表请求
|
|
Future<void> mockNetworkDataRequest() async {
|
|
final MassSendLockGroupListEntity entity = await ApiRepository.to.lockGroupList('0');
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
if (entity.data != null) {
|
|
state.lockNum = 0;
|
|
state.itemDataList.value = entity.data!.groupList!;
|
|
}
|
|
}
|
|
}
|
|
|
|
//创建锁分组请求
|
|
Future<void> addLockGroupRequest() async {
|
|
final MassSendLockGroupListEntity entity =
|
|
await ApiRepository.to.addLockGroup(state.changeNameController.text, '0');
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
showToast('创建成功'.tr, something: (){
|
|
mockNetworkDataRequest();
|
|
});
|
|
}
|
|
}
|
|
|
|
//编辑锁名字
|
|
Future<void> editLockGroupRequest(int groupId) async {
|
|
final MassSendLockGroupListEntity entity = await ApiRepository.to.editLockGroupRequest(groupId:groupId, groupName:state.changeNameController.text);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
showToast('编辑成功'.tr, something: (){
|
|
mockNetworkDataRequest();
|
|
});
|
|
}
|
|
}
|
|
|
|
//删除组
|
|
Future<void> deleteLockGroupRequest(int groupId) async {
|
|
final MassSendLockGroupListEntity entity = await ApiRepository.to.deleteGroup(groupId);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
showToast('删除成功'.tr, something: (){
|
|
mockNetworkDataRequest();
|
|
});
|
|
}
|
|
}
|
|
|
|
// 监听修改完详情之后刷新列表
|
|
late StreamSubscription _teamEvent;
|
|
void _initRefreshAction() {
|
|
_teamEvent = eventBus.on<LockGroupEditGroupLockRefreshEvent>().listen((LockGroupEditGroupLockRefreshEvent event) {
|
|
mockNetworkDataRequest();
|
|
});
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
_initRefreshAction();
|
|
|
|
mockNetworkDataRequest();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
_teamEvent.cancel();
|
|
}
|
|
|
|
} |