重构: 部门管理数据权限优化

pull/48/head
李强 2022-04-07 20:31:18 +08:00
parent 0f500d0866
commit 88f5d59827
2 changed files with 10 additions and 4 deletions

View File

@ -8,9 +8,7 @@
""" """
from dvadmin.system.models import Dept from dvadmin.system.models import Dept
from dvadmin.utils.filters import DataLevelPermissionsFilter
from dvadmin.utils.json_response import SuccessResponse from dvadmin.utils.json_response import SuccessResponse
from dvadmin.utils.permission import AnonymousUserPermission
from dvadmin.utils.serializers import CustomModelSerializer from dvadmin.utils.serializers import CustomModelSerializer
from dvadmin.utils.viewset import CustomModelViewSet 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: class Meta:
model = Dept model = Dept
fields = '__all__' fields = '__all__'
@ -47,7 +51,9 @@ class DeptViewSet(CustomModelViewSet):
""" """
queryset = Dept.objects.all() queryset = Dept.objects.all()
serializer_class = DeptSerializer serializer_class = DeptSerializer
extra_filter_backends = [] create_serializer_class = DeptCreateUpdateSerializer
update_serializer_class = DeptCreateUpdateSerializer
# extra_filter_backends = []
def list(self, request, *args, **kwargs): def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset()) queryset = self.filter_queryset(self.get_queryset())

View File

@ -236,6 +236,6 @@ export const crudOptions = (vm) => {
} }
} }
} }
].concat(vm.commonEndColumns({ dept_belong_id: { showForm: true, showTable: false } })) ].concat(vm.commonEndColumns())
} }
} }