fix:修复考勤编辑员工不会自动显示密码卡之类的信息

This commit is contained in:
anfe 2024-05-15 15:07:19 +08:00
parent 13d5ce9c36
commit 6019e61f3d
3 changed files with 57 additions and 47 deletions

View File

@ -1,22 +1,29 @@
import 'dart:async'; import 'dart:async';
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/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';
import 'checkingInAddStaffSelectKey_entity.dart'; import 'checkingInAddStaffSelectKey_entity.dart';
import 'checkingInAddStaff_state.dart'; import 'checkingInAddStaff_state.dart';
typedef KeyClickCallback = void Function(List<CheckingInAddStaffKeyEntity> selectKeyList); typedef KeyClickCallback = void Function(
List<CheckingInAddStaffKeyEntity> selectKeyList);
class CheckingInAddStaffLogic extends BaseGetXController { class CheckingInAddStaffLogic extends BaseGetXController {
CheckingInAddStaffState state = CheckingInAddStaffState(); CheckingInAddStaffState state = CheckingInAddStaffState();
// //
StreamSubscription? _getNumberEvent; StreamSubscription? _getNumberEvent;
void _initLoadDataAction() { void _initLoadDataAction() {
// eventBus // eventBus
_getNumberEvent = eventBus.on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>().listen((event) { _getNumberEvent = eventBus
.on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>()
.listen((event) {
state.attendanceWayNumber.value = event.number; state.attendanceWayNumber.value = event.number;
isCanClickAction(); isCanClickAction();
}); });
@ -30,7 +37,8 @@ class CheckingInAddStaffLogic extends BaseGetXController{
} }
// app且没有钥匙时attendanceWayNumber // app且没有钥匙时attendanceWayNumber
if(state.appUnHaveAccount.value && state.selectPrintingMethodType.value == "1"){ if (state.appUnHaveAccount.value &&
state.selectPrintingMethodType.value == "1") {
state.attendanceWayNumber.value = state.staffAccountController.text; state.attendanceWayNumber.value = state.staffAccountController.text;
} }
@ -52,7 +60,8 @@ class CheckingInAddStaffLogic extends BaseGetXController{
} }
} }
// - 1APP234attendanceWay分别为用户名 // - 1APP234
// attendanceWay分别为用户名
void addStaffSelectKey(KeyClickCallback kyClickCallback) async { void addStaffSelectKey(KeyClickCallback kyClickCallback) async {
var entity = await ApiRepository.to.addStaffSelectKeyData( var entity = await ApiRepository.to.addStaffSelectKeyData(
companyId: state.companyId.value, companyId: state.companyId.value,
@ -71,6 +80,7 @@ class CheckingInAddStaffLogic extends BaseGetXController{
usernameType = "2"; usernameType = "2";
} }
var 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,
@ -126,11 +136,14 @@ class CheckingInAddStaffLogic extends BaseGetXController{
// //
void isCanClickAction() { void isCanClickAction() {
if(state.selectPrintingMethodType.value == "1" && state.appUnHaveAccount.value){ if (state.selectPrintingMethodType.value == "1" &&
state.appUnHaveAccount.value) {
// //
state.isCanClick.value = state.staffNameIsNotEmpty && state.staffAccountIsNotEmpty; state.isCanClick.value =
state.staffNameIsNotEmpty && state.staffAccountIsNotEmpty;
} else { } else {
state.isCanClick.value = state.staffNameIsNotEmpty && state.attendanceWayNumberIsNotEmpty; state.isCanClick.value =
state.staffNameIsNotEmpty && state.attendanceWayNumberIsNotEmpty;
} }
} }
@ -145,7 +158,6 @@ class CheckingInAddStaffLogic extends BaseGetXController{
@override @override
void onInit() { void onInit() {
// TODO: implement onInit
super.onInit(); super.onInit();
} }
@ -156,5 +168,4 @@ class CheckingInAddStaffLogic extends BaseGetXController{
_getNumberEvent!.cancel(); _getNumberEvent!.cancel();
} }
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -28,9 +27,13 @@ class CheckingInAddStaffState{
final isCanClick = false.obs; final isCanClick = false.obs;
var staffName = ''.obs; var staffName = ''.obs;
var staffAccount = ''.obs; var staffAccount = ''.obs;
bool get staffNameIsNotEmpty => staffName.value.isNotEmpty; bool get staffNameIsNotEmpty => staffName.value.isNotEmpty;
bool get staffAccountIsNotEmpty => staffAccount.value.isNotEmpty; bool get staffAccountIsNotEmpty => staffAccount.value.isNotEmpty;
bool get attendanceWayNumberIsNotEmpty => attendanceWayNumber.value.isNotEmpty;
bool get attendanceWayNumberIsNotEmpty =>
attendanceWayNumber.value.isNotEmpty;
CheckingInAddStaffState() { CheckingInAddStaffState() {
Map map = Get.arguments; Map map = Get.arguments;
@ -42,7 +45,8 @@ class CheckingInAddStaffState{
staffListItemData.value = map["staffListItem"]; staffListItemData.value = map["staffListItem"];
staffNameController.text = staffListItemData.value.staffName!; staffNameController.text = staffListItemData.value.staffName!;
selectPrintingMethodType.value = staffListItemData.value.attendanceType.toString(); selectPrintingMethodType.value =
staffListItemData.value.attendanceType.toString();
switch (staffListItemData.value.attendanceType) { switch (staffListItemData.value.attendanceType) {
case 1: case 1:
selectPrintingMethodStr.value = "APP"; selectPrintingMethodStr.value = "APP";
@ -59,16 +63,11 @@ class CheckingInAddStaffState{
} }
if (staffListItemData.value.attendanceWay!.isNotEmpty) { if (staffListItemData.value.attendanceWay!.isNotEmpty) {
if(staffListItemData.value.cardStatus != 0){
appUnHaveAccount.value = false; appUnHaveAccount.value = false;
attendanceWayNumber.value = staffListItemData.value.attendanceWay!; attendanceWayNumber.value = staffListItemData.value.attendanceWay!;
} else { } else {
appUnHaveAccount.value = true; appUnHaveAccount.value = true;
} }
}else{
appUnHaveAccount.value = true;
} }
} }
} }
}

View File

@ -37,7 +37,7 @@ class CheckingInAddStaffListItemEntity {
int? staffId; int? staffId;
int? attendanceType; int? attendanceType;
int? countryCode; int? countryCode;
int? cardStatus; int? cardStatus;//0 1
String? attendanceWay; String? attendanceWay;
String? reason; String? reason;