diff --git a/safesite/migrations/0330_auto_20200409_1530.py b/safesite/migrations/0330_auto_20200409_1530.py new file mode 100644 index 00000000..e6a4139f --- /dev/null +++ b/safesite/migrations/0330_auto_20200409_1530.py @@ -0,0 +1,24 @@ +# Generated by Django 2.2.8 on 2020-04-09 15:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0329_auto_20200323_0957'), + ] + + operations = [ + + migrations.AddField( + model_name='checkjob', + name='yhtp', + field=models.CharField(blank=True, max_length=1000), + ), + migrations.AddField( + model_name='checkjob', + name='zghtp', + field=models.CharField(blank=True, max_length=1000), + ), + ] diff --git a/safesite/models.py b/safesite/models.py index d25091f8..4a5af80d 100644 --- a/safesite/models.py +++ b/safesite/models.py @@ -1270,3 +1270,5 @@ class Checkjob(models.Model): yanshouren=models.ForeignKey(User,related_name='yanshouren',on_delete=models.CASCADE,null=True)#验收人员 pmpeople=models.ManyToManyField(User,related_name='bcfr',null=True)#被处罚人员 content=models.CharField(max_length=400,null=True)#处罚内容 + yhtp = models.CharField(max_length=1000, blank=True) + zghtp = models.CharField(max_length=1000, blank=True) diff --git a/safesite/templates/checkjob.html b/safesite/templates/checkjob.html index 340df8ce..e242b631 100644 --- a/safesite/templates/checkjob.html +++ b/safesite/templates/checkjob.html @@ -54,7 +54,7 @@ { field: 'checktask__checktaskname', title: '任务名称', width: 100 }, { field: 'checktask__checktype__checktitle', title: '检查表', width: 100 }, - { field: 'checkname__username', title: '检查人员', width: 100 }, + { field: 'checkname__name', title: '检查人员', width: 100 }, //{ field: 'zguser__username', title: '整改人', width: 100 }, //{ field: 'zgtime', title: '整改时间', width: 100 }, diff --git a/safesite/templates/checkjobadd.html b/safesite/templates/checkjobadd.html index 010e4bfd..3c5ad570 100644 --- a/safesite/templates/checkjobadd.html +++ b/safesite/templates/checkjobadd.html @@ -40,57 +40,95 @@ - 检查发现的问题: + 检查问题: - + + 检查图片: + + + + + + + + - 整改情况: + + + + + + + + + 需要整改: + + + 整改图片: + + + + + + + + + + + + 检查状态: - 已整改完成 - 正在整改中 + 已整改完成 + 正在整改中 - +
+ data-options="label:'接受处理意见人员:',multiline:true,prompt:'没有接受处理意见人员可以不选'" > 选择
+ data-options="label:'处理意见:',multiline:true">
@@ -121,19 +159,202 @@ $('#checkplace').textbox('setValue', data.checktask__checkplace) $('#checkquestion').textbox('setValue', data.checkquestion) $('#zgjg').textbox('setValue', data.zgjg) - if (data.taskstate == 1) { - $("input[name='taskstate'][value=1]").attr("checked",true); - } - else - $("input[name='taskstate'][value=2]").attr("checked",true); + // if (data.taskstate == 1) { + // $("input[name='taskstate'][value=1]").attr("checked",true); + // } + //else + // $("input[name='taskstate'][value=2]").attr("checked",true); }); }) + //检查问题上传图片 + document.getElementById('file').onchange = function () { + var fileObj = this.files[0]; + var url = 'upfile' + var form = new FormData(); + if (fileObj.size / 1024 > 500) { //大于500k,进行压缩上传 + $("#file").after('图片大于500k,正在压缩...'); + photoCompress(fileObj, {}, function (base64Codes) { + //console.log("压缩后:" + base.length / 1024 + " " + base); + var bl = convertBase64UrlToBlob(base64Codes); + form.append("upfile", bl, fileObj.name); // 文件对象 + xhr = new XMLHttpRequest(); // XMLHttpRequest 对象 + xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。 + $("#tip").remove(); + $('#ps').show(); + xhr.onload = function (evt) { //服务断接收完文件返回的结果 + var data = JSON.parse(evt.target.responseText); + if (data.code = 1) { + $('#ps').hide(); + $("#addImage").append('
  • '); + document.getElementById('file').value = ''; + } else { alert("上传失败!"); } + }; //请求完成 + xhr.onerror = function (evt) { alert("上传失败!"); $('#ps').hide(); };; //请求失败 + + xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】 + xhr.upload.onloadstart = function () {//上传开始执行方法 + ot = new Date().getTime(); //设置上传开始时间 + oloaded = 0;//设置上传开始时,以上传的文件大小为0 + }; + + xhr.send(form); //开始上传,发送form数据 + }); + } else { //小于等于500k 原图上传 + form.append("upfile", fileObj); // 文件对象 + xhr = new XMLHttpRequest(); // XMLHttpRequest 对象 + xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。 + xhr.onload = function (evt) { //服务断接收完文件返回的结果 + var data = JSON.parse(evt.target.responseText); + if (data.code = 1) { + $('#ps').hide(); + $("#addImage").append('
  • '); + document.getElementById('file').value = ''; + } else { alert("上传失败!"); } + }; //请求完成 + xhr.onerror = function (evt) { alert("上传失败!"); $('#ps').hide(); };; //请求失败 + xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】 + xhr.upload.onloadstart = function () {//上传开始执行方法 + ot = new Date().getTime(); //设置上传开始时间 + oloaded = 0;//设置上传开始时,以上传的文件大小为0 + }; + + xhr.send(form); //开始上传,发送form数据 + } + function progressFunction(evt) { + var progressBar = document.getElementById("progressBar"); + var percentageDiv = document.getElementById("percentage"); + // event.total是需要传输的总字节,event.loaded是已经传输的字节。如果event.lengthComputable不为真,则event.total等于0 + if (evt.lengthComputable) {// + progressBar.max = evt.total; + progressBar.value = evt.loaded; + percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%"; + } + 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 = '上传已取消'; + } + } + document.getElementById('file2').onchange = function () { + var fileObj = this.files[0]; + var url = 'upfile' + var form = new FormData(); + if (fileObj.size / 1024 > 500) { //大于500k,进行压缩上传 + $("#file2").after('图片大于500k,正在压缩...'); + photoCompress(fileObj, {}, function (base64Codes) {//quality: 0.2 + //console.log("压缩后:" + base.length / 1024 + " " + base); + var bl = convertBase64UrlToBlob(base64Codes); + form.append("upfile", bl, fileObj.name); // 文件对象 + xhr = new XMLHttpRequest(); // XMLHttpRequest 对象 + xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。 + $("#tip").remove(); + $('#ps2').show(); + xhr.onload = function (evt) { //服务断接收完文件返回的结果 + var data = JSON.parse(evt.target.responseText); + if (data.code = 1) { + $('#ps2').hide(); + $("#addImage2").append('
  • '); + document.getElementById('file2').value = ''; + } else { alert("上传失败!"); } + }; //请求完成 + xhr.onerror = function (evt) { alert("上传失败!"); $('#ps2').hide(); };; //请求失败 + + xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】 + xhr.upload.onloadstart = function () {//上传开始执行方法 + ot = new Date().getTime(); //设置上传开始时间 + oloaded = 0;//设置上传开始时,以上传的文件大小为0 + }; + + xhr.send(form); //开始上传,发送form数据 + }); + } else { //小于等于1M 原图上传 + form.append("upfile", fileObj); // 文件对象 + xhr = new XMLHttpRequest(); // XMLHttpRequest 对象 + xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。 + xhr.onload = function (evt) { //服务断接收完文件返回的结果 + var data = JSON.parse(evt.target.responseText); + if (data.code = 1) { + $('#ps2').hide(); + $("#addImage2").append('
  • '); + document.getElementById('file2').value = ''; + } else { alert("上传失败!"); } + }; //请求完成 + xhr.onerror = function (evt) { alert("上传失败!"); $('#ps2').hide(); };; //请求失败 + xhr.send(form); //开始上传,发送form数据 + } + //上传进度实现方法,上传过程中会频繁调用该方法 + function progressFunction(evt) { + var progressBar = document.getElementById("progressBar2"); + var percentageDiv = document.getElementById("percentage2"); + // event.total是需要传输的总字节,event.loaded是已经传输的字节。如果event.lengthComputable不为真,则event.total等于0 + if (evt.lengthComputable) {// + progressBar.max = evt.total; + progressBar.value = evt.loaded; + percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%"; + } + var time = document.getElementById("time2"); + 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 wssubmitForm() { var wsdata = $('#wsff').serializeJSON(); + var yhtp = new Array(); + $(".yhtpimg").each(function () { + yhtp.push($(this).attr("filepath")); + }); + wsdata['yhtp'] = yhtp + var zghtp = new Array(); + $(".zghtpimg").each(function () { + zghtp.push($(this).attr("filepath")); + }); + wsdata['zghtp']=zghtp $.ajax({ type: "POST", url: 'api/checkproject?a=addjob&jobid='+jobid, diff --git a/safesite/templates/checkjobdetail.html b/safesite/templates/checkjobdetail.html index 24384c27..62235cab 100644 --- a/safesite/templates/checkjobdetail.html +++ b/safesite/templates/checkjobdetail.html @@ -21,13 +21,39 @@ {{checktask__checktype__checkcontent}} - 检查发现的问题: + 检查问题: {{checkquestion}} + + 问题图片 + + + {{each yhtp value index}} + +
    + + {{/each}} + + + + 整改情况: {{zgjg}} + + 整改图片 + + + {{each zghtp value index}} + +
    + + {{/each}} + + + + 检查状态: {{taskstate==1?'正在检查':'检查完毕'}} @@ -57,11 +83,11 @@ --> - 处罚内容: + 处理意见: {{content}} - 被处罚人员: + 接受处理意见人员: {{bcfr==[]?'kkl':bcfr}} diff --git a/safesite/views.py b/safesite/views.py index ece17ae2..4b725c74 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -7765,7 +7765,7 @@ def checkprojects(req): total = a.count() startnum, endnum = fenye(req) - a = a[startnum:endnum].values('id','checktaskname','tasktype','checkname','checktype__checktitle','checkplace', 'checktime','createuser__name','createdate') + a = a[startnum:endnum].values('id','checktaskname','checkname__name','tasktype','checkname','checktype__checktitle','checkplace', 'checktime','createuser__name','createdate') return HttpResponse(transjson(total, a), content_type="application/json") elif a == 'listall4': @@ -7774,7 +7774,7 @@ def checkprojects(req): total = a.count() startnum, endnum = fenye(req) - a = a.order_by('-starttime')[startnum:endnum].values('id','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate') + a = a.order_by('-starttime')[startnum:endnum].values('id','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username','checkname__name', 'taskstate','checktask__checktime','createuser__username','createdate') return HttpResponse(transjson(total, a), content_type="application/json") @@ -7783,7 +7783,7 @@ def checkprojects(req): a = Checkjob.objects.filter(usecomp=Partment.objects.get(partid=companyid),taskstate=2,checktask__createuser__userid=userid).exclude(deletemark=0) total = a.count() startnum, endnum = fenye(req) - a = a.order_by('-starttime')[startnum:endnum].values('id','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate') + a = a.order_by('-starttime')[startnum:endnum].values('id','checkname__name','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate') return HttpResponse(transjson(total, a), content_type="application/json") elif a == 'listself': @@ -7791,7 +7791,7 @@ def checkprojects(req): total = a.count() startnum, endnum = fenye(req) - a = a.order_by('-starttime')[startnum:endnum].values('id','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate') + a = a.order_by('-starttime')[startnum:endnum].values('id','checkname__name','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate') return HttpResponse(transjson(total, a), content_type="application/json") elif a == 'listallx': @@ -7799,7 +7799,7 @@ def checkprojects(req): partid=companyid),deletemark=1) total = a.count() startnum, endnum = fenye(req) - a = a.order_by('-starttime')[startnum:endnum].values('id','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate') + a = a.order_by('-starttime')[startnum:endnum].values('id','checkname__name','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate') return HttpResponse(transjson(total, a), content_type="application/json") @@ -7810,12 +7810,16 @@ def checkprojects(req): return JsonResponse({'code': 1, 'data': obj}) elif a == 'addjob': data = json.loads(req.body.decode('utf-8')) + yhtp = '?'.join(data['yhtp']) if 'yhtp' in data else [] + zghtp = '?'.join(data['zghtp']) if 'zghtp' in data else [] obj = Checkjob.objects.get(id=req.GET.get('jobid')) obj.checkquestion = data['checkquestion'] obj.zgjg = data['zgjg'] obj.taskstate = data['taskstate'] obj.createuser = User.objects.get(userid=userid) obj.content=data['content'] + obj.yhtp=yhtp + obj.zghtp=zghtp s=[] if data['participant']!="": list = data['participant'].split(',') @@ -7883,13 +7887,13 @@ def checkprojects(req): 'value': '处罚通知:' }, 'keyword1': { - 'value':'处罚内容:'+ obj.content + 'value':'处理意见:'+ obj.content }, 'keyword2': { 'value': '通知时间:'+str(obj.createdate) }, 'keyword3': { - 'value': '处罚人:'+obj.createuser.name + 'value': '接受处理意见人员:'+obj.createuser.name }, 'remark': { 'value': '请及时查看阅读' @@ -8033,8 +8037,16 @@ def checkprojects(req): uselist.append(item.name) x = a.values('checktask__checktaskname','starttime','zgjg','checktask__tasktype','endtime','jobstate','zguser__username','checktask__checktype__checkcontent','checktask__checkplace','checktask__checktime' ,'checkname__username', 'checkquestion', 'zgtime', 'zguser__username', 'createuser__username', - 'createdate', 'taskstate','content','pmpeople', 'zgyq','zgjg', 'yanshou', 'yanshouren__name')[0] + 'createdate', 'taskstate','zghtp','content','yhtp','pmpeople', 'zgyq','zgjg', 'yanshou', 'yanshouren__name')[0] x['bcfr'] = uselist + if x['yhtp'] != '': + x['yhtp'] = x['yhtp'].split('?') + else: + x['yhtp'] == [] + if x['zghtp'] != '': + x['zghtp'] = x['zghtp'].split('?') + else: + x['zghtp'] == [] return HttpResponse(json.dumps(x, cls=MyEncoder), content_type="application/json") elif a == 'checkdetail': id = req.GET.get('id')