diff --git a/spug_api/apps/host/views.py b/spug_api/apps/host/views.py index cf90cf1..0d905f7 100644 --- a/spug_api/apps/host/views.py +++ b/spug_api/apps/host/views.py @@ -97,7 +97,7 @@ def post_import(request): password = request.POST.get('password') file = request.FILES['file'] ws = load_workbook(file, read_only=True)['Sheet1'] - summary = {'invalid': [], 'skip': [], 'fail': [], 'network': [], 'success': []} + summary = {'invalid': [], 'skip': [], 'fail': [], 'network': [], 'repeat': [], 'success': []} for i, row in enumerate(ws.rows): if i == 0: # 第1行是表头 略过 continue @@ -127,6 +127,9 @@ def post_import(request): except socket.error: summary['network'].append(i) continue + if Host.objects.filter(name=data.name, deleted_by_id__isnull=True).exists(): + summary['repeat'].append(i) + continue host = Host.objects.create(created_by=request.user, **data) if request.user.role: request.user.role.add_host_perm(host.id) diff --git a/spug_web/src/pages/host/Import.js b/spug_web/src/pages/host/Import.js index c9169b3..07773f2 100644 --- a/spug_web/src/pages/host/Import.js +++ b/spug_web/src/pages/host/Import.js @@ -29,7 +29,7 @@ class ComImport extends React.Component { .then(res => { Modal.info({ title: '导入结果', - content:
+ content: {res.success.length} {res['fail'].length > 0 && {res['fail'].length} @@ -43,6 +43,9 @@ class ComImport extends React.Component { {res['invalid'].length > 0 && {res['invalid'].length} } + {res['repeat'].length > 0 && + {res['repeat'].length} + } }) })