From 3e7002c37f961446a43d1c5f2dc1baeaf1e42fa9 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 18 Sep 2019 21:22:49 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E6=B3=95=E5=BE=8B=E6=B3=95=E8=A7=84?= =?UTF-8?q?=E3=80=81=E9=9B=86=E5=9B=A2=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/daoru.py | 9 +++++++++ safesite/templates/areaedit.html | 2 ++ 2 files changed, 11 insertions(+) diff --git a/safesite/daoru.py b/safesite/daoru.py index a6f9cb2b..47291199 100644 --- a/safesite/daoru.py +++ b/safesite/daoru.py @@ -44,6 +44,15 @@ def makeqr4(data): img.save(filepath) return filepath +def makeqr_area(data): + upload_folder = 'media/qr_area' + if not os.path.exists(upload_folder): + os.mkdir(upload_folder) + img = qrcode.make(data=data) + filepath = os.path.join(upload_folder, data.split('=')[1]+'.png').replace('\\','/') + img.save(filepath) + return filepath + def drequipments(companyid,path): wb = load_workbook(path) sheet = wb.worksheets[0] diff --git a/safesite/templates/areaedit.html b/safesite/templates/areaedit.html index 5e98a58a..a855f6a9 100644 --- a/safesite/templates/areaedit.html +++ b/safesite/templates/areaedit.html @@ -16,6 +16,8 @@ +
区域二维码
+ diff --git a/safesite/templates/mgtindex.html b/safesite/templates/mgtindex.html new file mode 100644 index 00000000..09e87bae --- /dev/null +++ b/safesite/templates/mgtindex.html @@ -0,0 +1,78 @@ + +
+
+ 新增 + 删除 + + + +
+ +
+
+ \ No newline at end of file diff --git a/safesite/urls.py b/safesite/urls.py index 8d3309ca..d57b2a1c 100644 --- a/safesite/urls.py +++ b/safesite/urls.py @@ -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')), ] From 08e42ae7adc62b1ba17e031443592ec5358d22eb Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Tue, 8 Oct 2019 09:53:16 +0800 Subject: [PATCH 11/17] sc --- safesite/templates/mgtadd.html | 52 ++++++++++++++++------------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/safesite/templates/mgtadd.html b/safesite/templates/mgtadd.html index aa038f57..6424b9b4 100644 --- a/safesite/templates/mgtadd.html +++ b/safesite/templates/mgtadd.html @@ -128,7 +128,7 @@ 选择文件 - +

@@ -215,37 +215,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 = "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 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 = "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数据 - } + //上传进度实现方法,上传过程中会频繁调用该方法 function progressFunction(evt) { From 21be18b1a461627091c5bf6ab7499e8001aa35fe Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 8 Oct 2019 21:29:55 +0800 Subject: [PATCH 12/17] zuoye --- .../migrations/0273_auto_20191008_1604.py | 29 +++ safesite/models.py | 6 +- safesite/templates/operationspjdadd.html | 8 +- safesite/templates/suggest.html | 2 +- safesite/templates/zuoyepeizhi.html | 2 +- safesite/views.py | 168 +++++++++++------- 6 files changed, 145 insertions(+), 70 deletions(-) create mode 100644 safesite/migrations/0273_auto_20191008_1604.py diff --git a/safesite/migrations/0273_auto_20191008_1604.py b/safesite/migrations/0273_auto_20191008_1604.py new file mode 100644 index 00000000..459197f0 --- /dev/null +++ b/safesite/migrations/0273_auto_20191008_1604.py @@ -0,0 +1,29 @@ +# Generated by Django 2.1.5 on 2019-10-08 16:04 + +import django.contrib.postgres.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0272_auto_20190925_1657'), + ] + + operations = [ + # migrations.AddField( + # model_name='area', + # name='qrcode', + # field=models.CharField(blank=True, max_length=200, null=True), + # ), + migrations.AddField( + model_name='operation', + name='todousers', + field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, null=True, size=None), + ), + migrations.AddField( + model_name='operationspjd', + name='sprs', + field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, null=True, size=None), + ), + ] diff --git a/safesite/models.py b/safesite/models.py index 524f261f..29504ac0 100644 --- a/safesite/models.py +++ b/safesite/models.py @@ -1,7 +1,7 @@ from django.db import models import uuid import django.utils.timezone as timezone -from django.contrib.postgres.fields import JSONField +from django.contrib.postgres.fields import JSONField,ArrayField import jwt import datetime # Create your models here. @@ -466,6 +466,7 @@ class Operation(models.Model):#作业表 zyzt = JSONField() fxcs = models.CharField(max_length=200) todouser = models.ForeignKey(User,related_name='zyclr',on_delete=models.CASCADE,null=True,blank=True) + todousers = ArrayField(models.IntegerField(), blank=True,null=True) usecomp = models.ForeignKey(Partment,on_delete=models.CASCADE,null=True,blank=True,default=1) class Fxcs(models.Model):#作业分析措施 @@ -508,12 +509,13 @@ class Operzyry(models.Model):#作业确认人 modifytime = models.DateTimeField(auto_now = True) submittime = models.DateTimeField(default = timezone.now) -class Operationspjd(models.Model):#作业审批节点 +class Operationspjd(models.Model):#作业审批节点配置 id = models.AutoField(primary_key=True) zylx = models.ForeignKey(Dickey, on_delete=models.CASCADE,null=True,blank=True) jdmc = models.CharField(max_length=100) spbm = models.ForeignKey(Partment,related_name='spbm',on_delete=models.CASCADE,null=True,blank=True)#审批部门 spr = models.ForeignKey(User,related_name='spr',on_delete=models.CASCADE,null=True,blank=True)#审批部门 + sprs = ArrayField(models.IntegerField(), blank=True,null=True) submittime = models.DateTimeField(u'创建时间',default = timezone.now) modifytime = models.DateTimeField(auto_now = True) usecomp = models.ForeignKey(Partment,on_delete=models.CASCADE,null=True,blank=True) diff --git a/safesite/templates/operationspjdadd.html b/safesite/templates/operationspjdadd.html index fde8ca25..d7f20fd9 100644 --- a/safesite/templates/operationspjdadd.html +++ b/safesite/templates/operationspjdadd.html @@ -13,7 +13,7 @@ required=true />
-
@@ -22,9 +22,13 @@ + + + + + +
+
+
+ +
+
+ +
+ + + + + diff --git a/safesite/templates/examtestdetail.html b/safesite/templates/examtestdetail.html index 0766def4..a9c2a111 100644 --- a/safesite/templates/examtestdetail.html +++ b/safesite/templates/examtestdetail.html @@ -60,16 +60,16 @@ - + - + + {{each cjrydetail}} @@ -92,6 +95,7 @@ {{/if}} + {{/each}}
- 序号 - + 序号 + 姓名 - 部门 - + 部门 + 状态 @@ -78,6 +78,9 @@ 用时 + 答题详情 +
{{$value.score}} {{$value.took}}点击查看
@@ -183,4 +187,6 @@ } }); } + + \ No newline at end of file diff --git a/safesite/templates/lawsadd.html b/safesite/templates/lawsadd.html index 1aea27d9..3e0e8e5c 100644 --- a/safesite/templates/lawsadd.html +++ b/safesite/templates/lawsadd.html @@ -249,7 +249,7 @@ }; var imagSize = document.getElementById("file").files[0].size; if (imagSize > 1024 * 1024 * 10) { - alert("文件大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M,超出了上传大小," + "请选择3M以内的文件!"); + alert("文件大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M,超出了上传大小," + "请选择10M以内的文件!"); return false; } var url = "rlt/api/upload"; // 接收上传文件的后台地址 diff --git a/safesite/urls.py b/safesite/urls.py index d57b2a1c..cb895384 100644 --- a/safesite/urls.py +++ b/safesite/urls.py @@ -148,7 +148,7 @@ urlpatterns = [ #path('api/riskactcheck',views.apiriskactcheck), path('api/riskcheck2',views.apiriskcheck2), path('api/report',views.apireport), - + path('html/examhistory//',views.examhistory), #path('api/rights/group/',views.rightsgroup), diff --git a/safesite/views.py b/safesite/views.py index fd426a0a..037a0ee5 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -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): @@ -4756,7 +4758,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): From af81fbf1d015e2f25210514eb7cf3b5dc621c904 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 10 Oct 2019 16:02:06 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=AE=A1=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/safesite/mystatic/js/conversion.js | 1 + safesite/static/safesite/mystatic/js/util.js | 18 ++++-- safesite/templates/accesstrouble.html | 11 +++- safesite/templates/addtrouble.html | 8 +-- safesite/templates/main.html | 11 +++- safesite/templates/questionadd3.html | 4 ++ safesite/templates/questionedit.html | 1 + safesite/templates/questionedit2.html | 1 + safesite/templates/questionedit3.html | 5 ++ safesite/views.py | 60 +++++++++++++++---- 10 files changed, 96 insertions(+), 24 deletions(-) create mode 100644 safesite/static/safesite/mystatic/js/conversion.js diff --git a/safesite/static/safesite/mystatic/js/conversion.js b/safesite/static/safesite/mystatic/js/conversion.js new file mode 100644 index 00000000..1d598b03 --- /dev/null +++ b/safesite/static/safesite/mystatic/js/conversion.js @@ -0,0 +1 @@ +"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):window.imageConversion=t()}(function(){var t={};function e(t){return["image/png","image/jpeg","image/gif"].some(function(e){return e===t})}return t.urltoImage=function(t){return new Promise(function(e,a){var n=new Image;n.onload=function(){return e(n)},n.onerror=function(){return a(new Error("urltoImage(): Image failed to load, please check the image URL"))},n.src=t})},t.urltoBlob=function(t){return fetch(t).then(function(t){return t.blob()})},t.imagetoCanvas=async function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=document.createElement("canvas"),n=a.getContext("2d"),i=void 0,r=void 0;for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(e[o]=Number(e[o]));if(e.scale){var c=e.scale>0&&e.scale<10?e.scale:1;r=t.width*c,i=t.height*c}else r=e.width||e.height*t.width/t.height||t.width,i=e.height||e.width*t.height/t.width||t.height;switch([5,6,7,8].some(function(t){return t===e.orientation})?(a.height=r,a.width=i):(a.height=i,a.width=r),e.orientation){case 3:n.rotate(180*Math.PI/180),n.drawImage(t,-a.width,-a.height,a.width,a.height);break;case 6:n.rotate(90*Math.PI/180),n.drawImage(t,0,-a.width,a.height,a.width);break;case 8:n.rotate(270*Math.PI/180),n.drawImage(t,-a.height,0,a.height,a.width);break;case 2:n.translate(a.width,0),n.scale(-1,1),n.drawImage(t,0,0,a.width,a.height);break;case 4:n.translate(a.width,0),n.scale(-1,1),n.rotate(180*Math.PI/180),n.drawImage(t,-a.width,-a.height,a.width,a.height);break;case 5:n.translate(a.width,0),n.scale(-1,1),n.rotate(90*Math.PI/180),n.drawImage(t,0,-a.width,a.height,a.width);break;case 7:n.translate(a.width,0),n.scale(-1,1),n.rotate(270*Math.PI/180),n.drawImage(t,-a.height,0,a.height,a.width);break;default:n.drawImage(t,0,0,a.width,a.height)}return a},t.canvastoFile=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image/jpeg";return new Promise(function(n){return t.toBlob(function(t){return n(t)},a,e)})},t.canvastoDataURL=async function(t,a,n){return e(n)||(n="image/jpeg"),t.toDataURL(n,a)},t.filetoDataURL=function(t){return new Promise(function(e){var a=new FileReader;a.onloadend=function(t){return e(t.target.result)},a.readAsDataURL(t)})},t.dataURLtoImage=function(t){return new Promise(function(e,a){var n=new Image;n.onload=function(){return e(n)},n.onerror=function(){return a(new Error("dataURLtoImage(): dataURL is illegal"))},n.src=t})},t.dataURLtoFile=async function(t,a){for(var n=t.split(","),i=n[0].match(/:(.*?);/)[1],r=atob(n[1]),o=r.length,c=new Uint8Array(o);o--;)c[o]=r.charCodeAt(o);return e(a)&&(i=a),new Blob([c],{type:i})},t.downloadFile=function(t,e){var a=document.createElement("a");a.href=window.URL.createObjectURL(t),a.download=e||Date.now().toString(36),document.body.appendChild(a);var n=document.createEvent("MouseEvents");n.initEvent("click",!1,!1),a.dispatchEvent(n),document.body.removeChild(a)},t.compress=async function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(a instanceof Blob))throw new Error("compress(): First arg must be a Blob object or a File object.");if("object"!==(void 0===n?"undefined":_typeof(n))&&(n=Object.assign({quality:n})),n.quality=Number(n.quality),Number.isNaN(n.quality))return a;var i=await t.filetoDataURL(a),r=i.split(",")[0].match(/:(.*?);/)[1],o="image/jpeg";e(n.type)&&(o=n.type,r=n.type);var c=await t.dataURLtoImage(i),u=await t.imagetoCanvas(c,Object.assign({},n)),s=await t.canvastoDataURL(u,n.quality,o);return await t.dataURLtoFile(s,r)},t.compressAccurately=async function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(a instanceof Blob))throw new Error("compressAccurately(): First arg must be a Blob object or a File object.");if("object"!==(void 0===n?"undefined":_typeof(n))&&(n=Object.assign({size:n})),n.size=Number(n.size),Number.isNaN(n.size))return a;if(1024*n.size>a.size)return a;n.accuracy=Number(n.accuracy),(!n.accuracy||n.accuracy<.8||n.accuracy>.99)&&(n.accuracy=.95);var i=n.size*(2-n.accuracy)*1024,r=1024*n.size,o=n.size*n.accuracy*1024,c=await t.filetoDataURL(a),u=c.split(",")[0].match(/:(.*?);/)[1],s="image/jpeg";e(n.type)&&(s=n.type,u=n.type);for(var h=await t.dataURLtoImage(c),d=await t.imagetoCanvas(h,Object.assign({},n)),l=.5,f=void 0,g=[null,null],m=1;m<=7;m++){var w=.75*(f=await t.canvastoDataURL(d,l,s)).length;if(7===m){(iw)&&(f=[f].concat(g).filter(function(t){return t}).sort(function(t,e){return Math.abs(.75*t.length-r)-Math.abs(.75*e.length-r)})[0]);break}if(iw))break;g[0]=f,l+=.5**(m+1)}}var y=await t.dataURLtoFile(f,u);return y.size>a.size?a:y},t}); \ No newline at end of file diff --git a/safesite/static/safesite/mystatic/js/util.js b/safesite/static/safesite/mystatic/js/util.js index 35f76255..982a2f67 100644 --- a/safesite/static/safesite/mystatic/js/util.js +++ b/safesite/static/safesite/mystatic/js/util.js @@ -32,6 +32,17 @@ function canvasDataURL(path, obj, callback) { scale = w / h; w = obj.width || w; h = obj.height || (w / scale); + if(w <= h ){ + if(w>640){ + w = 640 + h = w/scale + } + }else{ + if(h>640){ + h=640 + w = h*scale + } + } var quality = 0.7; // 默认图片质量为0.7 //生成canvas var canvas = document.createElement('canvas'); @@ -45,9 +56,9 @@ function canvasDataURL(path, obj, callback) { canvas.setAttributeNode(anh); ctx.drawImage(that, 0, 0, w, h); // 图像质量 - if (obj.quality && obj.quality <= 1 && obj.quality > 0) { - quality = obj.quality; - } + // if (obj.quality && obj.quality <= 1 && obj.quality > 0) { + // quality = obj.quality; + // } // quality值越小,所绘制出的图像越模糊 var base64 = canvas.toDataURL('image/jpeg', quality); // 回调函数返回base64的值 @@ -62,7 +73,6 @@ function convertBase64UrlToBlob(urlData) { } return new Blob([u8arr], { type: mime }); } - //取消上传 function cancleUploadFile() { diff --git a/safesite/templates/accesstrouble.html b/safesite/templates/accesstrouble.html index 317c97f1..90c14740 100644 --- a/safesite/templates/accesstrouble.html +++ b/safesite/templates/accesstrouble.html @@ -301,7 +301,16 @@ $("#yhms").textbox('disable'); $('#fcyjdiv,#file2,#zgxq,#shyjdiv,#csyj,#reject').hide(); $('#jxpg').show(); $("#yhpg").combobox({ url: 'getdickey?dicclass=19&a=combobox', }); - $("#zgbm").combotree({ url: 'parthandle?a=tree3', onSelect: function (node) { $('#zgr').combobox({ url: 'getuser?partid=' + node.id + '&a=combobox', }); } }); + $("#zgbm").combotree({ url: 'parthandle?a=tree3', onSelect: function (node) { + $('#zgr').combobox({ + url: 'getuser?partid=' + node.id + '&a=combobox', + editable: false, + filter: function (q, row) { + var opts = $(this).combobox('options'); + return row[opts.textField].indexOf(q) >= 0;//这里改成>=即可在任意地方匹配 + }, + }); + } }); // if (data.yhpg__dickeyname != '' & data.yhpg__dickeyname != null) { // $("#yhpg").combobox('setValue', data.yhpg__dickeyid).combobox('readonly'); // $("#yhlx").combobox({ url: 'getdicclass?dicid=15' }).combobox('setValue', data.yhlx__dicid).combobox('readonly'); diff --git a/safesite/templates/addtrouble.html b/safesite/templates/addtrouble.html index 7e02d19d..0f3b607c 100644 --- a/safesite/templates/addtrouble.html +++ b/safesite/templates/addtrouble.html @@ -219,9 +219,7 @@ var form = new FormData(); if (fileObj.size / 1024 > 500) { //大于500k,进行压缩上传 $("#file").after('图片大于500k,正在压缩...'); - photoCompress(fileObj, { - quality: 0.2 - }, function (base64Codes) { + photoCompress(fileObj, {}, function (base64Codes) { //console.log("压缩后:" + base.length / 1024 + " " + base); var bl = convertBase64UrlToBlob(base64Codes); form.append("upfile", bl, fileObj.name); // 文件对象 @@ -310,9 +308,7 @@ var form = new FormData(); if (fileObj.size / 1024 > 500) { //大于500k,进行压缩上传 $("#file2").after('图片大于500k,正在压缩...'); - photoCompress(fileObj, { - quality: 0.2 - }, function (base64Codes) { + photoCompress(fileObj, {}, function (base64Codes) {//quality: 0.2 //console.log("压缩后:" + base.length / 1024 + " " + base); var bl = convertBase64UrlToBlob(base64Codes); form.append("upfile", bl, fileObj.name); // 文件对象 diff --git a/safesite/templates/main.html b/safesite/templates/main.html index 784daf6a..680a4ab7 100644 --- a/safesite/templates/main.html +++ b/safesite/templates/main.html @@ -263,7 +263,7 @@ float: left;">
-
@@ -326,6 +326,12 @@ float: left;">
+
+
+ +
+
+