fix:修复考勤编辑员工不会自动显示密码卡之类的信息
This commit is contained in:
parent
13d5ce9c36
commit
6019e61f3d
@ -1,36 +1,44 @@
|
|||||||
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(
|
||||||
class CheckingInAddStaffLogic extends BaseGetXController{
|
List<CheckingInAddStaffKeyEntity> selectKeyList);
|
||||||
|
|
||||||
|
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
|
||||||
state.attendanceWayNumber.value = event.number;
|
.on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>()
|
||||||
isCanClickAction();
|
.listen((event) {
|
||||||
});
|
state.attendanceWayNumber.value = event.number;
|
||||||
|
isCanClickAction();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加员工
|
// 添加员工
|
||||||
void addStaffLoadData() async{
|
void addStaffLoadData() async {
|
||||||
var usernameType = "1";
|
var 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 && state.selectPrintingMethodType.value == "1"){
|
if (state.appUnHaveAccount.value &&
|
||||||
|
state.selectPrintingMethodType.value == "1") {
|
||||||
state.attendanceWayNumber.value = state.staffAccountController.text;
|
state.attendanceWayNumber.value = state.staffAccountController.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,36 +49,38 @@ class CheckingInAddStaffLogic extends BaseGetXController{
|
|||||||
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,
|
||||||
);
|
);
|
||||||
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!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 考勤设置添加员工-选择钥匙 1为APP,2为密码,3为卡,4为指纹,返回数据中,attendanceWay分别为用户名、密码、卡号、指纹号
|
// 考勤设置添加员工-选择钥匙 1为APP,2为密码,3为卡,4为指纹,返回数据中,
|
||||||
void addStaffSelectKey(KeyClickCallback kyClickCallback) async{
|
// attendanceWay分别为用户名、密码、卡号、指纹号
|
||||||
|
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,
|
||||||
type:state.selectPrintingMethodType.value,
|
type: state.selectPrintingMethodType.value,
|
||||||
);
|
);
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
state.keyEntity.value = entity.data!;
|
state.keyEntity.value = entity.data!;
|
||||||
kyClickCallback(state.keyEntity.value);
|
kyClickCallback(state.keyEntity.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑员工
|
// 编辑员工
|
||||||
void editStaffLoadData() async{
|
void editStaffLoadData() async {
|
||||||
var usernameType = "1";
|
var usernameType = "1";
|
||||||
if(state.appUnHaveAccount.value && state.staffAccount.contains("@")){
|
if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) {
|
||||||
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 =
|
||||||
}else{
|
state.staffNameIsNotEmpty && state.staffAccountIsNotEmpty;
|
||||||
state.isCanClick.value = state.staffNameIsNotEmpty && state.attendanceWayNumberIsNotEmpty;
|
} else {
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@ -6,7 +5,7 @@ import '../../../../lockMian/entity/lockListInfo_entity.dart';
|
|||||||
import '../checkingInSetStaffList/checkingInStaffList_entity.dart';
|
import '../checkingInSetStaffList/checkingInStaffList_entity.dart';
|
||||||
import 'checkingInAddStaffSelectKey_entity.dart';
|
import 'checkingInAddStaffSelectKey_entity.dart';
|
||||||
|
|
||||||
class CheckingInAddStaffState{
|
class CheckingInAddStaffState {
|
||||||
final getKeyInfosData = LockListInfoItemEntity().obs;
|
final getKeyInfosData = LockListInfoItemEntity().obs;
|
||||||
final companyId = "".obs;
|
final companyId = "".obs;
|
||||||
final staffListItemData = CheckingInAddStaffListItemEntity().obs;
|
final staffListItemData = CheckingInAddStaffListItemEntity().obs;
|
||||||
@ -14,36 +13,41 @@ class CheckingInAddStaffState{
|
|||||||
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 selectPrintingMethodType = "1".obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸
|
||||||
final selectPrintingMethodStr = "APP".obs;// 选择打卡类型字符串
|
final selectPrintingMethodStr = "APP".obs; // 选择打卡类型字符串
|
||||||
|
|
||||||
final countryName = "中国".tr.obs;
|
final countryName = "中国".tr.obs;
|
||||||
final countryCode = "86".obs;
|
final countryCode = "86".obs;
|
||||||
|
|
||||||
final appUnHaveAccount = true.obs;// 默认没有账号
|
final appUnHaveAccount = true.obs; // 默认没有账号
|
||||||
final keyEntity = <CheckingInAddStaffKeyEntity>[].obs;// 选择钥匙数据
|
final keyEntity = <CheckingInAddStaffKeyEntity>[].obs; // 选择钥匙数据
|
||||||
|
|
||||||
final isAdd = "1".obs; // 1添加 2编辑
|
final isAdd = "1".obs; // 1添加 2编辑
|
||||||
final attendanceWayNumber = "".obs;
|
final attendanceWayNumber = "".obs;
|
||||||
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;
|
||||||
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 = staffListItemData.value.attendanceType.toString();
|
selectPrintingMethodType.value =
|
||||||
switch(staffListItemData.value.attendanceType){
|
staffListItemData.value.attendanceType.toString();
|
||||||
|
switch (staffListItemData.value.attendanceType) {
|
||||||
case 1:
|
case 1:
|
||||||
selectPrintingMethodStr.value = "APP";
|
selectPrintingMethodStr.value = "APP";
|
||||||
break;
|
break;
|
||||||
@ -58,17 +62,12 @@ class CheckingInAddStaffState{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
appUnHaveAccount.value = true;
|
appUnHaveAccount.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user