人员资料生日数据格式错误

This commit is contained in:
czz
2025-07-16 18:48:38 +08:00
parent db6903ee78
commit 8687a4b0dd
5 changed files with 237 additions and 32 deletions

View File

@@ -1,10 +1,15 @@
import 'dart:ui';
import 'package:ef/ef.dart'; import 'package:ef/ef.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/ServiceConstant.dart';
import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/common/util/requestWithLog.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/controller/main_bottom/global_controller.dart';
import 'package:vbvs_app/model/api_response.dart';
part 'people_info_controller.g.dart'; // 由json_serializable自动生成的部分 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 serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service; String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.person_info; String serviceApi = ServiceConstant.person_info;
String queryUrl = "$serviceAddress$serviceName$serviceApi"; 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: "更新人员信息", logTitle: "更新人员信息",
method: MyHttpMethod.put, method: MyHttpMethod.put,
queryUrl: queryUrl, queryUrl: queryUrl,
data: data, data: data,
onSuccess: (res) { onSuccess: (res) {
print("更新人员信息成功: $res"); TopSlideNotification.show(context,
text: res.msg!, textColor: Color(0XFF00C1AA));
}, },
onFailure: (err) { onFailure: (err) {
print("更新人员信息失败: $err"); TopSlideNotification.show(context,
text: err.msg!, textColor: Color(0xFFFF7159));
}, },
); );
} }

View File

@@ -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( Future showMonthSelectionDialog(
BuildContext context, { BuildContext context, {
required DateTime checkDate, required DateTime checkDate,
@@ -279,12 +426,42 @@ Future showMonthSelectionDialog(
}) { }) {
ThemeController themeController = Get.find(); 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) final List<int> years = List.generate(100, (i) => DateTime.now().year - i)
..sort(); ..sort();
final List<int> months = List.generate(12, (i) => i + 1);
final RxInt yearIndex = years.indexOf(checkDate.year).obs; final RxList<int> months = <int>[].obs;
final RxInt monthIndex = months.indexOf(checkDate.month).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( return showDialog(
context: context, context: context,
@@ -311,6 +488,7 @@ Future showMonthSelectionDialog(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
// 顶部标题与按钮
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@@ -323,9 +501,13 @@ Future showMonthSelectionDialog(
width: 100.rpx, width: 100.rpx,
height: 60.rpx, height: 60.rpx,
alignment: Alignment.center, alignment: Alignment.center,
child: Text("取消", child: Text(
"取消",
style: TextStyle( style: TextStyle(
fontSize: 30.rpx, color: Colors.white)), fontSize: 30.rpx,
color: Colors.white,
),
),
), ),
), ),
Text( Text(
@@ -352,15 +534,19 @@ Future showMonthSelectionDialog(
width: 100.rpx, width: 100.rpx,
height: 60.rpx, height: 60.rpx,
alignment: Alignment.center, alignment: Alignment.center,
child: Text("确定", child: Text(
"确定",
style: TextStyle( style: TextStyle(
fontSize: 30.rpx, fontSize: 30.rpx,
color: stringToColor("#84F5FF"))), color: stringToColor("#84F5FF"),
),
),
), ),
), ),
], ],
), ),
SizedBox(height: 20.rpx), SizedBox(height: 20.rpx),
// 中间选中高亮背景
Stack( Stack(
children: [ children: [
Positioned.fill( Positioned.fill(
@@ -378,6 +564,7 @@ Future showMonthSelectionDialog(
), ),
), ),
), ),
// 滚轮选择器
SizedBox( SizedBox(
height: 240.rpx, height: 240.rpx,
child: Padding( child: Padding(
@@ -395,7 +582,7 @@ Future showMonthSelectionDialog(
Expanded( Expanded(
child: getOnePickers( child: getOnePickers(
context, context,
months, months, // 注意这里取 .value
monthIndex, monthIndex,
unit: "", unit: "",
), ),

View File

@@ -179,27 +179,27 @@ class _BluetoothPageState extends State<BluetoothPage> {
// 蓝牙连接状态 // 蓝牙连接状态
Column( Column(
children: [ children: [
obsData['blueToothStatus'] == 1 obsData['blueToothStatus'] == 2
? SvgPicture.asset( ? SvgPicture.asset(
'assets/img/icon/blue_fail.svg', 'assets/img/icon/blue_success.svg',
width: 68.rpx, width: 68.rpx,
height: 68.rpx, height: 68.rpx,
) )
: SvgPicture.asset( : SvgPicture.asset(
'assets/img/icon/blue_success.svg', 'assets/img/icon/blue_fail.svg',
width: 68.rpx, width: 68.rpx,
height: 68.rpx, height: 68.rpx,
), ),
SizedBox(height: 4), SizedBox(height: 4),
//下面文字和颜色也根据上面变化 //下面文字和颜色也根据上面变化
Text( Text(
obsData['blueToothStatus'] == 1 obsData['blueToothStatus'] == 2
? '连接' ? '连接'
: '连接', : '连接',
style: TextStyle( style: TextStyle(
color: obsData['blueToothStatus'] == 1 color: obsData['blueToothStatus'] == 2
? Color(0xFFFF7159) ? Color(0xFF6BFDAC)
: Color(0xFF6BFDAC), : Color(0xFFFF7159),
fontSize: 26.rpx)), fontSize: 26.rpx)),
], ],
), ),

View File

@@ -35,6 +35,9 @@ class DevicePeopleInfo extends GetView<PeopleInfoController> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) {
controller.getPeoples (data['mac']);
});
return LayoutBuilder( return LayoutBuilder(
builder: (context, boxConstraints) => GestureDetector( builder: (context, boxConstraints) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(), onTap: () => FocusScope.of(context).unfocus(),
@@ -135,7 +138,7 @@ class DevicePeopleInfo extends GetView<PeopleInfoController> {
"房间:${data["roomName"] ?? "-"}"), "房间:${data["roomName"] ?? "-"}"),
getInfoRow( getInfoRow(
context, context,
"网络${data["status"]?["status"] == 1 ? "在线" : data["status"]?["status"] == 0 ? "不在线" : "-"}", "设备状态${data["status"]?["status"] == 1 ? "已绑定" : data["status"]?["status"] == 0 ? "已绑定" : "-"}",
), ),
getInfoRow( getInfoRow(
context, "MAC${data["mac"] ?? "-"}"), context, "MAC${data["mac"] ?? "-"}"),

View File

@@ -84,7 +84,6 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
gradientDirection: GradientDirection.vertical, gradientDirection: GradientDirection.vertical,
onTap: () async { onTap: () async {
bool isValid = true; bool isValid = true;
// 数据验证 // 数据验证
for (int i = 0; for (int i = 0;
i < controller.model.peopleList.length; i < controller.model.peopleList.length;
@@ -125,15 +124,11 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
break; break;
} }
} }
// 所有数据合法,开始保存 // 所有数据合法,开始保存
if (isValid) { if (isValid) {
for (var data in controller.model.peopleList) { for (var data in controller.model.peopleList) {
try { try {
await controller.savePeoples(data); await controller.savePeoples(data, context);
TopSlideNotification.show(context,
text: "更新成功".tr,
textColor: Color(0XFF00C1AA));
MHTHomeController mhtHomeController = MHTHomeController mhtHomeController =
Get.find(); Get.find();
mhtHomeController.getPersonList(); mhtHomeController.getPersonList();
@@ -652,6 +647,16 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
controller controller
.updateAll(); .updateAll();
print("$d"); 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[ .peopleList[
index] index]
['contact'] = value; ['contact'] = value;
controller.updateAll();
}, },
controller: controller.onReDraw( controller: controller.onReDraw(
TextEditingController( TextEditingController(