django 备件管理系统
阅读原文时间:2023年07月13日阅读:2

views

1 class limit:
2
3 def limit(self,res,obj):
4 limit = int(res.GET.get('limit',1))
5 pagelimit = int(res.GET.get('pagelimit',30))
6 startlimit = (limit-1)*pagelimit
7 endlimit = limit*pagelimit
8 logdb = obj[startlimit:endlimit]
9 page_count,lastpage_count = divmod(obj.count(),pagelimit)
10 if lastpage_count:
11 page_count +=1
12 startpage = 1
13 endpage = page_count
14 hrefli=[]
15 pagenumber = [30,50,70,100,200]
16 part1 = '

每页显示
'
19 for number in pagenumber:
20 if number == pagelimit:
21 option = ''%number
22 else:
23 option = ''%number
24 part2li.append(option)
25 part2 = ''.join(part2li)
26 pagesize = part1+part2+part3
27 hrefli.append(pagesize)
28 if limit !=1:
29 hrefli.append('%s'%(res.path,limit-1,pagelimit,'上一页'))
30 for x in range(startpage,endpage+1):
31 if limit+3 < x or x <limit -3:
32 hrefli.append(''%(res.path,x,pagelimit,x))
33 elif x == limit:
34 hrefli.append('%s'%(res.path,x,pagelimit,x))
35 else:
36 hrefli.append('%s'%(res.path,x,pagelimit,x))
37 if limit != endpage:
38 hrefli.append('%s'%(res.path,limit+1,pagelimit,'下一页'))
39 href=''.join(hrefli)
40 return href,logdb

limit.py

url.py

form.py

manage.py

models.py

1 from django.shortcuts import render,redirect,HttpResponse
2 from dw import models
3 from dw.views import form
4 from django.views.decorators.csrf import csrf_exempt
5 from functools import wraps
6 from django.db.models import Q
7 from django.utils.safestring import mark_safe
8 # Create your views here.
9 def auth(func):
10 @wraps(func)
11 def check_login(res,*args,**kwargs):
12 try:
13 res.session['name']
14 return func(res,*args,**kwargs)
15 except:
16 return redirect('/login.html')
17 return check_login
18 @csrf_exempt
19 def login(request):
20 form_obj = form.login()
21 if request.method == 'GET':
22 return render(request,'login.html',{'form_obj':form_obj})
23 elif request.method == 'POST':
24 auth_obj = models.login.objects
25 request_form = form.login(request.POST)
26 if request_form.is_valid():
27 user_info = request_form.clean()
28 if auth_obj.filter(**user_info):
29 request.session['name']=user_info['username']
30 return redirect('/index.html/')
31 else:
32 errors = '用户名或密码错误'
33 return render(request,'login.html',{'form_obj':form_obj,'errors':errors})
34 else:
35 errors = request_form.errors()
36 return render(request,'login.html',{'form_obj':form_obj,'errors':errors})
37 return render(request,'login.html',{'form_obj':form_obj})
38 @csrf_exempt
39 def register(request):
40 form_obj = form.register()
41 if request.method == 'GET':
42 return render(request,'register.html',{'form_obj':form_obj})
43 elif request.method == 'POST':
44 register_form = form.register(request.POST)
45 if register_form.is_valid():
46 userinfo = register_form.clean()
47 if models.login.objects.filter(username=userinfo['username']):
48 errors='用户名已经被注册'
49 return render(request,'register.html',{'form_obj':form_obj,'errors':errors})
50 else:
51 models.login.objects.create(**userinfo)
52 return redirect('/index.html/')
53 else:
54 errors = register_form.errors['pwd'][0]
55 return render(request,'register.html',{'form_obj':form_obj,'errors':errors})
56 @csrf_exempt
57 @auth
58 def index(request):
59 return render(request,'index.html')
60 @csrf_exempt
61 @auth
62 def module(request):
63 obj = models.module_info.objects
64 if request.method == 'GET':
65 search = request.GET.get('search','')
66 db_search = obj.filter( Q(module_vendor__vendor_name__icontains=search)|\
67 Q(module_type__device_type__icontains=search)|\
68 Q(module_model__module_model__icontains=search)|\
69 Q(module_length__length__icontains=search)|\
70 Q(module_sn__icontains=search)|\
71 Q(module_status__icontains=search))
72 form_obj = form.moduladd()
73 if search:
74 count = db_search.count()
75 web_limit = '

共计:%s

'%count
76 db_obj = db_search
77 else:
78 count = obj.all().count()
79 from dw.views.limit import limit
80 data_limit = limit()
81 web_limit,db_obj = data_limit.limit(request,obj.all())
82 return render(request,'module.html',{'db_queryset':db_obj,'form_obj':form_obj,'limit':mark_safe(web_limit),'count':count})
83 elif request.method == 'POST':
84 if request.POST.get('id'):
85 sid = request.POST.get('id')
86 obj.filter(id=sid).delete()
87 return HttpResponse('ok')
88 elif request.POST.getlist('data'):
89 datalist = request.POST.getlist('data')
90 dic = {}
91 dic['module_vendor_id'],dic['module_type_id'],dic['module_model_id'],\
92 dic['module_length_id'],dic['module_sn'],dic['module_status'],dic['id'] = datalist
93 obj.filter(id=dic['id']).update(**dic)
94 return HttpResponse('ok')
95 data_form = form.moduladd(request.POST)
96 data_form.is_valid()
97 obj.create(**data_form.clean())
98 return redirect('/module.html/')
99 @csrf_exempt
100 @auth
101 def server(request):
102 obj = models.server_info.objects
103 if request.method == 'GET':
104 search = request.GET.get('search','')
105 db_search = obj.filter( Q(server_vendor__vendor_name__icontains=search)|\
106 Q(server_type__device_type__icontains=search)|\
107 Q(server_model__server_model__icontains=search)|\
108 Q(server_sn__icontains=search)|\
109 Q(server_image__icontains=search)|\
110 Q(server_status__icontains=search))
111 form_obj = form.serveradd()
112 if search:
113 count = db_search.count()
114 web_limit = '

共计:%s

'%count
115 db_obj = db_search
116 else:
117 count = obj.all().count()
118 from dw.views.limit import limit
119 data_limit = limit()
120 web_limit,db_obj = data_limit.limit(request,obj.all())
121 return render(request,'server.html',{'db_queryset':db_obj,'form_obj':form_obj,'limit':mark_safe(web_limit),'count':count})
122 elif request.method == 'POST':
123 if request.POST.get('id'):
124 sid = request.POST.get('id')
125 obj.filter(id=sid).delete()
126 return HttpResponse('ok')
127 elif request.POST.getlist('data'):
128 datalist = request.POST.getlist('data')
129 dic = {}
130 dic['server_vendor_id'],dic['server_type_id'],dic['server_model_id'],\
131 dic['server_sn'],dic['server_image'],dic['server_status'],dic['id'] = datalist
132 obj.filter(id=dic['id']).update(**dic)
133 return HttpResponse('ok')
134 data_form = form.serveradd(request.POST)
135 data_form.is_valid()
136 obj.create(**data_form.clean())
137 return redirect('/server.html/')
138
139
140
141
142
143
144
145
146
147
148
149 @csrf_exempt
150 @auth
151 def switch(request):
152 obj = models.switch_info.objects
153 if request.method == 'GET':
154 search = request.GET.get('search','')
155 db_search = obj.filter( Q(switch_vendor__vendor_name__icontains=search)|\
156 Q(switch_type__device_type__icontains=search)|\
157 Q(switch_model__switch_model__icontains=search)|\
158 Q(switch_image__icontains=search)|\
159 Q(switch_sn__icontains=search)|\
160 Q(switch_status__icontains=search))
161 form_obj = form.switchadd()
162 if search:
163 count = db_search.count()
164 web_limit = '

共计:%s

'%count
165 db_obj = db_search
166 else:
167 count = obj.all().count()
168 from dw.views.limit import limit
169 data_limit = limit()
170 web_limit,db_obj = data_limit.limit(request,obj.all())
171 return render(request,'switch.html',{'form_obj':form_obj,'db_queryset':db_obj,'limit':mark_safe(web_limit),'count':count})
172 elif request.method == 'POST':
173 if request.POST.get('id'):
174 sid = request.POST.get('id')
175 obj.filter(id=sid).delete()
176 return HttpResponse('ok')
177 elif request.POST.getlist('data'):
178 datalist = request.POST.getlist('data')
179 dic = {}
180 dic['switch_vendor_id'],dic['switch_type_id'],dic['switch_model_id'],\
181 dic['switch_sn'],dic['switch_image'],dic['switch_status'],dic['id'] = datalist
182 obj.filter(id=dic['id']).update(**dic)
183 return HttpResponse('ok')
184 data_form = form.switchadd(request.POST)
185 data_form.is_valid()
186 obj.create(**data_form.clean())
187 return redirect('/switch.html/')
188
189
190
191 @csrf_exempt
192 @auth
193 def cable(request):
194 obj = models.cable_info.objects
195 if request.method == 'GET':
196 search = request.GET.get('search','')
197 db_search = obj.filter( Q(cable_vendor__vendor_name__icontains=search)|\
198 Q(cable_type__device_type__icontains=search)|\
199 Q(cable_model__cable_model__icontains=search)|\
200 Q(cable_length__length__icontains=search)|\
201 Q(cable_status__icontains=search))
202 form_obj = form.cableadd()
203 if search:
204 count = db_search.count()
205 web_limit = '

共计:%s

'%count
206 db_obj = db_search
207 else:
208 count = obj.all().count()
209 from dw.views.limit import limit
210 data_limit = limit()
211 web_limit,db_obj = data_limit.limit(request,obj.all())
212 return render(request,'cable.html',{'db_queryset':db_obj,'form_obj':form_obj,'limit':mark_safe(web_limit),'count':count})
213 elif request.method == 'POST':
214 if request.POST.get('id'):
215 sid = request.POST.get('id')
216 obj.filter(id=sid).delete()
217 return HttpResponse('ok')
218 elif request.POST.getlist('data'):
219 datalist = request.POST.getlist('data')
220 dic = {}
221 dic['cable_vendor_id'],dic['cable_type_id'],dic['cable_model_id'],\
222 dic['cable_length_id'],dic['cable_status'],dic['id'] = datalist
223 obj.filter(id=dic['id']).update(**dic)
224 return HttpResponse('ok')
225 data_form = form.cableadd(request.POST)
226 data_form.is_valid()
227 obj.create(**data_form.clean())
228 return redirect('/cable.html/')

views.py

CSS

cable.css

1 *{margin: 0;padding: 0; }
2 .top{
3 background-color: rgb(83, 83, 236);
4 height: 52px;
5 }
6
7 .top-left{
8 width: 300px;height: 53px;
9 float: left;
10 text-align: center;line-height: 48px;
11 color: seashell;
12
13 }
14
15 .top-right{height: 53px;
16 float: right;
17 text-align: center;line-height: 48px;
18 color: seashell;
19 margin-right: 60px;
20 }
21
22 .left{background-color: whitesmoke;
23 position: absolute;left: 0;top: 48px;bottom: 0; z-index: 99;
24 width: 300px;
25 border-right:1px solid black;
26 z-index: 99;
27 }
28
29 .right{
30 background-color: whitesmoke;
31 position: absolute;left: 301px;top: 48px;bottom: 0;right: 0; z-index: 99;
32 overflow: scroll;
33 z-index: 99;
34 }
35
36 a:hover{
37 background-color: cornflowerblue;
38 }
39
40 .leftmenu{
41 display: block;padding: 10px;
42 }
43
44 .block{
45 position: absolute;top: 0;bottom: 0;right: 0;left: 0;
46 background-color: black ;opacity: 0.2;z-index: 100;
47 }
48 .currsor:hover{
49 cursor: pointer;
50 }
51 .hidden{
52 display: none;
53 }
54 .pitch{
55 background-color:black;color: white;
56 }
57 .unpitch{
58 background-color: white;color: black;
59 }
60 .page{
61 margin-left: 10px;
62 }

index.css

1 .font{font-family: verdana,arial,sans-serif;}
2
3 .add{padding: 6px;margin-top: 3px;margin-bottom: 3px;}
4
5 .manageadd{
6 position: absolute;top: 50%;left: 50%;
7 transform: translate(-50%,-50%);
8 z-index: 101;
9 background-color: whitesmoke;
10 width: 500px;
11 height: 50px;
12 }
13
14 .manageadd input{height: 20px;}
15
16
17
18 table.gridtable {
19 font-family: verdana,arial,sans-serif;
20 font-size:11px;
21 width: 50%;
22 color:#333333;
23 border-width: 1px;
24 border-color: #666666;
25 border-collapse: collapse;
26 }
27 table.gridtable th {
28 border-width: 1px;
29 padding: 8px;
30 border-style: solid;
31 border-color: #666666;
32 background-color: #dedede;
33 }
34 .change{
35 width: 70px;
36 }
37 table.gridtable td {
38 border-width: 1px;
39 padding: 8px;
40 border-style: solid;
41 border-color: #666666;
42 background-color: #ffffff;
43 }

length_manage.css

1 *{margin: 0;padding:0}
2 body{background-color: royalblue;}
3 .login{position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);}
4 .button,input{width: 300px; height: 20px;margin-top: 10px;}
5 h1{text-align: center; color: seashell}
6 .errors{color: red;}

login.css

1 /* .swadd{
2 position: absolute;top: 50%;left: 50%;
3 transform: translate(-50%,-50%);
4 z-index: 101;
5 background-color:teal;
6 width: 300px;
7 } */
8 .font{font-family: verdana,arial,sans-serif;}
9
10 .add{padding: 6px;margin-top: 3px;margin-bottom: 3px;}
11
12 .manageadd{
13 position: absolute;top: 50%;left: 50%;
14 transform: translate(-50%,-50%);
15 z-index: 101;
16 background-color: whitesmoke;
17 width: 500px;
18 height: 50px;
19 }
20
21 .manageadd input{height: 20px;}
22
23
24
25
26 table.gridtable {
27 font-family: verdana,arial,sans-serif;
28 font-size:11px;
29 width: 50%;
30 color:#333333;
31 border-width: 1px;
32 border-color: #666666;
33 border-collapse: collapse;
34 }
35 table.gridtable th {
36 border-width: 1px;
37 padding: 8px;
38 border-style: solid;
39 border-color: #666666;
40 background-color: #dedede;
41 }
42 .change{
43 width: 70px;
44 }
45 table.gridtable td {
46 border-width: 1px;
47 padding: 8px;
48 border-style: solid;
49 border-color: #666666;
50 background-color: #ffffff;
51 }

model_manage.css

1 /* .swadd{
2 position: absolute;top: 50%;left: 50%;
3 transform: translate(-50%,-50%);
4 z-index: 101;
5 background-color:teal;
6 width: 300px;
7 } */
8 .font{
9 font-family: verdana,arial,sans-serif;
10 font-size:11px;
11 }
12
13 .search{
14 float: right;margin-right: 10px;
15 }
16
17 .add{padding: 6px;margin-top: 3px;margin-bottom: 3px;}
18
19 .swadd{
20 position: absolute;top:0px;bottom: 0px; right: 0px;
21 z-index: 101;
22 background-color: whitesmoke;
23 width: 500px;
24 }
25
26 .swadd p,hr{
27 margin-top: 50px;
28 }
29
30 .swadd input,.swadd select{
31 width: 50%;height: 20px;
32 }
33 .info input{
34 border: none
35 }
36 .info .date{
37 width: 100px;
38 }
39 .info .short{
40 width: 70px;
41 }
42
43 .info .long{
44 width: 100%;
45 }
46
47
48 table.gridtable {
49 font-family: verdana,arial,sans-serif;
50 font-size:11px;
51 width: 100%;
52 color:#333333;
53 border-width: 1px;
54 border-color: #666666;
55 border-collapse: collapse;
56 }
57 table.gridtable th {
58 border-width: 1px;
59 padding: 8px;
60 border-style: solid;
61 border-color: #666666;
62 background-color: #dedede;
63 }
64 .change{
65 width: 70px;
66 }
67 table.gridtable td {
68 border-width: 1px;
69 padding: 8px;
70 border-style: solid;
71 border-color: #666666;
72 background-color: #ffffff;
73 }

module.css

1 /* .swadd{
2 position: absolute;top: 50%;left: 50%;
3 transform: translate(-50%,-50%);
4 z-index: 101;
5 background-color:teal;
6 width: 300px;
7 } */
8 .font{
9 font-family: verdana,arial,sans-serif;
10 font-size:11px;
11 }
12
13 .search{
14 float: right;margin-right: 10px;
15 }
16
17 .add{padding: 6px;margin-top: 3px;margin-bottom: 3px;}
18
19 .serveradd{
20 position: absolute;top:0px;bottom: 0px; right: 0px;
21 z-index: 101;
22 background-color: whitesmoke;
23 width: 500px;
24 }
25
26 .serveradd p,hr{
27 margin-top: 50px;
28 }
29
30 .serveradd input,.serveradd select{
31 width: 50%;height: 20px;
32 }
33 .info input{
34 border: none
35 }
36 .info .date{
37 width: 100px;
38 }
39 .info .short{
40 width: 70px;
41 }
42
43 .info .long{
44 width: 100%;
45 }
46
47
48 table.gridtable {
49 font-family: verdana,arial,sans-serif;
50 font-size:11px;
51 width: 100%;
52 color:#333333;
53 border-width: 1px;
54 border-color: #666666;
55 border-collapse: collapse;
56 }
57 table.gridtable th {
58 border-width: 1px;
59 padding: 8px;
60 border-style: solid;
61 border-color: #666666;
62 background-color: #dedede;
63 }
64 .change{
65 width: 70px;
66 }
67 table.gridtable td {
68 border-width: 1px;
69 padding: 8px;
70 border-style: solid;
71 border-color: #666666;
72 background-color: #ffffff;
73 }

server.css

1 .font{
2 font-family: verdana,arial,sans-serif;
3 font-size:11px;
4 }
5
6 .search{
7 float: right;margin-right: 10px;
8 }
9
10
11 .add{padding: 6px;margin-top: 3px;margin-bottom: 3px;}
12
13 .swadd{
14 position: absolute;top:0px;bottom: 0px; right: 0px;
15 z-index: 101;
16 background-color: whitesmoke;
17 width: 500px;
18 }
19
20 .swadd p,hr{
21 margin-top: 50px;
22 }
23
24 .swadd input,.swadd select{
25 width: 50%;height: 20px;
26 }
27 .info input{
28 border: none
29 }
30 .info .date{
31 width: 100px;
32 }
33 .info .short{
34 width: 70px;
35 }
36
37 .info .long{
38 width: 100%;
39 }
40
41
42 table.gridtable {
43 font-family: verdana,arial,sans-serif;
44 font-size:11px;
45 width: 100%;
46 color:#333333;
47 border-width: 1px;
48 border-color: #666666;
49 border-collapse: collapse;
50 }
51 table.gridtable th {
52 border-width: 1px;
53 padding: 8px;
54 border-style: solid;
55 border-color: #666666;
56 background-color: #dedede;
57 }
58 .change{
59 width: 70px;
60 }
61 table.gridtable td {
62 border-width: 1px;
63 padding: 8px;
64 border-style: solid;
65 border-color: #666666;
66 background-color: #ffffff;
67 }

switch.css

1 .font{font-family: verdana,arial,sans-serif;}
2
3 .add{padding: 6px;margin-top: 3px;margin-bottom: 3px;}
4
5 .manageadd{
6 position: absolute;top: 50%;left: 50%;
7 transform: translate(-50%,-50%);
8 z-index: 101;
9 background-color: whitesmoke;
10 width: 500px;
11 height: 50px;
12 }
13
14 .manageadd input{height: 20px;}
15
16
17
18 table.gridtable {
19 font-family: verdana,arial,sans-serif;
20 font-size:11px;
21 width: 50%;
22 color:#333333;
23 border-width: 1px;
24 border-color: #666666;
25 border-collapse: collapse;
26 }
27 table.gridtable th {
28 border-width: 1px;
29 padding: 8px;
30 border-style: solid;
31 border-color: #666666;
32 background-color: #dedede;
33 }
34 .change{
35 width: 70px;
36 }
37 table.gridtable td {
38 border-width: 1px;
39 padding: 8px;
40 border-style: solid;
41 border-color: #666666;
42 background-color: #ffffff;
43 }

type_manage.css

1 .font{font-family: verdana,arial,sans-serif;}
2
3 .add{padding: 6px;margin-top: 3px;margin-bottom: 3px;}
4
5 .manageadd{
6 position: absolute;top: 50%;left: 50%;
7 transform: translate(-50%,-50%);
8 z-index: 101;
9 background-color: whitesmoke;
10 width: 500px;
11 height: 50px;
12 }
13
14 .manageadd input{height: 20px;}
15
16
17
18 table.gridtable {
19 font-family: verdana,arial,sans-serif;
20 font-size:11px;
21 width: 50%;
22 color:#333333;
23 border-width: 1px;
24 border-color: #666666;
25 border-collapse: collapse;
26 }
27 table.gridtable th {
28 border-width: 1px;
29 padding: 8px;
30 border-style: solid;
31 border-color: #666666;
32 background-color: #dedede;
33 }
34 .change{
35 width: 70px;
36 }
37 table.gridtable td {
38 border-width: 1px;
39 padding: 8px;
40 border-style: solid;
41 border-color: #666666;
42 background-color: #ffffff;
43 }

vendor_manage.css

JQuery

1 $(function(){
2 add()
3 cancel()
4 del()
5 edit()
6 commit()
7 pagelimit()
8 })
9
10 function add(){
11 $('.add').click(function(){
12 $('.block').removeClass('hidden')
13 $('.cableadd').removeClass('hidden')
14 })
15 }
16
17 function cancel(){
18 $('.cancel').click(function(){
19 $('.cableadd').addClass('hidden')
20 $('.block').addClass('hidden')
21 })
22 }
23 function del(){
24 $('.delete').click(function(){
25 var id = $(this).attr('sid')
26 $.ajax({
27 url:'/cable.html/',
28 data:{'id':id},
29 type:'POST',
30 success:function(){
31 location.reload()
32 }
33 })
34 })
35 }
36
37 function edit(){
38 $('.edit').click(function(){
39 var id = $(this).attr('sid')
40 $('.commit'+id).removeClass('hidden')
41 $(this).addClass('hidden')
42 $('.'+id).removeAttr('readonly')
43 $('.option'+id).removeClass('hidden')
44 $('.p'+id).addClass('hidden')
45 })
46 }
47
48 function commit(){
49 $('.commit').click(function(){
50 $(this).addClass('hidden')
51 $('.edit').removeClass('hidden')
52 var id = $(this).attr('sid')
53 $('.'+id).attr('readonly','readonly')
54 var data = $('.'+id)
55 var list = new Array()
56 $(this).parent().siblings().find('select option:checked').each(function(k,v){
57 list.push(v.text)
58 })
59 data.each(function(index,x){
60 list.push(x.value)
61 });
62 list.push(id)
63 $.ajax({
64 url:'/cable.html/',
65 data:{'data':list},
66 type:'POST',
67 traditional:true,
68 success:function(res){
69 if(res=='ok'){
70 location.reload()
71 }
72 else{
73 alert(res)
74 }
75 }
76 })
77 })
78 }
79
80
81
82 // function pagelimit(){
83 // var option = $('.pagelimit').val()
84 // var pagelimit = '&'+'?pagelimit'+option
85 // var a = $('.page')
86 // a.each(function(){
87 // var base_href = $(this).attr('href')
88 // var new_href = base_href + pagelimit
89 // console.log(new_href)
90 // })
91 // // for(x in a){
92 // // console.log(x)
93 // // }
94 // }

cable.js

1 $(function(){
2 add()
3 cancel()
4 del()
5 edit()
6 commit()
7 // pagelimit()
8 text()
9 })
10
11 function add(){
12 $('.add').click(function(){
13 $('.block').removeClass('hidden')
14 $('.swadd').removeClass('hidden')
15 })
16 }
17
18 function cancel(){
19 $('.cancel').click(function(){
20 $('.swadd').addClass('hidden')
21 $('.block').addClass('hidden')
22 })
23 }
24 function del(){
25 $('.delete').click(function(){
26 var id = $(this).attr('sid')
27 $.ajax({
28 url:'/module.html/',
29 data:{'id':id},
30 type:'POST',
31 success:function(){
32 location.reload()
33 }
34 })
35 })
36 }
37
38 function edit(){
39 $('.edit').click(function(){
40 var id = $(this).attr('sid')
41 $('.commit'+id).removeClass('hidden')
42 $(this).addClass('hidden')
43 $('.'+id).removeAttr('readonly')
44 $('.option'+id).removeClass('hidden')
45 $('.p'+id).addClass('hidden')
46 })
47 }
48
49 function commit(){
50 $('.commit').click(function(){
51 $(this).addClass('hidden')
52 $('.edit').removeClass('hidden')
53 var id = $(this).attr('sid')
54 $('.'+id).attr('readonly','readonly')
55 var data = $('.'+id)
56 var list = new Array()
57 $(this).parent().siblings().find('select option:checked').each(function(k,v){
58 list.push(v.text)
59 })
60 data.each(function(index,x){
61 list.push(x.value)
62 });
63 list.push(id)
64 console.log(list)
65 $.ajax({
66 url:'/module.html/',
67 data:{'data':list},
68 type:'POST',
69 traditional:true,
70 success:function(res){
71 if(res=='ok'){
72 location.reload()
73 }
74 else{
75 alert(res)
76 }
77 }
78 })
79 })
80 }
81
82
83
84 // function pagelimit(){
85 // var option = $('.pagelimit').val()
86 // var pagelimit = '&'+'?pagelimit'+option
87 // var a = $('.page')
88 // a.each(function(){
89 // var base_href = $(this).attr('href')
90 // var new_href = base_href + pagelimit
91 // console.log(new_href)
92 // })
93 // // for(x in a){
94 // // console.log(x)
95 // // }
96 // }

module.js

1 $(function(){
2 add()
3 cancel()
4 del()
5 edit()
6 commit()
7 pagelimit()
8 })
9
10 function add(){
11 $('.add').click(function(){
12 $('.block').removeClass('hidden')
13 $('.serveradd').removeClass('hidden')
14 })
15 }
16
17 function cancel(){
18 $('.cancel').click(function(){
19 $('.serveradd').addClass('hidden')
20 $('.block').addClass('hidden')
21 })
22 }
23 function del(){
24 $('.delete').click(function(){
25 var id = $(this).attr('sid')
26 $.ajax({
27 url:'/server.html/',
28 data:{'id':id},
29 type:'POST',
30 success:function(){
31 location.reload()
32 }
33 })
34 })
35 }
36
37 function edit(){
38 $('.edit').click(function(){
39 var id = $(this).attr('sid')
40 $('.commit'+id).removeClass('hidden')
41 $(this).addClass('hidden')
42 $('.'+id).removeAttr('readonly')
43 $('.option'+id).removeClass('hidden')
44 $('.p'+id).addClass('hidden')
45 })
46 }
47
48 function commit(){
49 $('.commit').click(function(){
50 $(this).addClass('hidden')
51 $('.edit').removeClass('hidden')
52 var id = $(this).attr('sid')
53 $('.'+id).attr('readonly','readonly')
54 var data = $('.'+id)
55 var list = new Array()
56 $(this).parent().siblings().find('select option:checked').each(function(k,v){
57 list.push(v.text)
58 })
59 data.each(function(index,x){
60 list.push(x.value)
61 });
62 list.push(id)
63
64 $.ajax({
65 url:'/server.html/',
66 data:{'data':list},
67 type:'POST',
68 traditional:true,
69 success:function(res){
70 if(res=='ok'){
71 location.reload()
72 }
73 else{
74 alert(res)
75 }
76 }
77 })
78 })
79 }
80
81
82
83 // function pagelimit(){
84 // var option = $('.pagelimit').val()
85 // var pagelimit = '&'+'?pagelimit'+option
86 // var a = $('.page')
87 // a.each(function(){
88 // var base_href = $(this).attr('href')
89 // var new_href = base_href + pagelimit
90 // console.log(new_href)
91 // })
92 // // for(x in a){
93 // // console.log(x)
94 // // }
95 // }

server.js

1 $(function(){
2 add()
3 cancel()
4 del()
5 edit()
6 commit()
7 })
8
9 function add(){
10 $('.add').click(function(){
11 $('.block').removeClass('hidden')
12 $('.swadd').removeClass('hidden')
13 })
14 }
15
16 function cancel(){
17 $('.cancel').click(function(){
18 $('.swadd').addClass('hidden')
19 $('.block').addClass('hidden')
20 })
21 }
22 function del(){
23 $('.delete').click(function(){
24 var id = $(this).attr('sid')
25 $.ajax({
26 url:'/switch.html/',
27 data:{'id':id},
28 type:'POST',
29 success:function(){
30 location.reload()
31 }
32 })
33 })
34 }
35
36 function edit(){
37 $('.edit').click(function(){
38 var id = $(this).attr('sid')
39 $('.commit'+id).removeClass('hidden')
40 $(this).addClass('hidden')
41 $('.'+id).removeAttr('readonly')
42 $('.option'+id).removeClass('hidden')
43 $('.p'+id).addClass('hidden')
44 })
45 }
46
47 function commit(){
48 $('.commit').click(function(){
49 $(this).addClass('hidden')
50 $('.edit').removeClass('hidden')
51 var id = $(this).attr('sid')
52 $('.'+id).attr('readonly','readonly')
53 var data = $('.'+id)
54 var list = new Array()
55 $(this).parent().siblings().find('select option:checked').each(function(k,v){
56 list.push(v.text)
57 })
58 data.each(function(index,x){
59 list.push(x.value)
60 });
61 list.push(id)
62 $.ajax({
63 url:'/switch.html/',
64 data:{'data':list},
65 type:'POST',
66 traditional:true,
67 success:function(res){
68 if(res=='ok'){
69 location.reload()
70 }
71 else{
72 alert(res)
73 }
74 }
75 })
76 })
77 }

switch.js

1 $(function(){
2 add()
3 cancel()
4 del()
5 })
6
7 function add(){
8 $('.add').click(function(){
9 $('.block').removeClass('hidden')
10 $('.manageadd').removeClass('hidden')
11 })
12 }
13
14 function cancel(){
15 $('.cancel').click(function(){
16 $('.manageadd').addClass('hidden')
17 $('.block').addClass('hidden')
18 event.preventDefault()
19 })
20 }
21
22 function del(){
23 $('.delete').click(function(){
24 var id = $(this).attr('sid')
25 $.ajax({
26 url:'/length_manage.html/',
27 data:{'id':id},
28 type:'POST',
29 success:function(){
30 location.reload()
31 }
32 })
33 })
34 }

length_manage.js

1 $(function(){
2 add()
3 cancel()
4 del()
5 })
6
7 function add(){
8 $('.add').click(function(){
9 $('.block').removeClass('hidden')
10 $('.manageadd').removeClass('hidden')
11 })
12 }
13
14 function cancel(){
15 $('.cancel').click(function(){
16 $('.manageadd').addClass('hidden')
17 $('.block').addClass('hidden')
18 event.preventDefault()
19 })
20 }
21
22 function del(){
23 $('.delete').click(function(){
24 var id = $(this).attr('sid')
25 var table_name = $(this).attr('dtype')
26 $.ajax({
27 url:'/model_manage.html/',
28 data:{'id':id,'table_name':table_name},
29 type:'POST',
30 success:function(){
31 location.reload()
32 }
33 })
34 })
35 }

model_manage.js

1 $(function(){
2 add()
3 cancel()
4 del()
5 })
6
7 function add(){
8 $('.add').click(function(){
9 $('.block').removeClass('hidden')
10 $('.manageadd').removeClass('hidden')
11 })
12 }
13
14 function cancel(){
15 $('.cancel').click(function(){
16 $('.manageadd').addClass('hidden')
17 $('.block').addClass('hidden')
18 event.preventDefault()
19 })
20 }
21
22 function del(){
23 $('.delete').click(function(){
24 var id = $(this).attr('sid')
25 $.ajax({
26 url:'/type_manage.html/',
27 data:{'id':id},
28 type:'POST',
29 success:function(){
30 location.reload()
31 }
32 })
33 })
34 }

type_manage.js

1 $(function(){
2 add()
3 cancel()
4 del()
5 })
6
7 function add(){
8 $('.add').click(function(){
9 $('.block').removeClass('hidden')
10 $('.manageadd').removeClass('hidden')
11 })
12 }
13
14 function cancel(){
15 $('.cancel').click(function(){
16 $('.manageadd').addClass('hidden')
17 $('.block').addClass('hidden')
18 event.preventDefault()
19 })
20 }
21
22 function del(){
23 $('.delete').click(function(){
24 var id = $(this).attr('sid')
25 $.ajax({
26 url:'/vendor_manage.html/',
27 data:{'id':id},
28 type:'POST',
29 success:function(){
30 location.reload()
31 }
32 })
33 })
34 }

vendor_manage.js

html页面

1
2 3 4 5 6 7 index 8 9 10 11 {%block cssandjs%} 12 {%endblock%} 13 14 15 16

17
18
19 备件管理系统 20
21
22
用户:{{username}}
23
24 25
26 27 39 {%block change%} 40 {%endblock%} 41
42 {%block data%} 43 {%endblock%} 44
45 46

index.html

1 {% extends 'index.html' %}
2 {%block cssandjs%}
3
4
7
8
11
12 {%endblock%}
13
14 {%block change%}
15


65 {%endblock%}
66
67
68
69 {%block data %}
70

71

共计{{count}}


72
73
77

78
79 80 81 82 83 84 85 86 87 88 89 {%for x in db_queryset%} 90 91 94 97 100 103 106 109 110 115 116 {%endfor%} 117
添加日期厂商类型型号传输距离备注操作
92 {{x.date}} 93 95 96 98 99 101 102 104 105 107 108 111 编辑 112 113 删除 114

118
119
120
121 {{limit}}
122 {%endblock%}
123

cable.html

1 {% extends 'index.html' %}
2 {%block cssandjs%}
3
4
7
8
10
11 {%endblock%}
12
13 {%block change%}
14


23 {%endblock%}
24
25 {%block data %}
26
27

28
29

30
31 32 33 34 35 36 37 {%for x in db_queryset%} 38 39 42 43 46 47 {%endfor%} 48
添加日期传输距离操作
40 {{x.date}} 41 {{x.length}} 44 删除 45

49 {{limit}}
50 {%endblock%}
51

length_manage.html

1
2 3 4 5 6 7 8 login 9 10 11

30 31

login.html

1 {% extends 'index.html' %}
2 {%block cssandjs%}
3
4
7
8
10
11 {%endblock%}
12
13 {%block change%}
14


29 {%endblock%}
30
31 {%block data %}
32

33
34

35
36 37 38 39 40 41 42 {%for x in switch_model_queryset%} 43 44 47 50 53 54 {%endfor%} 55 56 {%for x in module_model_queryset%} 57 58 61 64 67 68 {%endfor%} 69 70 {%for x in cable_model_queryset%} 71 72 75 78 81 82 {%endfor%} 83 84 {%for x in server_model_queryset%} 85 86 89 92 ¨C145C 95 96 {%endfor%} 97
添加日期型号操作
45 {{x.date}} 46 48 {{x.switch_model}} 49 51 删除 52
59 {{x.date}} 60 62 {{x.module_model}} 63 65 删除 66
73 {{x.date}} 74 76 {{x.cable_model}} 77 79 删除 80
87 {{x.date}} 88 90 {{x.server\_model}} 91

98 {{limit}}
99 {%endblock%}
100

model_manage.html

1 {% extends 'index.html' %}
2 {%block cssandjs%}
3
4
7
8
11
12 {%endblock%}
13
14 {%block change%}
15


72 {%endblock%}
73
74
75
76 {%block data %}
77

78

共计{{count}}


79
80
84

85
86 87 88 89 90 91 92 93 94 95 96 97 {%for x in db_queryset%} 98 99 102 105 108 111 114 117 120 121 126 127 {%endfor%} 128
添加日期厂商类型型号SN传输距离备注操作
100 {{x.date}} 101 103 104 106 107 109 110 112 113 115 116 118 119 122 编辑 123 124 删除 125

129
130
131
132 {{limit}}
133 {%endblock%}
134

module.html

1
2 3 4 5 6 7 8 register 9 10 11

25 26

register.html

1 {% extends 'index.html' %}
2 {%block cssandjs%}
3
4
7
8
11
12 {%endblock%}
13
14 {%block change%}
15


71 {%endblock%}
72
73
74
75 {%block data %}
76

77

共计{{count}}


78
79
83

84
85 86 87 88 89 90 91 92 93 94 95 96 {%for x in db_queryset%} 97 98 101 104 107 110 113 116 119 124 125 {%endfor%} 126
添加日期厂商类型型号SN系统备注操作
99 {{x.date}} 100 102 103 105 106 108 109 111 112 114 115 117 118 120 编辑 121 122 删除 123

127
128
129
130 {{limit}}
131 {%endblock%}
132

server.html

1 {% extends 'index.html' %}
2 {%block cssandjs%}
3
4
7
8
11
12 {%endblock%}
13
14 {%block change%}
15


72 {%endblock%}
73
74
75
76 {%block data %}
77

78

共计{{count}}


79
80
84

85
86 87 88 89 90 91 92 93 94 95 96 97 {%for x in db_queryset%} 98 99 102 105 108 111 114 117 120 125 126 {%endfor%} 127
添加日期厂商类型型号SN镜像备注操作
100 {{x.date}} 101 103 104 106 107 109 110 112 113 115 116 118 119 121 编辑 122 123 删除 124

128 {{limit}}
129 {%endblock%}
130

switch.html

1 {% extends 'index.html' %}
2
3 {%block cssandjs%}
4
5
8
9
11
12 {%endblock%}
13
14 {%block change%}
15


24 {%endblock%}
25
26 {%block data %}
27
28

29
30

31
32 33 34 35 36 37 38 {%for x in db_queryset%} 39 40 43 44 48 49 {%endfor%} 50
添加日期设备类型操作
41 {{x.date}} 42 {{x.device_type}} 45 46 删除 47

51 {{limit}}
52 {%endblock%}
53

type_manage.html

1 {% extends 'index.html' %}
2 {%block cssandjs%}
3
4
7
8
10
11 {%endblock%}
12
13 {%block change%}
14


23 {%endblock%}
24
25 {%block data %}
26
27

28
29

30
31 32 33 34 35 36 37 {%for x in db_queryset%} 38 39 42 43 46 47 {%endfor%} 48
添加日期厂商操作
40 {{x.date}} 41 {{x.vendor_name}} 44 删除 45

49 {{limit}}
50 {%endblock%}
51

vendor_manage.html