diff --git a/test_client/src/views/examtest/workscope.vue b/test_client/src/views/examtest/workscope.vue
index 949d459..d9121eb 100644
--- a/test_client/src/views/examtest/workscope.vue
+++ b/test_client/src/views/examtest/workscope.vue
@@ -34,6 +34,12 @@
否
+
+
+ 是
+ 否
+
+
{{ scope.row.sortnum }}
diff --git a/test_client/src/views/examtest/workscopecreate.vue b/test_client/src/views/examtest/workscopecreate.vue
index b02e55c..3388cf0 100644
--- a/test_client/src/views/examtest/workscopecreate.vue
+++ b/test_client/src/views/examtest/workscopecreate.vue
@@ -13,6 +13,9 @@
+
+
+
+
+
+
{
this.setData(res.data)
})
diff --git a/test_mini/pages/my/index.wxml b/test_mini/pages/my/index.wxml
index 3835256..48c0083 100644
--- a/test_mini/pages/my/index.wxml
+++ b/test_mini/pages/my/index.wxml
@@ -28,7 +28,7 @@
统计分析
-
+
@@ -37,7 +37,7 @@
{{userinfo.workscope_name}}
无
-
+
diff --git a/test_mini/pages/workscope/index.js b/test_mini/pages/workscope/index.js
index a9ed760..5359a3b 100644
--- a/test_mini/pages/workscope/index.js
+++ b/test_mini/pages/workscope/index.js
@@ -15,29 +15,29 @@ Page({
*/
onLoad: function (options) {
var that = this
- try {
- var value = wx.getStorageSync('nowSubject')
- if (value.id) {
- api.request('/examtest/workscope/', 'GET', { subject:value.id}).then(res => {
+ // try {
+ // var value = wx.getStorageSync('nowSubject')
+ // if (value.id) {
+ api.request('/examtest/workscope/', 'GET', {is_public:true}).then(res => {
that.setData({
workData:res.data
})
})
- }else{
- wx.showModal({
- content: '请先选择学科!',
- showCancel:false,
- success(res) {
- if (res.confirm) {
- wx.redirectTo({
- url: '/pages/subject/index',
- })
- }
- }
- })
- }
- } catch (e) {
- }
+ // }else{
+ // wx.showModal({
+ // content: '请先选择学科!',
+ // showCancel:false,
+ // success(res) {
+ // if (res.confirm) {
+ // wx.redirectTo({
+ // url: '/pages/subject/index',
+ // })
+ // }
+ // }
+ // })
+ // }
+ // } catch (e) {
+ // }
},
@@ -92,9 +92,17 @@ Page({
chooseWork: function (e) {
let work = e.currentTarget.dataset
- wx.setStorageSync('nowWork', work)
- wx.navigateBack({
+ api.request(`/examtest/workscope/${work.id}/chose/`, 'GET').then(res => {
+ //选择工作类别
+ // that.setData({
+ // workData:res.data
+ // })
+ getApp().globalData.userinfo.workscope = res.data.workscope
+ getApp().globalData.userinfo.workscope_name = res.data.workscope_name
+ wx.navigateBack({
+ })
})
-
+ //wx.setStorageSync('nowWork', work)
+
},
})
\ No newline at end of file
diff --git a/test_mini/pages/workscope/index.wxml b/test_mini/pages/workscope/index.wxml
index d205a7d..1d1046b 100644
--- a/test_mini/pages/workscope/index.wxml
+++ b/test_mini/pages/workscope/index.wxml
@@ -1,21 +1,18 @@
-
-
-
-所有工作类别
+
-
+
- {{item.subject_name}}
+ 公开可选
+ 该类别下包含{{item.questioncat.length}}个科目
-
-
+
diff --git a/test_mini/utils/request.js b/test_mini/utils/request.js
index 72efb49..3248084 100644
--- a/test_mini/utils/request.js
+++ b/test_mini/utils/request.js
@@ -18,9 +18,9 @@ function request(url, method, data) {
})
}
else {
- var msg = ''
+ var msg = '请求错误'
if(res.data.msg){
- msg = JSON.stringify(res.data.msg)
+ msg = res.data.msg
}
if (msg.indexOf('该操作的权限')!=-1){
msg = '权限不足或账户过期,请联系课程顾问'
diff --git a/test_server/examtest/migrations/0029_workscope_is_public.py b/test_server/examtest/migrations/0029_workscope_is_public.py
new file mode 100644
index 0000000..1832a49
--- /dev/null
+++ b/test_server/examtest/migrations/0029_workscope_is_public.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.4 on 2021-04-17 03:38
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('examtest', '0028_workscope_sortnum'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='workscope',
+ name='is_public',
+ field=models.BooleanField(default=True, verbose_name='是否公开'),
+ ),
+ ]
diff --git a/test_server/examtest/models_paper.py b/test_server/examtest/models_paper.py
index f5a9f7f..7f896a6 100644
--- a/test_server/examtest/models_paper.py
+++ b/test_server/examtest/models_paper.py
@@ -34,6 +34,7 @@ class WorkScope(CommonModel):
rule = models.ForeignKey(TestRule, on_delete=models.CASCADE, verbose_name='试卷结构')
can_exam = models.BooleanField('是否可组织考试', default=False)
sortnum = models.IntegerField('排序码', default=1)
+ is_public = models.BooleanField('是否公开', default=True)
# can_choose = models.BooleanField('客户是否可选择', default=False)
class Meta:
diff --git a/test_server/examtest/views.py b/test_server/examtest/views.py
index 5531d2e..75f9dd0 100644
--- a/test_server/examtest/views.py
+++ b/test_server/examtest/views.py
@@ -1,3 +1,4 @@
+from crm.models import Candidate
from datetime import datetime
from django.db.models import Avg
@@ -172,15 +173,15 @@ class WorkScopeViewSet(ModelViewSet):
工作类别:增删改查
"""
perms_map = [
- {'get': 'workscope_list'}, {'post': 'workscope_create'},
+ {'get': '*'}, {'post': 'workscope_create'},
{'put': 'workscope_update'}, {'delete': 'workscope_delete'}]
pagination_class = None
queryset = WorkScope.objects.filter(is_delete=0).all().order_by("id")
serializer_class = WorkScopeSerializer
ordering_fields = ('id',)
- ordering = ['sortnum']
+ ordering = ['-can_exam', 'sortnum']
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
- filterset_fields = ['subject', 'can_exam']
+ filterset_fields = ['subject', 'can_exam', 'is_public']
search_fields = ('name',)
def get_queryset(self):
@@ -307,6 +308,23 @@ class WorkScopeViewSet(ModelViewSet):
ret['remain_count'] = user.remain_count
return Response(ret)
+ @action(methods=['get'], detail=True, perms_map=[{'get':'*'}])
+ def chose(self, request, *args, **kwargs):
+ """
+ 用户自己选择工作类别
+ """
+ obj = self.get_object()
+ if obj.can_exam:
+ try:
+ Candidate.objects.get_or_create(consumer=request.user, workscope=request.user.workscope, defaults={'consumer':request.user, 'workscope':request.user.workscope})
+ except:
+ pass
+ request.user.workscope = obj
+ request.user.save()
+ return Response({'workscope':obj.pk, 'workscope_name':obj.name})
+ if Candidate.objects.filter(consumer=request.user, workscope=obj).exists():
+ return Response({'workscope':obj.pk, 'workscope_name':obj.name})
+ return Response({'error':'该类别不可选择,请咨询课程顾问'})
class BannerViewSet(ModelViewSet):
"""