站点增加广播
This commit is contained in:
@@ -28,6 +28,11 @@ class ReservationController extends GetxController with BaseControllerMixin {
|
||||
? DateFormat('yyyy-MM-dd HH:mm').format(customEndTime!)
|
||||
: '点击选择结束时间';
|
||||
|
||||
// --- 站点广播相关 ---
|
||||
final TextEditingController broadcastTitleController = TextEditingController();
|
||||
final TextEditingController broadcastContentController = TextEditingController();
|
||||
final RxInt selectedTabIndex = 0.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -120,8 +125,6 @@ class ReservationController extends GetxController with BaseControllerMixin {
|
||||
DateTime now = DateTime.now();
|
||||
DateTime initialDate = isStart ? (customStartTime ?? now) : (customEndTime ?? now);
|
||||
|
||||
// 确保初始时间不早于最小允许时间
|
||||
// 将 minimumDate 稍微提前一点点(比如1分钟)
|
||||
DateTime minLimit = isStart
|
||||
? now.subtract(const Duration(minutes: 1))
|
||||
: (customStartTime ?? now).subtract(const Duration(minutes: 1));
|
||||
@@ -157,7 +160,6 @@ class ReservationController extends GetxController with BaseControllerMixin {
|
||||
onPressed: () {
|
||||
if (isStart) {
|
||||
customStartTime = tempDate;
|
||||
// 如果开始时间变动后,结束时间早于开始时间,自动顺延一天
|
||||
if (customEndTime != null &&
|
||||
customEndTime!.isBefore(customStartTime!)) {
|
||||
customEndTime = customStartTime!.add(const Duration(days: 1));
|
||||
@@ -250,8 +252,54 @@ class ReservationController extends GetxController with BaseControllerMixin {
|
||||
}
|
||||
}
|
||||
|
||||
/// 发送站点广播
|
||||
void sendBroadcast() async {
|
||||
String title = broadcastTitleController.text.trim();
|
||||
String content = broadcastContentController.text.trim();
|
||||
|
||||
if (title.isEmpty) {
|
||||
showToast("请输入通知标题");
|
||||
return;
|
||||
}
|
||||
if (content.isEmpty) {
|
||||
showToast("请输入通知内容");
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading("发送中...");
|
||||
try {
|
||||
var responseData = await HttpService.to.post(
|
||||
'appointment/notice/push/station/broadcast',
|
||||
data: {
|
||||
'title': title,
|
||||
'content': content,
|
||||
},
|
||||
);
|
||||
|
||||
dismissLoading();
|
||||
if (responseData != null) {
|
||||
var result = BaseModel.fromJson(responseData.data);
|
||||
if (result.code == 0) {
|
||||
showSuccessToast("广播发送成功");
|
||||
} else {
|
||||
showErrorToast(result.error);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
dismissLoading();
|
||||
showToast("发送失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
void logout() async {
|
||||
await StorageService.to.clearLoginInfo();
|
||||
Get.offAll(() => LoginPage());
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
broadcastTitleController.dispose();
|
||||
broadcastContentController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user