功能变化: 加入软删除
parent
f987744bc6
commit
d1ced7d616
|
@ -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', })),
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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,
|
||||
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -14,7 +14,7 @@ export function GetList (query) {
|
|||
return request({
|
||||
url: urlPrefix,
|
||||
method: 'get',
|
||||
params: query
|
||||
params: {...query}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export function DelObj (id) {
|
|||
return request({
|
||||
url: urlPrefix + id + '/',
|
||||
method: 'delete',
|
||||
data: { softDelete: true }
|
||||
data: { soft_delete: true }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue