1,修复Bug-1000665 开锁页-密码-单次 单次密码不能改,星锁点击有弹出修改密码

2,修复Bug-1000660 开锁页-密码-限时 选择的开始时间是整点,显示却有分钟数
3,修复Bug- 1000658 开锁页-密码-清空码 不可修改,星锁点击修改框弹出
4,修复Bug- 1000649 开锁页-密码-单次-密码详情显示时间错误
5,修复Bug- 1000648 开锁页-密码-清空密码-密码详情显示时间错误
6,修改日期代码重构及参数检查
This commit is contained in:
Daisy 2024-01-02 15:32:56 +08:00
parent 2723c0b058
commit 4297e25b22
11 changed files with 246 additions and 184 deletions

View File

@ -1,4 +1,3 @@
import 'dart:async';
import 'package:get/get.dart';
@ -138,35 +137,49 @@ class CheckingInAddStaffLogic extends BaseGetXController{
have: state.appUnHaveAccount.value ? "2" : "1",
staffName: state.staffNameController.text,
countryCode: state.countryCode.value,
usernameType:usernameType,
usernameType: usernameType,
);
if(entity.errorCode!.codeIsSuccessful){
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshCheckInStaffListDataEvent());
Get.close(2);
}else if(entity.errorCode! == 425){
} else if (entity.errorCode! == 425) {
Toast.show(msg: entity.errorMsg!);
}
}
//
void getKeyboardPwdRequest() async {
if(state.staffNameController.text.isEmpty){
if (state.staffNameController.text.isEmpty) {
Toast.show(msg: "请输入姓名");
return;
}
// var entity = await ApiRepository.to.getPasswordKey(
// "0",
// '0',
// state.staffNameController.text,
// 2.toString(),
// '0',
// state.getKeyInfosData.value.lockId.toString(),
// '0',
// "0",
// '0',
// 0,
// 0,
// 1);
var entity = await ApiRepository.to.getPasswordKey(
"0",
'0',
state.staffNameController.text,
2.toString(),
'0',
state.getKeyInfosData.value.lockId.toString(),
'0',
"0",
'0',
0,
0,
1);
endDate: "0",
isExclusive: '0',
keyboardPwdName: state.staffNameController.text,
keyboardPwdType: 2.toString(),
keyboardPwdVersion: '0',
lockId: state.getKeyInfosData.value.lockId.toString(),
operatorUid: '0',
startDate: '0',
timezoneRawOffSet: '0',
startHours: 0,
endHours: 0,
isCoerced: 1);
if (entity.errorCode!.codeIsSuccessful) {
print('获取密码成功');
if (entity.data != null) {

View File

@ -0,0 +1,48 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_state.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/toast.dart';
class ElectronicKeyDetailChangeDateLogic extends BaseGetXController {
final ElectronicKeyDetailChangeDateState state =
ElectronicKeyDetailChangeDateState();
//
Future<void> updatePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
lockId: state.itemData.value.lockId!,
keyboardPwdId: state.pwdId.value.toString(),
keyboardPwdName: state.inputNameController.text,
newKeyboardPwd: state.inputPwdController.text,
startDate: state.startDate.value,
endDate: state.endDate.value,
changeType: state.changeType.value,
hoursStart: state.hoursStart.value,
hoursEnd: state.hoursEnd.value,
isCoerced: state.isCoerced.value);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "修改成功");
Get.back();
}
}
//
Future<void> updateKeyDateRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate(
state.itemData.value.keyId.toString(),
state.itemData.value.lockId.toString(),
state.failureDateTime.millisecondsSinceEpoch.toString(),
state.endDay.value,
'',
state.effectiveDateTime.millisecondsSinceEpoch.toString(),
state.startDay.value,
state.weekDays.value);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "修改成功");
Get.back();
}
}
}

View File

@ -1,16 +1,9 @@
import 'package:flutter/material.dart';
// import 'package:flutter_pickers/pickers.dart';
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart';
import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart';
@ -27,34 +20,11 @@ class ElectronicKeyDetailChangeDate extends StatefulWidget {
class _ElectronicKeyDetailChangeDateState
extends State<ElectronicKeyDetailChangeDate> {
ElectronicKeyListItem itemData = ElectronicKeyListItem();
String _selectEffectiveDate = ''; //
String _selectFailureDate = ''; //
late DateTime _effectiveDateTime;
late DateTime _failureDateTime;
late String endDay = '';
late String startDay = '';
late List weekDays = [];
late String pwdId = '';
late String lockId = '';
late String fromType = ''; // 1
final logic = Get.put(ElectronicKeyDetailChangeDateLogic());
final state = Get.find<ElectronicKeyDetailChangeDateLogic>().state;
@override
Widget build(BuildContext context) {
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["itemData"] != null)) {
itemData = obj["itemData"];
}
if (obj != null && (obj["pwdId"] != null)) {
pwdId = obj["pwdId"];
}
if (obj != null && (obj["lockId"] != null)) {
lockId = obj["lockId"];
}
if (obj != null && (obj["fromType"] != null)) {
fromType = obj["fromType"];
}
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
@ -69,12 +39,12 @@ class _ElectronicKeyDetailChangeDateState
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
onPressed: () {
if (fromType == "1") {
if (state.fromType.value == "1") {
} else {
if (lockId.isNotEmpty && pwdId.isNotEmpty) {
updatePwdRequest();
if (state.lockId.value != 0 && state.pwdId.value.isNotEmpty) {
logic.updatePwdRequest();
} else {
updateKeyDateRequest();
logic.updateKeyDateRequest();
}
}
},
@ -88,77 +58,37 @@ class _ElectronicKeyDetailChangeDateState
Widget buildMainUI() {
return Column(
children: [
CommonItem(
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: _selectEffectiveDate,
rightTitle: state.selectEffectiveDate.value,
isHaveLine: true,
isHaveDirection: true,
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
setState(() {
_selectEffectiveDate =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
_effectiveDateTime = DateTime.parse(_selectEffectiveDate);
});
state.selectEffectiveDate.value =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
state.effectiveDateTime =
DateTime.parse(state.selectEffectiveDate.value);
});
}),
CommonItem(
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: _selectFailureDate,
rightTitle: state.selectFailureDate.value,
isHaveDirection: true,
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
setState(() {
_selectFailureDate =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
_failureDateTime = DateTime.parse(_selectFailureDate);
});
state.selectFailureDate.value =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
state.failureDateTime =
DateTime.parse(state.selectFailureDate.value);
});
}),
})),
],
);
}
//
Future<void> updateKeyDateRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate(
itemData.keyId.toString(),
itemData.lockId.toString(),
_failureDateTime.millisecondsSinceEpoch.toString(),
endDay,
'',
_effectiveDateTime.millisecondsSinceEpoch.toString(),
startDay,
weekDays);
if (entity.errorCode!.codeIsSuccessful) {
print("修改要是名称成功啦啦啦啦啦");
Toast.show(msg: "修改成功");
setState(() {
Navigator.pop(context);
});
}
}
//
Future<void> updatePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
lockId,
pwdId,
'',
'',
_effectiveDateTime.millisecondsSinceEpoch.toString(),
_failureDateTime.millisecondsSinceEpoch.toString(),
'');
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "修改成功");
setState(() {
Navigator.pop(context);
});
}
}
String intToStr(int v) {
return (v < 10) ? "0$v" : "$v";
}

View File

@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
class ElectronicKeyDetailChangeDateState {
final itemData = ElectronicKeyListItem().obs;
final TextEditingController inputPwdController = TextEditingController();
final TextEditingController inputNameController = TextEditingController();
final changeType = '1'
.obs; //1-APP走蓝牙修改1APP SDK蓝牙修改后调用该接口 2-WiFi锁修改WiFi锁或有连接网关2
final isCoerced = '1'.obs; //:1;:2
final hoursStart = 0.obs;
final hoursEnd = 0.obs;
final startDate = 0.obs;
final endDate = 0.obs;
final pwdId = ''.obs;
final lockId = 0.obs;
final fromType = ''.obs;
final selectEffectiveDate = ''.obs; //
final selectFailureDate = ''.obs; //
DateTime effectiveDateTime = DateTime.now();
DateTime failureDateTime = DateTime.now();
final endDay = ''.obs;
final startDay = ''.obs;
final weekDays = [].obs;
ElectronicKeyDetailChangeDateState() {
Map map = Get.arguments;
// itemData.value = map["itemData"];
if ((map["itemData"] != null)) {
itemData.value = map["itemData"];
}
if ((map["pwdId"] != null)) {
pwdId.value = map["pwdId"];
}
if ((map["lockId"] != null)) {
lockId.value = map["lockId"];
}
if ((map["fromType"] != null)) {
fromType.value = map["fromType"];
}
}
}

View File

@ -23,13 +23,16 @@ class PasswordKeyDetailLogic extends BaseGetXController {
//
Future<void> updatePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
state.itemData.value.lockId.toString(),
state.itemData.value.keyboardPwdId.toString(),
state.inputNameController.text,
state.inputPwdController.text,
'',
'',
'');
lockId: state.itemData.value.lockId!,
keyboardPwdId: state.itemData.value.keyboardPwdId.toString(),
keyboardPwdName: state.inputNameController.text,
newKeyboardPwd: state.inputPwdController.text,
startDate: state.startDate.value,
endDate: state.endDate.value,
changeType: state.changeType.value,
hoursStart: state.hoursStart.value,
hoursEnd: state.hoursEnd.value,
isCoerced: state.isCoerced.value);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "修改成功");
Get.back();

View File

@ -55,10 +55,19 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
rightTitle: state.inputPwdController.text.isNotEmpty
? state.inputPwdController.text
: state.itemData.value.keyboardPwd,
isHaveDirection: true,
isHaveDirection: (state.itemData.value.keyboardPwdType == 1 ||
state.itemData.value.keyboardPwdType == 4)
? false
: true,
isHaveLine: true,
action: () {
showCupertinoAlertDialog(context, state.inputPwdController);
if (state.itemData.value.keyboardPwdType == 1 ||
state.itemData.value.keyboardPwdType == 4) {
return;
} else {
showCupertinoAlertDialog(
context, state.inputPwdController);
}
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,

View File

@ -6,6 +6,13 @@ class PasswordKeyDetailState {
final itemData = PasswordKeyListItem().obs;
final TextEditingController inputPwdController = TextEditingController();
final TextEditingController inputNameController = TextEditingController();
final changeType = '1'
.obs; //1-APP走蓝牙修改1APP SDK蓝牙修改后调用该接口 2-WiFi锁修改WiFi锁或有连接网关2
final isCoerced = '1'.obs; //:1;:2
final hoursStart = 0.obs;
final hoursEnd = 0.obs;
final startDate = 0.obs;
final endDate = 0.obs;
PasswordKeyDetailState() {
Map map = Get.arguments;

View File

@ -12,9 +12,8 @@ class PasswordKeyListLogic extends BaseGetXController {
//
void mockNetworkDataRequest() async {
PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList(
'0',
state.keyInfo.value.keyStatus.toString(),
state.keyInfo.value.lockId.toString(),
'0',
state.pageNum.toString(),
state.pageSize.toString(),
state.searchController.text);
@ -35,9 +34,10 @@ class PasswordKeyListLogic extends BaseGetXController {
}
// deleteType:1- 2-
Future<void> deletePwdRequest(String lockId, String keyboardPwdId, int deleteType) async {
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
lockId, keyboardPwdId, deleteType);
Future<void> deletePwdRequest(
String lockId, String keyboardPwdId, int deleteType) async {
PasswordKeyEntity entity = await ApiRepository.to
.deleteKeyboardPwd(lockId, keyboardPwdId, deleteType);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "删除成功");
mockNetworkDataRequest();

View File

@ -90,18 +90,18 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
}
var entity = await ApiRepository.to.getPasswordKey(
getFailureDateTime,
'0',
state.nameController.text,
getKeyType,
'0',
lockId,
'0',
getEffectiveDateTime,
'0',
state.loopStartHours.value,
state.loopEndHours.value,
1);
endDate: getFailureDateTime,
isExclusive: '0',
keyboardPwdName: state.nameController.text,
keyboardPwdType: getKeyType,
keyboardPwdVersion: '0',
lockId: lockId,
operatorUid: '0',
startDate: getEffectiveDateTime,
timezoneRawOffSet: '0',
startHours: state.loopStartHours.value,
endHours: state.loopEndHours.value,
isCoerced: 1);
if (entity.errorCode!.codeIsSuccessful) {
print('获取密码成功');
state.isSendSuccess.value = true;

View File

@ -362,19 +362,13 @@ class ApiProvider extends BaseProvider {
Future<Response> getWifiLockServiceIpAndPort() =>
post(getWifiServiceIpURL.toUrl, jsonEncode({}));
Future<Response> passwordKeyList(
String keyStatus,
String lockId,
String operatorUid,
String pageNo,
String pageSize,
String searchStr) =>
Future<Response> passwordKeyList(String keyStatus, String lockId,
String pageNo, String pageSize, String searchStr) =>
post(
passwordKeyListURL.toUrl,
jsonEncode({
'keyStatus': keyStatus,
'lockId': lockId,
'operatorUid': operatorUid,
'pageNo': pageNo,
'pageSize': pageSize,
'searchStr': searchStr
@ -436,14 +430,16 @@ class ApiProvider extends BaseProvider {
}));
Future<Response> updateKeyboardPwd(
String lockId,
String keyboardPwdId,
String keyboardPwdName,
String newKeyboardPwd,
String startDate,
String endDate,
String changeType,
) =>
int lockId,
String keyboardPwdId,
String keyboardPwdName,
String newKeyboardPwd,
int startDate,
int endDate,
String changeType,
String isCoerced,
int hoursStart,
int hoursEnd) =>
post(
updatePasswordKeyURL.toUrl,
jsonEncode({
@ -454,6 +450,9 @@ class ApiProvider extends BaseProvider {
'startDate': startDate,
'endDate': endDate,
'changeType': changeType,
'isCoerced': isCoerced,
'hoursStart': hoursStart,
'hoursEnd': hoursEnd
}));
Future<Response> clearOperationRecord(String lockId) =>

View File

@ -323,15 +323,10 @@ class ApiRepository {
}
//
Future<PasswordKeyListEntity> passwordKeyList(
String keyStatus,
String lockId,
String operatorUid,
String pageNo,
String pageSize,
String searchStr) async {
Future<PasswordKeyListEntity> passwordKeyList(String keyStatus, String lockId,
String pageNo, String pageSize, String searchStr) async {
final res = await apiProvider.passwordKeyList(
keyStatus, lockId, operatorUid, pageNo, pageSize, searchStr);
keyStatus, lockId, pageNo, pageSize, searchStr);
return PasswordKeyListEntity.fromJson(res.body);
}
@ -357,43 +352,47 @@ class ApiRepository {
}
//
Future<LockSetInfoEntity> getLockSettingInfoData({required String lockId}) async {
Future<LockSetInfoEntity> getLockSettingInfoData(
{required String lockId}) async {
final res = await apiProvider.getLockSettingInfoData(lockId);
return LockSetInfoEntity.fromJson(res.body);
}
//
Future<LockListInfoEntity> deletOwnerLockData({required String lockId}) async {
Future<LockListInfoEntity> deletOwnerLockData(
{required String lockId}) async {
final res = await apiProvider.deletLockInfo(lockId);
return LockListInfoEntity.fromJson(res.body);
}
//
Future<LockListInfoEntity> deletOwnerKeyData({required String lockId, required String keyId}) async {
Future<LockListInfoEntity> deletOwnerKeyData(
{required String lockId, required String keyId}) async {
final res = await apiProvider.deletOwnerKeyInfo(lockId, keyId);
return LockListInfoEntity.fromJson(res.body);
}
//
Future<LockListInfoEntity> checkLoginPassword({required String password}) async {
Future<LockListInfoEntity> checkLoginPassword(
{required String password}) async {
final res = await apiProvider.checkLoginPassword(password);
return LockListInfoEntity.fromJson(res.body);
}
//
Future<PasswordKeyEntity> getPasswordKey(
String endDate,
String isExclusive,
String keyboardPwdName,
String keyboardPwdType,
String keyboardPwdVersion,
String lockId,
String operatorUid,
String startDate,
String timezoneRawOffSet,
int startHours,
int endHours,
int isCoerced) async {
{required String endDate,
required String isExclusive,
required String keyboardPwdName,
required String keyboardPwdType,
required String keyboardPwdVersion,
required String lockId,
required String operatorUid,
required String startDate,
required String timezoneRawOffSet,
required int startHours,
required int endHours,
required int isCoerced}) async {
final res = await apiProvider.getKeyboardPwd(
endDate,
isExclusive,
@ -427,16 +426,27 @@ class ApiRepository {
//
Future<PasswordKeyEntity> updatePasswordKey(
String lockId,
String keyboardPwdId,
String keyboardPwdName,
String newKeyboardPwd,
String startDate,
String endDate,
String changeType,
) async {
final res = await apiProvider.updateKeyboardPwd(lockId, keyboardPwdId,
keyboardPwdName, newKeyboardPwd, startDate, endDate, changeType);
{required int lockId,
required String keyboardPwdId,
required String keyboardPwdName,
required String newKeyboardPwd,
required int startDate,
required int endDate,
required String changeType,
required String isCoerced,
required int hoursStart,
required int hoursEnd}) async {
final res = await apiProvider.updateKeyboardPwd(
lockId,
keyboardPwdId,
keyboardPwdName,
newKeyboardPwd,
startDate,
endDate,
changeType,
isCoerced,
hoursStart,
hoursEnd);
return PasswordKeyEntity.fromJson(res.body);
}