From 04d2dde5ebb5c47316e263e26498bd39ebfd254b Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 15:04:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E5=BC=80=E9=94=81?= =?UTF-8?q?=E9=A1=B5-=E8=80=83=E5=8B=A4-=E6=97=A5=E6=A6=9C=E5=92=8C?= =?UTF-8?q?=E6=9C=88=E6=A6=9C=E5=88=97=E8=A1=A8=E9=87=8C=E5=A7=93=E5=90=8D?= =?UTF-8?q?=E5=89=8D=E7=9A=84=E5=9B=BE=E5=83=8F=E9=83=BD=E4=B8=80=E6=A0=B7?= =?UTF-8?q?=EF=BC=8C=E5=BA=94=E5=92=8C=E5=91=98=E5=B7=A5=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=87=8C=E4=B8=80=E6=A0=B7=E5=8C=BA=E5=88=86=EF=BC=8C=E5=8F=A6?= =?UTF-8?q?APP=E5=A6=82=E6=9C=89=E5=A4=B4=E5=83=8F=E5=BA=94=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkingInList/checkingInList_page.dart | 530 +++++++++++------- .../checkingInStaffList_page.dart | 214 +++---- 2 files changed, 450 insertions(+), 294 deletions(-) diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart index 20344f94..608da425 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart'; +import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -23,8 +25,8 @@ class CheckingInListPage extends StatefulWidget { } class _CheckingInListPageState extends State { - final logic = Get.put(CheckingInListLogic()); - final state = Get.find().state; + final CheckingInListLogic logic = Get.put(CheckingInListLogic()); + final CheckingInListState state = Get.find().state; @override Widget build(BuildContext context) { @@ -35,26 +37,33 @@ class _CheckingInListPageState extends State { titleWidget: titleWidget(), haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ - (state.getKeyInfosData.value.keyRight == 1) ? - GestureDetector( - onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ - Get.toNamed(Routers.checkingInSetPage, arguments: { - "getKeyInfosData": state.getKeyInfosData.value, - }); - }else{ - // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); - } - }, - child: Image.asset('images/main/icon_lockDetail_checkIn_set.png', width: 36.w, height: 36.w,)) : Container(), + actionsList: [ + (state.getKeyInfosData.value.keyRight == 1) + ? GestureDetector( + onTap: () async { + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + Get.toNamed(Routers.checkingInSetPage, + arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + }); + } else { + // Get.toNamed(Routers.selectLockTypePage); + logic.showToast('演示模式'); + } + }, + child: Image.asset( + 'images/main/icon_lockDetail_checkIn_set.png', + width: 36.w, + height: 36.w, + )) + : Container(), SizedBox(width: 30.w), ], ), body: Column( - children: [ + children: [ topInfo(), SizedBox(height: 10.h), middleDayInfo(), @@ -70,7 +79,7 @@ class _CheckingInListPageState extends State { // height: 280.h, color: Colors.white, child: Column( - children: [ + children: [ SizedBox(height: 30.h), Obx(() => Container( width: 110.w, @@ -80,32 +89,38 @@ class _CheckingInListPageState extends State { color: AppColors.mainColor, borderRadius: BorderRadius.circular(60.w), ), - child: Image.asset(getTopImg(), width: 120.w, height: 120.w) - )), + child: Image.asset(getTopImg(), width: 120.w, height: 120.w))), SizedBox(height: 10.h), - Obx(() => Text(getTopTitle(), style: TextStyle(color: Colors.black, fontSize: 24.sp))), + Obx(() => Text(getTopTitle(), + style: TextStyle(color: Colors.black, fontSize: 24.sp))), SizedBox(height: 30.h), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ // SizedBox(width: 30.w,), Row( - children: [ - SizedBox(width: 20.w,), + children: [ + SizedBox( + width: 20.w, + ), GestureDetector( onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { setState(() { state.isDay.value = true; - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(state.checkListDateTimestamp.value); - String beginDate = formatDate(dateTime, [mm,'-',dd]); + final DateTime dateTime = + DateTime.fromMillisecondsSinceEpoch( + state.checkListDateTimestamp.value); + final String beginDate = + formatDate(dateTime, [mm, '-', dd]); state.checkListDate.value = beginDate; logic.loadDataByType(); }); - }else{ + } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Container( @@ -113,37 +128,47 @@ class _CheckingInListPageState extends State { // height: 100.h, color: Colors.white, child: Obx(() => Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text(TranslationLoader.lanKeys!.dailyCharts!.tr, style: TextStyle(color: state.isDay.value ? AppColors.mainColor : Colors.black, fontSize: 22.sp)), - SizedBox(height: 10.h), - Visibility( - visible: state.isDay.value, - child: Container( - width: 20.w, - height: 2.h, - color: state.isDay.value ? AppColors.mainColor : Colors.black - ), - ) - ], - )), + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text(TranslationLoader.lanKeys!.dailyCharts!.tr, + style: TextStyle( + color: state.isDay.value + ? AppColors.mainColor + : Colors.black, + fontSize: 22.sp)), + SizedBox(height: 10.h), + Visibility( + visible: state.isDay.value, + child: Container( + width: 20.w, + height: 2.h, + color: state.isDay.value + ? AppColors.mainColor + : Colors.black), + ) + ], + )), ), ), // SizedBox(width: 20.w,), GestureDetector( onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { setState(() { state.isDay.value = false; - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(state.checkListDateTimestamp.value); - String beginDate = formatDate(dateTime, [mm]); + final DateTime dateTime = + DateTime.fromMillisecondsSinceEpoch( + state.checkListDateTimestamp.value); + final String beginDate = + formatDate(dateTime, [mm]); state.checkListDate.value = beginDate; logic.loadDataByType(); }); - }else{ + } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Container( @@ -151,49 +176,76 @@ class _CheckingInListPageState extends State { // height: 100.h, color: Colors.white, child: Obx(() => Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text(TranslationLoader.lanKeys!.monthlyLeaderboard!.tr, style: TextStyle(color: !state.isDay.value ? AppColors.mainColor : Colors.black, fontSize: 22.sp)), - SizedBox(height: 10.h), - Visibility( - visible: !state.isDay.value, - child: Container(width: 20.w, height: 2.h, color: !state.isDay.value ? AppColors.mainColor : Colors.black)) - ], - )), + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text( + TranslationLoader + .lanKeys!.monthlyLeaderboard!.tr, + style: TextStyle( + color: !state.isDay.value + ? AppColors.mainColor + : Colors.black, + fontSize: 22.sp)), + SizedBox(height: 10.h), + Visibility( + visible: !state.isDay.value, + child: Container( + width: 20.w, + height: 2.h, + color: !state.isDay.value + ? AppColors.mainColor + : Colors.black)) + ], + )), ), ), ], ), GestureDetector( onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { await showDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return ShowCalendar( datePickerMode: DatePickerMode.day, - selectAction: (dateTime) { + selectAction: (DateTime dateTime) { setState(() { - state.checkListDateTimestamp.value = dateTime.millisecondsSinceEpoch; - String beginDate = formatDate(dateTime, state.isDay.value ? [mm,'-',dd] : [mm]); + state.checkListDateTimestamp.value = + dateTime.millisecondsSinceEpoch; + final String beginDate = formatDate( + dateTime, + state.isDay.value + ? [mm, '-', dd] + : [mm]); state.checkListDate.value = beginDate; logic.loadDataByType(); Get.back(); }); }); }); - }else{ + } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(state.checkListDate.value, style: TextStyle(color: Colors.black, fontSize: 22.sp),), - Image.asset('images/icon_grayPullDown.png', width: 50.w, height: 30.w,), - SizedBox(width: 10.w,), + children: [ + Text( + state.checkListDate.value, + style: TextStyle(color: Colors.black, fontSize: 22.sp), + ), + Image.asset( + 'images/icon_grayPullDown.png', + width: 50.w, + height: 30.w, + ), + SizedBox( + width: 10.w, + ), ], ), ) @@ -207,110 +259,151 @@ class _CheckingInListPageState extends State { Widget middleDayInfo() { return Obx(() => Visibility( - visible: state.isDay.value, - child: Container( - height: 80.h, - color: Colors.white, - margin: EdgeInsets.only(left: 15.h, right: 15.h, bottom: 10.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( + visible: state.isDay.value, + child: Container( + height: 80.h, + color: Colors.white, + margin: EdgeInsets.only(left: 15.h, right: 15.h, bottom: 10.h), + child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - SizedBox(height: 5.h), - Text(state.lateTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.beLate!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox(height: 5.h), + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox(height: 5.h), + Text(state.lateTimes.value, + style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.beLate!.tr, + style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox(height: 5.h), + Text(state.earlyTimes.value, + style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.leaveEarly!.tr, + style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox(height: 5.h), + Text(state.noPunchTimes.value, + style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.noCardPunched!.tr, + style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), + ], + ), ], ), - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - SizedBox(height: 5.h), - Text(state.earlyTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.leaveEarly!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox(height: 5.h), - ], - ), - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - SizedBox(height: 5.h), - Text(state.noPunchTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.noCardPunched!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox(height: 5.h), - ], - ), - ], - ), - ), - )); + ), + )); } - Widget getBottomList(){ - if((state.isDay.value == true && (state.listType.value == "1")) || (state.isDay.value == true && (state.listType.value == "2"))){ + Widget getBottomList() { + if ((state.isDay.value == true && (state.listType.value == '1')) || + (state.isDay.value == true && (state.listType.value == '2'))) { return bottomDayList(); - }else{ + } else { return bottomMonthList(); } } Widget bottomDayList() { - return Obx(() => state.checkingInDayListData.value.isNotEmpty ? ListView.separated( - itemCount: state.checkingInDayListData.value.length, - itemBuilder: (c, index) { - AttendanceRecordDayList attendanceRecordList= state.checkingInDayListData.value[index]; - return _checkingInListItem(index, attendanceRecordList.headurl, attendanceRecordList.staffName, () { - Get.toNamed(Routers.checkingInDetailPage, arguments: { - // "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value, - "staffId": attendanceRecordList.staffId, - "staffName": attendanceRecordList.staffName, + return Obx(() => state.checkingInDayListData.isNotEmpty + ? ListView.separated( + itemCount: state.checkingInDayListData.length, + itemBuilder: (BuildContext c, int index) { + final AttendanceRecordDayList attendanceRecordList = + state.checkingInDayListData[index]; + return _checkingInListItem( + index, + attendanceRecordList.headurl, + attendanceRecordList.staffName, + attendanceRecordList.attendanceType, () { + Get.toNamed(Routers.checkingInDetailPage, + arguments: { + // "getKeyInfosData": state.getKeyInfosData.value, + 'companyId': state.companyId.value, + 'staffId': attendanceRecordList.staffId, + 'staffName': attendanceRecordList.staffName, + }); }); - }); - }, - separatorBuilder: (context, index) { - return const Divider(height: 1, color: AppColors.greyLineColor); - }, - ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight*2 - 64.h - 280.h - 90.h,)); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider(height: 1, color: AppColors.greyLineColor); + }, + ) + : NoData( + noDataHeight: + 1.sh - ScreenUtil().statusBarHeight * 2 - 64.h - 280.h - 90.h, + )); } Widget bottomMonthList() { - return Obx(() => state.checkingInMonthListData.value.isNotEmpty ? ListView.separated( - itemCount: state.checkingInMonthListData.value.length, - itemBuilder: (c, index) { - AttendanceRecordMonthList attendanceRecordList= state.checkingInMonthListData.value[index]; - return _checkingInListItem(index, attendanceRecordList.headurl, attendanceRecordList.staffName, () { - Get.toNamed(Routers.checkingInDetailPage, arguments: { - "companyId": state.companyId.value, - "staffId": attendanceRecordList.staffId, - "staffName": attendanceRecordList.staffName, - }); - }); - }, - separatorBuilder: (context, index) { - return const Divider(height: 1, color: AppColors.greyLineColor); - }, - ) : NoData(noDataHeight: 1.sh - - ScreenUtil().statusBarHeight - 280.h - 90.h,)); + return Obx(() => state.checkingInMonthListData.isNotEmpty + ? ListView.separated( + itemCount: state.checkingInMonthListData.length, + itemBuilder: (BuildContext c, int index) { + final AttendanceRecordMonthList attendanceRecordList = + state.checkingInMonthListData[index]; + return _checkingInListItem( + index, + attendanceRecordList.headurl, + attendanceRecordList.staffName, + attendanceRecordList.attendanceType, () { + Get.toNamed(Routers.checkingInDetailPage, + arguments: { + 'companyId': state.companyId.value, + 'staffId': attendanceRecordList.staffId, + 'staffName': attendanceRecordList.staffName, + }); + }); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider(height: 1, color: AppColors.greyLineColor); + }, + ) + : NoData( + noDataHeight: 1.sh - -ScreenUtil().statusBarHeight - 280.h - 90.h, + )); } - Widget _checkingInListItem(int index, String? headUrl, String? name, Function() action) { + Widget _checkingInListItem( + int index, String? headUrl, String? name, int? type, Function() action) { return GestureDetector( onTap: action, child: Container( // height: 80.h, - padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h, bottom: 10.h), + padding: + EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h, bottom: 10.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.w), ), child: Row( - children: [ - SizedBox(width: 20.w,), - Text("${index+1}", style: TextStyle(fontSize: 20.sp),), - SizedBox(width: 20.w,), - Image.asset('images/controls_user.png', width: 60.w, height: 60.w,), + children: [ + SizedBox( + width: 20.w, + ), + Text( + '${index + 1}', + style: TextStyle(fontSize: 20.sp), + ), + SizedBox( + width: 20.w, + ), + Image.asset( + getTypeIcon(type ?? 0), + width: 60.w, + height: 60.w, + ), // Container( // width: 60.h, // height: 60.h, @@ -328,10 +421,17 @@ class _CheckingInListPageState extends State { // )), SizedBox(width: 20.w), Expanded( - child: Text(name!, style: TextStyle(fontSize: 24.sp),), + child: Text( + name!, + style: TextStyle(fontSize: 24.sp), + ), ), SizedBox(width: 20.h), - Image.asset("images/icon_right_grey.png", width: 21.w, height: 21.w,), + Image.asset( + 'images/icon_right_grey.png', + width: 21.w, + height: 21.w, + ), SizedBox(width: 20.h), ], ), @@ -339,35 +439,71 @@ class _CheckingInListPageState extends State { ); } + // 1APP 2密码 3卡 4指纹 + String getTypeIcon(int type) { + String title = 'images/controls_user.png'; + switch (type) { + case 1: + // 蓝牙开锁 + title = 'images/controls_user.png'; + break; + case 2: + // 密码开锁 + title = 'images/icon_password.png'; + break; + case 3: + // ic卡 + title = 'images/icon_card.png'; + break; + case 4: + // 指纹开锁 + title = 'images/icon_fingerprint.png'; + break; + default: + break; + } + return title; + } + Widget titleWidget() { return GestureDetector( onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { showListType(); - }else{ + } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Obx(() => Container( - // width: 200.w, - // height: 60.h, - color: AppColors.mainColor, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(state.listTypeStr.value, style: TextStyle(color: Colors.white, fontSize: 26.sp),), - SizedBox(width: 5.w,), - Image.asset('images/main/icon_lockDetail_checkIn_topTitle.png', width: 22.w, height: 16.w, fit: BoxFit.fill,) - ], - ), - )), + // width: 200.w, + // height: 60.h, + color: AppColors.mainColor, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + state.listTypeStr.value, + style: TextStyle(color: Colors.white, fontSize: 26.sp), + ), + SizedBox( + width: 5.w, + ), + Image.asset( + 'images/main/icon_lockDetail_checkIn_topTitle.png', + width: 22.w, + height: 16.w, + fit: BoxFit.fill, + ) + ], + ), + )), ); } void showListType() { - var list = [ + final List list = [ TranslationLoader.lanKeys!.earlyArrivalList!.tr, TranslationLoader.lanKeys!.lateList!.tr, TranslationLoader.lanKeys!.hardWorkingList!.tr @@ -385,39 +521,39 @@ class _CheckingInListPageState extends State { //adapter: PickerAdapter(), data: list, //选择事件的回调 - clickCallBack: (int index, var str) { - setState(() { - state.listTypeStr.value = str.toString(); - state.isDay.value = true; - if(index == 0){ - state.listType.value = "1"; - }else if(index == 1){ - state.listType.value = "2"; - }else if(index == 2){ - state.listType.value = "3"; - } - logic.loadDataByType(); - }); - }); + clickCallBack: (int index, Object str) { + setState(() { + state.listTypeStr.value = str.toString(); + state.isDay.value = true; + if (index == 0) { + state.listType.value = '1'; + } else if (index == 1) { + state.listType.value = '2'; + } else if (index == 2) { + state.listType.value = '3'; + } + logic.loadDataByType(); + }); + }); } - String getTopImg(){ - if(state.listType.value == "1"){ - return "images/main/icon_lockDetail_checkInRanking_zd.png"; - }else if(state.listType.value == "2"){ - return "images/main/icon_lockDetail_checkInRanking_cd.png"; - }else{ - return "images/main/icon_lockDetail_checkInRanking_qf.png"; + String getTopImg() { + if (state.listType.value == '1') { + return 'images/main/icon_lockDetail_checkInRanking_zd.png'; + } else if (state.listType.value == '2') { + return 'images/main/icon_lockDetail_checkInRanking_cd.png'; + } else { + return 'images/main/icon_lockDetail_checkInRanking_qf.png'; } } - String getTopTitle(){ - if(state.listType.value == "1"){ - return "无考勤记录"; - }else if(state.listType.value == "2"){ - return "大家干劲十足"; - }else{ - return "工作时长未出炉"; + String getTopTitle() { + if (state.listType.value == '1') { + return '无考勤记录'; + } else if (state.listType.value == '2') { + return '大家干劲十足'; + } else { + return '工作时长未出炉'; } } } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index a1ae4a07..2b0e1afe 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -24,8 +24,10 @@ class CheckingInStaffListPage extends StatefulWidget { } class _CheckingInStaffListPageState extends State { - final CheckingInStaffManageLogic logic = Get.put(CheckingInStaffManageLogic()); - final CheckingInStaffManageState state = Get.find().state; + final CheckingInStaffManageLogic logic = + Get.put(CheckingInStaffManageLogic()); + final CheckingInStaffManageState state = + Get.find().state; @override Widget build(BuildContext context) { @@ -38,12 +40,14 @@ class _CheckingInStaffListPageState extends State { actionsList: [ GestureDetector( onTap: () async { - final dynamic data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: { - 'getKeyInfosData': state.getKeyInfosData.value, - 'companyId': state.companyId.value, - 'isAdd': '1', - }); - if(data != null) { + final dynamic data = await Get.toNamed( + Routers.checkingInAddStaffPage, + arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, + 'isAdd': '1', + }); + if (data != null) { logic.getStaffList(); } }, @@ -59,65 +63,76 @@ class _CheckingInStaffListPageState extends State { ), body: Container( color: Colors.white, - child: Obx(() => state.staffListData.value.isNotEmpty ? - SlidableAutoCloseBehavior( - child: ListView.separated( - itemCount: state.staffListData.value.length, - 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: [ - SlidableAction( - onPressed: (BuildContext context){ - // 1APP 2密码 3卡 4指纹 5人脸 - if(staffListItem.attendanceType == 1){ - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (bool isAllData) { - logic.deletStaff(staffListItem.staffId!, (isAllData ? 1 : 0)); - }); - }else{ - ShowTipView().showIosTipWithContentDialog('确定要删除员工吗?'.tr, () { - logic.deletStaff(staffListItem.staffId!, 0); - }); - // showIosTipViewDialog(staffListItem.staffId!, context); - } - }, - backgroundColor: Colors.red, - foregroundColor: Colors.white, - label: '删除'.tr, - padding: EdgeInsets.only(left: 5.w, right: 5.w), - ), - ], + child: Obx(() => state.staffListData.isNotEmpty + ? SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.staffListData.length, + 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: [ + SlidableAction( + onPressed: (BuildContext context) { + // 1APP 2密码 3卡 4指纹 5人脸 + if (staffListItem.attendanceType == 1) { + ShowTipView() + .showDeleteAdministratorIsHaveAllDataDialog( + '同时删除员工钥匙'.tr, (bool isAllData) { + logic.deletStaff(staffListItem.staffId!, + (isAllData ? 1 : 0)); + }); + } else { + ShowTipView().showIosTipWithContentDialog( + '确定要删除员工吗?'.tr, () { + logic.deletStaff(staffListItem.staffId!, 0); + }); + // showIosTipViewDialog(staffListItem.staffId!, context); + } + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除'.tr, + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _checkingInStaffManageItem(staffListItem, () { + Get.toNamed(Routers.checkingInStaffDetailPage, + arguments: { + 'staffListItem': staffListItem, + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, + }); + }), + ); + + // return _checkingInStaffManageItem(staffListItem, () { + // Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { + // "staffListItem": staffListItem, + // "getKeyInfosData": state.getKeyInfosData.value, + // "companyId": state.companyId.value, + // }); + // }); + }, + separatorBuilder: (BuildContext context, int index) { + return Divider( + height: 1.h, + indent: 20.w, + color: AppColors.greyLineColor); + }, ), - child: _checkingInStaffManageItem(staffListItem, () { - Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { - 'staffListItem': staffListItem, - 'getKeyInfosData': state.getKeyInfosData.value, - 'companyId': state.companyId.value, - }); - }), - ); - - // return _checkingInStaffManageItem(staffListItem, () { - // Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { - // "staffListItem": staffListItem, - // "getKeyInfosData": state.getKeyInfosData.value, - // "companyId": state.companyId.value, - // }); - // }); - }, - separatorBuilder: (BuildContext context, int index) { - return Divider(height: 1.h, indent: 20.w, color: AppColors.greyLineColor); - }, - ), - ) : NoData()), + ) + : NoData()), )); } - Widget _checkingInStaffManageItem(CheckingInAddStaffListItemEntity staffListItem, Function() action) { + Widget _checkingInStaffManageItem( + CheckingInAddStaffListItemEntity staffListItem, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -127,10 +142,15 @@ class _CheckingInStaffListPageState extends State { margin: EdgeInsets.only(right: 10.w, top: 10.h, bottom: 10.h), child: Row( children: [ - SizedBox(width: 20.w,), + 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,), + Image.asset(getTypeIcon(staffListItem.attendanceType!), + width: 60.w, height: 60.w), + SizedBox( + width: 20.w, + ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -139,22 +159,23 @@ class _CheckingInStaffListPageState extends State { child: Text(staffListItem.staffName!, // maxLines: 1, // overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 24.sp) - ) - ), + style: TextStyle(fontSize: 24.sp))), Visibility( - visible: staffListItem.cardStatus == 1 ? true : false, - child: SizedBox(height: 5.h,) - ), + visible: staffListItem.cardStatus == 1, + child: SizedBox( + height: 5.h, + )), Visibility( - visible: staffListItem.cardStatus == 1 ? true : false, + visible: staffListItem.cardStatus == 1, child: Container( padding: EdgeInsets.only(right: 5.w, left: 5.w), decoration: BoxDecoration( 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)), ), ), ], @@ -170,19 +191,19 @@ class _CheckingInStaffListPageState extends State { String title = 'images/controls_user.png'; switch (type) { case 1: - // 蓝牙开锁 + // 蓝牙开锁 title = 'images/controls_user.png'; break; case 2: - // 密码开锁 + // 密码开锁 title = 'images/icon_password.png'; break; case 3: - // ic卡 + // ic卡 title = 'images/icon_card.png'; break; case 4: - // 指纹开锁 + // 指纹开锁 title = 'images/icon_fingerprint.png'; break; default: @@ -191,23 +212,22 @@ class _CheckingInStaffListPageState extends State { return title; } - // void showIosTipViewDialog(int staffId, BuildContext context) { - // showDialog( - // context: context, - // builder: (BuildContext context) { - // return ShowIosTipView( - // title: "提示", - // tipTitle: "确定要删除员工吗?", - // sureClick: () async { - // Get.back(); - // logic.deletStaff(staffId, 0); - // }, - // cancelClick: () { - // Get.back(); - // }, - // ); - // }, - // ); - // } - +// void showIosTipViewDialog(int staffId, BuildContext context) { +// showDialog( +// context: context, +// builder: (BuildContext context) { +// return ShowIosTipView( +// title: "提示", +// tipTitle: "确定要删除员工吗?", +// sureClick: () async { +// Get.back(); +// logic.deletStaff(staffId, 0); +// }, +// cancelClick: () { +// Get.back(); +// }, +// ); +// }, +// ); +// } }