From f87b25db352667a71fef08a439c042ad7d521f55 Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Thu, 5 Dec 2019 08:46:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E6=96=B0=E5=8F=91=E5=B8=83=E8=80=83?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/templates/examtestdetail.html | 34 +- safesite/views.py | 524 +++++++++++-------------- 2 files changed, 268 insertions(+), 290 deletions(-) diff --git a/safesite/templates/examtestdetail.html b/safesite/templates/examtestdetail.html index a9c2a111..18efccb1 100644 --- a/safesite/templates/examtestdetail.html +++ b/safesite/templates/examtestdetail.html @@ -60,16 +60,16 @@ - - - - + {{each cjrydetail}} @@ -95,7 +98,13 @@ {{/if}} - + + + {{if $value.passcode==0&&$value.ison==1&&state==1}} + + {{else}} + + {{/if}} {{/each}}
+ 序号 + 姓名 + 部门 + 状态 @@ -81,6 +81,9 @@ 答题详情 + 重新考试 +
{{$value.score}} {{$value.took}}点击查看点击查看
@@ -187,6 +196,19 @@ } }); } - + function updateIson() { + var examdlid = document.getElementById("examdlid").innerHTML; + $.ajax({ + type: "get", + url: "api/examtestdetail?a=updateison", + contentType: 'application/json; charset=utf-8', + data: { id: ksid, examdlid: examdlid}, + success: function (data) { + + alert(data.message); + + } + }); + } \ No newline at end of file diff --git a/safesite/views.py b/safesite/views.py index 17ef2000..eb5e5e6f 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -126,110 +126,110 @@ def upfile(req): return JsonResponse({"code":1,"filename":file_name,"filepath":filepath}) #html页面 - +@check_login def riskas(req): return render(req,'riskas.html') - +@check_login def reportedit(req): return render(req,'reportedit.html',{'year':req.GET.get('year'),'month':req.GET.get('month'),'part':req.GET.get('part')}) - +@check_login def riskedit(req,id): return render(req,'riskedit.html',{'id':id}) - +@check_login def riskcheck(req):#风险点排查记录 return render(req,'riskactcheck.html') - +@check_login def taskdo(req): return render(req,'taskdo.html') - +@check_login def task(req): return render(req,'task.html') - +@check_login def riskactchose(req): area = 0 if req.GET.get('area',None): area = req.GET.get('area') return render(req,'riskactchose.html',locals()) - +@check_login def riskactedit(req,id): return render(req,'riskactedit.html',{'id':id}) - +@check_login def riskactadd(req): return render(req,'riskactadd.html') - +@check_login def riskadd(req,id): return render(req,'riskadd.html',{'id':id}) - +@check_login def risk(req): return render(req,'risk.html') - +@check_login def inspect(req): return render(req,'inspect.html') - +@check_login def equipment(req): return render(req,'equipment.html') - +@check_login def areaedit(req,id): return render(req,'areaedit.html',{'id':id}) - +@check_login def areaadd(req): return render(req,'areaadd.html') - +@check_login def areadetail(req): id = req.GET.get('id') return render(req,'areadetail.html',{'id':id}) - +@check_login def mapshow(req): return render(req,'mapshow.html') - +@check_login def area(req): return render(req,'area.html') - +@check_login def personaltrain(req): return render(req,'personaltrain.html') - +@check_login def examtest(req): return render(req,'examtest.html') - +@check_login def safecert(req): return render(req,'safecert.html') - +@check_login def safecertadd(req): return render(req,'safecertadd.html') - +@check_login def examtestdetail(req,id): return render(req,'examtestdetail.html',{'id':id}) - +@check_login def examtestadd(req): return render(req,'examtestadd.html') - +@check_login def examtestadd2(req): return render(req,'examtestadd2.html') - +@check_login def questionchoose(req): return render(req,'questionchoose.html') - +@check_login def exampaperedit(req,id): return render(req,'exampaperedit.html',{'id':id}) - +@check_login def exampaperadd(req): return render(req,'exampaperadd.html') - +@check_login def exampaper(req): return render(req,'exampaper.html') - +@check_login def examhistory(req,id): return render(req,'examhistory.html',{'id':id}) - +@check_login def questionadd(req): return render(req,'questionadd.html') - +@check_login def questionadd2(req): return render(req,'questionadd2.html') - +@check_login def questionadd3(req): return render(req,'questionadd3.html') - +@check_login def questionedit(req,id): obj = Question.objects.get(id=id) if obj.type==1: @@ -238,140 +238,140 @@ def questionedit(req,id): return render(req,'questionedit2.html',{'id':id}) elif obj.type==3: return render(req,'questionedit3.html',{'id':id}) - +@check_login def question(req): return render(req,'question.html') - +@check_login def questioncatadd(req): return render(req,'questioncatadd.html') - +@check_login def questioncatedit(req,id): return render(req,'questioncatedit.html',{'id':id}) - +@check_login def operationspjdadd(req): return render(req,'operationspjdadd.html') - +@check_login def fxcsadd(req): return render(req,'fxcsadd.html') - +@check_login def operationadd(req,zyid): return render(req,'operationadd.html',{'zyid':zyid}) - +@check_login def operationdetail(req,zyid): return render(req,'operationdetail.html',{'zyid':zyid}) - +@check_login def operation(req): return render(req,'operation.html') - +@check_login def zuoyepeizhi(req): return render(req,'zuoyepeizhi.html') - +@check_login def notice(req): return render(req,'notice.html') - +@check_login def noticeadd(req): return render(req,'noticeadd.html') - +@check_login def noticedetail(req,id): return render(req,'noticedetail.html',{'id':id}) - +@check_login def noticeedit(req,id): return render(req,'noticeedit.html',{'id':id}) - +@check_login def suggestupdate(req,jyid): return render(req,'suggestupdate.html',{'jyid':jyid}) - +@check_login def suggestdetail(req,jyid): return render(req,'suggestdetail.html',{'jyid':jyid}) - +@check_login def suggestadd(req): return render(req,'suggestadd.html') - +@check_login def suggest(req): return render(req,'suggest.html') - +@check_login def medetail(req): return render(req,'medetail.html') - +@check_login def socerthtml(req): return render(req,'socert.html') - +@check_login def socertadd(req): return render(req,'socertadd.html') - +@check_login def rightshtml(req): groupid = req.GET.get('groupid') return render(req,'rights.html',{'groupid':groupid}) - +@check_login def misshtml(req): return render(req,'miss.html') - +@check_login def missadd(req): return render(req,'missadd.html') - +@check_login def missdetail(req,missid): return render(req,'missdetail.html',{'missid':missid}) - +@check_login def troublehtml(req): return render(req,'trouble.html') - +@check_login def observehtml(req): return render(req,'observe.html') - +@check_login def addobserve(req): return render(req,'addobserve.html') - +@check_login def accesstrouble(req): return render(req,'accesstrouble.html') - +@check_login def addtrouble(req): return render(req,'addtrouble.html') - +@check_login def dichtml(req): return render(req,'dichtml.html') - +@check_login def putreehtml(req): return render(req,'putree.html') - +@check_login def usergroup(req): return render(req,'usergroup.html') - +@check_login def getuserf(req): return render(req,'getuser.html') - +@check_login def getusersf(req): return render(req,'getusers.html') - +@check_login def trainhtml(req): return render(req,'train.html') - +@check_login def abtrain(req): return render(req,'abtrain.html') - +@check_login def drillhtml(req): return render(req,'drill.html') - +@check_login def abdrill(req): return render(req,'abdrill.html') - +@check_login def reporthtml(req): return render(req,'report.html') - +@check_login def troubleashtml(req): return render(req,'troubleashtml.html') - +@check_login def userhtml(req): return render(req,'userhtml.html') - +@check_login def bhrhtml(req): return render(req,'behavior.html') - +@check_login def trainfigure(req): return render(req,'trainfigure.html') - +@check_login def equipmentfigure(req): return render(req,'equipmentfigure.html') - +@check_login def mainhtml(req): #计算一些数据 userid = req.session['userid'] @@ -403,7 +403,6 @@ def login(req): if user.exists(): if check_password(password,user[0].epassword): req.session['userid'] = user[0].userid - req.session.set_expiry(60*40) return redirect('index') else: msg = '密码错误' @@ -579,53 +578,48 @@ def getspr(ubp): def getsprs(userid,ubp): currentpart=ubp - a=getsprs_ubp(userid,currentpart) + a=getsprs_ubp2(userid,currentpart) while a==False: currentpart=currentpart.parentid #已找不到上级部门 if currentpart: - a=getsprs_ubp(userid,currentpart) + a=getsprs_ubp2(userid,currentpart) else: return User.objects.get(ubelongpart=currentpart,issuper=1) return a -def getsprs_ubp(userid,ubp):#主管和被授权人员 +def getsprs_ubp(userid,ubp): a=ubp - # if a.aqy !=',': - # aqystr = a.aqy - # aqylist = aqystr.split(',') - # aqylist = list(map(int, list(filter(None, aqylist)))) - # if userid in aqylist: - # return [userid] - # else: - # if ',' + str(userid) + ',' in a.bmzg: - # return [userid] - # else: - # return aqylist + if a.aqy !=',': + aqystr = a.aqy + aqylist = aqystr.split(',') + aqylist = list(map(int, list(filter(None, aqylist)))) + if userid in aqylist: + return [userid] + else: + if ',' + str(userid) + ',' in a.bmzg: + return [userid] + else: + return aqylist if a.bmzg !=',': zgstr = a.bmzg zglist = zgstr.split(',') zglist = list(map(int, list(filter(None, zglist)))) - bsqstr = a.bsq - bsqlist = list(map(int, list(filter(None, bsqstr.split(','))))) if userid in zglist: return [userid] - elif userid in bsqlist: - zglist.append(userid) - return zglist else: return zglist else: return False -# def getsprs_ubp2(userid,ubp): -# a=ubp -# if a.aqy !=',' or a.bmzg !=',': -# allstr = a.aqy + a.bmzg -# alllist = allstr.split(',') -# alist = list(map(int, list(filter(None, alllist)))) -# return alist -# else: -# return False +def getsprs_ubp2(userid,ubp): + a=ubp + if a.aqy !=',' or a.bmzg !=',': + allstr = a.aqy + a.bmzg + alllist = allstr.split(',') + alist = list(map(int, list(filter(None, alllist)))) + return alist + else: + return False def menutree(req): @@ -1361,7 +1355,7 @@ def getdickey(req): if req.GET.get('dicclass')=='33': for i in a: objs = Operationspjd.objects.filter(zylx=Dickey.objects.get(dickeyid=i['dickeyid']),usecomp=Partment.objects.get(partid=companyid)) - str='作业负责人-作业部门-属地部门' + str='作业负责人-作业部门安全员-属地部门安全员' for x in objs: str = str + '-' + x.jdmc i['splcdetail'] = str @@ -1736,7 +1730,7 @@ def troublehandle(req): a = a.filter(Q(zgbm__in=parts) | Q(fxbm__in=parts,zgbm=None)) total = a.count() startnum,endnum=fenye(req) - obj = a.order_by('-fxsj')[startnum:endnum].values('troubleid','fxr__userid','fxr__name','yhms','yhzt','fxsj','tbsj','yhlb__dickeyname','todouser__name','yhpg__dickeyname','yhnum','yhdj__dickeyname','shresult','zgqx','yhtp','zghtp','todouser__userid') + obj = a.order_by('-xgsj')[startnum:endnum].values('troubleid','fxr__userid','fxr__name','yhms','yhzt','fxsj','tbsj','yhlb__dickeyname','todouser__name','yhpg__dickeyname','yhnum','yhdj__dickeyname','shresult','zgqx','yhtp','zghtp','todouser__userid') return HttpResponse(transjson(total,obj),content_type="application/json") elif a == 'listarea': userid = req.session['userid'] @@ -2587,7 +2581,7 @@ def pxhandle(req): a = a.filter(starttime__lte=jssj) total=a.count() startnum,endnum=fenye(req) - obj=a.order_by('-starttime')[startnum:endnum].values('trainnum','trainid','state','trainplace','starttime','trainname','traintype__dickeyname','teacher','lecturer__name','submituser__name','submituser__userid') + obj=a.order_by('-modifytime')[startnum:endnum].values('trainnum','trainid','state','trainplace','starttime','trainname','traintype__dickeyname','teacher','lecturer__name','submituser__name','submituser__userid') return HttpResponse(transjson(total,obj),content_type="application/json") elif req.GET.get('a')=='detailhtml': trainid = req.GET.get('trainid') @@ -2793,7 +2787,7 @@ def ylhandle(req): a = a.filter(starttime__lte=jssj) total=a.count() startnum,endnum=fenye(req) - obj=a.order_by('-starttime')[startnum:endnum].values('drillnum','drillid','state','drillplace','starttime','drillname','drilltype__dickeyname','chief__name','submituser__name','submituser__userid') + obj=a.order_by('-modifytime')[startnum:endnum].values('drillnum','drillid','state','drillplace','starttime','drillname','drilltype__dickeyname','chief__name','submituser__name','submituser__userid') return HttpResponse(transjson(total,a),content_type="application/json") def gchandle(req): @@ -3201,7 +3195,7 @@ def importusers(req): @apicheck_login def apicompany(req): - if int(req.session.get('userid'))==8: + if int(request.session.get('userid'))==8: a = req.GET.get('a') menurights = '11,1,2,3,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20,21,22,23,24,28,29,32,36,46,47,48,50'#菜单编码 if a=='add': @@ -3907,7 +3901,7 @@ def apisuggest(req): if req.GET.get('jssj'): a = a.filter(submittime__lte=req.GET.get('jssj')) total = a.count() - a = a.order_by('-submittime')[startnum:endnum].values('jyid','jylb__dickeyname','jyr__name','jybm__partname','dqxz','jynr','jynum','jyzt','todouser__userid','todouser__name','jyqy__name','jydd','submittime','accept') + a = a[startnum:endnum].values('jyid','jylb__dickeyname','jyr__name','jybm__partname','dqxz','jynr','jynum','jyzt','todouser__userid','todouser__name','jyqy__name','jydd','submittime','accept') return HttpResponse(transjson(total,a),content_type="application/json") elif a == 'exportexcel': userid = req.session['userid'] @@ -4165,13 +4159,6 @@ def apitool(req): i.epassword = make_password(i.password) i.save() return JsonResponse({"code":1}) - elif a == 'correct_operation': - for i in Operation.objects.all(): - if i.zyzt['zyzt'] == '待关闭' or i.zyzt['zyzt'] == '已关闭': - if 'jdmc' in i.zyzt: - i.zyzt['jdmc'] ='' - i.save() - return JsonResponse({"code":1}) @@ -4365,7 +4352,6 @@ def apinotice(req): def apioperation(req): a = req.GET.get('a') - userid = req.session['userid'] if a == 'add': userid = req.session['userid'] oneuser = User.objects.get(userid=userid) @@ -4389,9 +4375,9 @@ def apioperation(req): obj.zyzt = {'zyzt':'确认中','index':0} obj.save() splc = [] - splc.append({'jdmc':'作业负责人审批','sprs':[userid]}) - splc.append({'jdmc':'作业部门审批','sprs':getsprs(userid,obj.zybm)}) - splc.append({'jdmc':'属地部门审批','sprs':getsprs(userid,obj.sdbm)}) + splc.append({'jdmc':'作业负责人','sprs':[userid]}) + splc.append({'jdmc':'作业部门审批中','sprs':getsprs(userid,obj.zybm)}) + splc.append({'jdmc':'属地部门审批中','sprs':getsprs(userid,obj.sdbm)}) for i in Operationspjd.objects.filter(zylx=obj.zylx,usecomp=Partment.objects.get(partid=getcompany(userid))).order_by('id'): splc.append({'jdmc':i.jdmc,'sprs':i.sprs}) obj.zyzt['splc']=splc @@ -4400,50 +4386,7 @@ def apioperation(req): b=[]#发送通知 for i in data['zyry']: x=User.objects.get(userid=i) - if int(userid)==int(i):#申请人包含作业人直接确认 - m = Operzyry.objects.create(oper=obj,operzyry=x,checked=1) - if Operzyry.objects.filter(oper=obj,checked=0).exists(): - pass - else:#工作人员全部确认 - obj.zyzt['zyzt'] = '审批中' - obj.zyzt['index'] = 0 - index = obj.zyzt['index'] - sprs = [] #初始化审批人列表 - if 'sprs' in obj.zyzt['splc'][index]: - sprs = obj.zyzt['splc'][index]['sprs'] - else: - sprs = [obj.zyzt['splc'][index]['spr']] - jdmc = obj.zyzt['splc'][index]['jdmc'] - obj.zyzt['jdmc'] = jdmc - obj.todousers = sprs - obj.save() - postdict={ - 'touser':'', - 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0', - 'miniprogram':{'appid':'wx5c39b569f01c27db'}, - 'data':{ - 'first':{ - 'value':obj.zylx.dickeyname + '作业审批,审批节点:' + obj.zyzt['jdmc'] - }, - 'keyword1':{ - 'value':obj.zynr - }, - 'keyword2':{ - 'value':obj.kssj - }, - 'keyword3':{ - 'value':obj.zydd - }, - 'remark':{ - 'value':'请您及时完成审批!' - } - } - } - tolist = list(User.objects.filter(userid__in=sprs).values_list('openid',flat=True)) - send_wechatmsgs.delay(postdict,tolist) - return JsonResponse({"code":1}) - else: - m = Operzyry.objects.create(oper=obj,operzyry=x) + m = Operzyry(oper=obj,operzyry=x) m.save() b.append(x.openid) @@ -4516,8 +4459,6 @@ def apioperation(req): zyid=req.GET.get('zyid') a = Operation.objects.filter(zyid=zyid) x = a.values('zyid','zydd','zylx__dickeyname','zynum','zyfzr__name','zynr','zyzt','zyimg','submittime','zybm__partname','sdbm__partname','kssj','jssj','fxcs','zyimg2')[0] - for i in x['zyzt']['splc']: - i['sprs'] = ','.join(list(User.objects.filter(userid__in=i['sprs']).values_list('name',flat=True))) if x['zyimg']!='': x['zyimg'] = x['zyimg'].split('?') else: @@ -4528,10 +4469,8 @@ def apioperation(req): x['zyimg2']=[] x['fxcs'] = list(Fxcs.objects.filter(id__in=x['fxcs'].split('?')).values('id','fxfx','aqcs','cslx')) #确认详情 - qrxqobjs = Operzyry.objects.filter(oper=Operation.objects.get(zyid=zyid)) - qrxq = qrxqobjs.values('operzyry__name','checked') + qrxq = Operzyry.objects.filter(oper=Operation.objects.get(zyid=zyid)).values('operzyry__name','checked') x['qrxq'] = list(qrxq) - x['zyry'] = ','.join(list(qrxqobjs.values_list('operzyry__name',flat=True))) #审批详情 spxq = Operspxq.objects.filter(oper=Operation.objects.get(zyid=zyid)).order_by('submittime').values('jdmc','spbm__partname','spr__name','submittime','checked') x['spxq'] = list(spxq) @@ -4544,32 +4483,30 @@ def apioperation(req): userid = req.session['userid'] data = json.loads(req.body.decode('utf-8')) zyid = data['zyid'] - obj = Operation.objects.get(zyid=zyid) Operzyry.objects.filter(oper__zyid=zyid,operzyry__userid=userid).update(checked=1) if Operzyry.objects.filter(oper__zyid=zyid,checked=0).exists(): pass - else:#工作人员全部确认 + else: + obj = Operation.objects.get(zyid=zyid) nowzt = obj.zyzt obj.zyzt['zyzt'] = '审批中' obj.zyzt['index'] = 0 index = obj.zyzt['index'] - spruser = User.objects.get(userid=userid) - sprs = [] #初始化审批人列表 + obj.zyzt['jdmc'] = obj.zyzt['splc'][index]['jdmc'] if 'sprs' in obj.zyzt['splc'][index]: sprs = obj.zyzt['splc'][index]['sprs'] else: sprs = [obj.zyzt['splc'][index]['spr']] - jdmc = obj.zyzt['splc'][index]['jdmc'] - obj.zyzt['jdmc'] = jdmc obj.todousers = sprs obj.save() - postdict={ + for i in sprs: + postdict={ 'touser':'', - 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0', - 'miniprogram':{'appid':'wx5c39b569f01c27db'}, + 'template_id':User.objects.get(userid=i).openid, + "miniprogram":{"appid":"wx5c39b569f01c27db"}, 'data':{ 'first':{ - 'value':obj.zylx.dickeyname + '作业审批,审批节点:' + obj.zyzt['jdmc'] + 'value':obj.zylx.dickeyname + '作业审批:' }, 'keyword1':{ 'value':obj.zynr @@ -4585,83 +4522,30 @@ def apioperation(req): } } } - tolist = list(User.objects.filter(userid__in=sprs).values_list('openid',flat=True)) - send_wechatmsgs.delay(postdict,tolist) - return JsonResponse({"code":1}) + send_wechatmsg.delay(postdict) + return JsonResponse({"code":1}) elif a == 'spzy': + userid = req.session['userid'] data = json.loads(req.body.decode('utf-8')) zyid = data['zyid'] obj = Operation.objects.get(zyid=zyid) oldtodo = obj.todousers oldjdmc = obj.zyzt['jdmc'] - oldindex = obj.zyzt['index'] nextindex = obj.zyzt['index']+1 spruser = User.objects.get(userid=userid) - if oldindex == 0: - Operspxq.objects.create(oper=obj,jdmc=obj.zyzt['splc'][0]['jdmc'],spr=spruser,checked=1,spbm=spruser.ubelongpart) - spr1 = data['spr1'] if 'spr1' in data else None - spr2 = data['spr2'] if 'spr2' in data else None - if spr1: - obj.zyzt['splc'][1]['sprs'] = [spr1] #作业部门审批人 - if spr2: - obj.zyzt['splc'][2]['sprs'] = [spr2] #属地部门审批人 - while nextindex