daoru
This commit is contained in:
parent
1e85f59865
commit
855260497f
|
@ -40,7 +40,7 @@
|
||||||
<el-upload
|
<el-upload
|
||||||
:action="upUrl"
|
:action="upUrl"
|
||||||
:on-success="handleUploadSuccess"
|
:on-success="handleUploadSuccess"
|
||||||
accept=".rar,.zip"
|
accept=".zip"
|
||||||
:headers="upHeaders"
|
:headers="upHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
>
|
>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<el-upload
|
<el-upload
|
||||||
:action="upUrl"
|
:action="upUrl"
|
||||||
:on-success="handleUploadSuccess2"
|
:on-success="handleUploadSuccess2"
|
||||||
accept=".rar"
|
accept=".zip"
|
||||||
:headers="upHeaders"
|
:headers="upHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
>
|
>
|
||||||
|
@ -83,6 +83,9 @@
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
<el-card style="margin-top: 6px">
|
<el-card style="margin-top: 6px">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>部门</span>
|
||||||
|
</div>
|
||||||
<el-table
|
<el-table
|
||||||
v-loading="listLoading"
|
v-loading="listLoading"
|
||||||
:data="cmaList.results"
|
:data="cmaList.results"
|
||||||
|
@ -91,7 +94,7 @@
|
||||||
fit
|
fit
|
||||||
stripe
|
stripe
|
||||||
highlight-current-row
|
highlight-current-row
|
||||||
max-height="320"
|
max-height="300"
|
||||||
ref="filterTable"
|
ref="filterTable"
|
||||||
@filter-change="filterChange"
|
@filter-change="filterChange"
|
||||||
>
|
>
|
||||||
|
@ -167,6 +170,9 @@
|
||||||
/>
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card style="margin-top: 6px">
|
<el-card style="margin-top: 6px">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>部门</span>
|
||||||
|
</div>
|
||||||
<el-table
|
<el-table
|
||||||
v-loading="listLoading2"
|
v-loading="listLoading2"
|
||||||
:data="cnasList.results"
|
:data="cnasList.results"
|
||||||
|
@ -175,7 +181,7 @@
|
||||||
fit
|
fit
|
||||||
stripe
|
stripe
|
||||||
highlight-current-row
|
highlight-current-row
|
||||||
max-height="320"
|
max-height="300"
|
||||||
>
|
>
|
||||||
<el-table-column type="index" width="50" />
|
<el-table-column type="index" width="50" />
|
||||||
<el-table-column align="header-center" label="类别名称">
|
<el-table-column align="header-center" label="类别名称">
|
||||||
|
@ -203,7 +209,7 @@
|
||||||
><span v-html="showlight(scope.row.bztk)"></span
|
><span v-html="showlight(scope.row.bztk)"></span
|
||||||
></template>
|
></template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="header-center" label="所属中心">
|
<el-table-column align="header-center" label="所属地点">
|
||||||
<template slot-scope="scope"
|
<template slot-scope="scope"
|
||||||
><span v-html="showlight(scope.row.sszx)"></span
|
><span v-html="showlight(scope.row.sszx)"></span
|
||||||
></template>
|
></template>
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<el-upload
|
<el-upload
|
||||||
:action="upUrl"
|
:action="upUrl"
|
||||||
:on-success="handleUploadSuccess"
|
:on-success="handleUploadSuccess"
|
||||||
accept=".rar,.zip"
|
accept=".zip"
|
||||||
:headers="upHeaders"
|
:headers="upHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
>
|
>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import zipfile
|
||||||
import rarfile
|
import rarfile
|
||||||
from openpyxl import Workbook, load_workbook
|
from openpyxl import Workbook, load_workbook
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
|
import time
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
class CMAViewSet(ModelViewSet):
|
class CMAViewSet(ModelViewSet):
|
||||||
"""
|
"""
|
||||||
|
@ -49,7 +50,7 @@ class CMAViewSet(ModelViewSet):
|
||||||
import os
|
import os
|
||||||
if fullpath.endswith('.rar'):
|
if fullpath.endswith('.rar'):
|
||||||
rar = rarfile.RarFile(fullpath)
|
rar = rarfile.RarFile(fullpath)
|
||||||
fulldir = fullpath.replace('.rar','')
|
fulldir = fullpath.replace('.rar',time.strftime('%Y%m%d%H%M%S'))
|
||||||
os.mkdir(fulldir)
|
os.mkdir(fulldir)
|
||||||
os.chdir(fulldir)
|
os.chdir(fulldir)
|
||||||
rar.extractall()
|
rar.extractall()
|
||||||
|
@ -58,10 +59,10 @@ class CMAViewSet(ModelViewSet):
|
||||||
for root, dirs, files in os.walk(fulldir):
|
for root, dirs, files in os.walk(fulldir):
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.endswith('.xls'):
|
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'):
|
elif fullpath.endswith('.zip'):
|
||||||
fulldir = fullpath.replace('.zip','')
|
fulldir = fullpath.replace('.zip',time.strftime('%Y%m%d%H%M%S'))
|
||||||
os.mkdir(fulldir)
|
os.mkdir(fulldir)
|
||||||
os.chdir(fulldir)
|
os.chdir(fulldir)
|
||||||
CMA.objects.filter(type='center').delete()
|
CMA.objects.filter(type='center').delete()
|
||||||
|
@ -69,9 +70,9 @@ class CMAViewSet(ModelViewSet):
|
||||||
zzz.extractall(fulldir)
|
zzz.extractall(fulldir)
|
||||||
for root, dirs, files in os.walk(fulldir):
|
for root, dirs, files in os.walk(fulldir):
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.endswith('.xls'):
|
if f.endswith('.xlsx'):
|
||||||
return Response('不支持旧xls格式', status = status.HTTP_400_BAD_REQUEST)
|
|
||||||
import_cma(f.encode('cp437').decode('gbk'), os.path.join(root,f))
|
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)
|
return Response(status = status.HTTP_200_OK)
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, url_path='import2', url_name='cma_import2', perms_map = {'post':'cma_import2'})
|
@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
|
import os
|
||||||
if fullpath.endswith('.rar'):
|
if fullpath.endswith('.rar'):
|
||||||
rar = rarfile.RarFile(fullpath)
|
rar = rarfile.RarFile(fullpath)
|
||||||
fulldir = fullpath.replace('.rar','')
|
fulldir = fullpath.replace('.rar',time.strftime('%Y%m%d%H%M%S'))
|
||||||
os.mkdir(fulldir)
|
os.mkdir(fulldir)
|
||||||
os.chdir(fulldir)
|
os.chdir(fulldir)
|
||||||
rar.extractall()
|
rar.extractall()
|
||||||
|
@ -92,11 +93,11 @@ class CMAViewSet(ModelViewSet):
|
||||||
# CMA.objects.filter(type='sub').delete()
|
# CMA.objects.filter(type='sub').delete()
|
||||||
for root, dirs, files in os.walk(fulldir):
|
for root, dirs, files in os.walk(fulldir):
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.endswith('.xls'):
|
if f.endswith('.xlsx'):
|
||||||
return Response('不支持旧xls格式', status = status.HTTP_400_BAD_REQUEST)
|
|
||||||
import_cma2(f, os.path.join(root,f))
|
import_cma2(f, os.path.join(root,f))
|
||||||
|
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
|
||||||
elif fullpath.endswith('.zip'):
|
elif fullpath.endswith('.zip'):
|
||||||
fulldir = fullpath.replace('.zip','')
|
fulldir = fullpath.replace('.zip',time.strftime('%Y%m%d%H%M%S'))
|
||||||
os.mkdir(fulldir)
|
os.mkdir(fulldir)
|
||||||
os.chdir(fulldir)
|
os.chdir(fulldir)
|
||||||
# CMA.objects.filter(type='sub').delete()
|
# CMA.objects.filter(type='sub').delete()
|
||||||
|
@ -104,9 +105,9 @@ class CMAViewSet(ModelViewSet):
|
||||||
zzz.extractall(fulldir)
|
zzz.extractall(fulldir)
|
||||||
for root, dirs, files in os.walk(fulldir):
|
for root, dirs, files in os.walk(fulldir):
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.endswith('.xls'):
|
if f.endswith('.xlsx'):
|
||||||
return Response('不支持旧xls格式', status = status.HTTP_400_BAD_REQUEST)
|
|
||||||
import_cma2(f.encode('cp437').decode('gbk'), os.path.join(root,f))
|
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)
|
return Response(status = status.HTTP_200_OK)
|
||||||
|
|
||||||
class QualificationViewSet(ModelViewSet):
|
class QualificationViewSet(ModelViewSet):
|
||||||
|
|
Loading…
Reference in New Issue