今日预约搜索
This commit is contained in:
@@ -76,7 +76,8 @@ class ReservationModel {
|
|||||||
String startTimeStr = json['startTime']?.toString() ?? '';
|
String startTimeStr = json['startTime']?.toString() ?? '';
|
||||||
String endTimeStr = json['endTime']?.toString() ?? '';
|
String endTimeStr = json['endTime']?.toString() ?? '';
|
||||||
String dateStr = json['date']?.toString() ?? '';
|
String dateStr = json['date']?.toString() ?? '';
|
||||||
String timeRange = (startTimeStr.isNotEmpty && endTimeStr.isNotEmpty && dateStr.isNotEmpty)
|
String timeRange =
|
||||||
|
(startTimeStr.isNotEmpty && endTimeStr.isNotEmpty && dateStr.isNotEmpty)
|
||||||
? '$dateStr ${startTimeStr.substring(11, 16)}-${endTimeStr.substring(11, 16)}' // 截取 HH:mm
|
? '$dateStr ${startTimeStr.substring(11, 16)}-${endTimeStr.substring(11, 16)}' // 截取 HH:mm
|
||||||
: '时间未定';
|
: '时间未定';
|
||||||
|
|
||||||
@@ -119,6 +120,8 @@ class SiteController extends GetxController with BaseControllerMixin {
|
|||||||
List<ReservationModel> reservationList = [];
|
List<ReservationModel> reservationList = [];
|
||||||
Timer? _refreshTimer;
|
Timer? _refreshTimer;
|
||||||
|
|
||||||
|
final TextEditingController searchController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -130,6 +133,7 @@ class SiteController extends GetxController with BaseControllerMixin {
|
|||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
stopAutoRefresh();
|
stopAutoRefresh();
|
||||||
|
searchController.dispose();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,13 +159,17 @@ class SiteController extends GetxController with BaseControllerMixin {
|
|||||||
Future<void> fetchReservationData() async {
|
Future<void> fetchReservationData() async {
|
||||||
showLoading("加载中");
|
showLoading("加载中");
|
||||||
|
|
||||||
|
final String searchText = searchController.text.trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response = await HttpService.to.post(
|
var response = await HttpService.to.post(
|
||||||
"appointment/orderAddHyd/sitOrderPage",
|
"appointment/orderAddHyd/sitOrderPage",
|
||||||
data: {
|
data: {
|
||||||
'stationName': name, // 使用从 renderData 中获取到的 name
|
'stationName': name, // 使用从 renderData 中获取到的 name
|
||||||
'pageNum': 1,
|
'pageNum': 1,
|
||||||
'pageSize': 30, // 暂时不考虑分页,一次获取30条
|
'pageSize': 50, // 暂时不考虑分页,一次获取30条
|
||||||
|
'plateNumber': searchText, // 加氢站名称
|
||||||
|
'phone': searchText, //手机号
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -293,7 +301,9 @@ class SiteController extends GetxController with BaseControllerMixin {
|
|||||||
|
|
||||||
leftHydrogen = leftHydrogen.isEmpty ? "统计中" : leftHydrogen.toString();
|
leftHydrogen = leftHydrogen.isEmpty ? "统计中" : leftHydrogen.toString();
|
||||||
orderTotalAmount = orderTotalAmount.isEmpty ? "统计中" : orderTotalAmount.toString();
|
orderTotalAmount = orderTotalAmount.isEmpty ? "统计中" : orderTotalAmount.toString();
|
||||||
orderUnfinishedAmount = orderUnfinishedAmount.isEmpty ? "统计中" : orderUnfinishedAmount.toString();
|
orderUnfinishedAmount = orderUnfinishedAmount.isEmpty
|
||||||
|
? "统计中"
|
||||||
|
: orderUnfinishedAmount.toString();
|
||||||
|
|
||||||
//加载列表数据
|
//加载列表数据
|
||||||
fetchReservationData();
|
fetchReservationData();
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ class SitePage extends GetView<SiteController> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
_buildSearchView(),
|
||||||
controller.hasReservationData
|
controller.hasReservationData
|
||||||
? _buildReservationListView()
|
? _buildReservationListView()
|
||||||
: _buildEmptyReservationView(),
|
: _buildEmptyReservationView(),
|
||||||
@@ -190,6 +191,66 @@ class SitePage extends GetView<SiteController> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//搜索输入框,提示可以输入车牌或者手机
|
||||||
|
Widget _buildSearchView() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 44,
|
||||||
|
child: TextField(
|
||||||
|
controller: controller.searchController, // 绑定控制器
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: '输入车牌号或完整手机号查询',
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(22),
|
||||||
|
borderSide: BorderSide(color: Colors.grey.shade300),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(22),
|
||||||
|
borderSide: BorderSide(color: Colors.grey.shade300),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(22),
|
||||||
|
borderSide: BorderSide(color: Get.theme.primaryColor, width: 1.5),
|
||||||
|
),
|
||||||
|
// 清除按钮
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: const Icon(Icons.clear, size: 20),
|
||||||
|
onPressed: () {
|
||||||
|
controller.searchController.clear();
|
||||||
|
controller.fetchReservationData(); // 清除后也刷新一次
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSubmitted: (value) {
|
||||||
|
// 用户在键盘上点击“完成”或“搜索”时触发
|
||||||
|
controller.fetchReservationData();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
// 点击“搜索”按钮时触发
|
||||||
|
FocusScope.of(Get.context!).unfocus(); // 收起键盘
|
||||||
|
controller.fetchReservationData();
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.search_rounded),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// 构建单个统计项
|
/// 构建单个统计项
|
||||||
Widget _buildStatItem(String value, String label, {Color valueColor = Colors.blue}) {
|
Widget _buildStatItem(String value, String label, {Color valueColor = Colors.blue}) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
|
|||||||
Reference in New Issue
Block a user