用户自己选择工作类别
This commit is contained in:
parent
bdd68f6b61
commit
fd620df3df
|
|
@ -34,6 +34,12 @@
|
||||||
<el-tag type="warning" v-else>否</el-tag>
|
<el-tag type="warning" v-else>否</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="是否公开">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag v-if="scope.row.is_public">是</el-tag>
|
||||||
|
<el-tag type="warning" v-else>否</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="排序">
|
<el-table-column label="排序">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ scope.row.sortnum }}</span>
|
<span>{{ scope.row.sortnum }}</span>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@
|
||||||
<el-form-item label="是否可组织考试" prop="can_exam" label-width="120px">
|
<el-form-item label="是否可组织考试" prop="can_exam" label-width="120px">
|
||||||
<el-switch v-model="Form.can_exam"></el-switch>
|
<el-switch v-model="Form.can_exam"></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="是否公开" prop="is_public" label-width="120px">
|
||||||
|
<el-switch v-model="Form.is_public"></el-switch>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="所属学科" prop="subject">
|
<el-form-item label="所属学科" prop="subject">
|
||||||
<el-select v-model="Form.subject" placeholder="请选择所属学科" style="width:400px">
|
<el-select v-model="Form.subject" placeholder="请选择所属学科" style="width:400px">
|
||||||
<el-option
|
<el-option
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@
|
||||||
<el-form-item label="是否可组织考试" prop="can_exam" label-width="120px">
|
<el-form-item label="是否可组织考试" prop="can_exam" label-width="120px">
|
||||||
<el-switch v-model="Form.can_exam"></el-switch>
|
<el-switch v-model="Form.can_exam"></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="是否公开" prop="is_public" label-width="120px">
|
||||||
|
<el-switch v-model="Form.is_public"></el-switch>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="所属学科" prop="subject">
|
<el-form-item label="所属学科" prop="subject">
|
||||||
<el-select v-model="Form.subject" placeholder="请选择所属学科" style="width:400px">
|
<el-select v-model="Form.subject" placeholder="请选择所属学科" style="width:400px">
|
||||||
<el-option
|
<el-option
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,9 @@ App({
|
||||||
globalData: {
|
globalData: {
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
userinfo: {}, // 服务器传回的消费者信息
|
userinfo: {}, // 服务器传回的消费者信息
|
||||||
host: 'https://apitest.ahctc.cn',
|
//host: 'https://apitest.ahctc.cn',
|
||||||
mediahost: 'https://apitest.ahctc.cn',
|
mediahost: 'https://apitest.ahctc.cn',
|
||||||
//host: 'http://127.0.0.1:8000',
|
host: 'http://127.0.0.1:8000',
|
||||||
//mediahost: 'http://127.0.0.1:8000',
|
//mediahost: 'http://127.0.0.1:8000',
|
||||||
token : '',
|
token : '',
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,7 @@ Page({
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad: function (options) {
|
onLoad: function (options) {
|
||||||
let userinfo = getApp().globalData.userinfo
|
|
||||||
if(userinfo.username){
|
|
||||||
userinfo.username = userinfo.username.replace(/(\d{3})(\d{4})(\d{4})/,"$1****$3")
|
|
||||||
}
|
|
||||||
this.setData({
|
|
||||||
userinfo: userinfo
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,6 +30,13 @@ Page({
|
||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
|
let userinfo = getApp().globalData.userinfo
|
||||||
|
if(userinfo.username){
|
||||||
|
userinfo.username = userinfo.username.replace(/(\d{3})(\d{4})(\d{4})/,"$1****$3")
|
||||||
|
}
|
||||||
|
this.setData({
|
||||||
|
userinfo: userinfo
|
||||||
|
})
|
||||||
api.request('/examtest/examtest/fx/', 'GET').then(res => {
|
api.request('/examtest/examtest/fx/', 'GET').then(res => {
|
||||||
this.setData(res.data)
|
this.setData(res.data)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-cells__title">统计分析</view>
|
<view class="weui-cells__title">统计分析</view>
|
||||||
<view class="weui-cells weui-cells_after-title">
|
<view class="weui-cells weui-cells_after-title">
|
||||||
<view class="weui-cell">
|
<navigator url="/pages/workscope/index" class="weui-cell weui-cell_access">
|
||||||
<view class="weui-cell__hd">
|
<view class="weui-cell__hd">
|
||||||
<image src="/images/class.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
<image src="/images/class.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
||||||
</image>
|
</image>
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:if="{{userinfo.workscope_name}}">
|
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:if="{{userinfo.workscope_name}}">
|
||||||
{{userinfo.workscope_name}}</view>
|
{{userinfo.workscope_name}}</view>
|
||||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:else>无</view>
|
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:else>无</view>
|
||||||
</view>
|
</navigator>
|
||||||
<!-- <l-list title="模考次数" tag-content="{{total}}" tag-position="right"/> -->
|
<!-- <l-list title="模考次数" tag-content="{{total}}" tag-position="right"/> -->
|
||||||
<view class="weui-cell">
|
<view class="weui-cell">
|
||||||
<view class="weui-cell__hd">
|
<view class="weui-cell__hd">
|
||||||
|
|
|
||||||
|
|
@ -15,29 +15,29 @@ Page({
|
||||||
*/
|
*/
|
||||||
onLoad: function (options) {
|
onLoad: function (options) {
|
||||||
var that = this
|
var that = this
|
||||||
try {
|
// try {
|
||||||
var value = wx.getStorageSync('nowSubject')
|
// var value = wx.getStorageSync('nowSubject')
|
||||||
if (value.id) {
|
// if (value.id) {
|
||||||
api.request('/examtest/workscope/', 'GET', { subject:value.id}).then(res => {
|
api.request('/examtest/workscope/', 'GET', {is_public:true}).then(res => {
|
||||||
that.setData({
|
that.setData({
|
||||||
workData:res.data
|
workData:res.data
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}else{
|
// }else{
|
||||||
wx.showModal({
|
// wx.showModal({
|
||||||
content: '请先选择学科!',
|
// content: '请先选择学科!',
|
||||||
showCancel:false,
|
// showCancel:false,
|
||||||
success(res) {
|
// success(res) {
|
||||||
if (res.confirm) {
|
// if (res.confirm) {
|
||||||
wx.redirectTo({
|
// wx.redirectTo({
|
||||||
url: '/pages/subject/index',
|
// url: '/pages/subject/index',
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
}
|
// }
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -92,9 +92,17 @@ Page({
|
||||||
|
|
||||||
chooseWork: function (e) {
|
chooseWork: function (e) {
|
||||||
let work = e.currentTarget.dataset
|
let work = e.currentTarget.dataset
|
||||||
wx.setStorageSync('nowWork', work)
|
api.request(`/examtest/workscope/${work.id}/chose/`, 'GET').then(res => {
|
||||||
wx.navigateBack({
|
//选择工作类别
|
||||||
|
// 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)
|
||||||
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
@ -1,21 +1,18 @@
|
||||||
<!--pages/lianxi/index.wxml-->
|
|
||||||
<view class="page">
|
|
||||||
<view class="page__bd">
|
|
||||||
<view class="weui-panel__hd">所有工作类别</view>
|
|
||||||
<view class="weui-panel__bd">
|
<view class="weui-panel__bd">
|
||||||
<block wx:for="{{workData}}" wx:key="unique">
|
<block wx:for="{{workData}}" wx:key="unique">
|
||||||
<view class="weui-media-box weui-media-box_appmsg" bindtap="chooseWork" data-id="{{item.id}}" data-name="{{item.name}}">
|
<view class="weui-media-box weui-media-box_appmsg" bindtap="chooseWork" data-id="{{item.id}}" data-name="{{item.name}}">
|
||||||
<view class="weui-media-box__hd">
|
<!-- <view class="weui-media-box__hd">
|
||||||
<image class="weui-media-box__thumb" src="/images/fushe.svg" alt></image>
|
<image class="weui-media-box__thumb" src="/images/fushe.svg" alt></image>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="weui-media-box__bd">
|
<view class="weui-media-box__bd">
|
||||||
<h4 class="weui-media-box__title">{{item.name}}</h4>
|
<h4 class="weui-media-box__title">{{item.name}}</h4>
|
||||||
<view class="weui-media-box__desc">
|
<view class="weui-media-box__desc">
|
||||||
<span style="font-weight:bold;color:darkblue" >{{item.subject_name}}</span>
|
<span style="color:blue;border:1rpx solid blue;font-size:12px" wx:if="{{item.can_exam}}">公开可选</span>
|
||||||
|
该类别下包含<span style="color:darkblue">{{item.questioncat.length}}</span>个科目
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ function request(url, method, data) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var msg = ''
|
var msg = '请求错误'
|
||||||
if(res.data.msg){
|
if(res.data.msg){
|
||||||
msg = JSON.stringify(res.data.msg)
|
msg = res.data.msg
|
||||||
}
|
}
|
||||||
if (msg.indexOf('该操作的权限')!=-1){
|
if (msg.indexOf('该操作的权限')!=-1){
|
||||||
msg = '权限不足或账户过期,请联系课程顾问'
|
msg = '权限不足或账户过期,请联系课程顾问'
|
||||||
|
|
|
||||||
|
|
@ -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='是否公开'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -34,6 +34,7 @@ class WorkScope(CommonModel):
|
||||||
rule = models.ForeignKey(TestRule, on_delete=models.CASCADE, verbose_name='试卷结构')
|
rule = models.ForeignKey(TestRule, on_delete=models.CASCADE, verbose_name='试卷结构')
|
||||||
can_exam = models.BooleanField('是否可组织考试', default=False)
|
can_exam = models.BooleanField('是否可组织考试', default=False)
|
||||||
sortnum = models.IntegerField('排序码', default=1)
|
sortnum = models.IntegerField('排序码', default=1)
|
||||||
|
is_public = models.BooleanField('是否公开', default=True)
|
||||||
# can_choose = models.BooleanField('客户是否可选择', default=False)
|
# can_choose = models.BooleanField('客户是否可选择', default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
from crm.models import Candidate
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.db.models import Avg
|
from django.db.models import Avg
|
||||||
|
|
@ -172,15 +173,15 @@ class WorkScopeViewSet(ModelViewSet):
|
||||||
工作类别:增删改查
|
工作类别:增删改查
|
||||||
"""
|
"""
|
||||||
perms_map = [
|
perms_map = [
|
||||||
{'get': 'workscope_list'}, {'post': 'workscope_create'},
|
{'get': '*'}, {'post': 'workscope_create'},
|
||||||
{'put': 'workscope_update'}, {'delete': 'workscope_delete'}]
|
{'put': 'workscope_update'}, {'delete': 'workscope_delete'}]
|
||||||
pagination_class = None
|
pagination_class = None
|
||||||
queryset = WorkScope.objects.filter(is_delete=0).all().order_by("id")
|
queryset = WorkScope.objects.filter(is_delete=0).all().order_by("id")
|
||||||
serializer_class = WorkScopeSerializer
|
serializer_class = WorkScopeSerializer
|
||||||
ordering_fields = ('id',)
|
ordering_fields = ('id',)
|
||||||
ordering = ['sortnum']
|
ordering = ['-can_exam', 'sortnum']
|
||||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
filterset_fields = ['subject', 'can_exam']
|
filterset_fields = ['subject', 'can_exam', 'is_public']
|
||||||
search_fields = ('name',)
|
search_fields = ('name',)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|
@ -307,6 +308,23 @@ class WorkScopeViewSet(ModelViewSet):
|
||||||
ret['remain_count'] = user.remain_count
|
ret['remain_count'] = user.remain_count
|
||||||
return Response(ret)
|
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):
|
class BannerViewSet(ModelViewSet):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue