From db6903ee78b134285a2649553ff5383c80565c75 Mon Sep 17 00:00:00 2001 From: czz <862977248@qq.com> Date: Tue, 15 Jul 2025 17:48:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E6=8B=89=E7=8A=B6=E6=80=81=E6=97=A0?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=B8=8D=E5=8F=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply_repair_controller.dart | 3 +- lib/pages/mh_page/apply_repair_page.dart | 412 ++++++++++++------ lib/pages/mh_page/bluetooth.dart | 1 + lib/pages/mh_page/book_info_page.dart | 5 +- 4 files changed, 284 insertions(+), 137 deletions(-) diff --git a/lib/controller/mh_controller/apply_repair_controller.dart b/lib/controller/mh_controller/apply_repair_controller.dart index b103c7e..7716757 100644 --- a/lib/controller/mh_controller/apply_repair_controller.dart +++ b/lib/controller/mh_controller/apply_repair_controller.dart @@ -129,6 +129,7 @@ class ApplyRepairController extends GetControllerEx { await deviceListController.getDeviceList(); var aa = deviceListController.model.deviceList; ApplyRepairController applyRepairController = Get.find(); - applyRepairController.model.device_list = aa; + applyRepairController.model.device_list?.assignAll(aa); + updateAll(); } } diff --git a/lib/pages/mh_page/apply_repair_page.dart b/lib/pages/mh_page/apply_repair_page.dart index bbf9808..5b0dccd 100644 --- a/lib/pages/mh_page/apply_repair_page.dart +++ b/lib/pages/mh_page/apply_repair_page.dart @@ -213,150 +213,294 @@ class ApplyRepairPage extends GetView { ), ), Expanded( - child: - Container( - width: - 300, // 可以根据需要调整宽度 - height: - 56, // 可以根据需要调整高度 - decoration: - BoxDecoration( - borderRadius: - BorderRadius.circular(8), - color: - Colors.white, - ), - child: Obx( - () { - List> deviceOptions = controller + child: Container( + width: 300, // 可以根据需要调整宽度 + height: 56, // 可以根据需要调整高度 + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 8), + color: Colors + .white, + ), + // child: Obx( + // () { + // List> deviceOptions = controller + // .model + // .device_list! + // .map((device) => { + // 'mac': device['mac'].toString(), // 提取设备 Mac + // 'name': device['name'].toString(), // 提取设备名称 + // 'type': device['device_type'].toString() + // }) + // .toList(); + + // // 提取 optionsLabel 和 optionsValue + // // List deviceNames = deviceOptions + // // .map((device) => device['name']!) // 用于显示的名称列表 + // // .toList(); + // List + // deviceNames = + // controller.model.device_list!.map((device) { + // final mac = + // device['mac']?.toString() ?? ''; + // final name = + // device['name']?.toString() ?? ''; + // final type = + // getDeviceTypeName(int.tryParse('${device['device_type']}')); + + // return name.isNotEmpty + // ? '$name-MAC$mac' + // : '$type-MAC$mac'; + // }).toList(); + + // List deviceMacs = deviceOptions + // .map((device) => device['mac']!) // 用于匹配的 ID 列表 + // .toList(); + + // return FlutterFlowDropDown< + // String>( + // controller: + // tmpcontroller, + + // fillColor: + // Colors.white, // 控件区域背景色 + // options: + // deviceMacs, // 下拉菜单选项为设备的 ID + // optionLabels: + // deviceNames, // 下拉菜单显示的内容为设备名称 + // onChanged: + // (val) { + // // var selectedDevice = controller.model.device_list!.firstWhere((device) => device['mac'].toString() == val); + // // controller.model.select_device = val; + // // controller.model.device_type = selectedDevice['device_type']; + // // // controller.model.device_category = selectedDevice['deviceSeries']['name'] ?? '未知型号'; // 获取设备型号 + // // controller.model.device_category = '未知型号'; + // // controller.model.device_id = selectedDevice['mac'] ?? '未知设备mac'; // 获取设备ID + // // controller.model.device_name = selectedDevice['name'] ?? '未知设备'; // 获取设备名称 + // // controller.updateAll(); + + // var selectedDevice = controller.model.device_list!.firstWhere((device) => device['mac'].toString() == val); + + // final mac = selectedDevice['mac']?.toString() ?? '未知MAC'; + // final name = selectedDevice['name']?.toString(); + // final type = int.tryParse('${selectedDevice['device_type']}'); + // final typeName = getDeviceTypeName(type); + + // controller.model.select_device = mac; + // controller.model.device_type = selectedDevice['device_type']; + // controller.model.device_category = '未知型号'; // 后续可替换成设备系列 + + // // 如果 name 不为空则用 name,否则用 typeName-mac + // controller.model.device_name = (name != null && name.isNotEmpty) ? name : '$typeName-MAC$mac'; + + // controller.model.device_id = mac; + + // controller.updateAll(); + // }, + // width: + // 300, + // height: + // 56, + // searchHintTextStyle: + // const TextStyle( + // fontFamily: 'Readex Pro', + // letterSpacing: 0, + // ), + + // searchTextStyle: + // const TextStyle( + // fontFamily: 'Readex Pro', + // letterSpacing: 0, + // ), + // textStyle: + // TextStyle( + // fontFamily: 'Readex Pro', + // color: Colors.black, + // fontSize: 26.rpx, + // letterSpacing: 0, + // ), + // hintText: + // '请选择绑定设备', + // searchHintText: + // '查找', + // icon: + // const Icon( + // Icons.keyboard_arrow_down_rounded, + // color: Colors.black, + // size: 24, + // ), + // // fillColor: + // // FlutterFlowTheme.of(context).secondaryBackground, + // elevation: + // 2, + // borderColor: + // Colors.white, + // borderWidth: + // 0, + // borderRadius: + // 8, + // margin: const EdgeInsetsDirectional.fromSTEB( + // 10, + // 4, + // 10, + // 4), + // hidesUnderline: + // true, + // isOverButton: + // false, + // isSearchable: + // false, + // isMultiSelect: + // false, + // ); + // }) + child: Obx(() { + final isDeviceListEmpty = controller + .model + .device_list + ?.isEmpty ?? + true; + + List< + Map> deviceOptions = controller + .model + .device_list! + .map((device) => + { + 'mac': device['mac'].toString(), + 'name': device['name'].toString(), + 'type': device['device_type'].toString() + }) + .toList(); + + List + deviceNames = + controller .model .device_list! - .map((device) => { - 'mac': device['mac'].toString(), // 提取设备 Mac - 'name': device['name'].toString(), // 提取设备名称 - 'type': device['device_type'].toString() - }) + .map((device) { + final mac = + device['mac']?.toString() ?? + ''; + final name = + device['name']?.toString() ?? + ''; + final type = + getDeviceTypeName(int.tryParse('${device['device_type']}')); + + return name.isNotEmpty + ? '$name-MAC$mac' + : '$type-MAC$mac'; + }).toList(); + + List + deviceMacs = + deviceOptions + .map((device) => device['mac']!) .toList(); - // 提取 optionsLabel 和 optionsValue - // List deviceNames = deviceOptions - // .map((device) => device['name']!) // 用于显示的名称列表 - // .toList(); - List - deviceNames = - controller.model.device_list!.map((device) { + return AbsorbPointer( + absorbing: + isDeviceListEmpty, // 禁止点击 + child: FlutterFlowDropDown< + String>( + controller: + tmpcontroller, + fillColor: isDeviceListEmpty + ? Colors.grey[300]! + : Colors.white, + options: isDeviceListEmpty + ? [] + : deviceMacs, + optionLabels: isDeviceListEmpty + ? [] + : deviceNames, + onChanged: + (val) { + var selectedDevice = controller.model.device_list!.firstWhere((device) => + device['mac'].toString() == + val); + final mac = - device['mac']?.toString() ?? ''; + selectedDevice['mac']?.toString() ?? '未知MAC'; final name = - device['name']?.toString() ?? ''; + selectedDevice['name']?.toString(); final type = - getDeviceTypeName(int.tryParse('${device['device_type']}')); + int.tryParse('${selectedDevice['device_type']}'); + final typeName = + getDeviceTypeName(type); - return name.isNotEmpty - ? '$name-MAC$mac' - : '$type-MAC$mac'; - }).toList(); + controller.model.select_device = + mac; + controller.model.device_type = + selectedDevice['device_type']; + controller.model.device_category = + '未知型号'; + controller.model.device_name = (name != null && name.isNotEmpty) + ? name + : '$typeName-MAC$mac'; + controller.model.device_id = + mac; - List deviceMacs = deviceOptions - .map((device) => device['mac']!) // 用于匹配的 ID 列表 - .toList(); - - return FlutterFlowDropDown< - String>( - controller: - tmpcontroller, - fillColor: - Colors.white, // 控件区域背景色 - options: - deviceMacs, // 下拉菜单选项为设备的 ID - optionLabels: - deviceNames, // 下拉菜单显示的内容为设备名称 - onChanged: - (val) { - // var selectedDevice = controller.model.device_list!.firstWhere((device) => device['mac'].toString() == val); - // controller.model.select_device = val; - // controller.model.device_type = selectedDevice['device_type']; - // // controller.model.device_category = selectedDevice['deviceSeries']['name'] ?? '未知型号'; // 获取设备型号 - // controller.model.device_category = '未知型号'; - // controller.model.device_id = selectedDevice['mac'] ?? '未知设备mac'; // 获取设备ID - // controller.model.device_name = selectedDevice['name'] ?? '未知设备'; // 获取设备名称 - // controller.updateAll(); - - var selectedDevice = controller.model.device_list!.firstWhere((device) => device['mac'].toString() == val); - - final mac = selectedDevice['mac']?.toString() ?? '未知MAC'; - final name = selectedDevice['name']?.toString(); - final type = int.tryParse('${selectedDevice['device_type']}'); - final typeName = getDeviceTypeName(type); - - controller.model.select_device = mac; - controller.model.device_type = selectedDevice['device_type']; - controller.model.device_category = '未知型号'; // 后续可替换成设备系列 - - // 如果 name 不为空则用 name,否则用 typeName-mac - controller.model.device_name = (name != null && name.isNotEmpty) ? name : '$typeName-MAC$mac'; - - controller.model.device_id = mac; - - controller.updateAll(); - }, - width: - 300, - height: - 56, - searchHintTextStyle: - const TextStyle( - fontFamily: 'Readex Pro', - letterSpacing: 0, - ), - - searchTextStyle: - const TextStyle( - fontFamily: 'Readex Pro', - letterSpacing: 0, - ), - textStyle: - TextStyle( - fontFamily: 'Readex Pro', - color: Colors.black, - fontSize: 26.rpx, - letterSpacing: 0, - ), - hintText: - '请选择绑定设备', - searchHintText: - '查找', - icon: - const Icon( - Icons.keyboard_arrow_down_rounded, - color: Colors.black, - size: 24, - ), - // fillColor: - // FlutterFlowTheme.of(context).secondaryBackground, - elevation: - 2, - borderColor: - Colors.white, - borderWidth: + controller.updateAll(); + }, + width: + 300, + height: + 56, + textStyle: + TextStyle( + fontFamily: + 'Readex Pro', + color: isDeviceListEmpty + ? Colors.grey + : Colors.black, + fontSize: + 26.rpx, + letterSpacing: 0, - borderRadius: - 8, - margin: const EdgeInsetsDirectional.fromSTEB( - 10, - 4, - 10, - 4), - hidesUnderline: - true, - isOverButton: - false, - isSearchable: - false, - isMultiSelect: - false, - ); - }))), + ), + hintText: isDeviceListEmpty + ? '暂无可选设备' + : '请选择绑定设备', + searchHintText: + '查找', + icon: + Icon( + Icons.keyboard_arrow_down_rounded, + color: isDeviceListEmpty + ? Colors.grey + : Colors.black, + size: + 24, + ), + elevation: + 2, + borderColor: + Colors.white, + borderWidth: + 0, + borderRadius: + 8, + margin: const EdgeInsetsDirectional + .fromSTEB( + 10, + 4, + 10, + 4), + hidesUnderline: + true, + isOverButton: + false, + isSearchable: + false, + isMultiSelect: + false, + ), + ); + }))), ].divide(SizedBox( width: 26.rpx)), ), diff --git a/lib/pages/mh_page/bluetooth.dart b/lib/pages/mh_page/bluetooth.dart index a51e9b9..837a081 100644 --- a/lib/pages/mh_page/bluetooth.dart +++ b/lib/pages/mh_page/bluetooth.dart @@ -272,6 +272,7 @@ class _BluetoothPageState extends State { .unbindDevice(obsData); await deviceListController .getDeviceList(); + MHTHomeController homeController = Get.find(); homeController.selectDevcie.value = diff --git a/lib/pages/mh_page/book_info_page.dart b/lib/pages/mh_page/book_info_page.dart index 4f1eabb..362d958 100644 --- a/lib/pages/mh_page/book_info_page.dart +++ b/lib/pages/mh_page/book_info_page.dart @@ -87,7 +87,6 @@ class BookInfoPage extends GetView { 30.rpx, 40.rpx, 30.rpx, 0), child: Container( width: MediaQuery.sizeOf(context).width, - height: MediaQuery.sizeOf(context).height * 1, child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.max, @@ -104,7 +103,9 @@ class BookInfoPage extends GetView { width: 0.5.rpx))), child: Container( margin: EdgeInsets.only( - left: 30.rpx, right: 30.rpx), + left: 30.rpx, + right: 30.rpx, + bottom: 10.rpx), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: