From 8d7d775164f4f990d26004b51a8c5b06d7d87dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Tue, 9 May 2023 00:05:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=92=8C=E5=AD=97=E5=85=B8=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.修复菜单管理问题; 2.修复字典管理问题; --- backend/dvadmin/system/views/dictionary.py | 33 ++++++-- web/src/views/system/dept/index.vue | 30 +++++--- .../views/system/dictionary/subDict/api.ts | 4 +- .../views/system/dictionary/subDict/crud.tsx | 10 ++- .../menu/components/menuButton/crud.tsx | 7 +- .../menu/components/menuButton/index.vue | 11 ++- web/src/views/system/menu/index.vue | 75 ++++++++----------- web/src/views/system/role/crud.tsx | 2 +- 8 files changed, 101 insertions(+), 71 deletions(-) diff --git a/backend/dvadmin/system/views/dictionary.py b/backend/dvadmin/system/views/dictionary.py index 0dcc47c..46c2a9c 100644 --- a/backend/dvadmin/system/views/dictionary.py +++ b/backend/dvadmin/system/views/dictionary.py @@ -34,6 +34,19 @@ class DictionaryCreateUpdateSerializer(CustomModelSerializer): """ 字典管理 创建/更新时的列化器 """ + value = serializers.CharField(max_length=100) + + def validate_value(self, value): + """ + 在父级的字典编号验证重复性 + """ + initial_data = self.initial_data + parent = initial_data.get('parent',None) + if parent is None: + unique = Dictionary.objects.filter(value=value).exists() + if unique: + raise serializers.ValidationError("字典编号不能重复") + return value class Meta: model = Dictionary @@ -51,20 +64,24 @@ class DictionaryViewSet(CustomModelViewSet): """ queryset = Dictionary.objects.all() serializer_class = DictionarySerializer + create_serializer_class = DictionaryCreateUpdateSerializer extra_filter_class = [] search_fields = ['label'] def get_queryset(self): - params = self.request.query_params - parent = params.get('parent', None) - if params: - if parent: - queryset = self.queryset.filter(status=1, parent=parent) + if self.action =='list': + params = self.request.query_params + parent = params.get('parent', None) + if params: + if parent: + queryset = self.queryset.filter(parent=parent) + else: + queryset = self.queryset.filter(parent__isnull=True) else: - queryset = self.queryset.filter(status=1, parent__isnull=True) + queryset = self.queryset.filter(parent__isnull=True) + return queryset else: - queryset = self.queryset.filter(status=1, parent__isnull=True) - return queryset + return self.queryset class InitDictionaryViewSet(APIView): diff --git a/web/src/views/system/dept/index.vue b/web/src/views/system/dept/index.vue index 5612585..903fd39 100644 --- a/web/src/views/system/dept/index.vue +++ b/web/src/views/system/dept/index.vue @@ -63,10 +63,10 @@ 保存 - 新建 - 添加子级 - 添加同级 - 删除部门 + 新建 + 添加子级 + 添加同级 + 删除部门 @@ -79,7 +79,7 @@ diff --git a/web/src/views/system/menu/index.vue b/web/src/views/system/menu/index.vue index 30849c0..2b371c8 100644 --- a/web/src/views/system/menu/index.vue +++ b/web/src/views/system/menu/index.vue @@ -27,83 +27,59 @@ - + 菜单配置 - - - - - - - - - - - - - - 启用 禁用 - - 启用 禁用 - - - - - - - 保存 - 新建 - 添加子级 - 添加同级 - 删除菜单 - - - - - - - - - - + + + 保存 + 新建 + 添加子级 + + 删除菜单 + + + + + + @@ -111,7 +87,7 @@