功能变化: 部门导入
parent
b18e35b388
commit
bc6790c631
|
@ -37,6 +37,17 @@ class DeptSerializer(CustomModelSerializer):
|
|||
read_only_fields = ["id"]
|
||||
|
||||
|
||||
class DeptImportSerializer(CustomModelSerializer):
|
||||
"""
|
||||
部门-导入-序列化器
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = Dept
|
||||
fields = '__all__'
|
||||
read_only_fields = ["id"]
|
||||
|
||||
|
||||
class DeptInitSerializer(CustomModelSerializer):
|
||||
"""
|
||||
递归深度获取数信息(用于生成初始化json文件)
|
||||
|
@ -113,8 +124,12 @@ class DeptViewSet(CustomModelViewSet):
|
|||
update_serializer_class = DeptCreateUpdateSerializer
|
||||
filter_fields = ['name', 'id', 'parent']
|
||||
search_fields = []
|
||||
|
||||
# extra_filter_backends = []
|
||||
import_serializer_class = DeptImportSerializer
|
||||
import_field_dict = {
|
||||
"name": "部门名称",
|
||||
"key": "部门标识",
|
||||
}
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
# 如果懒加载,则只返回父级
|
||||
|
|
|
@ -155,9 +155,6 @@ class ImportSerializerMixin:
|
|||
else:
|
||||
filter_dic = {i: ele.get(i) for i in list(set(unique_list)) if ele.get(i) is not None}
|
||||
instance = filter_dic and queryset.filter(**filter_dic).first()
|
||||
print(unique_list)
|
||||
print(filter_dic)
|
||||
print(instance)
|
||||
if instance and not updateSupport:
|
||||
continue
|
||||
if not filter_dic:
|
||||
|
|
|
@ -16,6 +16,11 @@
|
|||
@click="addRow"
|
||||
><i class="el-icon-plus" /> 新增</el-button
|
||||
>
|
||||
<importExcel
|
||||
importApi="api/system/dept/import_data/"
|
||||
v-permission="'Import'"
|
||||
>导入
|
||||
</importExcel>
|
||||
</el-button-group>
|
||||
<crud-toolbar
|
||||
:search.sync="crud.searchOptions.show"
|
||||
|
|
Loading…
Reference in New Issue