更新快检报告
This commit is contained in:
63
lib/pages/device/component/health_experience_tool.dart
Normal file
63
lib/pages/device/component/health_experience_tool.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:vbvs_app/controller/device/device_type_controller.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
|
||||
DeviceTypeController deviceTypeController = Get.find();
|
||||
String getGenderText(dynamic gender) {
|
||||
var genderMap = {
|
||||
'1': '男'.tr,
|
||||
'2': '女'.tr,
|
||||
};
|
||||
|
||||
String genderStr = gender.toString().trim();
|
||||
return genderMap[genderStr] ?? '-'.tr;
|
||||
}
|
||||
|
||||
// 显示解绑确认对话框
|
||||
void showCancelConfirmDialog(BuildContext context, personInfo) {
|
||||
showConfirmDialog(
|
||||
context,
|
||||
Container(),
|
||||
"是否确认结束?".tr,
|
||||
onConfirm: () async {
|
||||
bool opRes = await deviceTypeController.qcCheckControl(personInfo, 2);
|
||||
if (!opRes) {
|
||||
return;
|
||||
}
|
||||
deviceTypeController.experience_status.value = 404;
|
||||
deviceTypeController.updateAll();
|
||||
},
|
||||
onCancel: () {},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
String calculateAge(String birthdayStr) {
|
||||
try {
|
||||
// 解析生日字符串 (格式: yyyy/MM/dd)
|
||||
List<String> parts = birthdayStr.trim().split('/');
|
||||
if (parts.length != 3) return '-'.tr;
|
||||
|
||||
int year = int.parse(parts[0]);
|
||||
int month = int.parse(parts[1]);
|
||||
int day = int.parse(parts[2]);
|
||||
|
||||
DateTime birthDate = DateTime(year, month, day);
|
||||
DateTime today = DateTime.now();
|
||||
|
||||
// 计算年龄
|
||||
int age = today.year - birthDate.year;
|
||||
|
||||
// 如果今年还没过生日,年龄减1
|
||||
if (today.month < birthDate.month ||
|
||||
(today.month == birthDate.month && today.day < birthDate.day)) {
|
||||
age--;
|
||||
}
|
||||
|
||||
return age.toString();
|
||||
} catch (e) {
|
||||
return '-'.tr;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user