Merge branch 'master' of 10.7.100.160:/job/safesite

This commit is contained in:
caoqianming 2019-10-10 16:02:30 +08:00
commit 023709fd9b
18 changed files with 793 additions and 93 deletions

0
safesite/mgt/__init__.py Normal file
View File

11
safesite/mgt/urls.py Normal file
View File

@ -0,0 +1,11 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index),
path('add',views.add),
path('api',views.api),
path('getdickey', views.getdickey),
path('upload', views.upload),
]

92
safesite/mgt/views.py Normal file
View File

@ -0,0 +1,92 @@
from django.shortcuts import render,redirect,render_to_response
from django.http import HttpResponse, HttpResponseRedirect,JsonResponse
from ..models import User,Trouble,Dickey,Partment,Dicclass,Train,Drill,TroubleAccess,Group,Yjyc,Trainuser,Drilluser,Yjsetup,Menu,Observe,Observeto,Unsafes,Miss,Socertificate,Userprofile,Suggest,Notice,Noticeto,Operation,Operzyry,Fxcs,Operationspjd,Operspxq,Question,ExamPaper,ExamTest,ExamPaperDetail,ExamTestDetail,Questioncat,Safecert,Map,Area,Missto,Suggestflow,Equipment,Inspect,Risk,RiskAct,Edulesson,EdulessonWatch,FileManage,FileReader,Regulations,Mgtsystem
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt
from django.core import serializers
import json
from uuid import UUID
import os
import time
from datetime import datetime,date,timedelta
from django.db.models import F,Count,Sum
import requests
from ..tasks import send_wechatmsgs,send_wechatmsg,yjjs,gettime,yjjs_px,yjjs_yl,updateTzzs,updateAqzs
from ..export import exportdoc,exportxlsx,exportyjdoc,exportsimplexlsx,exportdoc2
from ..daoru import drusers,drequipments,drrisks
from django.forms.models import model_to_dict
from ..safespider import getTzzs,getAqzs
#from duibiao import calsim
from django.db.models import Q
from django.core.serializers.json import DjangoJSONEncoder
from io import StringIO
import operator
import jwt
from ..views import getcompany,fenye,transjson
#法律法规
def index(req):
return render(req,'mgtindex.html')
def add(req):
return render(req,'mgtadd.html')
#上传文件,返回地址和名称
def upload(req):
username = User.objects.get(userid=req.session['userid']).username
file_name = time.strftime('%Y%m%d%H%M%S')+ '_' + req.FILES['mf'].name
user_upload_folder = os.path.join('media/mgt', username)
if not os.path.exists(user_upload_folder):
os.mkdir(user_upload_folder)
filepath = os.path.join(user_upload_folder, file_name)
filepath = filepath.replace('\\','/')
with open( filepath, 'wb') as f:
f.write(req.FILES['mf'].read())
return JsonResponse({"code":1,"filename":file_name,"filepath":filepath})
#转换为combobox所用string
def transstr(obj,str1,str2):
keylist = []
for i in list(obj):
keydictstr = '{"value":"'+ str(i[str1])+'","text":"'+i[str2]+'"}'
keylist.append(keydictstr)
keystr = '['+','.join(keylist)+']'
return keystr
def getdickey(req):
dicclass=req.GET.get('dicclass')
a = Dickey.objects.filter(dicparent=req.GET.get('dicclass'),deletemark=1)
a = a.values('dickeyid','dicparent__dicname','dickeyname','dicparent__dicid','detail').order_by('dickeyid')
return HttpResponse(transstr(a,'dickeyid','dickeyname'),content_type="application/json")
def api(req):
a=req.GET.get('a')
userid = req.session['userid']
companyid = getcompany(userid)
if a == 'add':
obj = Mgtsystem()
data = json.loads(req.body.decode('utf-8'))
obj.mgtname = data['mgtname']
obj.mgtpath = data['filepath']
obj.type= Dickey.objects.get(dickeyid=data['type'])
obj.publisdate=data['publisdate']
obj.usecomp=Partment.objects.get(partid=companyid)
obj.createuser=User.objects.get(userid=userid)
obj.save()
return JsonResponse({"code":1})
elif a=='listall':
startnum,endnum=fenye(req)
a = Mgtsystem.objects.filter(usecomp=Partment.objects.get(partid=companyid) ,deletemark=1).order_by('id')
total = a.count()
startnum,endnum=fenye(req)
a = a[startnum:endnum].values('id','mgtname','mgtpath','type__dickeyname','publisdate','createuser__name')
return HttpResponse(transjson(total,a),content_type="application/json")
elif a == 'del':
id =req.GET.get('id')
userid = req.session['userid']
a = Mgtsystem.objects.get(id=id)
if a.usecomp==Partment.objects.get(partid=companyid):
a.deletemark=0
a.save()
return JsonResponse({"code":1})
else:
return JsonResponse({"code":0})

View File

@ -0,0 +1,29 @@
# Generated by Django 2.1.5 on 2019-09-23 10:17
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('safesite', '0269_auto_20190919_1423'),
]
operations = [
migrations.CreateModel(
name='Mgtsystem',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mgtname', models.CharField(max_length=50)),
('mgtpath', models.CharField(blank=True, max_length=200, null=True)),
('publisdate', models.DateTimeField(default=django.utils.timezone.now)),
('deletemark', models.IntegerField(default=1)),
('createuser', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='safesite.User')),
('type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='safesite.Dickey')),
('usecomp', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='safesite.Partment')),
],
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-09-23 10:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('safesite', '0270_auto_20190923_1017'),
]
operations = [
migrations.AlterField(
model_name='mgtsystem',
name='mgtname',
field=models.CharField(max_length=64),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 2.1.5 on 2019-09-23 10:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('safesite', '0271_auto_20190923_1018'),
]
operations = [
migrations.AlterField(
model_name='mgtsystem',
name='id',
field=models.AutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='mgtsystem',
name='mgtname',
field=models.CharField(max_length=50),
),
]

View File

@ -871,3 +871,14 @@ class FileManage(models.Model):
usecomp= models.ForeignKey(Partment,on_delete=models.CASCADE,null=True,blank=True)
downnum = models.IntegerField(default=0)
deletemark = models.IntegerField(default=1)
#管理制度表
class Mgtsystem(models.Model):
id = models.AutoField(primary_key=True)
mgtname = models.CharField(max_length=50)
type = models.ForeignKey(Dickey,on_delete=models.CASCADE,null=True,blank=True)
usecomp = models.ForeignKey(Partment,on_delete=models.CASCADE,null=True,blank=True)
mgtpath = models.CharField(max_length=200,null=True,blank=True)
publisdate = models.DateTimeField(default = timezone.now)
createuser = models.ForeignKey(User,on_delete=models.CASCADE)
deletemark = models.IntegerField(default=1)

View File

@ -148,6 +148,9 @@
.icon-edu{
background:url('icons/edu.png') no-repeat center center;
}
.icon-gmt {
background: url('icons/gmt.png') no-repeat center center;
}
.icon-regulationstype {
background: url('icons/regulationstype.png') no-repeat center center;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

View File

@ -135,7 +135,7 @@
<a class="list" href="javascript:;">
<input id="file" type="file" name="myfile" onchange="UpladFile();" /><span>选择视频</span>
</a>
<button class="btn" type="button" onclick="sub();">上传</button>
<!--<button class="btn" type="button" onclick="sub();">上传</button>-->
</p>
<!--显示消失-->
@ -220,37 +220,35 @@
$(".el-upload-list").css("display", "block");
$(".el-upload-list li").css("border", "1px solid #20a0ff");
$("#videoName").text(fileObj.name);
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj == undefined || fileObj == "") {
alert("请选择文件");
return false;
};
var imagSize = document.getElementById("file").files[0].size;
if (imagSize > 1024 * 1024 * 10) {
alert("视频大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M超出了上传大小" + "请选择3M以内的视频");
return false;
}
var url = "edu/api/upload"; // 接收上传文件的后台地址
var form = new FormData(); // FormData 对象
form.append("mf", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = uploadComplete; //请求完成
xhr.onerror = uploadFailed; //请求失败
xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
xhr.upload.onloadstart = function () { //上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0; //设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
} else {
alert("请选择文件");
}
}
/*点击提交*/
function sub() {
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj == undefined || fileObj == "") {
alert("请选择文件");
return false;
};
var imagSize = document.getElementById("file").files[0].size;
if (imagSize > 1024 * 1024 * 10) {
alert("视频大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M超出了上传大小" + "请选择3M以内的视频");
return false;
}
var url = "edu/api/upload"; // 接收上传文件的后台地址
var form = new FormData(); // FormData 对象
form.append("mf",fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = uploadComplete; //请求完成
xhr.onerror = uploadFailed; //请求失败
xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
xhr.upload.onloadstart = function () { //上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0; //设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
}
//上传进度实现方法,上传过程中会频繁调用该方法
function progressFunction(evt) {

View File

@ -150,7 +150,7 @@
<a class="list" href="javascript:;">
<input id="file" type="file" name="myfile" onchange="UpladFile();" /><span>选择文件</span>
</a>
<button class="btn" type="button" onclick="sub();">上传</button>
<!--<button class="btn" type="button" onclick="sub();">上传</button>-->
<a class="el-upload-list__item-name">
<i class="el-icon-document"></i><span class="ploadname" id="fileName">上传文件名称</span>
</a>
@ -228,7 +228,30 @@
$(".el-upload-list").css("display", "block");
$(".el-upload-list li").css("border", "1px solid #20a0ff");
$("#fileName").text(fileObj.name);
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj == undefined || fileObj == "") {
alert("请选择文件");
return false;
};
var imagSize = document.getElementById("file").files[0].size;
if (imagSize > 1024 * 1024 * 3) {
alert("文件大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M超出了上传大小" + "请选择3M以内的文件");
return false;
}
var url = "edu/api/upload"; // 接收上传文件的后台地址
var form = new FormData(); // FormData 对象
form.append("mf", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = uploadComplete; //请求完成
xhr.onerror = uploadFailed; //请求失败
xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
xhr.upload.onloadstart = function () { //上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0; //设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
}
else {
@ -236,35 +259,7 @@
}
}
/*点击提交*/
function sub() {
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj == undefined || fileObj == "") {
alert("请选择文件");
return false;
};
var imagSize = document.getElementById("file").files[0].size;
if (imagSize > 1024 * 1024 * 3)
{
alert("文件大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M超出了上传大小" + "请选择3M以内的文件");
return false;
}
var url = "edu/api/upload"; // 接收上传文件的后台地址
var form = new FormData(); // FormData 对象
form.append("mf",fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = uploadComplete; //请求完成
xhr.onerror = uploadFailed; //请求失败
xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
xhr.upload.onloadstart = function () { //上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0; //设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
}
//上传进度实现方法,上传过程中会频繁调用该方法
function progressFunction(evt) {
// event.total是需要传输的总字节event.loaded是已经传输的字节。如果event.lengthComputable不为真则event.total等于0

View File

@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>答题详情</title>
<script type="text/javascript" src="/static/safesite/easyui/jquery.min.js"></script>
</head>
<body >
<div style="height:100%;overflow:auto;width:70%;background-color:lightcyan;margin:0 auto;">
<div id="examname" style="font-size: 36px;color: #73348a;text-align: center;margin-top: 30px;font-weight: bold;"></div>
<div style="height:200px" id="user">
</div>
<div id="examtype1"></div>
</div>
</body>
</html>
<script>
var id = {{id }};
var html;
alert(id);
$.ajax({
type: "get",
url: "/api/examtestdetail?a=detail",
data: { 'id': id },
dateType: "json",
success: function (data) {
document.getElementById("examname").innerHTML = data.examtest__name;
var divUserHtml = "";
divUserHtml += '<div style="margin-left:10px;padding-bottom:13px;float:left"><image style="margin: 10px 10px;" src=' + data.user__headimgurl + '></image></div>';
divUserHtml += '<div style="float:left;margin-top: 20px;margin-left:20px"><p>姓名:' + data.user__name + '</p><p>得分:' + data.score + '</p><p>是否通过:' + (data.passcode == 1 ? '通过' : '不通过') + '</p></div > ';
$("#user").append(divUserHtml);
for (var i = 1; i <= data.testdetail.length; i++) {
if (data.testdetail[i].question__type == 3)
{
var divHtml = "";
divHtml += '<div style="margin-left:30px;padding-bottom:13px">';
divHtml += '<span style="color:blue">' + "【判断题】</span></span>"+"第"+i+"题:" + data.testdetail[i].question__title +'</span>';
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
divHtml += '<br />';
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B +'</span></div>';
divHtml += '<br />';
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
if (data.testdetail[i].iscore == 0) {
divHtml += '<div style="color:red;">您的答案错误:' + data.testdetail[i].userchecked + '</div>';
}
else {
divHtml += '<div style="color:green;">您的答案正确:' + data.testdetail[i].userchecked + '</div>';
}
}
else if (data.testdetail[i].question__type == 2) {
var divHtml = "";
var answrText = "";
divHtml += '<div style="margin-left:30px;padding-bottom:13px">';
divHtml += '<span style="color:blue">' + "【多选题】</span></span>" +"第" + i + "题:" + data.testdetail[i].question__title + '</span>';
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
divHtml += '<br />';
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B + '</span></br></br><span>C.' + data.testdetail[i].question__answer.C + '</span></br></br><span>D.' + data.testdetail[i].question__answer.D + '</span></br></br><span>E.' + (data.testdetail[i].question__answer.E == undefined ? '无该选项' : data.testdetail[i].question__answer.E) + '</span></br></br><span>F.' + (data.testdetail[i].question__answer.F == undefined ? '无该选项' : data.testdetail[i].question__answer.F) + '</span></div>';
divHtml += '<br />';
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
if (data.testdetail[i].iscore == data.testdetail[i].score) {
divHtml += '<div style="color:green;">您的答案正确:' + data.testdetail[i].userchecked + '</div>';
}
else if (data.testdetail[i].iscore == 0) {
divHtml += '<div style="color:red;">您的答案错误:' + data.testdetail[i].userchecked + '</div>';
}
else {
divHtml += '<div style="color:yellow;">您没有选全答案:' + data.testdetail[i].userchecked + '</div>';
}
}
else {
var divHtml = "";
var answrText = "";
divHtml += '<div style="margin-left:30px;padding-bottom:13px">';
divHtml += '<span style="color:blue">' + "【单选题】</span></span>" + "第" + i + "题:" + data.testdetail[i].question__title + '</span>';
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
divHtml += '<br />';
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B + '</span></br></br><span>C.' + data.testdetail[i].question__answer.C + '</span></br></br><span>D.' + data.testdetail[i].question__answer.D + '</span></div>';
divHtml += '<br />';
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
if (data.testdetail[i].iscore == 0) {
divHtml += '<div style="color:red;">您的答案错误:' + data.testdetail[i].userchecked + '</div>';
}
else {
divHtml += '<div style="color:green;">您的答案正确:' + data.testdetail[i].userchecked + '</div>';
}
}
$("#examtype1").append(divHtml);
}
},
error: function () {
return false;
},
async: false
});
</script>

View File

@ -60,16 +60,16 @@
<table class='detailtable'>
<thead>
<tr>
<th style="width:10%">
序号
</th>
<th style="width:10%">
序号
</th>
<th style="width:20%">
姓名
</th>
<th style="width:30%">
部门
</th>
<th style="width:20%">
部门
</th>
<th style="width:15%">
状态
</th>
<th style="width:10%">
@ -78,6 +78,9 @@
<th style="width:10%">
用时
</th>
<th style="width:15%">
答题详情
</th>
</tr>
</thead>
{{each cjrydetail}}
@ -92,6 +95,7 @@
{{/if}}
<td>{{$value.score}}</td>
<td>{{$value.took}}</td>
<td><a target="_blank" href="/html/examhistory/{{$value.id}}" >点击查看</a></td>
</tr>
{{/each}}
</table>
@ -183,4 +187,6 @@
}
});
}
</script>

View File

@ -158,7 +158,7 @@
<a class="list" href="javascript:;">
<input id="file" type="file" name="maragepath" onchange="UpladFile();" /><span>选择文件</span>
</a>
<button class="btn" type="button" onclick="sub();">上传</button>
</p>
<!--显示消失-->
@ -219,7 +219,7 @@
success: function (data) {
if (data.code == 1) {
alert("数据保存!");
$('#edutab').datagrid('reload');
$('#tmtable').datagrid('reload');
$("#dd").dialog("close");
} else { $.messager.alert('提示', '失败!'); }
$('#submitb').linkbutton('enable');
@ -241,37 +241,37 @@
//$("#maragename").text(fileObj.name);
$("#maragename").textbox('setValue', fileObj.name)
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj == undefined || fileObj == "") {
alert("请选择文件");
return false;
};
var imagSize = document.getElementById("file").files[0].size;
if (imagSize > 1024 * 1024 * 10) {
alert("文件大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M超出了上传大小" + "请选择10M以内的文件");
return false;
}
var url = "rlt/api/upload"; // 接收上传文件的后台地址
var form = new FormData(); // FormData 对象
form.append("mf", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = uploadComplete; //请求完成
xhr.onerror = uploadFailed; //请求失败
xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
xhr.upload.onloadstart = function () { //上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0; //设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
} else {
alert("请选择文件");
}
}
/*点击提交*/
function sub() {
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj == undefined || fileObj == "") {
alert("请选择文件");
return false;
};
var imagSize = document.getElementById("file").files[0].size;
if (imagSize > 1024 * 1024 * 10) {
alert("文件大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M超出了上传大小" + "请选择3M以内的文件");
return false;
}
var url = "rlt/api/upload"; // 接收上传文件的后台地址
var form = new FormData(); // FormData 对象
form.append("mf",fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = uploadComplete; //请求完成
xhr.onerror = uploadFailed; //请求失败
xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
xhr.upload.onloadstart = function () { //上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0; //设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
}
//上传进度实现方法,上传过程中会频繁调用该方法
function progressFunction(evt) {

View File

@ -0,0 +1,312 @@
<style type="text/css">
#content {
border: 1px solid saddlebrown;
padding: 16px;
border-radius: 2px
}
.list {
top: 15px;
width: 140px;
height: 40px;
border: 1px solid #0082E6;
display: inline-block;
border-radius: 2px;
position: relative;
line-height: 40px;
}
#file {
position: absolute;
opacity: 0;
color: white;
width: 100%;
height: 100%;
z-index: 100;
}
.list span {
display: inline-block;
text-align: center;
width: 100%;
line-height: 40px;
position: absolute;
color: #0082E6;
}
video {
margin-top: 8px;
border-radius: 4px;
}
._p {
margin: 14px;
}
._p input {
display: inline-block;
width: 70%;
margin-left: 6px;
}
._p span {
font-size: 15px;
}
.container {
width: 100%;
height: 20px;
background-color: gray;
}
#progress {
height: 20px;
background-color: orange;
display: inline-block;
}
.btn {
text-align: center;
color: #0082E6;
width: 140px;
height: 41px;
border: 1px solid #0082E6;
display: inline-block;
border-radius: 2px;
position: relative;
line-height: 40px;
background-color: white;
}
.ploadname {
display: inline-block;
text-align: center;
color: #0082E6;
height: 40px;
display: inline-block;
border-radius: 2px;
position: relative;
line-height: 40px;
background-color: white;
}
</style>
<div class="easyui-layout" style="width:100%;height:100%;">
<form id="edu" method="post" name="edu" enctype="multipart/form-data">
<div data-options="region:'center'" style="padding:15px 15px;">
<table class="listTab">
<tr>
<td>制度标题:</td>
<td>
<input id="title" class="easyui-textbox" name="mgtname" style="width:480px">
</td>
</tr>
<tr>
<td>上传时间:</td>
<td>
<input id="submittime" editable="false" name="publisdate" class="easyui-datetimebox" style="width:480px"
data-options="currentText:'今天',closeText:'关闭',showSeconds:false" />
</td>
</tr>
<tr>
<td>所属类别:</td>
<td>
<input id="mgttype" name="type" class="easyui-textbox" style="width:480px">
</td>
</tr>
</table>
<div id="content">
<p class="_p">
<span>选择文件: </span>
<!--文件选择按钮-->
<a class="list" href="javascript:;">
<input id="file" type="file" name="myfile" onchange="UpladFile();" /><span>选择文件</span>
</a>
</p>
<!--显示消失-->
<ul class="el-upload-list el-upload-list--text" style="display: none;list-style-type:none">
<li tabindex="0" class="el-upload-list__item is-success">
<a class="el-upload-list__item-name">
<i class="el-icon-document"></i><span class="ploadname" id="videoName">food.jpeg</span>
</a>
</li>
</ul>
<span id="url" style="display:none"></span>
<!--进度条-->
<div class="el-progress el-progress--line" style="display: none;">
<div class='container'>
<span id="progress"></span>
</div>
<!--上传速度显示-->
<span id="time"></span>
</div>
</div>
</div>
<div id='southdiv' data-options="region:'south'" style="height:50px;text-align:center;padding:5px">
<a href="javascript:void(0)" iconCls="fa-check" class="easyui-linkbutton" onclick="wssubmitForm()" id="submitb">提交</a>
<a href="javascript:void(0)" iconCls="fa-close" class="easyui-linkbutton" onclick="closeForm()">取消</a>
</div>
</form>
</div>
<script type="text/javascript">
$("#mgttype").combobox({
url: 'mgt/getdickey?dicclass=55',
valueField: 'value',
textField: 'text',
editable: false,
});
function wssubmitForm() {
var edudata = $('#edu').serializeJSON();
edudata['filepath'] = document.getElementById('url').innerHTML;
$.ajax({
type: "POST",
url: 'mgt/api?a=add',
data: JSON.stringify(edudata),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
var bo = $('#edu').form('validate')
if (bo == false) {
return bo
} else {
$('#submitb').linkbutton('disable');
}
},
success: function (data) {
if (data.code == 1) {
alert("数据保存!");
$('#mgttab').datagrid('reload');
$("#dd").dialog("close");
} else { $.messager.alert('提示', '失败!'); }
$('#submitb').linkbutton('enable');
},
});
}
var xhr;//异步请求对象
var ot; //时间
var oloaded;//大小
//上传文件方法
function UpladFile() {
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj.name) {
$(".el-upload-list").css("display", "block");
$(".el-upload-list li").css("border", "1px solid #20a0ff");
$("#videoName").text(fileObj.name);
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj == undefined || fileObj == "") {
alert("请选择文件");
return false;
};
var imagSize = document.getElementById("file").files[0].size;
if (imagSize > 1024 * 1024 * 10) {
alert("视频大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M超出了上传大小" + "请选择3M以内的视频");
return false;
}
var url = "mgt/upload"; // 接收上传文件的后台地址
var form = new FormData(); // FormData 对象
form.append("mf", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = uploadComplete; //请求完成
xhr.onerror = uploadFailed; //请求失败
xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
xhr.upload.onloadstart = function () { //上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0; //设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
} else {
alert("请选择文件");
}
}
//上传进度实现方法,上传过程中会频繁调用该方法
function progressFunction(evt) {
// event.total是需要传输的总字节event.loaded是已经传输的字节。如果event.lengthComputable不为真则event.total等于0
if (evt.lengthComputable) {
$(".el-progress--line").css("display", "block");
var percent = Math.round(evt.loaded * 100 / evt.total);
/*进度条显示进度*/
document.getElementById('progress').innerHTML = Math.round(evt.loaded / evt.total * 100) + "%";
document.getElementById('progress').style.width = percent.toFixed(2) + '%';
}
var time = document.getElementById("time");
var nt = new Date().getTime(); //获取当前时间
var pertime = (nt - ot) / 1000; //计算出上次调用该方法时到现在的时间差单位为s
ot = new Date().getTime(); //重新赋值时间,用于下次计算
var perload = evt.loaded - oloaded; //计算该分段上传的文件大小单位b
oloaded = evt.loaded; //重新赋值已上传文件大小,用以下次计算
//上传速度计算
var speed = perload / pertime; //单位b/s
var bspeed = speed;
var units = 'b/s'; //单位名称
if (speed / 1024 > 1) {
speed = speed / 1024;
units = 'k/s';
}
if (speed / 1024 > 1) {
speed = speed / 1024;
units = 'M/s';
}
speed = speed.toFixed(1);
//剩余时间
var resttime = ((evt.total - evt.loaded) / bspeed).toFixed(1);
time.innerHTML = '上传速度:' + speed + units + ',剩余时间:' + resttime + 's';
if (bspeed == 0)
time.innerHTML = '上传已取消';
}
//上传成功响应
function uploadComplete(evt) {
//服务断接收完文件返回的结果 注意返回的字符串要去掉双引号
if (evt.target.responseText) {
var data = JSON.parse(evt.target.responseText);
if (data.code = 1) {
var str = data.filepath;
document.getElementById('url').innerHTML = str;
alert("上传成功!");
$(".preview").append("<video controls='' autoplay='' style='width:200px;height200px' name='media'><source src=" + str + " type='video/mp4'></video>");
}
} else {
alert("上传失败");
}
}
//上传失败
function uploadFailed(evt) {
alert("上传失败!");
}
</script>

View File

@ -0,0 +1,78 @@
<div id="edubar" style="padding: 4px;height: 40px;background-color:#FCFCFC">
<div style="width: 500px;padding: 5px;">
<a id="addedu" class="easyui-linkbutton" onclick="javascript:opendg('新增文件','mgt/add')" data-options="iconCls: 'fa-plus',plain:true">新增</a>
<a id="deledu" class="easyui-linkbutton" onclick="deledu()" data-options="iconCls: 'fa-trash',plain:true">删除</a>
</div>
</div>
<table id="mgttab" style="width:100%;height:100%;text-align: center;"></table>
<script>
$('#mgttab').datagrid({
url: 'mgt/api?a=listall',
rownumbers: true,
singleSelect: true,
striped: true,
fitColumns: true,
method: 'get',
pagination: 'true',
pageSize: 20,
border: false,
toolbar:'#edubar',
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ field: 'mgtname', title: '制度名称', width: 100 },
{ field: 'type__dickeyname', title: '制度类别', width: 100 },
{ field: 'publisdate', title: '上传时间', width: 100 },
{ field: 'createuser__name', title: '创建人', width: 100 },
{
field: 'mgtpath', title: '点击观看', width: 100, formatter: function (value, row, index) {
return '<a style="color:blue" target="_blank" href="' + row.mgtpath + '" id="one">点击查看</a>';
}
},
]]
});
function deledu() {
var row = $('#mgttab').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定删除吗?', function (r) {
if (r) {
$.ajax({
type: "GET",
url: 'mgt/api?a=del',
data: { 'id': row.id },
datatype: "json",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
$("#mgttab").datagrid('reload');
}
else {
$.messager.alert('提示', '你无权删除该条管理制度!');
}
},
complete: function (XMLHttpRequest, textStatus) {
},
error: function () {
}
});
}
});
}
else {
$.messager.alert('提示', '请选择一行数据!');
}
}
</script>

View File

@ -148,7 +148,7 @@ urlpatterns = [
#path('api/riskactcheck',views.apiriskactcheck),
path('api/riskcheck2',views.apiriskcheck2),
path('api/report',views.apireport),
path('html/examhistory/<int:id>/',views.examhistory),
#path('api/rights/group/<int:groupid>',views.rightsgroup),
@ -172,4 +172,5 @@ urlpatterns = [
path('datashow/charthandle', views.charthandle),
path('companyinfo/', views.companyinfo),
path('rlt/',include('safesite.rlt.urls')),
path('mgt/',include('safesite.mgt.urls')),
]

View File

@ -135,6 +135,8 @@ def exampaperadd(req):
return render(req,'exampaperadd.html')
def exampaper(req):
return render(req,'exampaper.html')
def examhistory(req,id):
return render(req,'examhistory.html',{'id':id})
def questionadd(req):
return render(req,'questionadd.html')
def questionadd2(req):
@ -4906,7 +4908,7 @@ def apiexamtestdetail(req):
elif a == 'detail':
id = req.GET.get('id')
obj = ExamTestDetail.objects.filter(id=id)
data = obj.values('id','starttime','took','score','testdetail')[0]
data = obj.values('id','starttime','took','score','passcode','testdetail','examtest__name','user__headimgurl','user__name')[0]
return JsonResponse(data)
def apitrain(req):