From f354fcf4f850173648a420245d81dfc7895470db Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 9 Nov 2020 17:34:23 +0800 Subject: [PATCH] =?UTF-8?q?ajax=E5=85=A8=E5=B1=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/static/safesite/mystatic/js/util.js | 17 +++++- safesite/templates/trouble.html | 2 +- safesite/views.py | 49 +++++++++++++++++- ...管理系统二次开发需求分析.docx | Bin 0 -> 162 bytes 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 需求/~$嘉华安全生产管理系统二次开发需求分析.docx diff --git a/safesite/static/safesite/mystatic/js/util.js b/safesite/static/safesite/mystatic/js/util.js index f415e7f0..dd64b09f 100644 --- a/safesite/static/safesite/mystatic/js/util.js +++ b/safesite/static/safesite/mystatic/js/util.js @@ -9,6 +9,21 @@ $.ajaxSetup({ top.location = "http://" + window.location.host; }); } + try{ + var jsonData = JSON.parse(xhr.responseText); + if(jsonData.code == -1){ + //如果超时就处理 ,指定要跳转的页面(比如登陆页) + $.messager.alert('错误','请重新登陆!','error',function(){ + location.reload() + }); + }else if(jsonData.code == 0){ + //其他的异常情况,给个提示。 + $.messager.alert('错误','操作失败!','error'); + }else{ + //正常情况就不统一处理了 + } + }catch(e){ + } } }); @@ -605,7 +620,7 @@ $.get('api/check_session',function(res){ if(res.code==1){ }else{ $.messager.alert('','长时间未操作,请重新登陆!','warning',function(){ - window.location.reload(true) + location.reload() }); } }) diff --git a/safesite/templates/trouble.html b/safesite/templates/trouble.html index 3f244f42..a93cdb9e 100644 --- a/safesite/templates/trouble.html +++ b/safesite/templates/trouble.html @@ -303,7 +303,7 @@ } function yhsearch() { var querydata = $('#searchyhff').serializeJSON(); - querydata['a'] = 'listsearch' + querydata.a = 'listall' $('#sdg_yh').dialog('close') $('#yhtable').datagrid('load', querydata); diff --git a/safesite/views.py b/safesite/views.py index e30091c1..653cab96 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -126,7 +126,7 @@ def apicheck_login(func): if is_login: return func(request, *args, **kwargs) else: - return JsonResponse({'code': 0, 'msg': 'login required'}) + return JsonResponse({'code': -1, 'msg': '请登陆'}) return warpper @@ -136,6 +136,9 @@ def check_session(req): else: return JsonResponse({"code": 0}) + + + # 存储文件 @@ -1992,6 +1995,47 @@ def troublehandle(req): companyid = getcompany(userid) a = Trouble.objects.filter(usecomp=Partment.objects.get( partid=companyid)).exclude(deletemark=0) + yhzt = req.GET.get('yhzt') + yhlx = req.GET.get('yhlx') + yhlb = req.GET.get('yhlb') + jclx = req.GET.get('jclx') + yhpg = req.GET.get('yhpg') + fxbm = req.GET.get('fxbm') + fxr = req.GET.get('fxr') + qssj = req.GET.get('qssj') + jssj = req.GET.get('jssj') + yhqy = req.GET.get('yhqy') + zgbm = req.GET.get('zgbm') + fxrname = req.GET.get('fxrname',None) + if yhzt != '' and yhzt != None: + a = a.filter(yhzt=yhzt) + if yhlx: + a = a.filter(yhlx__dicid=yhlx) + if yhlb: + a = a.filter(yhlb__dickeyid=yhlb) + if jclx: + a = a.filter(jclx__dickeyid=jclx) + if yhpg: + a = a.filter(yhpg__dickeyid=yhpg) + if fxbm or fxr: + if fxr: + a = a.filter(fxr__userid=fxr) + elif fxbm: + parts = Partment.objects.filter( + partlink__contains=','+str(fxbm)+',') | Partment.objects.filter(partid=fxbm) + a = a.filter(fxbm__in=parts) + if qssj: + a = a.filter(fxsj__gte=qssj) + if jssj: + a = a.filter(fxsj__lte=jssj) + if yhqy: + a = a.filter(yhqy__id=yhqy) + if zgbm: + parts = Partment.objects.filter( + partlink__contains=','+str(zgbm)+',') | Partment.objects.filter(partid=zgbm) + a = a.filter(Q(zgbm__in=parts) | Q(fxbm__in=parts, zgbm=None)) + if fxrname: + a = a.filter(fxr__name__contains=fxrname) total = a.count() startnum, endnum = fenye(req) obj = a.order_by('-fxsj')[startnum:endnum].values('troubleid', 'fxr__userid', 'fxr__name', 'yhms', 'yhzt', 'fxsj', 'tbsj', @@ -2042,7 +2086,7 @@ def troublehandle(req): partlink__contains=','+str(zgbm)+',') | Partment.objects.filter(partid=zgbm) a = a.filter(Q(zgbm__in=parts) | Q(fxbm__in=parts, zgbm=None)) if fxrname: - a = a.filter(fxr__name=fxrname) + a = a.filter(fxr__name__contains=fxrname) 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', @@ -3865,6 +3909,7 @@ def drapi(req): else: return JsonResponse({"code": 1}) +@apicheck_login def apimiss(req): a = req.GET.get('a') userid = req.session['userid'] diff --git a/需求/~$嘉华安全生产管理系统二次开发需求分析.docx b/需求/~$嘉华安全生产管理系统二次开发需求分析.docx new file mode 100644 index 0000000000000000000000000000000000000000..6e82e3ef994be186dfd094564d70397e3fe1482a GIT binary patch literal 162 acmZQhF3e>h889;>GZZqAp^;>p7#ILf#R7={ literal 0 HcmV?d00001