增加 加氢站可用标记
This commit is contained in:
@@ -4,6 +4,7 @@ class StationModel {
|
||||
final String address;
|
||||
final String price;
|
||||
final String siteStatusName; // 例如 "维修中"
|
||||
final int isSelect; // 新增字段 1是可用 0是不可用
|
||||
|
||||
StationModel({
|
||||
required this.hydrogenId,
|
||||
@@ -11,6 +12,7 @@ class StationModel {
|
||||
required this.address,
|
||||
required this.price,
|
||||
required this.siteStatusName,
|
||||
required this.isSelect,
|
||||
});
|
||||
|
||||
// 从 JSON map 创建对象的工厂构造函数
|
||||
@@ -21,6 +23,7 @@ class StationModel {
|
||||
address: json['address'] ?? '地址未知',
|
||||
price: json['price']?.toString() ?? '0.00',
|
||||
siteStatusName: json['siteStatusName'] ?? '',
|
||||
isSelect: json['isSelect'] as int? ?? 0, // 新增字段的解析,默认为 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
||||
), // Blue border
|
||||
),
|
||||
child: Text(
|
||||
reservation.stateName,
|
||||
reservation.stateName+"-"+reservation.addStatusName,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF1890FF),
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -552,11 +552,11 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
reservation.addStatusName,
|
||||
"修改",
|
||||
style: const TextStyle(
|
||||
color: Color(0xFFFA8C16),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -432,6 +432,7 @@ class ReservationPage extends GetView<C_ReservationController> {
|
||||
.map(
|
||||
(station) => DropdownMenuItem<String>(
|
||||
value: station.hydrogenId, // value 是站点的唯一ID
|
||||
enabled: station.isSelect == 1,
|
||||
child: _buildDropdownItem(station), // child 是自定义的 Widget
|
||||
),
|
||||
)
|
||||
@@ -478,7 +479,10 @@ class ReservationPage extends GetView<C_ReservationController> {
|
||||
|
||||
/// 构建下拉菜单中的每一项
|
||||
Widget _buildDropdownItem(StationModel station) {
|
||||
bool isMaintenance = (station.siteStatusName != '营运中');
|
||||
bool isSelectable = (station.isSelect == 1);
|
||||
//营运并且可用
|
||||
bool isMaintenance = ((station.siteStatusName != '营运中') && isSelectable);
|
||||
final textColor = isSelectable ? Colors.black : Colors.grey;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
@@ -495,14 +499,22 @@ class ReservationPage extends GetView<C_ReservationController> {
|
||||
Flexible(
|
||||
child: Text(
|
||||
station.name,
|
||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
' | ¥${station.price}/kg',
|
||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
if (isMaintenance) const SizedBox(width: 8),
|
||||
if (isMaintenance)
|
||||
|
||||
Reference in New Issue
Block a user