revert: 删除购油方案功能,修复MyDiary模板错误
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 14s
Test / e2e-test (push) Successful in 53s
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 14s
Test / e2e-test (push) Successful in 53s
完全移除oil_plans相关代码: - 后端: 7个API端点、2个数据库表 - 前端: plans store、Inventory方案UI、UserManagement方案编辑器 - UserMenu: 方案通知按钮 - 修复MyDiary.vue多余的section-card div导致的构建失败 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import { api } from '../composables/useApi'
|
||||
|
||||
export const usePlansStore = defineStore('plans', () => {
|
||||
const plans = ref([])
|
||||
const teachers = ref([])
|
||||
const shoppingList = ref([])
|
||||
|
||||
const activePlan = computed(() => plans.value.find(p => p.status === 'active'))
|
||||
const pendingPlans = computed(() => plans.value.filter(p => p.status === 'pending'))
|
||||
|
||||
async function loadPlans() {
|
||||
const res = await api('/api/oil-plans')
|
||||
if (res.ok) plans.value = await res.json()
|
||||
}
|
||||
|
||||
async function loadTeachers() {
|
||||
const res = await api('/api/teachers')
|
||||
if (res.ok) teachers.value = await res.json()
|
||||
}
|
||||
|
||||
async function createPlan(healthDesc, teacherId) {
|
||||
const res = await api('/api/oil-plans', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ health_desc: healthDesc, teacher_id: teacherId }),
|
||||
})
|
||||
if (!res.ok) throw new Error('创建失败')
|
||||
await loadPlans()
|
||||
return res.json()
|
||||
}
|
||||
|
||||
async function updatePlan(planId, data) {
|
||||
await api(`/api/oil-plans/${planId}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
await loadPlans()
|
||||
}
|
||||
|
||||
async function addRecipe(planId, recipeName, ingredients, timesPerMonth) {
|
||||
await api(`/api/oil-plans/${planId}/recipes`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ recipe_name: recipeName, ingredients, times_per_month: timesPerMonth }),
|
||||
})
|
||||
await loadPlans()
|
||||
}
|
||||
|
||||
async function removeRecipe(planId, recipeId) {
|
||||
await api(`/api/oil-plans/${planId}/recipes/${recipeId}`, { method: 'DELETE' })
|
||||
await loadPlans()
|
||||
}
|
||||
|
||||
async function loadShoppingList(planId) {
|
||||
const res = await api(`/api/oil-plans/${planId}/shopping-list`)
|
||||
if (res.ok) shoppingList.value = await res.json()
|
||||
}
|
||||
|
||||
return {
|
||||
plans, teachers, shoppingList,
|
||||
activePlan, pendingPlans,
|
||||
loadPlans, loadTeachers, createPlan, updatePlan,
|
||||
addRecipe, removeRecipe, loadShoppingList,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user