下拉状态无设备不可点

This commit is contained in:
czz
2025-07-15 17:48:05 +08:00
parent f10963a172
commit db6903ee78
4 changed files with 284 additions and 137 deletions

View File

@@ -129,6 +129,7 @@ class ApplyRepairController extends GetControllerEx<ApplyRepairModel> {
await deviceListController.getDeviceList(); await deviceListController.getDeviceList();
var aa = deviceListController.model.deviceList; var aa = deviceListController.model.deviceList;
ApplyRepairController applyRepairController = Get.find(); ApplyRepairController applyRepairController = Get.find();
applyRepairController.model.device_list = aa; applyRepairController.model.device_list?.assignAll(aa);
updateAll();
} }
} }

View File

@@ -213,42 +213,180 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
), ),
), ),
Expanded( Expanded(
child: child: Container(
Container( width: 300, // 可以根据需要调整宽度
width: height: 56, // 可以根据需要调整高度
300, // 可以根据需要调整宽度 decoration: BoxDecoration(
height:
56, // 可以根据需要调整高度
decoration:
BoxDecoration(
borderRadius: borderRadius:
BorderRadius.circular(8), BorderRadius.circular(
color: 8),
Colors.white, color: Colors
.white,
), ),
child: Obx( // child: Obx(
() { // () {
List<Map<String, String>> deviceOptions = controller // List<Map<String, String>> 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<String> deviceNames = deviceOptions
// // .map((device) => device['name']!) // 用于显示的名称列表
// // .toList();
// List<String>
// 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<String> 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<String,
String>> deviceOptions = controller
.model .model
.device_list! .device_list!
.map((device) => { .map((device) =>
'mac': device['mac'].toString(), // 提取设备 Mac {
'name': device['name'].toString(), // 提取设备名称 'mac': device['mac'].toString(),
'name': device['name'].toString(),
'type': device['device_type'].toString() 'type': device['device_type'].toString()
}) })
.toList(); .toList();
// 提取 optionsLabel 和 optionsValue
// List<String> deviceNames = deviceOptions
// .map((device) => device['name']!) // 用于显示的名称列表
// .toList();
List<String> List<String>
deviceNames = deviceNames =
controller.model.device_list!.map((device) { controller
.model
.device_list!
.map((device) {
final mac = final mac =
device['mac']?.toString() ?? ''; device['mac']?.toString() ??
'';
final name = final name =
device['name']?.toString() ?? ''; device['name']?.toString() ??
'';
final type = final type =
getDeviceTypeName(int.tryParse('${device['device_type']}')); getDeviceTypeName(int.tryParse('${device['device_type']}'));
@@ -257,46 +395,54 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
: '$type-MAC$mac'; : '$type-MAC$mac';
}).toList(); }).toList();
List<String> deviceMacs = deviceOptions List<String>
.map((device) => device['mac']!) // 用于匹配的 ID 列表 deviceMacs =
deviceOptions
.map((device) => device['mac']!)
.toList(); .toList();
return FlutterFlowDropDown< return AbsorbPointer(
absorbing:
isDeviceListEmpty, // 禁止点击
child: FlutterFlowDropDown<
String>( String>(
controller: controller:
tmpcontroller, tmpcontroller,
fillColor: fillColor: isDeviceListEmpty
Colors.white, // 控件区域背景色 ? Colors.grey[300]!
options: : Colors.white,
deviceMacs, // 下拉菜单选项为设备的 ID options: isDeviceListEmpty
optionLabels: ? []
deviceNames, // 下拉菜单显示的内容为设备名称 : deviceMacs,
optionLabels: isDeviceListEmpty
? []
: deviceNames,
onChanged: onChanged:
(val) { (val) {
// var selectedDevice = controller.model.device_list!.firstWhere((device) => device['mac'].toString() == val); var selectedDevice = controller.model.device_list!.firstWhere((device) =>
// controller.model.select_device = val; device['mac'].toString() ==
// controller.model.device_type = selectedDevice['device_type']; val);
// // 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);
final mac = selectedDevice['mac']?.toString() ?? '未知MAC'; controller.model.select_device =
final name = selectedDevice['name']?.toString(); mac;
final type = int.tryParse('${selectedDevice['device_type']}'); controller.model.device_type =
final typeName = getDeviceTypeName(type); selectedDevice['device_type'];
controller.model.device_category =
controller.model.select_device = mac; '未知型号';
controller.model.device_type = selectedDevice['device_type']; controller.model.device_name = (name != null && name.isNotEmpty)
controller.model.device_category = '未知型号'; // 后续可替换成设备系列 ? name
: '$typeName-MAC$mac';
// 如果 name 不为空则用 name否则用 typeName-mac controller.model.device_id =
controller.model.device_name = (name != null && name.isNotEmpty) ? name : '$typeName-MAC$mac'; mac;
controller.model.device_id = mac;
controller.updateAll(); controller.updateAll();
}, },
@@ -304,36 +450,32 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
300, 300,
height: height:
56, 56,
searchHintTextStyle:
const TextStyle(
fontFamily: 'Readex Pro',
letterSpacing: 0,
),
searchTextStyle:
const TextStyle(
fontFamily: 'Readex Pro',
letterSpacing: 0,
),
textStyle: textStyle:
TextStyle( TextStyle(
fontFamily: 'Readex Pro', fontFamily:
color: Colors.black, 'Readex Pro',
fontSize: 26.rpx, color: isDeviceListEmpty
letterSpacing: 0, ? Colors.grey
: Colors.black,
fontSize:
26.rpx,
letterSpacing:
0,
), ),
hintText: hintText: isDeviceListEmpty
'请选择绑定设备', ? '暂无可选设备'
: '请选择绑定设备',
searchHintText: searchHintText:
'查找', '查找',
icon: icon:
const Icon( Icon(
Icons.keyboard_arrow_down_rounded, Icons.keyboard_arrow_down_rounded,
color: Colors.black, color: isDeviceListEmpty
size: 24, ? Colors.grey
: Colors.black,
size:
24,
), ),
// fillColor:
// FlutterFlowTheme.of(context).secondaryBackground,
elevation: elevation:
2, 2,
borderColor: borderColor:
@@ -342,7 +484,8 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
0, 0,
borderRadius: borderRadius:
8, 8,
margin: const EdgeInsetsDirectional.fromSTEB( margin: const EdgeInsetsDirectional
.fromSTEB(
10, 10,
4, 4,
10, 10,
@@ -355,6 +498,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
false, false,
isMultiSelect: isMultiSelect:
false, false,
),
); );
}))), }))),
].divide(SizedBox( ].divide(SizedBox(

View File

@@ -272,6 +272,7 @@ class _BluetoothPageState extends State<BluetoothPage> {
.unbindDevice(obsData); .unbindDevice(obsData);
await deviceListController await deviceListController
.getDeviceList(); .getDeviceList();
MHTHomeController homeController = MHTHomeController homeController =
Get.find(); Get.find();
homeController.selectDevcie.value = homeController.selectDevcie.value =

View File

@@ -87,7 +87,6 @@ class BookInfoPage extends GetView<BookInfoController> {
30.rpx, 40.rpx, 30.rpx, 0), 30.rpx, 40.rpx, 30.rpx, 0),
child: Container( child: Container(
width: MediaQuery.sizeOf(context).width, width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height * 1,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
@@ -104,7 +103,9 @@ class BookInfoPage extends GetView<BookInfoController> {
width: 0.5.rpx))), width: 0.5.rpx))),
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: 30.rpx, right: 30.rpx), left: 30.rpx,
right: 30.rpx,
bottom: 10.rpx),
child: Column( child: Column(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
crossAxisAlignment: crossAxisAlignment: