From cf5b7e621244d469e1cab75501d7fdfedf703c2a Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Mon, 4 Sep 2023 15:04:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=8D=95=E6=8A=8A=E9=92=A5=E5=8C=99=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=80=9F=E5=8F=A3=202=EF=BC=8C=E9=94=81=E8=AE=BE=E7=BD=AE-?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E9=80=BB=E8=BE=91=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basicInformation/KeyDetailEntity.dart | 149 ++++++++++ .../basicInformation_page.dart | 257 +++++++++++------- .../lcokSet/lockSet/lockSet_page.dart | 4 +- star_lock/lib/network/api.dart | 1 + star_lock/lib/network/api_provider.dart | 3 + star_lock/lib/network/api_repository.dart | 7 + star_lock/lib/tools/commonItem.dart | 2 + 7 files changed, 323 insertions(+), 100 deletions(-) create mode 100644 star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart new file mode 100644 index 00000000..01064de4 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart @@ -0,0 +1,149 @@ +class KeyDetailEntity { + int? errorCode; + String? description; + String? errorMsg; + LockData? data; + + KeyDetailEntity({this.errorCode, this.description, this.errorMsg, this.data}); + + KeyDetailEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? LockData.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class LockData { + int? keyId; + int? lockId; + String? lockName; + String? lockAlias; + int? userType; + int? keyStatus; + int? startDate; + int? endDate; + int? keyRight; + int? keyType; + String? remarks; + int? remoteEnable; + int? appUnlockMustOnline; + int? lockUserNo; + LockItem? lockData; + String? lockMac; + int? noKeyPwd; + int? electricQuantity; + String? featureValue; + String? groupId; + String? groupName; + + LockData( + {this.keyId, + this.lockId, + this.lockName, + this.lockAlias, + this.userType, + this.keyStatus, + this.startDate, + this.endDate, + this.keyRight, + this.keyType, + this.remarks, + this.remoteEnable, + this.appUnlockMustOnline, + this.lockUserNo, + this.lockData, + this.lockMac, + this.noKeyPwd, + this.electricQuantity, + this.featureValue, + this.groupId, + this.groupName}); + + LockData.fromJson(Map json) { + keyId = json['keyId']; + lockId = json['lockId']; + lockName = json['lockName']; + lockAlias = json['lockAlias']; + userType = json['userType']; + keyStatus = json['keyStatus']; + json['startDate'] != null ? startDate = json['startDate'] : 0; + json['endDate'] != null ? endDate = json['endDate'] : 0; + keyRight = json['keyRight']; + keyType = json['keyType']; + json['remarks'] != null ? remarks = json['remarks'] : ""; + json['remoteEnable'] != null ? remoteEnable = json['remoteEnable'] : 0; + json['appUnlockMustOnline'] != null + ? appUnlockMustOnline = json['appUnlockMustOnline'] + : 0; + json['lockUserNo'] != null ? lockUserNo = json['lockUserNo'] : 0; + lockData = + json['lockData'] != null ? LockItem.fromJson(json['lockData']) : null; + lockMac = json['lockMac']; + json['noKeyPwd'] != null ? noKeyPwd = json['noKeyPwd'] : 0; + json['electricQuantity'] != null + ? electricQuantity = json['electricQuantity'] + : 0; + json['featureValue'] != null ? featureValue = json['featureValue'] : ""; + json['groupId'] != null ? groupId = json['groupId'] : ""; + groupName = json['groupName']; + } + + Map toJson() { + final Map data = {}; + data['keyId'] = keyId; + data['lockId'] = lockId; + data['lockName'] = lockName; + data['lockAlias'] = lockAlias; + data['userType'] = userType; + data['keyStatus'] = keyStatus; + data['startDate'] = startDate; + data['endDate'] = endDate; + data['keyRight'] = keyRight; + data['keyType'] = keyType; + data['remarks'] = remarks; + data['remoteEnable'] = remoteEnable; + data['appUnlockMustOnline'] = appUnlockMustOnline; + data['lockUserNo'] = lockUserNo; + if (lockData != null) { + data['lockData'] = lockData!.toJson(); + } + data['lockMac'] = lockMac; + data['noKeyPwd'] = noKeyPwd; + data['electricQuantity'] = electricQuantity; + data['featureValue'] = featureValue; + data['groupId'] = groupId; + data['groupName'] = groupName; + return data; + } +} + +class LockItem { + String? lockName; + String? lockMac; + + LockItem({this.lockName, this.lockMac}); + + LockItem.fromJson(Map json) { + lockName = json['lockName']; + lockMac = json['lockMac']; + } + + Map toJson() { + final Map data = {}; + data['lockName'] = lockName; + data['lockMac'] = lockMac; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart index 65b17056..b1958f98 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart @@ -1,6 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; +import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -19,6 +23,8 @@ class BasicInformationPage extends StatefulWidget { class _BasicInformationPageState extends State { late String _groupName = ""; + late KeyInfos keyInfo; + late LockMainEntity lockMainEntity; @override void initState() { @@ -28,115 +34,168 @@ class _BasicInformationPageState extends State { @override Widget build(BuildContext context) { + dynamic obj = ModalRoute.of(context)?.settings.arguments; + if (obj != null && (obj["keyInfo"] != null)) { + keyInfo = obj["keyInfo"]; + } + return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.basicInformation!.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: Column( - children: [ - Expanded( - child: ListView( - children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.lockNumber!.tr, - rightTitle: "MCBN0c_8f3106", - allHeight: 70.h, - isHaveLine: true), - CommonItem( - leftTitel: "MAC/ID", - rightTitle: "53:66:9F:06:31:8F/9418481", - allHeight: 70.h, - isHaveLine: false), - SizedBox( - height: 10.h, - ), - CommonItem( - leftTitel: - TranslationLoader.lanKeys!.electricQuantity!.tr, - rightTitle: "100%", - isHaveLine: true, - isHaveDirection: true, - action: () { - Navigator.pushNamed( - context, Routers.uploadElectricQuantityPage); - }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "永久", - allHeight: 70.h, - isHaveLine: false), - SizedBox( - height: 10.h, - ), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.lockName!.tr, - rightTitle: "MCBN0c_8f3106", - isHaveLine: true, - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.editLockNamePage); - }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.lockGrouping!.tr, - rightTitle: _groupName, - isHaveLine: true, - isHaveDirection: true, - action: () async { - var result = await Navigator.pushNamed( - context, Routers.lockSeletGroupingPage); - result as Map; - _groupName = result['groupName']; - setState(() {}); - }), - CommonItem( - leftTitel: - TranslationLoader.lanKeys!.adminOpenLockPassword!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Navigator.pushNamed( - context, Routers.adminOpenLockPasswordPage); - }), - ], - ), - ), - ], - )); + body: FutureBuilder( + future: mockNetworkDataRequest(), + builder: (BuildContext context, AsyncSnapshot snapshot) { + //请求结束 + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + //请求失败 + return const Text('请求失败'); + } else { + //请求成功 + final LockData itemData = snapshot.data!; + + return Column( + children: [ + Expanded( + child: ListView( + children: [ + CommonItem( + leftTitel: + TranslationLoader.lanKeys!.lockNumber!.tr, + rightTitle: itemData.lockAlias, + allHeight: 70.h, + isHaveLine: true), + CommonItem( + leftTitel: "MAC/ID", + rightTitle: itemData.lockMac, + allHeight: 70.h, + isHaveLine: false), + SizedBox( + height: 10.h, + ), + CommonItem( + leftTitel: TranslationLoader + .lanKeys!.electricQuantity!.tr, + rightTitle: "${itemData.electricQuantity}%", + isHaveLine: true, + isHaveDirection: true, + action: () { + Navigator.pushNamed(context, + Routers.uploadElectricQuantityPage); + }), + CommonItem( + leftTitel: TranslationLoader + .lanKeys!.periodValidity!.tr, + rightTitle: getUseDateStr(itemData), + allHeight: 70.h, + isHaveLine: false), + SizedBox( + height: 10.h, + ), + CommonItem( + leftTitel: + TranslationLoader.lanKeys!.lockName!.tr, + rightTitle: itemData.lockName, + isHaveLine: true, + isHaveDirection: true, + action: () { + Navigator.pushNamed( + context, Routers.editLockNamePage); + }), + CommonItem( + leftTitel: + TranslationLoader.lanKeys!.lockGrouping!.tr, + rightTitle: itemData.groupName == "" + ? _groupName + : itemData.groupName, + isHaveLine: true, + isHaveDirection: true, + action: () async { + var result = await Navigator.pushNamed( + context, Routers.lockSeletGroupingPage); + result as Map; + _groupName = result['groupName']; + setState(() {}); + }), + CommonItem( + leftTitel: TranslationLoader + .lanKeys!.adminOpenLockPassword!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Navigator.pushNamed(context, + Routers.adminOpenLockPasswordPage); + }), + ], + ), + ), + ], + ); + } + } else { + //请求未结束 显示loading + return Container(); + } + })); } -/* - void getLockInfo() async { - var entity = await ApiRepository.to.getLockInfo( - lastUpdateDate: DateTime.now().millisecondsSinceEpoch.toString(), - pageNo: '1', - ); - if (entity.errorCode!.codeIsSuccessful) { - // if (page == 0) { - // refreshController.refreshCompleted(); - // } else { - // if (entity.data!.keyInfos!.isEmpty) { - // refreshController.loadNoData(); - // } else { - // refreshController.loadComplete(); - // } - // } - // page++; - - if (entity.data!.keyInfos!.isEmpty) { - state.dataLength.value = 0; - } else if (entity.data!.keyInfos!.length == 1) { - state.dataLength.value = 1; + //使用期限 + String getUseDateStr(LockData indexEntity) { + String useDateStr = ''; + if (indexEntity.keyType == 1) { + //限期 + if (indexEntity.startDate != null && indexEntity.endDate != null) { + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; } else { - state.dataLength.value = 2; + useDateStr = '限期'; } - state.lockMainEntity.value = entity; - } else { - // refreshController.loadFailed(); + } else if (indexEntity.keyType == 2) { + //永久 + useDateStr = '永久'; + } else if (indexEntity.keyType == 3) { + //单次 + useDateStr = '单次'; + } else if (indexEntity.keyType == 4) { + //循环 + useDateStr = '循环'; } - // refreshController.refreshCompleted(); + + return useDateStr; + } + + //1:限期 2:永久 3:单次 4:循环 + String getKeyTypeStr(int keyType) { + String keyTypeStr = ""; + if (keyType == 1) { + keyTypeStr = "限期"; + } else if (keyType == 2) { + keyTypeStr = '永久'; + } else if (keyType == 3) { + keyTypeStr = '单次'; + } else if (keyType == 4) { + keyTypeStr = '循环'; + } + return keyTypeStr; + } + + //请求电子钥匙列表 + Future mockNetworkDataRequest() async { + KeyDetailEntity entity = + await ApiRepository.to.getKeyDetail(keyInfo.lockId.toString()); + if (entity.errorCode!.codeIsSuccessful) { + // print("电子钥匙列表成功:${entity.data?.itemList}"); + return entity.data!; + } + LockData data = LockData(); + return data; } - */ } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index ad898cbf..8281a610 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -43,7 +43,9 @@ class _LockSetPageState extends State { isHaveDirection: true, action: () { Navigator.pushNamed( - context, Routers.basicInformationPage); + context, Routers.basicInformationPage, arguments: { + 'keyInfo': state.getKeyInfosData.value + }); }), SizedBox( height: 10.h, diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 450deeec..861599b2 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -38,4 +38,5 @@ abstract class Api { final String updateSettingURL = '/room/updateSetting'; //标记房态 final String keyGroupListURL = '/keyGroup/list'; //分组列表 final String lockListByGroupURL = '/room/listByGroup'; //分组下的锁 + final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 4af64b07..4a6ffd18 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -373,6 +373,9 @@ class ApiProvider extends BaseProvider { Future lockListByGroup(String type, String keyGroupId) => post( lockListByGroupURL.toUrl, jsonEncode({'type': type, 'keyGroupId': keyGroupId})); + + Future getKeyDetail(String lockId) => + post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId})); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index b90d03c7..4df631d2 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -2,6 +2,7 @@ import 'package:get/get.dart'; import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.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/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/LockGroupListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; @@ -362,4 +363,10 @@ class ApiRepository { final res = await apiProvider.lockListByGroup(type, keyGroupId); return PasswordKeyEntity.fromJson(res.body); } + + //获取单把钥匙详情信息 + Future getKeyDetail(String lockId) async { + final res = await apiProvider.getKeyDetail(lockId); + return KeyDetailEntity.fromJson(res.body); + } } diff --git a/star_lock/lib/tools/commonItem.dart b/star_lock/lib/tools/commonItem.dart index f99e5928..0c5b8d68 100644 --- a/star_lock/lib/tools/commonItem.dart +++ b/star_lock/lib/tools/commonItem.dart @@ -61,6 +61,8 @@ class CommonItem extends StatelessWidget { : Text( rightTitle!, textAlign: TextAlign.end, + overflow: TextOverflow.ellipsis, + maxLines: 1, style: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor), From c888f27142da9f260c2f0de45e6a0afb9fa1f70b Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Thu, 7 Sep 2023 18:32:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=AF=86=E7=A0=81=E6=8E=A5=E5=8F=A3=202?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=90=84=E9=A1=B9=E4=BF=A1=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=203=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=94=81=E5=88=86=E7=BB=84=E6=8E=A5=E5=8F=A3=204=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E9=94=81=E5=88=86=E7=BB=84?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E9=94=81=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=205=EF=BC=8C=E6=96=B0=E5=A2=9E=E9=94=81=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95=206?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=BE=A4=E5=8F=91=E9=94=81=E5=88=86?= =?UTF-8?q?=E7=BB=84=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=207=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BE=A4=E5=8F=91=E6=8E=A5=E6=94=B6=E4=BA=BA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=208=EF=BC=8C=E6=96=B0=E5=A2=9E=E9=94=81?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/icon_massSend_delete.png | Bin 0 -> 1964 bytes star_lock/lib/appRouters.dart | 25 +- .../electronicKeyDetail_page.dart | 4 +- .../electronicKeyDetailChangeDate_page.dart | 33 ++- .../massSendElectronicKey_page.dart | 10 +- .../massSendLockGroupListEntity.dart | 70 +++++ .../massSendLockGroupList_page.dart | 143 ++++++---- .../massSendReceiver/lockUserListEntity.dart | 59 ++++ .../massSendReceiver/lockUserList_page.dart | 224 +++++++++++++++ .../massSendReceiver_page.dart | 258 ++++++++++++++++++ .../basicInformation/KeyDetailEntity.dart | 4 +- .../basicInformation_page.dart | 19 +- .../lockSeletGrouping_page.dart | 38 ++- .../passwordKeyDetail_page.dart | 81 +++++- .../passwordKey_perpetual_page.dart | 67 ++++- star_lock/lib/network/api.dart | 8 + star_lock/lib/network/api_provider.dart | 70 +++++ star_lock/lib/network/api_repository.dart | 61 +++++ .../lib/network/request_interceptor.dart | 5 +- star_lock/lib/tools/ExpandedListView.dart | 10 +- 20 files changed, 1081 insertions(+), 108 deletions(-) create mode 100644 star_lock/images/icon_massSend_delete.png create mode 100644 star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart create mode 100644 star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart create mode 100644 star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserList_page.dart create mode 100644 star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart diff --git a/star_lock/images/icon_massSend_delete.png b/star_lock/images/icon_massSend_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..55e087f9de9ac8d179afea95838a3483da3eaa64 GIT binary patch literal 1964 zcmV;d2UGZoP)&IK$M+mUDTS7zl=1*NQ>j#i zBuVv>B$*{iGOw(xd_||zJ?A(s!f{+wuh&OemW=}#C4>aE^iWZ1fHVYBsT8}gu+S|C z!cXSs=U9vnN)Cr3e*F0HHkM@*h2Zi+QA+u> zwYAEtSFcVBf}pj}qGdE1(c9bmre3d)<^yB$1)-F(mo8m;C4c}x6h&OPaN%ExM50Ds zLD`fOic-qox^?U02M->U$Dv9+fBqboFJGRZl(M<$a(sMT(X!)tezm*1`+EQ&iel^V@bCvKD=P}EZx_q5@Or%ijg5_$0bp!w>}L}b z6D@`A3j_lDTU%Q#27_T^i{Ho;rIeqXocy_x>KXu?PUj~81^^5gjmCeUJbChLRaI5d zFu*!cZ*T9pG|&Km0hi15iIRIMrMP|j_CGVTl?la8PEMXyYGi(Xz6U^m`f{MQw)U=r8LIe++6kY^0HaJ-hhfmqlb!FK7l~M914ZLh7!PJ zAgk572`Cnez3%t>dlZ`iAPB;@2q+$m zVHouE^bBNd3MB&p>l;Qm9R3E7h7v`wO;x0{l!D0_+6p9!V(ZY*(3wOcQHl+SqSy_j zp(IIiloSnx!Ss4Pyk74>Q&ZD6po$LW5ki6t0GLcBUn#+I0c|aPN-cs5$z(Ep2BeqY?%liR3hsj`+@7$fZ0O*fKqwT}P!>VgJ z87vqKzJqnJ{=0YY_7}P@?HeACr#G_;vZ<9rDdlHpXTN>@`t@HZ3CM9AcJ11QXf#^* z%?edpTMJ4llpd(Iw6sihc6Of12?eZ!oj-s6Ke3pmZXl`!)kmq?-(_^w!LuHCm%2P_&NF>r8 z3WeSehr@3zFE1nCU=|?+dc7VNi{-xEZvVZ-V!6(;Y$E;I|7VCXm*jC%0C@TGWsN*; y8jr`#m6erC)z#IaUaw!Ms;XK_-=g`r>3;z;dpgj0000 const AuthorityManagementPage()), - GetPage(name: Routers.addFingerprintTipPage, page: () => const AddFingerprintTipPage()), + GetPage( + name: Routers.addFingerprintTipPage, + page: () => const AddFingerprintTipPage()), GetPage( name: Routers.addFingerprintPage, page: () => const AddFingerprintPage()), + GetPage( + name: Routers.massSendLockGroupPage, + page: () => const MassSendLockGroupListPage()), + GetPage( + name: Routers.massSendReceiverPage, + page: () => const MassSendReceiverPage()), + GetPage( + name: Routers.lockUserListPage, page: () => const LockUserListPage()) ]; } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index e361ca3a..23b7357d 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -276,9 +276,7 @@ class _ElectronicKeyDetailPageState extends State { } } - void showCupertinoAlertDialog( - BuildContext context, - ) { + void showCupertinoAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { 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 b29d7afa..4f30b9e2 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 @@ -5,6 +5,7 @@ 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/tools/toast.dart'; @@ -33,6 +34,8 @@ class _ElectronicKeyDetailChangeDateState late String endDay = ''; late String startDay = ''; late List weekDays = []; + late String pwdId = ''; + late String lockId = ''; @override Widget build(BuildContext context) { @@ -40,6 +43,12 @@ class _ElectronicKeyDetailChangeDateState 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"]; + } return Scaffold( backgroundColor: AppColors.mainBackgroundColor, @@ -55,7 +64,11 @@ class _ElectronicKeyDetailChangeDateState style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - updateKeyDateRequest(); + if (lockId.isNotEmpty && pwdId.isNotEmpty) { + updatePwdRequest(); + } else { + updateKeyDateRequest(); + } }, ), ], @@ -120,6 +133,24 @@ class _ElectronicKeyDetailChangeDateState } } + //更新密码请求 + Future 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"; } diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart index 61cd1fdc..3f88d9e5 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -1,8 +1,6 @@ import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/app_settings/app_colors.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import '../../../../../tools/commonItem.dart'; @@ -87,12 +85,16 @@ class _MassSendElectronicKeyPageState extends State { rightTitle: TranslationLoader.lanKeys!.pleaseAdd!.tr, isHaveLine: true, isHaveDirection: true, - action: () {}), + action: () { + Navigator.pushNamed(context, Routers.massSendReceiverPage); + }), CommonItem( leftTitel: TranslationLoader.lanKeys!.lock!.tr, rightTitle: TranslationLoader.lanKeys!.pleaseSelet!.tr, isHaveDirection: true, - action: () {}), + action: () { + Navigator.pushNamed(context, Routers.massSendLockGroupPage); + }), Container(height: 10.h), ], ); diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart new file mode 100644 index 00000000..0e94a4c2 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart @@ -0,0 +1,70 @@ +class MassSendLockGroupListEntity { + int? errorCode; + String? description; + String? errorMsg; + LockListData? data; + + MassSendLockGroupListEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + MassSendLockGroupListEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? LockListData.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class LockListData { + List? lockList; + + LockListData({this.lockList}); + + LockListData.fromJson(Map json) { + if (json['list'] != null) { + lockList = []; + json['list'].forEach((v) { + lockList!.add(LockListItem.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + if (lockList != null) { + data['list'] = lockList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class LockListItem { + int? lockId; + String? lockAlias; + bool? isRefresh = false; + + LockListItem({this.lockId, this.lockAlias, this.isRefresh}); + + LockListItem.fromJson(Map json) { + lockId = json['lockId']; + lockAlias = json['lockAlias']; + } + + Map toJson() { + final Map data = {}; + data['lockId'] = lockId; + data['lockAlias'] = lockAlias; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart index ff690b08..e1a8d322 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart @@ -2,7 +2,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/utils.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/LockGroupListEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/ExpandedListView.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/translations/trans_lib.dart'; class MassSendLockGroupListPage extends StatefulWidget { @@ -15,9 +19,15 @@ class MassSendLockGroupListPage extends StatefulWidget { } class _MassSendLockGroupListPageState extends State { + List lockListByGroup = []; + List lockGroupList = []; + List clickIndexList = []; + @override void initState() { super.initState(); + + mockNetworkDataRequest(); } @override @@ -26,7 +36,7 @@ class _MassSendLockGroupListPageState extends State { appBar: AppBar( backgroundColor: AppColors.mainColor, title: Text( - TranslationLoader.lanKeys!.authorityManagement!.tr, + TranslationLoader.lanKeys!.lock!.tr, style: TextStyle( color: Colors.white, fontSize: 28.sp, @@ -39,75 +49,94 @@ class _MassSendLockGroupListPageState extends State { ), ), body: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text( - '请选择要发送的锁', - style: TextStyle( - color: AppColors.darkGrayTextColor, fontSize: 22.sp), + SizedBox( + height: 10.h, ), - _keyGroupList() + Container( + width: ScreenUtil().screenWidth, + margin: EdgeInsets.only(left: 20.w), + child: Text('请选择要发送的锁', + style: TextStyle( + color: AppColors.darkGrayTextColor, fontSize: 22.sp)), + ), + SizedBox( + height: 10.h, + ), + Expanded(child: _buildListView(context, lockGroupList)), + SizedBox( + height: 40.h, + ) ], )); } -//设备列表 - Widget _keyGroupList() { - return Column( - children: [ - SizedBox( - height: 10.h, - ), - Expanded( - child: ListView.separated( - itemBuilder: (context, index) { - if (index == 0) { - return _buildLockExpandedList(context, index, "大门锁"); - } else if (index == 1) { - return _buildLockExpandedList(context, index, "办公室锁"); - } else if (index == 2) { - return _buildLockExpandedList(context, index, "会议室锁"); - } else { - return _buildLockExpandedList(context, index, "宴会厅锁"); - } - }, - separatorBuilder: (context, index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - itemCount: 5)), - ], - ); + //分组列表请求 + Future> mockNetworkDataRequest() async { + LockGroupListEntity entity = await ApiRepository.to.lockGroupList('1'); + List dataList = []; + if (entity.errorCode!.codeIsSuccessful) { + if (entity.data != null) { + dataList = entity.data!.itemList!; + } + } + lockGroupList = dataList; + setState(() {}); + return dataList; + } + + //分组列表请求 + Future> listLockByGroup(String groupId) async { + MassSendLockGroupListEntity entity = + await ApiRepository.to.listLockByGroup('3', groupId); + List dataList = []; + if (entity.errorCode!.codeIsSuccessful) { + if (entity.data != null) { + dataList = entity.data!.lockList!; + } + } + lockListByGroup = dataList; + + setState(() {}); + return dataList; + } + + Widget _buildListView(BuildContext context, List itemList) { + return ListView.separated( + itemCount: itemList.length, + itemBuilder: (context, index) { + LockGroupItem itemData = itemList[index]; + return _buildLockExpandedList(context, index, itemData); + }, + shrinkWrap: true, + separatorBuilder: (context, index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }); } //设备多层级列表 - Widget _buildLockExpandedList(context, index, deviceName) { + Widget _buildLockExpandedList(context, index, LockGroupItem itemData) { return ExpandedListTile( - onTap: () => print("onTap."), - title: deviceName, - imgName: 'images/icon_lock.png', + onTap: () { + listLockByGroup(itemData.keyGroupId.toString()); + clickIndexList.add(index); + }, + title: itemData.keyGroupName!, + imgName: '', typeImgList: const [], child: ListView.separated( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, - itemCount: 10, - itemBuilder: (_, index) { - if (index == 0) { - return _buildNameWidget( - context, index, 'images/icon_password.png', '张三'); - } else if (index == 1) { - return _buildNameWidget( - context, index, 'images/icon_card.png', '李四'); - } else if (index == 2) { - return _buildNameWidget( - context, index, 'images/icon_fingerprint.png', '王二'); - } else if (index == 3) { - return _buildNameWidget( - context, index, 'images/icon_card.png', '麻子'); - } else { - return null; - } + itemCount: lockListByGroup.length, + itemBuilder: (_, itemIndex) { + LockListItem itemData = lockListByGroup[itemIndex]; + return _buildNameWidget(context, itemIndex, + 'images/icon_password.png', itemData.lockAlias); }, separatorBuilder: (BuildContext context, int index) { return const Divider( @@ -132,7 +161,7 @@ class _MassSendLockGroupListPageState extends State { width: 30.w, ), Image.asset( - 'images/controls_user.png', + 'images/mine/icon_mine_gatewaySignal_prompt.png', width: 36.w, height: 36.w, ), diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart new file mode 100644 index 00000000..fa7e6959 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart @@ -0,0 +1,59 @@ +class LockUserListEntity { + int? errorCode; + String? description; + String? errorMsg; + List? data; + + LockUserListEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + LockUserListEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] != null) { + data = []; + json['data'].forEach((v) { + data!.add(LockUserData.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class LockUserData { + int? uid; + String? nickname; + String? headUrl; + String? userid; + bool? isCheck = false; + + LockUserData( + {this.uid, this.nickname, this.headUrl, this.userid, this.isCheck}); + + LockUserData.fromJson(Map json) { + uid = json['uid']; + nickname = json['nickname']; + headUrl = json['headUrl']; + userid = json['userid']; + } + + Map toJson() { + final Map data = {}; + data['uid'] = uid; + data['nickname'] = nickname; + data['headUrl'] = headUrl; + data['userid'] = userid; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserList_page.dart new file mode 100644 index 00000000..7faa87ac --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserList_page.dart @@ -0,0 +1,224 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/utils.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/submitBtn.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +class LockUserListPage extends StatefulWidget { + const LockUserListPage({Key? key}) : super(key: key); + + @override + State createState() { + return _LockUserListPageState(); + } +} + +class _LockUserListPageState extends State { + List dataList = []; + List selectUserIdList = []; + List selectDataList = []; + @override + void initState() { + super.initState(); + + lockUserListRequest(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: AppColors.mainColor, + title: Text( + '选择用户', + style: TextStyle( + color: Colors.white, + fontSize: 28.sp, + fontWeight: FontWeight.w600), + ), + elevation: 0, + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios, color: Colors.white), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Column( + children: [ + SizedBox( + height: 20.h, + ), + _searchWidget(), + SizedBox( + height: 20.h, + ), + Expanded( + child: ListView.separated( + itemBuilder: (context, index) { + LockUserData indexEntity = dataList[index]; + return _electronicKeyItem(indexEntity); + }, + itemCount: dataList.length, + separatorBuilder: (context, index) { + return const Divider(height: 1, color: AppColors.greyLineColor); + }, + )), + Container( + height: 120.h, + padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 0.h), + margin: const EdgeInsets.only(left: 0, right: 0, bottom: 0), + color: Colors.white, + child: Row( + children: [ + Text( + '已选中:${selectUserIdList.length}', + style: TextStyle(color: Colors.black, fontSize: 24.sp), + ), + Expanded( + child: SizedBox( + width: 20.w, + )), + SizedBox( + width: 120.w, + height: 60.h, + child: SubmitBtn( + btnName: '确定', + onClick: () { + Map resultMap = {}; + resultMap['lockUserList'] = selectDataList; + Navigator.pop(context, resultMap); + }, + ), + ) + ], + ), + ) + ], + )); + } + + Widget _searchWidget() { + return Container( + height: 60.h, + margin: EdgeInsets.only(left: 20.w, right: 10.w), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(5)), + child: 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: TranslationLoader.lanKeys!.pleaseEnter!.tr, + hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), + //不需要输入框下划线 + border: InputBorder.none, + //左边图标设置 + icon: Padding( + padding: EdgeInsets.only( + top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), + child: Image.asset( + 'images/main/icon_main_search.png', + width: 40.w, + height: 40.w, + ), + ), + ), + ), + ); + } + + Widget _electronicKeyItem(LockUserData itemData) { + return Container( + color: Colors.white, + height: 90.h, + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/controls_user.png', + width: 60.w, + height: 60.w, + ), + SizedBox( + width: 20.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + children: [ + Text( + itemData.nickname!, + style: TextStyle( + fontSize: 24.sp, color: AppColors.blackColor), + ) + ], + ), + SizedBox(height: 10.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + itemData.userid!, + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor), + ), + ], + ), + SizedBox(width: 20.h), + ], + ), + ), + GestureDetector( + onTap: () { + setState(() { + itemData.isCheck = !itemData.isCheck!; + if (itemData.isCheck == true) { + selectUserIdList.add(itemData.userid); + selectDataList.add(itemData); + } else { + selectUserIdList.remove(itemData.userid); + selectDataList.remove(itemData); + } + }); + }, + child: Image.asset( + itemData.isCheck! + ? 'images/icon_round_selet.png' + : 'images/icon_round_unSelet.png', + width: 30.w, + height: 30.w, + )), + SizedBox(width: 20.h), + ], + ), + ); + } + + //请求锁用户列表 + Future> lockUserListRequest() async { + LockUserListEntity entity = + await ApiRepository.to.lockUserList('1', '20', ''); + if (entity.errorCode!.codeIsSuccessful) { + setState(() { + dataList = entity.data!; + }); + } + return dataList; + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart new file mode 100644 index 00000000..d13115a5 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart @@ -0,0 +1,258 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/utils.dart'; +import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart'; +import 'package:star_lock/tools/commonItem.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +class MassSendReceiverPage extends StatefulWidget { + const MassSendReceiverPage({Key? key}) : super(key: key); + + @override + State createState() { + return _MassSendReceiverPageState(); + } +} + +class _MassSendReceiverPageState extends State { + late List _lockUserList = []; + TextEditingController emailOrPhoneController = TextEditingController(); + TextEditingController keyNameController = TextEditingController(); + + String countryCode = '86'; + String countryName = '中国'; + + @override + void initState() { + super.initState(); + + LockUserData data = LockUserData(); + _lockUserList.add(data); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: AppColors.mainColor, + title: Text( + '接收者', + style: TextStyle( + color: Colors.white, + fontSize: 28.sp, + fontWeight: FontWeight.w600), + ), + elevation: 0, + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios, color: Colors.white), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Column( + children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + isHaveDirection: true, + rightWidget: Text( + '$countryName +$countryCode', + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), + ), + action: () async { + var result = await Navigator.pushNamed( + context, Routers.seletCountryRegionPage); + result as Map; + countryCode = result['code']; + countryName = result['countryName']; + setState(() {}); + }, + ), + Row( + children: [controlViewTitle(0), controlViewTitle(1)], + ), + SizedBox( + height: 2.h, + ), + Expanded( + child: ListView.separated( + itemBuilder: (BuildContext context, int index) { + LockUserData data = _lockUserList[index]; + return _itemBuilder(index, data); + }, + itemCount: _lockUserList.length, + separatorBuilder: (BuildContext context, int index) { + return Divider( + height: 20.h, + color: AppColors.greyBackgroundColor, + ); + }, + )), + ], + ), + ); + } + + Widget controlViewTitle(int btnIndex) { + return GestureDetector( + child: Container( + width: (ScreenUtil().screenWidth - 60.w) / 2, + height: 90.h, + margin: EdgeInsets.only(left: 20.w), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(8.w)), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'images/icon_btn_add.png', + width: 28.w, + height: 28.w, + ), + SizedBox( + width: 6.w, + ), + Text( + btnIndex == 0 ? '已有' : '新增', + style: TextStyle( + color: AppColors.mainColor, + fontSize: 24.sp, + fontWeight: FontWeight.bold), + ) + ], + ), + ), + onTap: () async { + if (btnIndex == 0) { + //已有 + Navigator.pushNamed(context, Routers.lockUserListPage).then((val) { + if (val != null) { + val as Map; + _lockUserList = val['lockUserList']; + + setState(() {}); + } + }); + } else if (btnIndex == 1) { + //新增 + _lockUserList.add(LockUserData()); + setState(() {}); + } + }, + ); + } + + Widget _itemBuilder(int index, LockUserData userData) { + return Container( + color: Colors.white, + child: Row( + children: [ + GestureDetector( + child: SizedBox( + width: 40.w, + child: Row( + children: [ + SizedBox( + width: 10.w, + ), + Image.asset( + 'images/icon_massSend_delete.png', + width: 26.w, + height: 26.w, + ) + ], + ), + ), + onTap: () { + _lockUserList.removeAt(index - 1); + setState(() {}); + }, + ), + Expanded( + child: Column( + children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.receiver!.tr, + rightTitle: userData.userid ?? ' ', + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: getTFWidget( + true, + TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, + 1)), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.name!.tr, + rightTitle: userData.nickname ?? ' ', + isHaveRightWidget: true, + rightWidget: getTFWidget( + false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)), + ], + )) + ], + ), + ); + } + + // 接受者信息输入框 + Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) { + return SizedBox( + height: 50.h, + width: 320.w, + child: Row( + children: [ + Expanded( + child: TextField( + controller: + lineIndex == 1 ? emailOrPhoneController : keyNameController, + //输入框一行 + maxLines: 1, + // controller: _controller, + autofocus: false, + textAlign: TextAlign.end, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + hintText: tfStr, + hintStyle: TextStyle(fontSize: 22.sp), + //不需要输入框下划线 + border: InputBorder.none, + ), + ), + ), + SizedBox( + width: 10.w, + ), + isHaveBtn + ? Container( + width: 32.w, + height: 32.w, + decoration: const BoxDecoration( + color: Colors.white, + image: DecorationImage( + image: AssetImage('images/icon_addressBook.png'), + fit: BoxFit.fill), + ), + alignment: Alignment.center, + child: InkWell( + onTap: () async { + // Contact? currentContact = + // await _contactPicker.selectContact(); + // setState(() { + // _contact = currentContact!; + // // print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}"); + // }); + }, + ), + ) + : Container() + ], + ), + ); + } +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart index 01064de4..91d2aba3 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart @@ -45,7 +45,7 @@ class LockData { int? noKeyPwd; int? electricQuantity; String? featureValue; - String? groupId; + int? groupId; String? groupName; LockData( @@ -96,7 +96,7 @@ class LockData { ? electricQuantity = json['electricQuantity'] : 0; json['featureValue'] != null ? featureValue = json['featureValue'] : ""; - json['groupId'] != null ? groupId = json['groupId'] : ""; + json['groupId'] != null ? groupId = json['groupId'] : 0; groupName = json['groupName']; } diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart index b1958f98..12914a66 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart'; -import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; -import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -25,6 +23,7 @@ class _BasicInformationPageState extends State { late String _groupName = ""; late KeyInfos keyInfo; late LockMainEntity lockMainEntity; + late LockData _lockData; @override void initState() { @@ -114,11 +113,16 @@ class _BasicInformationPageState extends State { isHaveLine: true, isHaveDirection: true, action: () async { - var result = await Navigator.pushNamed( - context, Routers.lockSeletGroupingPage); - result as Map; - _groupName = result['groupName']; - setState(() {}); + Navigator.pushNamed( + context, Routers.lockSeletGroupingPage, + arguments: { + 'LockData': _lockData + }).then((val) { + if (val != null) { + mockNetworkDataRequest(); + setState(() {}); + } + }); }), CommonItem( leftTitel: TranslationLoader @@ -193,6 +197,7 @@ class _BasicInformationPageState extends State { await ApiRepository.to.getKeyDetail(keyInfo.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { // print("电子钥匙列表成功:${entity.data?.itemList}"); + _lockData = entity.data!; return entity.data!; } LockData data = LockData(); diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart index d78bf873..8221a481 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/LockGroupListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -22,10 +23,15 @@ class LockSeletGroupingPage extends StatefulWidget { class _LockSeletGroupingPageState extends State { final TextEditingController _changeNameController = TextEditingController(); - final int _selectGroupIndex = -1; + late LockData _lockData; @override Widget build(BuildContext context) { + dynamic obj = ModalRoute.of(context)?.settings.arguments; + if (obj != null && (obj["LockData"] != null)) { + _lockData = obj["LockData"]; + } + return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -56,7 +62,7 @@ class _LockSeletGroupingPageState extends State { padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { showCupertinoAlertDialog(context); - Navigator.pop(context); + // Navigator.pop(context); }), SizedBox( height: 40.h, @@ -84,7 +90,7 @@ class _LockSeletGroupingPageState extends State { isHaveLine: true, isHaveDirection: false, isHaveRightWidget: true, - rightWidget: _selectGroupIndex == index + rightWidget: _lockData.groupId == itemData.keyGroupId ? Image( image: const AssetImage("images/icon_item_checked.png"), width: 30.w, @@ -93,11 +99,8 @@ class _LockSeletGroupingPageState extends State { ) : Container(), action: () { - Map resultMap = {}; - resultMap['groupName'] = itemData.keyGroupName; - Navigator.pop(context, resultMap); - - setState(() {}); + Navigator.pop(context, true); + setLockGroupRequest(itemData); }); }); } @@ -113,6 +116,16 @@ class _LockSeletGroupingPageState extends State { } } + //设置锁分组请求 + Future setLockGroupRequest(LockGroupItem itemData) async { + LockGroupListEntity entity = await ApiRepository.to.setLockGroup( + _lockData.lockId.toString(), itemData.keyGroupId.toString()); + if (entity.errorCode!.codeIsSuccessful) { + Toast.show(msg: "设置锁分组成功"); + mockNetworkDataRequest(); + } + } + //分组列表请求 Future> mockNetworkDataRequest() async { LockGroupListEntity entity = await ApiRepository.to.lockGroupList('1'); @@ -128,21 +141,22 @@ class _LockSeletGroupingPageState extends State { } } - void showCupertinoAlertDialog( - BuildContext context, - ) { + void showCupertinoAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return ShowTFView( title: - "${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}", + "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.lockGroup!.tr}", tipTitle: "请输入", controller: _changeNameController, sureClick: () { //发送编辑钥匙名称请求 if (_changeNameController.text.isNotEmpty) { addLockGroupRequest(); + Navigator.pop(context); + } else { + Toast.show(msg: '请输入分组名称'); } }, cancelClick: () { diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index 4c8effca..0886b8c9 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -2,11 +2,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.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/showTFView.dart'; import 'package:star_lock/tools/toast.dart'; import '../../../../appRouters.dart'; @@ -25,6 +25,16 @@ class PasswordKeyDetailPage extends StatefulWidget { class _PasswordKeyDetailPageState extends State { PasswordKeyListItem itemData = PasswordKeyListItem(); + late TextEditingController _inputPwdController; + late TextEditingController _inputNameController; + + @override + void initState() { + super.initState(); + + _inputPwdController = TextEditingController(); + _inputNameController = TextEditingController(); + } @override Widget build(BuildContext context) { @@ -64,19 +74,23 @@ class _PasswordKeyDetailPageState extends State { children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.password!.tr, - rightTitle: itemData.keyboardPwd, + rightTitle: _inputPwdController.text.isNotEmpty + ? _inputPwdController.text + : itemData.keyboardPwd, isHaveDirection: true, isHaveLine: true, action: () { - showCupertinoAlertDialog(context); + showCupertinoAlertDialog(context, _inputPwdController); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: itemData.keyboardPwdName, + rightTitle: _inputNameController.text.isNotEmpty + ? _inputNameController.text + : itemData.keyboardPwdName, isHaveDirection: true, isHaveLine: true, action: () { - showCupertinoAlertDialog(context); + showCupertinoAlertDialog(context, _inputNameController); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, @@ -84,7 +98,11 @@ class _PasswordKeyDetailPageState extends State { isHaveDirection: true, action: () { Navigator.pushNamed( - context, Routers.electronicKeyDetailChangeDate); + context, Routers.electronicKeyDetailChangeDate, + arguments: { + 'lockId': itemData.lockId.toString(), + 'pwdId': itemData.keyboardPwdId.toString() + }); }), Container(height: 10.h), CommonItem( @@ -272,7 +290,51 @@ class _PasswordKeyDetailPageState extends State { } } - void showCupertinoAlertDialog(BuildContext context) { + //更新密码请求 + Future updatePwdRequest() async { + PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey( + itemData.lockId.toString(), + itemData.keyboardPwdId.toString(), + _inputNameController.text, + _inputPwdController.text, + '', + '', + ''); + if (entity.errorCode!.codeIsSuccessful) { + Toast.show(msg: "修改成功"); + setState(() { + Navigator.pop(context); + }); + } + } + + void showCupertinoAlertDialog( + BuildContext context, TextEditingController inputController) { + showDialog( + context: context, + builder: (BuildContext context) { + return ShowTFView( + title: + "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", + tipTitle: "请输入", + controller: inputController, + sureClick: () { + //发送编辑钥匙名称请求 + if (inputController.text.isNotEmpty) { + updatePwdRequest(); + } + }, + cancelClick: () { + Navigator.pop(context); + }, + ); + }, + ); + } + +/* + void showCupertinoAlertDialog( + BuildContext context, TextEditingController inputController) { showDialog( context: context, builder: (BuildContext context) { @@ -291,6 +353,7 @@ class _PasswordKeyDetailPageState extends State { // color: Colors.white, margin: EdgeInsets.all(10.w), child: TextField( + controller: inputController, //输入框一行 maxLines: 1, // controller: _controller, @@ -330,14 +393,13 @@ class _PasswordKeyDetailPageState extends State { child: Text(TranslationLoader.lanKeys!.cancel!.tr), onPressed: () { Navigator.pop(context); - // print("取消"); }, ), CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.sure!.tr), onPressed: () { + updatePwdRequest(); Navigator.pop(context); - // print("确定"); }, ), ], @@ -345,4 +407,5 @@ class _PasswordKeyDetailPageState extends State { ); }); } + */ } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index cb51559b..19dcf3f2 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -352,8 +352,34 @@ class _PasswordKeyPerpetualPageState extends State { SubmitBtn( btnName: TranslationLoader.lanKeys!.getPassword!.tr, onClick: () { + /* + int getWidgetNumber = int.parse(widget.type); + + if (_nameController.text.isEmpty) { + Toast.show(msg: '请输入密码姓名'); + return; + } + if (getWidgetNumber != 0 || + getWidgetNumber != 2 || + getWidgetNumber != 5) { + if (getWidgetNumber == 3 && _pwdController.text.isEmpty) { + Toast.show(msg: '请输入密码'); + return; + } + if (_failureDateTime.compareTo(_effectiveDateTime) != 1) { + Toast.show(msg: '失效时间需大于生效时间'); + return; + } + } + */ logic.getStartDate(_effectiveDateTime); - getKeyboardPwdRequest(); + int passwordType = int.parse(widget.type); + if (passwordType == 3) { + //自定义密码 + addKeyboardPwdRequest(); + } else { + getKeyboardPwdRequest(); + } }), ], ); @@ -400,7 +426,7 @@ class _PasswordKeyPerpetualPageState extends State { //清空码 getKeyType = '4'; } - if (widget.type != '0' || widget.type != '2' || widget.type == '5') { + if (widget.type != '0' || widget.type != '2' || widget.type != '5') { getFailureDateTime = DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString(); getEffectiveDateTime = DateTime.parse(_selectEffectiveDate) @@ -429,6 +455,43 @@ class _PasswordKeyPerpetualPageState extends State { } } + //自定义密码请求 + Future addKeyboardPwdRequest() async { + String getFailureDateTime = '0'; + String getEffectiveDateTime = '0'; + String lockId = widget.getKeyInfo.lockId.toString(); + String getKeyType = '3'; + //是否为永久 + if (_isPermanent == false) { + getKeyType = '3'; + getFailureDateTime = + DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString(); + getEffectiveDateTime = DateTime.parse(_selectEffectiveDate) + .millisecondsSinceEpoch + .toString(); + } else { + getKeyType = '2'; + } + var entity = await ApiRepository.to.addPasswordKey( + lockId, + _nameController.text, + _pwdController.text, + getKeyType, + getEffectiveDateTime, + getFailureDateTime, + '0'); + if (entity.errorCode!.codeIsSuccessful) { + print('获取密码成功'); + _isSendSuccess = true; + if (entity.data != null) { + _getPwdStr = entity.data!.keyboardPwd!; + setState(() {}); + } + } else { + Toast.show(msg: '${entity.errorMsg}'); + } + } + // 发送电子钥匙成功 Widget sendElectronicKeySucceed() { return Column( diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 861599b2..ba271902 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -32,11 +32,19 @@ abstract class Api { final String deletLockURL = '/lock/delete'; // 删除锁 final String passwordKeyGetURL = '/keyboardPwd/get'; //获取密码 + final String passwordKeyAddURL = '/keyboardPwd/add'; //自定义密码 + final String updatePasswordKeyURL = '/keyboardPwd/update'; //修改密码详情 final String clearOperationRecordURL = '/lockRecords/clear'; //清空操作记录 final String addlockGroupURL = '/keyGroup/add'; //创建锁分组 + final String setlockGroupURL = '/keyGroup/setGroup'; //设置锁分组 final String lockGroupListURL = '/authorizedAdmin/listGroup'; //锁分组列表 + final String listLockByGroupURL = + '/authorizedAdmin/listLockByGroup'; //获取分组下的锁列表 final String updateSettingURL = '/room/updateSetting'; //标记房态 final String keyGroupListURL = '/keyGroup/list'; //分组列表 final String lockListByGroupURL = '/room/listByGroup'; //分组下的锁 final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息 + final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表 + final String canSendKeyURL = '/keyUser/canSendKey'; //群发钥匙检查 + final String batchSendKeyURL = '/key/batchSend'; //批处理群发钥匙 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 4a6ffd18..8ba1999b 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -340,6 +340,48 @@ class ApiProvider extends BaseProvider { 'timezoneRawOffSet': timezoneRawOffSet })); + Future addKeyboardPwd( + String lockId, + String keyboardPwdName, + String keyboardPwd, + String keyboardPwdType, + String startDate, + String endDate, + String addType, + ) => + post( + passwordKeyAddURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyboardPwdName': keyboardPwdName, + 'keyboardPwd': keyboardPwd, + 'keyboardPwdType': keyboardPwdType, + 'startDate': startDate, + 'endDate': endDate, + 'addType': addType, + })); + + Future updateKeyboardPwd( + String lockId, + String keyboardPwdId, + String keyboardPwdName, + String newKeyboardPwd, + String startDate, + String endDate, + String changeType, + ) => + post( + updatePasswordKeyURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyboardPwdId': keyboardPwdId, + 'keyboardPwdName': keyboardPwdName, + 'newKeyboardPwd': newKeyboardPwd, + 'startDate': startDate, + 'endDate': endDate, + 'changeType': changeType, + })); + Future clearOperationRecord(String lockId) => post(clearOperationRecordURL.toUrl, jsonEncode({'lockId': lockId})); @@ -347,6 +389,10 @@ class ApiProvider extends BaseProvider { addlockGroupURL.toUrl, jsonEncode({'groupName': groupName, 'operatorUid': operatorUid})); + Future setLockGroup(String lockId, String groupId) => post( + setlockGroupURL.toUrl, + jsonEncode({'lockId': lockId, 'groupId': groupId})); + Future lockGroupList(String type) => post(lockGroupListURL.toUrl, jsonEncode({'type': type})); @@ -374,8 +420,32 @@ class ApiProvider extends BaseProvider { lockListByGroupURL.toUrl, jsonEncode({'type': type, 'keyGroupId': keyGroupId})); + Future listLockByGroup(String type, String keyGroupId) => post( + listLockByGroupURL.toUrl, + jsonEncode({'type': type, 'keyGroupId': keyGroupId})); + Future getKeyDetail(String lockId) => post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId})); + + Future lockUserList( + String pageNo, String pageSize, String searchStr) => + post( + lockUserListURL.toUrl, + jsonEncode({ + 'pageNo': pageNo, + 'pageSize': pageSize, + 'searchStr': searchStr + })); + + Future canSendKey( + String endDate, String keyGroupIdList, String lockIdList) => + post( + canSendKeyURL.toUrl, + jsonEncode({ + 'endDate': endDate, + 'keyGroupIdList': keyGroupIdList, + 'lockIdList': lockIdList + })); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 4df631d2..515a4f5c 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -2,6 +2,8 @@ import 'package:get/get.dart'; import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.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/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart'; import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/LockGroupListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; @@ -311,6 +313,36 @@ class ApiRepository { return PasswordKeyEntity.fromJson(res.body); } + //自定义密码 + Future addPasswordKey( + String lockId, + String keyboardPwdName, + String keyboardPwd, + String keyboardPwdType, + String startDate, + String endDate, + String addType, + ) async { + final res = await apiProvider.addKeyboardPwd(lockId, keyboardPwdName, + keyboardPwd, keyboardPwdType, startDate, endDate, addType); + return PasswordKeyEntity.fromJson(res.body); + } + + //修改密码 + Future 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); + return PasswordKeyEntity.fromJson(res.body); + } + //清空操作记录 Future clearOperationRecord(String lockId) async { final res = await apiProvider.clearOperationRecord(lockId); @@ -324,6 +356,13 @@ class ApiRepository { return LockGroupListEntity.fromJson(res.body); } + //设置锁分组 + Future setLockGroup( + String lockId, String groupId) async { + final res = await apiProvider.setLockGroup(lockId, groupId); + return LockGroupListEntity.fromJson(res.body); + } + //锁分组列表 Future lockGroupList(String type) async { final res = await apiProvider.lockGroupList(type); @@ -364,9 +403,31 @@ class ApiRepository { return PasswordKeyEntity.fromJson(res.body); } + //分组下的锁列表 + Future listLockByGroup( + String type, String keyGroupId) async { + final res = await apiProvider.listLockByGroup(type, keyGroupId); + return MassSendLockGroupListEntity.fromJson(res.body); + } + //获取单把钥匙详情信息 Future getKeyDetail(String lockId) async { final res = await apiProvider.getKeyDetail(lockId); return KeyDetailEntity.fromJson(res.body); } + + //锁用户列表 + Future lockUserList( + String pageNo, String pageSize, String searchStr) async { + final res = await apiProvider.lockUserList(pageNo, pageSize, searchStr); + return LockUserListEntity.fromJson(res.body); + } + + //群发钥匙检查 + Future canSendKey( + String endDate, String keyGroupIdList, String lockIdList) async { + final res = + await apiProvider.canSendKey(endDate, keyGroupIdList, lockIdList); + return KeyDetailEntity.fromJson(res.body); + } } diff --git a/star_lock/lib/network/request_interceptor.dart b/star_lock/lib/network/request_interceptor.dart index 8aa66a81..ab2ca58e 100644 --- a/star_lock/lib/network/request_interceptor.dart +++ b/star_lock/lib/network/request_interceptor.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:get/get.dart'; import 'package:get/get_connect/http/src/request/request.dart'; +import 'package:star_lock/login/login/entity/LoginData.dart'; import '../login/login/entity/LoginEntity.dart'; import '../tools/platform_info_services.dart'; @@ -18,7 +19,9 @@ FutureOr requestInterceptor(Request request) async { String? xToken = ''; final data = await Storage.getString('userLoginData'); if (data != null && data.isNotEmpty) { - xToken = LoginEntity.fromJson(jsonDecode(data)).data!.accessToken; + LoginData loginData = LoginData.fromJson(jsonDecode(data)); + xToken = loginData.accessToken; + // xToken = LoginEntity.fromJson(jsonDecode(data)).data!.accessToken; } request.headers['Authorization'] = "Bearer ${xToken ?? ''}"; return request; diff --git a/star_lock/lib/tools/ExpandedListView.dart b/star_lock/lib/tools/ExpandedListView.dart index 01434c83..fae30663 100644 --- a/star_lock/lib/tools/ExpandedListView.dart +++ b/star_lock/lib/tools/ExpandedListView.dart @@ -87,11 +87,11 @@ class _ExpandedListTileState extends State { color: Colors.white, child: Row( children: [ - Image.asset( - widget.imgName, - width: 36.w, - height: 36.w, - ), + // Image.asset( + // widget.imgName, + // width: 36.w, + // height: 36.w, + // ), SizedBox( width: 10.w, ), From 72c26d89dbfb4006b6ee150e9174f44a3f0f9807 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Thu, 7 Sep 2023 18:34:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/network/request_interceptor.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/star_lock/lib/network/request_interceptor.dart b/star_lock/lib/network/request_interceptor.dart index ab2ca58e..8aa66a81 100644 --- a/star_lock/lib/network/request_interceptor.dart +++ b/star_lock/lib/network/request_interceptor.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:convert'; import 'package:get/get.dart'; import 'package:get/get_connect/http/src/request/request.dart'; -import 'package:star_lock/login/login/entity/LoginData.dart'; import '../login/login/entity/LoginEntity.dart'; import '../tools/platform_info_services.dart'; @@ -19,9 +18,7 @@ FutureOr requestInterceptor(Request request) async { String? xToken = ''; final data = await Storage.getString('userLoginData'); if (data != null && data.isNotEmpty) { - LoginData loginData = LoginData.fromJson(jsonDecode(data)); - xToken = loginData.accessToken; - // xToken = LoginEntity.fromJson(jsonDecode(data)).data!.accessToken; + xToken = LoginEntity.fromJson(jsonDecode(data)).data!.accessToken; } request.headers['Authorization'] = "Bearer ${xToken ?? ''}"; return request;