From a074e7acb27c4f42d1297e0ce1ceeaacca80f63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 19 Sep 2023 15:20:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=8C=87=E7=BA=B9=E3=80=81?= =?UTF-8?q?=E5=8D=A1=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_en.json | 3 +- star_lock/images/lan/lan_keys.json | 4 +- star_lock/images/lan/lan_zh.json | 3 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- star_lock/lib/appRouters.dart | 18 +- .../electronicKeyDetailChangeDate_page.dart | 18 +- .../addFingerprint/addFingerprint_logic.dart | 33 ++ .../addFingerprint/addFingerprint_state.dart | 23 ++ .../addFingerprintTip_logic.dart | 9 + .../addFingerprintTip_page.dart | 16 +- .../addFingerprintTip_state.dart | 28 ++ .../otherTypeAddKey_logic.dart | 135 ++++++- .../otherTypeAddKey/otherTypeAddKey_page.dart | 41 +- .../otherTypeAddKey_state.dart | 7 +- .../otherTypeKeyChangeDate_logic.dart | 52 +++ .../otherTypeKeyChangeDate_page.dart | 99 +++++ .../otherTypeKeyChangeDate_state.dart | 27 ++ .../otherTypeKeyChangeValidityDate_logic.dart | 56 +++ .../otherTypeKeyChangeValidityDate_page.dart | 193 +++++++++ .../otherTypeKeyChangeValidityDate_state.dart | 29 ++ .../otherTypeKeyDetail_logic.dart | 63 +++ .../otherTypeKeyDetail_page.dart | 380 ++++++++++-------- .../otherTypeKeyDetail_state.dart | 58 +++ .../fingerprintListData_entity.dart | 42 +- .../otherTypeKeyList_logic.dart | 73 +++- .../otherTypeKeyList_page.dart | 126 +++++- .../otherTypeKeyList_state.dart | 2 + .../otherTypeKeyManage_tabbar.dart | 2 +- star_lock/lib/network/api.dart | 8 + star_lock/lib/network/api_provider.dart | 130 +++++- star_lock/lib/network/api_repository.dart | 105 ++++- star_lock/lib/tools/commonItem.dart | 4 +- star_lock/lib/tools/eventBusEventManage.dart | 5 + star_lock/lib/translations/lanKeyEntity.dart | 10 +- 34 files changed, 1543 insertions(+), 261 deletions(-) create mode 100644 star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_logic.dart create mode 100644 star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_state.dart create mode 100644 star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart create mode 100644 star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart create mode 100644 star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart create mode 100644 star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart create mode 100644 star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart create mode 100644 star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_state.dart diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 769732d3..4ca15633 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -404,5 +404,6 @@ "wifiPwd":"WiFi password", "pleaseEnterWifiPwd":"Please Enter WiFi Password", "edit":"Edit", - "stressFingerprint":"Stress Fingerprint" + "stressFingerprint":"Stress Fingerprint", + "effectiveDay":"Effective Day" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 6f9d2f91..e48b4baa 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -404,6 +404,6 @@ "wifiPwd":"wifiPwd", "pleaseEnterWifiPwd":"pleaseEnterWifiPwd", "edit":"edit", - "stressFingerprint":"stressFingerprint" - + "stressFingerprint":"stressFingerprint", + "effectiveDay":"effectiveDay" } \ No newline at end of file diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index a680f955..0a09c1c9 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -407,5 +407,6 @@ "wifiPwd":"WiFi名字", "pleaseEnterWifiPwd":"请输入WiFi密码", "edit":"编辑", - "stressFingerprint":"胁迫指纹" + "stressFingerprint":"胁迫指纹", + "effectiveDay":"有效日" } \ No newline at end of file diff --git a/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index f3d88ace..c87d15a3 100644 --- a/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -40,7 +40,7 @@ const AdministratorDetailsPage()), GetPage( name: Routers.expireLockListPage, - page: () => const ExpireLockListPage()) + page: () => const ExpireLockListPage()), + GetPage( + name: Routers.otherTypeKeyChangeDatePage, + page: () => const OtherTypeKeyChangeDatePage()), + GetPage( + name: Routers.otherTypeKeyChangeValidityDatePage, + page: () => const OtherTypeKeyChangeValidityDatePage()) ]; } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart index 4f30b9e2..a58df7b4 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart @@ -36,6 +36,7 @@ class _ElectronicKeyDetailChangeDateState late List weekDays = []; late String pwdId = ''; late String lockId = ''; + late String fromType = '';// 1 从指纹详情进入 @override Widget build(BuildContext context) { @@ -49,7 +50,9 @@ class _ElectronicKeyDetailChangeDateState 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( @@ -64,10 +67,14 @@ class _ElectronicKeyDetailChangeDateState style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - if (lockId.isNotEmpty && pwdId.isNotEmpty) { - updatePwdRequest(); - } else { - updateKeyDateRequest(); + if(fromType == "1"){ + + }else{ + if (lockId.isNotEmpty && pwdId.isNotEmpty) { + updatePwdRequest(); + } else { + updateKeyDateRequest(); + } } }, ), @@ -151,6 +158,7 @@ class _ElectronicKeyDetailChangeDateState } } + String intToStr(int v) { return (v < 10) ? "0$v" : "$v"; } diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_logic.dart index aaf65e7d..2a44190d 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_logic.dart @@ -12,8 +12,10 @@ import '../../../../../blue/io_tool/io_manager.dart'; import '../../../../../blue/io_tool/io_tool.dart'; import '../../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../../blue/sender_manage.dart'; +import '../../../../../network/api_repository.dart'; import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/storage.dart'; +import '../../../../../tools/toast.dart'; import 'addFingerprint_state.dart'; class AddFingerprintLogic extends BaseGetXController { @@ -201,6 +203,37 @@ class AddFingerprintLogic extends BaseGetXController { }); } + // 添加指纹 + void addFingerprintsData() async{ + var entity = await ApiRepository.to.addFingerprintsData( + lockId: state.lockId.value.toString(), + endDate: state.endDate.value, + addType:state.addType.value, + fingerprintName: state.fingerprintName.value, + fingerprintNumber: "123456", + fingerprintType: state.fingerprintType.value, + isCoerced: state.isCoerced.value, + startDate: state.startDate.value, + weekDay: state.weekDay.value, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "添加成功"); + updateFingerprintUserNoLoadData(""); + } + } + + void updateFingerprintUserNoLoadData(String fingerprintId) async{ + var entity = await ApiRepository.to.updateFingerprintUserNoLoadData( + fingerprintId: fingerprintId, + lockId: state.lockId.value.toString(), + fingerprintUserNo: "0", + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "添加成功"); + Get.close(3); + } + } + @override void onReady() { // TODO: implement onReady diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_state.dart index 1deec85e..19896e12 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_state.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_state.dart @@ -4,4 +4,27 @@ import 'package:get/get.dart'; class AddFingerprintState{ var ifConnectScuess = false.obs; var addFingerprintProcessNumber = 0.obs; + final lockId = 0.obs; + final endDate = "".obs; + final addType = "".obs; + final fingerprintName = "".obs; + final fingerprintNumber = "".obs; + final fingerprintType = "".obs; + final isCoerced = "".obs; + final startDate = "".obs; + final weekDay = [].obs; + + AddFingerprintState() { + Map map = Get.arguments; + lockId.value = map["lockId"]; + endDate.value = map["endDate"]; + addType.value = map["addType"]; + fingerprintName.value = map["fingerprintName"]; + fingerprintNumber.value = map["fingerprintNumber"]; + fingerprintType.value = map["fingerprintType"]; + isCoerced.value = map["isCoerced"]; + startDate.value = map["startDate"]; + lockId.value = map["lockId"]; + weekDay.value = map["weekDay"]; + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_logic.dart new file mode 100644 index 00000000..8135cac5 --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_logic.dart @@ -0,0 +1,9 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; + +import 'addFingerprintTip_state.dart'; + +class AddFingerprintTipLogic extends BaseGetXController{ + AddFingerprintTipState state = AddFingerprintTipState(); +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_page.dart index 39319dca..7644eedb 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_page.dart @@ -8,6 +8,7 @@ import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/submitBtn.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; +import 'addFingerprintTip_logic.dart'; class AddFingerprintTipPage extends StatefulWidget { const AddFingerprintTipPage({Key? key}) : super(key: key); @@ -17,6 +18,9 @@ class AddFingerprintTipPage extends StatefulWidget { } class _AddFingerprintTipPageState extends State { + final logic = Get.put(AddFingerprintTipLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -66,7 +70,17 @@ class _AddFingerprintTipPageState extends State { btnName: "开始添加",//TranslationLoader.lanKeys!.next!.tr, borderRadius: 20.w, onClick: () { - Get.toNamed(Routers.addFingerprintPage); + Get.toNamed(Routers.addFingerprintPage, arguments: { + "lockId": state.lockId.value, + "endDate": state.endDate.value, + "addType": state.addType.value, + "fingerprintName": state.fingerprintName.value, + "fingerprintNumber": state.fingerprintNumber.value, + "fingerprintType": state.fingerprintType.value, + "isCoerced": state.isCoerced.value, + "startDate": state.startDate.value, + "weekDay": state.weekDay.value, + }); }), ), ], diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_state.dart new file mode 100644 index 00000000..325fba5d --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_state.dart @@ -0,0 +1,28 @@ + +import 'package:get/get.dart'; + +class AddFingerprintTipState{ + final lockId = 0.obs; + final endDate = "".obs; + final addType = "".obs; + final fingerprintName = "".obs; + final fingerprintNumber = "".obs; + final fingerprintType = "".obs; + final isCoerced = "".obs; + final startDate = "".obs; + final weekDay = [].obs; + + AddFingerprintTipState() { + Map map = Get.arguments; + lockId.value = map["lockId"]; + endDate.value = map["endDate"]; + addType.value = map["addType"]; + fingerprintName.value = map["fingerprintName"]; + fingerprintNumber.value = map["fingerprintNumber"]; + fingerprintType.value = map["fingerprintType"]; + isCoerced.value = map["isCoerced"]; + startDate.value = map["startDate"]; + lockId.value = map["lockId"]; + weekDay.value = map["weekDay"]; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_logic.dart index e0c729ec..a7724770 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_logic.dart @@ -1,6 +1,9 @@ +import 'dart:math'; + import 'package:get/get.dart'; +import '../../../../appRouters.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; import '../../../../tools/toast.dart'; @@ -9,24 +12,126 @@ import 'otherTypeAddKey_state.dart'; class OtherTypeAddKeyLogic extends BaseGetXController { OtherTypeAddKeyState state = OtherTypeAddKeyState(); - // 获取指纹列表 + // 添加指纹 void addFingerprintsData() async{ + var fingerprintType = 0;// 永久:1;限时2,单次3,循环:4 + var startDate = ""; + var endDate = ""; + if(state.seletType.value == "0"){ + fingerprintType = 1; + }else if(state.seletType.value == "1"){ + fingerprintType = 2; + if(state.beginTimeTimestamp.value.isEmpty){ + Toast.show(msg: "请选择开始时间"); + return; + } + if(state.endTimeTimestamp.value.isEmpty){ + Toast.show(msg: "请选择开始时间"); + return; + } - var entity = await ApiRepository.to.addFingerprintsData( - lockId: state.lockId.value.toString(), - endDate: state.fromType.value == 0 ? "0" : state.endTimeTimestamp.toString(), - addType:"1", - fingerprintName: state.nameController.text, - fingerprintNumber: "123456", - fingerprintType: state.fromType.value == 2 ? "4" : "1", - isCoerced: state.isStressFingerprint.value ? "1" : "0", - startDate: state.fromType.value == 0 ? "0" : state.beginTimeTimestamp.toString(), - cyclicConfig: '', - ); - if(entity.errorCode!.codeIsSuccessful){ - Toast.show(msg: "添加成功"); - Get.back(result: "addScuess"); + // if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){ + // Toast.show(msg: "生效时间要大于当前时间"); + // return; + // } + + print("fasdfasdfasdf:${int.parse(state.beginTimeTimestamp.value)} == ${int.parse(state.endTimeTimestamp.value)}"); + if(int.parse(state.beginTimeTimestamp.value) >= int.parse(state.endTimeTimestamp.value)){ + Toast.show(msg: "失效时间要大于生效时间"); + return; + } + + startDate = state.beginTimeTimestamp.value; + endDate = state.endTimeTimestamp.value; + }else if(state.seletType.value == "2"){ + if(state.effectiveDateTime.value <= 0){ + Toast.show(msg: "请选择生效时间"); + return; + } + if(state.failureDateTime.value <= 0){ + Toast.show(msg: "请选择失效时间"); + return; + } + + if(state.weekdaysList.value.isEmpty){ + Toast.show(msg: "请选择有效日"); + return; + } + + // if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){ + // Toast.show(msg: "生效时间要大于当前时间"); + // return; + // } + + if(state.effectiveDateTime.value >= state.failureDateTime.value){ + Toast.show(msg: "失效时间要大于生效时间"); + return; + } + startDate = state.effectiveDateTime.value.toString(); + endDate = state.failureDateTime.value.toString(); + fingerprintType = 4; } + + // if(state.fromType.value == 1){ + // Get.toNamed(Routers.addFingerprintTipPage, arguments: { + // "lockId": state.lockId.value, + // "endDate": endDate, + // "addType": "1", + // "fingerprintName": state.nameController.text, + // "fingerprintNumber": "123456", + // "fingerprintType": fingerprintType.toString(), + // "isCoerced": state.isStressFingerprint.value ? "1" : "2", + // "startDate": startDate, + // "weekDay": state.weekdaysList.value, + // }); + // } + + switch (state.fromType.value) { + case 0: + // 卡 + var entity = await ApiRepository.to.addICCardData( + lockId: state.lockId.value.toString(), + endDate: endDate, + cardName: state.nameController.text, + cardNumber: (Random().nextInt(100000000) + 10000000).floor().toString(), + cardType: fingerprintType.toString(), + addType:"1", + startDate: startDate, + isCoerced: state.isStressFingerprint.value ? "1" : "2", + weekDay: state.weekdaysList.value, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "添加成功"); + Get.back(result: "addScuess"); + } + + break; + case 1: + // 指纹 + var entity = await ApiRepository.to.addFingerprintsData( + lockId: state.lockId.value.toString(), + endDate: endDate, + addType:"1", + fingerprintName: state.nameController.text, + fingerprintNumber: (Random().nextInt(100000000) + 10000000).floor().toString(), + fingerprintType: fingerprintType.toString(), + isCoerced: state.isStressFingerprint.value ? "1" : "2", + startDate: startDate, + weekDay: state.weekdaysList.value, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "添加成功"); + Get.back(result: "addScuess"); + } + break; + case 2: + // 遥控 + + break; + default: + break; + } + } @override diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_page.dart index c3c7f40d..9e8a525e 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_page.dart @@ -4,6 +4,7 @@ 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:get_storage/get_storage.dart'; import 'package:star_lock/appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -16,7 +17,7 @@ import 'otherTypeAddKey_logic.dart'; class OtherTypeAddKeyPage extends StatefulWidget { final String seletType; final int lockType; // 0卡 1指纹 2钥匙 - final int lockId; // 0卡 1指纹 2钥匙 + final int lockId; const OtherTypeAddKeyPage( {Key? key, required this.seletType, required this.lockType, required this.lockId}) : super(key: key); @@ -30,6 +31,10 @@ class _OtherTypeAddKeyPageState extends State { @override Widget build(BuildContext context) { + state.seletType.value = widget.seletType; + state.fromType.value = widget.lockType; + state.lockId.value = widget.lockId; + return indexChangeWidget(); } @@ -68,17 +73,15 @@ class _OtherTypeAddKeyPageState extends State { perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController), CommonItem( - leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, + leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, rightTitle: "", isHaveDirection: true, - action: () { - // Map result = await Get.toNamed(Routers.electronicKeyPeriodValidityPage); - // // result as Map; - // weekdaysList = result['validityValue']; - // _effectiveDateTime = result['starDate']; - // _failureDateTime = result['endDate']; - // print( - // '得到的有效期数据:$weekdaysList $_effectiveDateTime $_failureDateTime'); + action: () async { + Map result = await Get.toNamed(Routers.electronicKeyPeriodValidityPage); + state.weekdaysList.value = result['validityValue']; + state.effectiveDateTime.value = result['starDate'].millisecondsSinceEpoch; + state.failureDateTime.value = result['endDate'].millisecondsSinceEpoch; + print('得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}'); }), SizedBox(height: 10.h), keyBottomWidget() @@ -121,14 +124,14 @@ class _OtherTypeAddKeyPageState extends State { setState(() { setState(() { state.beginTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}'; - state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).toString(); + state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).millisecondsSinceEpoch.toString(); }); }); }); })), - CommonItem( + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: "2020.06.20 11:49", + rightTitle: state.endTime.value, isHaveDirection: true, action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, @@ -136,11 +139,11 @@ class _OtherTypeAddKeyPageState extends State { setState(() { setState(() { state.endTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}'; - state.endTimeTimestamp.value = DateTime.parse(state.beginTime.value).toString(); + state.endTimeTimestamp.value = DateTime.parse(state.endTime.value).millisecondsSinceEpoch.toString(); }); }); }); - }), + })), Container(height: 10.h), ], ); @@ -150,7 +153,7 @@ class _OtherTypeAddKeyPageState extends State { return Column( children: [ CommonItem( - leftTitel: "胁迫指纹", + leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr, rightTitle: "", isTipsImg: false, isHaveRightWidget: true, @@ -162,11 +165,7 @@ class _OtherTypeAddKeyPageState extends State { Toast.show(msg: "请输入姓名"); return; } - - // if(widget.lockType == 1){ - Get.toNamed(Routers.addFingerprintTipPage); - // } - // logic.addFingerprintsData(); + logic.addFingerprintsData(); }), ], ); diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_state.dart index 30835b22..35d707df 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_state.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeAddKey/otherTypeAddKey_state.dart @@ -5,7 +5,8 @@ import 'package:get/get.dart'; class OtherTypeAddKeyState{ final lockId = 0.obs; - final fromType = 0.obs; + final seletType = "0".obs;// 0永久 1显示 2循环 + final fromType = 0.obs;// 0卡 1指纹 2钥匙 final isStressFingerprint = false.obs; var beginTime = "".obs;// 开始时间 @@ -13,6 +14,10 @@ class OtherTypeAddKeyState{ var beginTimeTimestamp = "".obs;// 开始时间时间戳 var endTimeTimestamp = "".obs;// 结束时间时间戳 + var effectiveDateTime = 0.obs;// 生效时间 + var failureDateTime = 0.obs;// 失效时间 + var weekdaysList = [].obs; + final TextEditingController nameController = TextEditingController(); OtherTypeAddKeyState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart new file mode 100644 index 00000000..2db946c8 --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart @@ -0,0 +1,52 @@ + +import 'package:get/get.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'otherTypeKeyChangeDate_state.dart'; + +class OtherTypeKeyChangeDateLogic extends BaseGetXController{ + OtherTypeKeyChangeDateState state = OtherTypeKeyChangeDateState(); + + // 修改指纹信息 + void editFingerprintsData() async{ + var entity = await ApiRepository.to.editFingerprintsData( + fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + weekDay: state.fingerprintItemData.value.weekDay!, + startDate: state.beginTimeTimestamp.value.toString(), + endDate: state.endTimeTimestamp.value.toString(), + isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", + fingerprintName: state.fingerprintItemData.value.fingerprintName!, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "修改成功"); + Get.back(result: { + "beginTimeTimestamp":state.beginTimeTimestamp.value, + "endTimeTimestamp":state.endTimeTimestamp.value, + }); + eventBus.fire(OtherTypeRefreshListEvent()); + } + } + + // 编辑iC卡 + void editICCardData() async{ + var entity = await ApiRepository.to.editICCardData( + cardId: state.fingerprintItemData.value.cardId.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + weekDay: state.fingerprintItemData.value.weekDay!, + startDate: state.beginTimeTimestamp.value.toString(), + endDate: state.endTimeTimestamp.value.toString(), + isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", + cardName: state.fingerprintItemData.value.cardName!, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "修改成功"); + Get.back(result: { + "beginTimeTimestamp":state.beginTimeTimestamp.value, + "endTimeTimestamp":state.endTimeTimestamp.value, + }); + } + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart new file mode 100644 index 00000000..84b96760 --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart @@ -0,0 +1,99 @@ + +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 '../../../../app_settings/app_colors.dart'; +import '../../../../tools/commonItem.dart'; +import '../../../../tools/titleAppBar.dart'; +import '../../../../translations/trans_lib.dart'; +import 'otherTypeKeyChangeDate_logic.dart'; + +class OtherTypeKeyChangeDatePage extends StatefulWidget { + const OtherTypeKeyChangeDatePage({Key? key}) : super(key: key); + + @override + State createState() => _OtherTypeKeyChangeDatePageState(); +} + +class _OtherTypeKeyChangeDatePageState extends State { + final logic = Get.put(OtherTypeKeyChangeDateLogic()); + final state = Get.find().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: () { + // print("state.pushType.value:${state.pushType.value}"); + switch (state.pushType.value) { + case 0: + // 卡 + logic.editICCardData(); + break; + case 1: + // 指纹 + logic.editFingerprintsData(); + break; + case 2: + + break; + default: + break; + } + }, + ), + ], + ), + body: buildMainUI(), + ); + } + + Widget buildMainUI() { + return Column( + children: [ + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, + rightTitle: state.beginTime.value, + isHaveLine: true, + isHaveDirection: true, + action: () { + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + state.beginTimeTimestamp.value = DateTime.parse( + '${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch; + state.beginTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}"; + }); + }); + })), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, + rightTitle: state.endTime.value, + isHaveDirection: true, + action: () { + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + state.endTimeTimestamp.value = DateTime.parse( + '${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch; + state.endTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}"; + }); + }); + })), + ], + ); + } +} diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart new file mode 100644 index 00000000..18dafe75 --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart @@ -0,0 +1,27 @@ + +import 'package:get/get.dart'; + +import '../../../../tools/dateTool.dart'; +import '../otherTypeKeyList/fingerprintListData_entity.dart'; + +class OtherTypeKeyChangeDateState{ + final fingerprintItemData = FingerprintItemData().obs; + + var beginTime = "".obs;// 开始时间 + var endTime = "".obs;// 结束时间 + var beginTimeTimestamp = 0.obs;// 开始时间时间戳 + var endTimeTimestamp = 0.obs;// 结束时间时间戳 + + var pushType = 0.obs;// 0卡 1指纹 2遥控 + + OtherTypeKeyChangeDateState() { + Map map = Get.arguments; + pushType.value = map["pushType"]; + fingerprintItemData.value = map["fingerprintItemData"]; + + beginTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.startDate.toString()); + endTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.endDate.toString()); + beginTimeTimestamp.value = fingerprintItemData.value.startDate!; + endTimeTimestamp.value = fingerprintItemData.value.endDate!; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart new file mode 100644 index 00000000..2f38fcea --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart @@ -0,0 +1,56 @@ + +import 'package:get/get.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'otherTypeKeyChangeValidityDate_state.dart'; + +class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ + OtherTypeKeyChangeValidityDateState state = OtherTypeKeyChangeValidityDateState(); + + // 修改指纹信息 + void editFingerprintsData() async{ + var entity = await ApiRepository.to.editFingerprintsData( + fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + weekDay: state.weekDay.value, + startDate: state.beginTimeTimestamp.value.toString(), + endDate: state.endTimeTimestamp.value.toString(), + isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", + fingerprintName: state.fingerprintItemData.value.fingerprintName!, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "修改成功"); + Get.back(result: { + "beginTimeTimestamp":state.beginTimeTimestamp.value, + "endTimeTimestamp":state.endTimeTimestamp.value, + "weekDay":state.weekDay.value, + }); + eventBus.fire(OtherTypeRefreshListEvent()); + } + } + + // 编辑iC卡 + void editICCardData() async{ + var entity = await ApiRepository.to.editICCardData( + cardId: state.fingerprintItemData.value.cardId.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + weekDay: state.weekDay.value, + startDate: state.beginTimeTimestamp.value.toString(), + endDate: state.endTimeTimestamp.value.toString(), + isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", + cardName: state.fingerprintItemData.value.cardName!, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "修改成功"); + Get.back(result: { + "beginTimeTimestamp":state.beginTimeTimestamp.value, + "endTimeTimestamp":state.endTimeTimestamp.value, + "weekDay":state.weekDay.value, + }); + } + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart new file mode 100644 index 00000000..4e109b42 --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart @@ -0,0 +1,193 @@ + + +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 '../../../../app_settings/app_colors.dart'; +import '../../../../tools/commonItem.dart'; +import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; +import '../../../../translations/trans_lib.dart'; +import 'otherTypeKeyChangeValidityDate_logic.dart'; + +class OtherTypeKeyChangeValidityDatePage extends StatefulWidget { + const OtherTypeKeyChangeValidityDatePage({Key? key}) : super(key: key); + + @override + State createState() => _OtherTypeKeyChangeValidityDatePageState(); +} + +class _OtherTypeKeyChangeValidityDatePageState extends State { + final logic = Get.put(OtherTypeKeyChangeValidityDateLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.normallyOpenMode!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: ListView( + children: [ + Container( + height: 10.h, + color: AppColors.mainBackgroundColor, + ), + topWidget(), + SizedBox(height: 10.h), + bottomWidget(), + Container( + margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h), + child: SubmitBtn( + btnName: TranslationLoader.lanKeys!.save!.tr, + onClick: () { + if(state.pushType.value == 0){ + logic.editICCardData(); + }else if(state.pushType.value == 1){ + logic.editFingerprintsData(); + } + }), + ), + ], + )); + } + + Widget topWidget() { + return Container( + height: 160.h, + width: 1.sw, + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 60.h, + // color: Colors.red, + padding: EdgeInsets.only(left: 30.w, top: 15.h), + child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))), + Container( + height: 100.h, + padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h), + child: GridView.builder( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 7, childAspectRatio: 1.0), + itemCount: 7, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + index += 1; + return btnItem(index); + })), + ], + ), + ); + } + + Widget btnItem(int index) { + String dateStr; + switch (index) { + case 1: + dateStr = TranslationLoader.lanKeys!.mondayShort!.tr; + break; + case 2: + dateStr = TranslationLoader.lanKeys!.tuesdayShort!.tr; + break; + case 3: + dateStr = TranslationLoader.lanKeys!.wednesdayShort!.tr; + break; + case 4: + dateStr = TranslationLoader.lanKeys!.thursdayShort!.tr; + break; + case 5: + dateStr = TranslationLoader.lanKeys!.fridayShort!.tr; + break; + case 6: + dateStr = TranslationLoader.lanKeys!.saturdayShort!.tr; + break; + case 7: + dateStr = TranslationLoader.lanKeys!.sundayShort!.tr; + break; + default: + dateStr = ""; + break; + } + return GestureDetector( + onTap: () { + setState(() { + if(state.weekDay.value.contains(index)){ + state.weekDay.value.remove(index); + }else{ + state.weekDay.value.add(index); + } + state.weekDay.value.sort(); + }); + }, + child: Obx(() => Container( + width: 40.w, + height: 40.w, + margin: EdgeInsets.all(10.w), + decoration: BoxDecoration( + color: state.weekDay.value.contains(index) ? AppColors.mainColor :Colors.white, + border: Border.all(width: 1, color: AppColors.btnDisableColor), + borderRadius: BorderRadius.circular(30.w), + ), + child: Center( + child: Text( + dateStr, + style: TextStyle(fontSize: 20.sp, color: state.weekDay.value.contains(index) ? Colors.white : AppColors.darkGrayTextColor), + )), + )), + ); + } + + Widget bottomWidget() { + return Column( + children: [ + Container( + color: Colors.white, + child: Column( + children: [ + Obx(() => CommonItem( + leftTitel: + "${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}", + rightTitle: state.beginTime.value, + isHaveDirection: true, + isHaveLine: true, + action: () { + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + state.beginTimeTimestamp.value = DateTime.parse( + '${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch; + state.beginTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}"; + }); + }); + })), + Obx(() => CommonItem( + leftTitel: + "${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}", + rightTitle: state.endTime.value, + isHaveDirection: true, + action: () { + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + state.endTimeTimestamp.value = DateTime.parse( + '${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch; + state.endTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}"; + }); + }); + })), + Container(height: 10.h), + ], + ), + ), + ], + ); + } + +} diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_state.dart new file mode 100644 index 00000000..4a00940c --- /dev/null +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_state.dart @@ -0,0 +1,29 @@ + +import 'package:get/get.dart'; + +import '../../../../tools/dateTool.dart'; +import '../otherTypeKeyList/fingerprintListData_entity.dart'; + +class OtherTypeKeyChangeValidityDateState{ + final fingerprintItemData = FingerprintItemData().obs; + + var beginTime = "".obs;// 开始时间 + var endTime = "".obs;// 结束时间 + var beginTimeTimestamp = 0.obs;// 开始时间时间戳 + var endTimeTimestamp = 0.obs;// 结束时间时间戳 + + var pushType = 0.obs;// 0卡 1指纹 2遥控 + var weekDay = [].obs; + + OtherTypeKeyChangeValidityDateState() { + Map map = Get.arguments; + pushType.value = map["pushType"]; + fingerprintItemData.value = map["fingerprintItemData"]; + + beginTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.startDate.toString()); + endTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.endDate.toString()); + beginTimeTimestamp.value = fingerprintItemData.value.startDate!; + endTimeTimestamp.value = fingerprintItemData.value.endDate!; + weekDay.value = fingerprintItemData.value.weekDay!; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_logic.dart index 60fbe6a8..201c5519 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_logic.dart @@ -1,11 +1,74 @@ +import 'package:get/get.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../network/api_repository.dart'; +import '../../../../tools/toast.dart'; import 'otherTypeKeyDetail_state.dart'; class OtherTypeKeyDetailLogic extends BaseGetXController{ OtherTypeKeyDetailState state = OtherTypeKeyDetailState(); + // 编辑指纹 + void editFingerprintsData() async{ + var entity = await ApiRepository.to.editFingerprintsData( + fingerprintId: state.keyId.value.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + weekDay: state.weekDay.value, + startDate: state.effectiveDateTime.value.toString(), + endDate: state.failureDateTime.value.toString(), + isCoerced: state.isStressFingerprint.value ? "2" : "1", + fingerprintName: state.changeNameController.text, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "修改成功"); + Get.back(result: "addScuess"); + } + } + + // 删除指纹 + void deletFingerprintsData() async{ + var entity = await ApiRepository.to.deletFingerprintsData( + fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + type: "0", + deleteType:"1" + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "删除成功"); + Get.back(result: "addScuess"); + } + } + + // 编辑iC卡 + void editICCardData() async{ + var entity = await ApiRepository.to.editICCardData( + cardId: state.keyId.value.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + weekDay: state.weekDay.value, + startDate: state.effectiveDateTime.value.toString(), + endDate: state.failureDateTime.value.toString(), + isCoerced: state.isStressFingerprint.value ? "2" : "1", + cardName: state.changeNameController.text, + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "修改成功"); + Get.back(result: "addScuess"); + } + } + + // 删除IC卡 + void deletICCardData() async{ + var entity = await ApiRepository.to.deletIcCardData( + cardId: state.fingerprintItemData.value.cardId.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + type: "0", + deleteType:"1" + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "删除成功"); + Get.back(result: "addScuess"); + } + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart index 9415e50e..26be1af0 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart @@ -6,8 +6,11 @@ import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; +import '../../../../tools/dateTool.dart'; +import '../../../../tools/showTFView.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; +import '../../../../tools/toast.dart'; import '../../../../translations/trans_lib.dart'; import 'otherTypeKeyDetail_logic.dart'; @@ -24,71 +27,171 @@ class _OtherTypeKeyDetailPageState extends State { @override Widget build(BuildContext context) { - var type = ModalRoute.of(context)?.settings.arguments as int; - return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: "${getAppBarTitle(type)}${TranslationLoader.lanKeys!.number!.tr}", + barTitle: "${getAppBarTitle(state.type.value)}${TranslationLoader.lanKeys!.number!.tr}", haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ - TextButton( - child: Text(TranslationLoader.lanKeys!.share!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),), - onPressed: () { - - }, - ), - ], + // actionsList: [ + // TextButton( + // child: Text(TranslationLoader.lanKeys!.share!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),), + // onPressed: () { + // + // }, + // ), + // ], ), body: Column( children: [ - CommonItem( - leftTitel: "${getAppBarTitle(type)}${TranslationLoader.lanKeys!.number!.tr}", - rightTitle: "98765432", - isHaveDirection: true, - isHaveLine: true, - action: () { - showCupertinoAlertDialog(context); - }), - CommonItem( + Obx(() => CommonItem( + leftTitel: "${getAppBarTitle(state.type.value)}${TranslationLoader.lanKeys!.number!.tr}", + rightTitle: state.typeNumber.value, + isHaveDirection: false, + isHaveLine: true)), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "你好", + rightTitle: state.typeName.value, isHaveDirection: true, isHaveLine: true, action: () { showCupertinoAlertDialog(context); - }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "永久", - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.electronicKeyDetailChangeDate); - }), + })), + Obx(() => Visibility( + visible: (state.keyType.value == 4 || state.keyType.value == 2) ? true : false, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, + allHeight: 70.h, + // rightTitle:"2023.09.19 11:27\n2023.09.25 11:27", + rightTitle: state.keyType.value == 1 ? "永久" : "${DateTool().dateToYMDHNString(state.effectiveDateTime.value.toString())}\n${DateTool().dateToYMDHNString(state.failureDateTime.value.toString())}", + isHaveDirection: true, + isHaveLine: true, + action: () async { + // switch(state.type.value){ + // case 0: + // // 卡 + // + // break; + // case 1: + // 当是指纹的时候 + if(state.keyType.value == 2){ + // 限时 + var data = await Get.toNamed(Routers.otherTypeKeyChangeDatePage, arguments: { + "pushType": state.type.value, + "fingerprintItemData": state.fingerprintItemData.value, + }); + if(data != null) { + setState(() { + state.effectiveDateTime.value = data["beginTimeTimestamp"]; + state.failureDateTime.value = data["endTimeTimestamp"]; + }); + } + }else if(state.keyType.value == 4){ + // 循环 + var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: { + "pushType": state.type.value, + "fingerprintItemData": state.fingerprintItemData.value, + }); + if(data != null) { + setState(() { + state.effectiveDateTime.value = data["beginTimeTimestamp"]; + state.failureDateTime.value = data["endTimeTimestamp"]; + state.weekDay.value = data["weekDay"]; + }); + } + } + // break; + // case 2: + // // 遥控 + // + // break; + // } + }))), + Obx(() => Visibility( + visible: state.keyType.value == 4 ? true : false, + child: Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr, + rightTitle: state.weekDay.value.join(','), + isHaveDirection: true, + action: () async { + // switch(state.type.value){ + // case 0: + // // 卡 + // + // break; + // case 1: + // 当是指纹的时候 + var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: { + "pushType": state.type.value, + "fingerprintItemData": state.fingerprintItemData.value, + }); + if(data != null) { + setState(() { + state.effectiveDateTime.value = data["beginTimeTimestamp"]; + state.failureDateTime.value = data["endTimeTimestamp"]; + state.weekDay.value = data["weekDay"]; + }); + } + // break; + // case 2: + // // 遥控 + // + // break; + // } + }))) + ), Container(height: 10.h), - CommonItem( + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.additive!.tr, - rightTitle: "15080825640", + rightTitle: state.adder.value, action: () { - }), - CommonItem( + })), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.addTime!.tr, - rightTitle: "2020.06.21 11:49", + rightTitle: DateTool().dateToYMDHNString(state.addTime.value.toString()), action: () { - }), + })), + SizedBox(height: 10.h), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr, + rightTitle: "", + isTipsImg: false, + isHaveRightWidget: true, + rightWidget: SizedBox( + width: 60.w, height: 50.h, child: _isStressFingerprint()))), Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr, rightTitle: "", isHaveDirection: true, action: () { - Get.toNamed(Routers.keyOperationRecordPage); + switch (state.type.value) { + case 0: + // 卡 + Get.toNamed(Routers.keyOperationRecordPage, arguments: { + 'lockId': state.fingerprintItemData.value.lockId.toString(), + 'cardId': state.fingerprintItemData.value.cardId.toString() + }); + break; + case 1: + // 指纹 + Get.toNamed(Routers.keyOperationRecordPage, arguments: { + 'lockId': state.fingerprintItemData.value.lockId.toString(), + 'fingerprintId': state.fingerprintItemData.value.fingerprintId.toString() + }); + break; + case 2: + + break; + default: + break; + } + }), - SizedBox(height: 40.h), - addControlsBtn(type), + // SizedBox(height: 40.h), + // addControlsBtn(type), SizedBox(height: 30.h), SubmitBtn( btnName: TranslationLoader.lanKeys!.delete!.tr, @@ -97,13 +200,57 @@ class _OtherTypeKeyDetailPageState extends State { margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { + switch (state.type.value) { + case 0: + // 卡 + logic.deletICCardData(); + break; + case 1: + // 指纹 + logic.deletFingerprintsData(); + break; + case 2: + break; + default: + break; + } }), ], ), ); } + //isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹 + CupertinoSwitch _isStressFingerprint() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: state.isStressFingerprint.value, + onChanged: (value) { + setState(() { + state.isStressFingerprint.value = value; + switch(state.type.value){ + case 0: + // 卡 + logic.editICCardData(); + break; + case 1: + // 指纹 + logic.editFingerprintsData(); + break; + case 2: + // 遥控 + + break; + } + + }); + }, + ); + } + Widget addControlsBtn(int type) { List widgetList = []; List> routerList = []; @@ -212,139 +359,38 @@ class _OtherTypeKeyDetailPageState extends State { return title; } - Widget commonItem(String leftTitle, String rightTitle, - {bool isHaveDirection = false, - bool isHaveLine = false, - bool isHaveRightWidget = false, - Widget? rightWidget, - Function()? action}) { - return GestureDetector( - onTap: action, - child: Column( - // mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - // height: 80.h, - color: Colors.white, - padding: EdgeInsets.only( - left: 20.w, right: 10.w, top: 20.w, bottom: 20.w), - child: Row( - children: [ - SizedBox(width: 20.w), - Text( - leftTitle, - style: - TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500), - ), - SizedBox(width: 20.w), - Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - isHaveRightWidget - ? rightWidget! - : Text( - rightTitle, - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 28.sp, fontWeight: FontWeight.w500), - ) - ], - ), - ), - SizedBox(width: 5.w), - isHaveDirection - ? Image.asset( - 'images/icon_right.png', - width: 50.w, - height: 50.w, - ) - : SizedBox(width: 10.w), - // SizedBox(width:10.w), - ], - ), - ), - isHaveLine - ? Container( - height: 0.5.h, - color: Colors.grey, - ) - : Container() - ], - ), - ); - } - void showCupertinoAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { - return Card( - color: const Color(0x00FFFFFF), - child: CupertinoAlertDialog( - title: const Text("修改密码"), - content: Column( - children: [ - const SizedBox( - height: 10, - ), - Container( - height: 80.h, - // color: Colors.white, - margin: EdgeInsets.all(10.w), - child: const TextField( - //输入框一行 - maxLines: 1, - // controller: _controller, - autofocus: false, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - // contentPadding: const EdgeInsets.only( - // top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), - hintText: "请输入要修改的名字", - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - // icon: Padding( - // padding: EdgeInsets.only(top:30.w, bottom: 20.w, right: 20.w, left: 20.w), - // child: Image.asset('images/main/icon_main_search.png', width: 40.w, height: 40.w,), - // ), - // //右边图标设置 - // suffixIcon: GestureDetector( - // onTap: () { - // //addPostFrameCallback是 StatefulWidge 渲染结束的回调,只会被调用一次 - // // SchedulerBinding.instance.addPostFrameCallback((_) { - // // _controller.text = ""; - // // }); - // }, - // child: Padding( - // padding: EdgeInsets.all(8), - // child: Image.asset('images/main/icon_main_cell.png', width: 50.w, height: 50.w,), - // ), - // ) - ), - ), - ) - ], - ), - actions: [ - CupertinoDialogAction( - child: const Text("取消"), - onPressed: () { - Navigator.pop(context); - // print("取消"); - }, - ), - CupertinoDialogAction( - child: const Text("确定"), - onPressed: () { - Navigator.pop(context); - // print("确定"); - }, - ), - ], - ), - ); + return ShowTFView( + title: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", + tipTitle: "", + controller: state.changeNameController, + sureClick: () { + if(state.changeNameController.text.isEmpty){ + Toast.show(msg: "请输入姓名"); + return; + } + Get.back(); + switch(state.type.value){ + case 0: + // 卡 + logic.editICCardData(); + break; + case 1: + // 指纹 + logic.editFingerprintsData(); + break; + case 2: + // 遥控 + + break; + } + }, + cancelClick: () { + Get.back(); + },); }); } } diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_state.dart index 73a22aef..8d2fcb85 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_state.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_state.dart @@ -1,4 +1,62 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../../tools/dateTool.dart'; +import '../otherTypeKeyList/fingerprintListData_entity.dart'; + class OtherTypeKeyDetailState{ + final fingerprintItemData = FingerprintItemData().obs; + final type = 0.obs;// 0卡 1指纹 2遥控 + final TextEditingController changeNameController = TextEditingController(); + + final typeNumber = "".obs;// 指纹号 + final typeName = "".obs;// 指纹名字 + var effectiveDateTime = 0.obs;// 生效时间 + var failureDateTime = 0.obs;// 失效时间 + final keyType = 0.obs;// 永久:1;限时2,单次3,循环:4 + var weekDay = [].obs;// 有效日 + var adder = "".obs;// 添加者 + var addTime = 0.obs;// 添加时间 + var keyId = 0.obs;// 添加时间 + + final isStressFingerprint = false.obs; + OtherTypeKeyDetailState() { + Map map = Get.arguments; + type.value = map["type"]; + if(type.value == 0){ + // 0卡 + fingerprintItemData.value = map["fingerprintItemData"]; + keyId.value = fingerprintItemData.value.cardId!; + typeNumber.value = fingerprintItemData.value.cardNumber!; + typeName.value = fingerprintItemData.value.cardName!; + changeNameController.text = typeName.value; + effectiveDateTime.value = fingerprintItemData.value.startDate!; + failureDateTime.value = fingerprintItemData.value.endDate!; + keyType.value = fingerprintItemData.value.cardType!; + adder.value = fingerprintItemData.value.senderUsername!; + addTime.value = fingerprintItemData.value.createDate!; + isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false; + weekDay.value = fingerprintItemData.value.weekDay!; + }else if(type.value == 1){ + // 1指纹 + fingerprintItemData.value = map["fingerprintItemData"]; + keyId.value = fingerprintItemData.value.fingerprintId!; + typeNumber.value = fingerprintItemData.value.fingerprintNumber!; + typeName.value = fingerprintItemData.value.fingerprintName!; + changeNameController.text = typeName.value; + effectiveDateTime.value = fingerprintItemData.value.startDate!; + failureDateTime.value = fingerprintItemData.value.endDate!; + keyType.value = fingerprintItemData.value.fingerprintType!; + adder.value = fingerprintItemData.value.senderUsername!; + addTime.value = fingerprintItemData.value.createDate!; + isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false; + weekDay.value = fingerprintItemData.value.weekDay!; + }else if(type.value == 2){ + // 2遥控 + + } + + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart index 5db8a804..6f834b34 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart @@ -62,62 +62,86 @@ class Data { } class FingerprintItemData { - int? status; + int? fingerprintStatus; int? lockId; int? createDate; String? fingerprintName; int? endDate; - String? userId; + int? apiUserId; String? nickName; int? isCoerced; int? startDate; String? fingerprintNumber; int? fingerprintType; int? fingerprintId; + String? senderUsername; + List? weekDay; + String? cardName; + String? cardNumber; + int? cardType; + int? cardId; FingerprintItemData( - {this.status, + { this.fingerprintStatus, this.lockId, this.createDate, this.fingerprintName, this.endDate, - this.userId, + this.apiUserId, this.nickName, this.isCoerced, this.startDate, this.fingerprintNumber, this.fingerprintType, - this.fingerprintId}); + this.fingerprintId, + this.senderUsername, + this.weekDay, + this.cardName, + this.cardNumber, + this.cardType, + this.cardId}); FingerprintItemData.fromJson(Map json) { - status = json['status']; + fingerprintStatus = json['fingerprintStatus']; lockId = json['lockId']; createDate = json['createDate']; fingerprintName = json['fingerprintName']; endDate = json['endDate']; - userId = json['userId']; + apiUserId = json['apiUserId']; nickName = json['nickName']; isCoerced = json['isCoerced']; startDate = json['startDate']; fingerprintNumber = json['fingerprintNumber']; fingerprintType = json['fingerprintType']; fingerprintId = json['fingerprintId']; + senderUsername = json['senderUsername']; + weekDay = json['weekDay']; + cardName = json['cardName']; + cardNumber = json['cardNumber']; + cardType = json['cardType']; + cardId = json['cardId']; } Map toJson() { final Map data = {}; - data['status'] = status; + data['fingerprintStatus'] = fingerprintStatus; data['lockId'] = lockId; data['createDate'] = createDate; data['fingerprintName'] = fingerprintName; data['endDate'] = endDate; - data['userId'] = userId; + data['apiUserId'] = apiUserId; data['nickName'] = nickName; data['isCoerced'] = isCoerced; data['startDate'] = startDate; data['fingerprintNumber'] = fingerprintNumber; data['fingerprintType'] = fingerprintType; data['fingerprintId'] = fingerprintId; + data['senderUsername'] = senderUsername; + data['weekDay'] = weekDay; + data['cardName'] = cardName; + data['cardNumber'] = cardNumber; + data['cardType'] = cardType; + data['cardId'] = cardId; return data; } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart index 467d885c..eb2fa652 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart @@ -14,7 +14,9 @@ import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; +import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; +import '../../../../tools/toast.dart'; import 'otherTypeKeyList_state.dart'; class OtherTypeKeyListLogic extends BaseGetXController{ @@ -267,13 +269,62 @@ class OtherTypeKeyListLogic extends BaseGetXController{ lockId: state.lockId.value.toString(), pageNo: '1', pageSize: '20', - searchStr: '', + searchStr: state.searchController.text, ); if(entity.errorCode!.codeIsSuccessful){ state.fingerprintItemListData.value = entity.data!.list!; } } + // 重置所有的指纹 + void deletAllFingerprintsData() async{ + var entity = await ApiRepository.to.deletFingerprintsData( + fingerprintId: "", + lockId: state.lockId.value.toString(), + type: "1", + deleteType:"1" + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "重置成功"); + getFingerprintsListData(); + } + } + + // 获取IC卡列表 + void getICCardListData() async{ + var entity = await ApiRepository.to.getICCardListData( + lockId: state.lockId.value.toString(), + pageNo: '1', + pageSize: '20', + searchStr: state.searchController.text, + ); + if(entity.errorCode!.codeIsSuccessful){ + state.fingerprintItemListData.value = entity.data!.list!; + } + } + + // 删除所有IC卡 + void deletICCardData() async{ + var entity = await ApiRepository.to.deletIcCardData( + cardId: "", + lockId: state.lockId.value.toString(), + type: "1", + deleteType:"1" + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "重置成功"); + getICCardListData(); + } + } + + // 监听修改完详情之后刷新列表 + late StreamSubscription _teamEvent; + void _initRefreshAction() { + _teamEvent = eventBus.on().listen((event) { + getFingerprintsListData(); + }); + } + @override void onReady() { // TODO: implement onReady @@ -282,7 +333,24 @@ class OtherTypeKeyListLogic extends BaseGetXController{ _initReplySubscription(); - getFingerprintsListData(); + _initRefreshAction(); + + switch (state.fromType.value) { + case 0: + // 卡 + getICCardListData(); + break; + case 1: + // 指纹 + getFingerprintsListData(); + break; + case 2: + // 遥控 + + break; + default: + break; + } } @override @@ -301,5 +369,6 @@ class OtherTypeKeyListLogic extends BaseGetXController{ // TODO: implement onClose super.onClose(); _replySubscription.cancel(); + _teamEvent.cancel(); } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart index 4308fd43..ba9ba0d1 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart @@ -37,7 +37,24 @@ class _OtherTypeKeyListPageState extends State { TranslationLoader.lanKeys!.reset!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp), ), - onPressed: () {}, + onPressed: () { + switch (state.fromType.value) { + case 0: + // 卡 + logic.deletICCardData(); + break; + case 1: + // 指纹 + logic.deletAllFingerprintsData(); + break; + case 2: + // 遥控 + + break; + default: + break; + } + }, ), ], ), @@ -49,15 +66,29 @@ class _OtherTypeKeyListPageState extends State { ), Expanded(child: _buildMainUI(state.fromType.value)), AddBottomWhiteBtn( - btnName: - '${TranslationLoader.lanKeys!.add!.tr}${getAppBarTitle(state.fromType.value)}', + btnName: '${TranslationLoader.lanKeys!.add!.tr}${getAppBarTitle(state.fromType.value)}', onClick: () async { var data = await Get.toNamed(Routers.otherTypeKeyManagePage, arguments: { "lockId": state.lockId.value, "fromType": state.fromType.value }); if(data != null) { - logic.getFingerprintsListData(); + switch (state.fromType.value) { + case 0: + // 卡 + logic.getICCardListData(); + break; + case 1: + // 指纹 + logic.getFingerprintsListData(); + break; + case 2: + // 遥控 + + break; + default: + break; + } } }, ), @@ -96,13 +127,36 @@ class _OtherTypeKeyListPageState extends State { child: TextField( //输入框一行 maxLines: 1, - // controller: _controller, + controller: state.searchController, autofocus: false, + onChanged: (value){ + print("onChanged:$value"); + }, + onEditingComplete: (){ + print("onEditingComplete:"); + }, + onSubmitted: (value){ + switch (state.fromType.value) { + case 0: + // 卡 + logic.getICCardListData(); + break; + case 1: + // 指纹 + logic.getFingerprintsListData(); + break; + case 2: + // 遥控 + break; + default: + break; + } + + }, decoration: InputDecoration( //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), + contentPadding: const EdgeInsets.only(top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), //不需要输入框下划线 @@ -123,26 +177,54 @@ class _OtherTypeKeyListPageState extends State { } Widget _buildMainUI(int type) { - String typeImgName = ""; - if (type == 0) { - //卡 - typeImgName = 'images/icon_card.png'; - } else if (type == 1) { - //指纹 - typeImgName = 'images/icon_fingerprint.png'; - } else { - //遥控 - typeImgName = 'images/icon_card.png'; - } + // String typeImgName = ""; + // if (type == 0) { + // //卡 + // typeImgName = 'images/icon_card.png'; + // } else if (type == 1) { + // //指纹 + // typeImgName = 'images/icon_fingerprint.png'; + // } else if (type == 2) { + // //遥控 + // typeImgName = 'images/icon_card.png'; + // } return Obx(() => state.fingerprintItemListData.value.isNotEmpty ? ListView.separated( itemCount: state.fingerprintItemListData.value.length, itemBuilder: (c, index) { FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index]; - return _keyItem(typeImgName, fingerprintItemData.fingerprintName!, fingerprintItemData.fingerprintType! == 1 ? "永久" : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", () { - Get.toNamed(Routers.otherTypeKeyDetailPage, - arguments: type); - }); + switch (state.fromType.value) { + case 0: + // 卡 + return _keyItem('images/icon_card.png', fingerprintItemData.cardName!, fingerprintItemData.cardType! == 1 ? "永久" : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", () async { + var data = await Get.toNamed(Routers.otherTypeKeyDetailPage, arguments: { + "fingerprintItemData": fingerprintItemData, + "type": type, + }); + if(data != null) { + logic.getICCardListData(); + } + }); + break; + case 1: + // 指纹 + return _keyItem('images/icon_fingerprint.png', fingerprintItemData.fingerprintName!, fingerprintItemData.fingerprintType! == 1 ? "永久" : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", () async { + var data = await Get.toNamed(Routers.otherTypeKeyDetailPage, arguments: { + "fingerprintItemData": fingerprintItemData, + "type": type, + }); + if(data != null) { + logic.getFingerprintsListData(); + } + }); + break; + case 2: + // 遥控 + + break; + default: + break; + } }, separatorBuilder: (BuildContext context, int index) { return const Divider( diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart index 6bde10b8..8f14cda6 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart @@ -1,4 +1,5 @@ +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'fingerprintListData_entity.dart'; @@ -8,6 +9,7 @@ class OtherTypeKeyListState{ final fromType = 0.obs; final fingerprintItemListData = [].obs; + final TextEditingController searchController = TextEditingController(); OtherTypeKeyListState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_tabbar.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_tabbar.dart index 2ed18add..34e8f88d 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_tabbar.dart @@ -10,7 +10,7 @@ import '../otherTypeAddKey/otherTypeAddKey_page.dart'; class OtherTypeKeyManageTabbar extends StatefulWidget { var initialIndex = 1; var lockType = 0; - var lockId = 0; // 0卡 1指纹 2钥匙 + var lockId = 0; OtherTypeKeyManageTabbar( {Key? key, required this.initialIndex, required this.lockType, required this.lockId}) : super(key: key); diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index f7007b6e..cd7955f5 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -79,6 +79,14 @@ abstract class Api { final String getFingerprintListURL = '/fingerprint/list'; // 指纹列表 final String addFingerprintURL = '/fingerprint/add'; // 添加指纹 + final String editFingerprintURL = '/fingerprint/changePeriod'; // 编辑指纹 + final String deleteFingerprintURL = '/fingerprint/delete'; // 删除指纹 + final String updateFingerprintUserNoURL = '/fingerprint/updateFingerprintUserNo'; // 更新指纹用户序号 + + final String getICCardListURL = '/identityCard/list'; // IC卡列表 + final String addICCardURL = '/identityCard/add'; // 添加IC卡 + final String editICCardURL = '/identityCard/update'; // 编辑IC卡 + final String deleteICCardURL = '/identityCard/delete'; // 删除IC卡 final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息 final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index e84b3b6f..4093233b 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -804,7 +804,7 @@ class ApiProvider extends BaseProvider { String fingerprintType, String isCoerced, String startDate, - String cyclicConfig,) => + List weekDay,) => post( addFingerprintURL.toUrl, jsonEncode({ @@ -816,9 +816,135 @@ class ApiProvider extends BaseProvider { 'fingerprintType': fingerprintType, 'isCoerced': isCoerced, 'startDate': startDate, - 'cyclicConfig': cyclicConfig, + 'weekDay': weekDay, })); + // 编辑指纹 + Future editFingerprintsData( + String fingerprintId, + String lockId, + List weekDay, + String startDate, + String endDate, + String isCoerced, + String fingerprintName) => + post( + editFingerprintURL.toUrl, + jsonEncode({ + 'fingerprintId': fingerprintId, + 'lockId': lockId, + 'weekDay': weekDay, + 'startDate': startDate, + 'endDate': endDate, + 'isCoerced': isCoerced, + 'fingerprintName': fingerprintName + }) + ); + + // 删除指纹 + Future deletFingerprintsData( + String fingerprintId, + String lockId, + String type, + String deleteType) => + post( + deleteFingerprintURL.toUrl, + jsonEncode({ + 'fingerprintId': fingerprintId, + 'lockId': lockId, + 'type': type, + 'deleteType': deleteType + }) + ); + + // 更新指纹用户序号 + Future updateFingerprintUserNoLoadData( + String fingerprintId, + String lockId, + String fingerprintUserNo) => + post( + updateFingerprintUserNoURL.toUrl, + jsonEncode({ + 'fingerprintId': fingerprintId, + 'lockId': lockId, + 'fingerprintUserNo': fingerprintUserNo + }) + ); + + // 获取IC卡列表 + Future getICCardListData(String lockId, String pageNo, String pageSize, String searchStr) => + post( + getICCardListURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'pageNo': pageNo, + 'pageSize': pageSize, + 'searchStr': searchStr, + })); + + // 添加卡 + Future addICCardData( + String lockId, + String endDate, + String cardName, + String cardNumber, + String cardType, + String addType, + String startDate, + String isCoerced, + List weekDay,) => + post( + addICCardURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'endDate': endDate, + 'cardName': cardName, + 'cardNumber': cardNumber, + 'cardType': cardType, + 'addType': addType, + 'startDate': startDate, + 'isCoerced': isCoerced, + 'weekDay': weekDay + })); + + // 编辑ICCard + Future editICCardData( + String lockId, + String cardId, + String cardName, + String startDate, + String endDate, + String isCoerced, + List weekDay) => + post( + editICCardURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'cardId': cardId, + 'cardName': cardName, + 'startDate': startDate, + 'endDate': endDate, + 'isCoerced': isCoerced, + 'weekDay': weekDay + }) + ); + + // 删除卡 + Future deletIcCardData( + String cardId, + String lockId, + String type, + String deleteType) => + post( + deleteICCardURL.toUrl, + jsonEncode({ + 'cardId': cardId, + 'lockId': lockId, + 'type': type, + 'deleteType': deleteType + }) + ); + Future listLockByGroup(String type, String keyGroupId) => post( listLockByGroupURL.toUrl, jsonEncode({'type': type, 'keyGroupId': keyGroupId})); diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 2f3f776c..a10cf287 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -885,10 +885,111 @@ class ApiRepository { required String fingerprintType, required String isCoerced, required String startDate, - required String cyclicConfig, + required List weekDay, }) async { final res = - await apiProvider.addFingerprintsData(lockId, endDate, addType, fingerprintName, fingerprintNumber, fingerprintType, isCoerced, startDate, cyclicConfig); + await apiProvider.addFingerprintsData(lockId, endDate, addType, fingerprintName, fingerprintNumber, fingerprintType, isCoerced, startDate, weekDay); return CheckingInListMonthEntity.fromJson(res.body); } + + // 编辑指纹 + Future editFingerprintsData( + { + required String fingerprintId, + required String lockId, + required List weekDay, + required String startDate, + required String endDate, + required String isCoerced, + required String fingerprintName + }) async { + final res = + await apiProvider.editFingerprintsData(fingerprintId, lockId, weekDay, startDate, endDate, isCoerced, fingerprintName); + return LoginEntity.fromJson(res.body); + } + + // 删除指纹 + Future deletFingerprintsData( + { + required String fingerprintId, + required String lockId, + required String type, + required String deleteType + }) async { + final res = + await apiProvider.deletFingerprintsData(fingerprintId, lockId, type, deleteType); + return LoginEntity.fromJson(res.body); + } + + // 更新指纹用户序号 + Future updateFingerprintUserNoLoadData( + { + required String fingerprintId, + required String lockId, + required String fingerprintUserNo + }) async { + final res = + await apiProvider.updateFingerprintUserNoLoadData(fingerprintId, lockId, fingerprintUserNo); + return LoginEntity.fromJson(res.body); + } + + // 获取Ic卡列表 + Future getICCardListData( + { + required String lockId, + required String pageNo, + required String pageSize, + required String searchStr, + }) async { + final res = + await apiProvider.getICCardListData(lockId, pageNo, pageSize, searchStr); + return FingerprintListDataEntity.fromJson(res.body); + } + + // 添加ID卡 + Future addICCardData( + { + required String lockId, + required String endDate, + required String cardName, + required String cardNumber, + required String cardType, + required String addType, + required String startDate, + required String isCoerced, + required List weekDay, + }) async { + final res = + await apiProvider.addICCardData(lockId, endDate, cardName, cardNumber, cardType, addType, startDate, isCoerced, weekDay); + return CheckingInListMonthEntity.fromJson(res.body); + } + + // 编辑IC卡 + Future editICCardData( + { + required String lockId, + required String cardId, + required String cardName, + required String startDate, + required String endDate, + required String isCoerced, + required List weekDay + }) async { + final res = + await apiProvider.editICCardData(lockId, cardId, cardName, startDate, endDate, isCoerced, weekDay); + return LoginEntity.fromJson(res.body); + } + + // 删除ic卡 + Future deletIcCardData( + { + required String cardId, + required String lockId, + required String type, + required String deleteType + }) async { + final res = + await apiProvider.deletIcCardData(cardId, lockId, type, deleteType); + return LoginEntity.fromJson(res.body); + } } diff --git a/star_lock/lib/tools/commonItem.dart b/star_lock/lib/tools/commonItem.dart index 50eac58f..bb2a8c5f 100644 --- a/star_lock/lib/tools/commonItem.dart +++ b/star_lock/lib/tools/commonItem.dart @@ -61,8 +61,8 @@ class CommonItem extends StatelessWidget { : Text( rightTitle ?? "", textAlign: TextAlign.end, - overflow: TextOverflow.ellipsis, - maxLines: 1, + // overflow: TextOverflow.ellipsis, + // maxLines: 1, style: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor), diff --git a/star_lock/lib/tools/eventBusEventManage.dart b/star_lock/lib/tools/eventBusEventManage.dart index 3ab53173..6cffeaba 100644 --- a/star_lock/lib/tools/eventBusEventManage.dart +++ b/star_lock/lib/tools/eventBusEventManage.dart @@ -19,3 +19,8 @@ class PassCurrentLockInformationEvent{ KeyInfos keyInfo; PassCurrentLockInformationEvent(this.keyInfo); } + +/// 卡、密码、指纹修改之后刷新列表 +class OtherTypeRefreshListEvent{ + OtherTypeRefreshListEvent(); +} diff --git a/star_lock/lib/translations/lanKeyEntity.dart b/star_lock/lib/translations/lanKeyEntity.dart index 543a9043..3206c9a8 100644 --- a/star_lock/lib/translations/lanKeyEntity.dart +++ b/star_lock/lib/translations/lanKeyEntity.dart @@ -388,7 +388,9 @@ class LanKeyEntity { this.pleaseEnterWifiPwd, this.wifiDistributionNetwork, this.attendanceRecord, - this.edit + this.edit, + this.stressFingerprint, + this.effectiveDay }); LanKeyEntity.fromJson(dynamic json) { @@ -811,6 +813,8 @@ class LanKeyEntity { wifiDistributionNetwork = json['wifiDistributionNetwork']; attendanceRecord = json['attendanceRecord']; edit = json['edit']; + stressFingerprint = json['stressFingerprint']; + effectiveDay = json['effectiveDay']; } String? starLock; String? clickUnlockAndHoldDownClose; @@ -1219,6 +1223,8 @@ class LanKeyEntity { String? wifiDistributionNetwork; String? attendanceRecord; String? edit; + String? stressFingerprint; + String? effectiveDay; Map toJson() { final map = {}; map['starLock'] = starLock; @@ -1637,6 +1643,8 @@ class LanKeyEntity { map['wifiDistributionNetwork'] = wifiDistributionNetwork; map['attendanceRecord'] = attendanceRecord; map['edit'] = edit; + map['stressFingerprint'] = stressFingerprint; + map['effectiveDay'] = effectiveDay; return map; } }