From 88f5d598279435bafb3247542485d487036b9388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Thu, 7 Apr 2022 20:31:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84:=20=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/dvadmin/system/views/dept.py | 12 +++++++++--- web/src/views/system/dept/crud.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/dvadmin/system/views/dept.py b/backend/dvadmin/system/views/dept.py index 21ebd1f..050d478 100644 --- a/backend/dvadmin/system/views/dept.py +++ b/backend/dvadmin/system/views/dept.py @@ -8,9 +8,7 @@ """ from dvadmin.system.models import Dept -from dvadmin.utils.filters import DataLevelPermissionsFilter from dvadmin.utils.json_response import SuccessResponse -from dvadmin.utils.permission import AnonymousUserPermission from dvadmin.utils.serializers import CustomModelSerializer from dvadmin.utils.viewset import CustomModelViewSet @@ -31,6 +29,12 @@ class DeptCreateUpdateSerializer(CustomModelSerializer): 部门管理 创建/更新时的列化器 """ + def create(self, validated_data): + instance = super().create(validated_data) + instance.dept_belong_id = instance.id + instance.save() + return instance + class Meta: model = Dept fields = '__all__' @@ -47,7 +51,9 @@ class DeptViewSet(CustomModelViewSet): """ queryset = Dept.objects.all() serializer_class = DeptSerializer - extra_filter_backends = [] + create_serializer_class = DeptCreateUpdateSerializer + update_serializer_class = DeptCreateUpdateSerializer + # extra_filter_backends = [] def list(self, request, *args, **kwargs): queryset = self.filter_queryset(self.get_queryset()) diff --git a/web/src/views/system/dept/crud.js b/web/src/views/system/dept/crud.js index 9555b3b..1ea0316 100644 --- a/web/src/views/system/dept/crud.js +++ b/web/src/views/system/dept/crud.js @@ -236,6 +236,6 @@ export const crudOptions = (vm) => { } } } - ].concat(vm.commonEndColumns({ dept_belong_id: { showForm: true, showTable: false } })) + ].concat(vm.commonEndColumns()) } }