From bf1bdcae3e4fc1143eae34d988c5a0724890a0db Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 22 Feb 2021 10:32:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A2=98=E5=B9=B2=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_client/src/views/analyse/chart.vue | 1 - test_client/src/views/question/question.vue | 12 +++++++++++- test_server/question/views.py | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test_client/src/views/analyse/chart.vue b/test_client/src/views/analyse/chart.vue index 400b656..681a28a 100644 --- a/test_client/src/views/analyse/chart.vue +++ b/test_client/src/views/analyse/chart.vue @@ -2,7 +2,6 @@
- + @@ -303,6 +304,15 @@ export default { window.open(response.data.path, "_blank"); }).catch(e=>{loading.close()}); }, + changeSort(val) { + if (val.order == "ascending") { + this.listQuery.ordering = val.prop; + } else { + this.listQuery.ordering = "-" + val.prop; + } + + this.getList(); + }, } }; diff --git a/test_server/question/views.py b/test_server/question/views.py index 82d0e02..7d8b513 100644 --- a/test_server/question/views.py +++ b/test_server/question/views.py @@ -98,7 +98,7 @@ class QuestionViewSet(ModelViewSet): queryset = Question.objects.filter(is_delete=0).all() serializer_class = QuestionSerializer pagination_class = CommonPagination - ordering_fields = ['id'] + ordering_fields = ['id', 'name'] ordering = ['-create_time'] filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter] filterset_fields = ['questioncat','level', 'type']