diff --git a/test_client/src/api/question.js b/test_client/src/api/question.js
index 63d51f0..b526fe3 100644
--- a/test_client/src/api/question.js
+++ b/test_client/src/api/question.js
@@ -108,6 +108,13 @@ export function deleteQuestion(id) {
method: 'delete',
})
}
+export function deleteQuestions(data) {
+ return request({
+ url: `/question/question/deletes/`,
+ method: 'post',
+ data
+ })
+}
export function importQuestion(data) {
return request({
url: `/question/question/import/`,
diff --git a/test_client/src/views/question/question.vue b/test_client/src/views/question/question.vue
index 6d6049e..1c5c27f 100644
--- a/test_client/src/views/question/question.vue
+++ b/test_client/src/views/question/question.vue
@@ -70,6 +70,12 @@
Excel导入
导出Excel
+批量删除
{
+ this.$message.success("成功");
+ this.getList();
+ })
+ } else {
+ this.$message.warning("请先选择题目");
+ }
+ },
exportQuestion() {
const loading = this.$loading({
text:'正在准备..'
diff --git a/test_server/question/views.py b/test_server/question/views.py
index 738eb80..31a0314 100644
--- a/test_server/question/views.py
+++ b/test_server/question/views.py
@@ -6,13 +6,13 @@ from rest_framework import status
from rest_framework.decorators import action, permission_classes
from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.generics import GenericAPIView
-from rest_framework.permissions import IsAuthenticated
+from rest_framework.permissions import IsAdminUser, IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
-from crm.models import PaySubject
+from crm.models import Consumer, PaySubject
from examtest.models import WorkScope
from server import settings
from utils.custom import CommonPagination
@@ -116,6 +116,13 @@ class QuestionViewSet(ModelViewSet):
ret['panduan'] = queryset.filter(type='判断').count()
return Response(ret)
+ def get_queryset(self):
+ user = self.request.user
+ if isinstance(user, Consumer):
+ questioncats = user.workscope.questioncat.all()
+ self.queryset = self.queryset.filter(questioncat__in = questioncats)
+ return super().get_queryset()
+
@action(methods=['get'], detail=False,
url_path='export', url_name='export_question', perms_map=[{'*':'export_question'}])
def export(self, request):
@@ -143,6 +150,17 @@ class QuestionViewSet(ModelViewSet):
i.save()
return Response()
+ @action(methods=['post'], detail=False, perms_map=[{'*':'question_delete'}])
+ def deletes(self, request):
+ """
+ 批量删除
+ """
+ ids = request.data.get('ids', [])
+ if request.user.is_superuser:
+ Question.objects.filter(id__in=ids).update(is_delete=True)
+ return Response()
+ return Response({'error':'权限不足'})
+
@action(methods=['post'], detail=False, url_name='enable_question', permission_classes=[IsAuthenticated])
def enable(self, request):
ids = request.data.get('ids',None)