下拉状态无设备不可点
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,150 +213,294 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child:
|
child: Container(
|
||||||
Container(
|
width: 300, // 可以根据需要调整宽度
|
||||||
width:
|
height: 56, // 可以根据需要调整高度
|
||||||
300, // 可以根据需要调整宽度
|
decoration: BoxDecoration(
|
||||||
height:
|
borderRadius:
|
||||||
56, // 可以根据需要调整高度
|
BorderRadius.circular(
|
||||||
decoration:
|
8),
|
||||||
BoxDecoration(
|
color: Colors
|
||||||
borderRadius:
|
.white,
|
||||||
BorderRadius.circular(8),
|
),
|
||||||
color:
|
// child: Obx(
|
||||||
Colors.white,
|
// () {
|
||||||
),
|
// List<Map<String, String>> deviceOptions = controller
|
||||||
child: Obx(
|
// .model
|
||||||
() {
|
// .device_list!
|
||||||
List<Map<String, String>> deviceOptions = controller
|
// .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
|
.model
|
||||||
.device_list!
|
.device_list!
|
||||||
.map((device) => {
|
.map((device) {
|
||||||
'mac': device['mac'].toString(), // 提取设备 Mac
|
final mac =
|
||||||
'name': device['name'].toString(), // 提取设备名称
|
device['mac']?.toString() ??
|
||||||
'type': device['device_type'].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();
|
.toList();
|
||||||
|
|
||||||
// 提取 optionsLabel 和 optionsValue
|
return AbsorbPointer(
|
||||||
// List<String> deviceNames = deviceOptions
|
absorbing:
|
||||||
// .map((device) => device['name']!) // 用于显示的名称列表
|
isDeviceListEmpty, // 禁止点击
|
||||||
// .toList();
|
child: FlutterFlowDropDown<
|
||||||
List<String>
|
String>(
|
||||||
deviceNames =
|
controller:
|
||||||
controller.model.device_list!.map((device) {
|
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 =
|
final mac =
|
||||||
device['mac']?.toString() ?? '';
|
selectedDevice['mac']?.toString() ?? '未知MAC';
|
||||||
final name =
|
final name =
|
||||||
device['name']?.toString() ?? '';
|
selectedDevice['name']?.toString();
|
||||||
final type =
|
final type =
|
||||||
getDeviceTypeName(int.tryParse('${device['device_type']}'));
|
int.tryParse('${selectedDevice['device_type']}');
|
||||||
|
final typeName =
|
||||||
|
getDeviceTypeName(type);
|
||||||
|
|
||||||
return name.isNotEmpty
|
controller.model.select_device =
|
||||||
? '$name-MAC$mac'
|
mac;
|
||||||
: '$type-MAC$mac';
|
controller.model.device_type =
|
||||||
}).toList();
|
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
|
controller.updateAll();
|
||||||
.map((device) => device['mac']!) // 用于匹配的 ID 列表
|
},
|
||||||
.toList();
|
width:
|
||||||
|
300,
|
||||||
return FlutterFlowDropDown<
|
height:
|
||||||
String>(
|
56,
|
||||||
controller:
|
textStyle:
|
||||||
tmpcontroller,
|
TextStyle(
|
||||||
fillColor:
|
fontFamily:
|
||||||
Colors.white, // 控件区域背景色
|
'Readex Pro',
|
||||||
options:
|
color: isDeviceListEmpty
|
||||||
deviceMacs, // 下拉菜单选项为设备的 ID
|
? Colors.grey
|
||||||
optionLabels:
|
: Colors.black,
|
||||||
deviceNames, // 下拉菜单显示的内容为设备名称
|
fontSize:
|
||||||
onChanged:
|
26.rpx,
|
||||||
(val) {
|
letterSpacing:
|
||||||
// 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,
|
0,
|
||||||
borderRadius:
|
),
|
||||||
8,
|
hintText: isDeviceListEmpty
|
||||||
margin: const EdgeInsetsDirectional.fromSTEB(
|
? '暂无可选设备'
|
||||||
10,
|
: '请选择绑定设备',
|
||||||
4,
|
searchHintText:
|
||||||
10,
|
'查找',
|
||||||
4),
|
icon:
|
||||||
hidesUnderline:
|
Icon(
|
||||||
true,
|
Icons.keyboard_arrow_down_rounded,
|
||||||
isOverButton:
|
color: isDeviceListEmpty
|
||||||
false,
|
? Colors.grey
|
||||||
isSearchable:
|
: Colors.black,
|
||||||
false,
|
size:
|
||||||
isMultiSelect:
|
24,
|
||||||
false,
|
),
|
||||||
);
|
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(
|
].divide(SizedBox(
|
||||||
width: 26.rpx)),
|
width: 26.rpx)),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -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 =
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user