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

View File

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

View File

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

View File

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