From 4045a13d8de23c6a71c2ab7668fe314eac653aca Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Wed, 13 Sep 2023 18:13:36 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E9=94=81=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=8F=8A=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86=202=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=94=81=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8F=8A=E7=94=A8=E6=88=B7=E6=8B=A5=E6=9C=89?= =?UTF-8?q?=E7=9A=84=E9=94=81=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorizedAdmin/authorizedAdmin_page.dart | 2 +- .../volumeAuthorizationLock_page.dart | 234 +++++++++++++++--- .../lockUserList/lockUserList_page.dart | 4 +- .../lockSeletGrouping_page.dart | 9 +- .../lockUserManage/keyListByUserEntity.dart | 206 +++++++++++++++ .../lockUserManageList_page.dart | 46 +++- .../lockUserManage/ownedKeyList_page.dart | 79 +++++- star_lock/lib/network/api.dart | 2 + star_lock/lib/network/api_provider.dart | 42 +++- star_lock/lib/network/api_repository.dart | 46 +++- 10 files changed, 596 insertions(+), 74 deletions(-) create mode 100644 star_lock/lib/mine/mineSet/lockUserManage/keyListByUserEntity.dart diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index e523ae71..7b7ba3f3 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -452,7 +452,7 @@ class _AuthorizedAdminPageState extends State { value: _isAuthentication, onChanged: (value) { setState(() { - _isAuthentication = value; + _isAuthentication = !_isAuthentication; }); }, ); diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index f274fd24..75b827f6 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -1,8 +1,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; +import 'package:flutter_pickers/pickers.dart'; +import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; import '../../../../appRouters.dart'; import '../../../../tools/commonItem.dart'; @@ -23,12 +28,25 @@ class VolumeAuthorizationLockPage extends StatefulWidget { class _VolumeAuthorizationLockPageState extends State { final FlutterContactPicker _contactPicker = FlutterContactPicker(); + final TextEditingController _emailOrPhoneController = + TextEditingController(); //邮箱/手机号输入框 + final TextEditingController _keyNameController = + TextEditingController(); //钥匙名输入框 late Contact _contact; late List _lockIdList; + late bool _isSendSuccess; + late bool _isCreateUser; //是否需要创建用户 + late bool _isRemoteUnlock; //是否远程开锁 + var _selectEffectiveDate = ''; //生效时间 + var _selectFailureDate = ''; //失效时间 + late DateTime _effectiveDateTime; + late DateTime _failureDateTime; @override Widget build(BuildContext context) { - return indexChangeWidget(); + return SingleChildScrollView( + child: indexChangeWidget(), + ); } @override @@ -36,16 +54,43 @@ class _VolumeAuthorizationLockPageState super.initState(); _lockIdList = []; + _isRemoteUnlock = false; + _isSendSuccess = false; + _isCreateUser = false; + DateTime dateTime = DateTime.now(); + _effectiveDateTime = dateTime; + _failureDateTime = dateTime; + _selectEffectiveDate = + '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 + _selectFailureDate = + '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 } Widget indexChangeWidget() { - switch (int.parse(widget.type)) { - case 0: - { - // 永久 + if (_isSendSuccess) { + return sendElectronicKeySucceed(); + } else { + switch (int.parse(widget.type)) { + case 0: + { + // 永久 + return Column( + children: [ + keyInfoWidget(), + remoteUnlockingWidget(), + SizedBox( + height: 30.h, + ), + keyBottomWidget() + ], + ); + } + default: + // 限时 return Column( children: [ keyInfoWidget(), + keyTimeWidget(), remoteUnlockingWidget(), SizedBox( height: 30.h, @@ -53,20 +98,7 @@ class _VolumeAuthorizationLockPageState keyBottomWidget() ], ); - } - default: - // 限时 - return Column( - children: [ - keyInfoWidget(), - keyTimeWidget(), - remoteUnlockingWidget(), - SizedBox( - height: 30.h, - ), - keyBottomWidget() - ], - ); + } } } @@ -81,13 +113,17 @@ class _VolumeAuthorizationLockPageState isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( - true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr)), + true, + TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, + _emailOrPhoneController)), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, rightTitle: "", isHaveRightWidget: true, - rightWidget: - getTFWidget(false, TranslationLoader.lanKeys!.pleaseEnter!.tr)), + rightWidget: getTFWidget( + false, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + _keyNameController)), Container(height: 10.h), ], ); @@ -99,12 +135,33 @@ class _VolumeAuthorizationLockPageState children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: "2020.06.20 11:49", - isHaveLine: true), + rightTitle: _selectEffectiveDate, + isHaveLine: true, + isHaveDirection: true, + action: () { + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + _selectEffectiveDate = + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + _effectiveDateTime = DateTime.parse(_selectEffectiveDate); + }); + }); + }), CommonItem( - leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: "2020.06.20 11:49", - ), + leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, + rightTitle: _selectFailureDate, + isHaveDirection: true, + action: () { + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + _selectFailureDate = + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + _failureDateTime = DateTime.parse(_selectFailureDate); + }); + }); + }), Container(height: 10.h), ], ); @@ -153,21 +210,23 @@ class _VolumeAuthorizationLockPageState margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { - // Navigator.pushNamed(context, Routers.nearbyLockPage); + addAuthorizedAdminRequest(); }), ], ); } // 接受者信息输入框 - Widget getTFWidget(bool isHaveBtn, String tfStr) { - return Container( + Widget getTFWidget( + bool isHaveBtn, String tfStr, TextEditingController editController) { + return SizedBox( height: 50.h, width: 300.w, child: Row( children: [ Expanded( child: TextField( + controller: editController, //输入框一行 maxLines: 1, // controller: _controller, @@ -213,18 +272,127 @@ class _VolumeAuthorizationLockPageState ); } + //发送批量授权管理员 + Future addAuthorizedAdminRequest() async { + String getFailureDateTime = '0'; + String getEffectiveDateTime = '0'; + if (widget.type == '1') { + getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString(); + getEffectiveDateTime = + _effectiveDateTime.millisecondsSinceEpoch.toString(); + } + var entity = await ApiRepository.to.addAuthorizedAdmin( + _isCreateUser ? "1" : "0", + getFailureDateTime, + _isRemoteUnlock == true ? '1' : '2', + [], + _lockIdList, + _keyNameController.text, + getEffectiveDateTime, + _emailOrPhoneController.text, + '86', + '1', + ); + if (entity.errorCode!.codeIsSuccessful) { + print('发送电子钥匙成功'); + _isSendSuccess = true; + setState(() {}); + } else { + Toast.show(msg: '${entity.errorMsg}'); + if (entity.errorCode == 425) { + //用户未注册 + _isCreateUser = true; + } + } + } + + // 发送电子钥匙成功 + Widget sendElectronicKeySucceed() { + return Column( + children: [ + Container( + height: 250.h, + width: 1.sw, + color: Colors.white, + child: Column( + children: [ + SizedBox( + height: 30.h, + ), + Image.asset( + 'images/icon_send_success.png', + width: 100.w, + height: 100.w, + ), + SizedBox( + height: 20.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "发送成功", + style: TextStyle( + fontSize: 26.sp, + color: Colors.black, + fontWeight: FontWeight.w500), + ), + ], + ), + ], + ), + ), + SizedBox( + height: 20.h, + ), + SubmitBtn( + btnName: '完成', + onClick: () { + _isSendSuccess = false; + Navigator.pop(context, true); + }), + SizedBox( + height: 10.h, + ), + OutLineBtn( + btnName: '邮件通知', + onClick: () { + Navigator.pushNamed(context, Routers.sendEmailNotificationPage); + }, + ), + SizedBox( + height: 10.h, + ), + OutLineBtn( + btnName: '微信通知', + onClick: () {}, + ), + SizedBox( + height: 10.h, + ), + OutLineBtn( + btnName: '标记为已入住', + onClick: () {}, + ), + ], + ); + } + CupertinoSwitch _switch() { - bool _isOn = false; return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: _isOn, + value: _isRemoteUnlock, onChanged: (value) { setState(() { - _isOn = value; + _isRemoteUnlock = !_isRemoteUnlock; }); }, ); } + + String intToStr(int v) { + return (v < 10) ? "0$v" : "$v"; + } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart index c8a45f62..7220a588 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart @@ -160,7 +160,7 @@ class _LockUserListPageState extends State { Row( children: [ Text( - itemData.nickname!, + itemData.nickname ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ) @@ -171,7 +171,7 @@ class _LockUserListPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - itemData.userid!, + itemData.userid ?? '', style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor), 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 38935c39..86111711 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 @@ -3,7 +3,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.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'; import 'package:star_lock/tools/showTFView.dart'; @@ -83,7 +82,7 @@ class _LockSeletGroupingPageState extends State { return ListView.builder( itemCount: itemList.length, itemBuilder: (c, index) { - LockGroupItem itemData = itemList[index]; + GroupListItem itemData = itemList[index]; return CommonItem( leftTitel: itemData.keyGroupName, rightTitle: "", @@ -108,7 +107,7 @@ class _LockSeletGroupingPageState extends State { //创建锁分组请求 Future addLockGroupRequest() async { - LockGroupListEntity entity = + MassSendLockGroupListEntity entity = await ApiRepository.to.addLockGroup(_changeNameController.text, '0'); if (entity.errorCode!.codeIsSuccessful) { Toast.show(msg: "创建成功"); @@ -118,8 +117,8 @@ class _LockSeletGroupingPageState extends State { } //设置锁分组请求 - Future setLockGroupRequest(LockGroupItem itemData) async { - LockGroupListEntity entity = await ApiRepository.to.setLockGroup( + Future setLockGroupRequest(GroupListItem itemData) async { + MassSendLockGroupListEntity entity = await ApiRepository.to.setLockGroup( _lockData.lockId.toString(), itemData.keyGroupId.toString()); if (entity.errorCode!.codeIsSuccessful) { Toast.show(msg: "设置锁分组成功"); diff --git a/star_lock/lib/mine/mineSet/lockUserManage/keyListByUserEntity.dart b/star_lock/lib/mine/mineSet/lockUserManage/keyListByUserEntity.dart new file mode 100644 index 00000000..65449998 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/keyListByUserEntity.dart @@ -0,0 +1,206 @@ +class KeyListByUserEntity { + int? errorCode; + String? description; + String? errorMsg; + KeyListByUserData? data; + + KeyListByUserEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + KeyListByUserEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = + json['data'] != null ? KeyListByUserData.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 KeyListByUserData { + List? keyList; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + KeyListByUserData( + {this.keyList, this.pageNo, this.pageSize, this.pages, this.total}); + + KeyListByUserData.fromJson(Map json) { + if (json['list'] != null) { + keyList = []; + json['list'].forEach((v) { + keyList!.add(KeyListItem.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (keyList != null) { + data['list'] = keyList!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class KeyListItem { + String? clientId; + int? lockOwnerId; + int? lockId; + int? senderUserId; + String? keyName; + int? keyType; + int? startDate; + int? endDate; + List? weekDays; + String? remarks; + int? remoteEnable; + int? isCameraEnable; + int? faceAuthentication; + int? keyRight; + int? userType; + int? keyStatus; + int? groupId; + int? lockUserNo; + int? date; + String? createdAt; + String? updatedAt; + UserInfo? userInfo; + int? keyId; + int? uid; + String? lockAlias; + + KeyListItem( + {this.clientId, + this.lockOwnerId, + this.lockId, + this.senderUserId, + this.keyName, + this.keyType, + this.startDate, + this.endDate, + this.weekDays, + this.remarks, + this.remoteEnable, + this.isCameraEnable, + this.faceAuthentication, + this.keyRight, + this.userType, + this.keyStatus, + this.groupId, + this.lockUserNo, + this.date, + this.createdAt, + this.updatedAt, + this.userInfo, + this.keyId, + this.uid, + this.lockAlias}); + + KeyListItem.fromJson(Map json) { + clientId = json['clientId']; + lockOwnerId = json['lockOwnerId']; + lockId = json['lockId']; + senderUserId = json['senderUserId']; + keyName = json['keyName']; + keyType = json['keyType']; + startDate = json['startDate']; + endDate = json['endDate']; + if (json['weekDays'] != null) { + weekDays = []; + json['weekDays'].forEach((v) { + weekDays!.add(v); + }); + } + remarks = json['remarks']; + remoteEnable = json['remoteEnable']; + isCameraEnable = json['isCameraEnable']; + faceAuthentication = json['faceAuthentication']; + keyRight = json['keyRight']; + userType = json['userType']; + keyStatus = json['keyStatus']; + groupId = json['groupId']; + lockUserNo = json['lockUserNo']; + date = json['date']; + createdAt = json['created_at']; + updatedAt = json['updated_at']; + userInfo = + json['user_info'] != null ? UserInfo.fromJson(json['user_info']) : null; + keyId = json['keyId']; + uid = json['uid']; + lockAlias = json['lockAlias']; + } + + Map toJson() { + final Map data = {}; + data['clientId'] = clientId; + data['lockOwnerId'] = lockOwnerId; + data['lockId'] = lockId; + data['senderUserId'] = senderUserId; + data['keyName'] = keyName; + data['keyType'] = keyType; + data['startDate'] = startDate; + data['endDate'] = endDate; + if (weekDays != null) { + data['weekDays'] = weekDays!.map((v) => v.toJson()).toList(); + } + data['remarks'] = remarks; + data['remoteEnable'] = remoteEnable; + data['isCameraEnable'] = isCameraEnable; + data['faceAuthentication'] = faceAuthentication; + data['keyRight'] = keyRight; + data['userType'] = userType; + data['keyStatus'] = keyStatus; + data['groupId'] = groupId; + data['lockUserNo'] = lockUserNo; + data['date'] = date; + data['created_at'] = createdAt; + data['updated_at'] = updatedAt; + if (userInfo != null) { + data['user_info'] = userInfo!.toJson(); + } + data['keyId'] = keyId; + data['uid'] = uid; + data['lockAlias'] = lockAlias; + return data; + } +} + +class UserInfo { + int? id; + String? accountName; + + UserInfo({this.id, this.accountName}); + + UserInfo.fromJson(Map json) { + id = json['id']; + accountName = json['account_name']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['account_name'] = accountName; + return data; + } +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList_page.dart index cc4d31f5..ee754ba6 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList_page.dart @@ -1,6 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -17,6 +20,15 @@ class LockUserManageListListPage extends StatefulWidget { class _LockUserManageListListPageState extends State { + List dataList = []; + + @override + void initState() { + super.initState(); + + lockUserListRequest(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -105,12 +117,10 @@ class _LockUserManageListListPageState Widget _buildMainUI() { return ListView.separated( - itemCount: 5, + itemCount: dataList.length, itemBuilder: (c, index) { - return _electronicKeyItem('images/controls_user.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { - Navigator.pushNamed(context, Routers.ownedKeyListPage); - }); + LockUserData indexEntity = dataList[index]; + return _electronicKeyItem(indexEntity); }, separatorBuilder: (BuildContext context, int index) { return const Divider( @@ -121,10 +131,24 @@ class _LockUserManageListListPageState ); } - Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { + //请求锁用户列表 + Future> lockUserListRequest() async { + LockUserListEntity entity = + await ApiRepository.to.lockUserList('1', '20', ''); + if (entity.errorCode!.codeIsSuccessful) { + setState(() { + dataList = entity.data!; + }); + } + return dataList; + } + + Widget _electronicKeyItem(LockUserData itemData) { return GestureDetector( - onTap: action, + onTap: () { + Navigator.pushNamed(context, Routers.ownedKeyListPage, + arguments: {'uid': itemData.uid}); + }, child: Container( height: 90.h, color: Colors.white, @@ -138,7 +162,7 @@ class _LockUserManageListListPageState width: 30.w, ), Image.asset( - lockTypeIcon, + 'images/controls_user.png', width: 60.w, height: 60.w, ), @@ -153,7 +177,7 @@ class _LockUserManageListListPageState mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - lockTypeTitle, + itemData.nickname ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ), @@ -164,7 +188,7 @@ class _LockUserManageListListPageState mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - "2023.6.21 11.15 永久", + itemData.userid ?? '', style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor), diff --git a/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList_page.dart index 30ae047d..3cf2004b 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList_page.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get_utils/get_utils.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/keyListByUserEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/translations/trans_lib.dart'; -import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/titleAppBar.dart'; @@ -15,8 +17,23 @@ class OwnedKeyListPage extends StatefulWidget { } class _OwnedKeyListPageState extends State { + String getUidStr = ''; + List dataList = []; + + @override + void initState() { + super.initState(); + } + @override Widget build(BuildContext context) { + dynamic obj = ModalRoute.of(context)?.settings.arguments; + if (obj != null && (obj["uid"] != null)) { + getUidStr = obj["uid"].toString(); + } + + keyListByUserRequest(); + return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -49,21 +66,59 @@ class _OwnedKeyListPageState extends State { ); } + //请求用户拥有的锁 + Future> keyListByUserRequest() async { + KeyListByUserEntity entity = + await ApiRepository.to.keyListByUser('1', '20', getUidStr); + if (entity.errorCode!.codeIsSuccessful) { + setState(() { + dataList = entity.data!.keyList!; + }); + } + return []; + } + + //使用期限 + String getUseDateStr(KeyListItem 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 { + useDateStr = '限期'; + } + } else if (indexEntity.keyType == 2) { + //永久 + useDateStr = '永久'; + } else if (indexEntity.keyType == 3) { + //单次 + useDateStr = '单次'; + } else if (indexEntity.keyType == 4) { + //循环 + useDateStr = '循环'; + } + + return useDateStr; + } + Widget _buildMainUI() { return ListView.builder( - itemCount: 5, + itemCount: dataList.length, itemBuilder: (c, index) { - return _electronicKeyItem('images/controls_user.png', "JBL01_5a3de9", - "2023.6.21 11.15", "2023.6.21 11.15", () { - // Navigator.pushNamed(context, Routers.authorizedAdminDetailPage); - }); + KeyListItem itemData = dataList[index]; + return _electronicKeyItem(itemData); }); } - Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { + Widget _electronicKeyItem(KeyListItem itemData) { return GestureDetector( - onTap: action, + onTap: () {}, child: Container( height: 90.h, margin: const EdgeInsets.only(top: 1), @@ -77,7 +132,7 @@ class _OwnedKeyListPageState extends State { width: 30.w, ), Image.asset( - lockTypeIcon, + 'images/icon_lockGroup_item.png', width: 60.w, height: 60.w, ), @@ -92,7 +147,7 @@ class _OwnedKeyListPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - lockTypeTitle, + itemData.keyName ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ), @@ -103,7 +158,7 @@ class _OwnedKeyListPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - "2023.6.21 11.15 永久", + getUseDateStr(itemData), style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor), diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index df8a11ef..b1183ee1 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -65,4 +65,6 @@ abstract class Api { final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表 final String canSendKeyURL = '/keyUser/canSendKey'; //群发钥匙检查 final String batchSendKeyURL = '/key/batchSend'; //批处理群发钥匙 + final String addAuthorizedAdminURL = '/authorizedAdmin/add'; //增加授权管理员 + final String keyListByUserURL = '/keyUser/listByUse'; //用户拥有的锁 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index df74025c..57383fd9 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -115,7 +115,8 @@ class ApiProvider extends BaseProvider { 'pageSize': pageSize, 'startDate': startDate, 'keyRight': keyRight - })); + }), + isShowLoading: true); Future sendElectronicKey( String createUser, @@ -252,7 +253,8 @@ class ApiProvider extends BaseProvider { 'keyboardPwdId': keyboardPwdId, 'cardId': cardId, 'fingerprintId': fingerprintId - })); + }), + isShowLoading: true); // 绑定蓝牙管理员 Future bindingBlueAdmin( @@ -344,7 +346,8 @@ class ApiProvider extends BaseProvider { 'operatorUid': operatorUid, 'startDate': startDate, 'timezoneRawOffSet': timezoneRawOffSet - })); + }), + isShowLoading: true); Future addKeyboardPwd( String lockId, @@ -606,7 +609,8 @@ class ApiProvider extends BaseProvider { jsonEncode({'type': type, 'keyGroupId': keyGroupId})); Future getKeyDetail(String lockId) => - post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId})); + post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId}), + isShowLoading: true); Future lockUserList( String pageNo, String pageSize, String searchStr) => @@ -618,6 +622,10 @@ class ApiProvider extends BaseProvider { 'searchStr': searchStr })); + Future keyListByUser(String pageNo, String pageSize, String uid) => + post(keyListByUserURL.toUrl, + jsonEncode({'pageNo': pageNo, 'pageSize': pageSize, 'uid': uid})); + Future canSendKey( String endDate, List keyGroupIdList, List lockIdList) => post( @@ -655,6 +663,32 @@ class ApiProvider extends BaseProvider { 'usernameType': usernameType, 'weekDays': weekDays, })); + + Future addAuthorizedAdmin( + String createUser, + String endDate, + String isRemoteUnlock, + List keyGroupIdList, + List lockIdList, + String name, + String startDate, + String userid, + String countryCode, + String usernameType) => + post( + addAuthorizedAdminURL.toUrl, + jsonEncode({ + 'createUser': createUser, + 'endDate': endDate, + 'isRemoteUnlock': isRemoteUnlock, + 'keyGroupIdList': keyGroupIdList, + 'lockIdList': lockIdList, + 'name': name, + 'startDate': startDate, + 'userid': userid, + 'countryCode': countryCode, + 'usernameType': usernameType + })); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 98e65693..88584a94 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -8,6 +8,7 @@ import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformat 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'; +import 'package:star_lock/mine/mineSet/lockUserManage/keyListByUserEntity.dart'; import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; @@ -356,17 +357,17 @@ class ApiRepository { } //创建锁分组 - Future addLockGroup( + Future addLockGroup( String groupName, String operatorUid) async { final res = await apiProvider.addLockGroup(groupName, operatorUid); - return LockGroupListEntity.fromJson(res.body); + return MassSendLockGroupListEntity.fromJson(res.body); } //设置锁分组 - Future setLockGroup( + Future setLockGroup( String lockId, String groupId) async { final res = await apiProvider.setLockGroup(lockId, groupId); - return LockGroupListEntity.fromJson(res.body); + return MassSendLockGroupListEntity.fromJson(res.body); } //锁分组列表 @@ -540,7 +541,14 @@ class ApiRepository { return LockUserListEntity.fromJson(res.body); } - //群发钥匙检查 + //用户拥有的锁 + Future keyListByUser( + String pageNo, String pageSize, String uid) async { + final res = await apiProvider.keyListByUser(pageNo, pageSize, uid); + return KeyListByUserEntity.fromJson(res.body); + } + + //群发电子钥匙检查 Future canSendKey( String endDate, List keyGroupIdList, List lockIdList) async { final res = @@ -548,7 +556,7 @@ class ApiRepository { return KeyDetailEntity.fromJson(res.body); } - //群发钥匙检查 + //群发电子钥匙 Future batchSendKey( String endDate, List keyGroupIdList, @@ -576,6 +584,32 @@ class ApiRepository { return KeyDetailEntity.fromJson(res.body); } + //增加授权管理员 + Future addAuthorizedAdmin( + String createUser, + String endDate, + String isRemoteUnlock, + List keyGroupIdList, + List lockIdList, + String name, + String startDate, + String userid, + String countryCode, + String usernameType) async { + final res = await apiProvider.addAuthorizedAdmin( + createUser, + endDate, + isRemoteUnlock, + keyGroupIdList, + lockIdList, + name, + startDate, + userid, + countryCode, + usernameType); + return KeyDetailEntity.fromJson(res.body); + } + // 开启考勤 获取考勤信息 Future openCheckingInData( {required String lockId}) async {