fix:修复添加员工密码后四位没有****号显示

This commit is contained in:
anfe 2024-05-18 15:58:50 +08:00
parent f60613a549
commit 0df385cba2
2 changed files with 174 additions and 114 deletions

View File

@ -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<MyApp> 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: <NavigatorObserver>[AppRouteObserver().routeObserver],
translations: TranslationMessage(),
supportedLocales: appDept.deptSupportedLocales,
localizationsDelegates: const [
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
localeResolutionCallback: (locale, supportedLocales) {
localeResolutionCallback:
(Locale? locale, Iterable<Locale> 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<MyApp> 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<MyApp> with WidgetsBindingObserver, BaseWidget {
}
Future<bool> getLoginStatus() async {
final data = await Storage.getString(saveUserLoginData);
final String? data = await Storage.getString(saveUserLoginData);
if (data != null && data.isNotEmpty) {
return true;
}

View File

@ -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<CheckingInAddStaffPage> {
final logic = Get.put(CheckingInAddStaffLogic());
final state = Get.find<CheckingInAddStaffLogic>().state;
final CheckingInAddStaffLogic logic = Get.put(CheckingInAddStaffLogic());
final CheckingInAddStaffState state =
Get.find<CheckingInAddStaffLogic>().state;
@override
Widget build(BuildContext context) {
@ -33,11 +36,11 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: [
children: <Widget>[
//
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: "",
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(
@ -50,35 +53,42 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
isHaveLine: false,
isHaveDirection: true,
action: () {
var list = ["APP", "密码".tr, "".tr, "指纹".tr];
if(state.getKeyInfosData.value.lockName!.contains("T9A")){
list.add("人脸".tr);
final List<String> list = <String>[
'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: <Widget>[
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<CheckingInAddStaffPage> {
))),
// 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: <Widget>[
CommonItem(
leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr,
rightTitle: "",
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(
@ -100,7 +113,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
CommonItem(
leftTitel:
TranslationLoader.lanKeys!.countryAndRegion!.tr,
rightTitle: "",
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
isHaveDirection: true,
@ -112,7 +125,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
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<String, dynamic>;
@ -127,103 +140,128 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
)),
//
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: <Widget>[
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: <String, Object?>{
'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: <String, Object?>{
'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: <String, Object?>{
'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<CheckingInAddStaffKeyEntity> v) {
final List<String> showList = <String>[];
final List<String> numberList = <String>[];
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<CheckingInAddStaffPage> {
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: <Widget>[
Expanded(
child: TextField(
//
@ -258,11 +309,12 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
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<CheckingInAddStaffPage> {
// 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<CheckingInAddStaffPage> {
}
// 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<CheckingInAddStaffPage> {
//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<CheckingInAddStaffPage> {
});
}
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: <Widget>[
Image.asset(
appUnHaveAccount
? 'images/icon_round_select.png'
@ -345,7 +407,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
}
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<CheckingInAddStaffPage> {
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<CheckingInAddStaffPage> {
}
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<CheckingInAddStaffPage> {
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;
}
}