fix:修复 第4栏应都要显示,星锁只显示后部分

This commit is contained in:
anfe 2024-05-20 11:04:15 +08:00
parent c978444330
commit b3d0c04ddc
5 changed files with 93 additions and 79 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -4,6 +4,8 @@ import 'dart:ffi';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.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 'package:star_lock/tools/baseGetXController.dart';
import '../../../../../network/api_repository.dart'; import '../../../../../network/api_repository.dart';
import '../../../../../tools/eventBusEventManage.dart'; import '../../../../../tools/eventBusEventManage.dart';
@ -23,30 +25,30 @@ class CheckingInAddStaffLogic extends BaseGetXController {
// eventBus // eventBus
_getNumberEvent = eventBus _getNumberEvent = eventBus
.on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>() .on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>()
.listen((event) { .listen((ChickInAddStaffCardAndFingerprintBlockNumberEvent event) {
state.attendanceWayNumber.value = event.number; state.attendanceWayNumber.value = event.number;
isCanClickAction(); isCanClickAction();
}); });
} }
// //
void addStaffLoadData() async { Future<void> addStaffLoadData() async {
var usernameType = "1"; String usernameType = '1';
if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) { if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) {
usernameType = "2"; usernameType = '2';
} }
// app且没有钥匙时attendanceWayNumber // app且没有钥匙时attendanceWayNumber
if (state.appUnHaveAccount.value && if (state.appUnHaveAccount.value &&
state.selectPrintingMethodType.value == "1") { state.selectPrintingMethodType.value == '1') {
state.attendanceWayNumber.value = state.staffAccountController.text; state.attendanceWayNumber.value = state.staffAccountController.text;
} }
var entity = await ApiRepository.to.addStaffData( final LoginEntity entity = await ApiRepository.to.addStaffData(
attendanceType: state.selectPrintingMethodType.value, attendanceType: state.selectPrintingMethodType.value,
attendanceWay: state.attendanceWayNumber.value, attendanceWay: state.attendanceWayNumber.value,
companyId: state.companyId.value, companyId: state.companyId.value,
have: state.appUnHaveAccount.value ? "2" : "1", have: state.appUnHaveAccount.value ? '2' : '1',
staffName: state.staffNameController.text, staffName: state.staffNameController.text,
countryCode: state.countryCode.value, countryCode: state.countryCode.value,
usernameType: usernameType, usernameType: usernameType,
@ -54,7 +56,7 @@ class CheckingInAddStaffLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshCheckInSetDataEvent()); eventBus.fire(RefreshCheckInSetDataEvent());
eventBus.fire(RefreshCheckInListEvent()); eventBus.fire(RefreshCheckInListEvent());
Get.back(result: "addScuess"); Get.back(result: 'addScuess');
} else if (entity.errorCode! == 425) { } else if (entity.errorCode! == 425) {
showToast(entity.errorMsg!); showToast(entity.errorMsg!);
} }
@ -62,8 +64,9 @@ class CheckingInAddStaffLogic extends BaseGetXController {
// - 1APP234 // - 1APP234
// attendanceWay分别为用户名 // attendanceWay分别为用户名
void addStaffSelectKey(KeyClickCallback kyClickCallback) async { Future<void> addStaffSelectKey(KeyClickCallback kyClickCallback) async {
var entity = await ApiRepository.to.addStaffSelectKeyData( final CheckingInAddStaffSelectKeyEntity entity =
await ApiRepository.to.addStaffSelectKeyData(
companyId: state.companyId.value, companyId: state.companyId.value,
type: state.selectPrintingMethodType.value, type: state.selectPrintingMethodType.value,
); );
@ -74,18 +77,17 @@ class CheckingInAddStaffLogic extends BaseGetXController {
} }
// //
void editStaffLoadData() async { Future<void> editStaffLoadData() async {
var usernameType = "1"; String usernameType = '1';
if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) { if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) {
usernameType = "2"; usernameType = '2';
} }
final LoginEntity entity = await ApiRepository.to.editStaffData(
var entity = await ApiRepository.to.editStaffData(
attendanceType: state.selectPrintingMethodType.value, attendanceType: state.selectPrintingMethodType.value,
attendanceWay: state.attendanceWayNumber.value, attendanceWay: state.attendanceWayNumber.value,
staffId: state.staffListItemData.value.staffId.toString(), staffId: state.staffListItemData.value.staffId.toString(),
have: state.appUnHaveAccount.value ? "2" : "1", have: state.appUnHaveAccount.value ? '2' : '1',
staffName: state.staffNameController.text, staffName: state.staffNameController.text,
countryCode: state.countryCode.value, countryCode: state.countryCode.value,
usernameType: usernameType, usernameType: usernameType,
@ -99,13 +101,13 @@ class CheckingInAddStaffLogic extends BaseGetXController {
} }
// //
void getKeyboardPwdRequest() async { Future<void> getKeyboardPwdRequest() async {
if (state.staffNameController.text.isEmpty) { if (state.staffNameController.text.isEmpty) {
showToast("请输入姓名"); showToast('请输入姓名');
return; return;
} }
var entity = await ApiRepository.to.getPasswordKey( final PasswordKeyEntity entity = await ApiRepository.to.getPasswordKey(
endDate: "0", endDate: '0',
keyboardPwdName: state.staffNameController.text, keyboardPwdName: state.staffNameController.text,
keyboardPwdType: 2.toString(), keyboardPwdType: 2.toString(),
lockId: state.getKeyInfosData.value.lockId.toString(), lockId: state.getKeyInfosData.value.lockId.toString(),
@ -136,7 +138,7 @@ class CheckingInAddStaffLogic extends BaseGetXController {
// //
void isCanClickAction() { void isCanClickAction() {
if (state.selectPrintingMethodType.value == "1" && if (state.selectPrintingMethodType.value == '1' &&
state.appUnHaveAccount.value) { state.appUnHaveAccount.value) {
// //
state.isCanClick.value = state.isCanClick.value =
@ -154,6 +156,8 @@ class CheckingInAddStaffLogic extends BaseGetXController {
_initLoadDataAction(); _initLoadDataAction();
changeInput(state.staffNameController); changeInput(state.staffNameController);
} }
@override @override

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.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/checkingInAddStaffSelectKey_entity.dart';
@ -62,7 +63,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
if (state.getKeyInfosData.value.lockName!.contains('T9A')) { if (state.getKeyInfosData.value.lockName!.contains('T9A')) {
list.add('人脸'.tr); list.add('人脸'.tr);
} }
_showSelectClockInType(list, list, '1', '选择钥匙'.tr); _showSelectClockInType(list, list, list, '1', '选择钥匙'.tr);
})), })),
SizedBox(height: 10.h), SizedBox(height: 10.h),
//App //App
@ -96,10 +97,8 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
))), ))),
// App时且没有钥匙的时候 // App时且没有钥匙的时候
Obx(() => Visibility( Obx(() => Visibility(
visible: (state.appUnHaveAccount.value && visible: state.appUnHaveAccount.value &&
state.selectPrintingMethodType.value == '1') state.selectPrintingMethodType.value == '1',
? true
: false,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
CommonItem( CommonItem(
@ -166,7 +165,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
return; return;
} }
final data = await Get.toNamed( final dynamic data = await Get.toNamed(
Routers.addCardPage, Routers.addCardPage,
arguments: <String, Object?>{ arguments: <String, Object?>{
'lockId': 'lockId':
@ -228,9 +227,14 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
// //
Obx(() { Obx(() {
final bool isPass = state.selectPrintingMethodType.value == '2'; 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) { if (isPass) {
rightTitle = showPass(rightTitle); attendanceWayNumber = showPass(attendanceWayNumber);
}
String rightTitle = attendanceWayNumber;
if (attendanceWayName.trim() != '') {
rightTitle = '$attendanceWayName - ' + rightTitle;
} }
return Visibility( return Visibility(
visible: !state.appUnHaveAccount.value, visible: !state.appUnHaveAccount.value,
@ -243,6 +247,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
logic.addStaffSelectKey( logic.addStaffSelectKey(
(List<CheckingInAddStaffKeyEntity> v) { (List<CheckingInAddStaffKeyEntity> v) {
final List<String> showList = <String>[]; final List<String> showList = <String>[];
final List<String> nameList = <String>[];
final List<String> numberList = <String>[]; final List<String> numberList = <String>[];
for (final CheckingInAddStaffKeyEntity element in v) { for (final CheckingInAddStaffKeyEntity element in v) {
final bool isPass = final bool isPass =
@ -252,12 +257,13 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
attendanceWay = showPass(attendanceWay); attendanceWay = showPass(attendanceWay);
} }
final String text = final String text =
'${element.staffName}-$attendanceWay'; '${element.staffName} - $attendanceWay';
showList.add(text); showList.add(text);
numberList.add(element.attendanceWay ?? ''); numberList.add(element.attendanceWay ?? '');
nameList.add(element.staffName ?? '');
} }
_showSelectClockInType(showList, numberList, '2', _showSelectClockInType(showList, numberList, nameList,
addStaffSelectKeySelectClockInType()); '2', addStaffSelectKeySelectClockInType());
}); });
}), }),
); );
@ -344,8 +350,8 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
} }
// type 1 2 // type 1 2
void _showSelectClockInType(List showList, List numberList, void _showSelectClockInType(List<String> showList, List<String> numberList,
String showBottomSheetToolType, String title) { List<String> nameList, String showBottomSheetToolType, String title) {
ShowBottomSheetTool().showSingleRowPicker( ShowBottomSheetTool().showSingleRowPicker(
// //
context, context,
@ -364,8 +370,10 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
if (showBottomSheetToolType == '1') { if (showBottomSheetToolType == '1') {
state.selectPrintingMethodType.value = (index + 1).toString(); state.selectPrintingMethodType.value = (index + 1).toString();
state.selectPrintingMethodStr.value = str.toString(); state.selectPrintingMethodStr.value = str.toString();
state.attendanceWayName.value = '';
state.attendanceWayNumber.value = ''; state.attendanceWayNumber.value = '';
} else { } else {
state.attendanceWayName.value = nameList[index].toString();
state.attendanceWayNumber.value = numberList[index].toString(); state.attendanceWayNumber.value = numberList[index].toString();
} }
logic.isCanClickAction(); logic.isCanClickAction();

View File

@ -6,27 +6,28 @@ import '../checkingInSetStaffList/checkingInStaffList_entity.dart';
import 'checkingInAddStaffSelectKey_entity.dart'; import 'checkingInAddStaffSelectKey_entity.dart';
class CheckingInAddStaffState { class CheckingInAddStaffState {
final getKeyInfosData = LockListInfoItemEntity().obs; final Rx<LockListInfoItemEntity> getKeyInfosData = LockListInfoItemEntity().obs;
final companyId = "".obs; final RxString companyId = ''.obs;
final staffListItemData = CheckingInAddStaffListItemEntity().obs; final Rx<CheckingInAddStaffListItemEntity> staffListItemData = CheckingInAddStaffListItemEntity().obs;
final TextEditingController staffNameController = TextEditingController(); final TextEditingController staffNameController = TextEditingController();
final TextEditingController staffAccountController = TextEditingController(); final TextEditingController staffAccountController = TextEditingController();
final selectPrintingMethodType = "1".obs; // 1APP 2 3 4 5 final RxString selectPrintingMethodType = '1'.obs; // 1APP 2 3 4 5
final selectPrintingMethodStr = "APP".obs; // final RxString selectPrintingMethodStr = 'APP'.obs; //
final countryName = "中国".tr.obs; final RxString countryName = '中国'.tr.obs;
final countryCode = "86".obs; final RxString countryCode = '86'.obs;
final appUnHaveAccount = true.obs; // final RxBool appUnHaveAccount = true.obs; //
final keyEntity = <CheckingInAddStaffKeyEntity>[].obs; // final RxList<CheckingInAddStaffKeyEntity> keyEntity = <CheckingInAddStaffKeyEntity>[].obs; //
final isAdd = "1".obs; // 1 2 final RxString isAdd = '1'.obs; // 1 2
final attendanceWayNumber = "".obs; final RxString attendanceWayName = ''.obs;
final isCanClick = false.obs; final RxString attendanceWayNumber = ''.obs;
var staffName = ''.obs; final RxBool isCanClick = false.obs;
var staffAccount = ''.obs; RxString staffName = ''.obs;
RxString staffAccount = ''.obs;
bool get staffNameIsNotEmpty => staffName.value.isNotEmpty; bool get staffNameIsNotEmpty => staffName.value.isNotEmpty;
@ -37,28 +38,28 @@ class CheckingInAddStaffState {
CheckingInAddStaffState() { CheckingInAddStaffState() {
Map map = Get.arguments; Map map = Get.arguments;
getKeyInfosData.value = map["getKeyInfosData"]; getKeyInfosData.value = map['getKeyInfosData'];
companyId.value = map["companyId"]; companyId.value = map['companyId'];
isAdd.value = map["isAdd"]; isAdd.value = map['isAdd'];
if (isAdd.value == "2") { if (isAdd.value == '2') {
staffListItemData.value = map["staffListItem"]; staffListItemData.value = map['staffListItem'];
staffNameController.text = staffListItemData.value.staffName!; staffNameController.text = staffListItemData.value.staffName!;
selectPrintingMethodType.value = selectPrintingMethodType.value =
staffListItemData.value.attendanceType.toString(); staffListItemData.value.attendanceType.toString();
switch (staffListItemData.value.attendanceType) { switch (staffListItemData.value.attendanceType) {
case 1: case 1:
selectPrintingMethodStr.value = "APP"; selectPrintingMethodStr.value = 'APP';
break; break;
case 2: case 2:
selectPrintingMethodStr.value = "密码".tr; selectPrintingMethodStr.value = '密码'.tr;
break; break;
case 3: case 3:
selectPrintingMethodStr.value = "".tr; selectPrintingMethodStr.value = ''.tr;
break; break;
case 4: case 4:
selectPrintingMethodStr.value = "指纹".tr; selectPrintingMethodStr.value = '指纹'.tr;
break; break;
} }

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.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 'package:star_lock/tools/showTipView.dart';
import '../../../../../appRouters.dart'; import '../../../../../appRouters.dart';
@ -23,8 +24,8 @@ class CheckingInStaffListPage extends StatefulWidget {
} }
class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> { class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
final logic = Get.put(CheckingInStaffManageLogic()); final CheckingInStaffManageLogic logic = Get.put(CheckingInStaffManageLogic());
final state = Get.find<CheckingInStaffManageLogic>().state; final CheckingInStaffManageState state = Get.find<CheckingInStaffManageLogic>().state;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -34,13 +35,13 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
barTitle: TranslationLoader.lanKeys!.staff!.tr, barTitle: TranslationLoader.lanKeys!.staff!.tr,
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor, backgroundColor: AppColors.mainColor,
actionsList: [ actionsList: <Widget>[
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
var data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: { final dynamic data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: <String, Object>{
"getKeyInfosData": state.getKeyInfosData.value, 'getKeyInfosData': state.getKeyInfosData.value,
"companyId": state.companyId.value, 'companyId': state.companyId.value,
"isAdd": "1", 'isAdd': '1',
}); });
if(data != null) { if(data != null) {
logic.getStaffList(); logic.getStaffList();
@ -62,23 +63,23 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
SlidableAutoCloseBehavior( SlidableAutoCloseBehavior(
child: ListView.separated( child: ListView.separated(
itemCount: state.staffListData.value.length, itemCount: state.staffListData.value.length,
itemBuilder: (c, index) { itemBuilder: (BuildContext c, int index) {
CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index]; final CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index];
return Slidable( return Slidable(
key:ValueKey(staffListItem.staffId), key:ValueKey(staffListItem.staffId),
endActionPane: ActionPane( endActionPane: ActionPane(
extentRatio: 0.2, extentRatio: 0.2,
motion: const ScrollMotion(), motion: const ScrollMotion(),
children: [ children: <Widget>[
SlidableAction( SlidableAction(
onPressed: (BuildContext context){ onPressed: (BuildContext context){
// 1APP 2 3 4 5 // 1APP 2 3 4 5
if(staffListItem.attendanceType == 1){ if(staffListItem.attendanceType == 1){
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (isAllData) { ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (bool isAllData) {
logic.deletStaff(staffListItem.staffId!, (isAllData ? 1 : 0)); logic.deletStaff(staffListItem.staffId!, (isAllData ? 1 : 0));
}); });
}else{ }else{
ShowTipView().showIosTipWithContentDialog("确定要删除员工吗?".tr, () { ShowTipView().showIosTipWithContentDialog('确定要删除员工吗?'.tr, () {
logic.deletStaff(staffListItem.staffId!, 0); logic.deletStaff(staffListItem.staffId!, 0);
}); });
// showIosTipViewDialog(staffListItem.staffId!, context); // showIosTipViewDialog(staffListItem.staffId!, context);
@ -92,10 +93,10 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
], ],
), ),
child: _checkingInStaffManageItem(staffListItem, () { child: _checkingInStaffManageItem(staffListItem, () {
Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { Get.toNamed(Routers.checkingInStaffDetailPage, arguments: <String, Object>{
"staffListItem": staffListItem, 'staffListItem': staffListItem,
"getKeyInfosData": state.getKeyInfosData.value, 'getKeyInfosData': state.getKeyInfosData.value,
"companyId": state.companyId.value, 'companyId': state.companyId.value,
}); });
}), }),
); );
@ -108,7 +109,7 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
// }); // });
// }); // });
}, },
separatorBuilder: (context, index) { separatorBuilder: (BuildContext context, int index) {
return Divider(height: 1.h, indent: 20.w, color: AppColors.greyLineColor); return Divider(height: 1.h, indent: 20.w, color: AppColors.greyLineColor);
}, },
), ),
@ -125,14 +126,14 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
color: Colors.white, color: Colors.white,
margin: EdgeInsets.only(right: 10.w, top: 10.h, bottom: 10.h), margin: EdgeInsets.only(right: 10.w, top: 10.h, bottom: 10.h),
child: Row( child: Row(
children: [ children: <Widget>[
SizedBox(width: 20.w,), SizedBox(width: 20.w,),
// CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w), // CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w),
Image.asset(getTypeIcon(staffListItem.attendanceType!), width: 60.w, height: 60.w), Image.asset(getTypeIcon(staffListItem.attendanceType!), width: 60.w, height: 60.w),
SizedBox(width: 20.w,), SizedBox(width: 20.w,),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: <Widget>[
SizedBox( SizedBox(
width: 1.sw - 20.w - 60.w - 20.w - 30.w, width: 1.sw - 20.w - 60.w - 20.w - 30.w,
child: Text(staffListItem.staffName!, child: Text(staffListItem.staffName!,
@ -153,7 +154,7 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
borderRadius: BorderRadius.circular(5.w), borderRadius: BorderRadius.circular(5.w),
color: AppColors.openPassageModeColor, 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)),
), ),
), ),
], ],