feat: 购油方案功能 #28
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user