成功预约
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:cashier_reserve/common/base/ui_model.dart';
|
||||
import 'package:cashier_reserve/common/channel/call_log_model.dart';
|
||||
import 'package:cashier_reserve/common/channel/channel_manager.dart';
|
||||
import 'package:cashier_reserve/common/manager/event_manager.dart';
|
||||
import 'package:cashier_reserve/common/utils/utils.dart';
|
||||
import 'package:cashier_reserve/data_model/reserve/table_area_model.dart';
|
||||
import 'package:cashier_reserve/data_model/reserve/table_model.dart';
|
||||
import 'package:cashier_reserve/model/reserve_model.dart';
|
||||
@@ -25,6 +26,10 @@ class ReserveViewModel extends BaseUIModel {
|
||||
};
|
||||
|
||||
PageController pageController = PageController();
|
||||
AnimationController? _animationController;
|
||||
Animation<double>? _animationSizeFactor;
|
||||
|
||||
Animation<double>? get animationSizeFactor => _animationSizeFactor;
|
||||
|
||||
DateTime now = DateTime.now();
|
||||
|
||||
@@ -34,6 +39,7 @@ class ReserveViewModel extends BaseUIModel {
|
||||
|
||||
List<TableAreaModel?>? _tableAreaList;
|
||||
List<TableAreaModel?>? get tableAreaList => _tableAreaList;
|
||||
Map<num, TableAreaModel?> _tableAreaMap = {};
|
||||
|
||||
List<TableModel?>? _tableList;
|
||||
List<TableModel?>? get tableList => _tableList;
|
||||
@@ -41,6 +47,8 @@ class ReserveViewModel extends BaseUIModel {
|
||||
|
||||
List<CallLogModel?>? callLogs = [];
|
||||
|
||||
bool _isShowReserveInfoView = false;
|
||||
|
||||
/// bookingGender 预订人性别 1: 男 2: 女
|
||||
int bookingGender = 1;
|
||||
/// bookingNumController 就餐人数
|
||||
@@ -66,6 +74,8 @@ class ReserveViewModel extends BaseUIModel {
|
||||
/// bookingStandardType 餐标类型
|
||||
String bookingStandardType = "table";
|
||||
|
||||
String showTableName = "";
|
||||
|
||||
TableModel? selectedTable;
|
||||
|
||||
ReserveViewModel() {
|
||||
@@ -99,6 +109,12 @@ class ReserveViewModel extends BaseUIModel {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
reloadPageData() {
|
||||
loadCallLog();
|
||||
loadTableAreaList();
|
||||
loadAreaTableList(0);
|
||||
}
|
||||
|
||||
void loadCallLog() {
|
||||
ChannelManager.getCallLog("getCallLog");
|
||||
}
|
||||
@@ -110,6 +126,11 @@ class ReserveViewModel extends BaseUIModel {
|
||||
|
||||
_tableAreaList ??= [];
|
||||
|
||||
_tableAreaMap = {};
|
||||
for (var item in _tableAreaList!) {
|
||||
_tableAreaMap[item!.id!] = item;
|
||||
}
|
||||
|
||||
_tableAreaList!.insert(0, TableAreaModel(id: 0, name: "全部"));
|
||||
|
||||
notifyListeners();
|
||||
@@ -135,6 +156,36 @@ class ReserveViewModel extends BaseUIModel {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void commitReserveInfo() async {
|
||||
if (!_checkReserveInfo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
"shopTableId": selectedTable!.id,
|
||||
"bookingDate": selectedDate,
|
||||
"bookingType": bookingType,
|
||||
"dinerNum": bookingNumController.text,
|
||||
"phoneNumber": bookingPhoneController.text,
|
||||
"bookingPerson": bookingNameController.text,
|
||||
"gender": bookingGender,
|
||||
"bookingTime": '$selectedDate $bookingSelectedTime:00',
|
||||
"diningType": bookingTypeController.text,
|
||||
"focus": bookingFocus ? 1 : 0,
|
||||
"receiveMarketingSms": bookingSms ? 1 : 0,
|
||||
"bookingTableNum": bookingTableNumController.text,
|
||||
"diningStandardPrice": bookingStandardController.text,
|
||||
"diningStandardUnit": bookingStandardType,
|
||||
"remark": bookingRemarkController.text,
|
||||
};
|
||||
|
||||
await ReserveModel.commitReserveInfo(params);
|
||||
|
||||
Utils.toast("预定成功", context);
|
||||
hideReserveInfoView();
|
||||
loadAreaTableList(0);
|
||||
}
|
||||
|
||||
void setSelectedDateIndex(int index) {
|
||||
selectedDateIndex = index;
|
||||
|
||||
@@ -147,6 +198,30 @@ class ReserveViewModel extends BaseUIModel {
|
||||
loadAreaTableList(0);
|
||||
}
|
||||
|
||||
void setAnimationController(AnimationController controller, Animation<double> sizeFactor) {
|
||||
_animationController = controller;
|
||||
_animationSizeFactor = sizeFactor;
|
||||
}
|
||||
|
||||
showReserveInfoView() {
|
||||
_resetReserveData();
|
||||
_isShowReserveInfoView = true;
|
||||
_animationController?.forward();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
hideReserveInfoView() {
|
||||
_isShowReserveInfoView = false;
|
||||
_animationController?.reverse();
|
||||
}
|
||||
|
||||
execCallLog(CallLogModel? callLog) {
|
||||
showReserveInfoView();
|
||||
bookingPhoneController.text = callLog?.number ?? "";
|
||||
bookingNameController.text = callLog?.name ?? "";
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updateBookingTime(int hour, int minute) {
|
||||
bookingSelectedTime = "${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}";
|
||||
notifyListeners();
|
||||
@@ -174,6 +249,70 @@ class ReserveViewModel extends BaseUIModel {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
clickTable(TableModel table) {
|
||||
if (_isShowReserveInfoView) {
|
||||
if (table.bookingInfo != null) {
|
||||
Utils.toast("当前台桌已预定", context);
|
||||
return;
|
||||
}
|
||||
selectedTable = table;
|
||||
TableAreaModel? area = _tableAreaMap[table.areaId!];
|
||||
showTableName = "${area?.name ?? ""} - ${table.name}";
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
_resetReserveData() {
|
||||
bookingGender = 1;
|
||||
bookingNumController.text = "";
|
||||
bookingPhoneController.text = "";
|
||||
bookingNameController.text = "";
|
||||
bookingTypeController.text = "";
|
||||
bookingTableNumController.text = "";
|
||||
bookingStandardController.text = "";
|
||||
bookingRemarkController.text = "";
|
||||
bookingSelectedTime = "";
|
||||
bookingFocus = false;
|
||||
bookingSms = false;
|
||||
bookingStandardType = "table";
|
||||
selectedTable = null;
|
||||
showTableName = "";
|
||||
}
|
||||
|
||||
bool _checkReserveInfo() {
|
||||
if (selectedTable == null) {
|
||||
Utils.toast("请选择台桌", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingNumController.text.isEmpty) {
|
||||
Utils.toast("请输入就餐人数", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingPhoneController.text.isEmpty) {
|
||||
Utils.toast("请输入联系电话", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingNameController.text.isEmpty) {
|
||||
Utils.toast("请输入预订人姓名", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingSelectedTime.isEmpty) {
|
||||
Utils.toast("请选择预订时间", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingTypeController.text.isEmpty) {
|
||||
Utils.toast("请输入预订类型", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
String getCurrentDate() {
|
||||
return "${now.year}/${now.month}/${now.day}";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user