调整和修改
This commit is contained in:
@@ -32,13 +32,16 @@ class HistoryController extends GetxController {
|
|||||||
final args = Get.arguments as Map<String, dynamic>;
|
final args = Get.arguments as Map<String, dynamic>;
|
||||||
stationName = args['stationName'] as String;
|
stationName = args['stationName'] as String;
|
||||||
fetchHistoryData();
|
fetchHistoryData();
|
||||||
getAllOrderCounts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getAllOrderCounts() async {
|
Future<void> getAllOrderCounts() async {
|
||||||
var response = await HttpService.to.post(
|
var response = await HttpService.to.post(
|
||||||
"appointment/orderAddHyd/getAllOrderCounts",
|
"appointment/orderAddHyd/getAllOrderCounts",
|
||||||
data: {
|
data: {
|
||||||
|
// --- 直接使用 DateFormat 来格式化日期 ---
|
||||||
|
'startTime': _apiDateFormat.format(startDate.value),
|
||||||
|
'endTime': _apiDateFormat.format(endDate.value),
|
||||||
|
'plateNumber': plateNumberController.text,
|
||||||
'stationName': stationName, // 加氢站名称
|
'stationName': stationName, // 加氢站名称
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -60,6 +63,10 @@ class HistoryController extends GetxController {
|
|||||||
|
|
||||||
Future<void> fetchHistoryData() async {
|
Future<void> fetchHistoryData() async {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
|
||||||
|
//获取数据
|
||||||
|
getAllOrderCounts();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response = await HttpService.to.post(
|
var response = await HttpService.to.post(
|
||||||
"appointment/orderAddHyd/sitOrderPage",
|
"appointment/orderAddHyd/sitOrderPage",
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ class SiteController extends GetxController with BaseControllerMixin {
|
|||||||
showToast('暂时无法获取预约数据');
|
showToast('暂时无法获取预约数据');
|
||||||
hasReservationData = false;
|
hasReservationData = false;
|
||||||
reservationList = [];
|
reservationList = [];
|
||||||
|
dismissLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -657,7 +657,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
showLoading("加载中");
|
showLoading("加氢站数据加载中");
|
||||||
final originalHeaders = Map<String, dynamic>.from(HttpService.to.dio.options.headers);
|
final originalHeaders = Map<String, dynamic>.from(HttpService.to.dio.options.headers);
|
||||||
try {
|
try {
|
||||||
HttpService.to.setBaseUrl(AppTheme.jiaqing_service_url);
|
HttpService.to.setBaseUrl(AppTheme.jiaqing_service_url);
|
||||||
@@ -670,49 +670,46 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
dismissLoading();
|
dismissLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
dismissLoading();
|
||||||
|
var result = BaseModel.fromJson(responseData.data);
|
||||||
|
var stationDataList = result.data['data'] as List;
|
||||||
|
|
||||||
try {
|
// 使用 map 将 List<dynamic> 转换为 List<StationModel>
|
||||||
dismissLoading();
|
var stations = stationDataList
|
||||||
var result = BaseModel.fromJson(responseData.data);
|
.map((item) => StationModel.fromJson(item as Map<String, dynamic>))
|
||||||
var stationDataList = result.data['data'] as List;
|
.toList();
|
||||||
|
|
||||||
// 使用 map 将 List<dynamic> 转换为 List<StationModel>
|
// 去重,确保每个 hydrogenId 唯一
|
||||||
var stations = stationDataList
|
var uniqueStationsMap = <String, StationModel>{}; // 使用 Map 来去重
|
||||||
.map((item) => StationModel.fromJson(item as Map<String, dynamic>))
|
for (var station in stations) {
|
||||||
.toList();
|
uniqueStationsMap[station.hydrogenId] = station; // 使用 hydrogenId 作为键,确保唯一
|
||||||
|
}
|
||||||
|
|
||||||
// 去重,确保每个 hydrogenId 唯一
|
// 获取去重后的 List<StationModel>
|
||||||
var uniqueStationsMap = <String, StationModel>{}; // 使用 Map 来去重
|
var uniqueStations = uniqueStationsMap.values.toList();
|
||||||
for (var station in stations) {
|
|
||||||
uniqueStationsMap[station.hydrogenId] = station; // 使用 hydrogenId 作为键,确保唯一
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取去重后的 List<StationModel>
|
stationOptions.assignAll(uniqueStations);
|
||||||
var uniqueStations = uniqueStationsMap.values.toList();
|
|
||||||
|
|
||||||
stationOptions.assignAll(uniqueStations);
|
if (stationOptions.isEmpty) {
|
||||||
|
showToast('附近暂无可用加氢站');
|
||||||
|
} else {
|
||||||
|
showToast('站点列表已刷新');
|
||||||
|
}
|
||||||
|
|
||||||
if (stationOptions.isEmpty) {
|
// 找到第一个可选的站点作为默认值
|
||||||
showToast('附近暂无可用加氢站');
|
if (stationOptions.isNotEmpty) {
|
||||||
} else {
|
final firstSelectable = stationOptions.firstWhere(
|
||||||
showToast('站点列表已刷新');
|
(station) => station.isSelect == 1,
|
||||||
}
|
orElse: () => stationOptions.first, // 降级:如果没有可选的,就用第一个
|
||||||
|
);
|
||||||
// 找到第一个可选的站点作为默认值
|
selectedStationId.value = firstSelectable.hydrogenId;
|
||||||
if (stationOptions.isNotEmpty) {
|
} else {
|
||||||
final firstSelectable = stationOptions.firstWhere(
|
// 如果列表为空,确保 selectedStationId 也为空
|
||||||
(station) => station.isSelect == 1,
|
selectedStationId.value = null;
|
||||||
orElse: () => stationOptions.first, // 降级:如果没有可选的,就用第一个
|
|
||||||
);
|
|
||||||
selectedStationId.value = firstSelectable.hydrogenId;
|
|
||||||
} else {
|
|
||||||
// 如果列表为空,确保 selectedStationId 也为空
|
|
||||||
selectedStationId.value = null;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
showToast('数据异常');
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
dismissLoading();
|
||||||
|
showToast('数据异常');
|
||||||
} finally {
|
} finally {
|
||||||
dismissLoading();
|
dismissLoading();
|
||||||
HttpService.to.setBaseUrl(AppTheme.test_service_url);
|
HttpService.to.setBaseUrl(AppTheme.test_service_url);
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
|||||||
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
showToast(result.error);
|
showToast(result.error);
|
||||||
|
dismissLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,6 +347,7 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
|||||||
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
showToast(result.error);
|
showToast(result.error);
|
||||||
|
dismissLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user