fix(用户管理): 🐛 用户管理新增
This commit is contained in:
@@ -13,10 +13,14 @@ 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__"
|
||||
@@ -45,3 +49,23 @@ class AreaViewSet(CustomModelViewSet):
|
||||
queryset = Area.objects.all()
|
||||
serializer_class = AreaSerializer
|
||||
extra_filter_class = []
|
||||
|
||||
def get_queryset(self):
|
||||
self.request.query_params._mutable = True
|
||||
params = self.request.query_params
|
||||
pcode = params.get('pcode', None)
|
||||
page = params.get('page', None)
|
||||
limit = params.get('limit', None)
|
||||
if page:
|
||||
del params['page']
|
||||
if limit:
|
||||
del params['limit']
|
||||
if params:
|
||||
if pcode:
|
||||
queryset = self.queryset.filter(enable=True, pcode=pcode)
|
||||
else:
|
||||
queryset = self.queryset.filter(enable=True)
|
||||
else:
|
||||
queryset = self.queryset.filter(enable=True, pcode__isnull=True)
|
||||
return queryset
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
|
||||
title: '序号',
|
||||
form: { show: false },
|
||||
column: {
|
||||
//type: 'index',
|
||||
type: 'index',
|
||||
align: 'center',
|
||||
width: '70px',
|
||||
columnSetDisabled: true, //禁止在列设置中选择
|
||||
@@ -164,9 +164,15 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
|
||||
}
|
||||
}),
|
||||
form: {
|
||||
rules: [ // 表单校验规则
|
||||
{
|
||||
required: true,
|
||||
message: '必填项'
|
||||
}
|
||||
],
|
||||
component: {
|
||||
filterable: true,
|
||||
placeholder: '请选择角色',
|
||||
placeholder: '请选择',
|
||||
props: {
|
||||
props: {
|
||||
value: "id",
|
||||
@@ -181,7 +187,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
|
||||
search: {
|
||||
disabled: true
|
||||
},
|
||||
type: 'dict-tree',
|
||||
type: 'dict-select',
|
||||
dict: dict({
|
||||
url: '/api/system/role/',
|
||||
value: 'id',
|
||||
@@ -200,15 +206,16 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
|
||||
}
|
||||
}),
|
||||
form: {
|
||||
rules: [ // 表单校验规则
|
||||
{
|
||||
required: true,
|
||||
message: '必填项'
|
||||
}
|
||||
],
|
||||
component: {
|
||||
multiple: true,
|
||||
filterable: true,
|
||||
placeholder: '请选择角色',
|
||||
props: {
|
||||
props: {
|
||||
value: "id",
|
||||
label: "name",
|
||||
}
|
||||
}
|
||||
placeholder: '请选择角色'
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -303,18 +310,8 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
|
||||
avatar: {
|
||||
title: '头像',
|
||||
type: 'avatar-cropper',
|
||||
form: {
|
||||
component: {
|
||||
props: {
|
||||
elProps: { // 与el-uploader 配置一致
|
||||
multiple: false,
|
||||
limit: 1 // 限制5个文件
|
||||
},
|
||||
sizeLimit: 500 * 1024 // 不能超过限制
|
||||
},
|
||||
span: 24
|
||||
},
|
||||
helper: '限制文件大小不能超过500k'
|
||||
form:{
|
||||
show:false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user