feat: 购油方案功能 #28

Merged
hera merged 13 commits from fix/next-batch-2 into main 2026-04-13 13:07:09 +00:00
Showing only changes of commit 1ca9bc1758 - Show all commits

View File

@@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { requestJSON, api } from '../composables/useApi'
import { api } from '../composables/useApi'
export const usePlansStore = defineStore('plans', () => {
const plans = ref([])
@@ -11,11 +11,13 @@ export const usePlansStore = defineStore('plans', () => {
const pendingPlans = computed(() => plans.value.filter(p => p.status === 'pending'))
async function loadPlans() {
plans.value = await requestJSON('/api/oil-plans')
const res = await api('/api/oil-plans')
if (res.ok) plans.value = await res.json()
}
async function loadTeachers() {
teachers.value = await requestJSON('/api/teachers')
const res = await api('/api/teachers')
if (res.ok) teachers.value = await res.json()
}
async function createPlan(healthDesc, teacherId) {
@@ -50,7 +52,8 @@ export const usePlansStore = defineStore('plans', () => {
}
async function loadShoppingList(planId) {
shoppingList.value = await requestJSON(`/api/oil-plans/${planId}/shopping-list`)
const res = await api(`/api/oil-plans/${planId}/shopping-list`)
if (res.ok) shoppingList.value = await res.json()
}
return {