diff --git a/frontend/src/components/input_recipe.vue b/frontend/src/components/input_recipe.vue index fffede5..e04fb25 100644 --- a/frontend/src/components/input_recipe.vue +++ b/frontend/src/components/input_recipe.vue @@ -54,7 +54,9 @@ - 提交 + 提交 @@ -77,10 +79,11 @@ export default { rules: { name: [{ required: true, trigger: 'blur', message: '输入菜名' }], }, + recipe_id: null, }; }, methods: { - onSubmit() { + onSubmit(recipe_id) { let data = { name: this.form.name, recipe_type: this.form.recipe_type, @@ -88,14 +91,25 @@ export default { rate: this.form.rate, note: this.form.note, }; - axios - .post('//localhost:8000/recipe/recipe/', data) - .then(function() { - location.reload(); - }) - .catch(function(error) { - console.log(error); - }); + if (!recipe_id) { + axios + .post('//localhost:8000/recipe/recipe/', data) + .then(function() { + location.reload(); + }) + .catch(function(error) { + console.log(error); + }); + } else { + axios + .put('//localhost:8000/recipe/recipe/' + recipe_id, data) + .then(function() { + location.reload(); + }) + .catch(function(error) { + console.log(error); + }); + } }, }, }; diff --git a/frontend/src/views/home.vue b/frontend/src/views/home.vue index bf65da2..9fcc374 100644 --- a/frontend/src/views/home.vue +++ b/frontend/src/views/home.vue @@ -48,6 +48,7 @@ import axios from 'axios'; import input_recipe from '@/components/input_recipe.vue'; import router from '@/router/index'; +import 'element-plus/dist/index.css'; // const api_root = 'localhost:8000' const type_map = { vegetable: '青菜', @@ -115,7 +116,6 @@ export default { }, }; - diff --git a/frontend/src/views/recipeDetail.vue b/frontend/src/views/recipeDetail.vue index 124c932..d24f2f6 100644 --- a/frontend/src/views/recipeDetail.vue +++ b/frontend/src/views/recipeDetail.vue @@ -1,8 +1,55 @@ - recipe detail + + + + + + + {{ recipe.name }} + + + + 类型:{{ recipe.recipe_type }} + 难度:{{ recipe.difficulty }} + 评分:{{ recipe.rate }} + + 备注:{{ recipe.note }} + + + + + + + +