导出无图隐患列表

This commit is contained in:
caoqianming 2021-07-11 16:58:26 +08:00
parent b9a3b9cf58
commit 73ce4d8118
3 changed files with 36 additions and 19 deletions

View File

@ -256,7 +256,7 @@ def exportdoc(a,id):
import re
ILLEGAL_CHARACTERS_RE = re.compile(r'[\000-\010]|[\013-\014]|[\016-\037]')
def exportxlsx(a,objs):
def exportxlsx(a,objs,pic=1):
if a =='yh':
wb = load_workbook(dirname + 'safesite/exportemp/yhdc.xlsx')
sheet = wb.active
@ -265,7 +265,11 @@ def exportxlsx(a,objs):
row_height = 70
#查询数据
yhobjs = objs.order_by('-troubleid')
if yhobjs.count()>100:
if yhobjs.count()>1000:
res = HttpResponse()
res.write('数量超过1000,请查询后导出!')
return res
if pic==1 and yhobjs.count()>100:
res = HttpResponse()
res.write('数量超过100,请查询后导出!')
return res
@ -308,6 +312,7 @@ def exportxlsx(a,objs):
sheet['r'+str(i+4)] = ILLEGAL_CHARACTERS_RE.sub(r'', v['zgms'])
sheet['s'+str(i+4)] = v['shr__name']
sheet['t'+str(i+4)] = v['fcr__name']
if pic==1:
if v['yhtp']:
try:
img = Image(dirname + v['yhtp'][0])

View File

@ -31,6 +31,9 @@
{% if request|has_permission:'b_trouble_exportxls' %}
<a id="exportexcel" onclick="exportyhexcel()">导出Excel</a>
{% endif %}
{% if request|has_permission:'b_trouble_exportxls' %}
<a id="exportexcel" onclick="exportyhexcel2()" class='easyui-linkbutton' data-options="iconCls: 'fa-download',plain:true">导出无图Excel</a>
{% endif %}
</div>
<div id="sdg_yh" class="easyui-dialog" title="筛选条件" style="width:400px;height:420px;"
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
@ -329,6 +332,12 @@
window.open(url);
// $('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
}
function exportyhexcel2() {
var querydata = $('#searchyhff').serializeJSON();
let url = 'troublehandle?a=exportexcel&nopic=1&' + parseParams(querydata)
window.open(url);
// $('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
}
function delyh() {
var row = $('#yhtable').datagrid('getSelected');
if (row) {

View File

@ -2057,6 +2057,9 @@ def troublehandle(req):
a = a.filter(Q(zgbm__in=parts) | Q(fxbm__in=parts, zgbm=None))
if fxrname:
a = a.filter(fxr__name=fxrname)
if req.GET.get('nopic', None):
res = exportxlsx('yh', a, 0)
else:
res = exportxlsx('yh', a)
return res
elif a == 'del':