修改ui设计错误
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
class BookInfoModel {
|
||||
// DateTime? dateTime; //预约时间
|
||||
@@ -16,6 +23,14 @@ class BookInfoModel {
|
||||
Map dataT = {};
|
||||
|
||||
BookInfoModel();
|
||||
BookInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
// dateTime = json['dateTime'];
|
||||
userName = json['userName'];
|
||||
userPhone = json['userPhone'];
|
||||
time_period = json['time_period'];
|
||||
// select_time = json['select_time'];
|
||||
select_time_index = json['select_time_index'];
|
||||
}
|
||||
}
|
||||
|
||||
class BookInfoController extends GetControllerEx<BookInfoModel> {
|
||||
@@ -25,13 +40,44 @@ class BookInfoController extends GetControllerEx<BookInfoModel> {
|
||||
|
||||
// get userInfoController => Get.find<UserInfoController>();
|
||||
|
||||
Future<void> getData(String storeId) async {
|
||||
// 初始化模型
|
||||
model.datetimes = [];
|
||||
model.datetimes_index = null;
|
||||
model.dataT = {};
|
||||
updateAll();
|
||||
|
||||
String url =
|
||||
"https://crm-api.swes.com.cn/agent/userBook/config/detailConfigByStore?storeId=$storeId";
|
||||
|
||||
await requestWithLog(
|
||||
logTitle: "获取预约门店时间",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: url,
|
||||
successMsg: "获取预约门店时间成功",
|
||||
errorMsg: "获取预约门店时间失败",
|
||||
onSuccess: (res) {
|
||||
final data = res.data;
|
||||
if (data != null) {
|
||||
model.datetimes = data["dateList"] ?? [];
|
||||
model.datetimes_index = 0;
|
||||
model.dataT = data;
|
||||
time_periodChange(); // 原来的 time_periodChange
|
||||
updateAll();
|
||||
}
|
||||
},
|
||||
onFailure: (res) {},
|
||||
);
|
||||
}
|
||||
|
||||
// getData(id) {
|
||||
// model.datetimes = [];
|
||||
// model.datetimes_index = null;
|
||||
// model.dataT = {};
|
||||
// updateAll();
|
||||
// ApiService.reservation.get("/agent/userBook/config/detailConfigByStore?storeId=$id")
|
||||
// .then((d) {
|
||||
// ApiService.reservation
|
||||
// .get("/agent/userBook/config/detailConfigByStore?storeId=$id")
|
||||
// .then((d) {
|
||||
// model.datetimes = d.data["dateList"];
|
||||
// model.datetimes_index = 0;
|
||||
// model.dataT = d.data;
|
||||
@@ -39,14 +85,15 @@ class BookInfoController extends GetControllerEx<BookInfoModel> {
|
||||
// });
|
||||
// }
|
||||
|
||||
// time_periodChange() {
|
||||
// if(model.datetimes_index == null) {
|
||||
// return;
|
||||
// }
|
||||
// model.select_time_index = null;
|
||||
// model.time_period = model.dataT[model.datetimes?[model.datetimes_index!]["day"]];
|
||||
// updateAll();
|
||||
// }
|
||||
time_periodChange() {
|
||||
if (model.datetimes_index == null) {
|
||||
return;
|
||||
}
|
||||
model.select_time_index = null;
|
||||
model.time_period =
|
||||
model.dataT[model.datetimes?[model.datetimes_index!]["day"]];
|
||||
updateAll();
|
||||
}
|
||||
|
||||
// submitData(id) {
|
||||
// String tel = userInfoController.model?.user?.tel ?? "";
|
||||
|
||||
22
lib/controller/mh_controller/device.dart
Normal file
22
lib/controller/mh_controller/device.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'device_share.dart';
|
||||
|
||||
part 'device.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class DeviceModel {
|
||||
String? name; //设备名称
|
||||
String? id; //设备id
|
||||
String? status; //设备状态
|
||||
String? roomName; //设备所属房间
|
||||
String? shareNum; //设备已分享数量
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
List<DeviceShareModel> shareInfo = []; //设备分享信息
|
||||
|
||||
DeviceModel();
|
||||
static DeviceModel fromJson(Map<String, dynamic> json) =>
|
||||
_$DeviceModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$DeviceModelToJson(this);
|
||||
}
|
||||
23
lib/controller/mh_controller/device.g.dart
Normal file
23
lib/controller/mh_controller/device.g.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'device.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
DeviceModel _$DeviceModelFromJson(Map<String, dynamic> json) => DeviceModel()
|
||||
..name = json['name'] as String?
|
||||
..id = json['id'] as String?
|
||||
..status = json['status'] as String?
|
||||
..roomName = json['roomName'] as String?
|
||||
..shareNum = json['shareNum'] as String?;
|
||||
|
||||
Map<String, dynamic> _$DeviceModelToJson(DeviceModel instance) =>
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
'id': instance.id,
|
||||
'status': instance.status,
|
||||
'roomName': instance.roomName,
|
||||
'shareNum': instance.shareNum,
|
||||
};
|
||||
100
lib/controller/mh_controller/device_list_controller.dart
Normal file
100
lib/controller/mh_controller/device_list_controller.dart
Normal file
@@ -0,0 +1,100 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
|
||||
import 'package:vbvs_app/controller/mh_controller/device.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
part 'device_list_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class DeviceListModel {
|
||||
//设备列表
|
||||
List<dynamic> deviceList = [];
|
||||
List<dynamic> deviceListWyf = [];
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
String? keyword;
|
||||
@JsonKey(ignore: true)
|
||||
Color? color = Color(0xFFFFFFFF);
|
||||
|
||||
DeviceListModel();
|
||||
static DeviceListModel fromJson(Map<String, dynamic> json) =>
|
||||
_$DeviceListModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$DeviceListModelToJson(this);
|
||||
}
|
||||
|
||||
class DeviceListController extends GetControllerEx<DeviceListModel> {
|
||||
DeviceListController() {
|
||||
attr = GetModel(DeviceListModel()).obs;
|
||||
}
|
||||
|
||||
// @override
|
||||
// void onInit() {
|
||||
// super.onInit();
|
||||
// model.keyword = "";
|
||||
// getDeviceList(); // 正确的初始化数据调用
|
||||
// }
|
||||
|
||||
// getDeviceList({int time = 1}) async {
|
||||
// String search = (model.keyword != null && model.keyword!.isNotEmpty)
|
||||
// ? "?key=${model.keyword}"
|
||||
// : "";
|
||||
// var data = await ApiService.request.get("/api/device/info/list$search");
|
||||
// if (data.data["data"] != null) {
|
||||
// try {
|
||||
// List<dynamic> tmp = data.data["data"] as List<dynamic>;
|
||||
// model.deviceList = tmp.map((obj) => DeviceModel.fromJson(obj)).toList();
|
||||
// model.deviceListWyf = tmp;
|
||||
// } catch (e) {
|
||||
// print(e);
|
||||
// }
|
||||
// } else {
|
||||
// model.deviceList = [];
|
||||
// model.deviceListWyf = [];
|
||||
// }
|
||||
// updateAll();
|
||||
// }
|
||||
|
||||
getDeviceList() async {
|
||||
try {
|
||||
String search = (model.keyword != null && model.keyword!.isNotEmpty)
|
||||
? "?key=${model.keyword}"
|
||||
: "";
|
||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr);
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.device_list;
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}$search";
|
||||
var response = await EasyDartModule.dio.get(queryUrl);
|
||||
if (response != null) {
|
||||
var responseData =
|
||||
response.data is String ? jsonDecode(response.data) : response.data;
|
||||
ApiResponse res =
|
||||
ApiResponse.fromJson(responseData, (object) => object);
|
||||
MyUtils.formatResponse(res, "设备.设备列表请求成功".tr, "设备.设备列表请求失败".tr);
|
||||
if (res.code == HttpStatusCodes.ok) {
|
||||
// bindDeviceNum.value = res.total!;
|
||||
model.deviceList =res.data;
|
||||
|
||||
updateAll();
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||
}
|
||||
return apiResponse;
|
||||
} catch (e) {
|
||||
EasyDartModule.logger.info("设备请求列表: $e");
|
||||
DailyLogUtils.writeLog("设备请求列表: $e");
|
||||
}
|
||||
return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement
|
||||
}
|
||||
}
|
||||
20
lib/controller/mh_controller/device_list_controller.g.dart
Normal file
20
lib/controller/mh_controller/device_list_controller.g.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'device_list_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
DeviceListModel _$DeviceListModelFromJson(Map<String, dynamic> json) =>
|
||||
DeviceListModel()
|
||||
..deviceList = (json['deviceList'] as List<dynamic>)
|
||||
.map((e) => DeviceModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..deviceListWyf = json['deviceListWyf'] as List<dynamic>;
|
||||
|
||||
Map<String, dynamic> _$DeviceListModelToJson(DeviceListModel instance) =>
|
||||
<String, dynamic>{
|
||||
'deviceList': instance.deviceList,
|
||||
'deviceListWyf': instance.deviceListWyf,
|
||||
};
|
||||
15
lib/controller/mh_controller/device_share.dart
Normal file
15
lib/controller/mh_controller/device_share.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'device_share.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class DeviceShareModel {
|
||||
String? name; //设备名称
|
||||
String? phone; //被分享手机号
|
||||
DateTime? share_time; //分享时间
|
||||
|
||||
DeviceShareModel();
|
||||
static DeviceShareModel fromJson(Map<String, dynamic> json) =>
|
||||
_$DeviceShareModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$DeviceShareModelToJson(this);
|
||||
}
|
||||
22
lib/controller/mh_controller/device_share.g.dart
Normal file
22
lib/controller/mh_controller/device_share.g.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'device_share.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
DeviceShareModel _$DeviceShareModelFromJson(Map<String, dynamic> json) =>
|
||||
DeviceShareModel()
|
||||
..name = json['name'] as String?
|
||||
..phone = json['phone'] as String?
|
||||
..share_time = json['share_time'] == null
|
||||
? null
|
||||
: DateTime.parse(json['share_time'] as String);
|
||||
|
||||
Map<String, dynamic> _$DeviceShareModelToJson(DeviceShareModel instance) =>
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
'phone': instance.phone,
|
||||
'share_time': instance.share_time?.toIso8601String(),
|
||||
};
|
||||
122
lib/controller/mh_controller/mhdevice_share_controller.dart
Normal file
122
lib/controller/mh_controller/mhdevice_share_controller.dart
Normal file
@@ -0,0 +1,122 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio/src/form_data.dart' as formdata;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
|
||||
part 'mhdevice_share_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class MHDeviceShareModel {
|
||||
String? phone;
|
||||
int? type = 1;
|
||||
|
||||
String? msg;
|
||||
int? show = 0;
|
||||
|
||||
int limit = AppConstants.limit;
|
||||
int offset = 0;
|
||||
bool isLoading = false;
|
||||
bool hasMore = true;
|
||||
|
||||
// List<dynamic>? shareUser = [
|
||||
// {"type": 1},
|
||||
// {"type": 2}
|
||||
// ];
|
||||
List<dynamic>? shareUser = [];
|
||||
Map mainShare = {};
|
||||
|
||||
MHDeviceShareModel();
|
||||
static MHDeviceShareModel fromJson(Map<String, dynamic> json) =>
|
||||
_$MHDeviceShareModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$MHDeviceShareModelToJson(this);
|
||||
}
|
||||
|
||||
class MHDeviceShareController extends GetControllerEx<MHDeviceShareModel> {
|
||||
MHDeviceShareController() {
|
||||
attr = GetModel(MHDeviceShareModel()).obs;
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
model.shareUser = [
|
||||
{
|
||||
'userName': '张三',
|
||||
'opType': 1, // 允许控制
|
||||
},
|
||||
{
|
||||
'userName': '李四',
|
||||
'opType': 2, // 仅查看
|
||||
},
|
||||
{
|
||||
'userName': '王五',
|
||||
'opType': 1,
|
||||
},
|
||||
];
|
||||
update(); // 刷新UI
|
||||
}
|
||||
|
||||
// Future<String> sendInvite(String? phone, String mac) async {
|
||||
// if (phone == null || phone.isEmpty) {
|
||||
// return "手机号不能为空";
|
||||
// }
|
||||
// if (!MyUtils.isValidPhoneNumber(phone)) {
|
||||
// return "手机号格式不正确";
|
||||
// }
|
||||
// var type = model.type;
|
||||
// try {
|
||||
// var aa = await ApiService.requestNoInfo.post("/api/device/info/share",
|
||||
// data: formdata.FormData.fromMap(
|
||||
// {"mac": mac, "tel": phone, "type": type}));
|
||||
// return "";
|
||||
// } catch (e) {
|
||||
// if (e is DioError) {
|
||||
// // 返回 DioError 的 message 属性
|
||||
// return e.message!;
|
||||
// } else {
|
||||
// // 处理其他类型的错误
|
||||
// return e.toString();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Future<void> initData() async {
|
||||
// //todo 请求分享列表
|
||||
// var deviceController = Get.find<GlobalController>();
|
||||
// var query = {
|
||||
// "mac": deviceController.model.deviceMain['mac'],
|
||||
// };
|
||||
// var data = await ApiService.request
|
||||
// .get("/api/device/info/share", data: formdata.FormData.fromMap(query));
|
||||
|
||||
// if (data.data["data"] != null) {
|
||||
// try {
|
||||
// List<dynamic> tmp = data.data["data"] as List<dynamic>;
|
||||
// model.shareUser = tmp;
|
||||
// } catch (e) {
|
||||
// print(e);
|
||||
// }
|
||||
// } else {
|
||||
// model.shareUser = [];
|
||||
// }
|
||||
// updateAll();
|
||||
// }
|
||||
|
||||
// //保存
|
||||
// saveShareDevice(Map shareInfo, RxInt type) async {
|
||||
// return await ApiService.request.put("/api/device/info/share",
|
||||
// data: formdata.FormData.fromMap({
|
||||
// "mac": shareInfo['mac'],
|
||||
// "tel": shareInfo['tel'],
|
||||
// "type": type.value
|
||||
// }));
|
||||
// }
|
||||
|
||||
// //删除
|
||||
// deleteShare(Map shareInfo) async {
|
||||
// return await ApiService.request.delete("/api/device/info/share",
|
||||
// data: formdata.FormData.fromMap(
|
||||
// {"mac": shareInfo['mac'], "tel": shareInfo['tel']}));
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'mhdevice_share_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MHDeviceShareModel _$MHDeviceShareModelFromJson(Map<String, dynamic> json) =>
|
||||
MHDeviceShareModel()
|
||||
..phone = json['phone'] as String?
|
||||
..type = (json['type'] as num?)?.toInt()
|
||||
..msg = json['msg'] as String?
|
||||
..show = (json['show'] as num?)?.toInt()
|
||||
..limit = (json['limit'] as num).toInt()
|
||||
..offset = (json['offset'] as num).toInt()
|
||||
..isLoading = json['isLoading'] as bool
|
||||
..hasMore = json['hasMore'] as bool
|
||||
..shareUser = json['shareUser'] as List<dynamic>?
|
||||
..mainShare = json['mainShare'] as Map<String, dynamic>;
|
||||
|
||||
Map<String, dynamic> _$MHDeviceShareModelToJson(MHDeviceShareModel instance) =>
|
||||
<String, dynamic>{
|
||||
'phone': instance.phone,
|
||||
'type': instance.type,
|
||||
'msg': instance.msg,
|
||||
'show': instance.show,
|
||||
'limit': instance.limit,
|
||||
'offset': instance.offset,
|
||||
'isLoading': instance.isLoading,
|
||||
'hasMore': instance.hasMore,
|
||||
'shareUser': instance.shareUser,
|
||||
'mainShare': instance.mainShare,
|
||||
};
|
||||
Reference in New Issue
Block a user