From ca1995372c12f6f776eb1c6aebe240f84bc5aaa9 Mon Sep 17 00:00:00 2001
From: czz <862977248@qq.com>
Date: Sat, 21 Jun 2025 17:55:47 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9D=80=E6=8E=A5=E5=8F=A3=E7=9A=84?=
=?UTF-8?q?=E8=A7=86=E7=BA=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
assets/img/icon/blue_fail.svg | 151 +++++
assets/img/icon/blue_success.svg | 151 +++++
lib/common/util/MyUtils.dart | 13 +
lib/component/img/img_default_widget.dart | 8 +-
lib/component/img/img_preview_widget.dart | 4 +-
.../mh_controller/people_info_controller.dart | 5 +-
.../mh_controller/repair_list_controller.dart | 51 +-
lib/controller/repair/repair_controller.dart | 70 ---
lib/pages/mh_page/MattressControl.dart | 12 +-
lib/pages/mh_page/apply_repair_page.dart | 579 +++++-------------
lib/pages/mh_page/bluetooth.dart | 29 +-
.../device/mht_blueteeth_device_page.dart | 3 +-
lib/pages/mh_page/edit_bed.dart | 6 +-
lib/pages/mh_page/repair_history_widget.dart | 160 +----
.../repair/component/RepairModelWidget.dart | 11 +-
lib/routers/mh_routers.dart | 3 +-
16 files changed, 593 insertions(+), 663 deletions(-)
create mode 100644 assets/img/icon/blue_fail.svg
create mode 100644 assets/img/icon/blue_success.svg
diff --git a/assets/img/icon/blue_fail.svg b/assets/img/icon/blue_fail.svg
new file mode 100644
index 0000000..4af3dc9
--- /dev/null
+++ b/assets/img/icon/blue_fail.svg
@@ -0,0 +1,151 @@
+
diff --git a/assets/img/icon/blue_success.svg b/assets/img/icon/blue_success.svg
new file mode 100644
index 0000000..71594f8
--- /dev/null
+++ b/assets/img/icon/blue_success.svg
@@ -0,0 +1,151 @@
+
diff --git a/lib/common/util/MyUtils.dart b/lib/common/util/MyUtils.dart
index 2dbd632..9cb224e 100644
--- a/lib/common/util/MyUtils.dart
+++ b/lib/common/util/MyUtils.dart
@@ -119,6 +119,19 @@ class MyUtils {
return formatter.format(dateTime);
}
+ static String formatTimestamp(int timestamp) {
+ try {
+ // 将毫秒时间戳转换为 DateTime
+ DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
+
+ // 格式化为你想要的样式,比如 'yyyy-MM-dd HH:mm'
+ final DateFormat formatter = DateFormat('yyyy-MM-dd HH:mm');
+ return formatter.format(dateTime);
+ } catch (e) {
+ return '';
+ }
+ }
+
static void scrollToFocusedInput(FocusNode focusNode, _scrollController) {
// 获取输入框相对于整个页面的偏移量
RenderObject? object = focusNode.context?.findRenderObject();
diff --git a/lib/component/img/img_default_widget.dart b/lib/component/img/img_default_widget.dart
index 049cff5..db00a65 100644
--- a/lib/component/img/img_default_widget.dart
+++ b/lib/component/img/img_default_widget.dart
@@ -1,5 +1,6 @@
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
+import 'package:vbvs_app/controller/repair/repair_controller.dart';
import '../../controller/mh_controller/apply_repair_controller.dart';
@@ -7,12 +8,13 @@ class ImgPreviewDefaultWidget extends GetView {
ApplyRepairController applyRepairController;
ImgPreviewDefaultWidget({required this.applyRepairController}) {}
-
+ RepairController repairController = Get.find();
@override
Widget build(BuildContext context) {
return InkWell(
- // onTap: applyRepairController.uploadImg,
- onTap: () async {},
+ onTap: () async {
+ await applyRepairController.uploadImg();
+ },
child: Container(
width: MediaQuery.sizeOf(context).width * 0.25,
height: MediaQuery.sizeOf(context).height * 0.15,
diff --git a/lib/component/img/img_preview_widget.dart b/lib/component/img/img_preview_widget.dart
index 5b70c42..d3735f9 100644
--- a/lib/component/img/img_preview_widget.dart
+++ b/lib/component/img/img_preview_widget.dart
@@ -41,9 +41,9 @@ class ImgPreviewWidget extends GetView {
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.network(
- 'https://picsum.photos/seed/73/600',
- // applyRepairController.getPublicUrl(imgUrl),
+ imgUrl,
+ // applyRepairController.getPublicUrl(imgUrl),
width: 300,
height: 200,
fit: BoxFit.cover,
diff --git a/lib/controller/mh_controller/people_info_controller.dart b/lib/controller/mh_controller/people_info_controller.dart
index 27d1622..61c8659 100644
--- a/lib/controller/mh_controller/people_info_controller.dart
+++ b/lib/controller/mh_controller/people_info_controller.dart
@@ -39,8 +39,9 @@ class PeopleInfoController extends GetControllerEx {
}
@override
- Future initData(String mac) async {
- await getPeoples(mac); // 控制器创建时立即执行
+ Future onInit() async {
+ super.onInit();
+ await getPeoples(Get.arguments['mac']); // 控制器创建时立即执行
}
getPeoples(String mac) async {
diff --git a/lib/controller/mh_controller/repair_list_controller.dart b/lib/controller/mh_controller/repair_list_controller.dart
index 53262f3..4661862 100644
--- a/lib/controller/mh_controller/repair_list_controller.dart
+++ b/lib/controller/mh_controller/repair_list_controller.dart
@@ -1,6 +1,9 @@
import 'package:ef/ef.dart';
import 'package:json_annotation/json_annotation.dart';
+import 'package:vbvs_app/common/color/ServiceConstant.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
+import 'package:vbvs_app/common/util/requestWithLog.dart';
+import 'package:vbvs_app/model/api_response.dart';
import 'apply_repair_controller.dart';
part 'repair_list_controller.g.dart';
@@ -11,7 +14,7 @@ class RepairListModel {
bool isLoading = false;
bool hasMore = true;
- List repairList = [];
+ List repairList = [];
RepairListModel();
static RepairListModel fromJson(Map json) =>
@@ -20,34 +23,32 @@ class RepairListModel {
}
class RepairListController extends GetControllerEx {
- // RepairRepository repairRepository = RepairRepository();
RepairListController() {
attr = GetModel(RepairListModel()).obs;
}
- // //初始化列表数据
- // Future initData() async {
- // if (model.isLoading) {
- // return;
- // }
- // model.isLoading = true;
- // final List fetchedRepairs = await repairRepository.fetchRepairs(
- // limit: model.limit, offset: model.offset);
- // if (fetchedRepairs != null) {
- // List infos = [];
- // List tmp = fetchedRepairs as List;
- // try {
- // infos = tmp.map((repair) => ApplyRepairModel.fromJson(repair)).toList();
- // model.repairList.addAll(infos);
- // } catch (e) {
- // print('Error parsing JSON: $e');
- // }
- // }
- // model.offset += model.limit; // 更新 offset,下一次查询跳过当前已经加载的记录
- // model.hasMore = fetchedRepairs.length == model.limit; // 判断是否还有更多数据
- // model.isLoading = false;
- // updateAll();
- // }
+ //初始化列表数据
+ @override
+ Future onInit() async {
+ super.onInit();
+ await getRepairList();
+ }
+
+ getRepairList() async {
+ String serviceAddress = ServiceConstant.service_address;
+ String serviceName = ServiceConstant.server_service;
+ String serviceApi = ServiceConstant.submit_repair;
+ String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
+ requestWithLog(
+ logTitle: "查询报修数据",
+ method: MyHttpMethod.get,
+ queryUrl: queryUrl,
+ onSuccess: (res) {
+ model.repairList = res.data;
+ updateAll();
+ },
+ );
+ }
// Future addScore(int id, int score) async {
// return await repairRepository.addScore(id, score);
diff --git a/lib/controller/repair/repair_controller.dart b/lib/controller/repair/repair_controller.dart
index b909bf2..a400825 100644
--- a/lib/controller/repair/repair_controller.dart
+++ b/lib/controller/repair/repair_controller.dart
@@ -108,74 +108,4 @@ class RepairController extends GetControllerEx {
return ApiResponse(code: -1, msg: "服务器.失败".tr);
}
}
-
- // Future uploadImg() async {
- // EasyDartModule.logger.info("请求上传媒体文件");
- // DailyLogUtils.writeLog("请求上传媒体文件");
- // final ImagePicker picker = ImagePicker();
- // final XFile? file = await picker.pickMedia(); // ✅ 支持图片或视频
-
- // try {
- // ApiResponse apiResponse = ApiResponse(code: -1, msg: "我的.媒体上传失败".tr);
- // if (file == null) {
- // apiResponse.msg = "我的.未选择文件".tr;
- // return apiResponse;
- // }
-
- // final String filePath = file.path;
- // final String fileName = filePath.split('/').last;
- // final int fileSize = await file.length();
-
- // final isImage = filePath.endsWith(".jpg") ||
- // filePath.endsWith(".jpeg") ||
- // filePath.endsWith(".png") ||
- // filePath.endsWith(".gif");
- // final isVideo = filePath.endsWith(".mp4") ||
- // filePath.endsWith(".mov") ||
- // filePath.endsWith(".avi") ||
- // filePath.endsWith(".mkv");
-
- // // 限制大小
- // if (isImage && fileSize > 1048576 * 5) {
- // apiResponse.msg = "上传限制(图片最大5MB)".tr;
- // return apiResponse;
- // } else if (isVideo && fileSize > 1048576 * 50) {
- // apiResponse.msg = "上传限制(视频最大50MB)".tr;
- // return apiResponse;
- // }
-
- // // 构建上传地址
- // String queryUrl =
- // "${ServiceConstant.service_address}${ServiceConstant.server_service}${ServiceConstant.upload_file}";
- // String? language =
- // languageController.selectLanguage?.value?.language_code;
- // if (language != null && language.isNotEmpty) {
- // queryUrl +=
- // queryUrl.contains("?") ? "&lang=$language" : "?lang=$language";
- // }
-
- // // 构建 formData
- // var formData = dio.FormData.fromMap({
- // "type": 2,
- // "file": await dio.MultipartFile.fromFile(filePath, filename: fileName),
- // });
-
- // var response = await EasyDartModule.dio.post(queryUrl, data: formData);
- // if (response != null) {
- // var responseData =
- // response.data is String ? jsonDecode(response.data) : response.data;
- // ApiResponse res =
- // ApiResponse.fromJson(responseData, (object) => object);
- // MyUtils.formatResponse(res, "我的.上传成功".tr, "我的.媒体上传失败".tr);
- // updateAll();
- // return res;
- // } else {
- // return ApiResponse(code: -1, msg: "服务器.失败".tr);
- // }
- // } catch (e) {
- // EasyDartModule.logger.error("上传媒体失败->$e");
- // DailyLogUtils.writeError("上传媒体失败->$e");
- // return ApiResponse(code: -1, msg: "服务器.失败".tr);
- // }
- // }
}
diff --git a/lib/pages/mh_page/MattressControl.dart b/lib/pages/mh_page/MattressControl.dart
index 55856b5..a752521 100644
--- a/lib/pages/mh_page/MattressControl.dart
+++ b/lib/pages/mh_page/MattressControl.dart
@@ -42,7 +42,8 @@ class _MattressControlPageState extends State {
"failure": 0,
"updateTime": -1
},
- "code": "545024122666"
+ "code": "545024122666",
+ "blueToothStatus": 1
};
int selectedIndex = 1; // 当前选中的tab索引
@override
@@ -120,16 +121,13 @@ class _MattressControlPageState extends State {
highlightColor: Colors.transparent,
padding: EdgeInsets.only(right: 69.rpx),
onTap: () {},
- child: Image.asset(
+ child:
+ //根据data['status']判断用那个svg
+ Image.asset(
'assets/images/active_bluetooth.png',
width: 42.rpx,
height: 42.rpx,
),
- // Icon(
- // Icons.bluetooth,
- // color: Colors.white,
- // size: 42.rpx,
- // ),
),
ClickableContainer(
backgroundColor: Colors.transparent,
diff --git a/lib/pages/mh_page/apply_repair_page.dart b/lib/pages/mh_page/apply_repair_page.dart
index b77b3b6..8250901 100644
--- a/lib/pages/mh_page/apply_repair_page.dart
+++ b/lib/pages/mh_page/apply_repair_page.dart
@@ -13,17 +13,21 @@ import 'package:vbvs_app/component/img/img_preview_widget.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/mh_controller/apply_repair_controller.dart';
+import 'package:vbvs_app/controller/mh_controller/repair_list_controller.dart';
import 'package:vbvs_app/controller/repair/repair_controller.dart';
import 'package:vbvs_app/model/api_response.dart';
+import 'package:vbvs_app/pages/mh_page/applyRepair/apply_repair_success.dart';
class ApplyRepairPage extends GetView {
final scaffoldKey = GlobalKey();
BoxConstraints? bodysize;
- RepairController repairController = Get.find();
+
+ RepairListController repairListController = Get.find();
+ ApplyRepairController applyRepairController = Get.find();
ApplyRepairPage() {
controller.attr.value.listenlists.clear();
controller.getDeviceList();
- controller.model.device_type = "";
+ controller.model.device_type = null;
controller.model.select_device = "";
controller.model.device_category = "";
controller.model.device_name = "";
@@ -37,9 +41,6 @@ class ApplyRepairPage extends GetView {
Widget build(BuildContext context) {
var tmpcontroller =
FormFieldController(controller.model.select_device);
- var typecontroller =
- FormFieldController(controller.model.device_type);
- controller.model.address;
List deviceTypeNames = ['床', '床垫'];
List deviceTypeIds = ['床', '床垫'];
return LayoutBuilder(builder: (context, cc) {
@@ -259,9 +260,10 @@ class ApplyRepairPage extends GetView {
(val) {
var selectedDevice = controller.model.device_list!.firstWhere((device) => device['_id'].toString() == val);
controller.model.select_device = val;
- controller.model.device_type = selectedDevice['type'] == 1 ? '床' : '床垫';
- controller.model.device_category = selectedDevice['deviceSeries']['name'] ?? '未知型号'; // 获取设备型号
- controller.model.device_id = selectedDevice['mac'] ?? '未知设备ID'; // 获取设备ID
+ controller.model.device_type = selectedDevice['device_type'];
+ // controller.model.device_category = selectedDevice['deviceSeries']['name'] ?? '未知型号'; // 获取设备型号
+ controller.model.device_category = '未知型号';
+ controller.model.device_id = selectedDevice['_id'] ?? '未知设备ID'; // 获取设备ID
controller.model.device_name = selectedDevice['name'] ?? '未知设备'; // 获取设备名称
controller.updateAll();
},
@@ -373,107 +375,24 @@ class ApplyRepairPage extends GetView {
),
Expanded(
child: Container(
- width: 100,
- height: 100,
- decoration:
- BoxDecoration(
- color: Colors
- .white,
- borderRadius:
- BorderRadius
- .circular(
- 8),
- ),
- child:
- TextFormField(
- // autofocus: true,
- onChanged:
- (value) {
- controller
- .model
- .device_type =
- value;
- },
- obscureText:
- false,
+ width: 100,
+ height: 100,
decoration:
- InputDecoration(
- isDense:
- true,
- labelStyle:
- const TextStyle(
- fontFamily:
- 'Readex Pro',
- letterSpacing:
- 0,
- ),
- hintStyle:
- const TextStyle(
- fontFamily:
- 'Readex Pro',
- letterSpacing:
- 0,
- ),
- enabledBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- color: const Color(
- 0x00000000),
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- AppConstants().normal_container_radius),
- ),
- focusedBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- color: Colors
- .transparent,
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
- errorBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- //
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
- focusedErrorBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- //
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
+ BoxDecoration(
+ color: Colors
+ .white,
+ borderRadius:
+ BorderRadius
+ .circular(8),
),
- style: TextStyle(
- letterSpacing:
- 0,
- color: Colors
- .black,
- fontSize:
- 26.rpx),
- ),
- ),
+ child: Padding(
+ padding: EdgeInsets.only(left: 26.rpx),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Obx(() => Text(
+ getDeviceTypeName(controller.model.device_type),
+ style: TextStyle(fontSize: 26.rpx, color: Colors.black),
+ ))))),
),
].divide(SizedBox(
width: 26.rpx)),
@@ -526,107 +445,24 @@ class ApplyRepairPage extends GetView {
),
Expanded(
child: Container(
- width: 100,
- height: 100,
- decoration:
- BoxDecoration(
- color: Colors
- .white,
- borderRadius:
- BorderRadius
- .circular(
- 8),
- ),
- child:
- TextFormField(
- // autofocus: true,
- onChanged:
- (value) {
- controller
- .model
- .device_category =
- value;
- },
- obscureText:
- false,
+ width: 100,
+ height: 100,
decoration:
- InputDecoration(
- isDense:
- true,
- labelStyle:
- const TextStyle(
- fontFamily:
- 'Readex Pro',
- letterSpacing:
- 0,
- ),
- hintStyle:
- const TextStyle(
- fontFamily:
- 'Readex Pro',
- letterSpacing:
- 0,
- ),
- enabledBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- color: const Color(
- 0x00000000),
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- AppConstants().normal_container_radius),
- ),
- focusedBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- color: Colors
- .transparent,
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
- errorBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- //
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
- focusedErrorBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- //
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
+ BoxDecoration(
+ color: Colors
+ .white,
+ borderRadius:
+ BorderRadius
+ .circular(8),
),
- style: TextStyle(
- letterSpacing:
- 0,
- color: Colors
- .black,
- fontSize:
- 26.rpx),
- ),
- ),
+ child: Padding(
+ padding: EdgeInsets.only(left: 26.rpx),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Obx(() => Text(
+ controller.model.device_category ?? '',
+ style: TextStyle(fontSize: 26.rpx, color: Colors.black),
+ ))))),
),
].divide(SizedBox(
width: 26.rpx)),
@@ -679,107 +515,24 @@ class ApplyRepairPage extends GetView {
),
Expanded(
child: Container(
- width: 100,
- height: 100,
- decoration:
- BoxDecoration(
- color: const Color(
- 0xFFF3F5F6),
- borderRadius:
- BorderRadius
- .circular(
- 8),
- ),
- child:
- TextFormField(
- // autofocus: true,
- onChanged:
- (value) {
- controller
- .model
- .device_id =
- value;
- },
- obscureText:
- false,
+ width: 100,
+ height: 100,
decoration:
- InputDecoration(
- isDense:
- true,
- labelStyle:
- const TextStyle(
- fontFamily:
- 'Readex Pro',
- letterSpacing:
- 0,
- ),
- hintStyle:
- const TextStyle(
- fontFamily:
- 'Readex Pro',
- letterSpacing:
- 0,
- ),
- enabledBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- color: const Color(
- 0x00000000),
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- AppConstants().normal_container_radius),
- ),
- focusedBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- color: Colors
- .transparent,
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
- errorBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- //
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
- focusedErrorBorder:
- OutlineInputBorder(
- borderSide:
- BorderSide(
- //
- width: 1
- .rpx,
- ),
- borderRadius:
- BorderRadius.circular(
- 8.rpx),
- ),
+ BoxDecoration(
+ color: Colors
+ .white,
+ borderRadius:
+ BorderRadius
+ .circular(8),
),
- style: TextStyle(
- letterSpacing:
- 0,
- color: Colors
- .black,
- fontSize:
- 26.rpx),
- ),
- ),
+ child: Padding(
+ padding: EdgeInsets.only(left: 26.rpx),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Obx(() => Text(
+ controller.model.device_id ?? '',
+ style: TextStyle(fontSize: 26.rpx, color: Colors.black),
+ ))))),
),
].divide(SizedBox(
width: 26.rpx)),
@@ -833,21 +586,11 @@ class ApplyRepairPage extends GetView {
child: InkWell(
onTap: () async {
ApiResponse apiResponse =
- await repairController
+ await applyRepairController
.uploadImg();
- print(apiResponse);
+
if (apiResponse.code ==
HttpStatusCodes.ok) {
- print(controller.model);
- // setState(() {
- // controller.model['path'] = apiResponse.data['path'];
- // });
- controller.model.issue_img!
- .add(apiResponse
- .data['path']);
- repairController.repairList
- .refresh(); // 通知 Obx 更新(如果用了 GetX)
- print(controller.model);
} else {
if (controller.model
.issue_img ==
@@ -1702,53 +1445,58 @@ class ApplyRepairPage extends GetView {
borderRadius: 16.rpx,
gradientDirection: GradientDirection.vertical,
onTap: () async {
- TopSlideNotification.show(
- context,
- text: "功能开发中...",
- );
- // Get.toNamed("/applyRepairSuccess");
- // String msg = checkRepairParam();
- // if (msg.isNotEmpty) {
- // TopSlideNotification.show(context,
- // text: msg,
- // textColor:
- // themeController.currentColor.sc9);
- // } else {
- // String serviceAddress =
- // ServiceConstant.service_address;
- // String serviceName =
- // ServiceConstant.server_service;
- // String serviceApi =
- // ServiceConstant.submit_repair;
- // String queryUrl =
- // "$serviceAddress$serviceName$serviceApi";
- // var data = {
- // "device": repairController.repairList.value,
- // "type": repairController.device_type.value,
- // "contacts": {
- // "name": repairController.name.value,
- // "phone": repairController.phone.value
- // },
- // };
- // ApiResponse apiResponse = await requestWithLog(
- // logTitle: "提交报修信息",
- // method: MyHttpMethod.post,
- // queryUrl: queryUrl,
- // data: data,
- // onSuccess: (res) {
- // TopSlideNotification.show(context,
- // text: res.msg!);
- // // Get.back();
- // Get.toNamed("/applyRepairSuccess");
- // },
- // onFailure: (res) {
- // TopSlideNotification.show(context,
- // text: res.msg!,
- // textColor:
- // themeController.currentColor.sc9);
- // },
- // );
- //}
+ String msg = checkRepairParam();
+ if (msg.isNotEmpty) {
+ TopSlideNotification.show(context,
+ text: msg,
+ textColor:
+ themeController.currentColor.sc9);
+ } else {
+ String serviceAddress =
+ ServiceConstant.service_address;
+ String serviceName =
+ ServiceConstant.server_service;
+ String serviceApi =
+ ServiceConstant.submit_repair;
+ String queryUrl =
+ "$serviceAddress$serviceName$serviceApi";
+ var data = {
+ "type": controller.model.device_type,
+ "contacts": {
+ "name": controller.model.apply_name,
+ "phone": controller.model.tel,
+ },
+ "device": [
+ {
+ "mac": controller.model.device_id,
+ "desc": controller.model.desc,
+ "img": controller.model.issue_img,
+ }
+ ],
+ };
+ ApiResponse apiResponse = await requestWithLog(
+ logTitle: "提交报修信息",
+ method: MyHttpMethod.post,
+ queryUrl: queryUrl,
+ data: data,
+ onSuccess: (res) {
+ TopSlideNotification.show(context,
+ text: res.msg!);
+
+ Get.toNamed("/applyRepairSuccess");
+ // repairListController.getRepairList();
+ },
+ onFailure: (res) {
+ TopSlideNotification.show(context,
+ text: res.msg!,
+ textColor:
+ themeController.currentColor.sc9);
+ },
+ );
+ controller.model =
+ ApplyRepairModel(); // 在 submitRepair 完成后执行
+ controller.updateAll();
+ }
},
colors: const [
Color(0xFFFCFCFC),
@@ -1819,61 +1567,54 @@ class ApplyRepairPage extends GetView {
}
String checkRepairParam() {
- String errormsg = "";
+ String message = "";
- // 检查报修项
- for (var i = 0; i < repairController.repairList.length; i++) {
- final item = repairController.repairList[i];
+ if (controller.model.device_type == null ||
+ controller.model.device_type == 0) {
+ message = '请选择设备类型!';
+ return message;
+ }
+ if (controller.model.device_category == null ||
+ controller.model.device_category!.isEmpty) {
+ message = '请输入设备型号!';
+ return message;
+ }
+ if (controller.model.device_id == null ||
+ controller.model.device_id!.isEmpty) {
+ message = '请输入设备序列号id!';
+ return message;
+ }
+ if (controller.model.apply_name == null ||
+ controller.model.apply_name!.isEmpty) {
+ message = '请输入姓名!';
+ return message;
+ }
+ RegExp nameRegExp = RegExp(r'^[\u4e00-\u9fa5]{2,4}$');
- if (item["path"] == null || item["path"].toString().isEmpty) {
- _scrollToKey(repairItemKeys[i]);
- // return "第 ${i + 1} 项图片未上传";
- return "图片未上传".tr;
- }
- if (item["id"] == null || item["id"].toString().isEmpty) {
- _scrollToKey(repairItemKeys[i]);
- // return "第 ${i + 1} 项设备未选择";
- return "设备未选择".tr;
- }
- if (item["param"] == null || item["param"].toString().isEmpty) {
- _scrollToKey(repairItemKeys[i]);
- // return "第 ${i + 1} 项参数未填写";
- return "参数未填写".tr;
- }
- if (item["issue"] == null || item["issue"].toString().isEmpty) {
- _scrollToKey(repairItemKeys[i]);
- // return "第 ${i + 1} 项问题描述未填写";
- return "问题描述未填写".tr;
- }
- if (item["issue"] != null && item["issue"].toString().trim().isNotEmpty) {
- final issueText = item["issue"].toString().trim();
- final charCount = issueText.runes.length;
+ if (!nameRegExp.hasMatch(controller.model.apply_name!)) {
+ message = '姓名必须为2到4个汉字!';
- if (charCount > 60) {
- _scrollToKey(repairItemKeys[i]);
- return "问题描述最多输入60个字".tr;
- }
- } else {
- _scrollToKey(repairItemKeys[i]);
- return "问题描述不能为空".tr;
- }
+ return message;
+ }
+ if (controller.model.tel == null || controller.model.tel!.isEmpty) {
+ message = '请输入手机号!';
+ return message;
+ }
+ if (!MyUtils.isValidPhoneNumber(controller.model.tel!)) {
+ message = '无效的手机号!';
+ return message;
}
- // 检查联系人
- if (repairController.name.trim().isEmpty) {
- _scrollToKey(contactKey);
- return "联系人不能为空".tr;
+ if (controller.model.desc == null || controller.model.desc!.isEmpty) {
+ message = '请输入问题描述!';
+ return message;
}
- if (repairController.phone.trim().isEmpty) {
- _scrollToKey(phoneKey);
- return "联系电话不能为空".tr;
+ if (controller.model.issue_img == null ||
+ controller.model.issue_img!.isEmpty) {
+ message = '请至少上传一张问题图片!';
+ return message;
}
- if (!MyUtils.isValidPhoneNumber(repairController.phone.trim())) {
- _scrollToKey(phoneKey);
- return "无效的手机号码".tr;
- }
-
- return errormsg;
+ return message;
}
// 新增滚动方法
@@ -1886,4 +1627,18 @@ class ApplyRepairPage extends GetView {
);
});
}
+
+ String getDeviceTypeName(int? type) {
+ if (type == null) return '';
+ switch (type) {
+ case 1:
+ return '体征检测设备';
+ case 2:
+ return '智能床';
+ case 3:
+ return '智能床垫';
+ default:
+ return '未知设备';
+ }
+ }
}
diff --git a/lib/pages/mh_page/bluetooth.dart b/lib/pages/mh_page/bluetooth.dart
index 0075f95..d6f3312 100644
--- a/lib/pages/mh_page/bluetooth.dart
+++ b/lib/pages/mh_page/bluetooth.dart
@@ -107,15 +107,27 @@ class BluetoothPage extends GetView {
// 蓝牙连接状态
Column(
children: [
- Image.asset(
- 'assets/images/active_bluetooth.png',
- width: 68.rpx,
- height: 68.rpx,
- ),
+ data['blueToothStatus'] == 1
+ ? SvgPicture.asset(
+ 'assets/img/icon/blue_fail.svg',
+ width: 68.rpx,
+ height: 68.rpx,
+ )
+ : SvgPicture.asset(
+ 'assets/img/icon/blue_success.svg',
+ width: 68.rpx,
+ height: 68.rpx,
+ ),
SizedBox(height: 4),
- Text('已连接',
+ //下面文字和颜色也根据上面变化
+ Text(
+ data['blueToothStatus'] == 1
+ ? '未连接'
+ : '已连接',
style: TextStyle(
- color: Color(0xFF6BFDAC),
+ color: data['blueToothStatus'] == 1
+ ? Color(0xFFFF7159)
+ : Color(0xFF6BFDAC),
fontSize: 26.rpx)),
],
),
@@ -136,7 +148,8 @@ class BluetoothPage extends GetView {
context, '人员资料', "/peopleInfoPage",
arguments: data),
_buildMenuButton(
- context, '房间选择', "/roomPickerPage",arguments: data),
+ context, '房间选择', "/roomPickerPage",
+ arguments: data),
_buildMenuButton(context, '设备校准', ""),
_buildMenuButton(context, '体征传感器', ""),
_buildMenuButton(context, 'WIFI配置', ""),
diff --git a/lib/pages/mh_page/device/mht_blueteeth_device_page.dart b/lib/pages/mh_page/device/mht_blueteeth_device_page.dart
index dcb9acd..baa0b1a 100644
--- a/lib/pages/mh_page/device/mht_blueteeth_device_page.dart
+++ b/lib/pages/mh_page/device/mht_blueteeth_device_page.dart
@@ -631,7 +631,8 @@ class _MHTBlueteethDevicePageState extends State {
)),
)),
Padding(
- padding: EdgeInsetsDirectional.fromSTEB(0, 52.rpx, 0, 0),
+ padding:
+ EdgeInsetsDirectional.fromSTEB(0, 52.rpx, 0, 30.rpx),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
diff --git a/lib/pages/mh_page/edit_bed.dart b/lib/pages/mh_page/edit_bed.dart
index 1d64fd8..466f414 100644
--- a/lib/pages/mh_page/edit_bed.dart
+++ b/lib/pages/mh_page/edit_bed.dart
@@ -5,6 +5,7 @@ import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/common/util/requestWithLog.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
+import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
class EditBedPage extends StatefulWidget {
final Map data;
@@ -171,6 +172,8 @@ class _EditBedPageState extends State {
style: TextStyle(
fontFamily: 'Readex Pro',
letterSpacing: 0,
+ color: Colors.white,
+ fontSize: 26.rpx,
),
),
))
@@ -200,7 +203,8 @@ class _EditBedPageState extends State {
"name": editedData["name"],
},
onSuccess: (res) {
- '更新人员信息成功: $res';
+ TopSlideNotification.show(context,
+ text: "修改名称成功".tr);
},
);
},
diff --git a/lib/pages/mh_page/repair_history_widget.dart b/lib/pages/mh_page/repair_history_widget.dart
index 09194a3..489374b 100644
--- a/lib/pages/mh_page/repair_history_widget.dart
+++ b/lib/pages/mh_page/repair_history_widget.dart
@@ -6,6 +6,7 @@ import 'package:vbvs_app/common/color/appColors.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/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/mh_controller/repair_info_controller.dart';
import 'package:vbvs_app/controller/mh_controller/repair_list_controller.dart';
import 'package:vbvs_app/pages/mh_page/ColorChangeOnTap.dart';
@@ -23,133 +24,19 @@ class RepairHistoryWidget extends GetView {
Widget build(BuildContext context) {
int tmp = index;
index = tmp;
- // return ColorChangeOnPress(
- // pressColor: AppColors().press_color, // 按下时的颜色
- // shouldNavigate: true, // 是否需要跳转
- // routeName: "/repairHistoryListPage", // 路由名称
- // topLeft: 16,
- // topRight: 16,
- // bottomLeft: 16,
- // bottomRight: 16,
- // onTap: () async {
- // print("object");
- // final RepairInfoController repairInfoController =
- // Get.find();
- // await repairInfoController
- // .initData(repairListController.model.repairList[index])
- // .then((_) {
- // repairInfoController.updateAll();
- // // Get.toNamed("/repairHistoryListPage"); // 这个在 ColorChangeOnPress 中已经处理
- // });
- // },
- // child: Container(
- // width: MediaQuery.sizeOf(context).width,
- // constraints: BoxConstraints(
- // minHeight: 70,
- // ),
- // child: Padding(
- // padding: EdgeInsetsDirectional.fromSTEB(15, 14, 15, 13),
- // child: Row(
- // mainAxisSize: MainAxisSize.max,
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
- // children: [
- // Container(
- // width: MediaQuery.sizeOf(context).width * 0.5,
- // child: Column(
- // mainAxisSize: MainAxisSize.max,
- // children: [
- // Align(
- // alignment: AlignmentDirectional(-1, 0),
- // child: Text(
- // repairListController
- // .model.repairList[index].device_category ??
- // '',
- // style: TextStyle(
- // fontFamily: 'Readex Pro',
- // color: Color(0xFF333333),
- // fontSize: 30.rpx,
- // letterSpacing: 0,
- // ),
- // ),
- // ),
- // Align(
- // alignment: AlignmentDirectional(-1, 0),
- // child: Text(
- // "报修单号:${repairListController.model.repairList[index].id}",
- // style: TextStyle(
- // fontFamily: 'Readex Pro',
- // color: Color(0xFFC8CBD2),
- // fontSize: AppFontsize.small_text_size,
- // letterSpacing: 0,
- // ),
- // ),
- // ),
- // Align(
- // alignment: AlignmentDirectional(-1, 0),
- // child: Text(
- // "提交时间:" +
- // (MyUtils.formatDateTime(repairListController
- // .model.repairList[index].create_time!) ??
- // ''),
- // style: TextStyle(
- // fontFamily: 'Readex Pro',
- // color: Color(0xFFC8CBD2),
- // fontSize: AppFontsize.small_text_size,
- // letterSpacing: 0,
- // ),
- // ),
- // ),
- // ],
- // ),
- // ),
- // Container(
- // width: MediaQuery.sizeOf(context).width * 0.2,
- // height: MediaQuery.sizeOf(context).height * 0.075,
- // constraints: BoxConstraints(
- // maxWidth: 130,
- // ),
- // child: Row(
- // mainAxisSize: MainAxisSize.max,
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
- // children: [
- // Align(
- // alignment: AlignmentDirectional(0, 0),
- // child: Text(
- // repairListController.model.repairList[index].status ??
- // '',
- // style: TextStyle(
- // fontFamily: 'Readex Pro',
- // color: Color(0xFF333333),
- // fontSize: AppFontsize.normal_text_size,
- // letterSpacing: 0,
- // ),
- // ),
- // ),
- // Flexible(
- // child: Align(
- // alignment: AlignmentDirectional(0, 0.05),
- // child: Icon(
- // Icons.arrow_forward_ios,
- // color: FlutterFlowTheme.of(context).secondaryText,
- // size: 10,
- // ),
- // ),
- // ),
- // ].divide(SizedBox(width: 27)),
- // ),
- // ),
- // ],
- // ),
- // ),
- // ),
- // );
return ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Color(0XFF055466),
padding: EdgeInsets.only(top: 0),
onTap: () {
- Get.toNamed("/repairHistoryListPage");
+ TopSlideNotification.show(
+ context,
+ text: "功能开发中...",
+ );
+
+ // Get.toNamed("/repairHistoryListPage",
+ // arguments: repairListController.model.repairList[index]);
},
child: Container(
// height: 119.rpx,
@@ -176,8 +63,8 @@ class RepairHistoryWidget extends GetView {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- repairListController
- .model.repairList[index].device_category ??
+ repairListController.model.repairList[index]['device']
+ [0]['mac'] ??
'',
style: TextStyle(
color: Colors.white, fontSize: 30.rpx, height: 1),
@@ -185,8 +72,8 @@ class RepairHistoryWidget extends GetView {
const SizedBox(height: 4),
Text(
"提交时间:" +
- (MyUtils.formatDateTime(repairListController
- .model.repairList[index].create_time!) ??
+ (MyUtils.formatTimestamp(repairListController
+ .model.repairList[index]["create_time"]) ??
''),
style: TextStyle(
color: Colors.white60, fontSize: 20.rpx, height: 1),
@@ -197,8 +84,8 @@ class RepairHistoryWidget extends GetView {
Row(
children: [
Text(
- repairListController.model.repairList[index].status ??
- '',
+ getStatusText(repairListController
+ .model.repairList[index]['status']),
style: TextStyle(color: Colors.white, fontSize: 26.rpx),
),
ClickableContainer(
@@ -225,4 +112,23 @@ class RepairHistoryWidget extends GetView {
),
)));
}
+
+ String getStatusText(dynamic status) {
+ switch (status?.toString()) {
+ case '1':
+ return '审核中';
+ case '2':
+ return '审核通过';
+ case '3':
+ return '维修中';
+ case '4':
+ return '维修完成';
+ case '5':
+ return '已完成';
+ case '6':
+ return '已评价';
+ default:
+ return '未知状态';
+ }
+ }
}
diff --git a/lib/pages/repair/component/RepairModelWidget.dart b/lib/pages/repair/component/RepairModelWidget.dart
index 47f1b25..76afdea 100644
--- a/lib/pages/repair/component/RepairModelWidget.dart
+++ b/lib/pages/repair/component/RepairModelWidget.dart
@@ -11,6 +11,7 @@ import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/device/body_device_controller.dart';
+import 'package:vbvs_app/controller/mh_controller/apply_repair_controller.dart';
import 'package:vbvs_app/controller/repair/repair_controller.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/model/api_response.dart';
@@ -28,7 +29,7 @@ class RepairModelWidget extends StatefulWidget {
required this.onTap,
required this.length,
required this.widgetKey,
- this.showDelete = true, // ✅ 默认为 false
+ this.showDelete = true, // ✅ 默认为 false
});
@override
@@ -38,6 +39,7 @@ class RepairModelWidget extends StatefulWidget {
class _RepairModelWidgetState extends State {
FormFieldController _deviceController =
FormFieldController(null);
+ ApplyRepairController applyRepairController = Get.find();
RepairController repairController = Get.find();
UserInfoController userInfoController = Get.find();
late FormFieldController? _issueController;
@@ -143,7 +145,7 @@ class _RepairModelWidgetState extends State {
),
icon: Icon(
Icons.keyboard_arrow_down_rounded,
- color:Colors.white,
+ color: Colors.white,
size: 24.rpx,
),
fillColor: themeController.currentColor.sc15,
@@ -342,7 +344,8 @@ class _RepairModelWidgetState extends State {
borderRadius: 20.rpx,
padding: EdgeInsets.zero,
onTap: () async {
- ApiResponse apiResponse = await repairController.uploadImg();
+ ApiResponse apiResponse =
+ await applyRepairController.uploadImg();
print(apiResponse);
if (apiResponse.code == HttpStatusCodes.ok) {
print(widget.model);
@@ -454,7 +457,7 @@ class _RepairModelWidgetState extends State {
),
),
),
- ),
+ ),
].divide(SizedBox(height: 29.rpx)),
),
),
diff --git a/lib/routers/mh_routers.dart b/lib/routers/mh_routers.dart
index ad3a64c..a29f31b 100644
--- a/lib/routers/mh_routers.dart
+++ b/lib/routers/mh_routers.dart
@@ -54,7 +54,8 @@ var mhroutes = {
"/peopleInfoPage": (contxt, {arguments}) => PeopleInfoPage(
data: arguments,
),
- "/repairHistoryListPage": (contxt) => RepairHistoryListPage(),
+ "/repairHistoryListPage": (contxt, {arguments}) =>
+ RepairHistoryListPage(data: arguments),
"/deviceRepairPage": (contxt) => DeviceRepairPage(),
"/settingPage": (contxt) => SettingPage(),
"/issueListpage": (contxt) => IssueListPage(),