diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_page.dart index 69c0ee60..333b888f 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; @@ -23,8 +22,8 @@ class _ExpireFingerprintPageState extends State { final state = Get.find().state; Future getHttpData() async { - logic.expirFingerprintListRequest().then((ExpireFingerprintEntity value){ - if(mounted) setState(() {}); + logic.expirFingerprintListRequest().then((ExpireFingerprintEntity value) { + if (mounted) setState(() {}); }); } @@ -38,56 +37,62 @@ class _ExpireFingerprintPageState extends State { @override Widget build(BuildContext context) { return EasyRefreshTool( - onRefresh: (){ + onRefresh: () { logic.pageNo = 1; getHttpData(); }, - onLoad: (){ + onLoad: () { getHttpData(); }, - child: Obx(() => _buildMainUI()) - ); + child: Obx(() => _buildMainUI())); } Widget _buildMainUI() { return state.dataList.isEmpty - ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + ? NoData( + noDataHeight: 1.sh - + ScreenUtil().statusBarHeight - + ScreenUtil().bottomBarHeight - + 190.h - + 64.h) : SlidableAutoCloseBehavior( - child: ListView.separated( - itemCount: state.dataList.length, - itemBuilder: (c, index) { - ExpireFingerprintItemEntity indexEntity = state.dataList[index]; - return Slidable( - key:ValueKey(indexEntity.uid), - endActionPane: ActionPane( - extentRatio: 0.2, - motion: const ScrollMotion(), - children: [ - SlidableAction( - onPressed: (BuildContext context){ - ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){ - state.deletExpireFingerprintItemEntity = indexEntity; - logic.senderAddFingerprint(); - }); - }, - backgroundColor: Colors.red, - foregroundColor: Colors.white, - label: '删除', - padding: EdgeInsets.only(left: 5.w, right: 5.w), - ), - ], + child: ListView.separated( + itemCount: state.dataList.length, + itemBuilder: (c, index) { + ExpireFingerprintItemEntity indexEntity = state.dataList[index]; + return Slidable( + key: ValueKey(indexEntity.uid), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context) { + ShowTipView().showIosTipWithContentDialog("确定删除指纹吗?", + () { + state.deletExpireFingerprintItemEntity = + indexEntity; + logic.senderAddFingerprint(); + }); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _electronicKeyItem(indexEntity), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, ), - child: _electronicKeyItem(indexEntity), ); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ), - ); } Widget _electronicKeyItem(ExpireFingerprintItemEntity itemData) { @@ -156,8 +161,8 @@ class _ExpireFingerprintPageState extends State { ), Expanded( child: SizedBox( - width: 10.w, - )), + width: 10.w, + )), Text( itemData.lockAlias ?? '', style: TextStyle( @@ -216,8 +221,7 @@ class _ExpireFingerprintPageState extends State { ), child: Text( '余${itemData.expireDate.toString()}天', - style: TextStyle( - color: Colors.white, fontSize: 13.sp), + style: TextStyle(color: Colors.white, fontSize: 13.sp), ), ); } else { @@ -229,12 +233,10 @@ class _ExpireFingerprintPageState extends State { ), child: Text( '已过期', - style: TextStyle( - color: Colors.white, fontSize: 13.sp), + style: TextStyle(color: Colors.white, fontSize: 13.sp), ), ); } // } } - } diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_logic.dart index 6ad96a31..2fc3273e 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_logic.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_logic.dart @@ -1,4 +1,3 @@ - import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; @@ -13,8 +12,9 @@ class ExpirePasswordLogic extends BaseGetXController { //请求即将到期列表 Future expirePasswordListRequest() async { - ExpirePasswordEntity entity = await ApiRepository.to.expirePasswordList(pageNo.toString(), pageSize.toString()); - if(entity.errorCode!.codeIsSuccessful){ + ExpirePasswordEntity entity = await ApiRepository.to + .expirePasswordList(pageNo.toString(), pageSize.toString()); + if (entity.errorCode!.codeIsSuccessful) { if (pageNo == 1) { state.dataList.value = entity.data!.list!; pageNo++; @@ -29,11 +29,12 @@ class ExpirePasswordLogic extends BaseGetXController { } //删除密码请求 deleteType:1-蓝牙 2-网关 - Future deletePwdRequest(ExpirePasswordItemData expirePasswordItemData) async { + Future deletePwdRequest( + ExpirePasswordItemData expirePasswordItemData) async { PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd( - lockId:expirePasswordItemData.lockId.toString(), - keyboardPwdId:expirePasswordItemData.pwdId.toString(), - deleteType:1); + lockId: expirePasswordItemData.lockId.toString(), + keyboardPwdId: expirePasswordItemData.pwdId.toString(), + deleteType: 1); if (entity.errorCode!.codeIsSuccessful) { showToast("删除成功", something: () { pageNo = 1; @@ -46,12 +47,13 @@ class ExpirePasswordLogic extends BaseGetXController { //使用期限 String getExpireDateStr(ExpirePasswordItemData itemData) { String useDateStr = ''; - if(itemData.keyboardPwdType == 4){ + //* getKeyType 单次1 永久2 限期3 删除4 周未循环5 每日循环6 工作日循环7 周一循环8 周二循环9 周三循环10 周四循环11 周五循环12 周六循环13 周天循环14 + if (itemData.keyboardPwdType! > 4) { useDateStr = '循环'; - }else{ - useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; + } else { + useDateStr = + '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; } return useDateStr; } - -} \ No newline at end of file +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_page.dart index c7db1c43..746969b1 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_page.dart @@ -1,10 +1,10 @@ - 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/appRouters.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/tools/EasyRefreshTool.dart'; import 'package:star_lock/tools/noData.dart'; @@ -24,8 +24,8 @@ class _ExpirePasswordPageState extends State { final state = Get.find().state; Future getHttpData() async { - logic.expirePasswordListRequest().then((ExpirePasswordEntity value){ - if(mounted) setState(() {}); + logic.expirePasswordListRequest().then((ExpirePasswordEntity value) { + if (mounted) setState(() {}); }); } @@ -39,67 +39,73 @@ class _ExpirePasswordPageState extends State { @override Widget build(BuildContext context) { return EasyRefreshTool( - onRefresh: (){ + onRefresh: () { logic.pageNo = 1; getHttpData(); }, - onLoad: (){ + onLoad: () { getHttpData(); }, - child: Obx(() => _buildMainUI()) - ); + child: Obx(() => _buildMainUI())); } Widget _buildMainUI() { return state.dataList.isEmpty - ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + ? NoData( + noDataHeight: 1.sh - + ScreenUtil().statusBarHeight - + ScreenUtil().bottomBarHeight - + 190.h - + 64.h) : SlidableAutoCloseBehavior( - child: ListView.separated( - itemCount: state.dataList.length, - itemBuilder: (c, index) { - ExpirePasswordItemData indexEntity = state.dataList[index]; - return Slidable( - key:ValueKey(indexEntity.uid), - endActionPane: ActionPane( - extentRatio: 0.2, - motion: const ScrollMotion(), - children: [ - SlidableAction( - onPressed: (BuildContext context){ - ShowTipView().showIosTipWithContentDialog("确定删除该密码吗?", (){ - logic.deletePwdRequest(indexEntity); - }); - }, - backgroundColor: Colors.red, - foregroundColor: Colors.white, - label: '删除', - padding: EdgeInsets.only(left: 5.w, right: 5.w), - ), - ], + child: ListView.separated( + itemCount: state.dataList.length, + itemBuilder: (c, index) { + ExpirePasswordItemData indexEntity = state.dataList[index]; + return Slidable( + key: ValueKey(indexEntity.uid), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context) { + ShowTipView().showIosTipWithContentDialog("确定删除该密码吗?", + () { + logic.deletePwdRequest(indexEntity); + }); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _electronicKeyItem(indexEntity), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, ), - child: _electronicKeyItem(indexEntity), ); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ), - ); } Widget _electronicKeyItem(ExpirePasswordItemData itemData) { return GestureDetector( onTap: () async { - // if(itemData.keyboardPwdType! == 4){ + // if (itemData.keyboardPwdType! > 4) { // // 循环 - // var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { - // "pushType": 0, - // "expireLockItem": itemData, - // }); - // if(data != null) { + // var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, + // arguments: { + // "pushType": 0, + // "expirePasswordItem": itemData, + // }); + // if (data != null) { // // setState(() { // // state.starDate.value = data["starDate"]; // // state.endDate.value = data["endDate"]; @@ -110,19 +116,20 @@ class _ExpirePasswordPageState extends State { // logic.pageNo = 1; // getHttpData(); // } - // }else{ - // var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: { - // "pushType": 0, - // "expireLockItem": itemData, - // }); - // if(data != null) { - // setState(() { - // // state.starDate.value = data["beginTimeTimestamp"].toString(); - // // state.endDate.value = data["endTimeTimestamp"].toString(); - // // state.keyType.value = 2; - // logic.pageNo = 1; - // getHttpData(); - // }); + // } else { + // var backData = await Get.toNamed( + // Routers.passwordKeyDetailChangeDatePage, + // arguments: { + // 'itemData': itemData, + + // }); + // if (backData != null) { + // itemData.startDate = + // int.parse(backData["beginTimeTimestamp"]) * 1000; + // itemData.endDate = int.parse(backData["endTimeTimestamp"]) * 1000; + // // 改了日期之后,永久只能改限时的 + // itemData.keyboardPwdType = 3; + // setState(() {}); // } // } }, @@ -156,8 +163,8 @@ class _ExpirePasswordPageState extends State { ), Expanded( child: SizedBox( - width: 10.w, - )), + width: 10.w, + )), Text( itemData.lockAlias ?? '', style: TextStyle( @@ -193,48 +200,36 @@ class _ExpirePasswordPageState extends State { } Widget getStatus(ExpirePasswordItemData itemData) { - // if (itemData.keyboardPwdStatus! == 1) { - // return Container( - // padding: EdgeInsets.only(left: 5.w, right: 5.w), - // decoration: BoxDecoration( - // color: Colors.red, - // borderRadius: BorderRadius.circular(2.0), - // ), - // child: Text( - // '未生效', - // style: TextStyle( - // color: Colors.white, fontSize: 13.sp), - // ), - // ); - // } else { - if (itemData.expireDate! > 0) { - return Container( - padding: EdgeInsets.only(left: 5.w, right: 5.w), - decoration: BoxDecoration( - color: AppColors.expireTextBgColor, - borderRadius: BorderRadius.circular(2.0), - ), - child: Text( - '余${itemData.expireDate.toString()}天', - style: TextStyle( - color: Colors.white, fontSize: 13.sp), - ), - ); - } else { - return Container( - padding: EdgeInsets.only(left: 5.w, right: 5.w), - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(2.0), - ), - child: Text( - '已过期', - style: TextStyle( - color: Colors.white, fontSize: 13.sp), - ), - ); - } - // } + //keyboardPwdStatus 1:正常 2:已过期 + return Row( + children: [ + Visibility( + visible: itemData.expireDate! > 0 ? true : false, + child: Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: AppColors.expireTextBgColor, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '余${itemData.expireDate.toString()}天', + style: TextStyle(color: Colors.white, fontSize: 13.sp), + ), + )), + Visibility( + visible: itemData.keyboardPwdStatus! == 2 ? true : false, + child: Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '已过期'.tr, + style: TextStyle(color: Colors.white, fontSize: 13.sp), + ), + )) + ], + ); } - }