feat(20240701_FieldPermission): 列权限管控
- 地区管理:增加列权限管控 - 登录日志:增加列权限管控
This commit is contained in:
@@ -35,6 +35,7 @@ system_url.register(r'message_center', MessageCenterViewSet)
|
||||
system_url.register(r'role_menu_button_permission', RoleMenuButtonPermissionViewSet)
|
||||
system_url.register(r'role_menu_permission', RoleMenuPermissionViewSet)
|
||||
system_url.register(r'column', MenuFieldViewSet)
|
||||
system_url.register(r'login_log', LoginLogViewSet)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
@@ -44,8 +45,8 @@ urlpatterns = [
|
||||
path('system_config/get_association_table/', SystemConfigViewSet.as_view({'get': 'get_association_table'})),
|
||||
path('system_config/get_table_data/<int:pk>/', SystemConfigViewSet.as_view({'get': 'get_table_data'})),
|
||||
path('system_config/get_relation_info/', SystemConfigViewSet.as_view({'get': 'get_relation_info'})),
|
||||
path('login_log/', LoginLogViewSet.as_view({'get': 'list'})),
|
||||
path('login_log/<int:pk>/', LoginLogViewSet.as_view({'get': 'retrieve'})),
|
||||
# path('login_log/', LoginLogViewSet.as_view({'get': 'list'})),
|
||||
# path('login_log/<int:pk>/', LoginLogViewSet.as_view({'get': 'retrieve'})),
|
||||
path('dept_lazy_tree/', DeptViewSet.as_view({'get': 'dept_lazy_tree'})),
|
||||
path('clause/privacy.html', PrivacyView.as_view()),
|
||||
path('clause/terms_service.html', TermsServiceView.as_view()),
|
||||
|
||||
@@ -3,6 +3,7 @@ from django.db.models import Q
|
||||
from rest_framework import serializers
|
||||
|
||||
from dvadmin.system.models import Area
|
||||
from dvadmin.utils.field_permission import FieldPermissionMixin
|
||||
from dvadmin.utils.json_response import SuccessResponse
|
||||
from dvadmin.utils.serializers import CustomModelSerializer
|
||||
from dvadmin.utils.viewset import CustomModelViewSet
|
||||
@@ -14,13 +15,16 @@ class AreaSerializer(CustomModelSerializer):
|
||||
"""
|
||||
pcode_count = serializers.SerializerMethodField(read_only=True)
|
||||
hasChild = serializers.SerializerMethodField()
|
||||
|
||||
def get_pcode_count(self, instance: Area):
|
||||
return Area.objects.filter(pcode=instance).count()
|
||||
|
||||
def get_hasChild(self, instance):
|
||||
hasChild = Area.objects.filter(pcode=instance.code)
|
||||
if hasChild:
|
||||
return True
|
||||
return False
|
||||
|
||||
class Meta:
|
||||
model = Area
|
||||
fields = "__all__"
|
||||
@@ -37,7 +41,7 @@ class AreaCreateUpdateSerializer(CustomModelSerializer):
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class AreaViewSet(CustomModelViewSet):
|
||||
class AreaViewSet(CustomModelViewSet, FieldPermissionMixin):
|
||||
"""
|
||||
地区管理接口
|
||||
list:查询
|
||||
@@ -65,4 +69,3 @@ class AreaViewSet(CustomModelViewSet):
|
||||
else:
|
||||
queryset = self.queryset.filter(enable=True)
|
||||
return queryset
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
@Remark: 按钮权限管理
|
||||
"""
|
||||
from dvadmin.system.models import LoginLog
|
||||
from dvadmin.utils.field_permission import FieldPermissionMixin
|
||||
from dvadmin.utils.serializers import CustomModelSerializer
|
||||
from dvadmin.utils.viewset import CustomModelViewSet
|
||||
|
||||
@@ -22,7 +23,7 @@ class LoginLogSerializer(CustomModelSerializer):
|
||||
read_only_fields = ["id"]
|
||||
|
||||
|
||||
class LoginLogViewSet(CustomModelViewSet):
|
||||
class LoginLogViewSet(CustomModelViewSet, FieldPermissionMixin):
|
||||
"""
|
||||
登录日志接口
|
||||
list:查询
|
||||
@@ -33,4 +34,4 @@ class LoginLogViewSet(CustomModelViewSet):
|
||||
"""
|
||||
queryset = LoginLog.objects.all()
|
||||
serializer_class = LoginLogSerializer
|
||||
extra_filter_class = []
|
||||
# extra_filter_class = []
|
||||
|
||||
@@ -39,3 +39,9 @@ export function DelObj(id: DelReq) {
|
||||
data: { id },
|
||||
});
|
||||
}
|
||||
export function GetPermission() {
|
||||
return request({
|
||||
url: apiPrefix + 'field_permission/',
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,14 +5,21 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="areas">
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { onMounted } from 'vue';
|
||||
import { useFs } from '@fast-crud/fast-crud';
|
||||
import { createCrudOptions } from './crud';
|
||||
import { GetPermission } from './api';
|
||||
import { handleColumnPermission } from '/@/utils/columnPermission';
|
||||
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions });
|
||||
const { crudBinding, crudRef, crudExpose, crudOptions, resetCrudOptions } = useFs({ createCrudOptions });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
// 设置列权限
|
||||
const newOptions = await handleColumnPermission(GetPermission, crudOptions);
|
||||
//重置crudBinding
|
||||
resetCrudOptions(newOptions);
|
||||
// 刷新
|
||||
crudExpose.doRefresh();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -39,3 +39,10 @@ export function DelObj(id: DelReq) {
|
||||
data: { id },
|
||||
});
|
||||
}
|
||||
|
||||
export function GetPermission() {
|
||||
return request({
|
||||
url: apiPrefix + 'field_permission/',
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,14 +5,21 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="loginLog">
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { onMounted } from 'vue';
|
||||
import { useFs } from '@fast-crud/fast-crud';
|
||||
import { createCrudOptions } from './crud';
|
||||
import { GetPermission } from './api';
|
||||
import { handleColumnPermission } from '/@/utils/columnPermission';
|
||||
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions });
|
||||
const { crudBinding, crudRef, crudExpose, crudOptions, resetCrudOptions } = useFs({ createCrudOptions });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
// 设置列权限
|
||||
const newOptions = await handleColumnPermission(GetPermission, crudOptions);
|
||||
//重置crudBinding
|
||||
resetCrudOptions(newOptions);
|
||||
// 刷新
|
||||
crudExpose.doRefresh();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -200,11 +200,9 @@ export const createCrudOptions = function ({crudExpose}: CreateCrudOptionsProps)
|
||||
component: {
|
||||
span: 24,
|
||||
props: {
|
||||
elProps: {
|
||||
allowCreate: true,
|
||||
filterable: true,
|
||||
clearable: true,
|
||||
},
|
||||
allowCreate: true,
|
||||
filterable: true,
|
||||
clearable: true,
|
||||
},
|
||||
},
|
||||
itemProps: {
|
||||
|
||||
Reference in New Issue
Block a user