From d1ced7d6165c2aeed654dd390af00b3deff5afe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Fri, 12 Aug 2022 23:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=98=E5=8C=96:=20?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=BD=AF=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/dvadmin/system/urls.py | 2 ++ backend/dvadmin/utils/models.py | 18 +++++++++++++++++- web/src/install.js | 4 ++-- web/src/main.js | 4 ++++ web/src/views/system/role/api.js | 2 +- web/src/views/system/user/api.js | 2 +- 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/backend/dvadmin/system/urls.py b/backend/dvadmin/system/urls.py index 06fcd9e..6b8c95f 100644 --- a/backend/dvadmin/system/urls.py +++ b/backend/dvadmin/system/urls.py @@ -9,6 +9,7 @@ from dvadmin.system.views.file_list import FileViewSet from dvadmin.system.views.login_log import LoginLogViewSet from dvadmin.system.views.menu import MenuViewSet from dvadmin.system.views.menu_button import MenuButtonViewSet +from dvadmin.system.views.message_center import MessageCenterViewSet from dvadmin.system.views.operation_log import OperationLogViewSet from dvadmin.system.views.role import RoleViewSet from dvadmin.system.views.system_config import SystemConfigViewSet @@ -26,6 +27,7 @@ system_url.register(r'area', AreaViewSet) system_url.register(r'file', FileViewSet) system_url.register(r'api_white_list', ApiWhiteListViewSet) system_url.register(r'system_config', SystemConfigViewSet) +system_url.register(r'message_center',MessageCenterViewSet) urlpatterns = [ path('user/export/', UserViewSet.as_view({'post': 'export_data', })), diff --git a/backend/dvadmin/utils/models.py b/backend/dvadmin/utils/models.py index 2363e92..ecac1a1 100644 --- a/backend/dvadmin/utils/models.py +++ b/backend/dvadmin/utils/models.py @@ -11,6 +11,7 @@ import uuid from django.apps import apps from django.db import models from django.db.models import QuerySet + from application import settings table_prefix = settings.TABLE_PREFIX # 数据库表名前缀 @@ -33,8 +34,23 @@ class SoftDeleteQuerySet(QuerySet): class SoftDeleteManager(models.Manager): """支持软删除""" + def __init__(self, *args, **kwargs): + self.__add_is_del_filter = False + super(SoftDeleteManager, self).__init__(*args, **kwargs) + + def filter(self, *args, **kwargs): + # 考虑是否主动传入is_deleted + if not kwargs.get('is_deleted') is None: + self.__add_is_del_filter = True + return super(SoftDeleteManager, self).filter(*args, **kwargs) + def get_queryset(self): - return SoftDeleteQuerySet(self.model).filter(is_deleted=False) + if self.__add_is_del_filter: + return SoftDeleteQuerySet(self.model, using=self._db).exclude(is_deleted=False) + return SoftDeleteQuerySet(self.model).exclude(is_deleted=True) + + def get_by_natural_key(self,name): + return SoftDeleteQuerySet(self.model).get(username=name) class CoreModel(models.Model): diff --git a/web/src/install.js b/web/src/install.js index 7e6e874..e6e2c96 100644 --- a/web/src/install.js +++ b/web/src/install.js @@ -405,9 +405,9 @@ Vue.prototype.commonEndColumns = function (param = {}) { dict:{ data:[{label:"是",value:true},{label:"否",value:false}] }, - sortable: true, form: { - disabled: !showData.is_deleted.showForm + disabled: !showData.is_deleted.showForm, + } } ] diff --git a/web/src/main.js b/web/src/main.js index e60e997..36b5dfc 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -32,10 +32,14 @@ import 'vxe-table/lib/style.css' // md5加密 import md5 from 'js-md5' +//websocket +import websocket from '@/api/websocket' + // 核心插件 Vue.use(d2Admin) Vue.use(VXETable) Vue.prototype.$md5 = md5 +Vue.prototype.$websocket = websocket new Vue({ router, diff --git a/web/src/views/system/role/api.js b/web/src/views/system/role/api.js index 5633a73..f215c52 100644 --- a/web/src/views/system/role/api.js +++ b/web/src/views/system/role/api.js @@ -14,7 +14,7 @@ export function GetList (query) { return request({ url: urlPrefix, method: 'get', - params: query + params: {...query} }) } diff --git a/web/src/views/system/user/api.js b/web/src/views/system/user/api.js index f85500a..8f88c54 100644 --- a/web/src/views/system/user/api.js +++ b/web/src/views/system/user/api.js @@ -29,7 +29,7 @@ export function DelObj (id) { return request({ url: urlPrefix + id + '/', method: 'delete', - data: { softDelete: true } + data: { soft_delete: true } }) }