workscope back
This commit is contained in:
parent
5698e0b2a2
commit
143e34d1ac
|
@ -108,6 +108,11 @@
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column align="center" label="工作类别">
|
||||||
|
<template slot-scope="scope" >
|
||||||
|
<el-tag v-if="scope.row.workscope_name">{{ scope.row.workscope_name }}</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.create_time }}</span>
|
<span>{{ scope.row.create_time }}</span>
|
||||||
|
@ -177,6 +182,17 @@
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="工作类别" prop="subjects">
|
||||||
|
<el-select v-model="consumer.workscope" placeholder="工作类别" style="width:100%" >
|
||||||
|
<el-option
|
||||||
|
v-for="item in workscopeData"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
>
|
||||||
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
@ -197,6 +213,7 @@ import {
|
||||||
importConsumer
|
importConsumer
|
||||||
} from "@/api/crm";
|
} from "@/api/crm";
|
||||||
import { getSubjectAll } from "@/api/question"
|
import { getSubjectAll } from "@/api/question"
|
||||||
|
import { getWorkScopeAll } from "@/api/examtest"
|
||||||
import { getCompanyList } from "@/api/crm";
|
import { getCompanyList } from "@/api/crm";
|
||||||
import { genTree, deepClone } from "@/utils";
|
import { genTree, deepClone } from "@/utils";
|
||||||
import checkPermission from "@/utils/permission";
|
import checkPermission from "@/utils/permission";
|
||||||
|
@ -209,7 +226,8 @@ const defaultConsumer = {
|
||||||
name: "",
|
name: "",
|
||||||
username: "",
|
username: "",
|
||||||
company: null,
|
company: null,
|
||||||
subjects:[]
|
subjects:[],
|
||||||
|
workscope:null
|
||||||
};
|
};
|
||||||
const listQuery = {
|
const listQuery = {
|
||||||
page: 1,
|
page: 1,
|
||||||
|
@ -253,6 +271,7 @@ export default {
|
||||||
treeLoding: false,
|
treeLoding: false,
|
||||||
companyData: [],
|
companyData: [],
|
||||||
subjectData: [],
|
subjectData: [],
|
||||||
|
workscopeData:[],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
|
@ -260,6 +279,7 @@ export default {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.getCompanyList();
|
this.getCompanyList();
|
||||||
this.getSubjectAll();
|
this.getSubjectAll();
|
||||||
|
this.getWorkScopeAll();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
checkPermission,
|
checkPermission,
|
||||||
|
@ -313,6 +333,11 @@ export default {
|
||||||
this.subjectData = genTree(response.data);
|
this.subjectData = genTree(response.data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getWorkScopeAll() {
|
||||||
|
getWorkScopeAll().then(response => {
|
||||||
|
this.workscopeData = genTree(response.data);
|
||||||
|
});
|
||||||
|
},
|
||||||
resetFilter() {
|
resetFilter() {
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
page: 1,
|
page: 1,
|
||||||
|
|
|
@ -20,10 +20,6 @@ App({
|
||||||
wx.reLaunch({
|
wx.reLaunch({
|
||||||
url: '/pages/login/login',
|
url: '/pages/login/login',
|
||||||
})
|
})
|
||||||
}else if(res.data.userinfo.subjects){
|
|
||||||
try {
|
|
||||||
wx.setStorageSync('nowSubject', {id:res.data.userinfo.subjects[0],name:res.data.userinfo.subjects_name[0]})
|
|
||||||
} catch (e) { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -52,9 +48,9 @@ App({
|
||||||
globalData: {
|
globalData: {
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
userinfo: null, // 服务器传回的消费者信息
|
userinfo: null, // 服务器传回的消费者信息
|
||||||
host: 'https://apitest.ctcshe.com/',
|
// host: 'https://apitest.ctcshe.com/',
|
||||||
mediahost: 'https://apitest.ctcshe.com/',
|
mediahost: 'https://apitest.ctcshe.com/',
|
||||||
// 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 : '',
|
||||||
subject:null,
|
subject:null,
|
||||||
|
|
|
@ -6,27 +6,25 @@ Page({
|
||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
questioncatData:[],
|
questioncatData: [],
|
||||||
isLoad:true
|
isLoad: true
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad: function () {
|
onLoad: function () {
|
||||||
try {
|
|
||||||
var value = wx.getStorageSync('nowWork')
|
if (getApp().globalData.userinfo.workscope) {
|
||||||
if (value) {
|
this.setData({
|
||||||
this.setData({
|
workscopeId: getApp().globalData.userinfo.workscope
|
||||||
workscopeId: value.id
|
})
|
||||||
})
|
} else {
|
||||||
} else{
|
wx.switchTab({
|
||||||
wx.switchTab({
|
url: '/pages/main/main',
|
||||||
url: '/pages/main/main',
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,10 +40,10 @@ Page({
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
this.getList()
|
this.getList()
|
||||||
},
|
},
|
||||||
getList: function (){
|
getList: function () {
|
||||||
var that = this
|
var that = this
|
||||||
if(that.data.workscopeId){
|
if (that.data.workscopeId) {
|
||||||
api.request('question/questioncat/workscope/', 'GET', { 'id': that.data.workscopeId }).then(res => {
|
api.request('question/questioncat/workscope/', 'GET', { 'id': that.data.workscopeId }).then(res => {
|
||||||
let questioncatData = []
|
let questioncatData = []
|
||||||
if (res.data.length > 0) {
|
if (res.data.length > 0) {
|
||||||
for (var i = 0; i < res.data.length; i++) {
|
for (var i = 0; i < res.data.length; i++) {
|
||||||
|
@ -61,10 +59,10 @@ Page({
|
||||||
questioncatData: that.showYd(questioncatData)
|
questioncatData: that.showYd(questioncatData)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
showYd: function (cat) {
|
showYd: function (cat) {
|
||||||
for (var i = 0; i < cat.length; i++) {
|
for (var i = 0; i < cat.length; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -111,10 +109,10 @@ Page({
|
||||||
onShareAppMessage: function () {
|
onShareAppMessage: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
startLianxi: function (e) {
|
startLianxi: function (e) {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: 'main?questioncat='+e.currentTarget.id,
|
url: 'main?questioncat=' + e.currentTarget.id,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
restartLianxi: function (e) {
|
restartLianxi: function (e) {
|
||||||
|
|
|
@ -71,11 +71,11 @@ Page({
|
||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
if(wx.getStorageSync('nowWork')){
|
// if(wx.getStorageSync('nowWork')){
|
||||||
this.setData({
|
// this.setData({
|
||||||
nowWork: wx.getStorageSync('nowWork')
|
// nowWork: wx.getStorageSync('nowWork')
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,36 +112,34 @@ Page({
|
||||||
onShareAppMessage: function () {
|
onShareAppMessage: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
chooseWork: function () {
|
// chooseWork: function () {
|
||||||
wx.navigateTo({
|
// wx.navigateTo({
|
||||||
url: '/pages/workscope/index',
|
// url: '/pages/workscope/index',
|
||||||
})
|
// })
|
||||||
},
|
// },
|
||||||
goLianxi: function () {
|
goLianxi: function () {
|
||||||
let nowWork = wx.getStorageSync('nowWork')
|
if (getApp().globalData.userinfo.workscope){
|
||||||
if (nowWork){
|
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/lianxi/index',
|
url: '/pages/lianxi/index',
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: '请先选择工作类别',
|
title: '未开通权限\r\n请联系顾问师圆',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 1500
|
duration: 2000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
goMoni: function () {
|
goMoni: function () {
|
||||||
let nowWork = wx.getStorageSync('nowWork')
|
if (getApp().globalData.userinfo.workscope) {
|
||||||
if (nowWork) {
|
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/moni/index',
|
url: '/pages/moni/index',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: '请先选择工作类别',
|
title: '未开通权限\r\n请联系顾问师圆',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 1500
|
duration: 2000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
</block>
|
</block>
|
||||||
</swiper>
|
</swiper>
|
||||||
<view style="margin-top:4px">
|
<view style="margin-top:4px">
|
||||||
<a class="weui-btn weui-btn_primary" bindtap="chooseWork">选择工作类别</a>
|
|
||||||
<view style="color:blue;font-weight:bold;text-align:center">
|
<view style="color:blue;font-weight:bold;text-align:center">
|
||||||
当前工作类别:
|
欢迎使用中科辐射学堂!
|
||||||
<span style="color:orange;font-weight:bold" wx:if="{{nowWork}}">{{nowWork.name}}</span>
|
<view style="color:orange;font-weight:bold">
|
||||||
<span style="color:orange;font-weight:bold" wx:else>未选择</span>
|
<view >如有疑问请联系顾问师圆</view>
|
||||||
|
<view >18355135390(微信同号)</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-cells__title">练习</view>
|
<view class="weui-cells__title">练习</view>
|
||||||
|
|
|
@ -14,20 +14,13 @@ Page({
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad: function () {
|
onLoad: function () {
|
||||||
try {
|
if (getApp().globalData.userinfo.workscope) {
|
||||||
var value = wx.getStorageSync('nowWork')
|
this.setData({
|
||||||
if (value) {
|
workscopeId: getApp().globalData.userinfo.workscope
|
||||||
this.setData({
|
})
|
||||||
workId: value.id
|
} else {
|
||||||
})
|
wx.switchTab({
|
||||||
this.genPaper()
|
url: '/pages/main/main',
|
||||||
}else{
|
|
||||||
wx.navigateBack({
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
wx.navigateBack({
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,7 +9,7 @@ Page({
|
||||||
total:0,
|
total:0,
|
||||||
avg_score:0,
|
avg_score:0,
|
||||||
pass_rate:0,
|
pass_rate:0,
|
||||||
nowSubject:'点击选择'
|
nowWork:'点击选择'
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,15 +32,6 @@ Page({
|
||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
try {
|
|
||||||
var value = wx.getStorageSync('nowSubject')
|
|
||||||
if (value) {
|
|
||||||
this.setData({
|
|
||||||
nowSubject: value.name
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
api.request('examtest/myexamtestfx', 'GET').then(res => {
|
api.request('examtest/myexamtestfx', 'GET').then(res => {
|
||||||
this.setData(res.data)
|
this.setData(res.data)
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
</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">
|
||||||
<navigator class="weui-cell" url="/pages/subject/index">
|
<view class="weui-cell" >
|
||||||
<view class="weui-cell__bd">当前学科</view>
|
<view class="weui-cell__bd">工作类别</view>
|
||||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue">{{nowSubject}}</view>
|
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue"
|
||||||
</navigator>
|
wx:if="{{userinfo.workscope_name}}"
|
||||||
|
>{{userinfo.workscope_name}}</view>
|
||||||
|
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue"
|
||||||
|
wx:else
|
||||||
|
>无</view>
|
||||||
|
</view>
|
||||||
<view class="weui-cell">
|
<view class="weui-cell">
|
||||||
<view class="weui-cell__bd">自助模考数量</view>
|
<view class="weui-cell__bd">自助模考数量</view>
|
||||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue">{{total}}</view>
|
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue">{{total}}</view>
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.0.4 on 2020-03-26 07:24
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('examtest', '0016_auto_20200325_1610'),
|
||||||
|
('crm', '0010_auto_20200324_1621'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='consumer',
|
||||||
|
name='workscope',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='examtest.WorkScope', verbose_name='工作类别'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -2,6 +2,7 @@ from django.db import models
|
||||||
import django.utils.timezone as timezone
|
import django.utils.timezone as timezone
|
||||||
from rbac.models import SoftCommonModel, CommonModel
|
from rbac.models import SoftCommonModel, CommonModel
|
||||||
from question.models import Questioncat, Question
|
from question.models import Questioncat, Question
|
||||||
|
from examtest.models_paper import WorkScope
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
class Company(SoftCommonModel):
|
class Company(SoftCommonModel):
|
||||||
|
@ -29,6 +30,7 @@ class Consumer(SoftCommonModel):
|
||||||
avatar = models.CharField(default='/media/default/avatar.png',max_length=1000, null=True, blank=True, verbose_name='头像')
|
avatar = models.CharField(default='/media/default/avatar.png',max_length=1000, null=True, blank=True, verbose_name='头像')
|
||||||
nickname = models.CharField(max_length=200, verbose_name='昵称', null=True, blank=True)
|
nickname = models.CharField(max_length=200, verbose_name='昵称', null=True, blank=True)
|
||||||
subjects = models.ManyToManyField(Questioncat, verbose_name='付费学科', through='PaySubject')
|
subjects = models.ManyToManyField(Questioncat, verbose_name='付费学科', through='PaySubject')
|
||||||
|
workscope = models.ForeignKey(WorkScope, verbose_name='工作类别', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
collects = models.ManyToManyField(Question, verbose_name='收藏试题')
|
collects = models.ManyToManyField(Question, verbose_name='收藏试题')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ class ConsumerSerializer(serializers.ModelSerializer):
|
||||||
update_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
|
update_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
|
||||||
company_name = serializers.StringRelatedField(source='company', read_only=True)
|
company_name = serializers.StringRelatedField(source='company', read_only=True)
|
||||||
subjects_name = serializers.StringRelatedField(source='subjects', many=True, read_only=True)
|
subjects_name = serializers.StringRelatedField(source='subjects', many=True, read_only=True)
|
||||||
|
workscope_name = serializers.StringRelatedField(source='workscope', read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Consumer
|
model = Consumer
|
||||||
|
|
|
@ -27,6 +27,7 @@ from crm.permission import IsConsumerAuthenticated
|
||||||
from .models import Company, Consumer, PaySubject, SendCode
|
from .models import Company, Consumer, PaySubject, SendCode
|
||||||
from .serializers import CompanySerializer, ConsumerSerializer
|
from .serializers import CompanySerializer, ConsumerSerializer
|
||||||
from question.serializers import QuestionSerializer
|
from question.serializers import QuestionSerializer
|
||||||
|
from examtest.models_paper import WorkScope
|
||||||
from server import settings
|
from server import settings
|
||||||
from question.models import Questioncat
|
from question.models import Questioncat
|
||||||
from crm.zhenzismsclient import ZhenziSmsClient
|
from crm.zhenzismsclient import ZhenziSmsClient
|
||||||
|
@ -101,8 +102,8 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
queryset = Consumer.objects.filter(is_delete=0).all()
|
queryset = Consumer.objects.filter(is_delete=0).all()
|
||||||
serializer_class = ConsumerSerializer
|
serializer_class = ConsumerSerializer
|
||||||
pagination_class = CommonPagination
|
pagination_class = CommonPagination
|
||||||
ordering_fields = ('id',)
|
ordering_fields = ('id','company','create_time')
|
||||||
ordering = ['company']
|
ordering = ['company','-create_time']
|
||||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
filterset_fields = ('company',)
|
filterset_fields = ('company',)
|
||||||
search_fields = ('^name',)
|
search_fields = ('^name',)
|
||||||
|
@ -145,7 +146,7 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
url_path='sendcode', url_name='code_send')
|
url_path='sendcode', url_name='code_send')
|
||||||
def sendcode(self, request):
|
def sendcode(self, request):
|
||||||
'''
|
'''
|
||||||
发送二维码
|
发送验证码
|
||||||
'''
|
'''
|
||||||
client = ZhenziSmsClient(sms_url, sms_appid, sms_appsecret)
|
client = ZhenziSmsClient(sms_url, sms_appid, sms_appsecret)
|
||||||
code = random.randint(1000,9999)
|
code = random.randint(1000,9999)
|
||||||
|
@ -204,34 +205,44 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
return Response({"error":"单位列错误!"})
|
return Response({"error":"单位列错误!"})
|
||||||
if sheet['d2'].value != '付费学科':
|
if sheet['d2'].value != '付费学科':
|
||||||
return Response({"error":"付费学科列错误!"})
|
return Response({"error":"付费学科列错误!"})
|
||||||
|
if sheet['e2'].value != '工作类别':
|
||||||
|
return Response({"error":"工作类别列错误!"})
|
||||||
companydict = {}
|
companydict = {}
|
||||||
consumerdict = {}
|
consumerdict = {}
|
||||||
companys = Company.objects.filter(is_delete=0)
|
companys = Company.objects.filter(is_delete=0)
|
||||||
for i in companys:
|
for i in companys:
|
||||||
companydict[i.name] = i.id
|
companydict[i.name] = i.id
|
||||||
i = 3
|
m = 3
|
||||||
while sheet['B'+str(i)].value:
|
while sheet['B'+str(m)].value:
|
||||||
name = sheet['A'+str(i)].value
|
name = sheet['A'+str(m)].value
|
||||||
if name:
|
if name:
|
||||||
name = name.replace(' ', '')
|
name = name.replace(' ', '')
|
||||||
username = sheet['B'+str(i)].value
|
username = sheet['B'+str(m)].value
|
||||||
if username:
|
if username:
|
||||||
username = str(username).replace(' ', '')
|
username = str(username).replace(' ', '')
|
||||||
companyname = sheet['C'+str(i)].value
|
companyname = sheet['C'+str(m)].value
|
||||||
if companyname:
|
if companyname:
|
||||||
companyname = companyname.replace(' ', '')
|
companyname = companyname.replace(' ', '')
|
||||||
if companyname not in companydict:
|
if companyname not in companydict:
|
||||||
return Response({"error":"不存在单位("+companyname+")!请先新建"})
|
return Response({"error":"不存在单位("+companyname+")!请先新建"})
|
||||||
else:
|
else:
|
||||||
companyobj = Company.objects.get(id=companydict[companyname])
|
companyobj = Company.objects.get(id=companydict[companyname])
|
||||||
subjects = sheet['d'+str(i)].value
|
subjects = sheet['d'+str(m)].value
|
||||||
|
workscope = sheet['e'+str(m)].value
|
||||||
if Consumer.objects.filter(username = username).exists():
|
if Consumer.objects.filter(username = username).exists():
|
||||||
consumerdict[username]=i
|
consumerdict[username]=m
|
||||||
else:
|
else:
|
||||||
obj = Consumer()
|
obj = Consumer()
|
||||||
obj.name = name
|
obj.name = name
|
||||||
obj.username = username
|
obj.username = username
|
||||||
obj.company = companyobj
|
obj.company = companyobj
|
||||||
|
if workscope:
|
||||||
|
workscope = workscope.replace(' ', '')
|
||||||
|
try:
|
||||||
|
workscopeobj = WorkScope.objects.get(name=workscope)
|
||||||
|
obj.workscope = workscopeobj
|
||||||
|
except:
|
||||||
|
pass
|
||||||
obj.save()
|
obj.save()
|
||||||
if subjects:
|
if subjects:
|
||||||
subjects_list = subjects.replace(' ','').split(',')
|
subjects_list = subjects.replace(' ','').split(',')
|
||||||
|
@ -239,7 +250,8 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
queryset = Questioncat.objects.filter(name=i,is_subject=True,is_delete=False)
|
queryset = Questioncat.objects.filter(name=i,is_subject=True,is_delete=False)
|
||||||
if queryset.exists():
|
if queryset.exists():
|
||||||
PaySubject.objects.create(subject=queryset.first(), consumer=obj)
|
PaySubject.objects.create(subject=queryset.first(), consumer=obj)
|
||||||
i = i + 1
|
|
||||||
|
m = m + 1
|
||||||
return Response(status=status.HTTP_200_OK)
|
return Response(status=status.HTTP_200_OK)
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,4 +318,6 @@ class ConsumerRegister(APIView):
|
||||||
else:
|
else:
|
||||||
return Response({'error':'验证码错误!'})
|
return Response({'error':'验证码错误!'})
|
||||||
else:
|
else:
|
||||||
return Response({'error':'认证错误!'})
|
return Response({'error':'认证错误!'})
|
||||||
|
else:
|
||||||
|
return Response({'error':'信息不全!'})
|
|
@ -3,46 +3,9 @@ from rbac.models import SoftCommonModel, CommonModel
|
||||||
from django.contrib.postgres.fields import JSONField, ArrayField
|
from django.contrib.postgres.fields import JSONField, ArrayField
|
||||||
from question.models import Questioncat, Question
|
from question.models import Questioncat, Question
|
||||||
from crm.models import Consumer
|
from crm.models import Consumer
|
||||||
|
from .models_paper import WorkScope, Paper
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
class TestRule(SoftCommonModel):
|
|
||||||
name = models.CharField(max_length=200, unique=True, verbose_name='名称')
|
|
||||||
danxuan_count = models.IntegerField(default=0, verbose_name='单选数量')
|
|
||||||
danxuan_score = models.FloatField(default=0, verbose_name='单选分数')
|
|
||||||
duoxuan_count = models.IntegerField(default=0, verbose_name='多选数量')
|
|
||||||
duoxuan_score = models.FloatField(default=0, verbose_name='多选分数')
|
|
||||||
panduan_count = models.IntegerField(default=0, verbose_name='判断数量')
|
|
||||||
panduan_score = models.FloatField(default=0, verbose_name='判断分数')
|
|
||||||
limit = models.IntegerField(default=0, verbose_name='限时(分钟)')
|
|
||||||
total_score = models.FloatField(default=0, verbose_name='满分')
|
|
||||||
pass_score = models.FloatField(default=0, verbose_name='及格分数')
|
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = '出题规则'
|
|
||||||
verbose_name_plural = verbose_name
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
class WorkScope(SoftCommonModel):
|
|
||||||
name = models.CharField(max_length=200, unique=True, verbose_name='名称')
|
|
||||||
subject = models.ForeignKey(Questioncat, verbose_name='所属学科', on_delete=models.CASCADE , related_name='workscope_subject')
|
|
||||||
questioncat = models.ManyToManyField(Questioncat, verbose_name='所选科目')
|
|
||||||
rule = models.ForeignKey(TestRule, on_delete=models.CASCADE, verbose_name='试卷结构')
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = '工作类别'
|
|
||||||
verbose_name_plural = verbose_name
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
class Paper(SoftCommonModel):
|
|
||||||
name = models.CharField(max_length=200, verbose_name='名称')
|
|
||||||
|
|
||||||
class ExamTest(CommonModel):
|
class ExamTest(CommonModel):
|
||||||
'''
|
'''
|
||||||
硬删除
|
硬删除
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
from django.db import models
|
||||||
|
from rbac.models import SoftCommonModel, CommonModel
|
||||||
|
from django.contrib.postgres.fields import JSONField, ArrayField
|
||||||
|
from question.models import Questioncat, Question
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class TestRule(SoftCommonModel):
|
||||||
|
name = models.CharField(max_length=200, unique=True, verbose_name='名称')
|
||||||
|
danxuan_count = models.IntegerField(default=0, verbose_name='单选数量')
|
||||||
|
danxuan_score = models.FloatField(default=0, verbose_name='单选分数')
|
||||||
|
duoxuan_count = models.IntegerField(default=0, verbose_name='多选数量')
|
||||||
|
duoxuan_score = models.FloatField(default=0, verbose_name='多选分数')
|
||||||
|
panduan_count = models.IntegerField(default=0, verbose_name='判断数量')
|
||||||
|
panduan_score = models.FloatField(default=0, verbose_name='判断分数')
|
||||||
|
limit = models.IntegerField(default=0, verbose_name='限时(分钟)')
|
||||||
|
total_score = models.FloatField(default=0, verbose_name='满分')
|
||||||
|
pass_score = models.FloatField(default=0, verbose_name='及格分数')
|
||||||
|
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = '出题规则'
|
||||||
|
verbose_name_plural = verbose_name
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class WorkScope(SoftCommonModel):
|
||||||
|
name = models.CharField(max_length=200, unique=True, verbose_name='名称')
|
||||||
|
subject = models.ForeignKey(Questioncat, verbose_name='所属学科', on_delete=models.CASCADE , related_name='workscope_subject')
|
||||||
|
questioncat = models.ManyToManyField(Questioncat, verbose_name='所选科目')
|
||||||
|
rule = models.ForeignKey(TestRule, on_delete=models.CASCADE, verbose_name='试卷结构')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = '工作类别'
|
||||||
|
verbose_name_plural = verbose_name
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class Paper(SoftCommonModel):
|
||||||
|
name = models.CharField(max_length=200, verbose_name='名称')
|
|
@ -1,7 +1,8 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from question.models import Questioncat
|
from question.models import Questioncat
|
||||||
from crm.models import Consumer
|
from crm.models import Consumer
|
||||||
from .models import TestRule, ExamTest, AnswerDetail, WorkScope
|
from .models import ExamTest, AnswerDetail
|
||||||
|
from .models_paper import TestRule, WorkScope
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ from utils.custom import CommonPagination
|
||||||
from rbac.permission import RbacPermission
|
from rbac.permission import RbacPermission
|
||||||
from question.models import Question
|
from question.models import Question
|
||||||
from question.serializers import QuestionSerializer
|
from question.serializers import QuestionSerializer
|
||||||
from .models import TestRule, ExamTest, AnswerDetail, WorkScope
|
from .models import ExamTest, AnswerDetail
|
||||||
|
from .models_paper import TestRule, WorkScope
|
||||||
from .serializers import TestRuleSerializer, MoniTestSerializer, AnswerDetailSerializer, ExamTestListSerializer, AnswerDetailCreateSerializer, WorkScopeSerializer
|
from .serializers import TestRuleSerializer, MoniTestSerializer, AnswerDetailSerializer, ExamTestListSerializer, AnswerDetailCreateSerializer, WorkScopeSerializer
|
||||||
from server import settings
|
from server import settings
|
||||||
from crm.authentication import ConsumerTokenAuthentication
|
from crm.authentication import ConsumerTokenAuthentication
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue