1,新增批量授权锁接口调试及逻辑处理
2,新增锁用户管理列表及用户拥有的锁接口调试
This commit is contained in:
parent
7112fcfdf3
commit
4045a13d8d
@ -452,7 +452,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
value: _isAuthentication,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_isAuthentication = value;
|
||||
_isAuthentication = !_isAuthentication;
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
@ -23,12 +28,25 @@ class VolumeAuthorizationLockPage extends StatefulWidget {
|
||||
class _VolumeAuthorizationLockPageState
|
||||
extends State<VolumeAuthorizationLockPage> {
|
||||
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
||||
final TextEditingController _emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
final TextEditingController _keyNameController =
|
||||
TextEditingController(); //钥匙名输入框
|
||||
late Contact _contact;
|
||||
late List _lockIdList;
|
||||
late bool _isSendSuccess;
|
||||
late bool _isCreateUser; //是否需要创建用户
|
||||
late bool _isRemoteUnlock; //是否远程开锁
|
||||
var _selectEffectiveDate = ''; //生效时间
|
||||
var _selectFailureDate = ''; //失效时间
|
||||
late DateTime _effectiveDateTime;
|
||||
late DateTime _failureDateTime;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return indexChangeWidget();
|
||||
return SingleChildScrollView(
|
||||
child: indexChangeWidget(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -36,16 +54,43 @@ class _VolumeAuthorizationLockPageState
|
||||
super.initState();
|
||||
|
||||
_lockIdList = [];
|
||||
_isRemoteUnlock = false;
|
||||
_isSendSuccess = false;
|
||||
_isCreateUser = false;
|
||||
DateTime dateTime = DateTime.now();
|
||||
_effectiveDateTime = dateTime;
|
||||
_failureDateTime = dateTime;
|
||||
_selectEffectiveDate =
|
||||
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
||||
_selectFailureDate =
|
||||
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.type)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
if (_isSendSuccess) {
|
||||
return sendElectronicKeySucceed();
|
||||
} else {
|
||||
switch (int.parse(widget.type)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
return Column(
|
||||
children: [
|
||||
keyInfoWidget(),
|
||||
remoteUnlockingWidget(),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
keyInfoWidget(),
|
||||
keyTimeWidget(),
|
||||
remoteUnlockingWidget(),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
@ -53,20 +98,7 @@ class _VolumeAuthorizationLockPageState
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
keyInfoWidget(),
|
||||
keyTimeWidget(),
|
||||
remoteUnlockingWidget(),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,13 +113,17 @@ class _VolumeAuthorizationLockPageState
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(
|
||||
true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr)),
|
||||
true,
|
||||
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
|
||||
_emailOrPhoneController)),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
getTFWidget(false, TranslationLoader.lanKeys!.pleaseEnter!.tr)),
|
||||
rightWidget: getTFWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
_keyNameController)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
@ -99,12 +135,33 @@ class _VolumeAuthorizationLockPageState
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: "2020.06.20 11:49",
|
||||
isHaveLine: true),
|
||||
rightTitle: _selectEffectiveDate,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
_selectEffectiveDate =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
_effectiveDateTime = DateTime.parse(_selectEffectiveDate);
|
||||
});
|
||||
});
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: "2020.06.20 11:49",
|
||||
),
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: _selectFailureDate,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
_selectFailureDate =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
_failureDateTime = DateTime.parse(_selectFailureDate);
|
||||
});
|
||||
});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
@ -153,21 +210,23 @@ class _VolumeAuthorizationLockPageState
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
// Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
addAuthorizedAdminRequest();
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(bool isHaveBtn, String tfStr) {
|
||||
return Container(
|
||||
Widget getTFWidget(
|
||||
bool isHaveBtn, String tfStr, TextEditingController editController) {
|
||||
return SizedBox(
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: editController,
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
// controller: _controller,
|
||||
@ -213,18 +272,127 @@ class _VolumeAuthorizationLockPageState
|
||||
);
|
||||
}
|
||||
|
||||
//发送批量授权管理员
|
||||
Future<void> addAuthorizedAdminRequest() async {
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
if (widget.type == '1') {
|
||||
getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime =
|
||||
_effectiveDateTime.millisecondsSinceEpoch.toString();
|
||||
}
|
||||
var entity = await ApiRepository.to.addAuthorizedAdmin(
|
||||
_isCreateUser ? "1" : "0",
|
||||
getFailureDateTime,
|
||||
_isRemoteUnlock == true ? '1' : '2',
|
||||
[],
|
||||
_lockIdList,
|
||||
_keyNameController.text,
|
||||
getEffectiveDateTime,
|
||||
_emailOrPhoneController.text,
|
||||
'86',
|
||||
'1',
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
_isSendSuccess = true;
|
||||
setState(() {});
|
||||
} else {
|
||||
Toast.show(msg: '${entity.errorMsg}');
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
_isCreateUser = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 250.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/icon_send_success.png',
|
||||
width: 100.w,
|
||||
height: 100.w,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"发送成功",
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
onClick: () {
|
||||
_isSendSuccess = false;
|
||||
Navigator.pop(context, true);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
OutLineBtn(
|
||||
btnName: '邮件通知',
|
||||
onClick: () {
|
||||
Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
OutLineBtn(
|
||||
btnName: '微信通知',
|
||||
onClick: () {},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
OutLineBtn(
|
||||
btnName: '标记为已入住',
|
||||
onClick: () {},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
CupertinoSwitch _switch() {
|
||||
bool _isOn = false;
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: _isOn,
|
||||
value: _isRemoteUnlock,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_isOn = value;
|
||||
_isRemoteUnlock = !_isRemoteUnlock;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ class _LockUserListPageState extends State<LockUserListPage> {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
itemData.nickname!,
|
||||
itemData.nickname ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor),
|
||||
)
|
||||
@ -171,7 +171,7 @@ class _LockUserListPageState extends State<LockUserListPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
itemData.userid!,
|
||||
itemData.userid ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor),
|
||||
|
||||
@ -3,7 +3,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.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/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/showTFView.dart';
|
||||
@ -83,7 +82,7 @@ class _LockSeletGroupingPageState extends State<LockSeletGroupingPage> {
|
||||
return ListView.builder(
|
||||
itemCount: itemList.length,
|
||||
itemBuilder: (c, index) {
|
||||
LockGroupItem itemData = itemList[index];
|
||||
GroupListItem itemData = itemList[index];
|
||||
return CommonItem(
|
||||
leftTitel: itemData.keyGroupName,
|
||||
rightTitle: "",
|
||||
@ -108,7 +107,7 @@ class _LockSeletGroupingPageState extends State<LockSeletGroupingPage> {
|
||||
|
||||
//创建锁分组请求
|
||||
Future<void> addLockGroupRequest() async {
|
||||
LockGroupListEntity entity =
|
||||
MassSendLockGroupListEntity entity =
|
||||
await ApiRepository.to.addLockGroup(_changeNameController.text, '0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "创建成功");
|
||||
@ -118,8 +117,8 @@ class _LockSeletGroupingPageState extends State<LockSeletGroupingPage> {
|
||||
}
|
||||
|
||||
//设置锁分组请求
|
||||
Future<void> setLockGroupRequest(LockGroupItem itemData) async {
|
||||
LockGroupListEntity entity = await ApiRepository.to.setLockGroup(
|
||||
Future<void> setLockGroupRequest(GroupListItem itemData) async {
|
||||
MassSendLockGroupListEntity entity = await ApiRepository.to.setLockGroup(
|
||||
_lockData.lockId.toString(), itemData.keyGroupId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "设置锁分组成功");
|
||||
|
||||
@ -0,0 +1,206 @@
|
||||
class KeyListByUserEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
KeyListByUserData? data;
|
||||
|
||||
KeyListByUserEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
KeyListByUserEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
data =
|
||||
json['data'] != null ? KeyListByUserData.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 KeyListByUserData {
|
||||
List<KeyListItem>? keyList;
|
||||
int? pageNo;
|
||||
int? pageSize;
|
||||
int? pages;
|
||||
int? total;
|
||||
|
||||
KeyListByUserData(
|
||||
{this.keyList, this.pageNo, this.pageSize, this.pages, this.total});
|
||||
|
||||
KeyListByUserData.fromJson(Map<String, dynamic> json) {
|
||||
if (json['list'] != null) {
|
||||
keyList = <KeyListItem>[];
|
||||
json['list'].forEach((v) {
|
||||
keyList!.add(KeyListItem.fromJson(v));
|
||||
});
|
||||
}
|
||||
pageNo = json['pageNo'];
|
||||
pageSize = json['pageSize'];
|
||||
pages = json['pages'];
|
||||
total = json['total'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
if (keyList != null) {
|
||||
data['list'] = keyList!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['pageNo'] = pageNo;
|
||||
data['pageSize'] = pageSize;
|
||||
data['pages'] = pages;
|
||||
data['total'] = total;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class KeyListItem {
|
||||
String? clientId;
|
||||
int? lockOwnerId;
|
||||
int? lockId;
|
||||
int? senderUserId;
|
||||
String? keyName;
|
||||
int? keyType;
|
||||
int? startDate;
|
||||
int? endDate;
|
||||
List? weekDays;
|
||||
String? remarks;
|
||||
int? remoteEnable;
|
||||
int? isCameraEnable;
|
||||
int? faceAuthentication;
|
||||
int? keyRight;
|
||||
int? userType;
|
||||
int? keyStatus;
|
||||
int? groupId;
|
||||
int? lockUserNo;
|
||||
int? date;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
UserInfo? userInfo;
|
||||
int? keyId;
|
||||
int? uid;
|
||||
String? lockAlias;
|
||||
|
||||
KeyListItem(
|
||||
{this.clientId,
|
||||
this.lockOwnerId,
|
||||
this.lockId,
|
||||
this.senderUserId,
|
||||
this.keyName,
|
||||
this.keyType,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.weekDays,
|
||||
this.remarks,
|
||||
this.remoteEnable,
|
||||
this.isCameraEnable,
|
||||
this.faceAuthentication,
|
||||
this.keyRight,
|
||||
this.userType,
|
||||
this.keyStatus,
|
||||
this.groupId,
|
||||
this.lockUserNo,
|
||||
this.date,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.userInfo,
|
||||
this.keyId,
|
||||
this.uid,
|
||||
this.lockAlias});
|
||||
|
||||
KeyListItem.fromJson(Map<String, dynamic> json) {
|
||||
clientId = json['clientId'];
|
||||
lockOwnerId = json['lockOwnerId'];
|
||||
lockId = json['lockId'];
|
||||
senderUserId = json['senderUserId'];
|
||||
keyName = json['keyName'];
|
||||
keyType = json['keyType'];
|
||||
startDate = json['startDate'];
|
||||
endDate = json['endDate'];
|
||||
if (json['weekDays'] != null) {
|
||||
weekDays = [];
|
||||
json['weekDays'].forEach((v) {
|
||||
weekDays!.add(v);
|
||||
});
|
||||
}
|
||||
remarks = json['remarks'];
|
||||
remoteEnable = json['remoteEnable'];
|
||||
isCameraEnable = json['isCameraEnable'];
|
||||
faceAuthentication = json['faceAuthentication'];
|
||||
keyRight = json['keyRight'];
|
||||
userType = json['userType'];
|
||||
keyStatus = json['keyStatus'];
|
||||
groupId = json['groupId'];
|
||||
lockUserNo = json['lockUserNo'];
|
||||
date = json['date'];
|
||||
createdAt = json['created_at'];
|
||||
updatedAt = json['updated_at'];
|
||||
userInfo =
|
||||
json['user_info'] != null ? UserInfo.fromJson(json['user_info']) : null;
|
||||
keyId = json['keyId'];
|
||||
uid = json['uid'];
|
||||
lockAlias = json['lockAlias'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['clientId'] = clientId;
|
||||
data['lockOwnerId'] = lockOwnerId;
|
||||
data['lockId'] = lockId;
|
||||
data['senderUserId'] = senderUserId;
|
||||
data['keyName'] = keyName;
|
||||
data['keyType'] = keyType;
|
||||
data['startDate'] = startDate;
|
||||
data['endDate'] = endDate;
|
||||
if (weekDays != null) {
|
||||
data['weekDays'] = weekDays!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['remarks'] = remarks;
|
||||
data['remoteEnable'] = remoteEnable;
|
||||
data['isCameraEnable'] = isCameraEnable;
|
||||
data['faceAuthentication'] = faceAuthentication;
|
||||
data['keyRight'] = keyRight;
|
||||
data['userType'] = userType;
|
||||
data['keyStatus'] = keyStatus;
|
||||
data['groupId'] = groupId;
|
||||
data['lockUserNo'] = lockUserNo;
|
||||
data['date'] = date;
|
||||
data['created_at'] = createdAt;
|
||||
data['updated_at'] = updatedAt;
|
||||
if (userInfo != null) {
|
||||
data['user_info'] = userInfo!.toJson();
|
||||
}
|
||||
data['keyId'] = keyId;
|
||||
data['uid'] = uid;
|
||||
data['lockAlias'] = lockAlias;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class UserInfo {
|
||||
int? id;
|
||||
String? accountName;
|
||||
|
||||
UserInfo({this.id, this.accountName});
|
||||
|
||||
UserInfo.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
accountName = json['account_name'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['account_name'] = accountName;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
@ -17,6 +20,15 @@ class LockUserManageListListPage extends StatefulWidget {
|
||||
|
||||
class _LockUserManageListListPageState
|
||||
extends State<LockUserManageListListPage> {
|
||||
List<LockUserData> dataList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
lockUserListRequest();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -105,12 +117,10 @@ class _LockUserManageListListPageState
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return ListView.separated(
|
||||
itemCount: 5,
|
||||
itemCount: dataList.length,
|
||||
itemBuilder: (c, index) {
|
||||
return _electronicKeyItem('images/controls_user.png', "张三",
|
||||
"2023.6.21 11.15", "2023.6.21 11.15", () {
|
||||
Navigator.pushNamed(context, Routers.ownedKeyListPage);
|
||||
});
|
||||
LockUserData indexEntity = dataList[index];
|
||||
return _electronicKeyItem(indexEntity);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
@ -121,10 +131,24 @@ class _LockUserManageListListPageState
|
||||
);
|
||||
}
|
||||
|
||||
Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle,
|
||||
String beginTime, String endTime, Function() action) {
|
||||
//请求锁用户列表
|
||||
Future<List<LockUserData>> lockUserListRequest() async {
|
||||
LockUserListEntity entity =
|
||||
await ApiRepository.to.lockUserList('1', '20', '');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
setState(() {
|
||||
dataList = entity.data!;
|
||||
});
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
Widget _electronicKeyItem(LockUserData itemData) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, Routers.ownedKeyListPage,
|
||||
arguments: {'uid': itemData.uid});
|
||||
},
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
color: Colors.white,
|
||||
@ -138,7 +162,7 @@ class _LockUserManageListListPageState
|
||||
width: 30.w,
|
||||
),
|
||||
Image.asset(
|
||||
lockTypeIcon,
|
||||
'images/controls_user.png',
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
),
|
||||
@ -153,7 +177,7 @@ class _LockUserManageListListPageState
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
lockTypeTitle,
|
||||
itemData.nickname ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor),
|
||||
),
|
||||
@ -164,7 +188,7 @@ class _LockUserManageListListPageState
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"2023.6.21 11.15 永久",
|
||||
itemData.userid ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor),
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get_utils/get_utils.dart';
|
||||
import 'package:star_lock/mine/mineSet/lockUserManage/keyListByUserEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
|
||||
@ -15,8 +17,23 @@ class OwnedKeyListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
|
||||
String getUidStr = '';
|
||||
List dataList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["uid"] != null)) {
|
||||
getUidStr = obj["uid"].toString();
|
||||
}
|
||||
|
||||
keyListByUserRequest();
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
@ -49,21 +66,59 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//请求用户拥有的锁
|
||||
Future<List<KeyListItem>> keyListByUserRequest() async {
|
||||
KeyListByUserEntity entity =
|
||||
await ApiRepository.to.keyListByUser('1', '20', getUidStr);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
setState(() {
|
||||
dataList = entity.data!.keyList!;
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr(KeyListItem indexEntity) {
|
||||
String useDateStr = '';
|
||||
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 {
|
||||
useDateStr = '限期';
|
||||
}
|
||||
} else if (indexEntity.keyType == 2) {
|
||||
//永久
|
||||
useDateStr = '永久';
|
||||
} else if (indexEntity.keyType == 3) {
|
||||
//单次
|
||||
useDateStr = '单次';
|
||||
} else if (indexEntity.keyType == 4) {
|
||||
//循环
|
||||
useDateStr = '循环';
|
||||
}
|
||||
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return ListView.builder(
|
||||
itemCount: 5,
|
||||
itemCount: dataList.length,
|
||||
itemBuilder: (c, index) {
|
||||
return _electronicKeyItem('images/controls_user.png', "JBL01_5a3de9",
|
||||
"2023.6.21 11.15", "2023.6.21 11.15", () {
|
||||
// Navigator.pushNamed(context, Routers.authorizedAdminDetailPage);
|
||||
});
|
||||
KeyListItem itemData = dataList[index];
|
||||
return _electronicKeyItem(itemData);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle,
|
||||
String beginTime, String endTime, Function() action) {
|
||||
Widget _electronicKeyItem(KeyListItem itemData) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
margin: const EdgeInsets.only(top: 1),
|
||||
@ -77,7 +132,7 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
|
||||
width: 30.w,
|
||||
),
|
||||
Image.asset(
|
||||
lockTypeIcon,
|
||||
'images/icon_lockGroup_item.png',
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
),
|
||||
@ -92,7 +147,7 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
lockTypeTitle,
|
||||
itemData.keyName ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor),
|
||||
),
|
||||
@ -103,7 +158,7 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"2023.6.21 11.15 永久",
|
||||
getUseDateStr(itemData),
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor),
|
||||
|
||||
@ -65,4 +65,6 @@ abstract class Api {
|
||||
final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表
|
||||
final String canSendKeyURL = '/keyUser/canSendKey'; //群发钥匙检查
|
||||
final String batchSendKeyURL = '/key/batchSend'; //批处理群发钥匙
|
||||
final String addAuthorizedAdminURL = '/authorizedAdmin/add'; //增加授权管理员
|
||||
final String keyListByUserURL = '/keyUser/listByUse'; //用户拥有的锁
|
||||
}
|
||||
|
||||
@ -115,7 +115,8 @@ class ApiProvider extends BaseProvider {
|
||||
'pageSize': pageSize,
|
||||
'startDate': startDate,
|
||||
'keyRight': keyRight
|
||||
}));
|
||||
}),
|
||||
isShowLoading: true);
|
||||
|
||||
Future<Response> sendElectronicKey(
|
||||
String createUser,
|
||||
@ -252,7 +253,8 @@ class ApiProvider extends BaseProvider {
|
||||
'keyboardPwdId': keyboardPwdId,
|
||||
'cardId': cardId,
|
||||
'fingerprintId': fingerprintId
|
||||
}));
|
||||
}),
|
||||
isShowLoading: true);
|
||||
|
||||
// 绑定蓝牙管理员
|
||||
Future<Response> bindingBlueAdmin(
|
||||
@ -344,7 +346,8 @@ class ApiProvider extends BaseProvider {
|
||||
'operatorUid': operatorUid,
|
||||
'startDate': startDate,
|
||||
'timezoneRawOffSet': timezoneRawOffSet
|
||||
}));
|
||||
}),
|
||||
isShowLoading: true);
|
||||
|
||||
Future<Response> addKeyboardPwd(
|
||||
String lockId,
|
||||
@ -606,7 +609,8 @@ class ApiProvider extends BaseProvider {
|
||||
jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
|
||||
|
||||
Future<Response> getKeyDetail(String lockId) =>
|
||||
post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId}));
|
||||
post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId}),
|
||||
isShowLoading: true);
|
||||
|
||||
Future<Response> lockUserList(
|
||||
String pageNo, String pageSize, String searchStr) =>
|
||||
@ -618,6 +622,10 @@ class ApiProvider extends BaseProvider {
|
||||
'searchStr': searchStr
|
||||
}));
|
||||
|
||||
Future<Response> keyListByUser(String pageNo, String pageSize, String uid) =>
|
||||
post(keyListByUserURL.toUrl,
|
||||
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize, 'uid': uid}));
|
||||
|
||||
Future<Response> canSendKey(
|
||||
String endDate, List keyGroupIdList, List lockIdList) =>
|
||||
post(
|
||||
@ -655,6 +663,32 @@ class ApiProvider extends BaseProvider {
|
||||
'usernameType': usernameType,
|
||||
'weekDays': weekDays,
|
||||
}));
|
||||
|
||||
Future<Response> addAuthorizedAdmin(
|
||||
String createUser,
|
||||
String endDate,
|
||||
String isRemoteUnlock,
|
||||
List keyGroupIdList,
|
||||
List lockIdList,
|
||||
String name,
|
||||
String startDate,
|
||||
String userid,
|
||||
String countryCode,
|
||||
String usernameType) =>
|
||||
post(
|
||||
addAuthorizedAdminURL.toUrl,
|
||||
jsonEncode({
|
||||
'createUser': createUser,
|
||||
'endDate': endDate,
|
||||
'isRemoteUnlock': isRemoteUnlock,
|
||||
'keyGroupIdList': keyGroupIdList,
|
||||
'lockIdList': lockIdList,
|
||||
'name': name,
|
||||
'startDate': startDate,
|
||||
'userid': userid,
|
||||
'countryCode': countryCode,
|
||||
'usernameType': usernameType
|
||||
}));
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformat
|
||||
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/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/mine/mineSet/lockUserManage/keyListByUserEntity.dart';
|
||||
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
|
||||
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
||||
import '../login/login/entity/LoginEntity.dart';
|
||||
@ -356,17 +357,17 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
//创建锁分组
|
||||
Future<LockGroupListEntity> addLockGroup(
|
||||
Future<MassSendLockGroupListEntity> addLockGroup(
|
||||
String groupName, String operatorUid) async {
|
||||
final res = await apiProvider.addLockGroup(groupName, operatorUid);
|
||||
return LockGroupListEntity.fromJson(res.body);
|
||||
return MassSendLockGroupListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//设置锁分组
|
||||
Future<LockGroupListEntity> setLockGroup(
|
||||
Future<MassSendLockGroupListEntity> setLockGroup(
|
||||
String lockId, String groupId) async {
|
||||
final res = await apiProvider.setLockGroup(lockId, groupId);
|
||||
return LockGroupListEntity.fromJson(res.body);
|
||||
return MassSendLockGroupListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//锁分组列表
|
||||
@ -540,7 +541,14 @@ class ApiRepository {
|
||||
return LockUserListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//群发钥匙检查
|
||||
//用户拥有的锁
|
||||
Future<KeyListByUserEntity> keyListByUser(
|
||||
String pageNo, String pageSize, String uid) async {
|
||||
final res = await apiProvider.keyListByUser(pageNo, pageSize, uid);
|
||||
return KeyListByUserEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//群发电子钥匙检查
|
||||
Future<KeyDetailEntity> canSendKey(
|
||||
String endDate, List keyGroupIdList, List lockIdList) async {
|
||||
final res =
|
||||
@ -548,7 +556,7 @@ class ApiRepository {
|
||||
return KeyDetailEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//群发钥匙检查
|
||||
//群发电子钥匙
|
||||
Future<KeyDetailEntity> batchSendKey(
|
||||
String endDate,
|
||||
List keyGroupIdList,
|
||||
@ -576,6 +584,32 @@ class ApiRepository {
|
||||
return KeyDetailEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//增加授权管理员
|
||||
Future<KeyDetailEntity> addAuthorizedAdmin(
|
||||
String createUser,
|
||||
String endDate,
|
||||
String isRemoteUnlock,
|
||||
List keyGroupIdList,
|
||||
List lockIdList,
|
||||
String name,
|
||||
String startDate,
|
||||
String userid,
|
||||
String countryCode,
|
||||
String usernameType) async {
|
||||
final res = await apiProvider.addAuthorizedAdmin(
|
||||
createUser,
|
||||
endDate,
|
||||
isRemoteUnlock,
|
||||
keyGroupIdList,
|
||||
lockIdList,
|
||||
name,
|
||||
startDate,
|
||||
userid,
|
||||
countryCode,
|
||||
usernameType);
|
||||
return KeyDetailEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 开启考勤 获取考勤信息
|
||||
Future<CheckingInInfoDataEntity> openCheckingInData(
|
||||
{required String lockId}) async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user