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,36 +1,44 @@
import 'dart:async';
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/tools/baseGetXController.dart';
import '../../../../../network/api_repository.dart';
import '../../../../../tools/eventBusEventManage.dart';
import 'checkingInAddStaffSelectKey_entity.dart';
import 'checkingInAddStaff_state.dart';
typedef KeyClickCallback = void Function(List<CheckingInAddStaffKeyEntity> selectKeyList);
class CheckingInAddStaffLogic extends BaseGetXController{
typedef KeyClickCallback = void Function(
List<CheckingInAddStaffKeyEntity> selectKeyList);
class CheckingInAddStaffLogic extends BaseGetXController {
CheckingInAddStaffState state = CheckingInAddStaffState();
//
StreamSubscription? _getNumberEvent;
void _initLoadDataAction() {
// eventBus
_getNumberEvent = eventBus.on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>().listen((event) {
state.attendanceWayNumber.value = event.number;
isCanClickAction();
});
_getNumberEvent = eventBus
.on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>()
.listen((event) {
state.attendanceWayNumber.value = event.number;
isCanClickAction();
});
}
//
void addStaffLoadData() async{
void addStaffLoadData() async {
var usernameType = "1";
if(state.appUnHaveAccount.value && state.staffAccount.contains("@")){
if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) {
usernameType = "2";
}
// app且没有钥匙时attendanceWayNumber
if(state.appUnHaveAccount.value && state.selectPrintingMethodType.value == "1"){
if (state.appUnHaveAccount.value &&
state.selectPrintingMethodType.value == "1") {
state.attendanceWayNumber.value = state.staffAccountController.text;
}
@ -41,36 +49,38 @@ class CheckingInAddStaffLogic extends BaseGetXController{
have: state.appUnHaveAccount.value ? "2" : "1",
staffName: state.staffNameController.text,
countryCode: state.countryCode.value,
usernameType:usernameType,
usernameType: usernameType,
);
if(entity.errorCode!.codeIsSuccessful){
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshCheckInSetDataEvent());
eventBus.fire(RefreshCheckInListEvent());
Get.back(result: "addScuess");
}else if(entity.errorCode! == 425){
} else if (entity.errorCode! == 425) {
showToast(entity.errorMsg!);
}
}
// - 1APP234attendanceWay分别为用户名
void addStaffSelectKey(KeyClickCallback kyClickCallback) async{
// - 1APP234
// attendanceWay分别为用户名
void addStaffSelectKey(KeyClickCallback kyClickCallback) async {
var entity = await ApiRepository.to.addStaffSelectKeyData(
companyId: state.companyId.value,
type:state.selectPrintingMethodType.value,
type: state.selectPrintingMethodType.value,
);
if(entity.errorCode!.codeIsSuccessful){
if (entity.errorCode!.codeIsSuccessful) {
state.keyEntity.value = entity.data!;
kyClickCallback(state.keyEntity.value);
}
}
//
void editStaffLoadData() async{
void editStaffLoadData() async {
var usernameType = "1";
if(state.appUnHaveAccount.value && state.staffAccount.contains("@")){
if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) {
usernameType = "2";
}
var entity = await ApiRepository.to.editStaffData(
attendanceType: state.selectPrintingMethodType.value,
attendanceWay: state.attendanceWayNumber.value,
@ -126,11 +136,14 @@ class CheckingInAddStaffLogic extends BaseGetXController{
//
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;
}else{
state.isCanClick.value = state.staffNameIsNotEmpty && state.attendanceWayNumberIsNotEmpty;
state.isCanClick.value =
state.staffNameIsNotEmpty && state.staffAccountIsNotEmpty;
} else {
state.isCanClick.value =
state.staffNameIsNotEmpty && state.attendanceWayNumberIsNotEmpty;
}
}
@ -145,7 +158,6 @@ class CheckingInAddStaffLogic extends BaseGetXController{
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@ -156,5 +168,4 @@ class CheckingInAddStaffLogic extends BaseGetXController{
_getNumberEvent!.cancel();
}
}

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@ -6,7 +5,7 @@ import '../../../../lockMian/entity/lockListInfo_entity.dart';
import '../checkingInSetStaffList/checkingInStaffList_entity.dart';
import 'checkingInAddStaffSelectKey_entity.dart';
class CheckingInAddStaffState{
class CheckingInAddStaffState {
final getKeyInfosData = LockListInfoItemEntity().obs;
final companyId = "".obs;
final staffListItemData = CheckingInAddStaffListItemEntity().obs;
@ -14,36 +13,41 @@ class CheckingInAddStaffState{
final TextEditingController staffNameController = TextEditingController();
final TextEditingController staffAccountController = TextEditingController();
final selectPrintingMethodType = "1".obs;// 1APP 2 3 4 5
final selectPrintingMethodStr = "APP".obs;//
final selectPrintingMethodType = "1".obs; // 1APP 2 3 4 5
final selectPrintingMethodStr = "APP".obs; //
final countryName = "中国".tr.obs;
final countryCode = "86".obs;
final appUnHaveAccount = true.obs;//
final keyEntity = <CheckingInAddStaffKeyEntity>[].obs;//
final appUnHaveAccount = true.obs; //
final keyEntity = <CheckingInAddStaffKeyEntity>[].obs; //
final isAdd = "1".obs; // 1 2
final attendanceWayNumber = "".obs;
final isCanClick = false.obs;
var staffName = ''.obs;
var staffAccount = ''.obs;
bool get staffNameIsNotEmpty => staffName.value.isNotEmpty;
bool get staffAccountIsNotEmpty => staffAccount.value.isNotEmpty;
bool get attendanceWayNumberIsNotEmpty => attendanceWayNumber.value.isNotEmpty;
bool get attendanceWayNumberIsNotEmpty =>
attendanceWayNumber.value.isNotEmpty;
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"];
if (isAdd.value == "2") {
staffListItemData.value = map["staffListItem"];
staffNameController.text = staffListItemData.value.staffName!;
selectPrintingMethodType.value = staffListItemData.value.attendanceType.toString();
switch(staffListItemData.value.attendanceType){
selectPrintingMethodType.value =
staffListItemData.value.attendanceType.toString();
switch (staffListItemData.value.attendanceType) {
case 1:
selectPrintingMethodStr.value = "APP";
break;
@ -58,17 +62,12 @@ class CheckingInAddStaffState{
break;
}
if(staffListItemData.value.attendanceWay!.isNotEmpty){
if(staffListItemData.value.cardStatus != 0){
appUnHaveAccount.value = false;
attendanceWayNumber.value = staffListItemData.value.attendanceWay!;
}else{
appUnHaveAccount.value = true;
}
}else{
if (staffListItemData.value.attendanceWay!.isNotEmpty) {
appUnHaveAccount.value = false;
attendanceWayNumber.value = staffListItemData.value.attendanceWay!;
} else {
appUnHaveAccount.value = true;
}
}
}
}

View File

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