本文共 20134 字,大约阅读时间需要 67 分钟。
{% extends 'base.html' %}
{% block title %}
<script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script>
<link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/static/style/authority/jquery.fancybox-1.3.4.css" media="screen"></link> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script><div id="container">
<div class="ui_content"> <div class="ui_text_indent"> <div id="box_border"> <div id="box_top">搜索</div> 软件名字 <input type="text" id="mname" name="mname" value="{ { mname }}" class="ui_input_txt02" /> </div> <div id="box_top">新增/编辑</div> <form id="submitForm" name="submitForm" method="post" action="add_software.html"> <input type="hidden" id="softwareid" name="softwareid"/> 软件名字 <input type="text" id="softwarename" name="softwarename" class="ui_input_txt02" /> 授权数 <input type="text" id="softwarelicense_num" name="softwarelicense_num" class="ui_input_txt02" /> 版本号 <input type="text" id="softwareversion" name="softwareversion" class="ui_input_txt02" /> </div> <div id="box_bottom"> <div class="pagination"> <span class="current"> {% if softwarelist.has_previous %} <a href="javascript:void(0)" οnclick="search_software({ { softwarelist.previous_page_number }});">上一页</a> {% endif %}Page { { softwarelist.number }} of { { softwarelist.paginator.num_pages }}. {% if softwarelist.has_next %} 下一页 {% endif %}
</div>
<input type="button" value="查询" class="ui_input_btn01" οnclick="search_software(1);"/> <input type="submit" value="新增" class="ui_input_btn01" /> <input type="button" value="编辑" class="ui_input_btn01" οnclick="edit_software({ { softwarelist.number }});" /> <input type="button" value="删除" class="ui_input_btn01" οnclick="batdel_software();" /> <input type="button" value="导出EXCEL" class="ui_input_btn01" οnclick="excel_software();" /> </div> </form> </div> </div> {% endblock %}{% block content %}
<div class="ui_content">
<div class="ui_tb"> <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"> <tr> <th width="30"><input type="checkbox" id="id" name="id" /> </th> <th>软件名字</th> <th>授权数</th> <th>版本号</th> <th>操作</th> </tr> {% for mr in softwarelist.object_list %} <tr> <td><input type="checkbox" name="idcheck" value={ { mr.id }} class="acb" /></td> <td>{ { mr.name }}</td> <td>{ { mr.license_num }}</td> <td>{ { mr.version }}</td> <td> <a href="javascript:void(0)" οnclick="edit_mr('{ { mr.id }}','{ { mr.name }}','{ { mr.license_num }}','{ { mr.version }}')" class="edit">编辑</a> <a href="javascript:void(0)" οnclick="del_software({ { mr.id }},{ { softwarelist.number }});">删除</a> </td> </tr> {% endfor %} </table> </div> </div> </div> <script type="text/javascript"> function search_software(page){ var text1 = document.getElementById("mname").value; var myurl="search_software.html"+"?"+"mname="+text1+"&&page="+page; window.location.assign(encodeURI(myurl)) } function edit_mr(id,name,license_num,version){ document.getElementById("softwareid").value=id; document.getElementById("softwarename").value=name; document.getElementById("softwarelicense_num").value=license_num; document.getElementById("softwareversion").value=version; } function edit_software(page){ var text1 = document.getElementById("mname").value; id=document.getElementById("softwareid").value; name=document.getElementById("softwarename").value; license_num=document.getElementById("softwarelicense_num").value; version=document.getElementById("softwareversion").value; var myurl="edit_software.html"+"?"+"id="+id+"&&name="+name+"&&license_num="+license_num+"&&version="+version+"&&mname="+text1+"&&page="+page; window.location.assign(encodeURI(myurl)) } function del_software(id,page){ if(window.confirm('确定要删除该记录吗?')){ var text1= document.getElementById("mname").value; var myurl="del_software.html"+"?"+"id="+id+"&&mname="+text1+"&&page="+page; window.location.assign(encodeURI(myurl)) return true; }else{ //alert("取消"); return false; } } function batdel_software(){ if(window.confirm('确定要删除记录吗?')){ obj = document.getElementsByName("idcheck"); var text1= document.getElementById("mname").value; check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } var myurl="batdel_software.html"+"?"+"ids="+check_val+"&&mname="+text1; window.location.assign(encodeURI(myurl)) return true; }else{ return false; } } function excel_software(){ var text1 = document.getElementById("mname").value; var myurl="excel_software.html"+"?"+"mname="+text1; window.location.assign(encodeURI(myurl)) } </script> {% endblock %}{% extends 'base.html' %}
{% block title %}
<script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script>
<link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/static/style/authority/jquery.fancybox-1.3.4.css" media="screen"></link> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script><div id="container">
<div class="ui_content"> <div class="ui_text_indent"> <div id="box_border"> <div id="box_top">搜索</div> 厂商名字 <input type="text" id="mname" name="mname" value="{ { mname }}" class="ui_input_txt02" /> </div> <div id="box_top">新增/编辑</div> <form id="submitForm" name="submitForm" method="post" action="add_manufactory.html"> <input type="hidden" id="manufactoryid" name="manufactoryid"/> 厂商名字 <input type="text" id="manufactorymanufactory" name="manufactorymanufactory" class="ui_input_txt02" /> 厂商电话 <input type="text" id="manufactorysupport_num" name="manufactorysupport_num" class="ui_input_txt02" /> 备注 <input type="text" id="manufactorymemo" name="manufactorymemo" class="ui_input_txt02" /> </div> <div id="box_bottom"> <div class="pagination"> <span class="current"> {% if manufactorylist.has_previous %} <a href="javascript:void(0)" οnclick="search_manufactory({ { manufactorylist.previous_page_number }});">上一页</a> {% endif %}Page { { manufactorylist.number }} of { { manufactorylist.paginator.num_pages }}. {% if manufactorylist.has_next %} 下一页 {% endif %}
</div>
<input type="button" value="查询" class="ui_input_btn01" οnclick="search_manufactory(1);"/> <input type="submit" value="新增" class="ui_input_btn01" /> <input type="button" value="编辑" class="ui_input_btn01" οnclick="edit_manufactory({ { manufactorylist.number }});" /> <input type="button" value="删除" class="ui_input_btn01" οnclick="batdel_manufactory();" /> <input type="button" value="导出EXCEL" class="ui_input_btn01" οnclick="excel_manufactory();" /> </div> </form> </div> </div> {% endblock %}{% block content %}
<div class="ui_content">
<div class="ui_tb"> <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"> <tr> <th width="30"><input type="checkbox" id="id" name="id" /> </th> <th>厂商名字</th> <th>厂商电话</th> <th>备注</th> <th>操作</th> </tr> {% for mr in manufactorylist.object_list %} <tr> <td><input type="checkbox" name="idcheck" value={ { mr.id }} class="acb" /></td> <td>{ { mr.manufactory }}</td> <td>{ { mr.support_num }}</td> <td>{ { mr.memo }}</td> <td> <a href="javascript:void(0)" οnclick="edit_mr('{ { mr.id }}','{ { mr.manufactory }}','{ { mr.support_num }}','{ { mr.memo }}')" class="edit">编辑</a> <a href="javascript:void(0)" οnclick="del_manufactory({ { mr.id }},{ { manufactorylist.number }});">删除</a> </td> </tr> {% endfor %} </table> </div> </div> </div> <script type="text/javascript"> function search_manufactory(page){ var text1 = document.getElementById("mname").value; var myurl="search_manufactory.html"+"?"+"mname="+text1+"&&page="+page; window.location.assign(encodeURI(myurl)) } function edit_mr(id,name,license_num,version){ document.getElementById("manufactoryid").value=id; document.getElementById("manufactorymanufactory").value=name; document.getElementById("manufactorysupport_num").value=license_num; document.getElementById("manufactorymemo").value=version; } function edit_manufactory(page){ var text1 = document.getElementById("mname").value; id=document.getElementById("manufactoryid").value; name=document.getElementById("manufactorymanufactory").value; license_num=document.getElementById("manufactorysupport_num").value; version=document.getElementById("manufactorymemo").value; var myurl="edit_manufactory.html"+"?"+"id="+id+"&&manufactory="+name+"&&support_num="+license_num+"&&memo="+version+"&&mname="+text1+"&&page="+page; window.location.assign(encodeURI(myurl)) } function del_manufactory(id,page){ if(window.confirm('确定要删除该记录吗?')){ var text1= document.getElementById("mname").value; var myurl="del_manufactory.html"+"?"+"id="+id+"&&mname="+text1+"&&page="+page; window.location.assign(encodeURI(myurl)) return true; }else{ //alert("取消"); return false; } } function batdel_manufactory(){ if(window.confirm('确定要删除记录吗?')){ obj = document.getElementsByName("idcheck"); var text1= document.getElementById("mname").value; check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } var myurl="batdel_manufactory.html"+"?"+"ids="+check_val+"&&mname="+text1; window.location.assign(encodeURI(myurl)) return true; }else{ return false; } } function excel_manufactory(){ var text1 = document.getElementById("mname").value; var myurl="excel_manufactory.html"+"?"+"mname="+text1; window.location.assign(encodeURI(myurl)) } </script> {% endblock %}from future import unicode_literals
from django.shortcuts import render,render_to_response
from django.core.paginator import Paginator,InvalidPage,EmptyPage from cmdbapp.models import * from django.http import HttpResponse from django.http import HttpResponseRedirect from xlwt import * import StringIOdef search_software(request):
error = False each_page = 5 mname=request.GET.get('mname','0') if mname=='0' or mname.strip()=='': record_list = Software.objects.all() mname='' paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_software.html',{'softwarelist':contacts,"mname":mname}) else:record_list = Software.objects.filter(name=mname) paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_software.html',{'softwarelist':contacts,"mname":mname})
def add_software(request):
n = request.POST.get('softwarename') v = request.POST.get('softwareversion') l = request.POST.get('softwarelicense_num') Software.objects.create(name=n,license_num=l,version=v) return HttpResponseRedirect('search_software.html') def edit_software(request): id=request.GET.get('id') iid=int(id) name=request.GET.get('name') l=request.GET.get('license_num') v=request.GET.get('version') Software.objects.filter(id=iid).update(name=name,license_num=l,version=v) page=request.GET.get('page') mname=request.GET.get('mname') return HttpResponseRedirect('search_software.html?mname='+mname+"&&page="+page) def del_software(request): id=request.GET.get('id') iid=int(id) Software.objects.filter(id=iid).delete() page=request.GET.get('page') mname=request.GET.get('mname') return HttpResponseRedirect('search_software.html?mname='+mname+"&&page="+page) def batdel_software(request): ids=request.GET.get('ids') b=ids.split(',') arr = map(int,b) for aaa in arr: Software.objects.filter(id=aaa).delete() mname=request.GET.get('mname') return HttpResponseRedirect('search_software.html?mname='+mname) def excel_software(request): mname=request.GET.get('mname','0') if mname=='0' or mname.strip()=='': list_obj = Software.objects.all() mname='' else: list_obj = Software.objects.filter(name=mname) if list_obj: # 创建工作薄 ws = Workbook(encoding='utf-8') w = ws.add_sheet(u"软件清单") w.write(0, 0, "id") w.write(0, 1, u"软件名字") w.write(0, 2, u"授权数") w.write(0, 3, u"版本号") # 写入数据 excel_row = 1 for obj in list_obj: data_id = obj.id data_name = obj.name data_license_num = obj.license_num data_version = obj.version w.write(excel_row, 0, data_id) w.write(excel_row, 1, data_name) w.write(excel_row, 2, data_license_num) w.write(excel_row, 3, data_version) excel_row += 1 sio = StringIO.StringIO() ws.save(sio) sio.seek(0) response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=机房清单-'+mname+'.xls' response.write(sio.getvalue()) return responsefrom future import unicode_literals
from django.shortcuts import render,render_to_response
from django.core.paginator import Paginator,InvalidPage,EmptyPage from cmdbapp.models import * from django.http import HttpResponse from django.http import HttpResponseRedirect from xlwt import * import StringIOdef search_manufactory(request):
error = False each_page = 5 mname=request.GET.get('mname','0') if mname=='0' or mname.strip()=='': record_list = Manufactory.objects.all() mname='' paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_manufactory.html',{'manufactorylist':contacts,"mname":mname}) else:record_list = Manufactory.objects.filter(name=mname) paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_manufactory.html',{'manufactorylist':contacts,"mname":mname})
def add_manufactory(request):
n = request.POST.get('manufactorymanufactory') v = request.POST.get('manufactorysupport_num') l = request.POST.get('manufactorymemo') Manufactory.objects.create(manufactory=n,support_num=v,memo=l) return HttpResponseRedirect('search_manufactory.html') def edit_manufactory(request): id=request.GET.get('id') iid=int(id) name=request.GET.get('manufactory') l=request.GET.get('support_num') v=request.GET.get('memo') Manufactory.objects.filter(id=iid).update(manufactory=name,support_num=l,memo=v) page=request.GET.get('page') mname=request.GET.get('mname') return HttpResponseRedirect('search_manufactory.html?mname='+mname+"&&page="+page) def del_manufactory(request): id=request.GET.get('id') iid=int(id) Manufactory.objects.filter(id=iid).delete() page=request.GET.get('page') mname=request.GET.get('mname') return HttpResponseRedirect('search_manufactory.html?mname='+mname+"&&page="+page) def batdel_manufactory(request): ids=request.GET.get('ids') b=ids.split(',') arr = map(int,b) for aaa in arr: Manufactory.objects.filter(id=aaa).delete() mname=request.GET.get('mname') return HttpResponseRedirect('search_manufactory.html?mname='+mname) def excel_manufactory(request): mname=request.GET.get('mname','0') if mname=='0' or mname.strip()=='': list_obj = Manufactory.objects.all() mname='' else: list_obj = Manufactory.objects.filter(name=mname) if list_obj: # 创建工作薄 ws = Workbook(encoding='utf-8') w = ws.add_sheet(u"厂商清单") w.write(0, 0, "id") w.write(0, 1, u"厂商名字") w.write(0, 2, u"电话") w.write(0, 3, u"备注") # 写入数据 excel_row = 1 for obj in list_obj: data_id = obj.id data_name = obj.manufactory data_license_num = obj.support_num data_version = obj.memo w.write(excel_row, 0, data_id) w.write(excel_row, 1, data_name) w.write(excel_row, 2, data_license_num) w.write(excel_row, 3, data_version) excel_row += 1 sio = StringIO.StringIO() ws.save(sio) sio.seek(0) response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=机房清单-'+mname+'.xls' response.write(sio.getvalue()) return response"""cmdb URL Configuration
The urlpatterns
list routes URLs to views. For more information please see:
urlpatterns = [
url(r'^static/(?P<path>.*)',machinaroomviews.main_page,name='main_page'), url(r'^base',machinaroomviews.base,name='base'), url(r'^search_machinaroom.html',machinaroomviews.add_machinaroom,name='add_machinaroom'), url(r'^edit_machinaroom.html',machinaroomviews.edit_machinaroom,name='edit_machinaroom'), url(r'^del_machinaroom.html',machinaroomviews.del_machinaroom,name='del_machinaroom'), url(r'^batdel_machinaroom.html',machinaroomviews.batdel_machinaroom,name='batdel_machinaroom'), url(r'^excel_machinaroom.html',machinaroomviews.excel_machinaroom,name='excel_machinaroom'), url(r'^login/',serverviews.search_server,name='search_server'), url(r'^add_server.html',serverviews.edit_server,name="edit_server"), url(r'^del_server.html',serverviews.del_server,name='del_server'), url(r'^batdel_server.html',serverviews.batdel_server,name='batdel_server'), url(r'^excel_server.html',serverviews.excel_server,name='excel_server'), url(r'^search_networkdevice.html',networkdeviceviews.add_networkdevice,name="add_networkdevice"), url(r'^edit_networkdevice.html',securitydeviceviews.search_securitydevice,name='search_securitydevice'), url(r'^add_securitydevice.html',securitydeviceviews.edit_securitydevice,name="edit_securitydevice"), url(r'^del_securitydevice.html',securitydeviceviews.del_securitydevice,name='del_securitydevice'), url(r'^batdel_securitydevice.html',securitydeviceviews.batdel_securitydevice,name='batdel_securitydevice'), url(r'^excel_securitydevice.html',securitydeviceviews.excel_securitydevice,name='excel_securitydevice'), url(r'^search_storagedevice.html',storagedeviceviews.add_storagedevice,name="add_storagedevice"), url(r'^edit_storagedevice.html',softwareviews.search_software,name='search_software'), url(r'^add_software.html',manufactoryviews.search_manufactory,name='search_manufactory'), url(r'^add_manufactory.html$',manufactoryviews.add_manufactory,name='add_manufactory'), url(r'^edit_manufactory.html',manufactoryviews.edit_manufactory,name='edit_manufactory'), url(r'^del_manufactory.html',manufactoryviews.del_manufactory,name='del_manufactory'), url(r'^batdel_manufactory.html',manufactoryviews.batdel_manufactory,name='batdel_manufactory'), url(r'^excel_manufactory.html',manufactoryviews.excel_manufactory,name='excel_manufactory'), ]转载地址:http://wcnba.baihongyu.com/