预约列表增加筛选条件
This commit is contained in:
@@ -434,7 +434,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
||||
|
||||
//打开预约列表
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
getReservationList();
|
||||
getReservationList(showPopup: true, addStatus: '');
|
||||
});
|
||||
} else {
|
||||
showToast(result.error);
|
||||
@@ -446,16 +446,16 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
||||
}
|
||||
|
||||
/// 状态变量:是否有预约数据
|
||||
bool hasReservationData = false;
|
||||
|
||||
final RxBool hasReservationData = false.obs;
|
||||
// 新增预约数据列表
|
||||
List<ReservationModel> reservationList = [];
|
||||
|
||||
final RxList<ReservationModel> reservationList = <ReservationModel>[].obs;
|
||||
final RxBool shouldShowReservationList = false.obs;
|
||||
// --- 用于防抖的 Timer ---
|
||||
Timer? _debounce;
|
||||
|
||||
//查看预约列表
|
||||
void getReservationList() async {
|
||||
void getReservationList({bool showPopup = false, String? addStatus}) async {
|
||||
// 增加 addStatus 参数
|
||||
if (_debounce?.isActive ?? false) {
|
||||
return;
|
||||
}
|
||||
@@ -464,19 +464,26 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
||||
showLoading("加载中");
|
||||
|
||||
try {
|
||||
|
||||
final Map<String, dynamic> requestData = {
|
||||
'phone': StorageService.to.phone,
|
||||
'pageNum': 1,
|
||||
'pageSize': 50,
|
||||
};
|
||||
// 将 addStatus 参数添加到请求中
|
||||
if (addStatus != null && addStatus.isNotEmpty) {
|
||||
requestData['addStatus'] = addStatus;
|
||||
}
|
||||
|
||||
var response = await HttpService.to.post(
|
||||
"appointment/orderAddHyd/driverOrderPage",
|
||||
data: {
|
||||
'phone': StorageService.to.phone, // 使用从 renderData 中获取到的 name
|
||||
'pageNum': 1,
|
||||
'pageSize': 50, // 暂时不考虑分页,一次获取30条
|
||||
},
|
||||
data: requestData,
|
||||
);
|
||||
|
||||
if (response == null || response.data == null) {
|
||||
showToast('暂时无法获取预约数据');
|
||||
hasReservationData = false;
|
||||
reservationList = [];
|
||||
hasReservationData.value = false;
|
||||
reservationList.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -485,13 +492,13 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
||||
if (baseModel.code == 0 && baseModel.data != null) {
|
||||
final dataMap = baseModel.data as Map<String, dynamic>;
|
||||
final List<dynamic> listFromServer = dataMap['records'] ?? [];
|
||||
reservationList = listFromServer.map((item) {
|
||||
|
||||
// 使用 .value 来更新响应式列表
|
||||
reservationList.value = listFromServer.map((item) {
|
||||
return ReservationModel.fromJson(item as Map<String, dynamic>);
|
||||
}).toList();
|
||||
|
||||
// 根据列表是否为空来更新 hasReservationData 状态
|
||||
hasReservationData = reservationList.isNotEmpty;
|
||||
|
||||
// 更新 hasEdit 状态
|
||||
for (var reservation in reservationList) {
|
||||
try {
|
||||
// 获取当前时间和预约的结束时间
|
||||
@@ -510,206 +517,27 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
||||
reservation.hasEdit = false;
|
||||
}
|
||||
}
|
||||
|
||||
hasReservationData.value = reservationList.isNotEmpty;
|
||||
|
||||
if (showPopup) {
|
||||
shouldShowReservationList.value = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
showToast(baseModel.message);
|
||||
hasReservationData = false;
|
||||
reservationList = []; // 清空列表
|
||||
hasReservationData.value = false;
|
||||
reservationList.clear();
|
||||
}
|
||||
} catch (e) {
|
||||
showToast('获取预约数据失败');
|
||||
hasReservationData = false;
|
||||
reservationList = []; // 清空列表
|
||||
hasReservationData.value = false;
|
||||
reservationList.clear();
|
||||
} finally {
|
||||
dismissLoading();
|
||||
}
|
||||
|
||||
Get.bottomSheet(
|
||||
Container(
|
||||
height: Get.height * 0.55,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
//标题
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'我的预约',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => Get.back(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.grey[200],
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
),
|
||||
child: const Text('关闭', style: TextStyle(color: Colors.black54)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: !hasReservationData
|
||||
? Container(
|
||||
margin: EdgeInsets.only(top: 40),
|
||||
child: TextX.bodyLarge('暂无预约', weight: FontWeight.w500),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: reservationList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final ReservationModel reservation = reservationList[index];
|
||||
return Card(
|
||||
color: Colors.white,
|
||||
margin: const EdgeInsets.only(bottom: 12.0),
|
||||
elevation: 1,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(
|
||||
0xFFE6F7FF,
|
||||
), // Light blue background
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF91D5FF),
|
||||
), // Blue border
|
||||
),
|
||||
child: Text(
|
||||
reservation.stateName +
|
||||
"-" +
|
||||
reservation.addStatusName,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF1890FF),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
!reservation.hasEdit
|
||||
? SizedBox()
|
||||
: GestureDetector(
|
||||
onTap: () async {
|
||||
var result = await Get.to(
|
||||
() => ReservationEditPage(),
|
||||
arguments: {
|
||||
'reservation': reservation,
|
||||
'difference': difference,
|
||||
},
|
||||
binding: BindingsBuilder(() {
|
||||
Get.put(ReservationEditController());
|
||||
}),
|
||||
preventDuplicates: false,
|
||||
);
|
||||
if (result == true) {
|
||||
Get.back();
|
||||
getReservationList();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(
|
||||
0xFFFFF7E6,
|
||||
), // Light orange background
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
"修改",
|
||||
style: const TextStyle(
|
||||
color: Color(0xFFFA8C16),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildDetailRow('车牌号:', reservation.plateNumber),
|
||||
_buildDetailRow('预约日期:', reservation.date),
|
||||
_buildDetailRow('预约氢量:', reservation.hydAmount),
|
||||
_buildDetailRow('加氢站:', reservation.stationName),
|
||||
_buildDetailRow('开始时间:', reservation.startTime),
|
||||
_buildDetailRow('结束时间:', reservation.endTime),
|
||||
_buildDetailRow('联系人:', reservation.contacts),
|
||||
_buildDetailRow('联系电话:', reservation.phone),
|
||||
reservation.addStatus == "5"
|
||||
? _buildDetailRow('拒绝原因:', reservation.rejectReason)
|
||||
: SizedBox(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
isScrollControlled: true,
|
||||
backgroundColor:
|
||||
Colors.transparent, // Make background transparent to see the rounded corners
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 85,
|
||||
child: Text(label, style: TextStyle(color: Colors.grey[600], fontSize: 14)),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String workEfficiency = "0";
|
||||
String fillingWeight = "0";
|
||||
|
||||
Reference in New Issue
Block a user