部门管理完成
							parent
							
								
									d9f920b245
								
							
						
					
					
						commit
						e54eccec46
					
				| 
						 | 
				
			
			@ -90,7 +90,7 @@ npm run build:prod
 | 
			
		|||
 | 
			
		||||
~~~bash
 | 
			
		||||
1. 进入项目目录 cd dvadmin-backend
 | 
			
		||||
2. 在项目根目录中,复制 env.example.py 文件为一份新的,并重命名为 env.py
 | 
			
		||||
2. 在项目根目录中,复制 ./conf/env.example.py 文件为一份新的到 ./conf 文件夹下,并重命名为 env.py
 | 
			
		||||
3. 在 env.py 中配置数据库信息
 | 
			
		||||
4. 安装依赖环境
 | 
			
		||||
	pip3 install -r requirements.txt
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -141,6 +141,8 @@ MEDIA_ROOT = os.path.join(BASE_DIR, "media")
 | 
			
		|||
# log 配置部分BEGIN #
 | 
			
		||||
SERVER_LOGS_FILE = os.path.join(BASE_DIR, 'logs', 'server.log')
 | 
			
		||||
ERROR_LOGS_FILE = os.path.join(BASE_DIR, 'logs', 'error.log')
 | 
			
		||||
if not os.path.exists(os.path.join(BASE_DIR, 'logs')):
 | 
			
		||||
    os.makedirs(os.path.join(BASE_DIR, 'logs'))
 | 
			
		||||
 | 
			
		||||
# 格式:[2020-04-22 23:33:01][micoservice.apps.ready():16] [INFO] 这是一条日志:
 | 
			
		||||
# 格式:[日期][模块.函数名称():行号] [级别] 信息
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
from collections import OrderedDict
 | 
			
		||||
from typing import Any
 | 
			
		||||
 | 
			
		||||
from rest_framework.pagination import PageNumberPagination, _positive_int
 | 
			
		||||
from rest_framework.utils.urls import replace_query_param
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +22,10 @@ class Pagination(PageNumberPagination):
 | 
			
		|||
    page_size = 10
 | 
			
		||||
 | 
			
		||||
    def paginate_queryset(self, queryset, request, view=None):
 | 
			
		||||
        page_num = request.query_params.get(self.page_query_param)
 | 
			
		||||
        # 判断,如果 pageNum 为all 则取消分页返回所有
 | 
			
		||||
        if page_num == 'all':
 | 
			
		||||
            return None
 | 
			
		||||
        return super().paginate_queryset(queryset, request, view)
 | 
			
		||||
 | 
			
		||||
    def get_next_link(self):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -232,7 +232,7 @@ class CustomMongoModelViewSet(MongoModelViewSet, mixins.TableSerializerMixin):
 | 
			
		|||
        filtering_kwargs = {}
 | 
			
		||||
        for param in self.request.query_params:
 | 
			
		||||
            param = param.strip()
 | 
			
		||||
            if param in ['page_size', 'page', 'search', 'ordering', 'as']: continue
 | 
			
		||||
            if param in ['pageSize', 'pageNum', 'search', 'ordering', 'as']: continue
 | 
			
		||||
            if self.filter_fields == '__all__' or param in self.filter_fields:
 | 
			
		||||
                # if param in self.filter_fields:
 | 
			
		||||
                filtering_kwargs[param] = self.request.query_params[param]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,53 @@
 | 
			
		|||
import django_filters
 | 
			
		||||
 | 
			
		||||
from apps.permission.models import Menu
 | 
			
		||||
from apps.permission.models import Menu, Dept, Post, Role, UserProfile
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class MenuFilter(django_filters.rest_framework.FilterSet):
 | 
			
		||||
    """
 | 
			
		||||
    菜单管理 简单序过滤器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Menu
 | 
			
		||||
        fields = '__all__'
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DeptFilter(django_filters.rest_framework.FilterSet):
 | 
			
		||||
    """
 | 
			
		||||
    部门管理 简单序过滤器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Dept
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PostFilter(django_filters.rest_framework.FilterSet):
 | 
			
		||||
    """
 | 
			
		||||
    岗位管理 简单序过滤器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Post
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class RoleFilter(django_filters.rest_framework.FilterSet):
 | 
			
		||||
    """
 | 
			
		||||
    角色管理 简单序过滤器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Role
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UserProfileFilter(django_filters.rest_framework.FilterSet):
 | 
			
		||||
    """
 | 
			
		||||
    用户管理 简单序过滤器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = UserProfile
 | 
			
		||||
        exclude = ('secret', 'password',)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,17 +5,17 @@ from apps.op_drf.models import CoreModel
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
class Dept(CoreModel):
 | 
			
		||||
    name = CharField(max_length=64, verbose_name="部门名称")
 | 
			
		||||
    deptName = CharField(max_length=64, verbose_name="部门名称")
 | 
			
		||||
    orderNum = IntegerField(verbose_name="显示排序")
 | 
			
		||||
    owner = CharField(max_length=32, verbose_name="负责人", null=True)
 | 
			
		||||
    phone = CharField(max_length=32, verbose_name="联系电话", null=True)
 | 
			
		||||
    email = CharField(max_length=32, verbose_name="邮箱", null=True)
 | 
			
		||||
    status = BooleanField(default=False, verbose_name="部门状态")
 | 
			
		||||
    parentId = ForeignKey(to='Dept', on_delete=CASCADE, default=False, verbose_name="上级部门")
 | 
			
		||||
    status = CharField(max_length=8, verbose_name="部门状态", null=True)
 | 
			
		||||
    parentId = ForeignKey(to='Dept', null=True, on_delete=CASCADE, default=False, verbose_name="上级部门")
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        verbose_name = '部门管理'
 | 
			
		||||
        verbose_name_plural = verbose_name
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return f"{self.name}"
 | 
			
		||||
        return f"{self.deptName}"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,13 @@
 | 
			
		|||
from rest_framework import serializers
 | 
			
		||||
 | 
			
		||||
from apps.op_drf.serializers import CustomModelSerializer
 | 
			
		||||
from apps.permission.models import UserProfile, Menu, Role
 | 
			
		||||
from apps.permission.models import Menu, Dept, Post, Role, UserProfile
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# ================================================= #
 | 
			
		||||
# ************** 用户管理 序列化器  ************** #
 | 
			
		||||
# ================================================= #
 | 
			
		||||
 | 
			
		||||
class UserProfileSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    简单用户序列化器
 | 
			
		||||
| 
						 | 
				
			
			@ -22,19 +26,24 @@ class UserProfileSerializer(CustomModelSerializer):
 | 
			
		|||
        exclude = ('password', 'secret', 'user_permissions', 'groups', 'is_superuser', 'date_joined')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# ================================================= #
 | 
			
		||||
# ************** 菜单管理 序列化器  ************** #
 | 
			
		||||
# ================================================= #
 | 
			
		||||
 | 
			
		||||
class MenuSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    简单菜单序列化器
 | 
			
		||||
    """
 | 
			
		||||
    parentId = serializers.IntegerField(source="parentId.id", default=0)
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Menu
 | 
			
		||||
        fields = '__all__'
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateUpdateMenuSerializer(CustomModelSerializer):
 | 
			
		||||
class MenuCreateUpdateSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    创建角色/更新时的列化器
 | 
			
		||||
    菜单管理 创建/更新时的列化器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def validate(self, attrs: dict):
 | 
			
		||||
| 
						 | 
				
			
			@ -50,15 +59,89 @@ class CreateUpdateMenuSerializer(CustomModelSerializer):
 | 
			
		|||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Menu
 | 
			
		||||
        fields = "__all__"
 | 
			
		||||
        read_only_fields = ('mtime', 'ctime', 'creator', 'modifier')
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
        read_only_fields = ('update_datetime', 'create_datetime', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class RoleSerializer(serializers.ModelSerializer):
 | 
			
		||||
# ================================================= #
 | 
			
		||||
# ************** 部门管理 序列化器  ************** #
 | 
			
		||||
# ================================================= #
 | 
			
		||||
 | 
			
		||||
class DeptSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    简单角色序列化器
 | 
			
		||||
    部门管理 简单序列化器
 | 
			
		||||
    """
 | 
			
		||||
    parentId = serializers.IntegerField(source="parentId.id", default=0)
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Dept
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DeptCreateUpdateSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    部门管理 创建/更新时的列化器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def validate(self, attrs: dict):
 | 
			
		||||
        return super().validate(attrs)
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Dept
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
        read_only_fields = ('update_datetime', 'create_datetime', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# ================================================= #
 | 
			
		||||
# ************** 岗位管理 序列化器  ************** #
 | 
			
		||||
# ================================================= #
 | 
			
		||||
 | 
			
		||||
class PostSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    岗位管理 简单序列化器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Post
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PostCreateUpdateSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    岗位管理 创建/更新时的列化器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def validate(self, attrs: dict):
 | 
			
		||||
        return super().validate(attrs)
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Post
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
        read_only_fields = ('update_datetime', 'create_datetime', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# ================================================= #
 | 
			
		||||
# ************** 角色管理 序列化器  ************** #
 | 
			
		||||
# ================================================= #
 | 
			
		||||
 | 
			
		||||
class RoleSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    角色管理 简单序列化器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Role
 | 
			
		||||
        fields = '__all__'
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class RoleCreateUpdateSerializer(CustomModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    角色管理 创建/更新时的列化器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def validate(self, attrs: dict):
 | 
			
		||||
        return super().validate(attrs)
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Role
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
        read_only_fields = ('update_datetime', 'create_datetime', 'creator', 'modifier')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,13 +1,17 @@
 | 
			
		|||
from django.urls import re_path
 | 
			
		||||
from rest_framework.routers import DefaultRouter
 | 
			
		||||
 | 
			
		||||
from apps.permission.views import MenuModelViewSet
 | 
			
		||||
from apps.permission.views import MenuModelViewSet, DeptModelViewSet, PostModelViewSet, RoleModelViewSet
 | 
			
		||||
 | 
			
		||||
router = DefaultRouter()
 | 
			
		||||
router.register(r'menus', MenuModelViewSet)
 | 
			
		||||
router.register(r'dept', DeptModelViewSet)
 | 
			
		||||
router.register(r'dept/exclude', DeptModelViewSet)
 | 
			
		||||
router.register(r'post', PostModelViewSet)
 | 
			
		||||
router.register(r'role', RoleModelViewSet)
 | 
			
		||||
urlpatterns = [
 | 
			
		||||
 | 
			
		||||
    # re_path('menus/', MenuModelViewSet.as_view({'get': 'list'}), name='api_token_auth'),
 | 
			
		||||
    re_path('dept/exclude/(?P<pk>.*)/', DeptModelViewSet.as_view({'get': 'exclude_list'}), name='api_token_auth'),
 | 
			
		||||
 | 
			
		||||
]
 | 
			
		||||
urlpatterns += router.urls
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,13 +1,15 @@
 | 
			
		|||
import json
 | 
			
		||||
 | 
			
		||||
from rest_framework.request import Request
 | 
			
		||||
from rest_framework.response import Response
 | 
			
		||||
from rest_framework.views import APIView
 | 
			
		||||
 | 
			
		||||
from apps.op_drf.viewsets import CustomModelViewSet
 | 
			
		||||
from apps.permission.filters import MenuFilter
 | 
			
		||||
from apps.permission.models import Role, Menu
 | 
			
		||||
from apps.permission.filters import MenuFilter, DeptFilter, PostFilter, RoleFilter
 | 
			
		||||
from apps.permission.models import Role, Menu, Dept, Post
 | 
			
		||||
from apps.permission.serializers import UserProfileSerializer, MenuSerializer, RoleSerializer, \
 | 
			
		||||
    CreateUpdateMenuSerializer
 | 
			
		||||
    MenuCreateUpdateSerializer, DeptSerializer, DeptCreateUpdateSerializer, PostSerializer, PostCreateUpdateSerializer, \
 | 
			
		||||
    RoleCreateUpdateSerializer
 | 
			
		||||
from utils.response import SuccessResponse
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -35,21 +37,19 @@ class GetRouters(APIView):
 | 
			
		|||
 | 
			
		||||
    def get(self, request, format=None):
 | 
			
		||||
        # data = GetUserInfoSerializer(request.user).data
 | 
			
		||||
        data = '{"msg":"操作成功","code":200,"data":[{"name":"System","path":"/system","hidden":false,"redirect":"noRedirect","component":"Layout","alwaysShow":true,"meta":{"title":"系统管理","icon":"system","noCache":false},"children":[{"name":"User","path":"user","hidden":false,"component":"system/user/index","meta":{"title":"用户管理","icon":"user","noCache":false}},{"name":"Role","path":"role","hidden":false,"component":"system/role/index","meta":{"title":"角色管理","icon":"peoples","noCache":false}},{"name":"Menu","path":"menu","hidden":false,"component":"system/menu/index","meta":{"title":"菜单管理","icon":"tree-table","noCache":false}},{"name":"Dept","path":"dept","hidden":false,"component":"system/dept/index","meta":{"title":"部门管理","icon":"tree","noCache":false}},{"name":"Post","path":"post","hidden":false,"component":"system/post/index","meta":{"title":"岗位管理","icon":"post","noCache":false}},{"name":"Dict","path":"dict","hidden":false,"component":"system/dict/index","meta":{"title":"字典管理","icon":"dict","noCache":false}},{"name":"Config","path":"config","hidden":false,"component":"system/config/index","meta":{"title":"参数设置","icon":"edit","noCache":false}},{"name":"Notice","path":"notice","hidden":false,"component":"system/notice/index","meta":{"title":"通知公告","icon":"message","noCache":false}},{"name":"Log","path":"log","hidden":false,"redirect":"noRedirect","component":"ParentView","alwaysShow":true,"meta":{"title":"日志管理","icon":"log","noCache":false},"children":[{"name":"Operlog","path":"operlog","hidden":false,"component":"monitor/operlog/index","meta":{"title":"操作日志","icon":"form","noCache":false}},{"name":"Logininfor","path":"logininfor","hidden":false,"component":"monitor/logininfor/index","meta":{"title":"登录日志","icon":"logininfor","noCache":false}}]}]},{"name":"Monitor","path":"/monitor","hidden":false,"redirect":"noRedirect","component":"Layout","alwaysShow":true,"meta":{"title":"系统监控","icon":"monitor","noCache":false},"children":[{"name":"Online","path":"online","hidden":false,"component":"monitor/online/index","meta":{"title":"在线用户","icon":"online","noCache":false}},{"name":"Job","path":"job","hidden":false,"component":"monitor/job/index","meta":{"title":"定时任务","icon":"job","noCache":false}},{"name":"Druid","path":"druid","hidden":false,"component":"monitor/druid/index","meta":{"title":"数据监控","icon":"druid","noCache":false}},{"name":"Server","path":"server","hidden":false,"component":"monitor/server/index","meta":{"title":"服务监控","icon":"server","noCache":false}},{"name":"Cache","path":"cache","hidden":false,"component":"monitor/cache/index","meta":{"title":"缓存监控","icon":"redis","noCache":false}}]},{"name":"Tool","path":"/tool","hidden":false,"redirect":"noRedirect","component":"Layout","alwaysShow":true,"meta":{"title":"系统工具","icon":"tool","noCache":false},"children":[{"name":"Build","path":"build","hidden":false,"component":"tool/build/index","meta":{"title":"表单构建","icon":"build","noCache":false}},{"name":"Gen","path":"gen","hidden":false,"component":"tool/gen/index","meta":{"title":"代码生成","icon":"code","noCache":false}},{"name":"Swagger","path":"swagger","hidden":false,"component":"tool/swagger/index","meta":{"title":"系统接口","icon":"swagger","noCache":false}}]},{"name":"Http://ruoyi.vip","path":"http://ruoyi.vip","hidden":false,"component":"Layout","meta":{"title":"若依官网","icon":"guide","noCache":false}}]}'
 | 
			
		||||
        data = '{"msg":"操作成功","code":200,"data":[{"name":"System","path":"/system","hidden":false,"redirect":"noRedirect","component":"Layout","alwaysShow":true,"meta":{"title":"系统管理","icon":"system","noCache":false},"children":[{"name":"User","path":"user","hidden":false,"component":"permission/user/index","meta":{"title":"用户管理","icon":"user","noCache":false}},{"name":"Role","path":"role","hidden":false,"component":"permission/role/index","meta":{"title":"角色管理","icon":"peoples","noCache":false}},{"name":"Menu","path":"menu","hidden":false,"component":"permission/menu/index","meta":{"title":"菜单管理","icon":"tree-table","noCache":false}},{"name":"Dept","path":"dept","hidden":false,"component":"permission/dept/index","meta":{"title":"部门管理","icon":"tree","noCache":false}},{"name":"Post","path":"post","hidden":false,"component":"permission/post/index","meta":{"title":"岗位管理","icon":"post","noCache":false}},{"name":"Dict","path":"dict","hidden":false,"component":"system/dict/index","meta":{"title":"字典管理","icon":"dict","noCache":false}},{"name":"Config","path":"config","hidden":false,"component":"system/config/index","meta":{"title":"参数设置","icon":"edit","noCache":false}},{"name":"Notice","path":"notice","hidden":false,"component":"system/notice/index","meta":{"title":"通知公告","icon":"message","noCache":false}},{"name":"Log","path":"log","hidden":false,"redirect":"noRedirect","component":"ParentView","alwaysShow":true,"meta":{"title":"日志管理","icon":"log","noCache":false},"children":[{"name":"Operlog","path":"operlog","hidden":false,"component":"monitor/operlog/index","meta":{"title":"操作日志","icon":"form","noCache":false}},{"name":"Logininfor","path":"logininfor","hidden":false,"component":"monitor/logininfor/index","meta":{"title":"登录日志","icon":"logininfor","noCache":false}}]}]},{"name":"Monitor","path":"/monitor","hidden":false,"redirect":"noRedirect","component":"Layout","alwaysShow":true,"meta":{"title":"系统监控","icon":"monitor","noCache":false},"children":[{"name":"Online","path":"online","hidden":false,"component":"monitor/online/index","meta":{"title":"在线用户","icon":"online","noCache":false}},{"name":"Job","path":"job","hidden":false,"component":"monitor/job/index","meta":{"title":"定时任务","icon":"job","noCache":false}},{"name":"Druid","path":"druid","hidden":false,"component":"monitor/druid/index","meta":{"title":"数据监控","icon":"druid","noCache":false}},{"name":"Server","path":"server","hidden":false,"component":"monitor/server/index","meta":{"title":"服务监控","icon":"server","noCache":false}},{"name":"Cache","path":"cache","hidden":false,"component":"monitor/cache/index","meta":{"title":"缓存监控","icon":"redis","noCache":false}}]},{"name":"Tool","path":"/tool","hidden":false,"redirect":"noRedirect","component":"Layout","alwaysShow":true,"meta":{"title":"系统工具","icon":"tool","noCache":false},"children":[{"name":"Build","path":"build","hidden":false,"component":"tool/build/index","meta":{"title":"表单构建","icon":"build","noCache":false}},{"name":"Gen","path":"gen","hidden":false,"component":"tool/gen/index","meta":{"title":"代码生成","icon":"code","noCache":false}},{"name":"Swagger","path":"swagger","hidden":false,"component":"tool/swagger/index","meta":{"title":"系统接口","icon":"swagger","noCache":false}}]},{"name":"Http://ruoyi.vip","path":"http://ruoyi.vip","hidden":false,"component":"Layout","meta":{"title":"若依官网","icon":"guide","noCache":false}}]}'
 | 
			
		||||
        data = json.loads(data)
 | 
			
		||||
        return Response(data)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class MenuModelViewSet(CustomModelViewSet):
 | 
			
		||||
    """
 | 
			
		||||
    菜单模型的CRUD视图
 | 
			
		||||
    菜单模型 的CRUD视图
 | 
			
		||||
    """
 | 
			
		||||
    queryset = Menu.objects.all()
 | 
			
		||||
    serializer_class = MenuSerializer
 | 
			
		||||
    create_serializer_class = CreateUpdateMenuSerializer
 | 
			
		||||
    update_serializer_class = CreateUpdateMenuSerializer
 | 
			
		||||
    # list_serializer_class = ListRoleSerializer
 | 
			
		||||
    # retrieve_serializer_class = DetailRoleSerializer
 | 
			
		||||
    create_serializer_class = MenuCreateUpdateSerializer
 | 
			
		||||
    update_serializer_class = MenuCreateUpdateSerializer
 | 
			
		||||
    filter_class = MenuFilter
 | 
			
		||||
    # update_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # destroy_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
| 
						 | 
				
			
			@ -58,17 +58,56 @@ class MenuModelViewSet(CustomModelViewSet):
 | 
			
		|||
    ordering = 'create_datetime'  # 默认排序
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DeptModelViewSet(CustomModelViewSet):
 | 
			
		||||
    """
 | 
			
		||||
    部门管理 的CRUD视图
 | 
			
		||||
    """
 | 
			
		||||
    queryset = Dept.objects.all()
 | 
			
		||||
    serializer_class = DeptSerializer
 | 
			
		||||
    create_serializer_class = DeptCreateUpdateSerializer
 | 
			
		||||
    update_serializer_class = DeptCreateUpdateSerializer
 | 
			
		||||
    filter_class = DeptFilter
 | 
			
		||||
    # update_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # destroy_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # create_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    search_fields = ('name',)
 | 
			
		||||
    ordering = 'create_datetime'  # 默认排序
 | 
			
		||||
 | 
			
		||||
    def exclude_list(self, request: Request, *args, **kwargs):
 | 
			
		||||
        dept_queryset = Dept.objects.filter(id=kwargs.get('pk')).first()
 | 
			
		||||
        parentId = dept_queryset.parentId if dept_queryset else ''
 | 
			
		||||
        queryset = self.queryset.exclude(parentId=parentId).order_by('orderNum')
 | 
			
		||||
        if hasattr(self, 'handle_logging'):
 | 
			
		||||
            self.handle_logging(request, *args, **kwargs)
 | 
			
		||||
        serializer = self.get_serializer(queryset, many=True)
 | 
			
		||||
        return SuccessResponse(serializer.data)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PostModelViewSet(CustomModelViewSet):
 | 
			
		||||
    """
 | 
			
		||||
    岗位管理 的CRUD视图
 | 
			
		||||
    """
 | 
			
		||||
    queryset = Post.objects.all()
 | 
			
		||||
    serializer_class = PostSerializer
 | 
			
		||||
    create_serializer_class = PostCreateUpdateSerializer
 | 
			
		||||
    update_serializer_class = PostCreateUpdateSerializer
 | 
			
		||||
    filter_class = PostFilter
 | 
			
		||||
    # update_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # destroy_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # create_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    search_fields = ('name',)
 | 
			
		||||
    ordering = 'create_datetime'  # 默认排序
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class RoleModelViewSet(CustomModelViewSet):
 | 
			
		||||
    """
 | 
			
		||||
    角色模型的CRUD视图
 | 
			
		||||
    角色管理 的CRUD视图
 | 
			
		||||
    """
 | 
			
		||||
    queryset = Role.objects.all()
 | 
			
		||||
    serializer_class = RoleSerializer
 | 
			
		||||
    # create_serializer_class = CreateUpdateRoleSerializer
 | 
			
		||||
    # update_serializer_class = CreateUpdateRoleSerializer
 | 
			
		||||
    # list_serializer_class = ListRoleSerializer
 | 
			
		||||
    # retrieve_serializer_class = DetailRoleSerializer
 | 
			
		||||
    # filter_class = RoleFilter
 | 
			
		||||
    create_serializer_class = RoleCreateUpdateSerializer
 | 
			
		||||
    update_serializer_class = RoleCreateUpdateSerializer
 | 
			
		||||
    filter_class = RoleFilter
 | 
			
		||||
    # update_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # destroy_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # create_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,12 +4,18 @@ from apps.system.models import DictDetails, DictData
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
class DictDataFilter(django_filters.rest_framework.FilterSet):
 | 
			
		||||
    """
 | 
			
		||||
    字典管理 简单过滤器
 | 
			
		||||
    """
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = DictData
 | 
			
		||||
        fields = '__all__'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DictDetailsFilter(django_filters.rest_framework.FilterSet):
 | 
			
		||||
    """
 | 
			
		||||
    字典详情 简单过滤器
 | 
			
		||||
    """
 | 
			
		||||
    dictType = django_filters.CharFilter(field_name='dict_data__dictType')
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = DictDetails
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ from apps.op_drf.models import CoreModel
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
class DictDetails(CoreModel):
 | 
			
		||||
    name = CharField(max_length=64, verbose_name="字典标签")
 | 
			
		||||
    dictLabel = CharField(max_length=64, verbose_name="字典标签")
 | 
			
		||||
    dictValue = CharField(max_length=256, verbose_name="字典键值")
 | 
			
		||||
    is_default = BooleanField(verbose_name="是否默认", default=False)
 | 
			
		||||
    status = CharField(max_length=2, verbose_name="字典状态")
 | 
			
		||||
| 
						 | 
				
			
			@ -17,4 +17,4 @@ class DictDetails(CoreModel):
 | 
			
		|||
        verbose_name_plural = verbose_name
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return f"{self.name}"
 | 
			
		||||
        return f"{self.dictLabel}"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,10 @@ from apps.op_drf.serializers import CustomModelSerializer
 | 
			
		|||
from apps.system.models import DictData, DictDetails
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# ================================================= #
 | 
			
		||||
# ************** 字典管理 序列化器  ************** #
 | 
			
		||||
# ================================================= #
 | 
			
		||||
 | 
			
		||||
class DictDataSerializer(serializers.ModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    字典管理 简单序列化器
 | 
			
		||||
| 
						 | 
				
			
			@ -21,10 +25,14 @@ class DictDataCreateUpdateSerializer(CustomModelSerializer):
 | 
			
		|||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = DictData
 | 
			
		||||
        fields = "__all__"
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
        read_only_fields = ('update_datetime', 'create_datetime', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# ================================================= #
 | 
			
		||||
# ************** 字典详情 序列化器  ************** #
 | 
			
		||||
# ================================================= #
 | 
			
		||||
 | 
			
		||||
class DictDetailsSerializer(serializers.ModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    字典详情 简单序列化器
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +41,16 @@ class DictDetailsSerializer(serializers.ModelSerializer):
 | 
			
		|||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = DictDetails
 | 
			
		||||
        exclude = ('creator', 'modifier')
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
 | 
			
		||||
class DictDetailsListSerializer(serializers.ModelSerializer):
 | 
			
		||||
    """
 | 
			
		||||
    字典详情List 简单序列化器
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = DictDetails
 | 
			
		||||
        fields = ('dictLabel', 'dictValue', 'is_default')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DictDetailsCreateUpdateSerializer(CustomModelSerializer):
 | 
			
		||||
| 
						 | 
				
			
			@ -43,5 +60,5 @@ class DictDetailsCreateUpdateSerializer(CustomModelSerializer):
 | 
			
		|||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = DictDetails
 | 
			
		||||
        fields = "__all__"
 | 
			
		||||
        exclude = ('description', 'creator', 'modifier')
 | 
			
		||||
        read_only_fields = ('update_datetime', 'create_datetime', 'creator', 'modifier')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ from apps.system.views import DictDataModelViewSet, DictDetailsModelViewSet, Dic
 | 
			
		|||
router = DefaultRouter()
 | 
			
		||||
router.register(r'dict/type', DictDataModelViewSet)
 | 
			
		||||
router.register(r'dict/data', DictDetailsModelViewSet)
 | 
			
		||||
router.register(r'dict/get/type', DictDetailsListModelViewSet)
 | 
			
		||||
urlpatterns = [
 | 
			
		||||
    re_path('dict/get/type/(?P<pk>.*)/', DictDetailsListModelViewSet.as_view({'get':'list'})),
 | 
			
		||||
]
 | 
			
		||||
urlpatterns += router.urls
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ from rest_framework.request import Request
 | 
			
		|||
from apps.op_drf.viewsets import CustomModelViewSet
 | 
			
		||||
from apps.system.models import DictData
 | 
			
		||||
from apps.system.serializers import DictDataSerializer, DictDataCreateUpdateSerializer, DictDetailsSerializer, \
 | 
			
		||||
    DictDetailsCreateUpdateSerializer
 | 
			
		||||
    DictDetailsCreateUpdateSerializer, DictDetailsListSerializer
 | 
			
		||||
from apps.system.models import DictDetails
 | 
			
		||||
from apps.system.filters import DictDetailsFilter, DictDataFilter
 | 
			
		||||
from utils.response import SuccessResponse
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +16,7 @@ class DictDataModelViewSet(CustomModelViewSet):
 | 
			
		|||
    queryset = DictData.objects.all()
 | 
			
		||||
    serializer_class = DictDataSerializer
 | 
			
		||||
    create_serializer_class = DictDataCreateUpdateSerializer
 | 
			
		||||
    # update_serializer_class = CreateUpdateRoleSerializer
 | 
			
		||||
    update_serializer_class = DictDataCreateUpdateSerializer
 | 
			
		||||
    # list_serializer_class = ListRoleSerializer
 | 
			
		||||
    # retrieve_serializer_class = DetailRoleSerializer
 | 
			
		||||
    filter_class = DictDataFilter
 | 
			
		||||
| 
						 | 
				
			
			@ -33,27 +33,41 @@ class DictDetailsModelViewSet(CustomModelViewSet):
 | 
			
		|||
    queryset = DictDetails.objects.all()
 | 
			
		||||
    serializer_class = DictDetailsSerializer
 | 
			
		||||
    create_serializer_class = DictDetailsCreateUpdateSerializer
 | 
			
		||||
    # update_serializer_class = CreateUpdateRoleSerializer
 | 
			
		||||
    # list_serializer_class = ListRoleSerializer
 | 
			
		||||
    # retrieve_serializer_class = DetailRoleSerializer
 | 
			
		||||
    update_serializer_class = DictDetailsCreateUpdateSerializer
 | 
			
		||||
    filter_class = DictDetailsFilter
 | 
			
		||||
    # update_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # destroy_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    # create_extra_permission_classes = (IsManagerPermission,)
 | 
			
		||||
    search_fields = ('name',)
 | 
			
		||||
    ordering = 'sort'  # 默认排序
 | 
			
		||||
    def list(self, request: Request, *args, **kwargs):
 | 
			
		||||
        queryset = self.filter_queryset(self.get_queryset())
 | 
			
		||||
 | 
			
		||||
        page = self.paginate_queryset(queryset)
 | 
			
		||||
        print(1,page)
 | 
			
		||||
        if hasattr(self, 'handle_logging'):
 | 
			
		||||
            self.handle_logging(request, *args, **kwargs)
 | 
			
		||||
        if page is not None:
 | 
			
		||||
            if getattr(self, 'values_queryset', None):
 | 
			
		||||
                return self.get_paginated_response(page)
 | 
			
		||||
            serializer = self.get_serializer(page, many=True)
 | 
			
		||||
            return self.get_paginated_response(serializer.data)
 | 
			
		||||
        if getattr(self, 'values_queryset', None):
 | 
			
		||||
            return SuccessResponse(page)
 | 
			
		||||
        serializer = self.get_serializer(queryset, many=True)
 | 
			
		||||
        return SuccessResponse(serializer.data)
 | 
			
		||||
 | 
			
		||||
class DictDetailsListModelViewSet(CustomModelViewSet):
 | 
			
		||||
    """
 | 
			
		||||
    根据字典类型查询字典数据信息 模型的CRUD视图
 | 
			
		||||
    """
 | 
			
		||||
    queryset = DictDetails.objects.filter(status=True)
 | 
			
		||||
    serializer_class = DictDetailsSerializer
 | 
			
		||||
    queryset = DictDetails.objects.filter(status=0)
 | 
			
		||||
    serializer_class = DictDetailsListSerializer
 | 
			
		||||
    filter_class = DictDetailsFilter
 | 
			
		||||
    search_fields = ('name',)
 | 
			
		||||
    ordering = 'create_datetime'  # 默认排序
 | 
			
		||||
    ordering = 'sort'  # 默认排序
 | 
			
		||||
    def list(self, request: Request, *args, **kwargs):
 | 
			
		||||
        queryset = self.filter_queryset(self.get_queryset())
 | 
			
		||||
        queryset = self.queryset.filter(dict_data__dictType=kwargs.get('pk')).order_by('sort')
 | 
			
		||||
        if hasattr(self, 'handle_logging'):
 | 
			
		||||
            self.handle_logging(request, *args, **kwargs)
 | 
			
		||||
        serializer = self.get_serializer(queryset, many=True)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@
 | 
			
		|||
# ************** mysql数据库 配置  ************** #
 | 
			
		||||
# ================================================= #
 | 
			
		||||
# 数据库类型 MYSQL/SQLITE3
 | 
			
		||||
DATABASE_TYPE = "SQLITE3"
 | 
			
		||||
DATABASE_TYPE = "MYSQL"
 | 
			
		||||
# 数据库地址
 | 
			
		||||
DATABASE_HOST = "127.0.0.1"
 | 
			
		||||
# 数据库端口
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ import request from '@/utils/request'
 | 
			
		|||
// 查询部门列表
 | 
			
		||||
export function listDept(query) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/system/dept/list',
 | 
			
		||||
    url: '/permission/dept/',
 | 
			
		||||
    method: 'get',
 | 
			
		||||
    params: query
 | 
			
		||||
  })
 | 
			
		||||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ export function listDept(query) {
 | 
			
		|||
// 查询部门列表(排除节点)
 | 
			
		||||
export function listDeptExcludeChild(deptId) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/system/dept/list/exclude/' + deptId,
 | 
			
		||||
    url: '/permission/dept/exclude/' + deptId + '/',
 | 
			
		||||
    method: 'get'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ export function listDeptExcludeChild(deptId) {
 | 
			
		|||
// 查询部门详细
 | 
			
		||||
export function getDept(deptId) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/system/dept/' + deptId,
 | 
			
		||||
    url: '/permission/dept/' + deptId + '/',
 | 
			
		||||
    method: 'get'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ export function getDept(deptId) {
 | 
			
		|||
// 查询部门下拉树结构
 | 
			
		||||
export function treeselect() {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/system/dept/treeselect',
 | 
			
		||||
    url: '/permission/dept/treeselect',
 | 
			
		||||
    method: 'get'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ export function treeselect() {
 | 
			
		|||
// 根据角色ID查询部门树结构
 | 
			
		||||
export function roleDeptTreeselect(roleId) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/system/dept/roleDeptTreeselect/' + roleId,
 | 
			
		||||
    url: '/permission/dept/roleDeptTreeselect/' + roleId,
 | 
			
		||||
    method: 'get'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +44,7 @@ export function roleDeptTreeselect(roleId) {
 | 
			
		|||
// 新增部门
 | 
			
		||||
export function addDept(data) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/system/dept',
 | 
			
		||||
    url: '/permission/dept/',
 | 
			
		||||
    method: 'post',
 | 
			
		||||
    data: data
 | 
			
		||||
  })
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +53,7 @@ export function addDept(data) {
 | 
			
		|||
// 修改部门
 | 
			
		||||
export function updateDept(data) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/system/dept',
 | 
			
		||||
    url: '/permission/dept/' + data.id + '/',
 | 
			
		||||
    method: 'put',
 | 
			
		||||
    data: data
 | 
			
		||||
  })
 | 
			
		||||
| 
						 | 
				
			
			@ -62,7 +62,7 @@ export function updateDept(data) {
 | 
			
		|||
// 删除部门
 | 
			
		||||
export function delDept(deptId) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/system/dept/' + deptId,
 | 
			
		||||
    url: '/permission/dept/' + deptId + '',
 | 
			
		||||
    method: 'delete'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,16 +43,21 @@
 | 
			
		|||
    <el-table
 | 
			
		||||
      v-loading="loading"
 | 
			
		||||
      :data="deptList"
 | 
			
		||||
      row-key="deptId"
 | 
			
		||||
      row-key="id"
 | 
			
		||||
      default-expand-all
 | 
			
		||||
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
 | 
			
		||||
    >
 | 
			
		||||
      <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
 | 
			
		||||
      <el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
 | 
			
		||||
      <el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column>
 | 
			
		||||
      <el-table-column label="创建时间" align="center" prop="createTime" width="200">
 | 
			
		||||
      <el-table-column prop="status" label="状态" :formatter="statusFormat" width="200"></el-table-column>
 | 
			
		||||
      <el-table-column label="更新时间" align="center" prop="update_datetime" width="200">
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
          <span>{{ parseTime(scope.row.createTime) }}</span>
 | 
			
		||||
          <span>{{ parseTime(scope.row.update_datetime) }}</span>
 | 
			
		||||
        </template>
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
      <el-table-column label="创建时间" align="center" prop="create_datetime" width="200">
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
          <span>{{ parseTime(scope.row.create_datetime) }}</span>
 | 
			
		||||
        </template>
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
 | 
			
		||||
| 
						 | 
				
			
			@ -165,7 +170,8 @@ export default {
 | 
			
		|||
      // 查询参数
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        deptName: undefined,
 | 
			
		||||
        status: undefined
 | 
			
		||||
        status: undefined,
 | 
			
		||||
        pageNum: 'all'
 | 
			
		||||
      },
 | 
			
		||||
      // 表单参数
 | 
			
		||||
      form: {},
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +214,7 @@ export default {
 | 
			
		|||
    getList() {
 | 
			
		||||
      this.loading = true;
 | 
			
		||||
      listDept(this.queryParams).then(response => {
 | 
			
		||||
        this.deptList = this.handleTree(response.data, "deptId");
 | 
			
		||||
        this.deptList = this.handleTree(response.data, "id");
 | 
			
		||||
        this.loading = false;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			@ -218,7 +224,7 @@ export default {
 | 
			
		|||
        delete node.children;
 | 
			
		||||
      }
 | 
			
		||||
      return {
 | 
			
		||||
        id: node.deptId,
 | 
			
		||||
        id: node.id,
 | 
			
		||||
        label: node.deptName,
 | 
			
		||||
        children: node.children
 | 
			
		||||
      };
 | 
			
		||||
| 
						 | 
				
			
			@ -235,7 +241,7 @@ export default {
 | 
			
		|||
    // 表单重置
 | 
			
		||||
    reset() {
 | 
			
		||||
      this.form = {
 | 
			
		||||
        deptId: undefined,
 | 
			
		||||
        id: undefined,
 | 
			
		||||
        parentId: undefined,
 | 
			
		||||
        deptName: undefined,
 | 
			
		||||
        orderNum: undefined,
 | 
			
		||||
| 
						 | 
				
			
			@ -259,31 +265,31 @@ export default {
 | 
			
		|||
    handleAdd(row) {
 | 
			
		||||
      this.reset();
 | 
			
		||||
      if (row != undefined) {
 | 
			
		||||
        this.form.parentId = row.deptId;
 | 
			
		||||
        this.form.parentId = row.id;
 | 
			
		||||
      }
 | 
			
		||||
      this.open = true;
 | 
			
		||||
      this.title = "添加部门";
 | 
			
		||||
      listDept().then(response => {
 | 
			
		||||
	        this.deptOptions = this.handleTree(response.data, "deptId");
 | 
			
		||||
      listDept({pageNum: 'all'}).then(response => {
 | 
			
		||||
	        this.deptOptions = this.handleTree(response.data, "id");
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 修改按钮操作 */
 | 
			
		||||
    handleUpdate(row) {
 | 
			
		||||
      this.reset();
 | 
			
		||||
      getDept(row.deptId).then(response => {
 | 
			
		||||
      getDept(row.id).then(response => {
 | 
			
		||||
        this.form = response.data;
 | 
			
		||||
        this.open = true;
 | 
			
		||||
        this.title = "修改部门";
 | 
			
		||||
      });
 | 
			
		||||
      listDeptExcludeChild(row.deptId).then(response => {
 | 
			
		||||
	        this.deptOptions = this.handleTree(response.data, "deptId");
 | 
			
		||||
      listDeptExcludeChild(row.id).then(response => {
 | 
			
		||||
	        this.deptOptions = this.handleTree(response.data, "id");
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 提交按钮 */
 | 
			
		||||
    submitForm: function() {
 | 
			
		||||
      this.$refs["form"].validate(valid => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          if (this.form.deptId != undefined) {
 | 
			
		||||
          if (this.form.id != undefined) {
 | 
			
		||||
            updateDept(this.form).then(response => {
 | 
			
		||||
              this.msgSuccess("修改成功");
 | 
			
		||||
              this.open = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -306,7 +312,7 @@ export default {
 | 
			
		|||
          cancelButtonText: "取消",
 | 
			
		||||
          type: "warning"
 | 
			
		||||
        }).then(function() {
 | 
			
		||||
          return delDept(row.deptId);
 | 
			
		||||
          return delDept(row.id);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.getList();
 | 
			
		||||
          this.msgSuccess("删除成功");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue