导出无图隐患列表
This commit is contained in:
parent
b9a3b9cf58
commit
73ce4d8118
|
@ -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,22 +312,23 @@ 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 v['yhtp']:
|
||||
try:
|
||||
img = Image(dirname + v['yhtp'][0])
|
||||
if img.format!='mpo':
|
||||
img.width, img.height = (90, 90) #这两个属性分别是对应添加图片的宽高
|
||||
sheet.add_image(img, 'u'+str(i+4))
|
||||
except:
|
||||
pass
|
||||
if v['zghtp']:
|
||||
try:
|
||||
img = Image(dirname + v['zghtp'][0])
|
||||
if img.format!='mpo':
|
||||
img.width, img.height = (90, 90) #这两个属性分别是对应添加图片的宽高
|
||||
sheet.add_image(img, 'w'+str(i+4))
|
||||
except:
|
||||
pass
|
||||
if pic==1:
|
||||
if v['yhtp']:
|
||||
try:
|
||||
img = Image(dirname + v['yhtp'][0])
|
||||
if img.format!='mpo':
|
||||
img.width, img.height = (90, 90) #这两个属性分别是对应添加图片的宽高
|
||||
sheet.add_image(img, 'u'+str(i+4))
|
||||
except:
|
||||
pass
|
||||
if v['zghtp']:
|
||||
try:
|
||||
img = Image(dirname + v['zghtp'][0])
|
||||
if img.format!='mpo':
|
||||
img.width, img.height = (90, 90) #这两个属性分别是对应添加图片的宽高
|
||||
sheet.add_image(img, 'w'+str(i+4))
|
||||
except:
|
||||
pass
|
||||
nowtime = datetime.now().strftime('%Y%m%d%H%M%S')
|
||||
sheet['b1'] = nowtime
|
||||
filename = 'YHS' + nowtime
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -2057,7 +2057,10 @@ def troublehandle(req):
|
|||
a = a.filter(Q(zgbm__in=parts) | Q(fxbm__in=parts, zgbm=None))
|
||||
if fxrname:
|
||||
a = a.filter(fxr__name=fxrname)
|
||||
res = exportxlsx('yh', a)
|
||||
if req.GET.get('nopic', None):
|
||||
res = exportxlsx('yh', a, 0)
|
||||
else:
|
||||
res = exportxlsx('yh', a)
|
||||
return res
|
||||
elif a == 'del':
|
||||
userid = req.session['userid']
|
||||
|
|
Loading…
Reference in New Issue