From 0df385cba2330bf0e5616a1dcb0f42a04e67f045 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 18 May 2024 15:58:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=AF=86=E7=A0=81=E5=90=8E=E5=9B=9B=E4=BD=8D?= =?UTF-8?q?=E6=B2=A1=E6=9C=89****=E5=8F=B7=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 19 +- .../checkingInAddStaff_page.dart | 269 +++++++++++------- 2 files changed, 174 insertions(+), 114 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index a88fa173..f674b529 100755 --- a/lib/app.dart +++ b/lib/app.dart @@ -11,7 +11,6 @@ import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart'; import 'package:star_lock/tools/app_manager.dart'; import 'package:star_lock/tools/bindings/app_binding.dart'; import 'package:star_lock/tools/storage.dart'; -import 'package:star_lock/tools/xs_jPhush.dart'; import 'package:star_lock/translations/app_dept.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -19,7 +18,6 @@ import 'package:star_lock/translations/trans_lib.dart'; import 'appRouters.dart'; import 'baseWidget.dart'; import 'tools/appRouteObserver.dart'; -import 'dart:io'; import 'tools/store_service.dart'; @@ -38,24 +36,25 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { Widget build(BuildContext context) { return ScreenUtilInit( designSize: const Size(585, 1265), - builder: (w, a) => _initMaterialApp()); + builder: (BuildContext w, Widget? a) => _initMaterialApp()); } GetMaterialApp _initMaterialApp() => GetMaterialApp( // enableLog: false, title: F.navTitle, - navigatorObservers: [AppRouteObserver().routeObserver], + navigatorObservers: [AppRouteObserver().routeObserver], translations: TranslationMessage(), supportedLocales: appDept.deptSupportedLocales, - localizationsDelegates: const [ + localizationsDelegates: const >[ GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], - localeResolutionCallback: (locale, supportedLocales) { + localeResolutionCallback: + (Locale? locale, Iterable supportedLocales) { if (!supportedLocales.contains(locale)) { - int idx = appSupportedLocales.indexWhere( - (element) => element.languageCode == locale!.languageCode); + final int idx = appSupportedLocales.indexWhere( + (Locale element) => element.languageCode == locale!.languageCode); if (idx != -1) { locale = appSupportedLocales[idx]; } else { @@ -68,7 +67,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { }, locale: StoreService.to.getLanguageCode()!.isNotEmpty ? appDept.deptSupportedLocales - .where((element) => + .where((Locale element) => element.languageCode == StoreService.to.getLanguageCode()) .first : Get.deviceLocale, @@ -148,7 +147,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { } Future getLoginStatus() async { - final data = await Storage.getString(saveUserLoginData); + final String? data = await Storage.getString(saveUserLoginData); if (data != null && data.isNotEmpty) { return true; } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index 4f600d95..9a03705f 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -20,8 +22,9 @@ class CheckingInAddStaffPage extends StatefulWidget { } class _CheckingInAddStaffPageState extends State { - final logic = Get.put(CheckingInAddStaffLogic()); - final state = Get.find().state; + final CheckingInAddStaffLogic logic = Get.put(CheckingInAddStaffLogic()); + final CheckingInAddStaffState state = + Get.find().state; @override Widget build(BuildContext context) { @@ -33,11 +36,11 @@ class _CheckingInAddStaffPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ // 姓名 CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( @@ -50,35 +53,42 @@ class _CheckingInAddStaffPageState extends State { isHaveLine: false, isHaveDirection: true, action: () { - var list = ["APP", "密码".tr, "卡".tr, "指纹".tr]; - if(state.getKeyInfosData.value.lockName!.contains("T9A")){ - list.add("人脸".tr); + final List list = [ + 'APP', + '密码'.tr, + '卡'.tr, + '指纹'.tr + ]; + if (state.getKeyInfosData.value.lockName!.contains('T9A')) { + list.add('人脸'.tr); } - _showSelectClockInType(list, list, "1", "选择钥匙".tr); + _showSelectClockInType(list, list, '1', '选择钥匙'.tr); })), SizedBox(height: 10.h), //员工是否有App、卡、钥匙、指纹必须显示 Obx(() => CommonItem( leftTitel: addStaffGetIfHaveKey(), - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: Row( - children: [ - whetherTheEmployeeHasAKeyWidget("无".tr, state.appUnHaveAccount.value, () { + children: [ + whetherTheEmployeeHasAKeyWidget( + '无'.tr, state.appUnHaveAccount.value, () { setState(() { state.appUnHaveAccount.value = true; - state.attendanceWayNumber.value = ""; + state.attendanceWayNumber.value = ''; logic.isCanClickAction(); }); }), SizedBox( width: 30.w, ), - whetherTheEmployeeHasAKeyWidget("有".tr, !state.appUnHaveAccount.value, () { + whetherTheEmployeeHasAKeyWidget( + '有'.tr, !state.appUnHaveAccount.value, () { setState(() { state.appUnHaveAccount.value = false; - state.attendanceWayNumber.value = ""; + state.attendanceWayNumber.value = ''; logic.isCanClickAction(); }); }), @@ -86,12 +96,15 @@ class _CheckingInAddStaffPageState extends State { ))), // 当选择App时且没有钥匙的时候 显示输入账号输入框和选择国家 其他隐藏 Obx(() => Visibility( - visible: (state.appUnHaveAccount.value && state.selectPrintingMethodType.value == "1") ? true : false, + visible: (state.appUnHaveAccount.value && + state.selectPrintingMethodType.value == '1') + ? true + : false, child: Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( @@ -100,7 +113,7 @@ class _CheckingInAddStaffPageState extends State { CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, isHaveDirection: true, @@ -112,7 +125,7 @@ class _CheckingInAddStaffPageState extends State { color: AppColors.darkGrayTextColor), ), action: () async { - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.selectCountryRegionPage); if (result != null) { result as Map; @@ -127,103 +140,128 @@ class _CheckingInAddStaffPageState extends State { )), // 当选择密码、卡、指纹时显示 Obx(() => Visibility( - visible: (state.selectPrintingMethodType.value != "1" && state.appUnHaveAccount.value) ? true : false, + visible: state.selectPrintingMethodType.value != '1' && + state.appUnHaveAccount.value, child: CommonItem( leftTitel: addStaffGetKeyType(), isHaveLine: false, isHaveRightWidget: true, rightWidget: Row( - children: [ - Obx(() => Text(state.attendanceWayNumber.value, style: TextStyle(fontSize: 24.sp))), + children: [ + Obx(() => Text(state.attendanceWayNumber.value, + style: TextStyle(fontSize: 24.sp))), SizedBox(width: 30.w), GestureDetector( onTap: () async { - switch (int.parse(state.selectPrintingMethodType.value)) { + switch (int.parse( + state.selectPrintingMethodType.value)) { case 2: - // 获取密码 + // 获取密码 logic.getKeyboardPwdRequest(); break; case 3: - // 卡 + // 卡 if (state.staffNameController.text.isEmpty) { - logic.showToast("请输入姓名".tr); + logic.showToast('请输入姓名'.tr); return; } - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.addCardPage, - arguments: { - "lockId": state.getKeyInfosData.value.lockId, - "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - "fromTypeTwoStaffName": state.staffNameController.text + arguments: { + 'lockId': + state.getKeyInfosData.value.lockId, + 'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + 'fromTypeTwoStaffName': + state.staffNameController.text }); - if (data != null) { - - } + if (data != null) {} break; case 4: - // 指纹 + // 指纹 if (state.staffNameController.text.isEmpty) { - logic.showToast("请输入姓名".tr); + logic.showToast('请输入姓名'.tr); return; } - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.addFingerprintTypePage, - arguments: { - "lockId": state.getKeyInfosData.value.lockId, - "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - "fromTypeTwoStaffName": state.staffNameController.text + arguments: { + 'lockId': + state.getKeyInfosData.value.lockId, + 'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + 'fromTypeTwoStaffName': + state.staffNameController.text }); - if (data != null) { - - } + if (data != null) {} break; case 5: - Get.toNamed(Routers.addFaceTypePage, arguments: { - "lockId": state.getKeyInfosData.value.lockId, - "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - "fromTypeTwoStaffName": state.staffNameController.text - }); + Get.toNamed(Routers.addFaceTypePage, + arguments: { + 'lockId': + state.getKeyInfosData.value.lockId, + 'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + 'fromTypeTwoStaffName': + state.staffNameController.text + }); break; } }, child: Container( height: 40.h, - padding: EdgeInsets.only(left: 25.w, right: 25.w, top: 2.h), + padding: EdgeInsets.only( + left: 25.w, right: 25.w, top: 2.h), decoration: BoxDecoration( color: AppColors.mainColor, borderRadius: BorderRadius.circular(20.h), ), - child: Text(addStaffSelectKeyType(), textAlign: TextAlign.center, - style: TextStyle(color: Colors.white, fontSize: 22.sp) - ), + child: Text(addStaffSelectKeyType(), + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, fontSize: 22.sp)), ), ), ], )), )), // 当选择钥匙类型为有时 必显示 - Obx(() => Visibility( - visible: !state.appUnHaveAccount.value, - child: CommonItem( - leftTitel: addStaffGetKeyType(), - rightTitle: state.attendanceWayNumber.value, - isHaveLine: false, - isHaveDirection: true, - action: () { - logic.addStaffSelectKey((v) { - var showList = []; - List numberList = []; - for (var element in v) { - showList.add("${element.staffName}-${element.attendanceWay}"); - numberList.add(element.attendanceWay); + Obx(() { + final bool isPass = state.selectPrintingMethodType.value == '2'; + String rightTitle = state.attendanceWayNumber.value; + if (isPass) { + rightTitle = showPass(rightTitle); + } + return Visibility( + visible: !state.appUnHaveAccount.value, + child: CommonItem( + leftTitel: addStaffGetKeyType(), + rightTitle: rightTitle, + isHaveLine: false, + isHaveDirection: true, + action: () { + logic.addStaffSelectKey( + (List v) { + final List showList = []; + final List numberList = []; + for (final CheckingInAddStaffKeyEntity element in v) { + final bool isPass = + state.selectPrintingMethodType.value == '2'; + String attendanceWay = element.attendanceWay ?? ''; + if (isPass) { + attendanceWay = showPass(attendanceWay); } - _showSelectClockInType(showList, numberList, "2", addStaffSelectKeySelectClockInType()); - }); - }), - )), + final String text = + '${element.staffName}-$attendanceWay'; + showList.add(text); + numberList.add(element.attendanceWay ?? ''); + } + _showSelectClockInType(showList, numberList, '2', + addStaffSelectKeySelectClockInType()); + }); + }), + ); + }), SizedBox(height: 50.w), Obx(() => SubmitBtn( btnName: TranslationLoader.lanKeys!.sure!.tr, @@ -231,25 +269,38 @@ class _CheckingInAddStaffPageState extends State { margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), isDisabled: state.isCanClick.value, - onClick: state.isCanClick.value ? (){ - if (state.isAdd.value == "2") { - logic.editStaffLoadData(); - } else { - logic.addStaffLoadData(); - } - }: null)) + onClick: state.isCanClick.value + ? () { + if (state.isAdd.value == '2') { + logic.editStaffLoadData(); + } else { + logic.addStaffLoadData(); + } + } + : null)) ], ), ); } + //显示密码 + String showPass(String text) { + final int length = text.length; + if (length > 4) { + return text.substring(0, length - 4) + '****'; + } else if (length > 00) { + return '****'; + } + return ''; + } + Widget getTFWidget(String tfStr, TextEditingController tf) { return SizedBox( // height: 50.h, width: 300.w, // color: Colors.red, child: Row( - children: [ + children: [ Expanded( child: TextField( //输入框一行 @@ -258,11 +309,12 @@ class _CheckingInAddStaffPageState extends State { FilteringTextInputFormatter.deny('\n'), // LengthLimitingTextInputFormatter(30), ], - style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), controller: tf, autofocus: false, textAlign: TextAlign.end, - onChanged: (v) { + onChanged: (String v) { logic.changeInput(tf); }, decoration: InputDecoration( @@ -270,10 +322,18 @@ class _CheckingInAddStaffPageState extends State { // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), ), @@ -284,7 +344,8 @@ class _CheckingInAddStaffPageState extends State { } // type 1 打卡方式 2选择钥匙 - void _showSelectClockInType(List showList, List numberList, String showBottomSheetToolType, String title) { + void _showSelectClockInType(List showList, List numberList, + String showBottomSheetToolType, String title) { ShowBottomSheetTool().showSingleRowPicker( //上下文 context, @@ -298,12 +359,12 @@ class _CheckingInAddStaffPageState extends State { //adapter: PickerAdapter(), data: showList, //选择事件的回调 - clickCallBack: (int index, var str) { + clickCallBack: (int index, Object str) { setState(() { - if (showBottomSheetToolType == "1") { + if (showBottomSheetToolType == '1') { state.selectPrintingMethodType.value = (index + 1).toString(); state.selectPrintingMethodStr.value = str.toString(); - state.attendanceWayNumber.value = ""; + state.attendanceWayNumber.value = ''; } else { state.attendanceWayNumber.value = numberList[index].toString(); } @@ -312,16 +373,17 @@ class _CheckingInAddStaffPageState extends State { }); } - Widget whetherTheEmployeeHasAKeyWidget(String title, bool appUnHaveAccount, Function() action) { + Widget whetherTheEmployeeHasAKeyWidget( + String title, bool appUnHaveAccount, Function() action) { return GestureDetector( onTap: action, child: Container( // width: 80.w, height: 65.w, - padding: EdgeInsets.only(left:10.w, right: 10.w), + padding: EdgeInsets.only(left: 10.w, right: 10.w), // color: Colors.red, child: Row( - children: [ + children: [ Image.asset( appUnHaveAccount ? 'images/icon_round_select.png' @@ -345,7 +407,7 @@ class _CheckingInAddStaffPageState extends State { } String addStaffGetIfHaveKey() { - String title = ""; + String title = ''; switch (int.parse(state.selectPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.whetherTheEmployeeHasAKey!.tr; @@ -360,14 +422,14 @@ class _CheckingInAddStaffPageState extends State { title = TranslationLoader.lanKeys!.whetherTheEmployeeHasFingerprint!.tr; break; case 4: - title = "员工是否有人脸".tr; + title = '员工是否有人脸'.tr; break; } return title; } String addStaffGetKeyType() { - String title = ""; + String title = ''; switch (int.parse(state.selectPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.accountNumber!.tr; @@ -389,7 +451,7 @@ class _CheckingInAddStaffPageState extends State { } String addStaffSelectKeyType() { - String title = ""; + String title = ''; switch (int.parse(state.selectPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.getKey!.tr; @@ -404,32 +466,31 @@ class _CheckingInAddStaffPageState extends State { title = TranslationLoader.lanKeys!.getFingerprint!.tr; break; case 5: - title = "获取人脸".tr; + title = '获取人脸'.tr; break; } return title; } String addStaffSelectKeySelectClockInType() { - String title = ""; + String title = ''; switch (int.parse(state.selectPrintingMethodType.value)) { case 1: - title = "选择钥匙".tr; + title = '选择钥匙'.tr; break; case 2: - title = "选择密码".tr; + title = '选择密码'.tr; break; case 3: - title = "选择卡".tr; + title = '选择卡'.tr; break; case 4: - title = "选择指纹".tr; + title = '选择指纹'.tr; break; case 5: - title = "选择人脸".tr; + title = '选择人脸'.tr; break; } return title; } - }