Initial commit - Zhangmenu Django project
A menu management application built with Django, featuring: - Dish management with cover images - Order system with party dates and participants - REST API with Django REST Framework - Bootstrap-styled frontend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
// 状态管理
|
||||
const state = {
|
||||
currentPage: 'menu',
|
||||
categories: [],
|
||||
dishes: [],
|
||||
orders: [],
|
||||
currentCategory: '',
|
||||
currentOrderFilter: '',
|
||||
dishCompletedCounts: {},
|
||||
|
||||
// 设置状态
|
||||
setPage(page) {
|
||||
this.currentPage = page;
|
||||
},
|
||||
|
||||
setCategories(categories) {
|
||||
this.categories = categories;
|
||||
},
|
||||
|
||||
setDishes(dishes) {
|
||||
this.dishes = dishes;
|
||||
},
|
||||
|
||||
setOrders(orders) {
|
||||
this.orders = orders;
|
||||
},
|
||||
|
||||
setCurrentCategory(category) {
|
||||
this.currentCategory = category;
|
||||
},
|
||||
|
||||
setCurrentOrderFilter(filter) {
|
||||
this.currentOrderFilter = filter;
|
||||
},
|
||||
|
||||
setDishCompletedCounts(counts) {
|
||||
this.dishCompletedCounts = counts;
|
||||
},
|
||||
|
||||
// 获取过滤后的数据
|
||||
getFilteredDishes() {
|
||||
let filtered = this.dishes;
|
||||
if (this.currentCategory) {
|
||||
filtered = filtered.filter(d => d.category_name === this.currentCategory);
|
||||
}
|
||||
return filtered;
|
||||
},
|
||||
|
||||
getFilteredOrders() {
|
||||
let filtered = this.orders;
|
||||
if (this.currentOrderFilter) {
|
||||
filtered = filtered.filter(o => o.status === this.currentOrderFilter);
|
||||
}
|
||||
return filtered;
|
||||
},
|
||||
|
||||
// 获取菜品在当前订单中的状态
|
||||
isDishInCurrentOrder(dishId) {
|
||||
const currentOrder = this.orders.find(o => o.status === 'in_progress');
|
||||
if (!currentOrder) return false;
|
||||
return currentOrder.dishes && currentOrder.dishes.includes(dishId);
|
||||
},
|
||||
|
||||
// 获取当前进行中的订单
|
||||
getCurrentOrder() {
|
||||
return this.orders.find(o => o.status === 'in_progress');
|
||||
},
|
||||
|
||||
// 重置状态
|
||||
reset() {
|
||||
this.currentPage = 'menu';
|
||||
this.currentCategory = '';
|
||||
this.currentOrderFilter = '';
|
||||
}
|
||||
};
|
||||
|
||||
// 导出供全局使用
|
||||
window.AppState = state;
|
||||
Reference in New Issue
Block a user