下拉状态无设备不可点
This commit is contained in:
@@ -213,150 +213,294 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child:
|
||||
Container(
|
||||
width:
|
||||
300, // 可以根据需要调整宽度
|
||||
height:
|
||||
56, // 可以根据需要调整高度
|
||||
decoration:
|
||||
BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
color:
|
||||
Colors.white,
|
||||
),
|
||||
child: Obx(
|
||||
() {
|
||||
List<Map<String, String>> deviceOptions = controller
|
||||
child: Container(
|
||||
width: 300, // 可以根据需要调整宽度
|
||||
height: 56, // 可以根据需要调整高度
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
8),
|
||||
color: Colors
|
||||
.white,
|
||||
),
|
||||
// child: Obx(
|
||||
// () {
|
||||
// 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
|
||||
.device_list!
|
||||
.map((device) =>
|
||||
{
|
||||
'mac': device['mac'].toString(),
|
||||
'name': device['name'].toString(),
|
||||
'type': device['device_type'].toString()
|
||||
})
|
||||
.toList();
|
||||
|
||||
List<String>
|
||||
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<String>
|
||||
deviceMacs =
|
||||
deviceOptions
|
||||
.map((device) => device['mac']!)
|
||||
.toList();
|
||||
|
||||
// 提取 optionsLabel 和 optionsValue
|
||||
// List<String> deviceNames = deviceOptions
|
||||
// .map((device) => device['name']!) // 用于显示的名称列表
|
||||
// .toList();
|
||||
List<String>
|
||||
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<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:
|
||||
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)),
|
||||
),
|
||||
|
||||
@@ -272,6 +272,7 @@ class _BluetoothPageState extends State<BluetoothPage> {
|
||||
.unbindDevice(obsData);
|
||||
await deviceListController
|
||||
.getDeviceList();
|
||||
|
||||
MHTHomeController homeController =
|
||||
Get.find();
|
||||
homeController.selectDevcie.value =
|
||||
|
||||
@@ -87,7 +87,6 @@ class BookInfoPage extends GetView<BookInfoController> {
|
||||
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<BookInfoController> {
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user