人员资料生日数据格式错误
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
part 'people_info_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@@ -67,21 +72,27 @@ class PeopleInfoController extends GetControllerEx<PeopleInfoModel> {
|
||||
);
|
||||
}
|
||||
|
||||
savePeoples(Map<String, dynamic> data) async {
|
||||
savePeoples(Map<String, dynamic> data, BuildContext context) async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.person_info;
|
||||
String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||
requestWithLog(
|
||||
String code = '';
|
||||
data['birthday'] = data['birthday'] is DateTime
|
||||
? DateFormat('yyyy-MM-dd').format(data['birthday'])
|
||||
: data['birthday'];
|
||||
await requestWithLog(
|
||||
logTitle: "更新人员信息",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
print("更新人员信息成功: $res");
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!, textColor: Color(0XFF00C1AA));
|
||||
},
|
||||
onFailure: (err) {
|
||||
print("更新人员信息失败: $err");
|
||||
TopSlideNotification.show(context,
|
||||
text: err.msg!, textColor: Color(0xFFFF7159));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -271,6 +271,153 @@ Future showDateSelectionDialog(BuildContext context,
|
||||
);
|
||||
}
|
||||
|
||||
// Future showMonthSelectionDialog(
|
||||
// BuildContext context, {
|
||||
// required DateTime checkDate,
|
||||
// Function(DateTime)? checkChange,
|
||||
// String title = "选择月份",
|
||||
// }) {
|
||||
// ThemeController themeController = Get.find();
|
||||
|
||||
// final List<int> years = List.generate(100, (i) => DateTime.now().year - i)
|
||||
// ..sort();
|
||||
// final List<int> months = List.generate(12, (i) => i + 1);
|
||||
|
||||
// final RxInt yearIndex = years.indexOf(checkDate.year).obs;
|
||||
// final RxInt monthIndex = months.indexOf(checkDate.month).obs;
|
||||
|
||||
// return showDialog(
|
||||
// context: context,
|
||||
// barrierDismissible: true,
|
||||
// builder: (BuildContext context) {
|
||||
// return Stack(
|
||||
// children: [
|
||||
// Positioned(
|
||||
// bottom: 0,
|
||||
// left: 0,
|
||||
// right: 0,
|
||||
// child: Material(
|
||||
// color: Colors.transparent,
|
||||
// child: Dialog(
|
||||
// backgroundColor: const Color(0xFF003058),
|
||||
// insetPadding: EdgeInsets.zero,
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(0),
|
||||
// ),
|
||||
// child: Container(
|
||||
// width: double.infinity,
|
||||
// padding: EdgeInsets.fromLTRB(30.rpx, 10.rpx, 30.rpx, 90.rpx),
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// children: <Widget>[
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// ClickableContainer(
|
||||
// backgroundColor: Colors.transparent,
|
||||
// highlightColor: Colors.transparent,
|
||||
// padding: EdgeInsets.zero,
|
||||
// onTap: () => Navigator.of(context).pop(),
|
||||
// child: Container(
|
||||
// width: 100.rpx,
|
||||
// height: 60.rpx,
|
||||
// alignment: Alignment.center,
|
||||
// child: Text("取消",
|
||||
// style: TextStyle(
|
||||
// fontSize: 30.rpx, color: Colors.white)),
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// title,
|
||||
// style: TextStyle(
|
||||
// fontFamily: 'Readex Pro',
|
||||
// color: themeController.currentColor.sc3,
|
||||
// fontSize: 30.rpx,
|
||||
// ),
|
||||
// ),
|
||||
// ClickableContainer(
|
||||
// backgroundColor: Colors.transparent,
|
||||
// highlightColor: Colors.transparent,
|
||||
// padding: EdgeInsets.zero,
|
||||
// onTap: () {
|
||||
// final selectedDate = DateTime(
|
||||
// years[yearIndex.value],
|
||||
// months[monthIndex.value],
|
||||
// );
|
||||
// Navigator.of(context).pop();
|
||||
// checkChange?.call(selectedDate);
|
||||
// },
|
||||
// child: Container(
|
||||
// width: 100.rpx,
|
||||
// height: 60.rpx,
|
||||
// alignment: Alignment.center,
|
||||
// child: Text("确定",
|
||||
// style: TextStyle(
|
||||
// fontSize: 30.rpx,
|
||||
// color: stringToColor("#84F5FF"))),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// SizedBox(height: 20.rpx),
|
||||
// Stack(
|
||||
// children: [
|
||||
// Positioned.fill(
|
||||
// child: IgnorePointer(
|
||||
// child: Center(
|
||||
// child: Container(
|
||||
// height: 90.rpx,
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 95.rpx),
|
||||
// decoration: BoxDecoration(
|
||||
// color: const Color(0xFF84F5FF),
|
||||
// borderRadius: BorderRadius.circular(16.rpx),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 240.rpx,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 95.rpx),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: getOnePickers(
|
||||
// context,
|
||||
// years,
|
||||
// yearIndex,
|
||||
// unit: "年",
|
||||
// ),
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: getOnePickers(
|
||||
// context,
|
||||
// months,
|
||||
// monthIndex,
|
||||
// unit: "月",
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
Future showMonthSelectionDialog(
|
||||
BuildContext context, {
|
||||
required DateTime checkDate,
|
||||
@@ -279,12 +426,42 @@ Future showMonthSelectionDialog(
|
||||
}) {
|
||||
ThemeController themeController = Get.find();
|
||||
|
||||
final currentYear = DateTime.now().year;
|
||||
final currentMonth = DateTime.now().month;
|
||||
|
||||
final List<int> years = List.generate(100, (i) => DateTime.now().year - i)
|
||||
..sort();
|
||||
final List<int> months = List.generate(12, (i) => i + 1);
|
||||
|
||||
final RxInt yearIndex = years.indexOf(checkDate.year).obs;
|
||||
final RxInt monthIndex = months.indexOf(checkDate.month).obs;
|
||||
final RxList<int> months = <int>[].obs;
|
||||
|
||||
// 初始化 yearIndex
|
||||
final int initYearIndex = years.indexOf(checkDate.year);
|
||||
final RxInt yearIndex = (initYearIndex >= 0 ? initYearIndex : 0).obs;
|
||||
|
||||
final RxInt monthIndex = 0.obs;
|
||||
|
||||
bool isInit = true;
|
||||
|
||||
void updateMonthList() {
|
||||
final selectedYear = years[yearIndex.value];
|
||||
final maxMonth = selectedYear == currentYear ? currentMonth : 12;
|
||||
final newMonths = List.generate(maxMonth, (i) => i + 1);
|
||||
months.value = newMonths;
|
||||
|
||||
if (isInit) {
|
||||
final int newMonthIndex = newMonths.indexOf(checkDate.month);
|
||||
monthIndex.value = newMonthIndex >= 0 ? newMonthIndex : 0;
|
||||
isInit = false;
|
||||
} else {
|
||||
if (monthIndex.value >= newMonths.length) {
|
||||
monthIndex.value = newMonths.length - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateMonthList();
|
||||
|
||||
ever(yearIndex, (_) => updateMonthList());
|
||||
|
||||
return showDialog(
|
||||
context: context,
|
||||
@@ -311,6 +488,7 @@ Future showMonthSelectionDialog(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
// 顶部标题与按钮
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -323,9 +501,13 @@ Future showMonthSelectionDialog(
|
||||
width: 100.rpx,
|
||||
height: 60.rpx,
|
||||
alignment: Alignment.center,
|
||||
child: Text("取消",
|
||||
style: TextStyle(
|
||||
fontSize: 30.rpx, color: Colors.white)),
|
||||
child: Text(
|
||||
"取消",
|
||||
style: TextStyle(
|
||||
fontSize: 30.rpx,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
@@ -352,15 +534,19 @@ Future showMonthSelectionDialog(
|
||||
width: 100.rpx,
|
||||
height: 60.rpx,
|
||||
alignment: Alignment.center,
|
||||
child: Text("确定",
|
||||
style: TextStyle(
|
||||
fontSize: 30.rpx,
|
||||
color: stringToColor("#84F5FF"))),
|
||||
child: Text(
|
||||
"确定",
|
||||
style: TextStyle(
|
||||
fontSize: 30.rpx,
|
||||
color: stringToColor("#84F5FF"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20.rpx),
|
||||
// 中间选中高亮背景
|
||||
Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
@@ -378,6 +564,7 @@ Future showMonthSelectionDialog(
|
||||
),
|
||||
),
|
||||
),
|
||||
// 滚轮选择器
|
||||
SizedBox(
|
||||
height: 240.rpx,
|
||||
child: Padding(
|
||||
@@ -395,7 +582,7 @@ Future showMonthSelectionDialog(
|
||||
Expanded(
|
||||
child: getOnePickers(
|
||||
context,
|
||||
months,
|
||||
months, // 注意这里取 .value
|
||||
monthIndex,
|
||||
unit: "月",
|
||||
),
|
||||
|
||||
@@ -179,27 +179,27 @@ class _BluetoothPageState extends State<BluetoothPage> {
|
||||
// 蓝牙连接状态
|
||||
Column(
|
||||
children: [
|
||||
obsData['blueToothStatus'] == 1
|
||||
obsData['blueToothStatus'] == 2
|
||||
? SvgPicture.asset(
|
||||
'assets/img/icon/blue_fail.svg',
|
||||
'assets/img/icon/blue_success.svg',
|
||||
width: 68.rpx,
|
||||
height: 68.rpx,
|
||||
)
|
||||
: SvgPicture.asset(
|
||||
'assets/img/icon/blue_success.svg',
|
||||
'assets/img/icon/blue_fail.svg',
|
||||
width: 68.rpx,
|
||||
height: 68.rpx,
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
//下面文字和颜色也根据上面变化
|
||||
Text(
|
||||
obsData['blueToothStatus'] == 1
|
||||
? '未连接'
|
||||
: '已连接',
|
||||
obsData['blueToothStatus'] == 2
|
||||
? '已连接'
|
||||
: '未连接',
|
||||
style: TextStyle(
|
||||
color: obsData['blueToothStatus'] == 1
|
||||
? Color(0xFFFF7159)
|
||||
: Color(0xFF6BFDAC),
|
||||
color: obsData['blueToothStatus'] == 2
|
||||
? Color(0xFF6BFDAC)
|
||||
: Color(0xFFFF7159),
|
||||
fontSize: 26.rpx)),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -35,6 +35,9 @@ class DevicePeopleInfo extends GetView<PeopleInfoController> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
controller.getPeoples (data['mac']);
|
||||
});
|
||||
return LayoutBuilder(
|
||||
builder: (context, boxConstraints) => GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
@@ -135,7 +138,7 @@ class DevicePeopleInfo extends GetView<PeopleInfoController> {
|
||||
"房间:${data["roomName"] ?? "-"}"),
|
||||
getInfoRow(
|
||||
context,
|
||||
"网络:${data["status"]?["status"] == 1 ? "在线" : data["status"]?["status"] == 0 ? "不在线" : "-"}",
|
||||
"设备状态:${data["status"]?["status"] == 1 ? "已绑定" : data["status"]?["status"] == 0 ? "已绑定" : "-"}",
|
||||
),
|
||||
getInfoRow(
|
||||
context, "MAC:${data["mac"] ?? "-"}"),
|
||||
|
||||
@@ -84,7 +84,6 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
|
||||
gradientDirection: GradientDirection.vertical,
|
||||
onTap: () async {
|
||||
bool isValid = true;
|
||||
|
||||
// 数据验证
|
||||
for (int i = 0;
|
||||
i < controller.model.peopleList.length;
|
||||
@@ -125,15 +124,11 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 所有数据合法,开始保存
|
||||
if (isValid) {
|
||||
for (var data in controller.model.peopleList) {
|
||||
try {
|
||||
await controller.savePeoples(data);
|
||||
TopSlideNotification.show(context,
|
||||
text: "更新成功".tr,
|
||||
textColor: Color(0XFF00C1AA));
|
||||
await controller.savePeoples(data, context);
|
||||
MHTHomeController mhtHomeController =
|
||||
Get.find();
|
||||
mhtHomeController.getPersonList();
|
||||
@@ -652,6 +647,16 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
|
||||
controller
|
||||
.updateAll();
|
||||
print("$d");
|
||||
// final String dateStr =
|
||||
// "${d.year}-${d.month.toString().padLeft(2, '0')}";
|
||||
|
||||
// controller.model.peopleList[
|
||||
// index]
|
||||
// ['birthday'] =
|
||||
// dateStr;
|
||||
// controller
|
||||
// .updateAll();
|
||||
// print(dateStr);
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -781,7 +786,6 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
|
||||
.peopleList[
|
||||
index]
|
||||
['contact'] = value;
|
||||
controller.updateAll();
|
||||
},
|
||||
controller: controller.onReDraw(
|
||||
TextEditingController(
|
||||
|
||||
Reference in New Issue
Block a user