修复部分bug

This commit is contained in:
Daisy 2024-02-28 18:22:55 +08:00
parent 872ae68c1c
commit 0a855c6af2
6 changed files with 81 additions and 80 deletions

View File

@ -32,17 +32,15 @@ class ElectronicKeyDetailChangeDateLogic extends BaseGetXController {
} }
} }
// //
Future<void> updateKeyDateRequest() async { Future<void> updateKeyDateRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate( KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate(
state.itemData.value.keyId.toString(), state.itemData.value.keyId.toString(),
state.itemData.value.lockId.toString(), state.itemData.value.lockId.toString(),
state.failureDateTime.millisecondsSinceEpoch.toString(), state.failureDateTime.millisecondsSinceEpoch.toString(),
state.endDay.value,
'',
state.effectiveDateTime.millisecondsSinceEpoch.toString(), state.effectiveDateTime.millisecondsSinceEpoch.toString(),
state.startDay.value, state.weekDays.value,
state.weekDays.value); state.itemData.value.keyType! == 1 ? 2 : state.itemData.value.keyType!);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast("修改成功", something: () { showToast("修改成功", something: () {
eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(ElectronicKeyListRefreshUI());

View File

@ -20,8 +20,6 @@ class ElectronicKeyDetailChangeDateState {
final selectFailureDate = ''.obs; // final selectFailureDate = ''.obs; //
DateTime effectiveDateTime = DateTime.now(); DateTime effectiveDateTime = DateTime.now();
DateTime failureDateTime = DateTime.now(); DateTime failureDateTime = DateTime.now();
final endDay = ''.obs;
final startDay = ''.obs;
final weekDays = [].obs; final weekDays = [].obs;
ElectronicKeyDetailChangeDateState() { ElectronicKeyDetailChangeDateState() {

View File

@ -18,23 +18,37 @@ class SendElectronicKeyLogic extends BaseGetXController {
showToast("请输入接收者账号"); showToast("请输入接收者账号");
return; return;
} }
if(state.keyNameController.text.isEmpty){ //
showToast("请输入接收者姓名"); // if(state.keyNameController.text.isEmpty){
return; // showToast("请输入接收者姓名");
} // return;
// }
DateTime startDateTime = DateTime(state.effectiveDateTime.value.year, state.effectiveDateTime.value.month, state.effectiveDateTime.value.day, state.effectiveDateTime.value.hour, state.effectiveDateTime.value.minute); DateTime startDateTime = DateTime(
DateTime endDateTime = DateTime(state.failureDateTime.value.year, state.failureDateTime.value.month, state.failureDateTime.value.day, state.failureDateTime.value.hour, state.failureDateTime.value.minute); state.effectiveDateTime.value.year,
state.effectiveDateTime.value.month,
state.effectiveDateTime.value.day,
state.effectiveDateTime.value.hour,
state.effectiveDateTime.value.minute);
DateTime endDateTime = DateTime(
state.failureDateTime.value.year,
state.failureDateTime.value.month,
state.failureDateTime.value.day,
state.failureDateTime.value.hour,
state.failureDateTime.value.minute);
// //
if (state.type.value == "0" || state.type.value == "3") { if (state.type.value == "0" || state.type.value == "3") {
print("startDateTime:$startDateTime endDateTime:$endDateTime DateTime.now():${DateTime.now()} startDateTime.isBefore(endDateTime):${startDateTime.isBefore(endDateTime)}"); print(
if (!startDateTime.isBefore(endDateTime) || startDateTime.isAtSameMomentAs(endDateTime)) { "startDateTime:$startDateTime endDateTime:$endDateTime DateTime.now():${DateTime.now()} startDateTime.isBefore(endDateTime):${startDateTime.isBefore(endDateTime)}");
if (!startDateTime.isBefore(endDateTime) ||
startDateTime.isAtSameMomentAs(endDateTime)) {
showToast("失效时间需大于生效时间"); showToast("失效时间需大于生效时间");
return; return;
} }
if (!startDateTime.isBefore(DateTime.now()) || startDateTime.isAtSameMomentAs(DateTime.now())) { if (!startDateTime.isBefore(DateTime.now()) ||
startDateTime.isAtSameMomentAs(DateTime.now())) {
showToast("生效时间需大于当前时间"); showToast("生效时间需大于当前时间");
return; return;
} }
@ -46,8 +60,10 @@ class SendElectronicKeyLogic extends BaseGetXController {
case 0: case 0:
{ {
typeValue = XSConstantMacro.keyTypeTime; typeValue = XSConstantMacro.keyTypeTime;
state.failureTimestamp.value = state.failureDateTime.value.millisecondsSinceEpoch; state.failureTimestamp.value =
state.effectiveTimestamp.value = state.effectiveDateTime.value.millisecondsSinceEpoch; state.failureDateTime.value.millisecondsSinceEpoch;
state.effectiveTimestamp.value =
state.effectiveDateTime.value.millisecondsSinceEpoch;
} }
break; break;
case 1: case 1:
@ -194,7 +210,11 @@ class SendElectronicKeyLogic extends BaseGetXController {
void resetData() { void resetData() {
state.emailOrPhoneController.text = ""; state.emailOrPhoneController.text = "";
state.keyNameController.text = ""; state.keyNameController.text = "";
state.selectEffectiveDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; // state.selectEffectiveDate =
state.selectFailureDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; // '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
.obs; //
state.selectFailureDate =
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
.obs; //
} }
} }

View File

@ -102,10 +102,9 @@ class _ExpireLockChangeDatePageState extends State<ExpireLockChangeDatePage> {
itemData.keyId.toString(), itemData.keyId.toString(),
itemData.lockId.toString(), itemData.lockId.toString(),
_failureDateTime.millisecondsSinceEpoch.toString(), _failureDateTime.millisecondsSinceEpoch.toString(),
'',
'',
_effectiveDateTime.millisecondsSinceEpoch.toString(), _effectiveDateTime.millisecondsSinceEpoch.toString(),
'', []); [],
itemData.keyType!);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
print("修改要是名称成功啦啦啦啦啦"); print("修改要是名称成功啦啦啦啦啦");
EasyLoading.showToast('修改成功', duration: 2000.milliseconds); EasyLoading.showToast('修改成功', duration: 2000.milliseconds);

View File

@ -23,7 +23,9 @@ class ApiProvider extends BaseProvider {
String password, String password,
String verificationCode, String verificationCode,
) => ) =>
post(registerUrl.toUrl, jsonEncode({ post(
registerUrl.toUrl,
jsonEncode({
'receiverType': receiverType, 'receiverType': receiverType,
'countryCode': countryCode, 'countryCode': countryCode,
"account": account, "account": account,
@ -196,26 +198,17 @@ class ApiProvider extends BaseProvider {
'operatorUid': operatorUid, 'operatorUid': operatorUid,
})); }));
Future<Response> updateKeyDate( Future<Response> updateKeyDate(String keyId, String lockId, String endDate,
String keyId, String startDate, List weekDays, int keyType) =>
String lockId,
String endDate,
String endDay,
String operatorUid,
String startDate,
String startDay,
List weekDays) =>
post( post(
updateKeyDateURL.toUrl, updateKeyDateURL.toUrl,
jsonEncode({ jsonEncode({
'keyId': keyId, 'keyId': keyId,
'lockId': lockId, 'lockId': lockId,
'endDate': endDate, 'endDate': endDate,
'endDay': endDay,
'operatorUid': operatorUid,
'startDate': startDate, 'startDate': startDate,
'startDay': startDay,
'weekDays': weekDays, 'weekDays': weekDays,
'keyType': keyType
})); }));
Future<Response> resetElectronicKey(String lockId, String operatorUid) => Future<Response> resetElectronicKey(String lockId, String operatorUid) =>

View File

@ -325,17 +325,10 @@ class ApiRepository {
} }
// //
Future<KeyOperationRecordEntity> updateKeyDate( Future<KeyOperationRecordEntity> updateKeyDate(String keyId, String lockId,
String keyId, String endDate, String startDate, List weekDays, int keyType) async {
String lockId, final res = await apiProvider.updateKeyDate(
String endDate, keyId, lockId, endDate, startDate, weekDays, keyType);
String endDay,
String operatorUid,
String startDate,
String startDay,
List weekDays) async {
final res = await apiProvider.updateKeyDate(keyId, lockId, endDate, endDay,
operatorUid, startDate, startDay, weekDays);
return KeyOperationRecordEntity.fromJson(res.body); return KeyOperationRecordEntity.fromJson(res.body);
} }