diff --git a/star_lock/.vscode/launch.json b/star_lock/.vscode/launch.json new file mode 100644 index 00000000..79fa3bcd --- /dev/null +++ b/star_lock/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "star_lock", + "request": "launch", + "type": "dart" + }, + { + "name": "star_lock (profile mode)", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "star_lock (release mode)", + "request": "launch", + "type": "dart", + "flutterMode": "release" + } + ] +} \ No newline at end of file diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 306e0cc3..a680f955 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -136,7 +136,7 @@ "lockEscalation":"锁升级", "markedHouseState":"标记房态", "unlockReminder":"开锁提醒", - "unlockQRCode":"开锁二维码", + "unlockQRCode":"微信二维码", "lockNumber":"锁编号", "electricQuantity":"电量", "lockName":"名称", diff --git a/star_lock/images/lockType/lockType_NFCLock.png b/star_lock/images/lockType/lockType_NFCLock.png new file mode 100644 index 00000000..735c5139 Binary files /dev/null and b/star_lock/images/lockType/lockType_NFCLock.png differ diff --git a/star_lock/images/lockType/lockType_allLocks.png b/star_lock/images/lockType/lockType_allLocks.png index cf16d55f..20aea7e5 100644 Binary files a/star_lock/images/lockType/lockType_allLocks.png and b/star_lock/images/lockType/lockType_allLocks.png differ diff --git a/star_lock/images/lockType/lockType_doorLock.png b/star_lock/images/lockType/lockType_doorLock.png index a7be3c3a..46a27100 100644 Binary files a/star_lock/images/lockType/lockType_doorLock.png and b/star_lock/images/lockType/lockType_doorLock.png differ diff --git a/star_lock/images/lockType/lockType_entranceGuardLock.png b/star_lock/images/lockType/lockType_entranceGuardLock.png new file mode 100644 index 00000000..363f70aa Binary files /dev/null and b/star_lock/images/lockType/lockType_entranceGuardLock.png differ diff --git a/star_lock/images/lockType/lockType_gatewayLock.png b/star_lock/images/lockType/lockType_gatewayLock.png new file mode 100644 index 00000000..f14724c9 Binary files /dev/null and b/star_lock/images/lockType/lockType_gatewayLock.png differ diff --git a/star_lock/images/main/icon_catEyes.png b/star_lock/images/main/icon_catEyes.png new file mode 100644 index 00000000..55887621 Binary files /dev/null and b/star_lock/images/main/icon_catEyes.png differ diff --git a/star_lock/images/main/icon_face.png b/star_lock/images/main/icon_face.png new file mode 100644 index 00000000..0aa2397c Binary files /dev/null and b/star_lock/images/main/icon_face.png differ diff --git a/star_lock/images/main/icon_main_openLockBtn.png b/star_lock/images/main/icon_main_openLockBtn.png index f2e2bda5..1f6f1950 100644 Binary files a/star_lock/images/main/icon_main_openLockBtn.png and b/star_lock/images/main/icon_main_openLockBtn.png differ diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index d8312234..50f23081 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -1,15 +1,22 @@ + import 'package:get/get.dart'; import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart'; import 'package:star_lock/login/register/starLock_register_binding.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart'; +import 'package:star_lock/login/register/starLock_register_binding.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart'; import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/minePersonInfoEmail_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart'; import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList_page.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList_Page.dart'; import 'package:star_lock/mine/mineSet/mineSet_page.dart'; import 'package:star_lock/mine/mineSet/transferGateway/selectGetewayList_page.dart'; import 'package:star_lock/mine/mineSet/transferSmartLock/recipientInformation_page.dart'; @@ -301,6 +308,8 @@ abstract class Routers { static const massSendLockGroupPage = '/massSendLockGroupPage'; //群发锁分组列表 static const massSendReceiverPage = '/massSendReceiverPage'; //群发接收人 static const lockUserListPage = '/lockUserListPage'; //锁用户列表 + static const administratorDetailsPage = '/administratorDetailsPage'; //管理员详情 + static const expireLockListPage = '/expireLockListPage'; //即将到期 } abstract class AppRouters { @@ -706,7 +715,7 @@ abstract class AppRouters { page: () => const AuthorizedAdministratorListPage()), GetPage( name: Routers.lockUserManageLisPage, - page: () => const LockUserManageListListPage()), + page: () => const LockUserManageListPage()), GetPage( name: Routers.lockGroupListPage, page: () => const LockGroupListPage()), GetPage( @@ -753,7 +762,7 @@ abstract class AppRouters { GetPage( name: Routers.configuringWifiPage, page: () => const ConfiguringWifiPage()), - GetPage( + GetPage( name: Routers.massSendLockGroupPage, page: () => const MassSendLockGroupListPage()), GetPage( @@ -766,5 +775,13 @@ abstract class AppRouters { GetPage( name: Routers.checkingInStaffDetailPage, page: () => const CheckingInStaffDetailPage()) + name: Routers.checkInCreatCompanyPage, + page: () => const CheckInCreatCompanyPage()), + GetPage( + name: Routers.administratorDetailsPage, + page: () => const AdministratorDetailsPage()), + GetPage( + name: Routers.expireLockListPage, + page: () => const ExpireLockListPage()) ]; } 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 88a87153..e47470b1 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,14 @@ 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/app_settings/app_colors.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,27 +29,71 @@ 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; + String countryName = '中国'; + String countryCode = '86'; @override Widget build(BuildContext context) { - return indexChangeWidget(); + return SingleChildScrollView( + child: indexChangeWidget(), + ); } @override void initState() { - // TODO: implement initState 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, @@ -51,20 +101,7 @@ class _VolumeAuthorizationLockPageState keyBottomWidget() ], ); - } - default: - // 限时 - return Column( - children: [ - keyInfoWidget(), - keyTimeWidget(), - remoteUnlockingWidget(), - SizedBox( - height: 30.h, - ), - keyBottomWidget() - ], - ); + } } } @@ -74,18 +111,43 @@ class _VolumeAuthorizationLockPageState children: [ Container(height: 10.h), CommonItem( - leftTitel: TranslationLoader.lanKeys!.number!.tr, + leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, rightTitle: "", isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( - true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr)), + true, + TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, + _emailOrPhoneController)), + 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(() {}); + }, + ), 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), ], ); @@ -97,12 +159,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), ], ); @@ -114,9 +197,22 @@ class _VolumeAuthorizationLockPageState children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.lock!.tr, - rightTitle: TranslationLoader.lanKeys!.pleaseSelet!.tr, + rightTitle: _lockIdList.isEmpty + ? TranslationLoader.lanKeys!.pleaseSelet!.tr + : _lockIdList.length.toString(), isHaveDirection: true, - action: () {}), + action: () { + Navigator.pushNamed(context, Routers.massSendLockGroupPage) + .then((value) { + //得到选中的锁ID列表 + if (value != null) { + value as Map; + _lockIdList = value['selectLockIdList']; + + setState(() {}); + } + }); + }), Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, @@ -138,21 +234,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, @@ -198,18 +296,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, + countryCode, + '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/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart new file mode 100644 index 00000000..dd1ada47 --- /dev/null +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetStaffList/checkingInStaffList_page.dart @@ -0,0 +1,117 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +import '../../../../appRouters.dart'; +import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/titleAppBar.dart'; +import '../../../../translations/trans_lib.dart'; +import 'checkingInStaffList_logic.dart'; + +class CheckingInStaffListPage extends StatefulWidget { + const CheckingInStaffListPage({Key? key}) : super(key: key); + + @override + State createState() => + _CheckingInStaffListPageState(); +} + +class _CheckingInStaffListPageState extends State { + final logic = Get.put(CheckingInStaffManageLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.greyBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.staff!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + GestureDetector( + onTap: () { + Navigator.pushNamed(context, Routers.checkingInAddStaffPage, + arguments: { + "getKeyInfosData": state.getKeyInfosData.value, + "companyId": state.companyId.value + }); + }, + child: Image.asset( + 'images/icon_add_white.png', + width: 36.w, + height: 36.w, + )), + SizedBox( + width: 30.w, + ), + ], + ), + body: Container( + color: Colors.white, + child: ListView.separated( + itemCount: 10, + itemBuilder: (c, index) { + return _checkingInStaffManageItem('images/icon_lock.png', "张三", + "2023.6.21 11.15", "2023.6.21 11.15", () { + // Navigator.pushNamed(context, Routers.electronicKeyDetailPage); + }); + }, + separatorBuilder: (context, index) { + return const Divider( + height: 1, indent: 20, color: AppColors.greyLineColor); + }, + ), + )); + } + + Widget _checkingInStaffManageItem(String lockTypeIcon, String lockTypeTitle, + String beginTime, String endTime, Function() action) { + return GestureDetector( + onTap: action, + child: Container( + height: 60.h, + margin: + EdgeInsets.only(left: 10.w, right: 10.w, top: 10.h, bottom: 10.h), + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(10.w), + // ), + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/controls_user.png', + width: 40.w, + height: 40.w, + ), + // Container( + // width: 60.h, + // height: 60.h, + // decoration: BoxDecoration( + // color: AppColors.mainColor, + // border: Border.all(width: 1, color: AppColors.mainColor), + // borderRadius: BorderRadius.circular(30.h), + // ), + // padding: EdgeInsets.all(10.w), + // child: Image.asset( + // 'images/controls_user.png', + // width: 40.w, + // height: 40.w, + // color: Colors.white, + // )), + SizedBox( + width: 30.w, + ), + Text( + lockTypeTitle, + style: TextStyle(fontSize: 24.sp), + ), + ], + ), + ), + ); + } +} 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 3f88d9e5..7a10a16d 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -1,7 +1,14 @@ import 'package:flutter/cupertino.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:flutter_native_contact_picker/flutter_native_contact_picker.dart'; +import 'package:star_lock/app_settings/app_colors.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 'package:star_lock/tools/toast.dart'; import '../../../../../tools/commonItem.dart'; import '../../../../../tools/submitBtn.dart'; @@ -22,6 +29,18 @@ class MassSendElectronicKeyPage extends StatefulWidget { class _MassSendElectronicKeyPageState extends State { final FlutterContactPicker _contactPicker = FlutterContactPicker(); late Contact _contact; + var _selectEffectiveDate = ''; //生效时间 + var _selectFailureDate = ''; //失效时间 + late DateTime _effectiveDateTime; + late DateTime _failureDateTime; + late bool _isSendSuccess; + late bool _isRemote; //是否远程开锁 + List _receiverList = []; //接受者列表 + List _lockIdList = []; //选中的锁ID列表 + String countryName = '中国'; + String countryCode = '86'; + List weekdaysList = []; + bool _isCreateUser = false; //用户未注册时传1 已注册传0 @override Widget build(BuildContext context) { @@ -31,6 +50,16 @@ class _MassSendElectronicKeyPageState extends State { @override void initState() { super.initState(); + + 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}'; //默认为当前时间 + _isSendSuccess = false; + _isRemote = false; } Widget indexChangeWidget() { @@ -75,6 +104,58 @@ class _MassSendElectronicKeyPageState extends State { } } + //群发钥匙检查 + Future MassKeyChecksRequest() async { + String getFailureDateTime = '0'; + if (int.parse(widget.type) != 1) { + getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString(); + } + var entity = + await ApiRepository.to.canSendKey(getFailureDateTime, [], _lockIdList); + if (entity.errorCode!.codeIsSuccessful) { + for (int i = 0; i < _receiverList.length; i++) { + LockUserData data = _receiverList[i]; + batchSendElectronicKeyRequest(data.userid ?? ''); + } + } else { + Toast.show(msg: '检查失败'); + } + } + + //批处理群发钥匙 + Future batchSendElectronicKeyRequest(String receiverUserID) async { + String getFailureDateTime = '0'; + String getEffectiveDateTime = '0'; + if (widget.type == '0') { + getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString(); + getEffectiveDateTime = + _effectiveDateTime.millisecondsSinceEpoch.toString(); + } + var entity = await ApiRepository.to.batchSendKey( + getFailureDateTime, + [], + _lockIdList, + '1', + _isRemote ? '1' : '2', + receiverUserID, + receiverUserID, + getEffectiveDateTime, + countryCode, + '1', + weekdaysList); + if (entity.errorCode!.codeIsSuccessful) { + print('群发电子钥匙成功'); + _isSendSuccess = true; + setState(() {}); + } else { + Toast.show(msg: '${entity.errorMsg}'); + if (entity.errorCode == 425) { + //用户未注册 + _isCreateUser = true; + } + } + } + // 顶部钥匙信息widget Widget keyInfoWidget() { return Column( @@ -82,18 +163,60 @@ class _MassSendElectronicKeyPageState extends State { Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.receiver!.tr, - rightTitle: TranslationLoader.lanKeys!.pleaseAdd!.tr, + rightTitle: _receiverList.isEmpty + ? TranslationLoader.lanKeys!.pleaseAdd!.tr + : _receiverList.length.toString(), isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendReceiverPage); + Navigator.pushNamed(context, Routers.massSendReceiverPage) + .then((value) { + if (value != null) { + value as Map; + _receiverList = value['lockUserList']; + + setState(() {}); + } + }); }), + 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(() {}); + }, + ), CommonItem( leftTitel: TranslationLoader.lanKeys!.lock!.tr, - rightTitle: TranslationLoader.lanKeys!.pleaseSelet!.tr, + rightTitle: _lockIdList.isEmpty + ? TranslationLoader.lanKeys!.pleaseSelet!.tr + : _lockIdList.length.toString(), isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendLockGroupPage); + Navigator.pushNamed(context, Routers.massSendLockGroupPage) + .then((value) { + //得到选中的锁ID列表 + if (value != null) { + value as Map; + _lockIdList = value['selectLockIdList']; + + setState(() {}); + } + }); }), Container(height: 10.h), ], @@ -106,12 +229,33 @@ class _MassSendElectronicKeyPageState extends State { 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), ], ); @@ -155,24 +299,27 @@ class _MassSendElectronicKeyPageState extends State { SubmitBtn( btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () { - // Navigator.pushNamed(context, Routers.nearbyLockPage); + MassKeyChecksRequest(); }), ], ); } CupertinoSwitch _switch() { - bool _isOn = false; return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: _isOn, + value: _isRemote, onChanged: (value) { setState(() { - _isOn = value; + _isRemote = !_isRemote; }); }, ); } + + String intToStr(int v) { + return (v < 10) ? "0$v" : "$v"; + } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart similarity index 100% rename from star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserListEntity.dart rename to star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart similarity index 97% rename from star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserList_page.dart rename to star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart index 7faa87ac..7220a588 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/lockUserList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart @@ -1,10 +1,8 @@ -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/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -162,7 +160,7 @@ class _LockUserListPageState extends State { Row( children: [ Text( - itemData.nickname!, + itemData.nickname ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ) @@ -173,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/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart new file mode 100644 index 00000000..b3240f85 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart @@ -0,0 +1,85 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; + +typedef _CallBack = void Function(int selectIndex, String selectLockId); + +class massSendLockGroupCell extends StatelessWidget { + final int currentIndex; + List lockListByGroup; + final _CallBack selectLockAction; + + massSendLockGroupCell(int index, + {Key? key, + required this.currentIndex, + required this.lockListByGroup, + required this.selectLockAction}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: lockListByGroup.length, + itemBuilder: (_, itemIndex) { + LockListItem itemData = lockListByGroup[itemIndex]; + return _itemBuilder(itemData, itemIndex); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ); + } + + Widget _itemBuilder(LockListItem itemData, int itemIndex) { + return GestureDetector( + child: Container( + height: 60.h, + color: Colors.white, + width: ScreenUtil().screenWidth, + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/mine/icon_mine_gatewaySignal_prompt.png', + width: 36.w, + height: 36.w, + ), + SizedBox( + width: 10.w, + ), + Text( + itemData.lockAlias!, + style: TextStyle( + fontSize: 20.sp, color: AppColors.darkGrayTextColor), + ), + Expanded( + child: SizedBox( + width: 20.w, + )), + Image.asset( + itemData.isChecked + ? "images/icon_round_selet.png" + : "images/icon_round_unSelet.png", + width: 30.w, + height: 30.w, + ), + SizedBox( + width: 30.w, + ) + ], + ), + ), + onTap: () { + selectLockAction(itemIndex, itemData.lockId.toString()); + }, + ); + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart index 0e94a4c2..872e1f91 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart @@ -2,7 +2,7 @@ class MassSendLockGroupListEntity { int? errorCode; String? description; String? errorMsg; - LockListData? data; + GroupListData? data; MassSendLockGroupListEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -11,7 +11,7 @@ class MassSendLockGroupListEntity { errorCode = json['errorCode']; description = json['description']; errorMsg = json['errorMsg']; - data = json['data'] != null ? LockListData.fromJson(json['data']) : null; + data = json['data'] != null ? GroupListData.fromJson(json['data']) : null; } Map toJson() { @@ -26,15 +26,49 @@ class MassSendLockGroupListEntity { } } -class LockListData { - List? lockList; +class GroupListData { + List? groupList; - LockListData({this.lockList}); + GroupListData({this.groupList}); - LockListData.fromJson(Map json) { + GroupListData.fromJson(Map json) { if (json['list'] != null) { - lockList = []; + groupList = []; json['list'].forEach((v) { + groupList!.add(GroupListItem.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + if (groupList != null) { + data['list'] = groupList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class GroupListItem { + int? lockNum; + int? keyGroupId; + String? keyGroupName; + List? lockList; + bool _isChecked = false; + bool get isChecked => _isChecked ?? false; + + set isChecked(bool value) => _isChecked = value; + + GroupListItem( + {this.lockNum, this.keyGroupId, this.keyGroupName, this.lockList}); + + GroupListItem.fromJson(Map json) { + lockNum = json['lockNum']; + keyGroupId = json['keyGroupId']; + keyGroupName = json['keyGroupName']; + if (json['lockList'] != null) { + lockList = []; + json['lockList'].forEach((v) { lockList!.add(LockListItem.fromJson(v)); }); } @@ -42,8 +76,11 @@ class LockListData { Map toJson() { final Map data = {}; + data['lockNum'] = lockNum; + data['keyGroupId'] = keyGroupId; + data['keyGroupName'] = keyGroupName; if (lockList != null) { - data['list'] = lockList!.map((v) => v.toJson()).toList(); + data['lockList'] = lockList!.map((v) => v.toJson()).toList(); } return data; } @@ -52,9 +89,12 @@ class LockListData { class LockListItem { int? lockId; String? lockAlias; - bool? isRefresh = false; + bool _isChecked = false; + bool get isChecked => _isChecked ?? false; - LockListItem({this.lockId, this.lockAlias, this.isRefresh}); + set isChecked(bool value) => _isChecked = value; + + LockListItem({this.lockId, this.lockAlias}); LockListItem.fromJson(Map json) { lockId = json['lockId']; 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 e1a8d322..b2cf104b 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,11 +2,12 @@ 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/massSendLockGroupCell.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/tools/submitBtn.dart'; import 'package:star_lock/translations/trans_lib.dart'; class MassSendLockGroupListPage extends StatefulWidget { @@ -19,9 +20,10 @@ class MassSendLockGroupListPage extends StatefulWidget { } class _MassSendLockGroupListPageState extends State { - List lockListByGroup = []; List lockGroupList = []; - List clickIndexList = []; + List selectGroupIdList = []; + List selectLockIdList = []; + int clickIndex = -1; @override void initState() { @@ -66,6 +68,15 @@ class _MassSendLockGroupListPageState extends State { height: 10.h, ), Expanded(child: _buildListView(context, lockGroupList)), + SubmitBtn( + btnName: '确定', + onClick: () { + print('得到lockid为$selectLockIdList '); + Map resultMap = {}; + resultMap['selectLockIdList'] = selectLockIdList; + Navigator.pop(context, resultMap); + }, + ), SizedBox( height: 40.h, ) @@ -74,12 +85,13 @@ class _MassSendLockGroupListPageState extends State { } //分组列表请求 - Future> mockNetworkDataRequest() async { - LockGroupListEntity entity = await ApiRepository.to.lockGroupList('1'); - List dataList = []; + Future> mockNetworkDataRequest() async { + MassSendLockGroupListEntity entity = + await ApiRepository.to.lockGroupList('1'); + List dataList = []; if (entity.errorCode!.codeIsSuccessful) { if (entity.data != null) { - dataList = entity.data!.itemList!; + dataList = entity.data!.groupList!; } } lockGroupList = dataList; @@ -87,27 +99,11 @@ class _MassSendLockGroupListPageState extends State { 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]; + GroupListItem itemData = itemList[index]; return _buildLockExpandedList(context, index, itemData); }, shrinkWrap: true, @@ -120,73 +116,26 @@ class _MassSendLockGroupListPageState extends State { } //设备多层级列表 - Widget _buildLockExpandedList(context, index, LockGroupItem itemData) { + Widget _buildLockExpandedList(context, index, GroupListItem itemData) { + List lockItemList = itemData.lockList ?? []; return ExpandedListTile( onTap: () { - listLockByGroup(itemData.keyGroupId.toString()); - clickIndexList.add(index); + selectGroupIdList.add(index); + clickIndex = index; }, - title: itemData.keyGroupName!, - imgName: '', typeImgList: const [], - child: ListView.separated( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - 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( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ), - ); - } - - //单个姓名行 - Widget _buildNameWidget(context, index, imageName, getName) { - return GestureDetector( - child: Container( - height: 60.h, - color: Colors.white, - width: ScreenUtil().screenWidth, - child: Row( - children: [ - SizedBox( - width: 30.w, - ), - Image.asset( - 'images/mine/icon_mine_gatewaySignal_prompt.png', - width: 36.w, - height: 36.w, - ), - SizedBox( - width: 10.w, - ), - Text( - getName, - style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor), - ), - SizedBox( - width: 30.w, - ) - ], - ), - ), - onTap: () { - // selectNameIndex = index; - // setState(() { - // if (selectNameIndex == index) { - // isNameSelect = !isNameSelect; - // } - // }); - }, + groupItem: itemData, + child: massSendLockGroupCell(index, + currentIndex: index, lockListByGroup: lockItemList, + selectLockAction: (selectIndex, selectLockId) { + LockListItem lockItem = lockItemList[selectIndex]; + setState(() { + lockItem.isChecked = !lockItem.isChecked; + if (lockItem.isChecked) { + selectLockIdList.add(lockItem.lockId); + } + }); + }), ); } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart new file mode 100644 index 00000000..f82551e1 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart @@ -0,0 +1,155 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get_utils/get_utils.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; +import 'package:star_lock/tools/commonItem.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +class MassSendReceiverCell extends StatelessWidget { + final int currentIndex; + LockUserData userData; + final VoidCallback clickDeleteUser; + + MassSendReceiverCell(int index, + {Key? key, + required this.currentIndex, + required this.userData, + required this.clickDeleteUser}) + : super(key: key); + + @override + Widget build(BuildContext context) { + TextEditingController emailOrPhoneController = TextEditingController(); + TextEditingController keyNameController = TextEditingController(); + + 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: () { + clickDeleteUser(); + // _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, + userData)), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.name!.tr, + rightTitle: userData.nickname ?? ' ', + isHaveRightWidget: true, + rightWidget: getTFWidget( + false, + TranslationLoader.lanKeys!.enterYourName!.tr, + 2, + userData)), + ], + )) + ], + ), + ); + } + + TextEditingController _receiverController(String getStr) { + TextEditingController controller = TextEditingController(text: getStr); + controller.addListener(() { + print(controller.text); + }); + + return controller; + } + + TextEditingController _nickNameController(String getStr) { + TextEditingController controller = TextEditingController(text: getStr); + controller.addListener(() { + print(controller.text); + }); + + return controller; + } + + // 接受者信息输入框 + Widget getTFWidget( + bool isHaveBtn, String tfStr, int lineIndex, LockUserData userData) { + return SizedBox( + height: 50.h, + width: 380.w, + child: Row( + children: [ + Expanded( + child: TextField( + controller: lineIndex == 1 + ? _receiverController(userData.userid ?? '') + : _nickNameController(userData.nickname ?? ''), + //输入框一行 + maxLines: 1, + autofocus: false, + textAlign: TextAlign.end, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + contentPadding: const EdgeInsets.only(top: -12.0, bottom: 0.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/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart index d13115a5..d581d3da 100644 --- 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 @@ -3,7 +3,8 @@ 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/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -38,7 +39,7 @@ class _MassSendReceiverPageState extends State { appBar: AppBar( backgroundColor: AppColors.mainColor, title: Text( - '接收者', + TranslationLoader.lanKeys!.receiver!.tr, style: TextStyle( color: Colors.white, fontSize: 28.sp, @@ -49,6 +50,19 @@ class _MassSendReceiverPageState extends State { icon: const Icon(Icons.arrow_back_ios, color: Colors.white), onPressed: () => Navigator.of(context).pop(), ), + actions: [ + TextButton( + child: Text( + TranslationLoader.lanKeys!.save!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: () { + Map resultMap = {}; + resultMap['lockUserList'] = _lockUserList; + Navigator.pop(context, resultMap); + }, + ), + ], ), body: Column( children: [ @@ -83,6 +97,9 @@ class _MassSendReceiverPageState extends State { child: ListView.separated( itemBuilder: (BuildContext context, int index) { LockUserData data = _lockUserList[index]; + emailOrPhoneController.text = data.userid ?? ''; + keyNameController.text = data.nickname ?? ''; + return _itemBuilder(index, data); }, itemCount: _lockUserList.length, @@ -149,110 +166,14 @@ class _MassSendReceiverPageState extends State { } 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() - ], - ), + return MassSendReceiverCell( + index, + currentIndex: index, + userData: userData, + clickDeleteUser: () { + _lockUserList.removeAt(index - 1); + setState(() {}); + }, ); } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart index fec53621..d43f16af 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get_utils/get_utils.dart'; +import 'package:star_lock/translations/trans_lib.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; @@ -30,7 +32,7 @@ class _SendEmailNotificationPageState extends State { body: Column( children: [ CommonItem( - leftTitel: "接收者", + leftTitel: TranslationLoader.lanKeys!.receiver!.tr, rightTitle: "786612630@qq.com", isHaveLine: true, ), 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 12914a66..d07aaea1 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 @@ -128,12 +128,21 @@ class _BasicInformationPageState extends State { leftTitel: TranslationLoader .lanKeys!.adminOpenLockPassword!.tr, rightTitle: "", - isHaveLine: false, + isHaveLine: true, isHaveDirection: true, action: () { Navigator.pushNamed(context, Routers.adminOpenLockPasswordPage); }), + CommonItem( + leftTitel: + TranslationLoader.lanKeys!.unlockQRCode!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.unlockQRCodePage); + }), ], ), ), 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 8221a481..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 @@ -1,8 +1,8 @@ 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/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'; @@ -38,10 +38,10 @@ class _LockSeletGroupingPageState extends State { barTitle: TranslationLoader.lanKeys!.selectGroup!.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: FutureBuilder>( + body: FutureBuilder>( future: mockNetworkDataRequest(), builder: (BuildContext context, - AsyncSnapshot> snapshot) { + AsyncSnapshot> snapshot) { //请求结束 if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { @@ -49,7 +49,7 @@ class _LockSeletGroupingPageState extends State { return const Text('请求失败'); } else { //请求成功 - final List itemData = snapshot.data!; + final List itemData = snapshot.data!; return Column( children: [ @@ -82,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: "", @@ -107,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: "创建成功"); @@ -117,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: "设置锁分组成功"); @@ -127,13 +127,14 @@ class _LockSeletGroupingPageState extends State { } //分组列表请求 - Future> mockNetworkDataRequest() async { - LockGroupListEntity entity = await ApiRepository.to.lockGroupList('1'); + Future> mockNetworkDataRequest() async { + MassSendLockGroupListEntity entity = + await ApiRepository.to.lockGroupList('1'); if (entity.errorCode!.codeIsSuccessful) { if (entity.data != null) { - return entity.data!.itemList!; + return entity.data!.groupList!; } else { - List dataList = []; + List dataList = []; return dataList; } } else { diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart index 10ad29cc..3f93cce5 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; @@ -21,73 +20,76 @@ import 'CheckingInInfoDataEntity.dart'; import 'lockSet_state.dart'; typedef BlockSetStateCallback = void Function(); -typedef BlockSetCheckInCallback = void Function(CheckingInInfoDataEntity checkingInInfoDataEntity); +typedef BlockSetCheckInCallback = void Function( + CheckingInInfoDataEntity checkingInInfoDataEntity); -class LockSetLogic extends BaseGetXController{ +class LockSetLogic extends BaseGetXController { final LockSetState state = LockSetState(); // 删除锁调用后台接口 - void deletLockInfoData() async{ + void deletLockInfoData() async { var entity = await ApiRepository.to.deletLockData( - lockId:state.getKeyInfosData.value.lockId.toString(), + lockId: state.getKeyInfosData.value.lockId.toString(), ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { Get.offAllNamed(Routers.starLockMain); } } // 开启考勤获取是否有公司 - void openCheckingInData(BlockSetCheckInCallback blockSetCheckInCallback) async{ + void openCheckingInData( + BlockSetCheckInCallback blockSetCheckInCallback) async { var entity = await ApiRepository.to.openCheckingInData( - lockId:state.getKeyInfosData.value.lockId.toString(), + lockId: state.getKeyInfosData.value.lockId.toString(), ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { blockSetCheckInCallback(entity); } } // 设置是否打开考勤 - void setLockSetGeneralSetting(String isOn) async{ + void setLockSetGeneralSetting(String isOn) async { var entity = await ApiRepository.to.setLockSetGeneralSettingData( lockId: state.getKeyInfosData.value.lockId.toString(), - changeType:"1", - isOn:isOn, - type:"1", + changeType: "1", + isOn: isOn, + type: "1", ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { eventBus.fire(RefreshLockListInfoDataEvent()); state.getKeyInfosData.value.isAttendance = int.parse(isOn); - eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + eventBus + .fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); Toast.show(msg: "设置成功"); - }else{ - - } + } else {} } // 设置是否打开开锁提醒 - void setLockPickingReminder() async{ + void setLockPickingReminder() async { var entity = await ApiRepository.to.setLockPickingReminderData( lockId: state.getKeyInfosData.value.lockId.toString(), - keyId:state.getKeyInfosData.value.keyId.toString(), - monitorFlag:state.isLockPickingReminder.value == 1 ? "1" : "2", // 1开启,2关闭 + keyId: state.getKeyInfosData.value.keyId.toString(), + monitorFlag: + state.isLockPickingReminder.value == 1 ? "1" : "2", // 1开启,2关闭 ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { eventBus.fire(RefreshLockListInfoDataEvent()); - state.getKeyInfosData.value.monitorFlag = state.isLockPickingReminder.value; - eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + state.getKeyInfosData.value.monitorFlag = + state.isLockPickingReminder.value; + eventBus + .fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); Toast.show(msg: "设置成功"); - }else{ - - } + } else {} } // 下级界面修改成功后传递数据 StreamSubscription? _passCurrentLockInformationEvent; void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _passCurrentLockInformationEvent = eventBus.on().listen((event) { + _passCurrentLockInformationEvent = + eventBus.on().listen((event) { state.getKeyInfosData.value = event.keyInfo; blockSetStateCallback(); }); @@ -96,8 +98,9 @@ class LockSetLogic extends BaseGetXController{ // 监听蓝牙协议返回结果 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { - if(reply is DeletUserReply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) async { + if (reply is DeletUserReply) { var tokenData = reply.data.sublist(2, 6); var saveStrList = changeIntListToStringList(tokenData); print("openDoorToken:$tokenData"); @@ -105,45 +108,46 @@ class LockSetLogic extends BaseGetXController{ int status = reply.data[6]; print("status:$status"); - switch(status){ + switch (status) { case 0x00: - //成功 + //成功 print("${reply.commandType}解析成功"); deletLockInfoData(); break; case 0x06: - //无权限 + //无权限 print("${reply.commandType}需要鉴权"); var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + List getPrivateKeyList = + changeStringListToIntList(privateKey!); var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); IoSenderManage.deletUser( - lockID:state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName, - authUserID:await Storage.getUid(), - keyID:"1", - delUserID:await Storage.getUid(), - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: tokenData - ); + lockID: + state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName, + authUserID: await Storage.getUid(), + keyID: "1", + delUserID: await Storage.getUid(), + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: tokenData); break; case 0x07: - //无权限 + //无权限 print("${reply.commandType}用户无权限"); break; case 0x09: - // 权限校验错误 + // 权限校验错误 print("${reply.commandType}权限校验错误"); break; default: - //失败 + //失败 print("${reply.commandType}失败"); break; @@ -154,8 +158,10 @@ class LockSetLogic extends BaseGetXController{ // 删除用户蓝牙协议 Future deletUserAction() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { - if (connectionState == DeviceConnectionState.connected){ + BlueManage().judgeReconnect( + BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, + (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -165,17 +171,17 @@ class LockSetLogic extends BaseGetXController{ var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); print("openDoorTokenPubToken:$getTokenList"); - print("state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName:${state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName}"); + print( + "state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName:${state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName}"); IoSenderManage.deletUser( - lockID:state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName, - authUserID:"100001", - keyID:"1", - delUserID:"100001", - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList - ); + lockID: state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName, + authUserID: "100001", + keyID: "1", + delUserID: "100001", + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList); } }); } @@ -194,8 +200,6 @@ class LockSetLogic extends BaseGetXController{ // TODO: implement onInit super.onInit(); print("onInit()"); - - } @override @@ -204,5 +208,4 @@ class LockSetLogic extends BaseGetXController{ _replySubscription.cancel(); _passCurrentLockInformationEvent!.cancel(); } - -} \ No newline at end of file +} 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 06668bda..caf8033a 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -67,57 +67,43 @@ class _LockSetPageState extends State with RouteAware { height: 10.h, ), CommonItem( - leftTitel: - TranslationLoader.lanKeys!.wirelessKeyboard!.tr, + leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr, rightTitle: "", isHaveLine: true, isHaveDirection: true, action: () { - // Get.toNamed(Routers.wirelessKeyboardPage); - Toast.show(msg: "功能暂未开放"); + Get.toNamed(Routers.doorMagneticPage); + // Toast.show(msg: "功能暂未开放"); }), CommonItem( - leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr, + leftTitel: + TranslationLoader.lanKeys!.wirelessKeyboard!.tr, rightTitle: "", isHaveLine: false, isHaveDirection: true, action: () { - // Get.toNamed(Routers.doorMagneticPage); - Toast.show(msg: "功能暂未开放"); + Get.toNamed(Routers.wirelessKeyboardPage); + // Toast.show(msg: "功能暂未开放"); }), SizedBox( height: 10.h, ), - Obx(()=> CommonItem( - leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr, - rightTitle: state.getKeyInfosData.value.remoteEnable == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.remoteUnlockingPage, arguments: state.getKeyInfosData.value); - })), Obx(() => CommonItem( leftTitel: - TranslationLoader.lanKeys!.automaticBlocking!.tr, - rightTitle: state.getKeyInfosData.value.autoLockTime! > -1 ? "${state.getKeyInfosData.value.autoLockTime!.toString()}s" : TranslationLoader.lanKeys!.closed!.tr, + TranslationLoader.lanKeys!.automaticBlocking!.tr, + rightTitle: state.getKeyInfosData.value.autoLockTime! > -1 + ? "${state.getKeyInfosData.value.autoLockTime!.toString()}s" + : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.automaticBlockingPage, arguments: state.getKeyInfosData.value); + Get.toNamed(Routers.automaticBlockingPage, + arguments: state.getKeyInfosData.value); })), - Obx(() => CommonItem( - leftTitel: - TranslationLoader.lanKeys!.normallyOpenMode!.tr, - rightTitle: state.getKeyInfosData.value.passageMode == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.normallyOpenModePage, arguments: state.getKeyInfosData.value); - }),), Obx(() { var titleStr = ""; - if(state.getKeyInfosData.value.lockSound == 1){ - switch(state.getKeyInfosData.value.volume){ + if (state.getKeyInfosData.value.lockSound == 1) { + switch (state.getKeyInfosData.value.volume) { case 1: titleStr = TranslationLoader.lanKeys!.low!.tr; break; @@ -134,7 +120,7 @@ class _LockSetPageState extends State with RouteAware { titleStr = TranslationLoader.lanKeys!.higher!.tr; break; } - }else{ + } else { titleStr = TranslationLoader.lanKeys!.closed!.tr; } return CommonItem( @@ -143,51 +129,115 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.lockSoundSetPage, arguments: state.getKeyInfosData.value); + Get.toNamed(Routers.lockSoundSetPage, + arguments: state.getKeyInfosData.value); }); }), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.burglarAlarm!.tr, - rightTitle: state.getKeyInfosData.value.tamperAlert == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr, + rightTitle: state.getKeyInfosData.value.tamperAlert == 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.burglarAlarmPage, arguments: state.getKeyInfosData.value); + Get.toNamed(Routers.burglarAlarmPage, + arguments: state.getKeyInfosData.value); + })), + SizedBox( + height: 10.h, + ), + Obx( + () => CommonItem( + leftTitel: + TranslationLoader.lanKeys!.normallyOpenMode!.tr, + rightTitle: state.getKeyInfosData.value.passageMode == 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.normallyOpenModePage, + arguments: state.getKeyInfosData.value); + }), + ), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr, + rightTitle: state.getKeyInfosData.value.remoteEnable == 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.remoteUnlockingPage, + arguments: state.getKeyInfosData.value); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.resetButton!.tr, - rightTitle: state.getKeyInfosData.value.resetButton == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr, + rightTitle: state.getKeyInfosData.value.resetButton == 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.resetButtonPage, arguments: state.getKeyInfosData.value); + Get.toNamed(Routers.resetButtonPage, + arguments: state.getKeyInfosData.value); })), + SizedBox( + height: 10.h, + ), + Obx(() { + var title = ""; + if (state.getKeyInfosData.value.roomStatus == 1) { + title = TranslationLoader.lanKeys!.checkedIn!.tr; + } else if (state.getKeyInfosData.value.roomStatus == 2) { + title = TranslationLoader.lanKeys!.leisure!.tr; + } + return CommonItem( + leftTitel: + TranslationLoader.lanKeys!.markedHouseState!.tr, + rightTitle: title, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.markedHouseStatePage, + arguments: state.getKeyInfosData.value); + }); + }), CommonItem( - leftTitel: TranslationLoader.lanKeys!.unlockQRCode!.tr, + leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr, rightTitle: "", isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.unlockQRCodePage); - }), + isHaveRightWidget: true, + rightWidget: + SizedBox(width: 60.w, child: _openCheckInSwitch())), CommonItem( - leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr, + leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, rightTitle: "", isHaveLine: false, + isHaveRightWidget: true, + rightWidget: + SizedBox(width: 60.w, child: _lockRemindSwitch())), + SizedBox( + height: 10.h, + ), + CommonItem( + leftTitel: TranslationLoader + .lanKeys!.wifiDistributionNetwork!.tr, + rightTitle: "", + isHaveLine: true, isHaveDirection: true, action: () { Get.toNamed(Routers.configuringWifiPage); }), - SizedBox( - height: 10.h, - ), CommonItem( leftTitel: TranslationLoader.lanKeys!.lockTime!.tr, rightTitle: "", isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.lockTimePage, arguments: state.getKeyInfosData.value); + Get.toNamed(Routers.lockTimePage, + arguments: state.getKeyInfosData.value); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.diagnose!.tr, @@ -195,7 +245,8 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.diagnosePage, arguments: state.getKeyInfosData.value); + Get.toNamed(Routers.diagnosePage, + arguments: state.getKeyInfosData.value); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.uploadData!.tr, @@ -222,57 +273,6 @@ class _LockSetPageState extends State with RouteAware { action: () { Get.toNamed(Routers.lockEscalationPage); }), - SizedBox( - height: 10.h, - ), - CommonItem( - leftTitel: "Amazon Alexa", - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Toast.show(msg: "功能暂未开放"); - }), - CommonItem( - leftTitel: "Google Home", - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Toast.show(msg: "功能暂未开放"); - }), - SizedBox( - height: 10.h, - ), - Obx((){ - var title = ""; - if(state.getKeyInfosData.value.roomStatus == 1){ - title = TranslationLoader.lanKeys!.checkedIn!.tr; - }else if(state.getKeyInfosData.value.roomStatus == 2){ - title = TranslationLoader.lanKeys!.leisure!.tr; - } - return CommonItem( - leftTitel: - TranslationLoader.lanKeys!.markedHouseState!.tr, - rightTitle: title, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.markedHouseStatePage, arguments: state.getKeyInfosData.value); - }); - }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr, - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: SizedBox(width: 60.w, child: _openCheckInSwitch())), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, - rightTitle: "", - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: SizedBox(width: 60.w, child: _lockRemindSwitch())), SizedBox( height: 30.h, ), @@ -302,16 +302,16 @@ class _LockSetPageState extends State with RouteAware { onChanged: (value) { setState(() { int isOnStr; - if(value == true){ + if (value == true) { isOnStr = 1; - }else{ + } else { isOnStr = 2; } - logic.openCheckingInData((checkingInInfoDataEntity){ - if(checkingInInfoDataEntity.data!.companyId == 0){ + logic.openCheckingInData((checkingInInfoDataEntity) { + if (checkingInInfoDataEntity.data!.companyId == 0) { showCupertinoAlertDialog(context); - }else{ + } else { logic.setLockSetGeneralSetting(isOnStr.toString()); } }); @@ -328,7 +328,8 @@ class _LockSetPageState extends State with RouteAware { value: state.isLockPickingReminder.value == 1 ? true : false, onChanged: (value) { setState(() { - state.isLockPickingReminder.value = state.isLockPickingReminder.value == 1 ? 2 : 1; + state.isLockPickingReminder.value = + state.isLockPickingReminder.value == 1 ? 2 : 1; logic.setLockPickingReminder(); }); }, @@ -336,8 +337,8 @@ class _LockSetPageState extends State with RouteAware { } void showCupertinoAlertDialog( - BuildContext context, - ) { + BuildContext context, + ) { showDialog( context: context, builder: (BuildContext context) { @@ -347,7 +348,8 @@ class _LockSetPageState extends State with RouteAware { sureClick: () { // Navigator.pop(context); - Get.toNamed(Routers.checkInCreatCompanyPage, arguments: state.getKeyInfosData.value); + Get.toNamed(Routers.checkInCreatCompanyPage, + arguments: state.getKeyInfosData.value); }, cancelClick: () { Navigator.pop(context); @@ -361,6 +363,7 @@ class _LockSetPageState extends State with RouteAware { void didChangeDependencies() { // TODO: implement didChangeDependencies super.didChangeDependencies(); + /// 路由订阅 AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); } @@ -396,5 +399,4 @@ class _LockSetPageState extends State with RouteAware { void didPushNext() { print("lockSet===didPushNext"); } - } diff --git a/star_lock/lib/main/lockDetail/lcokSet/unlockQRCode/unlockQRCode_page.dart b/star_lock/lib/main/lockDetail/lcokSet/unlockQRCode/unlockQRCode_page.dart index 70c7e107..c089ce5a 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/unlockQRCode/unlockQRCode_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/unlockQRCode/unlockQRCode_page.dart @@ -21,7 +21,7 @@ class _UnlockQRCodePageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.burglarAlarm!.tr, + barTitle: TranslationLoader.lanKeys!.unlockQRCode!.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: Column( diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 50d342d9..ddef9ed3 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -30,7 +30,7 @@ class LockDetailPage extends StatefulWidget { State createState() => _LockDetailPageState(); } -class _LockDetailPageState extends State with RouteAware{ +class _LockDetailPageState extends State with RouteAware { final logic = Get.put(LockDetailLogic()); final state = Get.find().state; @@ -57,7 +57,8 @@ class _LockDetailPageState extends State with RouteAware{ Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); // signKey - List signKeyData = state.keyInfos.value.bluetooth!.signKey!.cast(); + List signKeyData = + state.keyInfos.value.bluetooth!.signKey!.cast(); var saveSignKeyList = changeIntListToStringList(signKeyData); Storage.setStringList(saveBlueSignKey, saveSignKeyList); // print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList"); @@ -130,7 +131,8 @@ class _LockDetailPageState extends State with RouteAware{ width: 268.w, height: 268.w), )), Visibility( - visible: state.keyInfos.value.remoteEnable == 1 ? true: false, + visible: + state.keyInfos.value.remoteEnable == 1 ? true : false, child: Align( alignment: const Alignment(0.6, 1), child: Image.asset( @@ -175,31 +177,32 @@ class _LockDetailPageState extends State with RouteAware{ // color: Colors.blue, child: SizedBox( child: GridView.count( - crossAxisCount: 4, - // childAspectRatio: 3, - crossAxisSpacing: 20.w, - mainAxisSpacing: 0.h, - physics: const NeverScrollableScrollPhysics(), - children: getShowWidget() - ), + crossAxisCount: 4, + // childAspectRatio: 3, + crossAxisSpacing: 20.w, + mainAxisSpacing: 0.h, + physics: const NeverScrollableScrollPhysics(), + children: getShowWidget()), ), ); } - List getShowWidget(){ + List getShowWidget() { var showWidgetArr = []; // 考勤 - if(state.keyInfos.value.isAttendance == 1){ + if (state.keyInfos.value.isAttendance == 1) { showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png', TranslationLoader.lanKeys!.checkingIn!.tr, () { - Get.toNamed(Routers.checkingInListPage, arguments: state.keyInfos.value); - })); + Get.toNamed(Routers.checkingInListPage, + arguments: state.keyInfos.value); + })); } var defaultWidgetArr = [ // 电子钥匙 - bottomItem('images/main/icon_main_electronicKey.png', TranslationLoader.lanKeys!.electronicKey!.tr, () { + bottomItem('images/main/icon_main_electronicKey.png', + TranslationLoader.lanKeys!.electronicKey!.tr, () { Get.toNamed(Routers.electronicKeyListPage, arguments: { "lockMainEntity": widget.lockMainEntity, "keyInfo": widget.keyInfo @@ -207,13 +210,13 @@ class _LockDetailPageState extends State with RouteAware{ }), // 密码 - bottomItem('images/main/icon_main_password.png', TranslationLoader.lanKeys!.password!.tr, () { - Get.toNamed(Routers.passwordKeyListPage, - arguments: { - "lockMainEntity": widget.lockMainEntity, - "keyInfo": widget.keyInfo - }); - }), + bottomItem('images/main/icon_main_password.png', + TranslationLoader.lanKeys!.password!.tr, () { + Get.toNamed(Routers.passwordKeyListPage, arguments: { + "lockMainEntity": widget.lockMainEntity, + "keyInfo": widget.keyInfo + }); + }), // ic卡 bottomItem('images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, () { @@ -237,42 +240,49 @@ class _LockDetailPageState extends State with RouteAware{ "lockId": widget.keyInfo.lockId, "fromType": 2 }); - }), + ]; showWidgetArr.addAll(defaultWidgetArr); //可视对讲门锁新增->人脸 - showWidgetArr.add(bottomItem('images/main/icon_main_fingerprint.png', '人脸', () { - // Navigator.pushNamed(context, Routers.otherTypeKeyListPage, - // arguments: 1); - }),); + showWidgetArr.add( + bottomItem('images/main/icon_face.png', '人脸', () { + // Navigator.pushNamed(context, Routers.otherTypeKeyListPage, + // arguments: 1); + }), + ); //可视对讲门锁新增->监控 - showWidgetArr.add(bottomItem('images/main/icon_main_fingerprint.png', '监控', () { - // Navigator.pushNamed(context, Routers.otherTypeKeyListPage, - // arguments: 1); - }),); + showWidgetArr.add( + bottomItem('images/main/icon_catEyes.png', '监控', () { + // Navigator.pushNamed(context, Routers.otherTypeKeyListPage, + // arguments: 1); + }), + ); var endWiddget = [ // 授权管理员 - bottomItem('images/main/icon_main_authorizedAdmin.png', TranslationLoader.lanKeys!.authorizedAdmin!.tr, () { - Get.toNamed(Routers.authorizedAdminListPage, arguments: { - "lockMainEntity": widget.lockMainEntity, - "keyInfo": widget.keyInfo - }); - }), + bottomItem('images/main/icon_main_authorizedAdmin.png', + TranslationLoader.lanKeys!.authorizedAdmin!.tr, () { + Get.toNamed(Routers.authorizedAdminListPage, arguments: { + "lockMainEntity": widget.lockMainEntity, + "keyInfo": widget.keyInfo + }); + }), // 操作记录 - bottomItem('images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, () { - Get.toNamed(Routers.lockOperatingRecordPage, - arguments: { - "lockMainEntity": widget.lockMainEntity, - "keyInfo": widget.keyInfo - }); - }), + bottomItem('images/main/icon_main_operatingRecord.png', + TranslationLoader.lanKeys!.operatingRecord!.tr, () { + Get.toNamed(Routers.lockOperatingRecordPage, arguments: { + "lockMainEntity": widget.lockMainEntity, + "keyInfo": widget.keyInfo + }); + }), // 设置 - bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () { - Get.toNamed(Routers.lockSetPage, arguments: widget.keyInfo); - }), + bottomItem( + 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, + () { + Get.toNamed(Routers.lockSetPage, arguments: widget.keyInfo); + }), ]; showWidgetArr.addAll(endWiddget); return showWidgetArr; @@ -310,6 +320,7 @@ class _LockDetailPageState extends State with RouteAware{ void didChangeDependencies() { // TODO: implement didChangeDependencies super.didChangeDependencies(); + /// 路由订阅 AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); } @@ -324,26 +335,17 @@ class _LockDetailPageState extends State with RouteAware{ /// @override - void didPush() { - - } + void didPush() {} /// Called when the current route has been popped off. @override - void didPop() { - - } + void didPop() {} /// Called when the current route has been popped off. @override - void didPopNext() { - - } + void didPopNext() {} /// Called when the current route has been popped off. @override - void didPushNext() { - - } - + void didPushNext() {} } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart index f5989215..905c0cb5 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart @@ -86,8 +86,8 @@ class _PasswordKeyManageTabbarPageState Tab _tab(ItemView item) { return Tab( // text: item.title, - child: Container( - width: 1.sw / 8, + child: SizedBox( + width: item.title.length > 2 ? 1.sw / 8 : 1.sw / 12, // margin: EdgeInsets.all(10.w), // color: Colors.red, child: Text( diff --git a/star_lock/lib/mine/addLock/seletLockType/seletLockType_page.dart b/star_lock/lib/mine/addLock/seletLockType/seletLockType_page.dart index 1edaa1d1..9ebeef55 100644 --- a/star_lock/lib/mine/addLock/seletLockType/seletLockType_page.dart +++ b/star_lock/lib/mine/addLock/seletLockType/seletLockType_page.dart @@ -41,7 +41,7 @@ class _SeletLockTypePageState extends State with BaseWidget { TranslationLoader.lanKeys!.doorLock!.tr, () { Navigator.pushNamed(context, Routers.addLockPage); }), - lockTypeItem('images/lockType/lockType_doorLock.png', + lockTypeItem('images/lockType/lockType_NFCLock.png', TranslationLoader.lanKeys!.NFCPassiveLock!.tr, () { Navigator.pushNamed(context, Routers.addLockPage); }), @@ -57,8 +57,7 @@ class _SeletLockTypePageState extends State with BaseWidget { TranslationLoader.lanKeys!.parkingLock!.tr, () { Navigator.pushNamed(context, Routers.addLockPage); }), - lockTypeItem( - 'images/lockType/lockType_intelligentLockCore.png', + lockTypeItem('images/lockType/lockType_entranceGuardLock.png', TranslationLoader.lanKeys!.itelligentAccessControl!.tr, () { Navigator.pushNamed(context, Routers.addLockPage); @@ -68,7 +67,7 @@ class _SeletLockTypePageState extends State with BaseWidget { // TranslationLoader.lanKeys!.bicycleLock!.tr, () { // Navigator.pushNamed(context, Routers.addLockPage); // }), - lockTypeItem('images/lockType/lockType_remoteControl.png', + lockTypeItem('images/lockType/lockType_gatewayLock.png', TranslationLoader.lanKeys!.gateway!.tr, () { Navigator.pushNamed(context, Routers.gatewayListPage); }), @@ -138,8 +137,8 @@ class _SeletLockTypePageState extends State with BaseWidget { SizedBox(width: 30.w), Image.asset( lockTypeIcon, - width: 32.w, - height: 48.w, + width: 48.w, + height: 60.w, ), SizedBox(width: 20.w), Expanded( diff --git a/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_page.dart b/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_page.dart index 30a781d5..0b3fa821 100644 --- a/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_page.dart +++ b/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_page.dart @@ -17,32 +17,62 @@ class MineMultiLanguagePage extends StatefulWidget { } class _MineMultiLanguagePageState extends State { - final logic = Get.put(MineMultiLanguageLogic()); final state = Get.find().state; - @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar(barTitle: TranslationLoader.lanKeys!.multilingual!.tr, haveBack:true, backgroundColor: AppColors.mainColor), - body: Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: _children(), - ) - ); + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.multilingual!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: _children(), + )); } - List _children(){ + List _children() { List l = []; - for(int i = 0; i < state.languages.length; i++){ + l.add( + CommonItem( + leftTitel: '跟随系统', + rightTitle: "", + allHeight: 90.h, + isHaveLine: true, + isHaveDirection: false, + isHaveRightWidget: true, + rightWidget: Container(), + action: () { + // logic.changeLanguage(e); + }), + ); + for (int i = 0; i < state.languages.length; i++) { var e = state.languages[i]; var lanType = ExtensionLanguageType.fromLanguageCode(e.languageCode); - l.add(CommonItem(leftTitel:lanType.lanTitle, rightTitle:"", allHeight: 90.h, isHaveLine: true, isHaveDirection:false, isHaveRightWidget: true, rightWidget: Obx(() => state.currentLanguageType.value == lanType ? Image(image: const AssetImage("images/icon_item_checked.png"),width:30.w,height:30.w, fit: BoxFit.contain,): Container()), action: (){ - logic.changeLanguage(e); - }),); + l.add( + CommonItem( + leftTitel: lanType.lanTitle, + rightTitle: "", + allHeight: 90.h, + isHaveLine: true, + isHaveDirection: false, + isHaveRightWidget: true, + rightWidget: Obx(() => state.currentLanguageType.value == lanType + ? Image( + image: const AssetImage("images/icon_item_checked.png"), + width: 30.w, + height: 30.w, + fit: BoxFit.contain, + ) + : Container()), + action: () { + logic.changeLanguage(e); + }), + ); } return l; } diff --git a/star_lock/lib/mine/mineSet/authorityManagement/authorityManagement_page.dart b/star_lock/lib/mine/mineSet/authorityManagement/authorityManagement_page.dart index 62403282..bd4896dd 100644 --- a/star_lock/lib/mine/mineSet/authorityManagement/authorityManagement_page.dart +++ b/star_lock/lib/mine/mineSet/authorityManagement/authorityManagement_page.dart @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get_utils/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/massSendLockGroupListEntity.dart'; import 'package:star_lock/tools/ExpandedListView.dart'; import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -167,9 +168,10 @@ class _AuthorityManagementPageState extends State Widget _buildDeviceExpandedList(context, index, deviceName) { return ExpandedListTile( onTap: () => print("onTap."), - title: deviceName, - imgName: 'images/icon_lock.png', + // title: deviceName, + // imgName: 'images/icon_lock.png', typeImgList: const [], + groupItem: GroupListItem(), child: ListView.separated( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, @@ -205,9 +207,10 @@ class _AuthorityManagementPageState extends State Widget _buildNameExpandedList(context, index, deviceName) { return ExpandedListTile( onTap: () => print("onTap."), - title: deviceName, - imgName: 'images/controls_user.png', + // title: deviceName, + // imgName: 'images/controls_user.png', typeImgList: const ['images/icon_password.png', 'images/icon_card.png'], + groupItem: GroupListItem(), child: ListView.separated( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart new file mode 100644 index 00000000..cc6c77a4 --- /dev/null +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart @@ -0,0 +1,272 @@ +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/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/jh_pop_menus.dart'; +import 'package:star_lock/tools/toast.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdminListEntity.dart'; + +import '../../../../../appRouters.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/commonItem.dart'; +import '../../../../../tools/showTFView.dart'; +import '../../../../../tools/submitBtn.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; + +class AdministratorDetailsPage extends StatefulWidget { + const AdministratorDetailsPage({Key? key}) : super(key: key); + + @override + State createState() => + _AdministratorDetailsPageState(); +} + +class _AdministratorDetailsPageState extends State { + final TextEditingController _changeNameController = TextEditingController(); + AuthorizedAdminListItem itemData = AuthorizedAdminListItem(); + + @override + Widget build(BuildContext context) { + dynamic obj = ModalRoute.of(context)?.settings.arguments; + if (obj != null && (obj["itemData"] != null)) { + itemData = obj["itemData"]; + } + + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: '管理员详情', + haveBack: true, + actionsList: [ + IconButton( + icon: Image.asset( + 'images/icon_bar_more.png', + height: 30.h, + width: 10.w, + ), + onPressed: () { + JhPopMenus.showLinePop(context, + clickCallback: (index, selText) { + print('选中index: $index'); + print('选中text: $selText'); + }, listData: [ + {'text': '冻结'}, + {'text': '取消授权'} + ]); + }, + ), + ], + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.name!.tr, + rightTitle: _changeNameController.text.isNotEmpty + ? _changeNameController.text + : itemData.name, + isHaveDirection: true, + isHaveLine: true, + action: () { + showCupertinoAlertDialog(context); + }), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, + allHeight: 90.h, + rightTitle: getUseDateStr(itemData), + isHaveDirection: true, + action: () { + Navigator.pushNamed( + context, Routers.electronicKeyDetailChangeDate, + arguments: {"itemData": itemData}); + }), + Container(height: 10.h), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.lock!.tr, + rightTitle: itemData.lockNum.toString(), + isHaveDirection: true, + action: () { + //锁列表 + }), + Container(height: 10.h), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr, + rightTitle: "", + isHaveRightWidget: true, + rightWidget: SizedBox( + width: 60.w, + child: _switch(itemData.isRemoteUnlock == 1 ? true : false)), + action: () {}), + Container(height: 40.h), + SubmitBtn( + btnName: TranslationLoader.lanKeys!.delete!.tr, + borderRadius: 20.w, + isDelete: true, + margin: EdgeInsets.only( + left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), + padding: EdgeInsets.only(top: 25.w, bottom: 25.w), + onClick: () { + deleteAdministratorRequest(); + }), + ], + ), + ); + } + + //使用期限 + String getUseDateStr(AuthorizedAdminListItem indexEntity) { + String useDateStr = ''; + if (indexEntity.keyType == 1) { + //限期 + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}'; + } else if (indexEntity.keyType == 2) { + //永久 + DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久'; + } else if (indexEntity.keyType == 3) { + //单次 + DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次'; + } else if (indexEntity.keyType == 4) { + //循环 + useDateStr = '循环'; + } + + return useDateStr; + } + + Widget commonItem(String leftTitle, String rightTitle, + {bool isHaveDirection = false, + bool isHaveLine = false, + bool isHaveRightWidget = false, + Widget? rightWidget, + Function()? action}) { + return GestureDetector( + onTap: action, + child: Column( + // mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + // height: 80.h, + color: Colors.white, + padding: EdgeInsets.only( + left: 20.w, right: 10.w, top: 20.w, bottom: 20.w), + child: Row( + children: [ + SizedBox(width: 20.w), + Text( + leftTitle, + style: + TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500), + ), + SizedBox(width: 20.w), + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + isHaveRightWidget + ? rightWidget! + : Text( + rightTitle, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 28.sp, fontWeight: FontWeight.w500), + ) + ], + ), + ), + SizedBox(width: 5.w), + isHaveDirection + ? Image.asset( + 'images/icon_right.png', + width: 50.w, + height: 50.w, + ) + : SizedBox(width: 10.w), + // SizedBox(width:10.w), + ], + ), + ), + isHaveLine + ? Container( + height: 0.5.h, + color: Colors.grey, + ) + : Container() + ], + ), + ); + } + + CupertinoSwitch _switch(isOn) { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: isOn, + onChanged: (value) { + setState(() { + isOn = value; + }); + }, + ); + } + + //更新管理员信息请求 + Future updateAdministratorRequest() async { + ElectronicKeyListEntity entity = await ApiRepository.to.updateAdministrator( + itemData.uid.toString(), _changeNameController.text, '', '', ''); + if (entity.errorCode!.codeIsSuccessful) { + print("修改管理员信息成功啦啦啦啦啦"); + Toast.show(msg: "修改成功"); + setState(() { + Navigator.pop(context); + }); + } + } + + //删除授权管理员请求 + Future deleteAdministratorRequest() async { + ElectronicKeyListEntity entity = + await ApiRepository.to.deleteAdministrator(itemData.uid.toString(), ''); + if (entity.errorCode!.codeIsSuccessful) { + print("删除电子钥匙成功"); + Toast.show(msg: "删除成功"); + setState(() { + Navigator.pop(context); + }); + } + } + + void showCupertinoAlertDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return ShowTFView( + title: + "${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}", + tipTitle: "请输入", + controller: _changeNameController, + sureClick: () { + //发送编辑钥匙名称请求 + if (_changeNameController.text.isNotEmpty) { + updateAdministratorRequest(); + } + }, + cancelClick: () { + Navigator.pop(context); + }, + ); + }, + ); + } +} diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdminListEntity.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdminListEntity.dart new file mode 100644 index 00000000..47a035e5 --- /dev/null +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdminListEntity.dart @@ -0,0 +1,122 @@ +class AuthorizedAdminListEntity { + int? errorCode; + String? description; + String? errorMsg; + AuthorizedAdminListData? data; + + AuthorizedAdminListEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + AuthorizedAdminListEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null + ? AuthorizedAdminListData.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 AuthorizedAdminListData { + List? itemList; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + AuthorizedAdminListData( + {this.itemList, this.pageNo, this.pageSize, this.pages, this.total}); + + AuthorizedAdminListData.fromJson(Map json) { + if (json['list'] != null) { + itemList = []; + json['list'].forEach((v) { + itemList!.add(AuthorizedAdminListItem.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (itemList != null) { + data['list'] = itemList!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class AuthorizedAdminListItem { + int? uid; + int? keyStatus; + int? lockNum; + int? endDate; + int? startDate; + String? name; + String? headUrl; + String? userid; + int? keyType; + int? date; + int? isRemoteUnlock; + + AuthorizedAdminListItem( + {this.uid, + this.keyStatus, + this.lockNum, + this.endDate, + this.startDate, + this.name, + this.headUrl, + this.userid, + this.keyType, + this.date, + this.isRemoteUnlock}); + + AuthorizedAdminListItem.fromJson(Map json) { + uid = json['uid']; + keyStatus = json['keyStatus']; + lockNum = json['lockNum']; + endDate = json['endDate']; + startDate = json['startDate']; + name = json['name']; + headUrl = json['headUrl']; + userid = json['userid']; + keyType = json['keyType']; + date = json['date']; + isRemoteUnlock = json['isRemoteUnlock']; + } + + Map toJson() { + final Map data = {}; + data['uid'] = uid; + data['keyStatus'] = keyStatus; + data['lockNum'] = lockNum; + data['endDate'] = endDate; + data['startDate'] = startDate; + data['name'] = name; + data['headUrl'] = headUrl; + data['userid'] = userid; + data['keyType'] = keyType; + data['date'] = date; + data['isRemoteUnlock'] = isRemoteUnlock; + return data; + } +} diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministratorList_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministratorList_page.dart index 20be0f8a..ea44142d 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministratorList_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministratorList_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/mine/mineSet/authorizedAdministrator/authorizedAdminListEntity.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,13 @@ class AuthorizedAdministratorListPage extends StatefulWidget { class _AuthorizedAdministratorListPageState extends State { + @override + void initState() { + super.initState(); + + mockNetworkDataRequest(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -40,15 +50,49 @@ class _AuthorizedAdministratorListPageState ), ], ), - body: Column( - children: [ - _searchWidget(), - Expanded(child: _buildMainUI()), - ], - ), + body: FutureBuilder>( + future: mockNetworkDataRequest(), + builder: (BuildContext context, + AsyncSnapshot> snapshot) { + //请求结束 + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + //请求失败 + return const Text('请求失败'); + } else { + //请求成功 + final List itemList = snapshot.data!; + + return Column( + children: [ + _searchWidget(), + Expanded(child: _buildMainUI(itemList)), + ], + ); + } + } else { + //请求未结束 显示loading + return Container(); + } + }), ); } + //请求授权管理员列表 + Future> mockNetworkDataRequest() async { + AuthorizedAdminListEntity entity = + await ApiRepository.to.authorizedAdminList('1', '20'); + if (entity.errorCode!.codeIsSuccessful) { + print("授权管理员列表成功:${entity.data?.itemList}"); + } + if (entity.data != null) { + return entity.data!.itemList!; + } else { + List dataList = []; + return dataList; + } + } + Widget _searchWidget() { return Container( height: 60.h, @@ -84,22 +128,21 @@ class _AuthorizedAdministratorListPageState ); } - Widget _buildMainUI() { + Widget _buildMainUI(List itemList) { return ListView.builder( - itemCount: 5, + itemCount: itemList.length, itemBuilder: (c, index) { - return _electronicKeyItem('images/controls_user.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { - // Navigator.pushNamed(context, Routers.authorizedAdminDetailPage); - Navigator.pushNamed(context, Routers.electronicKeyDetailPage); - }); + AuthorizedAdminListItem itemData = itemList[index]; + return _electronicKeyItem(itemData); }); } - Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { + Widget _electronicKeyItem(AuthorizedAdminListItem itemData) { return GestureDetector( - onTap: action, + onTap: () { + Navigator.pushNamed(context, Routers.administratorDetailsPage, + arguments: {'itemData': itemData}); + }, child: Container( height: 100.h, margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), @@ -113,7 +156,7 @@ class _AuthorizedAdministratorListPageState width: 30.w, ), Image.asset( - lockTypeIcon, + 'images/controls_user.png', width: 60.w, height: 60.w, ), @@ -128,7 +171,7 @@ class _AuthorizedAdministratorListPageState mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - lockTypeTitle, + itemData.name ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ), @@ -156,4 +199,33 @@ class _AuthorizedAdministratorListPageState ), ); } + + //使用期限 + String getUseDateStr(AuthorizedAdminListItem 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; + } } diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart new file mode 100644 index 00000000..42c5db0e --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart @@ -0,0 +1,144 @@ +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/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'; +import '../../../../tools/titleAppBar.dart'; +import '../../../../translations/trans_lib.dart'; + +class ExpireLockListPage extends StatefulWidget { + const ExpireLockListPage({Key? key}) : super(key: key); + + @override + State createState() => _ExpireLockListPageState(); +} + +class _ExpireLockListPageState extends State { + List dataList = []; + + @override + void initState() { + super.initState(); + + expireLockListRequest(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: '即将到期', + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + child: Text( + TranslationLoader.lanKeys!.aboutToExpire!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: () {}, + ), + ], + ), + body: _buildMainUI(), + ); + } + + Widget _buildMainUI() { + return ListView.separated( + itemCount: dataList.length, + itemBuilder: (c, index) { + LockUserData indexEntity = dataList[index]; + return _electronicKeyItem(indexEntity); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ); + } + + //请求锁用户列表 + Future> expireLockListRequest() async { + ElectronicKeyListEntity entity = + await ApiRepository.to.expireLockList('0', '1', '20'); + // if (entity.errorCode!.codeIsSuccessful) { + // setState(() { + // dataList = entity.data! as List; + // // dataList = entity.data!; + // }); + // } + return dataList; + } + + Widget _electronicKeyItem(LockUserData itemData) { + return GestureDetector( + onTap: () { + Navigator.pushNamed(context, Routers.ownedKeyListPage, + arguments: {'uid': itemData.uid}); + }, + child: Container( + height: 90.h, + color: Colors.white, + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(10.w), + // ), + 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, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + itemData.nickname ?? '', + style: TextStyle( + fontSize: 24.sp, color: AppColors.blackColor), + ), + ], + ), + SizedBox(height: 5.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + itemData.userid ?? '', + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor), + ), + ], + ), + SizedBox(width: 20.h), + ], + ), + ), + SizedBox(width: 20.w), + ], + ), + ), + ); + } +} 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..6236370c 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList_page.dart @@ -1,22 +1,32 @@ 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'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; -class LockUserManageListListPage extends StatefulWidget { - const LockUserManageListListPage({Key? key}) : super(key: key); +class LockUserManageListPage extends StatefulWidget { + const LockUserManageListPage({Key? key}) : super(key: key); @override - State createState() => - _LockUserManageListListPageState(); + State createState() => _LockUserManageListPageState(); } -class _LockUserManageListListPageState - extends State { +class _LockUserManageListPageState extends State { + List dataList = []; + + @override + void initState() { + super.initState(); + + lockUserListRequest(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -31,7 +41,9 @@ class _LockUserManageListListPageState TranslationLoader.lanKeys!.aboutToExpire!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp), ), - onPressed: () {}, + onPressed: () { + Navigator.pushNamed(context, Routers.expireLockListPage); + }, ), ], ), @@ -54,7 +66,7 @@ class _LockUserManageListListPageState context, Routers.massSendElectronicKeyManagePage); }, child: Text( - '群发钥匙', + TranslationLoader.lanKeys!.sendGroupKey!.tr, style: TextStyle( color: AppColors.mainColor, fontSize: 24.sp, @@ -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..539c7b24 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,22 +17,53 @@ 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(); + } + return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.ownedKey!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - ), - body: Column( - children: [ - _topOwnedKeyText(), - Expanded(child: _buildMainUI()), - ], - ), - ); + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.ownedKey!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: FutureBuilder>( + future: mockNetworkDataRequest(), + builder: (BuildContext context, + AsyncSnapshot> snapshot) { + //请求结束 + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + //请求失败 + return const Text('请求失败'); + } else { + //请求成功 + final List itemList = snapshot.data!; + + return Column( + children: [ + _topOwnedKeyText(), + Expanded(child: _buildMainUI(itemList)), + ], + ); + } + } else { + //请求未结束 显示loading + return Container(); + } + })); } Widget _topOwnedKeyText() { @@ -49,21 +82,62 @@ class _OwnedKeyListPageState extends State { ); } - Widget _buildMainUI() { + //请求用户拥有的锁 + Future> mockNetworkDataRequest() async { + KeyListByUserEntity entity = + await ApiRepository.to.keyListByUser('1', '20', getUidStr); + if (entity.errorCode!.codeIsSuccessful) { + print("请求用户拥有的锁:${entity.data!.keyList}"); + } + if (entity.data != null) { + return entity.data!.keyList!; + } else { + List dataList = []; + return dataList; + } + } + + //使用期限 + 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(List itemList) { return ListView.builder( - itemCount: 5, + itemCount: itemList.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 = itemList[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 +151,7 @@ class _OwnedKeyListPageState extends State { width: 30.w, ), Image.asset( - lockTypeIcon, + 'images/icon_lockGroup_item.png', width: 60.w, height: 60.w, ), @@ -92,7 +166,7 @@ class _OwnedKeyListPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - lockTypeTitle, + itemData.lockAlias ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ), @@ -103,7 +177,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/mine/mineSet/mineSet_page.dart b/star_lock/lib/mine/mineSet/mineSet_page.dart index 74eb72b6..58e3258a 100644 --- a/star_lock/lib/mine/mineSet/mineSet_page.dart +++ b/star_lock/lib/mine/mineSet/mineSet_page.dart @@ -153,6 +153,21 @@ class _MineSetPageState extends State { Navigator.pushNamed(context, Routers.aPPUnlockNeedMobileNetworkingLockPage); }), + SizedBox( + height: 10.h, + ), + CommonItem( + leftTitel: "Amazon Alexa", + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () {}), + CommonItem( + leftTitel: "Google Home", + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () {}), // CommonItem(leftTitel:TranslationLoader.lanKeys!.valueAddedServices!.tr, rightTitle:"", isHaveDirection: true, action: (){ // // }), diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index fe2953ef..f7007b6e 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -46,16 +46,20 @@ abstract class Api { final String getWifiServiceIpURL = '/wifiLock/getWifiServiceIp'; // 获取Wifi锁服务器 final String updateSpecialValueUrl = '/room/updateSpecialValue'; // 开启/关闭 远程开锁 final String setAutoLockTimeUrl = '/room/setAutoLockTime'; // 自动闭锁 - final String getPassageModeConfigUrl = '/room/getPassageModeConfig'; // 获取锁的常开模式设置 + final String getPassageModeConfigUrl = + '/room/getPassageModeConfig'; // 获取锁的常开模式设置 final String configPassageModeUrl = '/room/configPassageMode'; // 配置锁的常开模式 final String updateSettingUrl = '/room/updateSetting'; // 锁声音/防撬报警/重置键/考勤 final String roomQueryDateUrl = '/room/queryDate'; // 获取网关时间 final String lockDiagnoseUrl = '/room/uploadLockInfo'; // 锁诊断 final String getServerDatetimeUrl = '/check/getServerDatetime'; // 获取服务器当前时间 final String getLockVersionInfoUrl = '/room/update'; // 获取锁当前版本信息 - final String openCheckingInURL = '/attendanceCompany/isExistenceCompany'; // 开启考勤获取是否有公司 - final String setCheckInCreateCompanyURL = '/attendanceCompany/add'; // 设置考勤时创建公司 - final String setLockPickingReminderDataURL = '/key/updateMonitorFlag'; // 设置开锁提醒 + final String openCheckingInURL = + '/attendanceCompany/isExistenceCompany'; // 开启考勤获取是否有公司 + final String setCheckInCreateCompanyURL = + '/attendanceCompany/add'; // 设置考勤时创建公司 + final String setLockPickingReminderDataURL = + '/key/updateMonitorFlag'; // 设置开锁提醒 final String getAttendanceRecordListByDateURL = '/attendanceRecord/listByDate'; // 获取考勤列表-早到榜日榜 final String getAttendanceRecordListByMonthURL = '/attendanceRecord/earlyListByMonth'; // 获取考勤列表-早到榜月榜 @@ -80,5 +84,11 @@ 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'; //用户拥有的锁 + final String authorizedAdminListURL = '/authorizedAdmin/list'; //授权管理员列表 + final String deleteAdministratorURL = '/authorizedAdmin/delete'; //删除授权管理员 + final String updateAdministratorURL = + '/authorizedAdmin/update'; //管理员姓名/有效期/远程开锁修改 + final String expireLockListURL = '/keyUser/listExpireUser'; //即将到期的锁列表 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 8d830a94..1bec24cb 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( @@ -297,10 +299,8 @@ class ApiProvider extends BaseProvider { })); // 获取Wifi锁服务器 - Future getWifiLockServiceIpAndPort() => post( - getWifiServiceIpURL.toUrl, - jsonEncode({ - })); + Future getWifiLockServiceIpAndPort() => + post(getWifiServiceIpURL.toUrl, jsonEncode({})); Future passwordKeyList( String keyStatus, @@ -346,7 +346,8 @@ class ApiProvider extends BaseProvider { 'operatorUid': operatorUid, 'startDate': startDate, 'timezoneRawOffSet': timezoneRawOffSet - })); + }), + isShowLoading: true); Future addKeyboardPwd( String lockId, @@ -402,11 +403,38 @@ class ApiProvider extends BaseProvider { jsonEncode({'lockId': lockId, 'groupId': groupId})); Future lockGroupList(String type) => - post(lockGroupListURL.toUrl, jsonEncode({'type': type})); + post(lockGroupListURL.toUrl, jsonEncode({'type': type}), + isShowLoading: true); Future deleteElectronicKey(String keyId) => post(deleteElectronicKeyURL.toUrl, jsonEncode({'keyId': keyId})); + Future deleteAdministrator(String uid, String includeUnderlings) => + post(deleteElectronicKeyURL.toUrl, + jsonEncode({'uid': uid, 'includeUnderlings': includeUnderlings})); + + Future updateAdministrator(String uid, String name, String endDate, + String startDate, String isRemoteUnlock) => + post( + deleteElectronicKeyURL.toUrl, + jsonEncode({ + 'uid': uid, + 'name': name, + 'endDate': endDate, + 'startDate': startDate, + 'isRemoteUnlock': isRemoteUnlock + })); + + Future expireLockList( + String operatorUid, String pageNo, String pageSize) => + post( + expireLockListURL.toUrl, + jsonEncode({ + 'operatorUid': operatorUid, + 'pageNo': pageNo, + 'pageSize': pageSize, + })); + Future deleteKeyboardPwd( String lockId, String keyboardPwdId, String deleteType) => post( @@ -428,10 +456,10 @@ class ApiProvider extends BaseProvider { lockListByGroupURL.toUrl, jsonEncode({'type': type, 'keyGroupId': keyGroupId})); - -/// 锁设置模块 + /// 锁设置模块 // 远程开锁 - Future remoteUnlockingOpenOrCloseLoadData(String lockId, String featureValue) => + Future remoteUnlockingOpenOrCloseLoadData( + String lockId, String featureValue) => post( updateSpecialValueUrl.toUrl, jsonEncode({ @@ -440,7 +468,8 @@ class ApiProvider extends BaseProvider { })); // 自动闭锁 - Future setAutoUnlockLoadData(String lockId, String autoLockTime, String type) => + Future setAutoUnlockLoadData( + String lockId, String autoLockTime, String type) => post( setAutoLockTimeUrl.toUrl, jsonEncode({ @@ -450,15 +479,22 @@ class ApiProvider extends BaseProvider { })); // 获取锁的常开模式设置 - Future getPassageModeConfigLoadData(String lockId) => - post( - getPassageModeConfigUrl.toUrl, - jsonEncode({ - 'lockId': lockId, - })); + Future getPassageModeConfigLoadData(String lockId) => post( + getPassageModeConfigUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + })); // 获取锁的常开模式设置 - Future configPassageMode(String lockId, String passageMode, String autoUnlock, String type, String startDate, String endDate, String isAllDay, List weekDays) => + Future configPassageMode( + String lockId, + String passageMode, + String autoUnlock, + String type, + String startDate, + String endDate, + String isAllDay, + List weekDays) => post( configPassageModeUrl.toUrl, jsonEncode({ @@ -473,7 +509,8 @@ class ApiProvider extends BaseProvider { })); // 获取锁的常开模式设置 - Future setLockSetGeneralSetting(String lockId, String changeType, String isOn, String type) => + Future setLockSetGeneralSetting( + String lockId, String changeType, String isOn, String type) => post( updateSettingUrl.toUrl, jsonEncode({ @@ -484,31 +521,29 @@ class ApiProvider extends BaseProvider { })); // 通过网关获取锁的时间 - Future getLockTimeFromGatewayLoadData(String lockId) => - post( - roomQueryDateUrl.toUrl, - jsonEncode({ - 'lockId': lockId, - })); + Future getLockTimeFromGatewayLoadData(String lockId) => post( + roomQueryDateUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + })); // 获取服务器当前时间 - Future getServerDatetimeLoadData(String lockId) => - post( - getServerDatetimeUrl.toUrl, - jsonEncode({ - 'lockId': lockId, - })); + Future getServerDatetimeLoadData(String lockId) => post( + getServerDatetimeUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + })); // 锁诊断 Future setLockDiagnoseData( - String lockId, - String electricQuantity, - String firmwareRevision, - String hardwareRevision, - String lockDate, - String modelNum, - String pwdInfo, - String timestamp) => + String lockId, + String electricQuantity, + String firmwareRevision, + String hardwareRevision, + String lockDate, + String modelNum, + String pwdInfo, + String timestamp) => post( lockDiagnoseUrl.toUrl, jsonEncode({ @@ -523,11 +558,11 @@ class ApiProvider extends BaseProvider { })); // 获取锁版本信息 - Future getLockVersionInfoLoadData(String lockId) => - post( - getLockVersionInfoUrl.toUrl, - jsonEncode({ - 'lockId': lockId,})); + Future getLockVersionInfoLoadData(String lockId) => post( + getLockVersionInfoUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + })); // 开启考勤获取考勤信息 Future openCheckingInGetData(String lockId) => post( @@ -540,22 +575,26 @@ class ApiProvider extends BaseProvider { // 设置考勤时创建公司 Future setCheckInCreateCompanyData( - String lockId, - String attendanceType, - String companyName, - List workDay, - String workEndTime, - String workStartTime) => post(setCheckInCreateCompanyURL.toUrl, jsonEncode({ - 'lockId': lockId, - 'attendanceType': attendanceType, - 'companyName': companyName, - 'workDay': workDay, - 'workEndTime': workEndTime, - 'workStartTime': workStartTime, - })); + String lockId, + String attendanceType, + String companyName, + List workDay, + String workEndTime, + String workStartTime) => + post( + setCheckInCreateCompanyURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'attendanceType': attendanceType, + 'companyName': companyName, + 'workDay': workDay, + 'workEndTime': workEndTime, + 'workStartTime': workStartTime, + })); // 获取开锁提醒 - Future setLockPickingReminderData(String lockId, String keyId, String monitorFlag) => + Future setLockPickingReminderData( + String lockId, String keyId, String monitorFlag) => post( setLockPickingReminderDataURL.toUrl, jsonEncode({ @@ -565,23 +604,22 @@ class ApiProvider extends BaseProvider { })); // 获取员工列表 - Future getStaffListData(String companyId, String lockId) => - post( - getStaffListURL.toUrl, - jsonEncode({ - 'companyId': companyId, - 'lockId': lockId, - })); + Future getStaffListData(String companyId, String lockId) => post( + getStaffListURL.toUrl, + jsonEncode({ + 'companyId': companyId, + 'lockId': lockId, + })); // 添加员工 Future addStaffData( - String attendanceType, - String attendanceWay, - String companyId, - String have, - String staffName, - String countryCode, - String usernameType) => + String attendanceType, + String attendanceWay, + String companyId, + String have, + String staffName, + String countryCode, + String usernameType) => post( addStaffURL.toUrl, jsonEncode({ @@ -790,20 +828,29 @@ 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) => post( lockUserListURL.toUrl, - jsonEncode({ - 'pageNo': pageNo, - 'pageSize': pageSize, - 'searchStr': searchStr - })); + jsonEncode( + {'pageNo': pageNo, 'pageSize': pageSize, 'searchStr': searchStr}), + isShowLoading: true); + + Future keyListByUser(String pageNo, String pageSize, String uid) => + post(keyListByUserURL.toUrl, + jsonEncode({'pageNo': pageNo, 'pageSize': pageSize, 'uid': uid}), + isShowLoading: true); + + Future authorizedAdminList(String pageNo, String pageSize) => post( + authorizedAdminListURL.toUrl, + jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}), + isShowLoading: true); Future canSendKey( - String endDate, String keyGroupIdList, String lockIdList) => + String endDate, List keyGroupIdList, List lockIdList) => post( canSendKeyURL.toUrl, jsonEncode({ @@ -811,6 +858,60 @@ class ApiProvider extends BaseProvider { 'keyGroupIdList': keyGroupIdList, 'lockIdList': lockIdList })); + + Future batchSendKey( + String endDate, + List keyGroupIdList, + List lockIdList, + String createUser, + String isRemoteUnlock, + String keyNameForAdmin, + String receiverUsername, + String startDate, + String countryCode, + String usernameType, + List weekDays) => + post( + batchSendKeyURL.toUrl, + jsonEncode({ + 'endDate': endDate, + 'keyGroupIdList': keyGroupIdList, + 'lockIdList': lockIdList, + 'createUser': createUser, + 'isRemoteUnlock': isRemoteUnlock, + 'keyNameForAdmin': keyNameForAdmin, + 'receiverUsername': receiverUsername, + 'startDate': startDate, + 'countryCode': countryCode, + '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 0a8aebed..1c6da3cd 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -2,12 +2,14 @@ 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/lockUserList/lockUserListEntity.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'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdminListEntity.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'; @@ -364,23 +366,23 @@ 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); } //锁分组列表 - Future lockGroupList(String type) async { + Future lockGroupList(String type) async { final res = await apiProvider.lockGroupList(type); - return LockGroupListEntity.fromJson(res.body); + return MassSendLockGroupListEntity.fromJson(res.body); } //删除电子钥匙 @@ -389,6 +391,28 @@ class ApiRepository { return ElectronicKeyListEntity.fromJson(res.body); } + //删除授权管理员 + Future deleteAdministrator( + String uid, String includeUnderlings) async { + final res = await apiProvider.deleteAdministrator(uid, includeUnderlings); + return ElectronicKeyListEntity.fromJson(res.body); + } + + //更新授权管理员 + Future updateAdministrator(String uid, String name, + String endDate, String startDate, String isRemoteUnlock) async { + final res = await apiProvider.updateAdministrator( + uid, name, endDate, startDate, isRemoteUnlock); + return ElectronicKeyListEntity.fromJson(res.body); + } + + //即将到期的锁列表 + Future expireLockList( + String operatorUid, String pageNo, String pageSize) async { + final res = await apiProvider.expireLockList(operatorUid, pageNo, pageSize); + return ElectronicKeyListEntity.fromJson(res.body); + } + //删除密码 Future deleteKeyboardPwd( String lockId, String keyboardPwdId, String deleteType) async { @@ -417,122 +441,116 @@ class ApiRepository { return PasswordKeyEntity.fromJson(res.body); } - // 获取Wifi锁服务器 Future getWifiLockServiceIpAndPort() async { final res = await apiProvider.getWifiLockServiceIpAndPort(); return ConfiguringWifiEntity.fromJson(res.body); } -/// 锁设置模块 + /// 锁设置模块 // 远程开锁开/关 - Future remoteUnlockingOpenOrClose( - { + Future remoteUnlockingOpenOrClose({ required String lockId, required String featureValue, }) async { - final res = - await apiProvider.remoteUnlockingOpenOrCloseLoadData(lockId, featureValue); + final res = await apiProvider.remoteUnlockingOpenOrCloseLoadData( + lockId, featureValue); return LoginEntity.fromJson(res.body); } // 自动闭锁 - Future setAutoUnlock( - { - required String lockId, - required String autoLockTime, - required String type, - }) async { + Future setAutoUnlock({ + required String lockId, + required String autoLockTime, + required String type, + }) async { final res = - await apiProvider.setAutoUnlockLoadData(lockId, autoLockTime, type); + await apiProvider.setAutoUnlockLoadData(lockId, autoLockTime, type); return LoginEntity.fromJson(res.body); } // 获取锁的常开模式设置 configPassageMode - Future getPassageModeConfig( - { - required String lockId, - }) async { - final res = - await apiProvider.getPassageModeConfigLoadData(lockId); + Future getPassageModeConfig({ + required String lockId, + }) async { + final res = await apiProvider.getPassageModeConfigLoadData(lockId); return GetPassageModeConfigEntity.fromJson(res.body); } // 配置锁的常开模式 - Future configPassageModeLoadData( - { - required String lockId, - required String passageMode, - required String autoUnlock, - required String type, - required String startDate, - required String endDate, - required String isAllDay, - required List weekDays, - }) async { - final res = - await apiProvider.configPassageMode(lockId, passageMode, autoUnlock, type, startDate, endDate, isAllDay, weekDays); + Future configPassageModeLoadData({ + required String lockId, + required String passageMode, + required String autoUnlock, + required String type, + required String startDate, + required String endDate, + required String isAllDay, + required List weekDays, + }) async { + final res = await apiProvider.configPassageMode(lockId, passageMode, + autoUnlock, type, startDate, endDate, isAllDay, weekDays); return GetPassageModeConfigEntity.fromJson(res.body); } // 配置锁的常规设置 - Future setLockSetGeneralSettingData( - { - required String lockId, - required String changeType, - required String isOn, - required String type, - }) async { - final res = - await apiProvider.setLockSetGeneralSetting(lockId, changeType, isOn, type); + Future setLockSetGeneralSettingData({ + required String lockId, + required String changeType, + required String isOn, + required String type, + }) async { + final res = await apiProvider.setLockSetGeneralSetting( + lockId, changeType, isOn, type); return LoginEntity.fromJson(res.body); } // 获取锁时间 通过网关 - Future getLockTimeFromGateway( - { - required String lockId, - }) async { - final res = - await apiProvider.getLockTimeFromGatewayLoadData(lockId); + Future getLockTimeFromGateway({ + required String lockId, + }) async { + final res = await apiProvider.getLockTimeFromGatewayLoadData(lockId); return GetPassageModeConfigEntity.fromJson(res.body); } // 获取服务器当前时间 - Future getServerDatetimeData( - { - required String lockId, - }) async { - final res = - await apiProvider.getServerDatetimeLoadData(lockId); + Future getServerDatetimeData({ + required String lockId, + }) async { + final res = await apiProvider.getServerDatetimeLoadData(lockId); return GetServerDatetimeEntity.fromJson(res.body); } // 锁诊断上传数据 - Future setLockDiagnoseData( - { - required String lockId, - required String electricQuantity, - required String firmwareRevision, - required String hardwareRevision, - required String lockDate, - required String modelNum, - required String pwdInfo, - required String timestamp, - }) async { - final res = - await apiProvider.setLockDiagnoseData(lockId, electricQuantity, firmwareRevision, hardwareRevision, lockDate, modelNum, pwdInfo, timestamp); + Future setLockDiagnoseData({ + required String lockId, + required String electricQuantity, + required String firmwareRevision, + required String hardwareRevision, + required String lockDate, + required String modelNum, + required String pwdInfo, + required String timestamp, + }) async { + final res = await apiProvider.setLockDiagnoseData( + lockId, + electricQuantity, + firmwareRevision, + hardwareRevision, + lockDate, + modelNum, + pwdInfo, + timestamp); return LoginEntity.fromJson(res.body); } // 获取锁版本信息 - Future getLockVersionInfoData( - { - required String lockId, - }) async { - final res = - await apiProvider.getLockVersionInfoLoadData(lockId); - return GetServerDatetimeEntity.fromJson(res.body);} + Future getLockVersionInfoData({ + required String lockId, + }) async { + final res = await apiProvider.getLockVersionInfoLoadData(lockId); + return GetServerDatetimeEntity.fromJson(res.body); + } //分组下的锁列表 Future listLockByGroup( @@ -554,44 +572,110 @@ 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, String keyGroupIdList, String lockIdList) async { + String endDate, List keyGroupIdList, List lockIdList) async { final res = await apiProvider.canSendKey(endDate, keyGroupIdList, lockIdList); return KeyDetailEntity.fromJson(res.body); } + //群发电子钥匙 + Future batchSendKey( + String endDate, + List keyGroupIdList, + List lockIdList, + String createUser, + String isRemoteUnlock, + String keyNameForAdmin, + String receiverUsername, + String startDate, + String countryCode, + String usernameType, + List weekDays) async { + final res = await apiProvider.batchSendKey( + endDate, + keyGroupIdList, + lockIdList, + createUser, + isRemoteUnlock, + keyNameForAdmin, + receiverUsername, + startDate, + countryCode, + usernameType, + weekDays); + 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 authorizedAdminList( + String pageNo, String pageSize) async { + final res = await apiProvider.authorizedAdminList(pageNo, pageSize); + return AuthorizedAdminListEntity.fromJson(res.body); + } + // 开启考勤 获取考勤信息 - Future openCheckingInData({required String lockId}) async { + Future openCheckingInData( + {required String lockId}) async { final res = await apiProvider.openCheckingInGetData(lockId); return CheckingInInfoDataEntity.fromJson(res.body); } // 设置考勤时创建公司 Future setCheckInCreateCompanyData( - { - required String lockId, - required String attendanceType, - required String companyName, - required List workDay, - required String workEndTime, - required String workStartTime - }) async { - final res = - await apiProvider.setCheckInCreateCompanyData(lockId, attendanceType, companyName, workDay, workEndTime, workStartTime); + {required String lockId, + required String attendanceType, + required String companyName, + required List workDay, + required String workEndTime, + required String workStartTime}) async { + final res = await apiProvider.setCheckInCreateCompanyData(lockId, + attendanceType, companyName, workDay, workEndTime, workStartTime); return LoginEntity.fromJson(res.body); } // 设置锁开锁提醒 - Future setLockPickingReminderData( - { - required String lockId, - required String keyId, - required String monitorFlag, - }) async { - final res = - await apiProvider.setLockPickingReminderData(lockId, keyId, monitorFlag); + Future setLockPickingReminderData({ + required String lockId, + required String keyId, + required String monitorFlag, + }) async { + final res = await apiProvider.setLockPickingReminderData( + lockId, keyId, monitorFlag); return LoginEntity.fromJson(res.body); } @@ -672,21 +756,28 @@ class ApiRepository { final res = await apiProvider.getStaffListData(companyId, lockId); return CheckingInAddStaffListEntity.fromJson(res.body); + + // 获取员工 + Future getStaffListData({ + required String companyId, + required String lockId, + }) async { + final res = await apiProvider.getStaffListData(companyId, lockId); + return LoginEntity.fromJson(res.body); } // 添加员工 - Future addStaffData( - { - required String attendanceType, - required String attendanceWay, - required String companyId, - required String have, - required String staffName, - required String countryCode, - required String usernameType, - }) async { - final res = - await apiProvider.addStaffData(attendanceType, attendanceWay, companyId, have, staffName, countryCode, usernameType); + Future addStaffData({ + required String attendanceType, + required String attendanceWay, + required String companyId, + required String have, + required String staffName, + required String countryCode, + required String usernameType, + }) async { + final res = await apiProvider.addStaffData(attendanceType, attendanceWay, + companyId, have, staffName, countryCode, usernameType); return LoginEntity.fromJson(res.body); } @@ -808,5 +899,4 @@ class ApiRepository { await apiProvider.addFingerprintsData(lockId, endDate, addType, fingerprintName, fingerprintNumber, fingerprintType, isCoerced, startDate, cyclicConfig); return CheckingInListMonthEntity.fromJson(res.body); } - } diff --git a/star_lock/lib/network/request_interceptor.dart b/star_lock/lib/network/request_interceptor.dart index 7fd95370..f77d4faa 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/LoginData.dart'; import '../login/login/entity/LoginEntity.dart'; diff --git a/star_lock/lib/tools/ExpandedListView.dart b/star_lock/lib/tools/ExpandedListView.dart index fae30663..cee2311a 100644 --- a/star_lock/lib/tools/ExpandedListView.dart +++ b/star_lock/lib/tools/ExpandedListView.dart @@ -1,22 +1,23 @@ +import 'dart:core'; + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; class ExpandedListTile extends StatefulWidget { const ExpandedListTile( {Key? key, - required this.title, this.child, this.onTap, - required this.typeImgList, - required this.imgName}) + required this.groupItem, + required this.typeImgList}) : super(key: key); - final String title; - final String imgName; final Widget? child; final List typeImgList; final Function()? onTap; + final GroupListItem groupItem; @override _ExpandedListTileState createState() => _ExpandedListTileState(); @@ -78,7 +79,9 @@ class _ExpandedListTileState extends State { //点击左侧是否勾选按钮 setState(() { _isCheck = !_isCheck; + widget.groupItem.isChecked = _isCheck; }); + widget.onTap?.call(); }, )); widgetList.add(GestureDetector( @@ -96,7 +99,7 @@ class _ExpandedListTileState extends State { width: 10.w, ), Text( - widget.title, + widget.groupItem.keyGroupName ?? '', style: TextStyle(color: AppColors.blackColor, fontSize: 22.sp), ), Expanded( @@ -119,7 +122,6 @@ class _ExpandedListTileState extends State { setState(() { _isExpanded = !_isExpanded; }); - widget.onTap?.call(); }, )); return widgetList; diff --git a/star_lock/lib/tools/showTFView.dart b/star_lock/lib/tools/showTFView.dart index c6b8ce79..4fc01340 100644 --- a/star_lock/lib/tools/showTFView.dart +++ b/star_lock/lib/tools/showTFView.dart @@ -45,11 +45,10 @@ class ShowTFView extends StatelessWidget { controller: controller, autofocus: false, decoration: InputDecoration( - //输入里面输入文字内边距设置 contentPadding: - EdgeInsets.only(top: 20.h, left: 15.0, bottom: 13.h), - hintText: tipTitle, - hintStyle: TextStyle(fontSize: 28.sp), + const EdgeInsets.only(left: 5, top: -8, bottom: 6), + hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, + hintStyle: TextStyle(fontSize: 22.sp, height: 1.0), //不需要输入框下划线 border: InputBorder.none, //左边图标设置