多语言

This commit is contained in:
czz
2025-07-30 16:48:48 +08:00
parent 92b6896176
commit 300e3b31f6
96 changed files with 3741 additions and 2710 deletions

View File

@@ -70,7 +70,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
children: [
// 中间居中的标题
Text(
'申请报修',
'申请报修'.tr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
@@ -147,7 +147,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
const AlignmentDirectional(
0, -1),
child: Text(
'选择需要报修的设备',
'选择需要报修的设备'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
letterSpacing: 0,
@@ -193,7 +193,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
const AlignmentDirectional(
-1, 0),
child: Text(
'已绑设备',
'已绑设备'.tr,
style: TextStyle(
fontFamily:
'Readex Pro',
@@ -201,6 +201,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
26.rpx,
letterSpacing:
0,
height: 1,
color: Colors
.white),
),
@@ -221,138 +222,6 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
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
@@ -367,7 +236,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
.device_list!
.map((device) =>
{
'mac': device['mac'].toString(),
'mac'.tr: device['mac'.tr].toString(),
'name': device['name'].toString(),
'type': device['device_type'].toString()
})
@@ -381,7 +250,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
.map(
(device) {
final mac =
device['mac']?.toString() ??
device['mac'.tr]?.toString() ??
'';
final name =
device['name']?.toString() ??
@@ -400,7 +269,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
deviceMacs =
deviceOptions
.map((device) =>
device['mac']!)
device['mac'.tr]!)
.toList();
return AbsorbPointer(
@@ -428,12 +297,12 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
.model
.device_list!
.firstWhere((device) =>
device['mac'].toString() ==
device['mac'.tr].toString() ==
val);
final mac =
selectedDevice['mac']?.toString() ??
'未知MAC';
selectedDevice['mac'.tr]?.toString() ??
'未知MAC'.tr;
final name =
selectedDevice['name']?.toString();
final type =
@@ -449,7 +318,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
.device_type = selectedDevice['device_type'];
controller
.model
.device_category = '未知型号';
.device_category = '未知型号'.tr;
controller
.model
.device_name = (name != null &&
@@ -481,9 +350,11 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
),
hintText: isDeviceListEmpty
? '暂无可选设备'
: '请选择绑定设备',
.tr
: '请选择绑定设备'
.tr,
searchHintText:
'查找',
'查找'.tr,
icon:
Icon(
Icons
@@ -546,15 +417,16 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
.height *
0.038,
constraints:
const BoxConstraints(
minWidth: 60,
BoxConstraints(
minWidth: 62,
),
child: Align(
alignment:
const AlignmentDirectional(
-1, 0),
child: Text(
'设备系列',
'设备系列'.tr,
maxLines: 2,
style: TextStyle(
fontFamily:
'Readex Pro',
@@ -562,6 +434,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
26.rpx,
letterSpacing:
0,
height: 1,
color: Colors
.white),
),
@@ -730,7 +603,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
const AlignmentDirectional(
-1, 0),
child: Text(
'产品型号',
'产品型号'.tr,
style: TextStyle(
fontFamily:
'Readex Pro',
@@ -738,6 +611,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
26.rpx,
letterSpacing:
0,
height: 1,
color: Colors
.white),
),
@@ -898,15 +772,16 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
.height *
0.038,
constraints:
const BoxConstraints(
minWidth: 60,
),
BoxConstraints(
minWidth: 60,
minHeight:
60.rpx),
child: Align(
alignment:
const AlignmentDirectional(
-1, 0),
child: Text(
'序列号',
'序列号'.tr,
style: TextStyle(
fontFamily:
'Readex Pro',
@@ -914,6 +789,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
26.rpx,
letterSpacing:
0,
height: 1,
color: Colors
.white),
),
@@ -1182,7 +1058,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
const AlignmentDirectional(
0, 0),
child: Text(
'上传设备故障照片',
'上传设备故障照片'.tr,
style: TextStyle(
fontFamily:
'Readex Pro',
@@ -1393,7 +1269,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
padding: const EdgeInsetsDirectional
.fromSTEB(0, 15, 0, 16),
child: Text(
'请描述一下您的问题',
'请描述一下您的问题'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: Colors.white,
@@ -1432,7 +1308,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
obscureText: false,
decoration: InputDecoration(
hintText: '问题描述100个字以内',
hintText: '问题描述100个字以内'.tr,
labelStyle: TextStyle(
fontFamily: 'Readex Pro',
fontSize: AppFontsize
@@ -1530,13 +1406,12 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
padding: EdgeInsetsDirectional.fromSTEB(
0, 48.rpx, 0, 48.rpx),
child: Text(
'联系方式',
'联系方式'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: Colors.white,
fontSize: 30.rpx,
letterSpacing: 0,
),
),
),
@@ -1592,7 +1467,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
MainAxisSize.max,
children: [
Text(
'联系人',
'联系人'.tr,
style: TextStyle(
fontFamily:
'Readex Pro',
@@ -1756,7 +1631,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
MainAxisSize.max,
children: [
Text(
'手机号码',
'手机号码'.tr,
style: TextStyle(
fontFamily:
'Readex Pro',
@@ -1807,6 +1682,8 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
letterSpacing:
0,
),
// hintText:
// "请输入手机号".tr,
hintStyle:
TextStyle(
fontFamily:
@@ -1932,7 +1809,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
},
"device": [
{
"mac": controller.model.device_id,
"mac".tr: controller.model.device_id,
"desc": controller.model.desc,
"img": controller.model.issue_img,
"category": controller.model.device_category,
@@ -1942,7 +1819,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
],
};
ApiResponse apiResponse = await requestWithLog(
logTitle: "提交报修信息",
logTitle: "提交报修信息".tr,
method: MyHttpMethod.post,
queryUrl: queryUrl,
data: data,
@@ -1979,7 +1856,7 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
borderRadius: BorderRadius.circular(6),
),
child: Text(
"提交申请",
"提交申请".tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: stringToColor("#011D33"),
@@ -2016,53 +1893,52 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
return images;
}
String checkRepairParam() {
String message = "";
if (controller.model.device_type == null ||
controller.model.device_series!.isEmpty) {
message = '请输入设备系列!';
message = '请输入设备系列!'.tr;
return message;
}
if (controller.model.device_category == null ||
controller.model.device_category!.isEmpty) {
message = '请输入设备型号!';
message = '请输入设备型号!'.tr;
return message;
}
if (controller.model.device_id == null ||
controller.model.device_id!.isEmpty) {
message = '请输入设备序列号id';
message = '请输入设备序列号id'.tr;
return message;
}
if (controller.model.apply_name == null ||
controller.model.apply_name!.isEmpty) {
message = '请输入姓名!';
message = '请输入姓名!'.tr;
return message;
}
RegExp nameRegExp = RegExp(r'^[\u4e00-\u9fa5]{2,4}$');
if (!nameRegExp.hasMatch(controller.model.apply_name!)) {
message = '姓名必须为2到4个汉字';
message = '姓名必须为2到4个汉字'.tr;
return message;
}
if (controller.model.tel == null || controller.model.tel!.isEmpty) {
message = '请输入手机号!';
message = '请输入手机号!'.tr;
return message;
}
if (!MyUtils.isValidPhoneNumber(controller.model.tel!)) {
message = '无效的手机号!';
message = '无效的手机号!'.tr;
return message;
}
if (controller.model.desc == null || controller.model.desc!.isEmpty) {
message = '请输入问题描述!';
message = '请输入问题描述!'.tr;
return message;
}
if (controller.model.issue_img == null ||
controller.model.issue_img!.isEmpty) {
message = '请至少上传一张问题图片!';
message = '请至少上传一张问题图片!'.tr;
return message;
}
return message;
@@ -2083,13 +1959,13 @@ class ApplyRepairPage extends GetView<ApplyRepairController> {
if (type == null) return '';
switch (type) {
case 1:
return '体征检测设备';
return '体征检测设备'.tr;
case 2:
return '智能床';
return '智能床'.tr;
case 3:
return '智能床垫';
return '智能床垫'.tr;
default:
return '未知设备';
return '未知设备'.tr;
}
}
}