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'])