57 lines
2.2 KiB
Dart
Executable File
57 lines
2.2 KiB
Dart
Executable File
import 'package:get/get.dart';
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
|
|
|
import '../../../../../network/api_repository.dart';
|
|
import '../../../../../tools/dateTool.dart';
|
|
import '../../../../../tools/eventBusEventManage.dart';
|
|
import '../../../lockOperatingRecord/keyOperationRecord_entity.dart';
|
|
import 'electronicKeyPeriodValidity_state.dart';
|
|
|
|
class ElectronicKeyPeriodValidityLogic extends BaseGetXController {
|
|
final ElectronicKeyPeriodValidityState state = ElectronicKeyPeriodValidityState();
|
|
|
|
//编辑电子钥匙有效期请求
|
|
Future<void> updateKeyDateRequest() async {
|
|
|
|
var starDateTimestamp = DateTool().dateToTimestamp(state.starDate.value, 1);
|
|
var endDateTimestamp = DateTool().dateToTimestamp(state.endDate.value, 1);
|
|
var starTimeTimestamp = DateTool().dateToTimestamp(state.starTime.value, 0);
|
|
var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 0);
|
|
|
|
if (starDateTimestamp >= endDateTimestamp) {
|
|
showToast("失效日期要大于生效日期".tr);
|
|
return;
|
|
}
|
|
|
|
if (starTimeTimestamp >= endTimeTimestamp) {
|
|
showToast("失效时间要大于生效时间".tr);
|
|
return;
|
|
}
|
|
KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate(
|
|
keyId:state.keyId.value.toString(),
|
|
lockId:state.lockId.value.toString(),
|
|
endDate:endDateTimestamp.toString(),
|
|
startDate:starDateTimestamp.toString(),
|
|
weekDays:state.weekDay.value,
|
|
keyType:state.keyType.value!,
|
|
startTime: starTimeTimestamp,
|
|
endTime: endTimeTimestamp,
|
|
isOnlyManageSelf: state.isOnlyManageSelf.value!,
|
|
remoteEnable: state.remoteEnable.value!);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
showToast("修改成功".tr, something: () {
|
|
eventBus.fire(ElectronicKeyListRefreshUI());
|
|
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
|
Get.back(result: {
|
|
"starDate":starDateTimestamp.toString(),
|
|
"endDate":endDateTimestamp.toString(),
|
|
"starTime":starTimeTimestamp.toString(),
|
|
"endTime":endTimeTimestamp.toString(),
|
|
"validityValue":state.weekDay.value,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
}
|