| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- class VehicleModel {
- final String id;
- final String applicationNo;
- final String applicantId;
- final String applicantName;
- final String deptId;
- final String deptName;
- final String vehicleId;
- final String licensePlate;
- final String purpose;
- final String reason;
- final String origin;
- final double? originLongitude;
- final double? originLatitude;
- final String destination;
- final double? destLongitude;
- final double? destLatitude;
- final int passengerCount;
- final DateTime startTime;
- final DateTime endTime;
- final DateTime? actualReturnTime;
- final double startOdometer;
- final double endOdometer;
- final double actualCost;
- final String costRemark;
- final String status;
- final String approvalInstanceId;
- final DateTime createTime;
- final DateTime updateTime;
- const VehicleModel({
- required this.id,
- required this.applicationNo,
- required this.applicantId,
- required this.applicantName,
- required this.deptId,
- required this.deptName,
- this.vehicleId = '',
- this.licensePlate = '',
- required this.purpose,
- required this.reason,
- required this.origin,
- this.originLongitude,
- this.originLatitude,
- required this.destination,
- this.destLongitude,
- this.destLatitude,
- this.passengerCount = 1,
- required this.startTime,
- required this.endTime,
- this.actualReturnTime,
- this.startOdometer = 0.0,
- this.endOdometer = 0.0,
- this.actualCost = 0.0,
- this.costRemark = '',
- this.status = 'draft',
- this.approvalInstanceId = '',
- required this.createTime,
- required this.updateTime,
- });
- factory VehicleModel.fromJson(Map<String, dynamic> json) {
- return VehicleModel(
- id: json['id'] as String,
- applicationNo: json['applicationNo'] as String? ?? '',
- applicantId: json['applicantId'] as String? ?? '',
- applicantName: json['applicantName'] as String? ?? '',
- deptId: json['deptId'] as String? ?? '',
- deptName: json['deptName'] as String? ?? '',
- vehicleId: json['vehicleId'] as String? ?? '',
- licensePlate: json['licensePlate'] as String? ?? '',
- purpose: json['purpose'] as String? ?? '',
- reason: json['reason'] as String? ?? '',
- origin: json['origin'] as String? ?? '',
- originLongitude: (json['originLongitude'] as num?)?.toDouble(),
- originLatitude: (json['originLatitude'] as num?)?.toDouble(),
- destination: json['destination'] as String? ?? '',
- destLongitude: (json['destLongitude'] as num?)?.toDouble(),
- destLatitude: (json['destLatitude'] as num?)?.toDouble(),
- passengerCount: json['passengerCount'] as int? ?? 1,
- startTime: DateTime.parse(json['startTime'] as String),
- endTime: DateTime.parse(json['endTime'] as String),
- actualReturnTime: json['actualReturnTime'] != null
- ? DateTime.parse(json['actualReturnTime'] as String)
- : null,
- startOdometer: (json['startOdometer'] as num?)?.toDouble() ?? 0.0,
- endOdometer: (json['endOdometer'] as num?)?.toDouble() ?? 0.0,
- actualCost: (json['actualCost'] as num?)?.toDouble() ?? 0.0,
- costRemark: json['costRemark'] as String? ?? '',
- status: json['status'] as String? ?? 'draft',
- approvalInstanceId: json['approvalInstanceId'] as String? ?? '',
- createTime: DateTime.parse(json['createTime'] as String),
- updateTime: DateTime.parse(json['updateTime'] as String),
- );
- }
- Map<String, dynamic> toJson() => {
- 'id': id,
- 'applicationNo': applicationNo,
- 'applicantId': applicantId,
- 'applicantName': applicantName,
- 'deptId': deptId,
- 'deptName': deptName,
- 'vehicleId': vehicleId,
- 'licensePlate': licensePlate,
- 'purpose': purpose,
- 'reason': reason,
- 'origin': origin,
- 'originLongitude': originLongitude,
- 'originLatitude': originLatitude,
- 'destination': destination,
- 'destLongitude': destLongitude,
- 'destLatitude': destLatitude,
- 'passengerCount': passengerCount,
- 'startTime': startTime.toIso8601String(),
- 'endTime': endTime.toIso8601String(),
- 'actualReturnTime': actualReturnTime?.toIso8601String(),
- 'startOdometer': startOdometer,
- 'endOdometer': endOdometer,
- 'actualCost': actualCost,
- 'costRemark': costRemark,
- 'status': status,
- 'approvalInstanceId': approvalInstanceId,
- 'createTime': createTime.toIso8601String(),
- 'updateTime': updateTime.toIso8601String(),
- };
- VehicleModel copyWith({
- String? id,
- String? applicationNo,
- String? applicantId,
- String? applicantName,
- String? deptId,
- String? deptName,
- String? vehicleId,
- String? licensePlate,
- String? purpose,
- String? reason,
- String? origin,
- double? originLongitude,
- double? originLatitude,
- String? destination,
- double? destLongitude,
- double? destLatitude,
- int? passengerCount,
- DateTime? startTime,
- DateTime? endTime,
- DateTime? actualReturnTime,
- double? startOdometer,
- double? endOdometer,
- double? actualCost,
- String? costRemark,
- String? status,
- String? approvalInstanceId,
- DateTime? createTime,
- DateTime? updateTime,
- }) {
- return VehicleModel(
- id: id ?? this.id,
- applicationNo: applicationNo ?? this.applicationNo,
- applicantId: applicantId ?? this.applicantId,
- applicantName: applicantName ?? this.applicantName,
- deptId: deptId ?? this.deptId,
- deptName: deptName ?? this.deptName,
- vehicleId: vehicleId ?? this.vehicleId,
- licensePlate: licensePlate ?? this.licensePlate,
- purpose: purpose ?? this.purpose,
- reason: reason ?? this.reason,
- origin: origin ?? this.origin,
- originLongitude: originLongitude ?? this.originLongitude,
- originLatitude: originLatitude ?? this.originLatitude,
- destination: destination ?? this.destination,
- destLongitude: destLongitude ?? this.destLongitude,
- destLatitude: destLatitude ?? this.destLatitude,
- passengerCount: passengerCount ?? this.passengerCount,
- startTime: startTime ?? this.startTime,
- endTime: endTime ?? this.endTime,
- actualReturnTime: actualReturnTime ?? this.actualReturnTime,
- startOdometer: startOdometer ?? this.startOdometer,
- endOdometer: endOdometer ?? this.endOdometer,
- actualCost: actualCost ?? this.actualCost,
- costRemark: costRemark ?? this.costRemark,
- status: status ?? this.status,
- approvalInstanceId: approvalInstanceId ?? this.approvalInstanceId,
- createTime: createTime ?? this.createTime,
- updateTime: updateTime ?? this.updateTime,
- );
- }
- }
|