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

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

View File

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