1,电子钥匙循环有效期UI及逻辑修改
2,新增全局公用的时间转化格式的方法 3,修改部分请求字段类型
This commit is contained in:
parent
0a855c6af2
commit
b47f8423df
@ -8,10 +8,8 @@ import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addUser.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_protocol/io_transferPermissions.dart';
|
||||
import '../../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
@ -163,7 +161,8 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
|
||||
// 转移权限
|
||||
Future<void> transferPermissionsAction() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -228,33 +227,47 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
|
||||
//发送授权管理员列表请求
|
||||
Future<void> sendElectronicKeyRequest() async {
|
||||
if(state.emailOrPhoneController.text.isEmpty){
|
||||
if (state.emailOrPhoneController.text.isEmpty) {
|
||||
showToast("请输入接收者账号");
|
||||
return;
|
||||
}
|
||||
if(state.keyNameController.text.isEmpty){
|
||||
if (state.keyNameController.text.isEmpty) {
|
||||
showToast("请输入接收者姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
// String getFailureDateTime = '0';
|
||||
// String getEffectiveDateTime = '0';
|
||||
String lockID = state.keyInfo.value.lockId.toString();
|
||||
Get.log("state.type.value:${state.type.value}");
|
||||
String getKeyType = "1";
|
||||
if (state.type.value == '0') {
|
||||
getKeyType = "2";
|
||||
getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime = state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||
// getFailureDateTime =
|
||||
// state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||
// getEffectiveDateTime =
|
||||
// state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||
|
||||
DateTime startDateTime = DateTime(state.effectiveDateTime.value.year, state.effectiveDateTime.value.month, state.effectiveDateTime.value.day, state.effectiveDateTime.value.hour, state.effectiveDateTime.value.minute);
|
||||
DateTime endDateTime = DateTime(state.failureDateTime.value.year, state.failureDateTime.value.month, state.failureDateTime.value.day, state.failureDateTime.value.hour, state.failureDateTime.value.minute);
|
||||
if (!startDateTime.isBefore(endDateTime) || startDateTime.isAtSameMomentAs(endDateTime)) {
|
||||
DateTime startDateTime = DateTime(
|
||||
state.effectiveDateTime.value.year,
|
||||
state.effectiveDateTime.value.month,
|
||||
state.effectiveDateTime.value.day,
|
||||
state.effectiveDateTime.value.hour,
|
||||
state.effectiveDateTime.value.minute);
|
||||
DateTime endDateTime = DateTime(
|
||||
state.failureDateTime.value.year,
|
||||
state.failureDateTime.value.month,
|
||||
state.failureDateTime.value.day,
|
||||
state.failureDateTime.value.hour,
|
||||
state.failureDateTime.value.minute);
|
||||
if (!startDateTime.isBefore(endDateTime) ||
|
||||
startDateTime.isAtSameMomentAs(endDateTime)) {
|
||||
showToast("失效时间需大于生效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!startDateTime.isBefore(DateTime.now()) || startDateTime.isAtSameMomentAs(DateTime.now())) {
|
||||
if (!startDateTime.isBefore(DateTime.now()) ||
|
||||
startDateTime.isAtSameMomentAs(DateTime.now())) {
|
||||
showToast("生效时间需大于当前时间");
|
||||
return;
|
||||
}
|
||||
@ -264,7 +277,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
createUser: state.isCreateUser.value ? "1" : "0",
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: '1',
|
||||
endDate: getFailureDateTime,
|
||||
endDate: state.failureDateTime.value.millisecondsSinceEpoch,
|
||||
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
||||
isCameraEnable: '2',
|
||||
isRemoteUnlock: '2',
|
||||
@ -275,8 +288,10 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
operatorUid: '',
|
||||
receiverUsername: state.emailOrPhoneController.text,
|
||||
remarks: '',
|
||||
startDate: getEffectiveDateTime,
|
||||
weekDays: state.weekdaysList);
|
||||
startDate: state.effectiveDateTime.value.millisecondsSinceEpoch,
|
||||
weekDays: state.weekdaysList,
|
||||
startTime: state.startTime.value,
|
||||
endTime: state.endTime.value);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
state.isSendSuccess.value = true;
|
||||
|
||||
@ -6,6 +6,7 @@ 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/dateUtils.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
@ -134,10 +135,11 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.selectEffectiveDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.effectiveDateTime.value =
|
||||
DateTime.parse(state.selectEffectiveDate.value);
|
||||
state.effectiveDateTime.value = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}',
|
||||
'yyyy-mm-dd HH:mm');
|
||||
state.selectEffectiveDate.value = XSDateUtils.formatDateTime(
|
||||
state.effectiveDateTime.value, 'yyyy-mm-dd HH:mm');
|
||||
});
|
||||
});
|
||||
}),
|
||||
@ -149,10 +151,11 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.selectFailureDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.failureDateTime.value =
|
||||
DateTime.parse(state.selectFailureDate.value);
|
||||
state.failureDateTime.value = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}',
|
||||
'yyyy-mm-dd HH:mm');
|
||||
state.selectFailureDate.value = XSDateUtils.formatDateTime(
|
||||
state.failureDateTime.value, 'yyyy-mm-dd HH:mm');
|
||||
});
|
||||
});
|
||||
}),
|
||||
@ -358,10 +361,18 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp),
|
||||
focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
||||
),
|
||||
// decoration: InputDecoration(
|
||||
@ -424,8 +435,4 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -6,8 +5,10 @@ import 'package:get/get.dart';
|
||||
import '../../../lockMian/entity/lockListInfo_entity.dart';
|
||||
|
||||
class AuthorizedAdminState {
|
||||
final TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框
|
||||
final TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
||||
final TextEditingController emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
final TextEditingController keyNameController =
|
||||
TextEditingController(); //钥匙名输入框
|
||||
|
||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||
late Contact contact;
|
||||
@ -20,8 +21,15 @@ class AuthorizedAdminState {
|
||||
final effectiveDateTime = DateTime.now().obs;
|
||||
final failureDateTime = DateTime.now().obs;
|
||||
|
||||
var selectEffectiveDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; //默认为当前时间
|
||||
var selectFailureDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; //默认为当前时间
|
||||
var selectEffectiveDate =
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
|
||||
.obs; //默认为当前时间
|
||||
var selectFailureDate =
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
|
||||
.obs; //默认为当前时间
|
||||
|
||||
var startTime = 0.obs;
|
||||
var endTime = 0.obs;
|
||||
|
||||
var isSendSuccess = false.obs;
|
||||
var countryName = '中国'.obs;
|
||||
@ -35,4 +43,4 @@ class AuthorizedAdminState {
|
||||
// lockMainEntity.value = map["lockMainEntity"];
|
||||
keyInfo.value = map["keyInfo"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart';
|
||||
import 'package:star_lock/tools/dateUtils.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
@ -81,10 +82,11 @@ class _ElectronicKeyDetailChangeDateState
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.selectEffectiveDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.effectiveDateTime =
|
||||
DateTime.parse(state.selectEffectiveDate.value);
|
||||
state.effectiveDateTime = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}',
|
||||
'yyyy-mm-dd HH:mm');
|
||||
state.selectEffectiveDate.value = XSDateUtils.formatDateTime(
|
||||
state.effectiveDateTime, 'yyyy-mm-dd HH:mm');
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -96,17 +98,14 @@ class _ElectronicKeyDetailChangeDateState
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.selectFailureDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.failureDateTime =
|
||||
DateTime.parse(state.selectFailureDate.value);
|
||||
state.failureDateTime = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}',
|
||||
'yyyy-mm-dd HH:mm');
|
||||
state.selectFailureDate.value = XSDateUtils.formatDateTime(
|
||||
state.failureDateTime, 'yyyy-mm-dd HH:mm');
|
||||
});
|
||||
})),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/KeyPeriodValidityModel.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_logic.dart';
|
||||
import 'package:star_lock/tools/dateUtils.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
@ -52,15 +52,15 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
children: [
|
||||
topWidget(),
|
||||
Container(
|
||||
color: Colors.white,
|
||||
effectiveDateWidget(),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
topWidget(),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
effectiveTimeWidget(),
|
||||
bottomWidget()
|
||||
],
|
||||
));
|
||||
@ -68,7 +68,7 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
|
||||
Widget topWidget() {
|
||||
return Container(
|
||||
height: 150.h,
|
||||
height: 160.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
@ -92,7 +92,11 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
KeyPeriodValidityModel model =
|
||||
state.validityDataList.value[index];
|
||||
return btnItem(model);
|
||||
}))
|
||||
})),
|
||||
Container(
|
||||
color: Colors.white,
|
||||
height: 10.h,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -107,6 +111,7 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
} else {
|
||||
state.selectIndexList.value.remove(model.validityValue);
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
child: Container(
|
||||
@ -135,7 +140,8 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
));
|
||||
}
|
||||
|
||||
Widget bottomWidget() {
|
||||
//生效日期
|
||||
Widget effectiveDateWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
@ -144,14 +150,13 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMD,
|
||||
onConfirm: (p) {
|
||||
state.isHaveEffectiveDate.value = true;
|
||||
state.effectiveDateTime.value = DateTime.parse(
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||
state.selectEffectiveDate.value = formatDate(
|
||||
state.effectiveDateTime.value,
|
||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
||||
state.effectiveDate.value = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day!}', 'yyyy-mm-dd');
|
||||
state.selectEffectiveDate.value = XSDateUtils.formatDateTime(
|
||||
state.effectiveDate.value, 'yyyy-mm-dd');
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -159,16 +164,59 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
rightTitle: state.selectFailureDate.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMD,
|
||||
onConfirm: (p) {
|
||||
state.isHaveFailureDate.value = true;
|
||||
state.failureDateTime.value = DateTime.parse(
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||
state.selectFailureDate.value = formatDate(
|
||||
state.failureDateTime.value,
|
||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
||||
state.failureDate.value = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day!}', 'yyyy-mm-dd');
|
||||
state.selectFailureDate.value = XSDateUtils.formatDateTime(
|
||||
state.failureDate.value, 'yyyy-mm-dd');
|
||||
});
|
||||
})),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
//生效时间
|
||||
Widget effectiveTimeWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.selectEffectiveTime.value,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
state.isHaveEffectiveTime.value = true;
|
||||
state.effectiveTime.value = XSDateUtils.parseDateTime(
|
||||
'${p.hour!}:${p.minute!}', 'HH:mm');
|
||||
state.selectEffectiveTime.value = XSDateUtils.formatDateTime(
|
||||
state.effectiveTime.value, 'HH:mm');
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.selectFailureTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
state.isHaveFailureTime.value = true;
|
||||
state.failureTime.value = XSDateUtils.parseDateTime(
|
||||
'${p.hour!}:${p.minute!}', 'HH:mm');
|
||||
state.selectFailureTime.value = XSDateUtils.formatDateTime(
|
||||
state.failureTime.value, 'HH:mm');
|
||||
});
|
||||
})),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget bottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 40.h),
|
||||
Obx(() => SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||
@ -177,7 +225,9 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
isDisabled: (state.selectIndexList.value.isNotEmpty &&
|
||||
state.isHaveEffectiveDate.value == true &&
|
||||
state.isHaveFailureDate.value == true)
|
||||
state.isHaveFailureDate.value == true &&
|
||||
state.isHaveEffectiveTime.value == true &&
|
||||
state.isHaveFailureTime.value == true)
|
||||
? true
|
||||
: false,
|
||||
onClick: () {
|
||||
@ -185,17 +235,17 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
state.isHaveEffectiveDate.value == true &&
|
||||
state.isHaveFailureDate.value == true)) {
|
||||
DateTime startDateTime = DateTime(
|
||||
state.effectiveDateTime.value.year,
|
||||
state.effectiveDateTime.value.month,
|
||||
state.effectiveDateTime.value.day,
|
||||
state.effectiveDateTime.value.hour,
|
||||
state.effectiveDateTime.value.minute);
|
||||
state.effectiveDate.value.year,
|
||||
state.effectiveDate.value.month,
|
||||
state.effectiveDate.value.day,
|
||||
state.effectiveDate.value.hour,
|
||||
state.effectiveDate.value.minute);
|
||||
DateTime endDateTime = DateTime(
|
||||
state.failureDateTime.value.year,
|
||||
state.failureDateTime.value.month,
|
||||
state.failureDateTime.value.day,
|
||||
state.failureDateTime.value.hour,
|
||||
state.failureDateTime.value.minute);
|
||||
state.failureDate.value.year,
|
||||
state.failureDate.value.month,
|
||||
state.failureDate.value.day,
|
||||
state.failureDate.value.hour,
|
||||
state.failureDate.value.minute);
|
||||
//时间判断
|
||||
if (!startDateTime.isBefore(endDateTime) ||
|
||||
startDateTime.isAtSameMomentAs(endDateTime)) {
|
||||
@ -203,8 +253,10 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
} else {
|
||||
Map<String, dynamic> resultMap = {};
|
||||
resultMap['validityValue'] = state.selectIndexList.value;
|
||||
resultMap['starDate'] = state.effectiveDateTime.value;
|
||||
resultMap['endDate'] = state.failureDateTime.value;
|
||||
resultMap['starDate'] = state.effectiveDate.value;
|
||||
resultMap['endDate'] = state.failureDate.value;
|
||||
resultMap['starTime'] = state.effectiveTime.value;
|
||||
resultMap['endTime'] = state.failureTime.value;
|
||||
Navigator.pop(context, resultMap);
|
||||
}
|
||||
}
|
||||
@ -212,8 +264,4 @@ class _ElectronicKeyPeriodValidityPageState
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
@ -24,11 +25,24 @@ class ElectronicKeyPeriodValidityState {
|
||||
].obs;
|
||||
final validityDataList = [].obs; //自定义数据块
|
||||
final selectIndexList = [].obs; //选中的有效期数组
|
||||
final selectEffectiveDate = ''.obs; //生效时间
|
||||
final selectFailureDate = ''.obs; //失效时间
|
||||
|
||||
DateTime dateTime = DateTime.now();
|
||||
final effectiveDateTime = DateTime.now().obs;
|
||||
final failureDateTime = DateTime.now().obs;
|
||||
final effectiveDate = DateTime.now().obs;
|
||||
final failureDate = DateTime.now().obs;
|
||||
final selectEffectiveDate = ''.obs; //生效日期
|
||||
final selectFailureDate = ''.obs; //失效日期
|
||||
|
||||
final selectEffectiveTime = ''.obs; //生效时间
|
||||
final selectFailureTime = ''.obs; //失效时间
|
||||
final effectiveTime = DateTime.now().obs;
|
||||
final failureTime = DateTime.now().obs;
|
||||
|
||||
var isHaveEffectiveDate = false.obs;
|
||||
var isHaveFailureDate = false.obs;
|
||||
var isHaveEffectiveTime = false.obs;
|
||||
var isHaveFailureTime = false.obs;
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
||||
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
|
||||
? '1'
|
||||
: '2',
|
||||
endDate: state.failureTimestamp.value.toString(),
|
||||
endDate: state.failureTimestamp.value,
|
||||
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
||||
isCameraEnable: '2',
|
||||
isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2',
|
||||
@ -98,8 +98,10 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
||||
operatorUid: '',
|
||||
receiverUsername: state.emailOrPhoneController.text,
|
||||
remarks: '',
|
||||
startDate: state.effectiveTimestamp.value.toString(),
|
||||
weekDays: state.weekdaysList.value);
|
||||
startDate: state.effectiveTimestamp.value,
|
||||
weekDays: state.weekdaysList.value,
|
||||
startTime: state.startTime.value,
|
||||
endTime: state.endTime.value);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
state.isSendSuccess.value = true;
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/dateUtils.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
@ -171,10 +172,11 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.selectEffectiveDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.effectiveDateTime.value =
|
||||
DateTime.parse(state.selectEffectiveDate.value);
|
||||
state.effectiveDateTime.value = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}',
|
||||
'yyyy-mm-dd HH:mm');
|
||||
state.selectEffectiveDate.value = XSDateUtils.formatDateTime(
|
||||
state.effectiveDateTime.value, 'yyyy-mm-dd HH:mm');
|
||||
});
|
||||
}),
|
||||
CommonItem(
|
||||
@ -184,10 +186,11 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.selectFailureDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.failureDateTime.value =
|
||||
DateTime.parse(state.selectFailureDate.value);
|
||||
state.failureDateTime.value = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}',
|
||||
'yyyy-mm-dd HH:mm');
|
||||
state.selectFailureDate.value = XSDateUtils.formatDateTime(
|
||||
state.failureDateTime.value, 'yyyy-mm-dd HH:mm');
|
||||
});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
@ -233,6 +236,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureTimestamp.value =
|
||||
result['endDate'].millisecondsSinceEpoch;
|
||||
state.startTime.value =
|
||||
result['starTime'].millisecondsSinceEpoch;
|
||||
state.endTime.value = result['endTime'].millisecondsSinceEpoch;
|
||||
}
|
||||
}),
|
||||
SizedBox(
|
||||
@ -547,10 +553,6 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
|
||||
Future _openModalBottomSheet() async {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
|
||||
@ -20,6 +20,8 @@ class SendElectronicKeyState {
|
||||
final failureDateTime = DateTime.now().obs;
|
||||
final effectiveTimestamp = 0.obs;
|
||||
final failureTimestamp = 0.obs;
|
||||
final startTime = 0.obs;
|
||||
final endTime = 0.obs;
|
||||
|
||||
var selectEffectiveDate =
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
|
||||
|
||||
@ -45,46 +45,46 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
//发送钥匙请求
|
||||
Future<void> sendElectronicKeyRequest(BuildContext widgetContext) async {
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
String lockID = state.keyInfo.value.lockId.toString();
|
||||
String getKeyType = (int.parse(state.type.value) + 1).toString();
|
||||
if (state.type.value == '0') {
|
||||
getFailureDateTime =
|
||||
state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime =
|
||||
state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||
}
|
||||
// //发送钥匙请求
|
||||
// Future<void> sendElectronicKeyRequest(BuildContext widgetContext) async {
|
||||
// String lockID = state.keyInfo.value.lockId.toString();
|
||||
// String getKeyType = (int.parse(state.type.value) + 1).toString();
|
||||
// if (state.type.value == '0') {
|
||||
// // getFailureDateTime =
|
||||
// // state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||
// // getEffectiveDateTime =
|
||||
// // state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||
// }
|
||||
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
createUser: state.isCreateUser.value ? "1" : "0",
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: '1',
|
||||
endDate: getFailureDateTime,
|
||||
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
||||
isCameraEnable: '2',
|
||||
isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2',
|
||||
keyNameForAdmin: state.keyNameController.text,
|
||||
keyRight: '0',
|
||||
keyType: getKeyType,
|
||||
lockId: lockID,
|
||||
operatorUid: '',
|
||||
receiverUsername: state.emailOrPhoneController.text,
|
||||
remarks: '',
|
||||
startDate: getEffectiveDateTime,
|
||||
weekDays: state.weekdaysList);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
state.isSendSuccess.value = true;
|
||||
} else {
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
_showDialog(widgetContext, '${entity.errorMsg}');
|
||||
}
|
||||
}
|
||||
}
|
||||
// var entity = await ApiRepository.to.sendElectronicKey(
|
||||
// createUser: state.isCreateUser.value ? "1" : "0",
|
||||
// countryCode: state.countryCode.value,
|
||||
// usernameType: '1',
|
||||
// endDate: state.failureDateTime.value.millisecondsSinceEpoch,
|
||||
// faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
||||
// isCameraEnable: '2',
|
||||
// isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2',
|
||||
// keyNameForAdmin: state.keyNameController.text,
|
||||
// keyRight: '0',
|
||||
// keyType: getKeyType,
|
||||
// lockId: lockID,
|
||||
// operatorUid: '',
|
||||
// receiverUsername: state.emailOrPhoneController.text,
|
||||
// remarks: '',
|
||||
// startDate: state.effectiveDateTime.value.millisecondsSinceEpoch,
|
||||
// weekDays: state.weekdaysList,
|
||||
// startTime: state.st.value,
|
||||
// endTime: state.endTime.value);
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// print('发送电子钥匙成功');
|
||||
// state.isSendSuccess.value = true;
|
||||
// } else {
|
||||
// if (entity.errorCode == 425) {
|
||||
// //用户未注册
|
||||
// _showDialog(widgetContext, '${entity.errorMsg}');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//用户未注册确认弹窗
|
||||
void _showDialog(widgetContext, String errMsg) {
|
||||
|
||||
@ -3,12 +3,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_utils/get_utils.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/commonItem.dart';
|
||||
import 'package:star_lock/tools/dateUtils.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
@ -25,28 +23,13 @@ class AddAuthorizedAdministratorPage extends StatefulWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministratorPage> with SingleTickerProviderStateMixin {
|
||||
class _AddAuthorizedAdministratorPageState
|
||||
extends State<AddAuthorizedAdministratorPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final logic = Get.put(AddAuthorizedAdministratorLogic());
|
||||
final state = Get.find<AddAuthorizedAdministratorLogic>().state;
|
||||
|
||||
TabController? _tabController;
|
||||
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
||||
late Contact _contact;
|
||||
final _templateNameTf = TextEditingController();
|
||||
late List _lockIdList;
|
||||
late bool _isRemoteUnlock;
|
||||
late bool _isCreateUser;
|
||||
var _selectEffectiveDate = ''; //生效时间
|
||||
var _selectFailureDate = ''; //失效时间
|
||||
late DateTime _effectiveDateTime;
|
||||
late DateTime _failureDateTime;
|
||||
final TextEditingController _emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
final TextEditingController _keyNameController =
|
||||
TextEditingController(); //钥匙名输入框
|
||||
String countryName = '中国';
|
||||
String countryCode = '86';
|
||||
late bool _isSendSuccess;
|
||||
|
||||
List tabs = [
|
||||
TranslationLoader.lanKeys!.permanent!.tr,
|
||||
@ -57,10 +40,6 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_isCreateUser = false;
|
||||
_lockIdList = [];
|
||||
_isRemoteUnlock = false;
|
||||
_isSendSuccess = false;
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
}
|
||||
|
||||
@ -119,7 +98,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
|
||||
//永久
|
||||
Widget _permanentAdministrator() {
|
||||
if (_isSendSuccess) {
|
||||
if (state.isSendSuccess.value == true) {
|
||||
return sendElectronicKeySucceed();
|
||||
} else {
|
||||
return Column(
|
||||
@ -133,9 +112,9 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
|
||||
rightTitle: _lockIdList.isEmpty
|
||||
rightTitle: state.lockIdList.value.isEmpty
|
||||
? TranslationLoader.lanKeys!.pleaseSelect!.tr
|
||||
: _lockIdList.length.toString(),
|
||||
: state.lockIdList.value.length.toString(),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupPage)
|
||||
@ -143,7 +122,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
_lockIdList = value['selectLockIdList'];
|
||||
state.lockIdList.value = value['selectLockIdList'];
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
@ -164,7 +143,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
|
||||
//限时管理员
|
||||
Widget _timeLimitAdministrator() {
|
||||
if (_isSendSuccess) {
|
||||
if (state.isSendSuccess.value == true) {
|
||||
return sendElectronicKeySucceed();
|
||||
} else {
|
||||
return Column(
|
||||
@ -182,9 +161,9 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
|
||||
rightTitle: _lockIdList.isEmpty
|
||||
rightTitle: state.lockIdList.value.isEmpty
|
||||
? TranslationLoader.lanKeys!.pleaseSelect!.tr
|
||||
: _lockIdList.length.toString(),
|
||||
: state.lockIdList.value.length.toString(),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupPage)
|
||||
@ -192,7 +171,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
_lockIdList = value['selectLockIdList'];
|
||||
state.lockIdList.value = value['selectLockIdList'];
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
@ -211,41 +190,6 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
}
|
||||
}
|
||||
|
||||
//发送批量授权管理员
|
||||
Future<void> addAuthorizedAdminRequest() async {
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
if (_tabController!.index == 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,
|
||||
countryCode,
|
||||
'1',
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
_isSendSuccess = true;
|
||||
setState(() {});
|
||||
} else {
|
||||
logic.showToast("${entity.errorMsg}");
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
_isCreateUser = true;
|
||||
addAuthorizedAdminRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 顶部钥匙信息widget
|
||||
Widget keyInfoWidget() {
|
||||
return Column(
|
||||
@ -259,7 +203,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
rightWidget: getTFWidget(
|
||||
true,
|
||||
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
|
||||
_emailOrPhoneController)),
|
||||
state.emailOrPhoneController)),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
||||
rightTitle: "",
|
||||
@ -267,7 +211,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
isHaveRightWidget: true,
|
||||
isHaveDirection: true,
|
||||
rightWidget: Text(
|
||||
'$countryName +$countryCode',
|
||||
'${state.countryName.value} +${state.countryCode.value}',
|
||||
textAlign: TextAlign.end,
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
@ -277,8 +221,8 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
context, Routers.selectCountryRegionPage);
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
@ -290,7 +234,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
rightWidget: getTFWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
_keyNameController)),
|
||||
state.keyNameController)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
@ -339,10 +283,10 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
Contact? currentContact =
|
||||
await _contactPicker.selectContact();
|
||||
await state.contactPicker.selectContact();
|
||||
setState(() {
|
||||
if (currentContact!.phoneNumbers!.isNotEmpty) {
|
||||
_emailOrPhoneController.text = currentContact
|
||||
state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
|
||||
}
|
||||
@ -364,7 +308,8 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: Obx(() => _switch())),
|
||||
action: () {}),
|
||||
Container(height: 40.h),
|
||||
],
|
||||
@ -377,30 +322,34 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: _selectEffectiveDate,
|
||||
rightTitle: state.selectEffectiveDate.value,
|
||||
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);
|
||||
state.effectiveDateTime.value = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}',
|
||||
'yyyy-mm-dd HH:mm');
|
||||
state.selectEffectiveDate.value = XSDateUtils.formatDateTime(
|
||||
state.effectiveDateTime.value, 'yyyy-mm-dd HH:mm');
|
||||
});
|
||||
});
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: _selectFailureDate,
|
||||
rightTitle: state.selectFailureDate.value,
|
||||
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);
|
||||
state.failureDateTime.value = XSDateUtils.parseDateTime(
|
||||
'${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}',
|
||||
'yyyy-mm-dd HH:mm');
|
||||
state.selectFailureDate.value = XSDateUtils.formatDateTime(
|
||||
state.failureDateTime.value, 'yyyy-mm-dd HH:mm');
|
||||
});
|
||||
});
|
||||
}),
|
||||
@ -430,7 +379,9 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
onClick: () {
|
||||
logic.addAuthorizedAdminRequest();
|
||||
}),
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 30.w),
|
||||
// color: Colors.red,
|
||||
@ -497,7 +448,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
onClick: () {
|
||||
_isSendSuccess = false;
|
||||
state.isSendSuccess.value = false;
|
||||
Navigator.pop(context, true);
|
||||
}),
|
||||
SizedBox(
|
||||
@ -532,11 +483,9 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: _isRemoteUnlock,
|
||||
value: state.isRemoteUnlock.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_isRemoteUnlock = !_isRemoteUnlock;
|
||||
});
|
||||
state.isRemoteUnlock.value = !state.isRemoteUnlock.value;
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -545,12 +494,8 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
|
||||
return SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||
onClick: () {
|
||||
addAuthorizedAdminRequest();
|
||||
logic.addAuthorizedAdminRequest();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,8 +22,10 @@ class AddAuthorizedAdministratorState {
|
||||
var selectFailureDate =
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
|
||||
.obs; //默认为当前时间
|
||||
final effectiveDateTime = DateTime.now().obs;
|
||||
final failureDateTime = DateTime.now().obs;
|
||||
final effectiveDate = DateTime.now().obs;
|
||||
final failureDate = DateTime.now().obs;
|
||||
var startTime = 0.obs;
|
||||
var endTime = 0.obs;
|
||||
var countryName = '中国'.obs;
|
||||
var countryCode = '86'.obs;
|
||||
var isSendSuccess = false.obs;
|
||||
|
||||
@ -127,7 +127,7 @@ class ApiProvider extends BaseProvider {
|
||||
String createUser,
|
||||
String countryCode,
|
||||
String usernameType,
|
||||
String endDate,
|
||||
int endDate,
|
||||
String faceAuthentication,
|
||||
String isCameraEnable,
|
||||
String isRemoteUnlock,
|
||||
@ -138,8 +138,10 @@ class ApiProvider extends BaseProvider {
|
||||
String operatorUid,
|
||||
String receiverUsername,
|
||||
String remarks,
|
||||
String startDate,
|
||||
List weekDays) =>
|
||||
int startDate,
|
||||
List weekDays,
|
||||
int startTime,
|
||||
int endTime) =>
|
||||
post(
|
||||
sendElectronicKeyURL.toUrl,
|
||||
jsonEncode({
|
||||
@ -158,7 +160,9 @@ class ApiProvider extends BaseProvider {
|
||||
'receiverUsername': receiverUsername,
|
||||
'remarks': remarks,
|
||||
'startDate': startDate,
|
||||
'weekDays': weekDays
|
||||
'weekDays': weekDays,
|
||||
'startTime': startTime,
|
||||
'endTime': endTime
|
||||
}));
|
||||
|
||||
Future<Response> uploadElectricQuantity(
|
||||
|
||||
@ -144,7 +144,7 @@ class ApiRepository {
|
||||
{required String createUser,
|
||||
required String countryCode,
|
||||
required String usernameType,
|
||||
required String endDate,
|
||||
required int endDate,
|
||||
required String faceAuthentication,
|
||||
required String isCameraEnable,
|
||||
required String isRemoteUnlock,
|
||||
@ -155,8 +155,10 @@ class ApiRepository {
|
||||
required String operatorUid,
|
||||
required String receiverUsername,
|
||||
required String remarks,
|
||||
required String startDate,
|
||||
required List weekDays}) async {
|
||||
required int startDate,
|
||||
required List weekDays,
|
||||
required int startTime,
|
||||
required int endTime}) async {
|
||||
final res = await apiProvider.sendElectronicKey(
|
||||
createUser,
|
||||
countryCode,
|
||||
@ -173,7 +175,9 @@ class ApiRepository {
|
||||
receiverUsername,
|
||||
remarks,
|
||||
startDate,
|
||||
weekDays);
|
||||
weekDays,
|
||||
startTime,
|
||||
endTime);
|
||||
return AuthorizedAdminSendEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
|
||||
28
star_lock/lib/tools/dateUtils.dart
Normal file
28
star_lock/lib/tools/dateUtils.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class XSDateUtils {
|
||||
// 将DateTime对象格式化为指定格式的字符串
|
||||
static String formatDateTime(DateTime dateTime, String format) {
|
||||
DateFormat dateFormat = DateFormat(format);
|
||||
return dateFormat.format(dateTime);
|
||||
}
|
||||
|
||||
// 将指定格式的日期时间字符串解析为DateTime对象
|
||||
static DateTime parseDateTime(String dateString, String format) {
|
||||
DateFormat dateFormat = DateFormat(format);
|
||||
return dateFormat.parse(dateString);
|
||||
}
|
||||
}
|
||||
|
||||
// 使用示例
|
||||
// void main() {
|
||||
// // 格式化日期时间
|
||||
// DateTime now = DateTime.now();
|
||||
// String formattedDateTime = DateUtils.formatDateTime(now, 'HH:mm');
|
||||
// print('Formatted DateTime: $formattedDateTime');
|
||||
|
||||
// // 解析日期时间字符串
|
||||
// String dateString = '08:30';
|
||||
// DateTime parsedDateTime = DateUtils.parseDateTime(dateString, 'HH:mm');
|
||||
// print('Parsed DateTime: $parsedDateTime');
|
||||
// }
|
||||
Loading…
x
Reference in New Issue
Block a user