调整司机预约时间
站点工单状态
This commit is contained in:
@@ -7,16 +7,17 @@ import 'package:ln_jq_app/common/styles/theme.dart';
|
||||
import 'package:ln_jq_app/storage_service.dart';
|
||||
|
||||
enum ReservationStatus {
|
||||
pending, // 待处理 ( addStatus: 1)
|
||||
completed, // 已完成 ( addStatus: 2)
|
||||
rejected, // 已拒绝 ( 3)
|
||||
pending, // 待处理 ( addStatus: 0)
|
||||
completed, // 完成 ( addStatus: 1)
|
||||
rejected, // 拒绝 ( -1)
|
||||
unadded, // 未加 ( 2)
|
||||
unknown, // 未知状态
|
||||
}
|
||||
|
||||
class ReservationModel {
|
||||
final String id;
|
||||
final String plateNumber;
|
||||
String amount;
|
||||
String amount;
|
||||
final String time;
|
||||
final String contactPerson;
|
||||
final String contactPhone;
|
||||
@@ -33,6 +34,7 @@ class ReservationModel {
|
||||
final String stateName;
|
||||
final String addStatus;
|
||||
final String addStatusName;
|
||||
bool hasEdit;
|
||||
|
||||
ReservationModel({
|
||||
required this.id,
|
||||
@@ -41,6 +43,7 @@ class ReservationModel {
|
||||
required this.time,
|
||||
required this.contactPerson,
|
||||
required this.contactPhone,
|
||||
required this.hasEdit,
|
||||
this.status = ReservationStatus.pending,
|
||||
required this.contacts,
|
||||
required this.phone,
|
||||
@@ -57,21 +60,26 @@ class ReservationModel {
|
||||
|
||||
/// 工厂构造函数,用于从JSON创建ReservationModel实例
|
||||
factory ReservationModel.fromJson(Map<String, dynamic> json) {
|
||||
//1完成 0待处理 2已拒绝
|
||||
// 1完成 2未加 -1拒绝 0是待加氢
|
||||
ReservationStatus currentStatus;
|
||||
int statusFromServer = json['addStatus'] as int? ?? 0;
|
||||
switch (statusFromServer) {
|
||||
case 0:
|
||||
currentStatus = ReservationStatus.pending;
|
||||
break;
|
||||
case 1:
|
||||
currentStatus = ReservationStatus.completed;
|
||||
break;
|
||||
case 2:
|
||||
currentStatus = ReservationStatus.rejected;
|
||||
break;
|
||||
default:
|
||||
currentStatus = ReservationStatus.unknown;
|
||||
int state = json['state'] as int? ?? 0;
|
||||
if (state == -1) {
|
||||
currentStatus = ReservationStatus.rejected;
|
||||
} else {
|
||||
switch (statusFromServer) {
|
||||
case 0:
|
||||
currentStatus = ReservationStatus.pending;
|
||||
break;
|
||||
case 1:
|
||||
currentStatus = ReservationStatus.completed;
|
||||
break;
|
||||
case 2:
|
||||
currentStatus = ReservationStatus.unadded;
|
||||
break;
|
||||
default:
|
||||
currentStatus = ReservationStatus.unknown;
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化时间显示
|
||||
@@ -105,6 +113,7 @@ class ReservationModel {
|
||||
addStatus: statusFromServer.toString(),
|
||||
addStatusName: json['addStatusName']?.toString() ?? '',
|
||||
stateName: json['stateName']?.toString() ?? '',
|
||||
hasEdit: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -189,7 +198,7 @@ class SiteController extends GetxController with BaseControllerMixin {
|
||||
// 【核心修改】处理接口返回的列表数据
|
||||
final dataMap = baseModel.data as Map<String, dynamic>;
|
||||
|
||||
final List<dynamic> listFromServer = dataMap['list'] ?? [];
|
||||
final List<dynamic> listFromServer = dataMap['records'] ?? [];
|
||||
|
||||
// 使用 .map() 遍历列表,将每个 item 转换为一个 ReservationModel 对象
|
||||
reservationList = listFromServer.map((item) {
|
||||
@@ -553,8 +562,8 @@ class SiteController extends GetxController with BaseControllerMixin {
|
||||
orderAmount = result.data["orderAmount"].toString();
|
||||
completedAmount = result.data["completedAmount"].toString();
|
||||
name = result.data["name"].toString();
|
||||
orderTotalAmount = result.data["orderTotalAmount"] ?? "";
|
||||
orderUnfinishedAmount = result.data["orderUnfinishedAmount"] ?? "";
|
||||
orderTotalAmount = result.data["orderTotalAmount"].toString() ?? "";
|
||||
orderUnfinishedAmount = result.data["orderUnfinishedAmount"].toString() ?? "";
|
||||
|
||||
leftHydrogen = leftHydrogen.isEmpty ? "统计中" : leftHydrogen.toString();
|
||||
orderTotalAmount = orderTotalAmount.isEmpty ? "统计中" : orderTotalAmount.toString();
|
||||
|
||||
@@ -433,15 +433,19 @@ class SitePage extends GetView<SiteController> {
|
||||
Color color;
|
||||
switch (status) {
|
||||
case ReservationStatus.pending:
|
||||
text = '待处理';
|
||||
text = '待加氢';
|
||||
color = Colors.orange;
|
||||
break;
|
||||
case ReservationStatus.completed:
|
||||
text = '已完成';
|
||||
text = '已加氢';
|
||||
color = Colors.greenAccent;
|
||||
break;
|
||||
case ReservationStatus.rejected:
|
||||
text = '已拒绝';
|
||||
text = '拒绝加氢';
|
||||
color = Colors.red;
|
||||
break;
|
||||
case ReservationStatus.unadded:
|
||||
text = '未加氢';
|
||||
color = Colors.red;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user