From e8b6e827ebc4fb6110652aff2c0a37f3476b17b1 Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Wed, 20 Nov 2019 14:33:29 +0800 Subject: [PATCH] kaoshi --- mysite/settings.py | 4 +- safesite/templates/equipmentfigure.html | 280 +++++++++++++++++++++++- safesite/templates/examhistory.html | 21 +- safesite/urls.py | 2 +- safesite/views.py | 20 +- 5 files changed, 318 insertions(+), 9 deletions(-) diff --git a/mysite/settings.py b/mysite/settings.py index 01ffba4e..8f76d9a8 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -85,8 +85,8 @@ DATABASES = { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'safedb', 'USER':'postgres', - 'PASSWORD':'0000', - 'HOST':'114.115.210.98', + 'PASSWORD':'cTc1111Qa', + 'HOST':'121.36.23.77', 'PORT':'5432', 'CONN_MAX_AGE': 600, }, diff --git a/safesite/templates/equipmentfigure.html b/safesite/templates/equipmentfigure.html index 98f380eb..c038d430 100644 --- a/safesite/templates/equipmentfigure.html +++ b/safesite/templates/equipmentfigure.html @@ -1 +1,279 @@ -
正在完成
\ No newline at end of file + + + + +
+ +
+
+ + + + +
+ +
+
+
+ +
+ +
+
+
+ + + + + + + + +
姓名用户名培训次数
+
+
+ +
+ + + + 查询 + 导出 +
+ +
+
+
+
+ +
diff --git a/safesite/templates/examhistory.html b/safesite/templates/examhistory.html index b3ea40ea..fdcabb1a 100644 --- a/safesite/templates/examhistory.html +++ b/safesite/templates/examhistory.html @@ -1,4 +1,4 @@ - + @@ -30,6 +30,7 @@ type: "get", url: "/api/examtestdetail?a=detail", data: { 'id': id }, + async: true, dateType: "json", success: function (data) { document.getElementById("examname").innerHTML = data.examtest__name; @@ -49,7 +50,9 @@ divHtml += '' + "【判断题】"+"第"+i+"题:" + data.testdetail[i].question__title +''; divHtml += '此题得分:' + data.testdetail[i].iscore + ' 分'; divHtml += '
'; - divHtml += '
A.' + data.testdetail[i].question__answer.A + '

B.' + data.testdetail[i].question__answer.B +'
'; + for (var item in data.testdetail[i].question__answer) { + divHtml += '
' + item + '、' + data.testdetail[i].question__answer[item] + '
'; + } divHtml += '
'; divHtml += '
'; divHtml += '
正确答案:' + data.testdetail[i].question__right + '
'; @@ -62,13 +65,16 @@ divHtml += '
' + (data.testdetail[i].question_resolution == undefined ? '本题无解析!' : data.testdetail[i].question_resolution) +'
'; } else if (data.testdetail[i].question__type == 2) { + console.log(data.testdetail[i]) var divHtml = ""; var answrText = ""; divHtml += '
'; divHtml += '' + "【多选题】" +"第" + i + "题:" + data.testdetail[i].question__title + ''; divHtml += '此题得分:' + data.testdetail[i].iscore + ' 分'; divHtml += '
'; - divHtml += '
A.' + data.testdetail[i].question__answer.A + '

B.' + data.testdetail[i].question__answer.B + '

C.' + data.testdetail[i].question__answer.C + '

D.' + data.testdetail[i].question__answer.D + '

E.' + (data.testdetail[i].question__answer.E == undefined ? '无该选项' : data.testdetail[i].question__answer.E) + '

F.' + (data.testdetail[i].question__answer.F == undefined ? '无该选项' : data.testdetail[i].question__answer.F) + '
'; + for (var item in data.testdetail[i].question__answer) { + divHtml += '
' + item + '、' + data.testdetail[i].question__answer[item] + '
'; + } divHtml += '
'; divHtml += '
'; divHtml += '
正确答案:' + data.testdetail[i].question__right + '
'; @@ -91,7 +97,14 @@ divHtml += '' + "【单选题】" + "第" + i + "题:" + data.testdetail[i].question__title + ''; divHtml += '此题得分:' + data.testdetail[i].iscore + ' 分'; divHtml += '
'; - divHtml += '
A.' + data.testdetail[i].question__answer.A + '

B.' + data.testdetail[i].question__answer.B + '

C.' + data.testdetail[i].question__answer.C + '

D.' + data.testdetail[i].question__answer.D + '
'; + for (var item in data.testdetail[i].question__answer) { + if (data.testdetail[i].question__answer[item] != "") + { + divHtml += '
' + item + '、' + data.testdetail[i].question__answer[item] + '
'; + } + + } + divHtml += '
'; divHtml += '
'; divHtml += '
正确答案:' + data.testdetail[i].question__right + '
'; diff --git a/safesite/urls.py b/safesite/urls.py index 0730db2b..934b6455 100644 --- a/safesite/urls.py +++ b/safesite/urls.py @@ -158,7 +158,7 @@ urlpatterns = [ path('api/riskas',views.apiriskas), path('api/trainfg',views.trainfg), path('api/check_session',views.check_session), - + path('api/equipmentfig',views.equipmentfig),#设备统计图 #path('api/rights/group/',views.rightsgroup), path('api/main',views.mainapi), path('bindwechat', views.bwlogin,name='bwlogin'), #微信登陆绑定相关 diff --git a/safesite/views.py b/safesite/views.py index c3de2af4..e18c6cd1 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -6145,4 +6145,22 @@ def trainfg(req): dickeyname=i.dickeyname traintypelist.append({'value':count,'name':dickeyname}) return HttpResponse(json.dumps({'code':1,'data':{'traintypelist':list(traintypelist)}}), content_type='application/json') - \ No newline at end of file +#设备统计图 + +def equipmentfig(req): + a = req.GET.get('a') + userid = req.session['userid'] + companyid = getcompany(userid) + + if a=='state': + # year = int(req.GET.get('year')) + # month = int(req.GET.get('month')) + # first_day,first_day_of_next_month = gettime(datetime(year,month,1)) + a = Equipment.objects.filter(usecomp__partid=companyid,deletemark=1) + normal = a.filter(state=1).count()#正常 + abnormal = a.filter(state=0).count()#异常 + return JsonResponse({"code":1,"normal":normal,"abnormal":abnormal}) + elif a=='eqmcount': + eqmlist=Equipment.objects.filter(usecomp__partid=companyid,deletemark=1).values('area__name').annotate(num = Count('area')) + + return HttpResponse(json.dumps({'code':1,'data':{'eqmlist':list(eqmlist)}}), content_type='application/json') \ No newline at end of file