From 8e4d807398eb86462e9e56f9490722f2972ed862 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 16 Nov 2020 17:40:35 +0800 Subject: [PATCH 1/8] socert up --- safesite/models.py | 4 +- safesite/safespider.py | 9 +- .../static/safesite/easyui/themes/icon.css | 4 +- .../easyui/themes/icons/scheduleset.png | Bin 0 -> 535 bytes safesite/templates/socert.html | 33 ++--- safesite/templates/socertadd.html | 11 +- safesite/templates/socertedit.html | 125 ++++++++++++++++++ safesite/views.py | 16 +++ 8 files changed, 172 insertions(+), 30 deletions(-) create mode 100644 safesite/static/safesite/easyui/themes/icons/scheduleset.png create mode 100644 safesite/templates/socertedit.html diff --git a/safesite/models.py b/safesite/models.py index fa26ed4a..1525cf8c 100644 --- a/safesite/models.py +++ b/safesite/models.py @@ -1291,13 +1291,13 @@ class Checktask(models.Model): checktype=models.ForeignKey(Checktable,on_delete=models.CASCADE)#关联检查表 checkname=models.ManyToManyField(User,related_name='jiancha')#检查人员 checktime= models.DateTimeField(null=True, blank=True)#任务首次执行时间 - checkplace=models.CharField(max_length=200)#检查地点 + checkplace=models.TextField(default='')#检查地点 createuser = models.ForeignKey(User,related_name='chuangjians',on_delete=models.CASCADE)#创建人 createdate = models.DateTimeField(default = timezone.now)#创建时间 usecomp = models.ForeignKey(Partment,related_name='taskscomp',on_delete=models.CASCADE,null=True,blank=True)#创建公司 deletemark = models.IntegerField(default=1)#是否删除 tasktype = models.IntegerField(default=0)#任务执行频率(1每天,2每周,3每月,4每季度,5每半年,6每年) - userlist = models.CharField(max_length=200,null=True,)#检查人列表 + userlist = models.TextField(default='')#检查人列表 zxstate = models.IntegerField(default=1)#1同时执行,2一个执行就执行 taskstate = models.IntegerField(default=1)#是否暂停,1运行,2暂停 diff --git a/safesite/safespider.py b/safesite/safespider.py index e9f58e90..0c697b9d 100644 --- a/safesite/safespider.py +++ b/safesite/safespider.py @@ -15,16 +15,11 @@ headers = { def getTzzs(certnum,stu_name):#特种证书(身份证号,姓名,均是字符) certtype_code='720' - proxies = { - "http": "http://112.91.78.240:5412" -} stu_name=parse.quote(parse.quote(stu_name)) - text1 = requests.post('http://cx.mem.gov.cn//cms/html/certQuery/certQuery.do?method=getServerTime',headers=headers, proxies=proxies).text - print(text1) + text1 = requests.post('http://cx.mem.gov.cn//cms/html/certQuery/certQuery.do?method=getServerTime',headers=headers).text sessionId = eval(text1)['time'] - url = "http://cx.mem.gov.cn/cms/html/certQuery/certQuery.do?method=getCertQueryResult&ref=ch&certtype_code="+certtype_code+"&certnum="+certnum+"&stu_name="+stu_name+'&passcode=1234'+'&sessionId='+sessionId - data = requests.get(url,headers=headers, proxies=proxies).text + data = requests.get(url,headers=headers).text tree = etree.HTML(data) e1 = tree.xpath("//th[text()='姓名']/following-sibling::td[1]/text()") e2 = tree.xpath("//th[text()='性别']/following-sibling::td[1]/text()") diff --git a/safesite/static/safesite/easyui/themes/icon.css b/safesite/static/safesite/easyui/themes/icon.css index 82778c70..5441ca86 100644 --- a/safesite/static/safesite/easyui/themes/icon.css +++ b/safesite/static/safesite/easyui/themes/icon.css @@ -178,7 +178,9 @@ .icon-inspectitem { background: url('icons/inspectitem.png') no-repeat center center; } - +.icon-scheduleset { + background: url('icons/scheduleset.png') no-repeat center center; +} .icon-mini-add{ diff --git a/safesite/static/safesite/easyui/themes/icons/scheduleset.png b/safesite/static/safesite/easyui/themes/icons/scheduleset.png new file mode 100644 index 0000000000000000000000000000000000000000..df1f8107882d6f0ac1748b01fc4ac86db33cc760 GIT binary patch literal 535 zcmV+y0_gpTP)vPKXKu@l5bL>onof~L|&w6NG+MMy}cL~jpK!Lt!|W)1}51Z{RsMJx;v zH14e+irARO50F#QMiB)oTMH4?+j%kvckEtrX)-Xy`go(6amhTRJI+&&%yaIqmDjv zzP^H}-Z~HFEk=eXdh|g+7oyW!Ao^tD;K~3X%b59YQwDQI05R_?)NC4$YapTt6Z?J% zP_1WIneo#|Ul*J7<;|WxVAJl`^O4RZ5!NKJf36JB=@cL)6X_pZYPhO8dkWauM20gZ zfa~%I{re!mwM2&5Vvwp%eG6*jykeVsr4qmyr|J)O2o`S{+-%A)DncqcH3X_yvOBNG zN8Sw`q_daOb$>hJ2EbcEG~Z3^Hj+M$diLbCi{X! -
-
- {% load myfilter %} - {% if request|has_permission:'b_socert_add' %} - - {% endif %} - {% if request|has_permission:'b_socert_del' %} - 删除 - {% endif %} - {% if request|has_permission:'b_socert_exportexl' %} - 导出Excel - {% endif %} -
-
+
+ +
@@ -23,6 +12,21 @@
+
+ {% load myfilter %} + {% if request|has_permission:'b_socert_add' %} + 新增 + {% endif %} + {% if request|has_permission:'b_socert_add' %} + 编辑 + {% endif %} + {% if request|has_permission:'b_socert_del' %} + 删除 + {% endif %} + {% if request|has_permission:'b_socert_exportexl' %} + 导出Excel + {% endif %} +
+
+ + + 选择 +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+
+ \ No newline at end of file diff --git a/safesite/views.py b/safesite/views.py index 025531d1..c232b629 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -4060,6 +4060,22 @@ def apisocert(req): a = a.values('id', 'realname', 'gender', 'zylb', 'czxm', 'fzjg', 'ccfzrq', 'yfsrq', 'yxqkssj', 'yxqjssj', 'sjfssj', 'zszt', 'url', 'cardnum') return HttpResponse(transjson(total, a), content_type="application/json") + elif a == 'add': + postdata = json.loads(req.body.decode('utf-8')) + obj = Socertificate() + user = User.objects.get(userid = postdata['userid']) + obj.user = User.objects.get(userid = postdata['userid']) + obj.zylb = postdata['zylb'] + obj.fzjg = postdata['fzjg'] + obj.czxm = postdata['czxm'] + obj.ccfzrq = postdata['ccfzrq'] + obj.yfsrq = postdata['yfsrq'] + obj.yxqkssj = postdata['yxqkssj'] + obj.yxqjssj = postdata['yxqjssj'] + obj.zszt = guoqi(postdata['yfsrq']) + obj.usecomp = user.usecomp + obj.save() + return JsonResponse({'code':1}) # elif a == 'addspider': # postdata = json.loads(req.body.decode('utf-8')) # userid = postdata['userid'] From 24bc4dfc6b080c2d586fd399639bf0f5d12751d1 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 17 Nov 2020 11:13:55 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=AF=95=E9=A2=98=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=97=B6=E5=88=86=E7=B1=BB=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/daoru.py | 6 +++--- safesite/views.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/safesite/daoru.py b/safesite/daoru.py index 8c88145c..7d6822ec 100644 --- a/safesite/daoru.py +++ b/safesite/daoru.py @@ -95,7 +95,7 @@ def drquestions(companyid,path,userid): cateobj = Questioncat.objects.create(usecomp=Partment.objects.get(partid=companyid),name=cate) if type == '单选': if Question.objects.filter(type=1,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').exists(): - Question.objects.filter(type=1,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='') + Question.objects.filter(type=1,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='', questioncat=cateobj) else: if right in ['A','B','C','D','E','F']: obj = Question() @@ -115,7 +115,7 @@ def drquestions(companyid,path,userid): elif type == '多选': right = list(right) if Question.objects.filter(type=2,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').exists(): - Question.objects.filter(type=2,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='') + Question.objects.filter(type=2,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='', questioncat=cateobj) else: if [False for c in right if c not in qlist]: pass @@ -140,7 +140,7 @@ def drquestions(companyid,path,userid): else: right = 'B' if Question.objects.filter(type=3,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').exists(): - Question.objects.filter(type=3,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='') + Question.objects.filter(type=3,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='', questioncat=cateobj) else: obj = Question() obj.type = 3 diff --git a/safesite/views.py b/safesite/views.py index c232b629..5b49acf5 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -5038,6 +5038,12 @@ def apitool(req): # Userprofile.objects.filter(realname='null').update(realname='') # Userprofile.objects.filter(cardnum='null').update(cardnum='') return JsonResponse({"code":1}) + elif a == 'correct_questioncat': + # print(Questioncat.objects.filter(usecomp__partid=2184).delete()) + print(Question.objects.filter(questioncat__name='冬季四防安全生产知识').count()) + # Questioncat.objects.filter(usecomp__partname='广安厂').update(parent=None, link=',', deletemark=1) + # print(Questioncat.objects.filter(name='冬季四防安全生产知识').values('usecomp__partname')) + return JsonResponse({"code":1}) From 7c8a03c5a9033d7423935d1d2ed648721c173688 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 17 Nov 2020 13:13:17 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/templates/safecert.html | 35 +++++--- safesite/templates/safecertadd.html | 30 +++++-- safesite/templates/safecertadd_.html | 96 ++++++++++++++++++++++ safesite/templates/safecertedit.html | 117 +++++++++++++++++++++++++++ safesite/templates/socert.html | 15 ++-- safesite/templates/socertadd.html | 6 +- safesite/templates/socertedit.html | 15 ++-- safesite/urls.py | 2 + safesite/views.py | 54 +++++++++++-- 9 files changed, 330 insertions(+), 40 deletions(-) create mode 100644 safesite/templates/safecertadd_.html create mode 100644 safesite/templates/safecertedit.html diff --git a/safesite/templates/safecert.html b/safesite/templates/safecert.html index 1ce72e39..ef9de712 100644 --- a/safesite/templates/safecert.html +++ b/safesite/templates/safecert.html @@ -1,10 +1,21 @@
-
-
+
+
+ + +
+
{% load myfilter %} {% if request|has_permission:'b_safecert_add' %} - + 新增 + {% endif %} + {% if request|has_permission:'b_safecert_add' %} + 编辑 {% endif %} {% if request|has_permission:'b_safecert_del' %} 删除 @@ -13,14 +24,7 @@ 导出Excel {% endif %}
-
- - -
+
\ No newline at end of file diff --git a/safesite/templates/safecertadd.html b/safesite/templates/safecertadd.html index 0be5e79f..abbe2cbf 100644 --- a/safesite/templates/safecertadd.html +++ b/safesite/templates/safecertadd.html @@ -1,12 +1,11 @@
提交查询 + id="submitb">提交 取消
-

请输入相关信息后提交进行联网查询证书

@@ -14,12 +13,29 @@ 选择
- +
- + +
+
+ +
+
+ +
+
+ +
+
+ +
@@ -29,7 +45,7 @@ var aqzsdata = $('#aqzsff').serializeJSON(); $.ajax({ type: "POST", - url: 'api/safecert?a=addspider', + url: 'api/safecert?a=add', data: JSON.stringify(aqzsdata), datatype: "json", processData: false, diff --git a/safesite/templates/safecertadd_.html b/safesite/templates/safecertadd_.html new file mode 100644 index 00000000..0be5e79f --- /dev/null +++ b/safesite/templates/safecertadd_.html @@ -0,0 +1,96 @@ +
+ +
+
+

请输入相关信息后提交进行联网查询证书

+
+ + + 选择 +
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/safesite/templates/safecertedit.html b/safesite/templates/safecertedit.html new file mode 100644 index 00000000..cea1d109 --- /dev/null +++ b/safesite/templates/safecertedit.html @@ -0,0 +1,117 @@ +
+
+ 提交 + 取消 +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ \ No newline at end of file diff --git a/safesite/templates/socert.html b/safesite/templates/socert.html index 7bfef4b5..6c1c2ce8 100644 --- a/safesite/templates/socert.html +++ b/safesite/templates/socert.html @@ -92,9 +92,9 @@ { field: 'ccfzrq', title: '初次发证日期', width: 80 }, { field: 'yfsrq', title: '应复审日期', width: 80 ,sortable:true,styler: function (value, row, index) { switch (row.zszt) { - case 1: return 'background-color:green;'; break; + case 1: return 'background-color:green;color:white'; break; case 2: return 'background-color:yellow;'; break; - case 3: return 'background-color:red;'; break; + case 3: return 'background-color:red;color:white'; break; } }}, { field: 'yxqkssj', title: '有效期开始时间', width: 80 }, @@ -136,12 +136,13 @@ $.messager.alert('提示', '未选择数据!'); } } - function wsdetail(){ - var row = $('#wstable').datagrid('getSelected'); + function edittzzs(){ + var row = $('#tzzstable').datagrid('getSelected'); if (row) { - var url = 'misshtml/detail/' + row.missid - opendg('查看详情',url) + opendg('编辑','html/socert/edit/' + row.id) } - else { $.messager.alert('提示', '未选择数据!'); } + else { + $.messager.alert('提示', '请先选择一条记录!'); + } } \ No newline at end of file diff --git a/safesite/templates/socertadd.html b/safesite/templates/socertadd.html index f4752638..7a0ac832 100644 --- a/safesite/templates/socertadd.html +++ b/safesite/templates/socertadd.html @@ -69,7 +69,7 @@ } else { $('#submitb').linkbutton('disable'); } - loading('联网查询中,请稍等。。') + // loading('联网查询中,请稍等。。') }, success: function (data) { if (data.code == 1) { @@ -78,14 +78,14 @@ } // else { $.messager.alert('提示', '相关信息错误或查询无证!'); } $('#submitb').linkbutton('enable'); - removeLoading() + // removeLoading() }, error: function (XMLHttpRequest, textStatus, errorThrown) { // $("#p_test").innerHTML = "there is something wrong!"; // alert(XMLHttpRequest.status); // alert(XMLHttpRequest.readyState); // alert(textStatus); - removeLoading() + // removeLoading() $('#submitb').linkbutton('enable'); } }); diff --git a/safesite/templates/socertedit.html b/safesite/templates/socertedit.html index f4752638..6beb4036 100644 --- a/safesite/templates/socertedit.html +++ b/safesite/templates/socertedit.html @@ -10,8 +10,6 @@
- - 选择
/',views.socertedit), path('html/medetail', views.medetail), path('html/suggest', views.suggest), path('html/suggest/add', views.suggestadd), @@ -71,6 +72,7 @@ urlpatterns = [ path('html/examtest/detail//', views.examtestdetail), path('html/safecert', views.safecert), path('html/safecert/add', views.safecertadd), + path('html/safecert/edit//',views.safecertedit), path('html/area', views.area), path('html/areadetail', views.areadetail), path('html/mapshow', views.mapshow), diff --git a/safesite/views.py b/safesite/views.py index 5b49acf5..90ef5c8c 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -284,6 +284,8 @@ def safecert(req): def safecertadd(req): return render(req, 'safecertadd.html') +def safecertedit(req, id): + return render(req, 'safecertedit.html', {'id': id}) def examtestdetail(req, id): return render(req, 'examtestdetail.html', {'id': id}) @@ -420,6 +422,8 @@ def socerthtml(req): def socertadd(req): return render(req, 'socertadd.html') +def socertedit(req, id): + return render(req, 'socertedit.html', {'id':id}) def rightshtml(req): groupid = req.GET.get('groupid') @@ -4040,8 +4044,7 @@ def apisocert(req): userid = req.session['userid'] companyid = getcompany(userid) startnum, endnum = fenye(req) - a = Socertificate.objects.filter(usecomp=Partment.objects.get( - partid=companyid)).order_by('id') # 无deletemark + a = Socertificate.objects.filter(user__usecomp__partid=companyid).order_by('id') # 无deletemark total = a.count() startnum, endnum = fenye(req) if req.GET.get('sort'): @@ -4076,6 +4079,19 @@ def apisocert(req): obj.usecomp = user.usecomp obj.save() return JsonResponse({'code':1}) + elif a == 'edit': + postdata = json.loads(req.body.decode('utf-8')) + obj = Socertificate.objects.get(id=postdata['id']) + obj.zylb = postdata['zylb'] + obj.fzjg = postdata['fzjg'] + obj.czxm = postdata['czxm'] + obj.ccfzrq = postdata['ccfzrq'] + obj.yfsrq = postdata['yfsrq'] + obj.yxqkssj = postdata['yxqkssj'] + obj.yxqjssj = postdata['yxqjssj'] + obj.zszt = guoqi(postdata['yfsrq']) + obj.save() + return JsonResponse({'code':1}) # elif a == 'addspider': # postdata = json.loads(req.body.decode('utf-8')) # userid = postdata['userid'] @@ -4200,7 +4216,7 @@ def apisocert(req): elif a == 'detail': id = req.GET.get('id') a = Socertificate.objects.filter(id=id).values( - 'id', 'realname', 'gender', 'zylb', 'czxm', 'fzjg', 'ccfzrq', 'yfsrq', 'yxqkssj', 'yxqjssj', 'sjfssj', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum') + 'id', 'realname', 'gender', 'zylb', 'czxm', 'fzjg', 'ccfzrq', 'yfsrq', 'yxqkssj', 'yxqjssj', 'sjfssj', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum', 'user__name') return JsonResponse(a[0]) elif a == 'getjson': cardnum = req.GET.get('cardnum') @@ -4233,8 +4249,7 @@ def apisafecert(req): userid = req.session['userid'] companyid = getcompany(userid) startnum, endnum = fenye(req) - a = Safecert.objects.filter(usecomp=Partment.objects.get( - partid=companyid)).order_by('id') # 无deletemark + a = Safecert.objects.filter(user__usecomp__partid=companyid).order_by('id') # 无deletemark total = a.count() startnum, endnum = fenye(req) if req.GET.get('sort'): @@ -4253,6 +4268,33 @@ def apisafecert(req): a = a.values('id', 'realname', 'gender', 'zglx', 'dwlx', 'fzjg', 'yfsrq', 'yxqkssj', 'yxqjssj', 'zszt', 'url', 'cardnum', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum') return HttpResponse(transjson(total, a), content_type="application/json") + elif a == 'add': + postdata = json.loads(req.body.decode('utf-8')) + obj = Safecert() + user = User.objects.get(userid = postdata['userid']) + obj.user = User.objects.get(userid = postdata['userid']) + obj.zglx = postdata['zglx'] + obj.fzjg = postdata['fzjg'] + obj.dwlx = postdata['dwlx'] + obj.yfsrq = postdata['yfsrq'] + obj.yxqkssj = postdata['yxqkssj'] + obj.yxqjssj = postdata['yxqjssj'] + obj.zszt = guoqi(postdata['yfsrq']) + obj.usecomp = user.usecomp + obj.save() + return JsonResponse({'code':1}) + elif a == 'edit': + postdata = json.loads(req.body.decode('utf-8')) + obj = Safecert.objects.get(id=postdata['id']) + obj.zylb = postdata['zglx'] + obj.fzjg = postdata['fzjg'] + obj.czxm = postdata['dwlx'] + obj.yfsrq = postdata['yfsrq'] + obj.yxqkssj = postdata['yxqkssj'] + obj.yxqjssj = postdata['yxqjssj'] + obj.zszt = guoqi(postdata['yfsrq']) + obj.save() + return JsonResponse({'code':1}) # elif a == 'addspider': # postdata = json.loads(req.body.decode('utf-8')) # userid = postdata['userid'] @@ -4370,7 +4412,7 @@ def apisafecert(req): elif a == 'detail': id = req.GET.get('id') a = Safecert.objects.filter(id=id).values( - 'id', 'realname', 'gender', 'zglx', 'dwlx', 'fzjg', 'yfsrq', 'yxqkssj', 'yxqjssj', 'zszt', 'url', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum') + 'id', 'realname', 'gender', 'zglx', 'dwlx', 'fzjg', 'yfsrq', 'yxqkssj', 'yxqjssj', 'zszt', 'url', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum', 'user__name') return JsonResponse(a[0]) elif a == 'getjson': cardnum = req.GET.get('cardnum') From 835b7116e666bbd1405825d303ce78d65828d388 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 17 Nov 2020 13:49:09 +0800 Subject: [PATCH 4/8] dialog refresh --- .../migrations/0366_auto_20201117_1314.py | 27 +++++++++++++++++++ safesite/templates/examtestdetail.html | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 safesite/migrations/0366_auto_20201117_1314.py diff --git a/safesite/migrations/0366_auto_20201117_1314.py b/safesite/migrations/0366_auto_20201117_1314.py new file mode 100644 index 00000000..319a3f31 --- /dev/null +++ b/safesite/migrations/0366_auto_20201117_1314.py @@ -0,0 +1,27 @@ +# Generated by Django 2.2.8 on 2020-11-17 13:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0365_auto_20201115_2158'), + ] + + operations = [ + # migrations.RemoveField( + # model_name='companyinfo', + # name='liaison_fax', + # ), + migrations.AlterField( + model_name='checktask', + name='checkplace', + field=models.TextField(default=''), + ), + migrations.AlterField( + model_name='checktask', + name='userlist', + field=models.TextField(default=''), + ), + ] diff --git a/safesite/templates/examtestdetail.html b/safesite/templates/examtestdetail.html index 03827a66..52bbf657 100644 --- a/safesite/templates/examtestdetail.html +++ b/safesite/templates/examtestdetail.html @@ -217,7 +217,7 @@ success: function (data) { alert(data.msg); - $("#dd").dialog("close"); + $("#dd").dialog("refresh"); } }); }; From a1de212d696f2300771a0f25dbc9ee2270c8578c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 17 Nov 2020 16:38:04 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E9=A2=98=E7=9B=AE=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0367_auto_20201117_1405.py | 22 ++++++++ safesite/models.py | 1 + safesite/static/safesite/mystatic/js/util.js | 8 +-- safesite/templates/question.html | 52 +++++++++++++++++++ safesite/templates/questioncatadd.html | 4 ++ safesite/templates/questioncatedit.html | 8 +++ safesite/templates/userhtml.html | 2 +- safesite/views.py | 22 ++++---- 8 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 safesite/migrations/0367_auto_20201117_1405.py diff --git a/safesite/migrations/0367_auto_20201117_1405.py b/safesite/migrations/0367_auto_20201117_1405.py new file mode 100644 index 00000000..f17b788f --- /dev/null +++ b/safesite/migrations/0367_auto_20201117_1405.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.8 on 2020-11-17 14:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0366_auto_20201117_1314'), + ] + + operations = [ + # migrations.RemoveField( + # model_name='companyinfo', + # name='liaison_fax', + # ), + migrations.AddField( + model_name='questioncat', + name='isopen', + field=models.IntegerField(default=0), + ), + ] diff --git a/safesite/models.py b/safesite/models.py index 1525cf8c..10a0311c 100644 --- a/safesite/models.py +++ b/safesite/models.py @@ -693,6 +693,7 @@ class Questioncat(models.Model): # 题目分类 modifytime = models.DateTimeField(auto_now=True) usecomp = models.ForeignKey( Partment, on_delete=models.CASCADE, null=True, blank=True) + isopen = models.IntegerField(default=0) #默认不共享 # 题库数据表 diff --git a/safesite/static/safesite/mystatic/js/util.js b/safesite/static/safesite/mystatic/js/util.js index 8364bc05..0470b57e 100644 --- a/safesite/static/safesite/mystatic/js/util.js +++ b/safesite/static/safesite/mystatic/js/util.js @@ -213,14 +213,16 @@ function convert(rows, x) { id: row.id, text: row.name, state: x, - pic: row.pic + pic: row.pic, + isopen: row.isopen } if(row.name=='默认分类'){ node = { id: row.id, text: row.name, state: 'closed', - pic: row.pic + pic: row.pic, + isopen: row.isopen } } @@ -238,7 +240,7 @@ function convert(rows, x) { for (var i = 0; i < rows.length; i++) { var row = rows[i]; if (row.parentId == node.id) { - var child = { id: row.id, text: row.name, pic: row.pic }; + var child = { id: row.id, text: row.name, pic: row.pic, isopen:row.isopen }; if (node.children) { node.children.push(child); } else { diff --git a/safesite/templates/question.html b/safesite/templates/question.html index 5d121f92..be713c5f 100644 --- a/safesite/templates/question.html +++ b/safesite/templates/question.html @@ -56,6 +56,7 @@ {% endif %} 复制题目至自建分类 + 导出Excel
+
+ + +
- + 查询
diff --git a/safesite/views.py b/safesite/views.py index 90ef5c8c..587cfa67 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -2755,7 +2755,7 @@ def getuser(req): companyid = getcompany(userid) parts = Partment.objects.filter( partlink__contains=','+companyid+',') | Partment.objects.filter(partid=companyid) - a = User.objects.filter(ubelongpart__in=parts, deletemark=1, name__contains=req.GET.get('name')).order_by( + a = User.objects.filter(ubelongpart__in=parts, deletemark=1).filter(Q(name__contains=req.GET.get('name'))|Q(username__contains=req.GET.get('name'))).order_by( 'userid').values('userid', 'empid', 'name', 'ubelongpart__partname', 'ubelongpart__partid', 'username', 'openid') total = a.count() return HttpResponse(transjson(total, a), content_type="application/json") @@ -6666,11 +6666,11 @@ def apiquestioncat(req): companyid = getcompany(userid) if a == 'tree1': list_items = (Questioncat.objects.filter(usecomp__partid=1, deletemark=1)).annotate( - parentId=F('parent__id')).values('id', 'parentId', 'name') + parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') return HttpResponse(json.dumps(list(list_items)), content_type="application/json") elif a == 'tree2': list_items = (Questioncat.objects.filter(usecomp__partid=companyid, deletemark=1)).annotate( - parentId=F('parent__id')).values('id', 'parentId', 'name') + parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') return HttpResponse(json.dumps(list(list_items)), content_type="application/json") elif a == 'tree3': groups = g_models.Groupmember.objects.filter(member__partid=companyid).values_list('group__id', flat=True) @@ -6679,19 +6679,21 @@ def apiquestioncat(req): pass else: companys = Partment.objects.filter(partid=companyid).values_list('partid', flat=True) - list_items = (Questioncat.objects.filter(usecomp__in=companys, deletemark=1)| Questioncat.objects.filter( - usecomp__partid=1, deletemark=1)).annotate( - parentId=F('parent__id')).values('id', 'parentId', 'name') + list_items = (Questioncat.objects.filter(usecomp__in=companys, deletemark=1, isopen=1)| Questioncat.objects.filter( + usecomp__partid=1, deletemark=1, isopen=1)).annotate( + parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') return HttpResponse(json.dumps(list(list_items)), content_type="application/json") elif a == 'tree': list_items = (Questioncat.objects.filter(usecomp__partid=1, deletemark=1) | Questioncat.objects.filter( - usecomp__partid=companyid, deletemark=1)).annotate(parentId=F('parent__id')).values('id', 'parentId', 'name') + usecomp__partid=companyid, deletemark=1)).annotate(parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') return HttpResponse(json.dumps(list(list_items)), content_type="application/json") elif a == 'add': data = json.loads(req.body.decode('utf-8')) obj = Questioncat() name = data['name'] obj.name = name + if 'isopen' in data: + obj.isopen = 1 if 'parent' in data: if data['parent']: parent = data['parent'] @@ -6710,17 +6712,19 @@ def apiquestioncat(req): return JsonResponse({"code": 1}) else: return JsonResponse({"code": 0}) - return JsonResponse({"code": 1}) elif a == 'detail': id = req.GET.get('id') a = Questioncat.objects.filter(id=id).values( - 'id', 'name', 'parent__id')[0] + 'id', 'name', 'parent__id', 'isopen')[0] return JsonResponse(a) elif a == 'edit': data = json.loads(req.body.decode('utf-8')) id = data['id'] a = Questioncat.objects.get(id=id) a.name = data['name'] + a.isopen = 0 + if 'isopen' in data: + a.isopen = 1 if 'parent' in data: if data['parent']: parent = Questioncat.objects.get(id=data['parent']) From 912c4ec1bae6dcd9a4d84deb83e4aef4a4a70b2b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 17 Nov 2020 16:56:20 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E9=A2=98=E7=9B=AE=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/templates/question.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/safesite/templates/question.html b/safesite/templates/question.html index be713c5f..6ac0dbc2 100644 --- a/safesite/templates/question.html +++ b/safesite/templates/question.html @@ -54,9 +54,13 @@ 导入试题 {% endif %} + {% if request|has_permission:'b_question_copy' %} 复制题目至自建分类 + {% endif %} + {% if request|has_permission:'b_question_export' %} 导出Excel + {% endif %}