1,新增获取单把钥匙详情借口

2,锁设置-基本信息逻辑处理
This commit is contained in:
Daisy 2023-09-04 15:04:44 +08:00
parent d8c68b5ac7
commit cf5b7e6212
7 changed files with 323 additions and 100 deletions

View File

@ -0,0 +1,149 @@
class KeyDetailEntity {
int? errorCode;
String? description;
String? errorMsg;
LockData? data;
KeyDetailEntity({this.errorCode, this.description, this.errorMsg, this.data});
KeyDetailEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? LockData.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class LockData {
int? keyId;
int? lockId;
String? lockName;
String? lockAlias;
int? userType;
int? keyStatus;
int? startDate;
int? endDate;
int? keyRight;
int? keyType;
String? remarks;
int? remoteEnable;
int? appUnlockMustOnline;
int? lockUserNo;
LockItem? lockData;
String? lockMac;
int? noKeyPwd;
int? electricQuantity;
String? featureValue;
String? groupId;
String? groupName;
LockData(
{this.keyId,
this.lockId,
this.lockName,
this.lockAlias,
this.userType,
this.keyStatus,
this.startDate,
this.endDate,
this.keyRight,
this.keyType,
this.remarks,
this.remoteEnable,
this.appUnlockMustOnline,
this.lockUserNo,
this.lockData,
this.lockMac,
this.noKeyPwd,
this.electricQuantity,
this.featureValue,
this.groupId,
this.groupName});
LockData.fromJson(Map<String, dynamic> json) {
keyId = json['keyId'];
lockId = json['lockId'];
lockName = json['lockName'];
lockAlias = json['lockAlias'];
userType = json['userType'];
keyStatus = json['keyStatus'];
json['startDate'] != null ? startDate = json['startDate'] : 0;
json['endDate'] != null ? endDate = json['endDate'] : 0;
keyRight = json['keyRight'];
keyType = json['keyType'];
json['remarks'] != null ? remarks = json['remarks'] : "";
json['remoteEnable'] != null ? remoteEnable = json['remoteEnable'] : 0;
json['appUnlockMustOnline'] != null
? appUnlockMustOnline = json['appUnlockMustOnline']
: 0;
json['lockUserNo'] != null ? lockUserNo = json['lockUserNo'] : 0;
lockData =
json['lockData'] != null ? LockItem.fromJson(json['lockData']) : null;
lockMac = json['lockMac'];
json['noKeyPwd'] != null ? noKeyPwd = json['noKeyPwd'] : 0;
json['electricQuantity'] != null
? electricQuantity = json['electricQuantity']
: 0;
json['featureValue'] != null ? featureValue = json['featureValue'] : "";
json['groupId'] != null ? groupId = json['groupId'] : "";
groupName = json['groupName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['keyId'] = keyId;
data['lockId'] = lockId;
data['lockName'] = lockName;
data['lockAlias'] = lockAlias;
data['userType'] = userType;
data['keyStatus'] = keyStatus;
data['startDate'] = startDate;
data['endDate'] = endDate;
data['keyRight'] = keyRight;
data['keyType'] = keyType;
data['remarks'] = remarks;
data['remoteEnable'] = remoteEnable;
data['appUnlockMustOnline'] = appUnlockMustOnline;
data['lockUserNo'] = lockUserNo;
if (lockData != null) {
data['lockData'] = lockData!.toJson();
}
data['lockMac'] = lockMac;
data['noKeyPwd'] = noKeyPwd;
data['electricQuantity'] = electricQuantity;
data['featureValue'] = featureValue;
data['groupId'] = groupId;
data['groupName'] = groupName;
return data;
}
}
class LockItem {
String? lockName;
String? lockMac;
LockItem({this.lockName, this.lockMac});
LockItem.fromJson(Map<String, dynamic> json) {
lockName = json['lockName'];
lockMac = json['lockMac'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['lockName'] = lockName;
data['lockMac'] = lockMac;
return data;
}
}

View File

@ -1,6 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
@ -19,6 +23,8 @@ class BasicInformationPage extends StatefulWidget {
class _BasicInformationPageState extends State<BasicInformationPage> { class _BasicInformationPageState extends State<BasicInformationPage> {
late String _groupName = ""; late String _groupName = "";
late KeyInfos keyInfo;
late LockMainEntity lockMainEntity;
@override @override
void initState() { void initState() {
@ -28,25 +34,62 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["keyInfo"] != null)) {
keyInfo = obj["keyInfo"];
}
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.basicInformation!.tr, barTitle: TranslationLoader.lanKeys!.basicInformation!.tr,
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: Column( body: FutureBuilder<LockData>(
future: mockNetworkDataRequest(),
builder: (BuildContext context, AsyncSnapshot<LockData> snapshot) {
//
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
//
return const Text('请求失败');
} else {
//
final LockData itemData = snapshot.data!;
return Column(
children: [ children: [
Expanded( Expanded(
child: ListView( child: ListView(
children: [ children: [
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockNumber!.tr, leftTitel:
rightTitle: "MCBN0c_8f3106", TranslationLoader.lanKeys!.lockNumber!.tr,
rightTitle: itemData.lockAlias,
allHeight: 70.h, allHeight: 70.h,
isHaveLine: true), isHaveLine: true),
CommonItem( CommonItem(
leftTitel: "MAC/ID", leftTitel: "MAC/ID",
rightTitle: "53:66:9F:06:31:8F/9418481", rightTitle: itemData.lockMac,
allHeight: 70.h,
isHaveLine: false),
SizedBox(
height: 10.h,
),
CommonItem(
leftTitel: TranslationLoader
.lanKeys!.electricQuantity!.tr,
rightTitle: "${itemData.electricQuantity}%",
isHaveLine: true,
isHaveDirection: true,
action: () {
Navigator.pushNamed(context,
Routers.uploadElectricQuantityPage);
}),
CommonItem(
leftTitel: TranslationLoader
.lanKeys!.periodValidity!.tr,
rightTitle: getUseDateStr(itemData),
allHeight: 70.h, allHeight: 70.h,
isHaveLine: false), isHaveLine: false),
SizedBox( SizedBox(
@ -54,33 +97,20 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
), ),
CommonItem( CommonItem(
leftTitel: leftTitel:
TranslationLoader.lanKeys!.electricQuantity!.tr, TranslationLoader.lanKeys!.lockName!.tr,
rightTitle: "100%", rightTitle: itemData.lockName,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Navigator.pushNamed( Navigator.pushNamed(
context, Routers.uploadElectricQuantityPage); context, Routers.editLockNamePage);
}), }),
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, leftTitel:
rightTitle: "永久", TranslationLoader.lanKeys!.lockGrouping!.tr,
allHeight: 70.h, rightTitle: itemData.groupName == ""
isHaveLine: false), ? _groupName
SizedBox( : itemData.groupName,
height: 10.h,
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockName!.tr,
rightTitle: "MCBN0c_8f3106",
isHaveLine: true,
isHaveDirection: true,
action: () {
Navigator.pushNamed(context, Routers.editLockNamePage);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockGrouping!.tr,
rightTitle: _groupName,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
@ -91,52 +121,81 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
setState(() {}); setState(() {});
}), }),
CommonItem( CommonItem(
leftTitel: leftTitel: TranslationLoader
TranslationLoader.lanKeys!.adminOpenLockPassword!.tr, .lanKeys!.adminOpenLockPassword!.tr,
rightTitle: "", rightTitle: "",
isHaveLine: false, isHaveLine: false,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Navigator.pushNamed( Navigator.pushNamed(context,
context, Routers.adminOpenLockPasswordPage); Routers.adminOpenLockPasswordPage);
}), }),
], ],
), ),
), ),
], ],
));
}
/*
void getLockInfo() async {
var entity = await ApiRepository.to.getLockInfo(
lastUpdateDate: DateTime.now().millisecondsSinceEpoch.toString(),
pageNo: '1',
); );
if (entity.errorCode!.codeIsSuccessful) { }
// if (page == 0) { } else {
// refreshController.refreshCompleted(); // loading
// } else { return Container();
// if (entity.data!.keyInfos!.isEmpty) { }
// refreshController.loadNoData(); }));
// } else { }
// refreshController.loadComplete();
// }
// }
// page++;
if (entity.data!.keyInfos!.isEmpty) { //使
state.dataLength.value = 0; String getUseDateStr(LockData indexEntity) {
} else if (entity.data!.keyInfos!.length == 1) { String useDateStr = '';
state.dataLength.value = 1; if (indexEntity.keyType == 1) {
//
if (indexEntity.startDate != null && indexEntity.endDate != null) {
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
} else { } else {
state.dataLength.value = 2; useDateStr = '限期';
} }
state.lockMainEntity.value = entity; } else if (indexEntity.keyType == 2) {
} else { //
// refreshController.loadFailed(); useDateStr = '永久';
} else if (indexEntity.keyType == 3) {
//
useDateStr = '单次';
} else if (indexEntity.keyType == 4) {
//
useDateStr = '循环';
} }
// refreshController.refreshCompleted();
return useDateStr;
}
//1: 2: 3: 4:
String getKeyTypeStr(int keyType) {
String keyTypeStr = "";
if (keyType == 1) {
keyTypeStr = "限期";
} else if (keyType == 2) {
keyTypeStr = '永久';
} else if (keyType == 3) {
keyTypeStr = '单次';
} else if (keyType == 4) {
keyTypeStr = '循环';
}
return keyTypeStr;
}
//
Future<LockData> mockNetworkDataRequest() async {
KeyDetailEntity entity =
await ApiRepository.to.getKeyDetail(keyInfo.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) {
// print("电子钥匙列表成功:${entity.data?.itemList}");
return entity.data!;
}
LockData data = LockData();
return data;
} }
*/
} }

View File

@ -43,7 +43,9 @@ class _LockSetPageState extends State<LockSetPage> {
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Navigator.pushNamed( Navigator.pushNamed(
context, Routers.basicInformationPage); context, Routers.basicInformationPage, arguments: {
'keyInfo': state.getKeyInfosData.value
});
}), }),
SizedBox( SizedBox(
height: 10.h, height: 10.h,

View File

@ -38,4 +38,5 @@ abstract class Api {
final String updateSettingURL = '/room/updateSetting'; // final String updateSettingURL = '/room/updateSetting'; //
final String keyGroupListURL = '/keyGroup/list'; // final String keyGroupListURL = '/keyGroup/list'; //
final String lockListByGroupURL = '/room/listByGroup'; // final String lockListByGroupURL = '/room/listByGroup'; //
final String getKeyDetailURL = '/key/get'; //
} }

View File

@ -373,6 +373,9 @@ class ApiProvider extends BaseProvider {
Future<Response> lockListByGroup(String type, String keyGroupId) => post( Future<Response> lockListByGroup(String type, String keyGroupId) => post(
lockListByGroupURL.toUrl, lockListByGroupURL.toUrl,
jsonEncode({'type': type, 'keyGroupId': keyGroupId})); jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
Future<Response> getKeyDetail(String lockId) =>
post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId}));
} }
extension ExtensionString on String { extension ExtensionString on String {

View File

@ -2,6 +2,7 @@ import 'package:get/get.dart';
import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart'; import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart';
import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/LockGroupListEntity.dart'; import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/LockGroupListEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
@ -362,4 +363,10 @@ class ApiRepository {
final res = await apiProvider.lockListByGroup(type, keyGroupId); final res = await apiProvider.lockListByGroup(type, keyGroupId);
return PasswordKeyEntity.fromJson(res.body); return PasswordKeyEntity.fromJson(res.body);
} }
//
Future<KeyDetailEntity> getKeyDetail(String lockId) async {
final res = await apiProvider.getKeyDetail(lockId);
return KeyDetailEntity.fromJson(res.body);
}
} }

View File

@ -61,6 +61,8 @@ class CommonItem extends StatelessWidget {
: Text( : Text(
rightTitle!, rightTitle!,
textAlign: TextAlign.end, textAlign: TextAlign.end,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 22.sp,
color: AppColors.darkGrayTextColor), color: AppColors.darkGrayTextColor),