This commit is contained in:
caoqianming 2020-09-29 09:50:04 +08:00
parent 1e85f59865
commit 855260497f
3 changed files with 28 additions and 21 deletions

View File

@ -40,7 +40,7 @@
<el-upload
:action="upUrl"
:on-success="handleUploadSuccess"
accept=".rar,.zip"
accept=".zip"
:headers="upHeaders"
:show-file-list="false"
>
@ -66,7 +66,7 @@
<el-upload
:action="upUrl"
:on-success="handleUploadSuccess2"
accept=".rar"
accept=".zip"
:headers="upHeaders"
:show-file-list="false"
>
@ -83,6 +83,9 @@
</el-popover>
</div>
<el-card style="margin-top: 6px">
<div slot="header" class="clearfix">
<span>部门</span>
</div>
<el-table
v-loading="listLoading"
:data="cmaList.results"
@ -91,7 +94,7 @@
fit
stripe
highlight-current-row
max-height="320"
max-height="300"
ref="filterTable"
@filter-change="filterChange"
>
@ -167,6 +170,9 @@
/>
</el-card>
<el-card style="margin-top: 6px">
<div slot="header" class="clearfix">
<span>部门</span>
</div>
<el-table
v-loading="listLoading2"
:data="cnasList.results"
@ -175,7 +181,7 @@
fit
stripe
highlight-current-row
max-height="320"
max-height="300"
>
<el-table-column type="index" width="50" />
<el-table-column align="header-center" label="类别名称">
@ -203,7 +209,7 @@
><span v-html="showlight(scope.row.bztk)"></span
></template>
</el-table-column>
<el-table-column align="header-center" label="所属中心">
<el-table-column align="header-center" label="所属地点">
<template slot-scope="scope"
><span v-html="showlight(scope.row.sszx)"></span
></template>

View File

@ -58,7 +58,7 @@
<el-upload
:action="upUrl"
:on-success="handleUploadSuccess"
accept=".rar,.zip"
accept=".zip"
:headers="upHeaders"
:show-file-list="false"
>

View File

@ -10,6 +10,7 @@ import zipfile
import rarfile
from openpyxl import Workbook, load_workbook
from django.db.models import Count
import time
# Create your views here.
class CMAViewSet(ModelViewSet):
"""
@ -49,7 +50,7 @@ class CMAViewSet(ModelViewSet):
import os
if fullpath.endswith('.rar'):
rar = rarfile.RarFile(fullpath)
fulldir = fullpath.replace('.rar','')
fulldir = fullpath.replace('.rar',time.strftime('%Y%m%d%H%M%S'))
os.mkdir(fulldir)
os.chdir(fulldir)
rar.extractall()
@ -58,10 +59,10 @@ class CMAViewSet(ModelViewSet):
for root, dirs, files in os.walk(fulldir):
for f in files:
if f.endswith('.xls'):
return Response('不支持旧xls格式', status = status.HTTP_400_BAD_REQUEST)
import_cma(f, os.path.join(root,f))
import_cma(f, os.path.join(root,f))
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
elif fullpath.endswith('.zip'):
fulldir = fullpath.replace('.zip','')
fulldir = fullpath.replace('.zip',time.strftime('%Y%m%d%H%M%S'))
os.mkdir(fulldir)
os.chdir(fulldir)
CMA.objects.filter(type='center').delete()
@ -69,9 +70,9 @@ class CMAViewSet(ModelViewSet):
zzz.extractall(fulldir)
for root, dirs, files in os.walk(fulldir):
for f in files:
if f.endswith('.xls'):
return Response('不支持旧xls格式', status = status.HTTP_400_BAD_REQUEST)
import_cma(f.encode('cp437').decode('gbk'), os.path.join(root,f))
if f.endswith('.xlsx'):
import_cma(f.encode('cp437').decode('gbk'), os.path.join(root,f))
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
return Response(status = status.HTTP_200_OK)
@action(methods=['post'], detail=False, url_path='import2', url_name='cma_import2', perms_map = {'post':'cma_import2'})
@ -84,7 +85,7 @@ class CMAViewSet(ModelViewSet):
import os
if fullpath.endswith('.rar'):
rar = rarfile.RarFile(fullpath)
fulldir = fullpath.replace('.rar','')
fulldir = fullpath.replace('.rar',time.strftime('%Y%m%d%H%M%S'))
os.mkdir(fulldir)
os.chdir(fulldir)
rar.extractall()
@ -92,11 +93,11 @@ class CMAViewSet(ModelViewSet):
# CMA.objects.filter(type='sub').delete()
for root, dirs, files in os.walk(fulldir):
for f in files:
if f.endswith('.xls'):
return Response('不支持旧xls格式', status = status.HTTP_400_BAD_REQUEST)
import_cma2(f, os.path.join(root,f))
if f.endswith('.xlsx'):
import_cma2(f, os.path.join(root,f))
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
elif fullpath.endswith('.zip'):
fulldir = fullpath.replace('.zip','')
fulldir = fullpath.replace('.zip',time.strftime('%Y%m%d%H%M%S'))
os.mkdir(fulldir)
os.chdir(fulldir)
# CMA.objects.filter(type='sub').delete()
@ -104,9 +105,9 @@ class CMAViewSet(ModelViewSet):
zzz.extractall(fulldir)
for root, dirs, files in os.walk(fulldir):
for f in files:
if f.endswith('.xls'):
return Response('不支持旧xls格式', status = status.HTTP_400_BAD_REQUEST)
import_cma2(f.encode('cp437').decode('gbk'), os.path.join(root,f))
if f.endswith('.xlsx'):
import_cma2(f.encode('cp437').decode('gbk'), os.path.join(root,f))
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
return Response(status = status.HTTP_200_OK)
class QualificationViewSet(ModelViewSet):