export sbs
This commit is contained in:
parent
cc3ff02701
commit
282090a8fc
|
@ -85,7 +85,7 @@ DATABASES = {
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
'NAME': 'safedb',
|
'NAME': 'safedb',
|
||||||
'USER':'postgres',
|
'USER':'postgres',
|
||||||
'PASSWORD':'0000',
|
'PASSWORD':'cTc1111Qa',
|
||||||
'HOST':'114.115.210.98',
|
'HOST':'114.115.210.98',
|
||||||
'PORT':'5432',
|
'PORT':'5432',
|
||||||
'CONN_MAX_AGE': 600,
|
'CONN_MAX_AGE': 600,
|
||||||
|
@ -224,4 +224,4 @@ LOGGING = {
|
||||||
'propagate': True
|
'propagate': True
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -609,7 +609,7 @@ def exportxlsx(a,objs):
|
||||||
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
||||||
res.write(output.getvalue())
|
res.write(output.getvalue())
|
||||||
return res
|
return res
|
||||||
elif a == 'xj':
|
elif a == 'xj':#巡检记录
|
||||||
#查询数据
|
#查询数据
|
||||||
xjlist = objs.values('id','state','content','creattime','equipment__num','equipment__name','equipment__area__name','user__name','user__ubelongpart__partname','trouble__yhzt','trouble__yhnum','trouble__yhms')
|
xjlist = objs.values('id','state','content','creattime','equipment__num','equipment__name','equipment__area__name','user__name','user__ubelongpart__partname','trouble__yhzt','trouble__yhnum','trouble__yhms')
|
||||||
wb = load_workbook(dirname + 'safesite/exportemp/xj.xlsx')
|
wb = load_workbook(dirname + 'safesite/exportemp/xj.xlsx')
|
||||||
|
@ -637,6 +637,28 @@ def exportxlsx(a,objs):
|
||||||
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
||||||
res.write(output.getvalue())
|
res.write(output.getvalue())
|
||||||
return res
|
return res
|
||||||
|
elif a == 'equipment':#设备
|
||||||
|
#查询数据
|
||||||
|
wb = load_workbook(dirname + 'safesite/exportemp/equipment.xlsx')
|
||||||
|
sheet = wb.active
|
||||||
|
for i, x in enumerate(objs):
|
||||||
|
num = str(i+3)
|
||||||
|
sheet['a'+num] = x.name
|
||||||
|
sheet['b'+num] = x.catename
|
||||||
|
sheet['c'+num] = x.type
|
||||||
|
sheet['d'+num] = x.area.name
|
||||||
|
sheet['e'+num] = '正常' if x.state==1 else '异常'
|
||||||
|
sheet['f'+num] = 'https://safeyun.ctcshe.com/miniprogram/equipment?id='+str(x.id)
|
||||||
|
nowtime = datetime.now().strftime('%Y%m%d%H%M%S')
|
||||||
|
sheet['b1'] = nowtime
|
||||||
|
filename = 'SBS' + nowtime
|
||||||
|
output = BytesIO()
|
||||||
|
wb.save(output)
|
||||||
|
output.seek(0)
|
||||||
|
res = HttpResponse(content_type='application/vnd.ms-excel')
|
||||||
|
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
||||||
|
res.write(output.getvalue())
|
||||||
|
return res
|
||||||
|
|
||||||
def exportyjdoc(vl):
|
def exportyjdoc(vl):
|
||||||
doc = DocxTemplate(dirname + "safesite/exportemp/fxbg.docx")
|
doc = DocxTemplate(dirname + "safesite/exportemp/fxbg.docx")
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -29,6 +29,7 @@
|
||||||
<label>设备名称</label><input name='name' id='sname'
|
<label>设备名称</label><input name='name' id='sname'
|
||||||
class="easyui-textbox" >
|
class="easyui-textbox" >
|
||||||
<a id="sbsearch" onclick="sbsearch()" class="easyui-linkbutton" data-options="iconCls: 'fa-search',plain:true">查询</a>
|
<a id="sbsearch" onclick="sbsearch()" class="easyui-linkbutton" data-options="iconCls: 'fa-search',plain:true">查询</a>
|
||||||
|
<a id="exportsbexcel" onclick="exportsbexcel()" class="easyui-linkbutton" data-options="iconCls: 'fa-download',plain:true">导出Excel</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -254,9 +255,6 @@
|
||||||
else {
|
else {
|
||||||
$.messager.alert('提示', '未选择数据!');
|
$.messager.alert('提示', '未选择数据!');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
function exportsbexcel(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
function sbsearch(){
|
function sbsearch(){
|
||||||
var querydata = $('#searchsbff').serializeJSON();
|
var querydata = $('#searchsbff').serializeJSON();
|
||||||
|
@ -264,6 +262,11 @@
|
||||||
$('#sbtable').datagrid('load',querydata);
|
$('#sbtable').datagrid('load',querydata);
|
||||||
//$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
//$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
||||||
}
|
}
|
||||||
|
function exportsbexcel() {
|
||||||
|
var querydata = $('#searchsbff').serializeJSON();
|
||||||
|
let url = 'api/equipment?a=listall&b=exportexcel&'+parseParams(querydata)
|
||||||
|
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
||||||
|
}
|
||||||
function addsb(){
|
function addsb(){
|
||||||
$('#sbff').form('clear')
|
$('#sbff').form('clear')
|
||||||
$('#sbtable').datagrid('clearSelections');
|
$('#sbtable').datagrid('clearSelections');
|
||||||
|
|
|
@ -5371,19 +5371,22 @@ def apiequipment(req):
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
companyid = getcompany(userid)
|
companyid = getcompany(userid)
|
||||||
if a=='listall':
|
if a=='listall':
|
||||||
a = Equipment.objects.filter(deletemark=1,usecomp__partid=companyid)
|
objs = Equipment.objects.filter(deletemark=1,usecomp__partid=companyid)
|
||||||
if req.GET.get('area',False):
|
if req.GET.get('area',False):
|
||||||
a = a.filter(area__id=req.GET.get('area'))
|
objs = objs.filter(area__id=req.GET.get('area'))
|
||||||
if req.GET.get('cate'):
|
if req.GET.get('cate'):
|
||||||
a = a.filter(cate__dickeyid=req.GET.get('cate'))
|
objs = objs.filter(cate__dickeyid=req.GET.get('cate'))
|
||||||
if req.GET.get('state'):
|
if req.GET.get('state'):
|
||||||
a = a.filter(state=req.GET.get('state'))
|
objs = objs.filter(state=req.GET.get('state'))
|
||||||
if req.GET.get('name'):
|
if req.GET.get('name'):
|
||||||
a = a.filter(name__contains=req.GET.get('name'))
|
objs = objs.filter(name__contains=req.GET.get('name'))
|
||||||
total = a.count()
|
if req.GET.get('b',None) == 'exportexcel':
|
||||||
|
res = exportxlsx('equipment',objs)#导出设备列表
|
||||||
|
return res
|
||||||
|
total = objs.count()
|
||||||
startnum,endnum=fenye(req)
|
startnum,endnum=fenye(req)
|
||||||
a = a.order_by('num')[startnum:endnum].values('id','num','name','type','oem','udate','place','istz','iskey','state','cate__dickeyname','area__name')
|
objs = objs.order_by('num')[startnum:endnum].values('id','num','name','type','oem','udate','place','istz','iskey','state','cate__dickeyname','area__name')
|
||||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
return HttpResponse(transjson(total,objs),content_type="application/json")
|
||||||
elif a == 'update':
|
elif a == 'update':
|
||||||
data = json.loads(req.body.decode('utf-8'))
|
data = json.loads(req.body.decode('utf-8'))
|
||||||
id = data['id']
|
id = data['id']
|
||||||
|
|
Loading…
Reference in New Issue