修改选择器样式
This commit is contained in:
198
lib/controller/mh_controller/apply_repair_controller.dart
Normal file
198
lib/controller/mh_controller/apply_repair_controller.dart
Normal file
@@ -0,0 +1,198 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:img_picker/img_picker.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
|
||||
import 'muser_info_controller.dart';
|
||||
|
||||
part 'apply_repair_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class ApplyRepairModel {
|
||||
int? id; //报修id
|
||||
String? apply_name; //申请人名称
|
||||
String? tel; //手机号
|
||||
String? address; //地址
|
||||
String? desc; //问题描述
|
||||
DateTime? create_time; //创建时间
|
||||
|
||||
String? device_type; //类型 床,床垫 不能为空
|
||||
String? device_category; //型号 不能为空
|
||||
String? device_id; //序列号 设备id 不能为空
|
||||
|
||||
String? device_name; //名称 可为空
|
||||
|
||||
List<String>? issue_img = []; //图片
|
||||
int? imagesLImit = 3; //图片限制上传数量
|
||||
String? img_bucket = 'mianhuatang_repair';
|
||||
|
||||
String? status; //维修状态
|
||||
|
||||
String? select_device;
|
||||
// String? select_type;
|
||||
// List<String>? device_list = ['床垫/BY-H/智能床垫', '床垫/BY-A/智能床垫', '床垫/BY-C/智能床垫'];
|
||||
List<dynamic>? device_list = [];
|
||||
int? score;
|
||||
DateTime? score_time; //创建时间
|
||||
|
||||
int? messageType = 1; //消息类型
|
||||
int? repairId; //消息类型
|
||||
|
||||
ApplyRepairModel();
|
||||
static ApplyRepairModel fromJson(Map<String, dynamic> json) =>
|
||||
_$ApplyRepairModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ApplyRepairModelToJson(this);
|
||||
}
|
||||
|
||||
class ApplyRepairController extends GetControllerEx<ApplyRepairModel> {
|
||||
// RepairRepository repairRepository = RepairRepository();
|
||||
ApplyRepairController() {
|
||||
attr = GetModel(ApplyRepairModel()).obs;
|
||||
}
|
||||
|
||||
// //上传图片
|
||||
// Future<void> uploadImg() async {
|
||||
// final ImagePicker picker = ImagePicker();
|
||||
// final XFile? image = await picker.pickImage(source: ImageSource.gallery);
|
||||
// final user = Supabase.instance.client.auth.currentUser;
|
||||
// try {
|
||||
// if (image != null) {
|
||||
// int fileSize = await image.length(); // 获取图片大小,单位为字节
|
||||
// if (fileSize > 1024 * 1024 * 5) {
|
||||
// // 1 MB = 1024 * 1024 bytes
|
||||
// showToast("上传图片不能超过5MB");
|
||||
// return;
|
||||
// }
|
||||
// final filePath = image.path; // 获取文件路径
|
||||
// final fileExtension = p.extension(filePath); // 获取文件扩展名,包括点(.)
|
||||
// // 获取当前日期并格式化为 yyyy-MM-dd
|
||||
// final String folderName =
|
||||
// DateFormat('yyyy-MM-dd').format(DateTime.now());
|
||||
// final file = File(image.path);
|
||||
// // 构造文件路径,文件会被上传到 record_img 文件夹下的当天日期文件夹
|
||||
// var response = await ef.client.storage
|
||||
// .from(model.img_bucket!)
|
||||
// .upload('$folderName/${Uuid().v4()}$fileExtension', file);
|
||||
// if (response != null) {
|
||||
// String publicUrl =
|
||||
// ef.client.storage.from(model.img_bucket!).getPublicUrl(response);
|
||||
|
||||
// print('文件上传成功: $response');
|
||||
// print('文件上传成功: $publicUrl');
|
||||
// String prefixToRemove = 'mianhuatang_repair/';
|
||||
// model.issue_img!.add(response.startsWith(prefixToRemove)
|
||||
// ? response.substring(prefixToRemove.length)
|
||||
// : response);
|
||||
// updateAll();
|
||||
// }
|
||||
// print('/$model.img_bucket');
|
||||
// } else {
|
||||
// print('未选择图片');
|
||||
// return;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print('上传失败: $e');
|
||||
// }
|
||||
// }
|
||||
|
||||
// //提交
|
||||
// Future<String> submitRepair(BuildContext context) async {
|
||||
// //tmp
|
||||
// // return '';
|
||||
// String message = '';
|
||||
// final MyDialogController myDialogController =
|
||||
// Get.find<MyDialogController>();
|
||||
// if (model.device_type == null || model.device_type!.isEmpty) {
|
||||
// message = '请选择设备类型!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.device_category == null || model.device_category!.isEmpty) {
|
||||
// message = '请输入设备型号!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.device_id == null || model.device_id!.isEmpty) {
|
||||
// message = '请输入设备序列号id!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.apply_name == null || model.apply_name!.isEmpty) {
|
||||
// message = '请输入姓名!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// RegExp nameRegExp = RegExp(r'^[\u4e00-\u9fa5]{2,4}$');
|
||||
|
||||
// if (!nameRegExp.hasMatch(model.apply_name!)) {
|
||||
// message = '姓名必须为2到4个汉字!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.tel == null || model.tel!.isEmpty) {
|
||||
// message = '请输入手机号!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (!MyUtils.isValidPhoneNumber(model.tel!)) {
|
||||
// message = '无效的手机号!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.address == null || model.address!.isEmpty) {
|
||||
// message = '请输入地址!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.desc == null || model.desc!.isEmpty) {
|
||||
// message = '请输入问题描述!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.issue_img == null || model.issue_img!.isEmpty) {
|
||||
// message = '请至少上传一张问题图片!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// model.status = RepairStatus.pending;
|
||||
// await repairRepository.saveRepair(model);
|
||||
// return message;
|
||||
// }
|
||||
|
||||
// Future<void> getDeviceList() async {
|
||||
// final UserInfoController userInfoController =
|
||||
// Get.find<UserInfoController>();
|
||||
// // UserModel loginUser = userInfoController.model.user!;
|
||||
// DeviceListController deviceListController = Get.find();
|
||||
// await deviceListController.getDeviceList();
|
||||
// var aa = deviceListController.model.deviceListWyf;
|
||||
// ApplyRepairController applyRepairController = Get.find();
|
||||
// applyRepairController.model.device_list = aa;
|
||||
// }
|
||||
|
||||
// String getPublicUrl(String path) {
|
||||
// try {
|
||||
// String bucketPath = '${model.img_bucket}/';
|
||||
// if (path.contains(bucketPath)) {
|
||||
// int firstIndex = path.indexOf(bucketPath);
|
||||
// // int secondIndex =
|
||||
// // response.indexOf(bucketPath, firstIndex + bucketPath.length);
|
||||
// if (firstIndex != -1) {
|
||||
// // 去掉第一个存储桶路径
|
||||
// path = path.replaceFirst(bucketPath, '', firstIndex);
|
||||
// }
|
||||
// }
|
||||
// String publicUrl =
|
||||
// ef.client.storage.from(model.img_bucket!).getPublicUrl(path);
|
||||
// return publicUrl;
|
||||
// } catch (e) {}
|
||||
// return '';
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user