修改设备信息 其他页面刷新

This commit is contained in:
czz
2025-07-01 09:01:24 +08:00
parent 0e0f475536
commit a56e2b6eea
2 changed files with 39 additions and 23 deletions

View File

@@ -11,13 +11,23 @@ import 'package:vbvs_app/model/api_response.dart';
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart'; import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
class BluetoothPage extends GetView { class BluetoothPage extends StatefulWidget {
Map data; final Map data;
BluetoothPage({required this.data}); BluetoothPage({Key? key, required this.data});
@override
_BluetoothPageState createState() => _BluetoothPageState();
}
class _BluetoothPageState extends State<BluetoothPage> {
late RxMap<String, dynamic> obsData;
@override
void initState() {
super.initState();
obsData = Map<String, dynamic>.from(widget.data).obs; // 复制成 obs
}
BoxConstraints? bodysize; BoxConstraints? bodysize;
DeviceListController deviceListController = Get.find(); DeviceListController deviceListController = Get.find();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, cc) { return LayoutBuilder(builder: (context, cc) {
@@ -77,7 +87,7 @@ class BluetoothPage extends GetView {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
data['name']?.toString() ?? '未命名', obsData['name']?.toString() ?? '未命名',
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 40.rpx, fontSize: 40.rpx,
@@ -88,9 +98,15 @@ class BluetoothPage extends GetView {
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
highlightColor: const Color(0xFF055466), highlightColor: const Color(0xFF055466),
padding: EdgeInsets.only(left: 0), padding: EdgeInsets.only(left: 0),
onTap: () { onTap: () async {
Get.toNamed("/editBedPage", var x = await Get.toNamed(
arguments: data); "/editBedPage",
arguments: obsData);
if (x != null) {
setState(() {
obsData.addAll(x); // 值更新后主动刷新页面
});
}
}, },
child: Container( child: Container(
width: 42.rpx, width: 42.rpx,
@@ -103,7 +119,7 @@ class BluetoothPage extends GetView {
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text(data['mac']?.toString() ?? '未命名', Text(obsData['mac']?.toString() ?? '未命名',
style: TextStyle( style: TextStyle(
color: Colors.white70, fontSize: 26.rpx)), color: Colors.white70, fontSize: 26.rpx)),
@@ -112,7 +128,7 @@ class BluetoothPage extends GetView {
// 蓝牙连接状态 // 蓝牙连接状态
Column( Column(
children: [ children: [
data['blueToothStatus'] == 1 obsData['blueToothStatus'] == 1
? SvgPicture.asset( ? SvgPicture.asset(
'assets/img/icon/blue_fail.svg', 'assets/img/icon/blue_fail.svg',
width: 68.rpx, width: 68.rpx,
@@ -126,11 +142,11 @@ class BluetoothPage extends GetView {
SizedBox(height: 4), SizedBox(height: 4),
//下面文字和颜色也根据上面变化 //下面文字和颜色也根据上面变化
Text( Text(
data['blueToothStatus'] == 1 obsData['blueToothStatus'] == 1
? '未连接' ? '未连接'
: '已连接', : '已连接',
style: TextStyle( style: TextStyle(
color: data['blueToothStatus'] == 1 color: obsData['blueToothStatus'] == 1
? Color(0xFFFF7159) ? Color(0xFFFF7159)
: Color(0xFF6BFDAC), : Color(0xFF6BFDAC),
fontSize: 26.rpx)), fontSize: 26.rpx)),
@@ -148,13 +164,13 @@ class BluetoothPage extends GetView {
children: [ children: [
_buildMenuButton( _buildMenuButton(
context, '详情', "/devicePeopleInfo", context, '详情', "/devicePeopleInfo",
arguments: data), arguments: obsData),
_buildMenuButton( _buildMenuButton(
context, '人员资料', "/peopleInfoPage", context, '人员资料', "/peopleInfoPage",
arguments: data), arguments: obsData,),
_buildMenuButton( _buildMenuButton(
context, '房间选择', "/roomPickerPage", context, '房间选择', "/roomPickerPage",
arguments: data), arguments: obsData),
_buildMenuButton(context, '设备校准', ""), _buildMenuButton(context, '设备校准', ""),
_buildMenuButton(context, '体征传感器', ""), _buildMenuButton(context, '体征传感器', ""),
_buildMenuButton(context, 'WIFI配置', ""), _buildMenuButton(context, 'WIFI配置', ""),
@@ -162,20 +178,20 @@ class BluetoothPage extends GetView {
context, '睡眠习惯', "/sleepHabitPage"), context, '睡眠习惯', "/sleepHabitPage"),
_buildMenuButton( _buildMenuButton(
context, '分享设备', "/deviceSharePage", context, '分享设备', "/deviceSharePage",
arguments: data), arguments: obsData),
_buildMenuButton( _buildMenuButton(
context, context,
data['bind_type'] == 1 ? '解绑' : '删除', obsData['bind_type'] == 1 ? '解绑' : '删除',
"", "",
onTap: () { onTap: () {
if (data['bind_type'] == 1) { if (obsData['bind_type'] == 1) {
// 解绑弹窗 // 解绑弹窗
showUnbindConfirmDialog( showUnbindConfirmDialog(
context: context, context: context,
title: "是否进行解绑?", title: "是否进行解绑?",
onConfirm: () async { onConfirm: () async {
await deviceListController await deviceListController
.unbindDevice(data); .unbindDevice(obsData);
await deviceListController await deviceListController
.getDeviceList(); .getDeviceList();
try { try {
@@ -195,7 +211,7 @@ class BluetoothPage extends GetView {
// 点击取消后的逻辑 // 点击取消后的逻辑
}, },
); );
} else if (data['bind_type'] == 2) { } else if (obsData['bind_type'] == 2) {
// 删除弹窗 // 删除弹窗
showDeleteDeviceConfirmDialog( showDeleteDeviceConfirmDialog(
context: context, context: context,
@@ -203,7 +219,7 @@ class BluetoothPage extends GetView {
onConfirm: () async { onConfirm: () async {
await deviceListController await deviceListController
.unbindDevice( .unbindDevice(
data, obsData,
); );
await deviceListController await deviceListController
.getDeviceList(); .getDeviceList();

View File

@@ -189,7 +189,7 @@ class _RoomPickerPageState extends State<RoomPickerPage> {
"roomId": rooms[selectedIndex]['_id'], "roomId": rooms[selectedIndex]['_id'],
}, },
onSuccess: (res) { onSuccess: (res) {
Get.back();
TopSlideNotification.show(context, TopSlideNotification.show(context,
text: "更新成功".tr, text: "更新成功".tr,
textColor: Color(0XFF00C1AA)); textColor: Color(0XFF00C1AA));
@@ -202,7 +202,7 @@ class _RoomPickerPageState extends State<RoomPickerPage> {
} catch (e) { } catch (e) {
ef.log("[h5]通知列表更新错误:$e"); ef.log("[h5]通知列表更新错误:$e");
} }
Get.toNamed('bluetoothPage'); Get.back(result:editedData);
}, },
onFailure: (res) { onFailure: (res) {
TopSlideNotification.show(context, TopSlideNotification.show(context,