魏少阳 fe7cb98cf9 1、修改关于时间的3点讨论结果
a,领锁,点击+号时,如果获取网络时间失败,不进入下一页,提示必须联网
b. 开锁时:有网络时间则同步,无网络则不同步时间
c. 同步时间功能:必须有网才同步时间,确定和通通锁不一致
2、修改登录、注册、修改密码选择跟当前ip不是用一个国家的时候,弹窗提示
2024-06-07 10:53:24 +08:00

170 lines
5.6 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.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';
import 'checkingInAddStaffSelectKey_entity.dart';
import 'checkingInAddStaff_state.dart';
typedef KeyClickCallback = void Function(
List<CheckingInAddStaffKeyEntity> selectKeyList);
class CheckingInAddStaffLogic extends BaseGetXController {
CheckingInAddStaffState state = CheckingInAddStaffState();
// 下级界面修改成功后传递数据
StreamSubscription? _getNumberEvent;
void _initLoadDataAction() {
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
_getNumberEvent = eventBus
.on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>()
.listen((ChickInAddStaffCardAndFingerprintBlockNumberEvent event) {
state.attendanceWayNumber.value = event.number;
isCanClickAction();
});
}
// 添加员工
Future<void> 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.attendanceWayNumber.value = state.staffAccountController.text;
}
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',
staffName: state.staffNameController.text,
countryCode: state.countryCode.value,
usernameType: usernameType,
);
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshCheckInSetDataEvent());
eventBus.fire(RefreshCheckInListEvent());
Get.back(result: 'addScuess');
} else if (entity.errorCode! == 425) {
showToast(entity.errorMsg!);
}
}
// 考勤设置添加员工-选择钥匙 1为APP2为密码3为卡4为指纹返回数据中
// attendanceWay分别为用户名、密码、卡号、指纹号
Future<void> addStaffSelectKey(KeyClickCallback kyClickCallback) async {
final CheckingInAddStaffSelectKeyEntity entity =
await ApiRepository.to.addStaffSelectKeyData(
companyId: state.companyId.value,
type: state.selectPrintingMethodType.value,
);
if (entity.errorCode!.codeIsSuccessful) {
state.keyEntity.value = entity.data!;
kyClickCallback(state.keyEntity);
}
}
// 编辑员工
Future<void> editStaffLoadData() async {
String usernameType = '1';
if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) {
usernameType = '2';
}
// 当是app且没有钥匙时直接把账号赋值给attendanceWayNumber
if (state.appUnHaveAccount.value &&
state.selectPrintingMethodType.value == '1') {
state.attendanceWayNumber.value = state.staffAccountController.text;
}
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',
staffName: state.staffNameController.text,
countryCode: state.countryCode.value,
usernameType: usernameType,
);
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshCheckInStaffListDataEvent());
Get.close(2);
} else if (entity.errorCode! == 425) {
showToast(entity.errorMsg!);
}
}
//获取密码请求
Future<void> getKeyboardPwdRequest() async {
if (state.staffNameController.text.isEmpty) {
showToast('请输入姓名');
return;
}
final PasswordKeyEntity entity = await ApiRepository.to.getPasswordKey(
endDate: '0',
keyboardPwdName: state.staffNameController.text,
keyboardPwdType: 2.toString(),
lockId: state.getKeyInfosData.value.lockId!,
startDate: '0',
startHours: 0,
endHours: 0,
isCoerced: 1);
if (entity.errorCode!.codeIsSuccessful) {
if (entity.data != null) {
state.attendanceWayNumber.value = entity.data!.keyboardPwd!;
isCanClickAction();
}
} else {
showToast('${entity.errorMsg}');
}
}
void changeInput(TextEditingController controller) {
if (controller == state.staffNameController) {
state.staffName.value = controller.text;
}
if (controller == state.staffAccountController) {
state.staffAccount.value = controller.text;
}
isCanClickAction();
}
// 是否能点击
void isCanClickAction() {
if (state.selectPrintingMethodType.value == '1' &&
state.appUnHaveAccount.value) {
// 没有账号的时候直接判断姓名和账号是否为空
state.isCanClick.value =
state.staffNameIsNotEmpty && state.staffAccountIsNotEmpty;
} else {
state.isCanClick.value =
state.staffNameIsNotEmpty && state.attendanceWayNumberIsNotEmpty;
}
}
@override
void onReady() {
super.onReady();
_initLoadDataAction();
changeInput(state.staffNameController);
}
@override
void onClose() {
super.onClose();
_getNumberEvent!.cancel();
}
}