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