From b3d0c04ddca62dc89d38d40014b790c91bc25bea Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 11:04:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E7=AC=AC4=E6=A0=8F?= =?UTF-8?q?=E5=BA=94=E9=83=BD=E8=A6=81=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=98=9F?= =?UTF-8?q?=E9=94=81=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=90=8E=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes .../checkingInAddStaff_logic.dart | 50 ++++++++++-------- .../checkingInAddStaff_page.dart | 34 +++++++----- .../checkingInAddStaff_state.dart | 47 ++++++++-------- .../checkingInStaffList_page.dart | 41 +++++++------- 5 files changed, 93 insertions(+), 79 deletions(-) diff --git a/.DS_Store b/.DS_Store index ab459319e6a778b2a3dea34e5b8e7b01e88e0ec3..fce4fcc3b0432e5f39e9c8a2564ff8e890f2dd76 100755 GIT binary patch delta 45 zcmZoMXfc@J&&aniU^g=(-)0_`PfU{^ur_cQS(xZ37+V-j&S0~j{F%*ZGdss$egH+I B4m|(> delta 31 ncmZoMXfc@J&&azmU^g=(?`9sBPfU|9u$xaTxU`v_<1aq|s7nhR diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart index ab08598e..6f21bf4e 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart @@ -4,6 +4,8 @@ import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/eventBusEventManage.dart'; @@ -23,30 +25,30 @@ class CheckingInAddStaffLogic extends BaseGetXController { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _getNumberEvent = eventBus .on() - .listen((event) { + .listen((ChickInAddStaffCardAndFingerprintBlockNumberEvent event) { state.attendanceWayNumber.value = event.number; isCanClickAction(); }); } // 添加员工 - void addStaffLoadData() async { - var usernameType = "1"; - if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) { - usernameType = "2"; + Future addStaffLoadData() async { + String usernameType = '1'; + if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) { + usernameType = '2'; } // 当是app且没有钥匙时,直接把账号赋值给attendanceWayNumber if (state.appUnHaveAccount.value && - state.selectPrintingMethodType.value == "1") { + state.selectPrintingMethodType.value == '1') { state.attendanceWayNumber.value = state.staffAccountController.text; } - var entity = await ApiRepository.to.addStaffData( + final LoginEntity entity = await ApiRepository.to.addStaffData( attendanceType: state.selectPrintingMethodType.value, attendanceWay: state.attendanceWayNumber.value, companyId: state.companyId.value, - have: state.appUnHaveAccount.value ? "2" : "1", + have: state.appUnHaveAccount.value ? '2' : '1', staffName: state.staffNameController.text, countryCode: state.countryCode.value, usernameType: usernameType, @@ -54,7 +56,7 @@ class CheckingInAddStaffLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { eventBus.fire(RefreshCheckInSetDataEvent()); eventBus.fire(RefreshCheckInListEvent()); - Get.back(result: "addScuess"); + Get.back(result: 'addScuess'); } else if (entity.errorCode! == 425) { showToast(entity.errorMsg!); } @@ -62,8 +64,9 @@ class CheckingInAddStaffLogic extends BaseGetXController { // 考勤设置添加员工-选择钥匙 1为APP,2为密码,3为卡,4为指纹,返回数据中, // attendanceWay分别为用户名、密码、卡号、指纹号 - void addStaffSelectKey(KeyClickCallback kyClickCallback) async { - var entity = await ApiRepository.to.addStaffSelectKeyData( + Future addStaffSelectKey(KeyClickCallback kyClickCallback) async { + final CheckingInAddStaffSelectKeyEntity entity = + await ApiRepository.to.addStaffSelectKeyData( companyId: state.companyId.value, type: state.selectPrintingMethodType.value, ); @@ -74,18 +77,17 @@ class CheckingInAddStaffLogic extends BaseGetXController { } // 编辑员工 - void editStaffLoadData() async { - var usernameType = "1"; - if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) { - usernameType = "2"; + Future editStaffLoadData() async { + String usernameType = '1'; + if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) { + usernameType = '2'; } - - var entity = await ApiRepository.to.editStaffData( + final LoginEntity entity = await ApiRepository.to.editStaffData( attendanceType: state.selectPrintingMethodType.value, attendanceWay: state.attendanceWayNumber.value, staffId: state.staffListItemData.value.staffId.toString(), - have: state.appUnHaveAccount.value ? "2" : "1", + have: state.appUnHaveAccount.value ? '2' : '1', staffName: state.staffNameController.text, countryCode: state.countryCode.value, usernameType: usernameType, @@ -99,13 +101,13 @@ class CheckingInAddStaffLogic extends BaseGetXController { } //获取密码请求 - void getKeyboardPwdRequest() async { + Future getKeyboardPwdRequest() async { if (state.staffNameController.text.isEmpty) { - showToast("请输入姓名"); + showToast('请输入姓名'); return; } - var entity = await ApiRepository.to.getPasswordKey( - endDate: "0", + final PasswordKeyEntity entity = await ApiRepository.to.getPasswordKey( + endDate: '0', keyboardPwdName: state.staffNameController.text, keyboardPwdType: 2.toString(), lockId: state.getKeyInfosData.value.lockId.toString(), @@ -136,7 +138,7 @@ class CheckingInAddStaffLogic extends BaseGetXController { // 是否能点击 void isCanClickAction() { - if (state.selectPrintingMethodType.value == "1" && + if (state.selectPrintingMethodType.value == '1' && state.appUnHaveAccount.value) { // 没有账号的时候直接判断姓名和账号是否为空 state.isCanClick.value = @@ -154,6 +156,8 @@ class CheckingInAddStaffLogic extends BaseGetXController { _initLoadDataAction(); changeInput(state.staffNameController); + + } @override diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index 9a03705f..0376b3a1 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_easyloading/flutter_easyloading.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'; @@ -62,7 +63,7 @@ class _CheckingInAddStaffPageState extends State { if (state.getKeyInfosData.value.lockName!.contains('T9A')) { list.add('人脸'.tr); } - _showSelectClockInType(list, list, '1', '选择钥匙'.tr); + _showSelectClockInType(list, list, list, '1', '选择钥匙'.tr); })), SizedBox(height: 10.h), //员工是否有App、卡、钥匙、指纹必须显示 @@ -96,10 +97,8 @@ 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', child: Column( children: [ CommonItem( @@ -166,7 +165,7 @@ class _CheckingInAddStaffPageState extends State { return; } - final data = await Get.toNamed( + final dynamic data = await Get.toNamed( Routers.addCardPage, arguments: { 'lockId': @@ -228,9 +227,14 @@ class _CheckingInAddStaffPageState extends State { // 当选择钥匙类型为有时 必显示 Obx(() { final bool isPass = state.selectPrintingMethodType.value == '2'; - String rightTitle = state.attendanceWayNumber.value; + String attendanceWayNumber = state.attendanceWayNumber.value; + final String attendanceWayName = state.attendanceWayName.value; if (isPass) { - rightTitle = showPass(rightTitle); + attendanceWayNumber = showPass(attendanceWayNumber); + } + String rightTitle = attendanceWayNumber; + if (attendanceWayName.trim() != '') { + rightTitle = '$attendanceWayName - ' + rightTitle; } return Visibility( visible: !state.appUnHaveAccount.value, @@ -243,6 +247,7 @@ class _CheckingInAddStaffPageState extends State { logic.addStaffSelectKey( (List v) { final List showList = []; + final List nameList = []; final List numberList = []; for (final CheckingInAddStaffKeyEntity element in v) { final bool isPass = @@ -252,12 +257,13 @@ class _CheckingInAddStaffPageState extends State { attendanceWay = showPass(attendanceWay); } final String text = - '${element.staffName}-$attendanceWay'; + '${element.staffName} - $attendanceWay'; showList.add(text); numberList.add(element.attendanceWay ?? ''); + nameList.add(element.staffName ?? ''); } - _showSelectClockInType(showList, numberList, '2', - addStaffSelectKeySelectClockInType()); + _showSelectClockInType(showList, numberList, nameList, + '2', addStaffSelectKeySelectClockInType()); }); }), ); @@ -344,8 +350,8 @@ class _CheckingInAddStaffPageState extends State { } // type 1 打卡方式 2选择钥匙 - void _showSelectClockInType(List showList, List numberList, - String showBottomSheetToolType, String title) { + void _showSelectClockInType(List showList, List numberList, + List nameList, String showBottomSheetToolType, String title) { ShowBottomSheetTool().showSingleRowPicker( //上下文 context, @@ -364,8 +370,10 @@ class _CheckingInAddStaffPageState extends State { if (showBottomSheetToolType == '1') { state.selectPrintingMethodType.value = (index + 1).toString(); state.selectPrintingMethodStr.value = str.toString(); + state.attendanceWayName.value = ''; state.attendanceWayNumber.value = ''; } else { + state.attendanceWayName.value = nameList[index].toString(); state.attendanceWayNumber.value = numberList[index].toString(); } logic.isCanClickAction(); diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart index 10f58706..dd23cda8 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart @@ -6,27 +6,28 @@ import '../checkingInSetStaffList/checkingInStaffList_entity.dart'; import 'checkingInAddStaffSelectKey_entity.dart'; class CheckingInAddStaffState { - final getKeyInfosData = LockListInfoItemEntity().obs; - final companyId = "".obs; - final staffListItemData = CheckingInAddStaffListItemEntity().obs; + final Rx getKeyInfosData = LockListInfoItemEntity().obs; + final RxString companyId = ''.obs; + final Rx staffListItemData = CheckingInAddStaffListItemEntity().obs; final TextEditingController staffNameController = TextEditingController(); final TextEditingController staffAccountController = TextEditingController(); - final selectPrintingMethodType = "1".obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸 - final selectPrintingMethodStr = "APP".obs; // 选择打卡类型字符串 + final RxString selectPrintingMethodType = '1'.obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸 + final RxString selectPrintingMethodStr = 'APP'.obs; // 选择打卡类型字符串 - final countryName = "中国".tr.obs; - final countryCode = "86".obs; + final RxString countryName = '中国'.tr.obs; + final RxString countryCode = '86'.obs; - final appUnHaveAccount = true.obs; // 默认没有账号 - final keyEntity = [].obs; // 选择钥匙数据 + final RxBool appUnHaveAccount = true.obs; // 默认没有账号 + final RxList keyEntity = [].obs; // 选择钥匙数据 - final isAdd = "1".obs; // 1添加 2编辑 - final attendanceWayNumber = "".obs; - final isCanClick = false.obs; - var staffName = ''.obs; - var staffAccount = ''.obs; + final RxString isAdd = '1'.obs; // 1添加 2编辑 + final RxString attendanceWayName = ''.obs; + final RxString attendanceWayNumber = ''.obs; + final RxBool isCanClick = false.obs; + RxString staffName = ''.obs; + RxString staffAccount = ''.obs; bool get staffNameIsNotEmpty => staffName.value.isNotEmpty; @@ -37,28 +38,28 @@ class CheckingInAddStaffState { CheckingInAddStaffState() { Map map = Get.arguments; - getKeyInfosData.value = map["getKeyInfosData"]; - companyId.value = map["companyId"]; + getKeyInfosData.value = map['getKeyInfosData']; + companyId.value = map['companyId']; - isAdd.value = map["isAdd"]; - if (isAdd.value == "2") { - staffListItemData.value = map["staffListItem"]; + isAdd.value = map['isAdd']; + if (isAdd.value == '2') { + staffListItemData.value = map['staffListItem']; staffNameController.text = staffListItemData.value.staffName!; selectPrintingMethodType.value = staffListItemData.value.attendanceType.toString(); switch (staffListItemData.value.attendanceType) { case 1: - selectPrintingMethodStr.value = "APP"; + selectPrintingMethodStr.value = 'APP'; break; case 2: - selectPrintingMethodStr.value = "密码".tr; + selectPrintingMethodStr.value = '密码'.tr; break; case 3: - selectPrintingMethodStr.value = "卡".tr; + selectPrintingMethodStr.value = '卡'.tr; break; case 4: - selectPrintingMethodStr.value = "指纹".tr; + selectPrintingMethodStr.value = '指纹'.tr; break; } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index c3d189b7..a1ae4a07 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart'; import 'package:star_lock/tools/showTipView.dart'; import '../../../../../appRouters.dart'; @@ -23,8 +24,8 @@ class CheckingInStaffListPage extends StatefulWidget { } class _CheckingInStaffListPageState extends State { - final logic = Get.put(CheckingInStaffManageLogic()); - final state = Get.find().state; + final CheckingInStaffManageLogic logic = Get.put(CheckingInStaffManageLogic()); + final CheckingInStaffManageState state = Get.find().state; @override Widget build(BuildContext context) { @@ -34,13 +35,13 @@ class _CheckingInStaffListPageState extends State { barTitle: TranslationLoader.lanKeys!.staff!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + actionsList: [ GestureDetector( onTap: () async { - var data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: { - "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value, - "isAdd": "1", + final dynamic data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, + 'isAdd': '1', }); if(data != null) { logic.getStaffList(); @@ -62,23 +63,23 @@ class _CheckingInStaffListPageState extends State { SlidableAutoCloseBehavior( child: ListView.separated( itemCount: state.staffListData.value.length, - itemBuilder: (c, index) { - CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index]; + itemBuilder: (BuildContext c, int index) { + final CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index]; return Slidable( key:ValueKey(staffListItem.staffId), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context){ // 1APP 2密码 3卡 4指纹 5人脸 if(staffListItem.attendanceType == 1){ - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (bool isAllData) { logic.deletStaff(staffListItem.staffId!, (isAllData ? 1 : 0)); }); }else{ - ShowTipView().showIosTipWithContentDialog("确定要删除员工吗?".tr, () { + ShowTipView().showIosTipWithContentDialog('确定要删除员工吗?'.tr, () { logic.deletStaff(staffListItem.staffId!, 0); }); // showIosTipViewDialog(staffListItem.staffId!, context); @@ -92,10 +93,10 @@ class _CheckingInStaffListPageState extends State { ], ), child: _checkingInStaffManageItem(staffListItem, () { - Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { - "staffListItem": staffListItem, - "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value, + Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { + 'staffListItem': staffListItem, + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, }); }), ); @@ -108,7 +109,7 @@ class _CheckingInStaffListPageState extends State { // }); // }); }, - separatorBuilder: (context, index) { + separatorBuilder: (BuildContext context, int index) { return Divider(height: 1.h, indent: 20.w, color: AppColors.greyLineColor); }, ), @@ -125,14 +126,14 @@ class _CheckingInStaffListPageState extends State { color: Colors.white, margin: EdgeInsets.only(right: 10.w, top: 10.h, bottom: 10.h), child: Row( - children: [ + children: [ SizedBox(width: 20.w,), // CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w), Image.asset(getTypeIcon(staffListItem.attendanceType!), width: 60.w, height: 60.w), SizedBox(width: 20.w,), Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ SizedBox( width: 1.sw - 20.w - 60.w - 20.w - 30.w, child: Text(staffListItem.staffName!, @@ -153,7 +154,7 @@ class _CheckingInStaffListPageState extends State { borderRadius: BorderRadius.circular(5.w), color: AppColors.openPassageModeColor, ), - child: Text("打卡方式无效".tr, style: TextStyle(fontSize: 18.sp, color: AppColors.appBarIconColor)), + child: Text('打卡方式无效'.tr, style: TextStyle(fontSize: 18.sp, color: AppColors.appBarIconColor)), ), ), ],