更新快检功能必传mac参数
This commit is contained in:
@@ -1,3 +1,246 @@
|
||||
// import 'package:ef/ef.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_svg/svg.dart';
|
||||
// import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
// import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
// import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
// import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
// import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
// import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
// import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
|
||||
// import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
// class QcZiZhuShenJingPercentWidget extends StatefulWidget {
|
||||
// var reportData; // 改为更通用的名称
|
||||
// QcZiZhuShenJingPercentWidget({super.key, required this.reportData});
|
||||
|
||||
// @override
|
||||
// State<QcZiZhuShenJingPercentWidget> createState() =>
|
||||
// _ZiZhuShenJingPercentWidgetState();
|
||||
// }
|
||||
|
||||
// class _ZiZhuShenJingPercentWidgetState
|
||||
// extends State<QcZiZhuShenJingPercentWidget> {
|
||||
// @override
|
||||
// void setState(VoidCallback callback) {
|
||||
// super.setState(callback);
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void dispose() {
|
||||
// super.dispose();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// try {
|
||||
// if (widget.reportData == null) {
|
||||
// return Container();
|
||||
// }
|
||||
|
||||
// // 从reportData中获取zzsjphzs数据
|
||||
// Map<String, dynamic> zzsjphzsData = widget.reportData['zzsjphzs'] ?? {};
|
||||
// if (zzsjphzsData.isEmpty) {
|
||||
// return Container();
|
||||
// }
|
||||
|
||||
// int level = zzsjphzsData['level'] ?? 0;
|
||||
|
||||
// // 根据level值确定显示内容和颜色
|
||||
// String levelText = '';
|
||||
// Color levelColor = themeController.currentColor.sc3;
|
||||
|
||||
// switch (level) {
|
||||
// case 0:
|
||||
// levelText = '正常';
|
||||
// levelColor = Colors.green;
|
||||
// break;
|
||||
// case 1:
|
||||
// levelText = '轻度失衡';
|
||||
// levelColor = Colors.orange;
|
||||
// break;
|
||||
// case 2:
|
||||
// levelText = '中度失衡';
|
||||
// levelColor = Colors.red;
|
||||
// break;
|
||||
// case 3:
|
||||
// levelText = '重度失衡';
|
||||
// levelColor = Colors.red;
|
||||
// break;
|
||||
// default:
|
||||
// levelText = '未知';
|
||||
// levelColor = Colors.grey;
|
||||
// }
|
||||
|
||||
// // 构建StatusBarWithIndicator需要的数据格式
|
||||
// List<Map<String, dynamic>> showLabel = [
|
||||
// {
|
||||
// 'key': 0,
|
||||
// 'name': '正常',
|
||||
// 'color': Colors.green,
|
||||
// },
|
||||
// {
|
||||
// 'key': 1,
|
||||
// 'name': '轻度失衡',
|
||||
// 'color': Colors.orange,
|
||||
// },
|
||||
// {
|
||||
// 'key': 2,
|
||||
// 'name': '中度失衡',
|
||||
// 'color': Colors.red,
|
||||
// },
|
||||
// {
|
||||
// 'key': 3,
|
||||
// 'name': '重度失衡',
|
||||
// 'color': Colors.red,
|
||||
// },
|
||||
// ];
|
||||
|
||||
// return Container(
|
||||
// width: double.infinity,
|
||||
// decoration: BoxDecoration(
|
||||
// color: themeController.currentColor.sc5,
|
||||
// borderRadius: BorderRadius.circular(
|
||||
// AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
// ),
|
||||
// child: Padding(
|
||||
// padding:
|
||||
// EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// Container(
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// "自主神经平衡指数".tr,
|
||||
// style: TextStyle(
|
||||
// color: themeController.currentColor.sc3,
|
||||
// fontSize: AppConstants().title_text_fontSize),
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
// ),
|
||||
// ClickableContainer(
|
||||
// backgroundColor: Colors.transparent,
|
||||
// highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
// padding: EdgeInsetsDirectional.fromSTEB(
|
||||
// 14.rpx, 10.rpx, 14.rpx, 10.rpx), //
|
||||
// borderRadius: 0.rpx, // 圆形点击区域
|
||||
// onTap: () {
|
||||
// if (AppConstants().ent_type ==
|
||||
// APPPackageType.MHT.code) {
|
||||
// showTipDialog(
|
||||
// context,
|
||||
// Container(
|
||||
// child: Text(
|
||||
// // "心理健康评估介绍".tr,
|
||||
// "自主神经平衡指数 是评估人体自主神经系统(ANS)功能状态的重要指标,主要反映交感神经和副交感神经的活性平衡关系。"
|
||||
// .tr,
|
||||
// style: TextStyle(
|
||||
// fontSize: 26.rpx,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// backgroundColor: Color(0xFFFFFFFF),
|
||||
// colors: [
|
||||
// Color(0XFF1592AA),
|
||||
// Color(0xFF0C83A7),
|
||||
// Color(0xFF006FA3)
|
||||
// ],
|
||||
// );
|
||||
// } else {
|
||||
// showTipDialog(
|
||||
// context,
|
||||
// Container(
|
||||
// child: Text(
|
||||
// "自主神经平衡指数 是评估人体自主神经系统(ANS)功能状态的重要指标,主要反映交感神经和副交感神经的活性平衡关系。"
|
||||
// .tr,
|
||||
// style: TextStyle(
|
||||
// fontSize: 26.rpx,
|
||||
// color: themeController.currentColor.sc3,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// backgroundColor: themeController.currentColor.sc17,
|
||||
// colors: AppConstants().thNormalButton,
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// child: Container(
|
||||
// padding: EdgeInsetsDirectional.fromSTEB(
|
||||
// 0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
// width: 28.rpx,
|
||||
// height: 28.rpx,
|
||||
// child: SvgPicture.asset(
|
||||
// 'assets/img/icon/explain.svg',
|
||||
// fit: BoxFit.cover,
|
||||
// color: themeController.currentColor.sc4,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 83.rpx,
|
||||
// ),
|
||||
// // 显示level值的文本
|
||||
// // Padding(
|
||||
// // padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 30.rpx),
|
||||
// // child: Row(
|
||||
// // mainAxisAlignment: MainAxisAlignment.center,
|
||||
// // children: [
|
||||
// // Text(
|
||||
// // '当前状态:',
|
||||
// // style: TextStyle(
|
||||
// // fontSize: 30.rpx,
|
||||
// // color: themeController.currentColor.sc4,
|
||||
// // ),
|
||||
// // ),
|
||||
// // Text(
|
||||
// // levelText,
|
||||
// // style: TextStyle(
|
||||
// // fontSize: 36.rpx,
|
||||
// // fontWeight: FontWeight.bold,
|
||||
// // color: levelColor,
|
||||
// // ),
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// // ),
|
||||
// Padding(
|
||||
// padding: EdgeInsetsDirectional.fromSTEB(
|
||||
// 30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
// child: StatusBarWithIndicator(
|
||||
// selectKey: level, // 使用level值作为选中的key
|
||||
// showLabel: showLabel,
|
||||
// currentValueText: "当前属于".tr,
|
||||
// showCurrentValue: true,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 56.rpx,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// } catch (e) {
|
||||
// es.EasyDartModule.logger.error("自主神经平衡指数绘制异常${e}");
|
||||
// return Container();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
@@ -36,6 +279,24 @@ class _ZiZhuShenJingPercentWidgetState
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// 辅助方法:将颜色字符串转换为Color对象
|
||||
Color _getColorFromString(String colorStr) {
|
||||
try {
|
||||
// 如果颜色字符串以#开头,直接使用
|
||||
if (colorStr.startsWith('#')) {
|
||||
return Color(int.parse('0xFF${colorStr.substring(1)}'));
|
||||
}
|
||||
// 如果是6位十六进制颜色码(不带#)
|
||||
else if (colorStr.length == 6) {
|
||||
return Color(int.parse('0xFF$colorStr'));
|
||||
}
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("颜色转换异常:$e");
|
||||
}
|
||||
// 默认返回主题色
|
||||
return themeController.currentColor.sc3;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
@@ -51,55 +312,51 @@ class _ZiZhuShenJingPercentWidgetState
|
||||
|
||||
int level = zzsjphzsData['level'] ?? 0;
|
||||
|
||||
// 根据level值确定显示内容和颜色
|
||||
String levelText = '';
|
||||
Color levelColor = themeController.currentColor.sc3;
|
||||
|
||||
switch (level) {
|
||||
case 0:
|
||||
levelText = '正常';
|
||||
levelColor = Colors.green;
|
||||
break;
|
||||
case 1:
|
||||
levelText = '轻度失衡';
|
||||
levelColor = Colors.orange;
|
||||
break;
|
||||
case 2:
|
||||
levelText = '中度失衡';
|
||||
levelColor = Colors.red;
|
||||
break;
|
||||
case 3:
|
||||
levelText = '重度失衡';
|
||||
levelColor = Colors.red;
|
||||
break;
|
||||
default:
|
||||
levelText = '未知';
|
||||
levelColor = Colors.grey;
|
||||
}
|
||||
// 从reportData中获取type和zs数据
|
||||
Map<String, dynamic> typeData = widget.reportData['type'] ?? {};
|
||||
List<dynamic> zsList = typeData['zs'] ?? [];
|
||||
|
||||
// 构建StatusBarWithIndicator需要的数据格式
|
||||
List<Map<String, dynamic>> showLabel = [
|
||||
{
|
||||
'key': 0,
|
||||
'name': '正常',
|
||||
'color': Colors.green,
|
||||
},
|
||||
{
|
||||
'key': 1,
|
||||
'name': '轻度失衡',
|
||||
'color': Colors.orange,
|
||||
},
|
||||
{
|
||||
'key': 2,
|
||||
'name': '中度失衡',
|
||||
'color': Colors.red,
|
||||
},
|
||||
{
|
||||
'key': 3,
|
||||
'name': '重度失衡',
|
||||
'color': Colors.red,
|
||||
},
|
||||
];
|
||||
List<Map<String, dynamic>> showLabel = [];
|
||||
|
||||
if (zsList.isNotEmpty) {
|
||||
// 从zs数据动态构建showLabel
|
||||
showLabel = zsList.map((item) {
|
||||
return {
|
||||
'key': item['level'] ?? 0,
|
||||
'name': item['name'] ?? '未知',
|
||||
'color': _getColorFromString(item['color'] ?? ''),
|
||||
};
|
||||
}).toList();
|
||||
|
||||
// 按level排序,确保顺序正确
|
||||
showLabel.sort((a, b) => (a['key'] as int).compareTo(b['key'] as int));
|
||||
} else {
|
||||
// 如果zs数据为空,使用默认数据作为后备方案
|
||||
es.EasyDartModule.logger.warning("自主神经平衡指数zs数据为空,使用默认配置");
|
||||
showLabel = [
|
||||
{
|
||||
'key': 0,
|
||||
'name': '正常',
|
||||
'color': Colors.green,
|
||||
},
|
||||
{
|
||||
'key': 1,
|
||||
'name': '轻度失衡',
|
||||
'color': Colors.orange,
|
||||
},
|
||||
{
|
||||
'key': 2,
|
||||
'name': '中度失衡',
|
||||
'color': Colors.red,
|
||||
},
|
||||
{
|
||||
'key': 3,
|
||||
'name': '重度失衡',
|
||||
'color': Colors.red,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
@@ -193,30 +450,6 @@ class _ZiZhuShenJingPercentWidgetState
|
||||
SizedBox(
|
||||
height: 83.rpx,
|
||||
),
|
||||
// 显示level值的文本
|
||||
// Padding(
|
||||
// padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 30.rpx),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Text(
|
||||
// '当前状态:',
|
||||
// style: TextStyle(
|
||||
// fontSize: 30.rpx,
|
||||
// color: themeController.currentColor.sc4,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// levelText,
|
||||
// style: TextStyle(
|
||||
// fontSize: 36.rpx,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: levelColor,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
|
||||
Reference in New Issue
Block a user