设备报修

This commit is contained in:
czz
2025-07-14 18:04:42 +08:00
parent a26834f56c
commit d5a5e3282d
13 changed files with 952 additions and 374 deletions

View File

@@ -41,8 +41,8 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
Widget build(BuildContext context) {
var tmpcontroller =
FormFieldController<String>(controller.model.select_device);
List<String> deviceTypeNames = ['', '床垫'];
List<String> deviceTypeIds = ['', '床垫'];
// List<String> deviceTypeNames = ['床', '床垫'];
// List<String> deviceTypeIds = ['床', '床垫'];
return LayoutBuilder(builder: (context, cc) {
bodysize = cc;
return GestureDetector(
@@ -232,18 +232,33 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
.model
.device_list!
.map((device) => {
'id': device['_id'].toString(), // 提取设备 ID
'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 = 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']}'));
List<String> deviceIds = deviceOptions
.map((device) => device['id']!) // 用于匹配的 ID 列表
return name.isNotEmpty
? '$name-MAC$mac'
: '$type-MAC$mac';
}).toList();
List<String> deviceMacs = deviceOptions
.map((device) => device['mac']!) // 用于匹配的 ID 列表
.toList();
return FlutterFlowDropDown<
@@ -253,18 +268,36 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
fillColor:
Colors.white, // 控件区域背景色
options:
deviceIds, // 下拉菜单选项为设备的 ID
deviceMacs, // 下拉菜单选项为设备的 ID
optionLabels:
deviceNames, // 下拉菜单显示的内容为设备名称
onChanged:
(val) {
var selectedDevice = controller.model.device_list!.firstWhere((device) => device['_id'].toString() == val);
controller.model.select_device = 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 = selectedDevice['deviceSeries']['name'] ?? '未知型号'; // 获取设备型号
controller.model.device_category = '未知型号';
controller.model.device_id = selectedDevice['_id'] ?? '未知设备ID'; // 获取设备ID
controller.model.device_name = selectedDevice['name'] ?? '未知设备'; // 获取设备名称
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:
@@ -375,30 +408,499 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
),
Expanded(
child: Container(
width: 100,
height: 100,
decoration:
BoxDecoration(
color: Colors
.white,
borderRadius:
BorderRadius
.circular(8),
decoration:
BoxDecoration(
color: Colors
.white,
borderRadius:
BorderRadius
.circular(
8),
),
width: double
.infinity,
child: Padding(
padding: EdgeInsetsDirectional
.fromSTEB(
35.rpx,
0,
35.rpx,
0),
child: Row(
mainAxisSize:
MainAxisSize
.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Expanded(
child:
Container(
child:
Align(
alignment:
AlignmentDirectional(-1, 0),
child:
TextFormField(
onChanged: (value) {
controller.model.device_series = value;
},
autofocus: false,
obscureText: false,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(0),
isDense: true,
labelStyle: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
),
hintStyle: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc4,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
filled: false,
fillColor: Colors.white,
),
style: TextStyle(
fontFamily: 'Readex Pro',
letterSpacing: 0,
color: Colors.black,
fontSize: 26.rpx,
),
// cursorColor:
// Colors.black,
// validator: _model
// .textControllerValidator
// .asValidator(context),
),
),
),
),
],
),
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)),
),
),
),
// Flexible(
// child: Container(
// width:
// MediaQuery.sizeOf(
// context)
// .width,
// height: 10,
// constraints:
// BoxConstraints(
// minHeight: 60.rpx,
// ),
// child: Row(
// mainAxisSize:
// MainAxisSize.max,
// children: [
// Container(
// width: 105.rpx,
// height: MediaQuery
// .sizeOf(
// context)
// .height *
// 0.038,
// constraints:
// const BoxConstraints(
// minWidth: 60,
// ),
// child: Align(
// alignment:
// const AlignmentDirectional(
// -1, 0),
// child: Text(
// '产品型号',
// style: TextStyle(
// fontFamily:
// 'Readex Pro',
// fontSize: 26
// .rpx,
// letterSpacing:
// 0,
// color: Colors
// .white),
// ),
// ),
// ),
// // Expanded(
// // child: Container(
// // width: 100,
// // height: 100,
// // decoration:
// // BoxDecoration(
// // color: Colors
// // .white,
// // borderRadius:
// // BorderRadius
// // .circular(8),
// // ),
// // 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),
// // ))))),
// // ),
// Expanded(
// child: Container(
// child: Align(
// alignment:
// AlignmentDirectional(
// -1,
// 0),
// child:
// TextFormField(
// onChanged:
// (value) {
// controller
// .model
// .device_category = value;
// },
// autofocus:
// false,
// obscureText:
// false,
// decoration:
// InputDecoration(
// contentPadding:
// EdgeInsets.all(
// 0),
// isDense:
// true,
// labelStyle:
// TextStyle(
// fontFamily:
// 'Inter',
// fontSize:
// 26.rpx,
// letterSpacing:
// 0.0,
// ),
// hintStyle:
// TextStyle(
// fontFamily:
// 'Inter',
// fontSize:
// 26.rpx,
// letterSpacing:
// 0.0,
// color: themeController
// .currentColor
// .sc4,
// ),
// enabledBorder:
// OutlineInputBorder(
// borderSide:
// BorderSide(
// color:
// Color(0x00000000),
// width:
// 1.rpx,
// ),
// borderRadius:
// BorderRadius.circular(8.rpx),
// ),
// focusedBorder:
// OutlineInputBorder(
// borderSide:
// BorderSide(
// color:
// Color(0x00000000),
// width:
// 1.rpx,
// ),
// borderRadius:
// BorderRadius.circular(8.rpx),
// ),
// errorBorder:
// OutlineInputBorder(
// borderSide:
// BorderSide(
// color:
// Colors.red,
// width:
// 1.rpx,
// ),
// borderRadius:
// BorderRadius.circular(8.rpx),
// ),
// focusedErrorBorder:
// OutlineInputBorder(
// borderSide:
// BorderSide(
// color:
// Colors.red,
// width:
// 1.rpx,
// ),
// borderRadius:
// BorderRadius.circular(8.rpx),
// ),
// filled:
// false,
// fillColor:
// Colors
// .white,
// ),
// style:
// TextStyle(
// fontFamily:
// 'Readex Pro',
// letterSpacing:
// 0,
// color: Colors
// .black,
// fontSize:
// 26.rpx,
// ),
// // cursorColor:
// // Colors.black,
// // validator: _model
// // .textControllerValidator
// // .asValidator(context),
// ),
// ),
// ),
// ),
// ].divide(SizedBox(
// width: 26.rpx)),
// ),
// ),
// ),
// Flexible(
// child: Container(
// width:
// MediaQuery.sizeOf(
// context)
// .width,
// height: 10,
// constraints:
// BoxConstraints(
// minHeight: 60.rpx,
// ),
// child: Row(
// mainAxisSize:
// MainAxisSize.max,
// children: [
// Container(
// width: 105.rpx,
// height: MediaQuery
// .sizeOf(
// context)
// .height *
// 0.038,
// constraints:
// const BoxConstraints(
// minWidth: 60,
// ),
// child: Align(
// alignment:
// const AlignmentDirectional(
// -1, 0),
// child: Text(
// '序列号',
// style: TextStyle(
// fontFamily:
// 'Readex Pro',
// fontSize: 26
// .rpx,
// letterSpacing:
// 0,
// color: Colors
// .white),
// ),
// ),
// ),
// // Expanded(
// // child: Container(
// // width: 100,
// // height: 100,
// // decoration:
// // BoxDecoration(
// // color: Colors
// // .white,
// // borderRadius:
// // BorderRadius
// // .circular(8),
// // ),
// // 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),
// // ))))),
// // ),
// Expanded(
// child: Container(
// child: Align(
// alignment:
// AlignmentDirectional(
// -1,
// 0),
// child:
// TextFormField(
// onChanged:
// (value) {
// controller
// .model
// .device_id = value;
// },
// autofocus:
// false,
// obscureText:
// false,
// decoration:
// InputDecoration(
// contentPadding:
// EdgeInsets.all(
// 0),
// isDense:
// true,
// labelStyle:
// TextStyle(
// fontFamily:
// 'Inter',
// fontSize:
// 26.rpx,
// letterSpacing:
// 0.0,
// ),
// hintStyle:
// TextStyle(
// fontFamily:
// 'Inter',
// fontSize:
// 26.rpx,
// letterSpacing:
// 0.0,
// color: themeController
// .currentColor
// .sc4,
// ),
// enabledBorder:
// OutlineInputBorder(
// borderSide:
// BorderSide(
// color:
// Color(0x00000000),
// width:
// 1.rpx,
// ),
// borderRadius:
// BorderRadius.circular(8.rpx),
// ),
// focusedBorder:
// OutlineInputBorder(
// borderSide:
// BorderSide(
// color:
// Color(0x00000000),
// width:
// 1.rpx,
// ),
// borderRadius:
// BorderRadius.circular(8.rpx),
// ),
// errorBorder:
// OutlineInputBorder(
// borderSide:
// BorderSide(
// color:
// Colors.red,
// width:
// 1.rpx,
// ),
// borderRadius:
// BorderRadius.circular(8.rpx),
// ),
// focusedErrorBorder:
// OutlineInputBorder(
// borderSide:
// BorderSide(
// color:
// Colors.red,
// width:
// 1.rpx,
// ),
// borderRadius:
// BorderRadius.circular(8.rpx),
// ),
// filled:
// false,
// fillColor:
// Colors
// .white,
// ),
// style:
// TextStyle(
// fontFamily:
// 'Readex Pro',
// letterSpacing:
// 0,
// color: Colors
// .black,
// fontSize:
// 26.rpx,
// ),
// // cursorColor:
// // Colors.black,
// // validator: _model
// // .textControllerValidator
// // .asValidator(context),
// ),
// ),
// ),
// ),
// ].divide(SizedBox(
// width: 26.rpx)),
// ),
// ),
// ),
Flexible(
child: Container(
width:
@@ -445,24 +947,110 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
),
Expanded(
child: Container(
width: 100,
height: 100,
decoration:
BoxDecoration(
color: Colors
.white,
borderRadius:
BorderRadius
.circular(8),
decoration:
BoxDecoration(
color: Colors
.white,
borderRadius:
BorderRadius
.circular(
8),
),
width: double
.infinity,
child: Padding(
padding: EdgeInsetsDirectional
.fromSTEB(
35.rpx,
0,
35.rpx,
0),
child: Row(
mainAxisSize:
MainAxisSize
.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Expanded(
child:
Container(
child:
Align(
alignment:
AlignmentDirectional(-1, 0),
child:
TextFormField(
onChanged: (value) {
controller.model.device_category = value;
},
autofocus: false,
obscureText: false,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(0),
isDense: true,
labelStyle: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
),
hintStyle: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc4,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
filled: false,
fillColor: Colors.white,
),
style: TextStyle(
fontFamily: 'Readex Pro',
letterSpacing: 0,
color: Colors.black,
fontSize: 26.rpx,
),
// cursorColor:
// Colors.black,
// validator: _model
// .textControllerValidator
// .asValidator(context),
),
),
),
),
],
),
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)),
@@ -515,24 +1103,110 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
),
Expanded(
child: Container(
width: 100,
height: 100,
decoration:
BoxDecoration(
color: Colors
.white,
borderRadius:
BorderRadius
.circular(8),
decoration:
BoxDecoration(
color: Colors
.white,
borderRadius:
BorderRadius
.circular(
8),
),
width: double
.infinity,
child: Padding(
padding: EdgeInsetsDirectional
.fromSTEB(
35.rpx,
0,
35.rpx,
0),
child: Row(
mainAxisSize:
MainAxisSize
.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Expanded(
child:
Container(
child:
Align(
alignment:
AlignmentDirectional(-1, 0),
child:
TextFormField(
onChanged: (value) {
controller.model.device_id = value;
},
autofocus: false,
obscureText: false,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(0),
isDense: true,
labelStyle: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
),
hintStyle: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc4,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8.rpx),
),
filled: false,
fillColor: Colors.white,
),
style: TextStyle(
fontFamily: 'Readex Pro',
letterSpacing: 0,
color: Colors.black,
fontSize: 26.rpx,
),
// cursorColor:
// Colors.black,
// validator: _model
// .textControllerValidator
// .asValidator(context),
),
),
),
),
],
),
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)),
@@ -1491,6 +2165,10 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
"mac": controller.model.device_id,
"desc": controller.model.desc,
"img": controller.model.issue_img,
"category":
controller.model.device_category,
"series": controller.model.device_series,
"name": controller.model.device_name
}
],
};
@@ -1502,9 +2180,8 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
onSuccess: (res) {
TopSlideNotification.show(context,
text: res.msg!);
repairListController.getRepairList();
Get.toNamed("/applyRepairSuccess");
// repairListController.getRepairList();
},
onFailure: (res) {
TopSlideNotification.show(context,
@@ -1590,8 +2267,8 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
String message = "";
if (controller.model.device_type == null ||
controller.model.device_type == 0) {
message = '选择设备类型';
controller.model.device_series!.isEmpty) {
message = '输入设备系列';
return message;
}
if (controller.model.device_category == null ||