From 971d120ac5f8da041a40fb06e9894e6c4c0afe32 Mon Sep 17 00:00:00 2001 From: 18631081161 <2088094923@qq.com> Date: Mon, 22 Sep 2025 16:19:29 +0800 Subject: [PATCH] =?UTF-8?q?UI=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bean/odf_details_bean.dart | 7 +- lib/bean/odf_details_bean.g.dart | 4 ++ lib/dialog/add_note_dialog.dart | 97 +--------------------------- lib/dialog/modify_info_dialog.dart | 81 +++++++++++++++++------ lib/tools/machine/machine_model.dart | 4 +- 5 files changed, 75 insertions(+), 118 deletions(-) diff --git a/lib/bean/odf_details_bean.dart b/lib/bean/odf_details_bean.dart index f35d24b..b0dde91 100644 --- a/lib/bean/odf_details_bean.dart +++ b/lib/bean/odf_details_bean.dart @@ -27,6 +27,9 @@ class OdfDetailsBean { String? updatedAt; String? statusLabel; String? deptName; + String? equipmentModel; + String? businessType; + OdfDetailsBean( this.id, @@ -49,7 +52,9 @@ class OdfDetailsBean { this.createdAt, this.updatedAt, this.statusLabel, - this.deptName); + this.deptName, + this.equipmentModel, + this.businessType); factory OdfDetailsBean.fromJson(Map json) => _$OdfDetailsBeanFromJson(json); diff --git a/lib/bean/odf_details_bean.g.dart b/lib/bean/odf_details_bean.g.dart index 736b2d6..3c4ffcb 100644 --- a/lib/bean/odf_details_bean.g.dart +++ b/lib/bean/odf_details_bean.g.dart @@ -31,6 +31,8 @@ OdfDetailsBean _$OdfDetailsBeanFromJson(Map json) => json['updatedAt'] as String?, json['statusLabel'] as String?, json['deptName'] as String?, + json['equipmentModel'] as String?, + json['businessType'] as String?, ); Map _$OdfDetailsBeanToJson(OdfDetailsBean instance) => @@ -56,4 +58,6 @@ Map _$OdfDetailsBeanToJson(OdfDetailsBean instance) => 'updatedAt': instance.updatedAt, 'statusLabel': instance.statusLabel, 'deptName': instance.deptName, + 'equipmentModel': instance.equipmentModel, + 'businessType': instance.businessType, }; diff --git a/lib/dialog/add_note_dialog.dart b/lib/dialog/add_note_dialog.dart index 4ec8cef..50318bd 100644 --- a/lib/dialog/add_note_dialog.dart +++ b/lib/dialog/add_note_dialog.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import '../network/NetworkConfig.dart'; - class AddNoteDialog extends StatefulWidget { Function onTap; @@ -22,18 +20,10 @@ class _AddNoteDialogState extends State { final TextEditingController _portNumber2Controller = TextEditingController(); final TextEditingController _portNumber3Controller = TextEditingController(); - // final List items2 = ['电视', '光缆', '大会员', '电信', '联通']; - - String selectedValue = ""; - String selectedValue2 = ""; - @override void initState() { // TODO: implement initState super.initState(); - - selectedValue = NetworkConfig.diverItems.first; - selectedValue2 = NetworkConfig.businessItems.first; } @override @@ -57,8 +47,7 @@ class _AddNoteDialogState extends State { return; } - widget.onTap(_businessNameController.text, selectedValue, selectedValue2, - "${_portNumber1Controller.text}/${_portNumber2Controller.text}/${_portNumber3Controller.text}"); + widget.onTap(_businessNameController.text, "${_portNumber1Controller.text}/${_portNumber2Controller.text}/${_portNumber3Controller.text}"); Navigator.pop(context); } @@ -117,89 +106,7 @@ class _AddNoteDialogState extends State { ), ), - ///设备型号 - Container( - alignment: Alignment.centerLeft, - margin: EdgeInsets.all(10), - child: Text( - "设备型号", - style: TextStyle(fontSize: 12), - ), - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - padding: EdgeInsets.symmetric(horizontal: 5), - height: 35, - alignment: Alignment.center, - decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))), - child: DropdownButton( - value: selectedValue, - // 当前选中的值 - icon: const Icon(Icons.arrow_drop_down, color: Colors.blue), - hint: const Text('请选择设备型号'), - underline: Container(), - isExpanded: true, - dropdownColor: const Color(0xFFEBEBEB), - onChanged: (String? newValue) { - // 当选择改变时,更新状态 - setState(() { - selectedValue = newValue!; - }); - }, - items: NetworkConfig.diverItems.map>((String value) { - return DropdownMenuItem( - value: value, - child: Text( - value, - style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w400), - ), - ); - }).toList(), - ), - ), - - /// - Container( - alignment: Alignment.centerLeft, - margin: EdgeInsets.all(10), - child: Text( - "业务类型", - style: TextStyle(fontSize: 12), - ), - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - padding: EdgeInsets.symmetric(horizontal: 5), - height: 35, - alignment: Alignment.center, - decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))), - child: DropdownButton( - value: selectedValue2, - // 当前选中的值 - icon: const Icon(Icons.arrow_drop_down, color: Colors.blue), - hint: const Text('请选择业务类型'), - underline: Container(), - isExpanded: true, - dropdownColor: const Color(0xFFEBEBEB), - onChanged: (String? newValue) { - // 当选择改变时,更新状态 - setState(() { - selectedValue2 = newValue!; - }); - }, - items: NetworkConfig.businessItems.map>((String value) { - return DropdownMenuItem( - value: value, - child: Text( - value, - style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w400), - ), - ); - }).toList(), - ), - ), - - /// + ///端口号数 Container( alignment: Alignment.centerLeft, margin: EdgeInsets.all(10), diff --git a/lib/dialog/modify_info_dialog.dart b/lib/dialog/modify_info_dialog.dart index ee9d72b..5ee9eae 100644 --- a/lib/dialog/modify_info_dialog.dart +++ b/lib/dialog/modify_info_dialog.dart @@ -42,13 +42,8 @@ class _ModifyInfoDialogState extends State { bool isConnect = false; bool isLoad = false; - String businessName = ""; - String deviceModel = ""; + String equipmentModel = ""; String businessType = ""; - String portNumber = ""; - - String selectedValue = ""; - String selectedValue2 = ""; // 用列表存储所有输入框的值,通过索引区分不同输入框 late List _controllers; @@ -89,8 +84,8 @@ class _ModifyInfoDialogState extends State { // TODO: implement initState super.initState(); - selectedValue = NetworkConfig.diverItems.first; - selectedValue2 = NetworkConfig.businessItems.first; + equipmentModel = NetworkConfig.diverItems.first; + businessType = NetworkConfig.businessItems.first; subscription = _viewmodel.streamController.stream.listen((event) { String code = event['code']; @@ -120,6 +115,14 @@ class _ModifyInfoDialogState extends State { (index) => TextEditingController(text: odfDetailsBean.historyFault![index].faultReason), ); + if ("${odfDetailsBean.equipmentModel}" == "null" && "${odfDetailsBean.equipmentModel}" == "") { + equipmentModel = "${odfDetailsBean.equipmentModel}"; + } + + if ("${odfDetailsBean.businessType}" != "null" && "${odfDetailsBean.businessType}" != "") { + businessType = "${odfDetailsBean.businessType}"; + } + break; case "save": //保存信息 @@ -160,7 +163,7 @@ class _ModifyInfoDialogState extends State { } if (_items.isNotEmpty) { - // 方法1:使用every()检查所有元素的faultTime是否为空 + // every()检查所有元素的faultTime是否为空 bool allFaultTimeEmpty = _items.every((bean) { // 判断faultTime为null或空字符串 return bean.faultTime == null || bean.faultTime!.trim().isEmpty; @@ -174,7 +177,7 @@ class _ModifyInfoDialogState extends State { EasyLoading.show(status: "loading..."); _viewmodel.save(widget.id, isConnect ? 1 : 0, _remarksController.text, _opticalAttenuationController.text, _historyRemarksController.text, _items, - _opticalCableOffRemarksController.text); + _opticalCableOffRemarksController.text, equipmentModel, businessType); } @override @@ -216,15 +219,9 @@ class _ModifyInfoDialogState extends State { FunctionUtil.popDialog2( context, AddNoteDialog( - onTap: (value1, value2, value3, value4) { - print("$value1-$value2-$value3-$value4"); - - appendTextWithNewline("$value1 $value2 $value3 $value4"); - - businessName = value1; - deviceModel = value2; - businessType = value3; - portNumber = value4; + onTap: (value1, value2) { + print("$value1-$value2-"); + appendTextWithNewline("$value1 $value2"); setState(() {}); }, ), @@ -376,7 +373,7 @@ class _ModifyInfoDialogState extends State { alignment: Alignment.center, decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))), child: DropdownButton( - value: selectedValue, + value: equipmentModel, // 当前选中的值 icon: const Icon(Icons.arrow_drop_down, color: Colors.blue), hint: const Text('请选择设备型号'), @@ -386,7 +383,7 @@ class _ModifyInfoDialogState extends State { onChanged: (String? newValue) { // 当选择改变时,更新状态 setState(() { - selectedValue = newValue!; + equipmentModel = newValue!; }); }, items: NetworkConfig.diverItems.map>((String value) { @@ -400,6 +397,48 @@ class _ModifyInfoDialogState extends State { }).toList(), ), ), + + ///业务类型 + Container( + alignment: Alignment.centerLeft, + margin: EdgeInsets.all(10), + child: Text( + "业务类型", + style: TextStyle(fontSize: 12), + ), + ), + Container( + margin: EdgeInsets.only(left: 10, right: 10), + padding: EdgeInsets.symmetric(horizontal: 5), + height: 35, + alignment: Alignment.center, + decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))), + child: DropdownButton( + value: businessType, + // 当前选中的值 + icon: const Icon(Icons.arrow_drop_down, color: Colors.blue), + hint: const Text('请选择业务类型'), + underline: Container(), + isExpanded: true, + dropdownColor: const Color(0xFFEBEBEB), + onChanged: (String? newValue) { + // 当选择改变时,更新状态 + setState(() { + businessType = newValue!; + }); + }, + items: NetworkConfig.businessItems.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text( + value, + style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w400), + ), + ); + }).toList(), + ), + ), + Container( alignment: Alignment.centerLeft, margin: EdgeInsets.all(10), diff --git a/lib/tools/machine/machine_model.dart b/lib/tools/machine/machine_model.dart index 48a2f17..b97a4c3 100644 --- a/lib/tools/machine/machine_model.dart +++ b/lib/tools/machine/machine_model.dart @@ -103,7 +103,7 @@ class MachineModel { } ///机架接口信息保存 - Future save(id, status, remarks, opticalAttenuation, historyRemarks, historyFault, opticalCableOffRemarks) async { + Future save(id, status, remarks, opticalAttenuation, historyRemarks, historyFault, opticalCableOffRemarks,equipmentModel,businessType) async { RequestCenter.instance.request(NetworkConfig.save, { "Id": id, "Status": status, @@ -112,6 +112,8 @@ class MachineModel { "HistoryRemarks": historyRemarks, "HistoryFault": historyFault, "OpticalCableOffRemarks": opticalCableOffRemarks, + "EquipmentModel": equipmentModel, + "BusinessType": businessType, }, (dataEntity) { if (dataEntity.code == 200) { // OdfDetailsBean odfDetailsBean = OdfDetailsBean.fromJson(dataEntity.data);