This commit is contained in:
魏少阳 2024-01-02 18:17:09 +08:00
commit ef5a7c63fb
8 changed files with 235 additions and 15 deletions

View File

@ -15,6 +15,7 @@ import 'package:star_lock/main/lockDetail/lcokSet/msgNotification/msgNotificatio
import 'package:star_lock/main/lockDetail/lcokSet/notificationMode/notificationMode_page.dart';
import 'package:star_lock/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_page.dart';
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart';
import 'package:star_lock/mine/about/webviewShow_page.dart';
import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart';
@ -383,23 +384,28 @@ abstract class Routers {
static const lowBatteryReminderPage = '/lowBatteryReminderPage'; //
static const coerceFingerprintListPage = '/coerceFingerprintListPage'; //
static const lockMonitoringPage = '/LockMonitoringPage'; //
static const monitoringRealTimeScreenPage = '/MonitoringRealTimeScreenPage'; //
static const monitoringRealTimeScreenPage =
'/MonitoringRealTimeScreenPage'; //
static const videoLogPage = '/VideoLogPage'; //
static const editVideoLogPage = '/EditVideoLogPage'; //
static const videoLogDetailPage = '/VideoLogDetailPage'; //
static const videoLogDownLoadPage = '/VideoLogDownLoadPage'; //
static const remoteControlListPage = '/RemoteControlListPage'; //
static const addRemoteControlManagePage = '/AddRemoteControlManagePage'; //
static const addRemoteControlManagePage =
'/AddRemoteControlManagePage'; //
static const cardListPage = '/CardListPage'; //
static const addCardTypeManagePage = '/AddCardTypeManagePage'; //
static const cardDetailPage = '/CardDetailPage'; //
static const fingerprintListPage = '/FingerprintListPage'; //
static const addFingerprintTypeManagePage = '/AddFingerprintTypeManagePage'; //
static const addFingerprintTypeManagePage =
'/AddFingerprintTypeManagePage'; //
static const fingerprintDetailPage = '/FingerprintDetailPage'; //
static const faceList = '/FaceList'; //
static const addFaceTypeManagePage = '/AddFaceTypeManagePage'; //
static const passwordKeyDetailChangeDatePage =
'/passwordKeyDetailChangeDatePage'; //
}
abstract class AppRouters {
@ -983,11 +989,12 @@ abstract class AppRouters {
GetPage(
name: Routers.fingerprintDetailPage,
page: () => const FingerprintDetailPage()),
GetPage(
name: Routers.faceList,
page: () => const FaceList()),
GetPage(name: Routers.faceList, page: () => const FaceList()),
GetPage(
name: Routers.addFaceTypeManagePage,
page: () => const AddFaceTypeManagePage()),
GetPage(
name: Routers.passwordKeyDetailChangeDatePage,
page: () => const PasswordKeyDetailChangeDatePage())
];
}

View File

@ -56,11 +56,26 @@ class _ElectronicKeyDetailChangeDateState
}
Widget buildMainUI() {
String getStartDate = "";
String getEndDate = "";
if (state.itemData.value.startDate != null) {
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
getStartDate = startDateStr.toLocal().toString().substring(0, 16);
}
if (state.itemData.value.endDate != null) {
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
getEndDate = endDateStr.toLocal().toString().substring(0, 16);
}
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.selectEffectiveDate.value,
rightTitle: state.selectEffectiveDate.value.isNotEmpty
? state.selectEffectiveDate.value
: getStartDate,
isHaveLine: true,
isHaveDirection: true,
action: () {
@ -74,7 +89,9 @@ class _ElectronicKeyDetailChangeDateState
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.selectFailureDate.value,
rightTitle: state.selectFailureDate.value.isNotEmpty
? state.selectFailureDate.value
: getEndDate,
isHaveDirection: true,
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,

View File

@ -92,9 +92,10 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
return;
}
Navigator.pushNamed(
context, Routers.electronicKeyDetailChangeDate,
context, Routers.passwordKeyDetailChangeDatePage,
arguments: {
'lockId': state.itemData.value.lockId.toString(),
'itemData': state.itemData.value,
'lockId': state.itemData.value.lockId,
'pwdId': state.itemData.value.keyboardPwdId.toString()
});
}),
@ -298,7 +299,8 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
title: inputController == state.inputNameController
? "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}"
: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.password!.tr}",
tipTitle: "请输入",
tipTitle:
inputController.text.isNotEmpty ? inputController.text : "请输入",
controller: inputController,
sureClick: () {
//

View File

@ -0,0 +1,30 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_state.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 PasswordKeyDetailChangeDateLogic extends BaseGetXController {
final PasswordKeyDetailChangeDateState state =
PasswordKeyDetailChangeDateState();
//
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();
}
}
}

View File

@ -0,0 +1,108 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart';
import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
class PasswordKeyDetailChangeDatePage extends StatefulWidget {
const PasswordKeyDetailChangeDatePage({Key? key}) : super(key: key);
@override
State<PasswordKeyDetailChangeDatePage> createState() =>
_PasswordKeyDetailChangeDatePage();
}
class _PasswordKeyDetailChangeDatePage
extends State<PasswordKeyDetailChangeDatePage> {
final logic = Get.put(PasswordKeyDetailChangeDateLogic());
final state = Get.find<PasswordKeyDetailChangeDateLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle:
"${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.periodValidity!.tr}",
haveBack: true,
backgroundColor: AppColors.mainColor,
actionsList: [
TextButton(
child: Text(
TranslationLoader.lanKeys!.sure!.tr,
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
onPressed: () {
if (state.lockId.value != 0 && state.pwdId.value.isNotEmpty) {
logic.updatePwdRequest();
}
},
),
],
),
body: buildMainUI(),
);
}
Widget buildMainUI() {
String getStartDate = "";
String getEndDate = "";
if (state.itemData.value.startDate != null) {
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
getStartDate = startDateStr.toLocal().toString().substring(0, 16);
}
if (state.itemData.value.endDate != null) {
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
getEndDate = endDateStr.toLocal().toString().substring(0, 16);
}
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.selectEffectiveDate.value.isNotEmpty
? state.selectEffectiveDate.value
: getStartDate,
isHaveLine: true,
isHaveDirection: true,
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.selectEffectiveDate.value =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
state.effectiveDateTime =
DateTime.parse(state.selectEffectiveDate.value);
});
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.selectFailureDate.value.isNotEmpty
? state.selectFailureDate.value
: getEndDate,
isHaveDirection: true,
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.selectFailureDate.value =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
state.failureDateTime =
DateTime.parse(state.selectFailureDate.value);
});
})),
],
);
}
String intToStr(int v) {
return (v < 10) ? "0$v" : "$v";
}
}

View File

@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
class PasswordKeyDetailChangeDateState {
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;
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;
PasswordKeyDetailChangeDateState() {
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"];
}
}
}

View File

@ -69,7 +69,7 @@ class PasswordKeyListItem {
int? lockId;
String? keyboardPwd;
String? keyboardPwdName;
int? keyboardPwdStatus;
int? keyboardPwdStatus; //1 2
int? keyboardPwdType;
int? startDate;
int? endDate;

View File

@ -182,7 +182,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(1)),
),
child: _electronicKeyItem('images/icon_password.png',
child: _electronicKeyItem(index, 'images/icon_password.png',
passwordKeyListItem.keyboardPwdName!, useDateStr, () {
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
arguments: {"itemData": passwordKeyListItem}).then((val) {
@ -334,8 +334,10 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
return useDateStr;
}
Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle,
String useDateStr, Function()? action) {
Widget _electronicKeyItem(int itemIndex, String lockTypeIcon,
String lockTypeTitle, String useDateStr, Function()? action) {
PasswordKeyListItem passwordKeyListItem = state.itemDataList[itemIndex];
return GestureDetector(
onTap: action,
child: Container(
@ -367,6 +369,20 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
style: TextStyle(
fontSize: 24.sp, color: AppColors.blackColor),
),
Expanded(
child: SizedBox(
width: 20.w,
)),
passwordKeyListItem.keyboardPwdStatus == 2
? Text(
'已失效',
style:
TextStyle(color: Colors.red, fontSize: 20.sp),
)
: Container(),
SizedBox(
width: 20.w,
)
],
),
SizedBox(height: 5.h),