diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart index 0aba9876..c4a05ffe 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart @@ -17,7 +17,8 @@ class AuthorizedAdminListLogic extends BaseGetXController { state.pageNum.toString(), state.pageSize.toString(), '0', - '0'); + '0', + state.searchStr.value); List dataList = []; if (entity.errorCode!.codeIsSuccessful) { print("电子钥匙列表成功:${entity.data?.itemList}"); diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index c67cfbd1..31a49855 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -25,9 +25,6 @@ class _AuthorizedAdminListPageState extends State { final logic = Get.put(AuthorizedAdminListLogic()); final state = Get.find().state; - // late KeyInfos keyInfo; - // late LockMainEntity lockMainEntity; - @override void initState() { super.initState(); @@ -45,14 +42,6 @@ class _AuthorizedAdminListPageState extends State { @override Widget build(BuildContext context) { - // dynamic obj = ModalRoute.of(context)?.settings.arguments; - // if (obj != null && (obj["lockMainEntity"] != null)) { - // lockMainEntity = obj["lockMainEntity"]; - // } - // if (obj != null && (obj["keyInfo"] != null)) { - // keyInfo = obj["keyInfo"]; - // } - return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -88,82 +77,9 @@ class _AuthorizedAdminListPageState extends State { height: 64.h, ) ], - ) - /* - FutureBuilder>( - future: mockNetworkDataRequest(), - builder: (BuildContext context, - AsyncSnapshot> snapshot) { - //请求结束 - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.hasError) { - //请求失败 - return const Text('请求失败'); - } else { - //请求成功 - final List itemData = snapshot.data!; - - return Column( - children: [ - Expanded(child: _buildMainUI(itemData)), - SizedBox( - height: 20.h, - ), - AddBottomWhiteBtn( - btnName: - TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, - onClick: () { - Navigator.pushNamed( - context, Routers.authorizedAdminManagePage, - arguments: { - "lockMainEntity": lockMainEntity, - "keyInfo": keyInfo - }).then((val) { - if (val != null) { - mockNetworkDataRequest(); - setState(() {}); - } - }); - }, - ), - SizedBox( - height: 64.h, - ) - ], - ); - } - } else { - //请求未结束 显示loading - return Container(); - } - }), - */ - ); + )); } - // //请求授权管理员列表 跟电子钥匙列表的接口一样,但必须在参数中加keyRight=1为授权管理员 - // Future> mockNetworkDataRequest() async { - // ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( - // '0', - // keyInfo.keyId.toString(), - // '', - // keyInfo.lockId.toString(), - // '', - // '1', - // '20', - // '0', - // '1'); - // if (entity.errorCode!.codeIsSuccessful) { - // print("电子钥匙列表成功:${entity.data?.itemList}"); - // } - // if (entity.data != null) { - // return entity.data!.itemList; - // } else { - // List dataList = []; - // return dataList; - // } - // } - Widget _buildMainUI(itemData) { List getItemData = itemData; return getItemData.isEmpty diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart index 11bd6b15..47ddc0b9 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart @@ -8,6 +8,7 @@ class AuthorizedAdminListState { var pageNum = 1.obs; //请求页码 final pageSize = 20.obs; //请求每页数据条数 final itemDataList = [].obs; + final searchStr = ''.obs; AuthorizedAdminListState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart index a0e94873..106ea751 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -18,7 +18,8 @@ class ElectronicKeyListLogic extends BaseGetXController { state.pageNum.toString(), state.pageSize.toString(), '0', - '0'); + '0', + state.searchController.text); List dataList = []; if (entity.errorCode!.codeIsSuccessful) { print("电子钥匙列表成功:${entity.data?.itemList}"); diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 1c100b0f..9fa0cf45 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -25,7 +25,6 @@ class _ElectronicKeyListPageState extends State { final logic = Get.put(ElectronicKeyListLogic()); final state = Get.find().state; late RefreshController _refreshController; - // late List itemDataList = []; @override void initState() { @@ -92,73 +91,7 @@ class _ElectronicKeyListPageState extends State { height: 64.h, ) ], - ) - /* - FutureBuilder>( - future: logic.mockNetworkDataRequest(), - builder: (BuildContext context, - AsyncSnapshot> snapshot) { - //请求结束 - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.hasError) { - //请求失败 - return const Text('请求失败'); - } else { - //请求成功 - itemDataList = snapshot.data!; - - return Column( - children: [ - _searchWidget(), - SizedBox( - height: 20.h, - ), - Expanded( - child: itemDataList.isEmpty - ? const NoData() - : SmartRefresher( - controller: _refreshController, - onRefresh: _refresh, - onLoading: _loadMore, - header: ClassicHeader( - height: 45.h, - releaseText: '松开手刷新', - refreshingText: '刷新中', - completeText: '刷新完成', - failedText: '刷新失败', - idleText: '下拉刷新', - ), - child: _buildMainUI(itemDataList), - )), - AddBottomWhiteBtn( - btnName: TranslationLoader.lanKeys!.sendKey!.tr, - onClick: () { - Navigator.pushNamed( - context, Routers.sendElectronicKeyManagePage, - arguments: { - "lockMainEntity": state.lockMainEntity.value, - "keyInfo": state.keyInfo.value - }).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); - } - }); - }, - ), - SizedBox( - height: 64.h, - ) - ], - ); - } - } else { - //请求未结束 显示loading - return Container(); - } - }), - */ - ); + )); } ///加载更多函数 @@ -196,7 +129,10 @@ class _ElectronicKeyListPageState extends State { maxLines: 1, // controller: _controller, autofocus: false, - + controller: state.searchController, + onSubmitted: (value) { + logic.mockNetworkDataRequest(); + }, decoration: InputDecoration( //输入里面输入文字内边距设置 contentPadding: const EdgeInsets.only( diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart index b51f5cef..f3c342a7 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart @@ -1,8 +1,10 @@ +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; class ElectronicKeyListState { + TextEditingController searchController = TextEditingController(); //邮箱/手机号输入框 final keyInfo = KeyInfos().obs; final lockMainEntity = LockMainEntity().obs; var pageNum = 1.obs; //请求页码 diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index e3c7888c..0b21808c 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -8,22 +8,17 @@ class PasswordKeyListLogic extends BaseGetXController { final PasswordKeyListState state = PasswordKeyListState(); //请求密码钥匙列表 - Future> mockNetworkDataRequest() async { + void mockNetworkDataRequest() async { PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList( '0', state.keyInfo.value.lockId.toString(), '0', state.pageNum.toString(), - state.pageSize.toString()); - List dataList = []; + state.pageSize.toString(), + state.searchController.text); if (entity.errorCode!.codeIsSuccessful) { - print("密码钥匙列表成功:${entity.data?.itemList}"); - if (entity.data != null) { - dataList = entity.data!.itemList!; - } + state.itemDataList.value = entity.data!.itemList!; } - state.itemDataList.value = dataList; - return dataList; } //密码钥匙重置请求 diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 86d82868..5b65a89e 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -23,7 +23,6 @@ class PasswordKeyListPage extends StatefulWidget { class _PasswordKeyListPageState extends State { final logic = Get.put(PasswordKeyListLogic()); final state = Get.find().state; - // late List _itemDataList = []; late RefreshController _refreshController; @@ -92,102 +91,32 @@ class _PasswordKeyListPageState extends State { height: 42.h, ) ], - ) - /* - FutureBuilder>( - future: logic.mockNetworkDataRequest(), - builder: (BuildContext context, - AsyncSnapshot> snapshot) { - //请求结束 - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.hasError) { - //请求失败 - return const Text('请求失败'); - } else { - //请求成功 - _itemDataList = snapshot.data!; - - return Column( - children: [ - _searchWidget(), - SizedBox( - height: 20.h, - ), - Expanded( - child: _itemDataList.isEmpty - ? const NoData() - : SmartRefresher( - controller: _refreshController, - onRefresh: _refresh, - onLoading: _loadMore, - enablePullUp: true, - enablePullDown: true, - header: ClassicHeader( - height: 45.h, - releaseText: '松开手刷新', - refreshingText: '刷新中', - completeText: '刷新完成', - failedText: '刷新失败', - idleText: '下拉刷新', - ), - child: _buildMainUI(_itemDataList), - )), - SizedBox( - height: 20.h, - ), - AddBottomWhiteBtn( - btnName: TranslationLoader.lanKeys!.getPassword!.tr, - onClick: () { - Navigator.pushNamed( - context, Routers.passwordKeyManagePage, - arguments: { - "lockMainEntity": state.lockMainEntity.value, - "keyInfo": state.keyInfo.value - }).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); - } - }); - }), - SizedBox( - height: 42.h, - ) - ], - ); - } - } else { - //请求未结束 显示loading - return Container(); - } - }), - */ - ); + )); } - ///加载更多函数 - Future _loadMore() async { - if (state.pageNum.value == 1) { - if (state.itemDataList.length < 10) { - _refreshController.loadComplete(); - } else { - state.pageNum.value++; - await logic.mockNetworkDataRequest(); - _refreshController.loadComplete(); - } - } else { - state.pageNum.value++; - await logic.mockNetworkDataRequest(); - _refreshController.loadComplete(); - } - } + // ///加载更多函数 + // Future _loadMore() async { + // if (state.pageNum.value == 1) { + // if (state.itemDataList.length < 10) { + // _refreshController.loadComplete(); + // } else { + // state.pageNum.value++; + // await logic.mockNetworkDataRequest(); + // _refreshController.loadComplete(); + // } + // } else { + // state.pageNum.value++; + // await logic.mockNetworkDataRequest(); + // _refreshController.loadComplete(); + // } + // } - ///刷新函数 - Future _refresh() async { - state.pageNum.value = 1; - await logic.mockNetworkDataRequest(); - _refreshController.refreshCompleted(); - } + // ///刷新函数 + // Future _refresh() async { + // state.pageNum.value = 1; + // await logic.mockNetworkDataRequest(); + // _refreshController.refreshCompleted(); + // } Widget _searchWidget() { return Container( @@ -200,7 +129,10 @@ class _PasswordKeyListPageState extends State { maxLines: 1, // controller: _controller, autofocus: false, - + controller: state.searchController, + onSubmitted: (value) { + logic.mockNetworkDataRequest(); + }, decoration: InputDecoration( //输入里面输入文字内边距设置 contentPadding: const EdgeInsets.only( diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart index c6c7cde1..de9cc5b5 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart @@ -1,3 +1,4 @@ +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; @@ -8,6 +9,7 @@ class PasswordKeyListState { var pageNum = 1.obs; //请求页码 final pageSize = 20.obs; //请求每页数据条数 final itemDataList = [].obs; + final TextEditingController searchController = TextEditingController(); PasswordKeyListState() { Map map = Get.arguments; diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 2468f419..b203f9f2 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -102,7 +102,8 @@ class ApiProvider extends BaseProvider { String pageNo, String pageSize, String startDate, - String keyRight) => + String keyRight, + String searchStr) => post( electronicKeyListURL.toUrl, jsonEncode({ @@ -114,7 +115,8 @@ class ApiProvider extends BaseProvider { 'pageNo': pageNo, 'pageSize': pageSize, 'startDate': startDate, - 'keyRight': keyRight + 'keyRight': keyRight, + 'searchStr': searchStr })); Future sendElectronicKey( @@ -323,12 +325,12 @@ class ApiProvider extends BaseProvider { post(getWifiServiceIpURL.toUrl, jsonEncode({})); Future passwordKeyList( - String keyStatus, - String lockId, - String operatorUid, - String pageNo, - String pageSize, - ) => + String keyStatus, + String lockId, + String operatorUid, + String pageNo, + String pageSize, + String searchStr) => post( passwordKeyListURL.toUrl, jsonEncode({ @@ -336,7 +338,8 @@ class ApiProvider extends BaseProvider { 'lockId': lockId, 'operatorUid': operatorUid, 'pageNo': pageNo, - 'pageSize': pageSize + 'pageSize': pageSize, + 'searchStr': searchStr })); Future resetPasswordKey(String lockId, String operatorUid) => post( @@ -960,7 +963,7 @@ class ApiProvider extends BaseProvider { // 更新ICCard序号 Future updateIdCardUserNoLoadData( - String lockId, String cardId, String cardUserNo) => + String lockId, String cardId, String cardUserNo) => post( updateICCardUserNoURL.toUrl, jsonEncode( diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index f3424af2..f64e2f05 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -128,9 +128,10 @@ class ApiRepository { String pageNo, String pageSize, String startDate, - String keyRight) async { + String keyRight, + String searchStr) async { final res = await apiProvider.electronicKeyList(endDate, keyId, keyStatus, - lockId, operatorUid, pageNo, pageSize, startDate, keyRight); + lockId, operatorUid, pageNo, pageSize, startDate, keyRight, searchStr); return ElectronicKeyListEntity.fromJson(res.body); } @@ -301,14 +302,14 @@ class ApiRepository { //密码列表 Future passwordKeyList( - String keyStatus, - String lockId, - String operatorUid, - String pageNo, - String pageSize, - ) async { + String keyStatus, + String lockId, + String operatorUid, + String pageNo, + String pageSize, + String searchStr) async { final res = await apiProvider.passwordKeyList( - keyStatus, lockId, operatorUid, pageNo, pageSize); + keyStatus, lockId, operatorUid, pageNo, pageSize, searchStr); return PasswordKeyListEntity.fromJson(res.body); }