From 83a3bd193bc71efba4beaebf55015eed917ceaaa Mon Sep 17 00:00:00 2001 From: Ching Date: Sat, 5 Feb 2022 01:41:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(recipe=20detail=20page):=20=E8=8F=9C?= =?UTF-8?q?=E8=B0=B1=E7=BC=96=E8=BE=91=E9=A1=B5=E5=A2=9E=E5=8A=A0=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 菜谱编辑页增加删除按钮 Signed-off-by: Ching --- frontend/src/components/input_recipe.vue | 69 ++++++++++++++---- .../components/recipe-mobile/recipe-edit.vue | 73 ++++++++++++++++--- recipe/views.py | 2 +- 3 files changed, 118 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/input_recipe.vue b/frontend/src/components/input_recipe.vue index a8535d4..b052536 100644 --- a/frontend/src/components/input_recipe.vue +++ b/frontend/src/components/input_recipe.vue @@ -1,5 +1,5 @@ @@ -68,6 +98,8 @@ import { Rate, Button, Toast, + Col, + Row, } from 'vant'; import axios from 'axios'; import config from '@/config/index'; @@ -90,6 +122,8 @@ export default { [RadioGroup.name]: RadioGroup, [Rate.name]: Rate, [Button.name]: Button, + [Col.name]: Col, + [Row.name]: Row, }, data() { return { @@ -137,6 +171,20 @@ export default { ); } }, + onSubmitDelete(recipe_id) { + if (!this.form.name) { + return; + } + this.loading = true; + axios.delete(config.publicPath + '/recipe/recipe/' + recipe_id).then( + (Toast.success({ + message: '删除成功', + forbidClick: true, + duration: 500, + }), + (this.loading = false)) + ); + }, }, }; @@ -144,4 +192,7 @@ export default { .recipe-create { margin: 20px 16px; } +.submit-button { + width: 100%; +} diff --git a/recipe/views.py b/recipe/views.py index e958f5f..436402b 100644 --- a/recipe/views.py +++ b/recipe/views.py @@ -18,7 +18,7 @@ class RecipeAPI(rest_framework.generics.RetrieveUpdateDestroyAPIView): # authentication.SessionAuthentication, # authentication.BasicAuthentication) # permission_classes = (permissions.IsAuthenticated,) - queryset = recipe.models.Recipe.objects.exclude(status=const.RECIPE_STATUS_DELETED) + queryset = recipe.models.Recipe.objects.all() serializer_class = recipe.serializers.RecipeSerializer def perform_destroy(self, instance):