增加培训计划表
This commit is contained in:
parent
1e1ed8330b
commit
d869afcee5
|
@ -793,9 +793,13 @@ class TrainPlan(models.Model):
|
||||||
purpose = models.TextField('培训目的')
|
purpose = models.TextField('培训目的')
|
||||||
year = models.IntegerField('年份', default=2021)
|
year = models.IntegerField('年份', default=2021)
|
||||||
month = models.IntegerField('月份', default=1)
|
month = models.IntegerField('月份', default=1)
|
||||||
manager = models.ForeignKey(User, verbose_name="负责人", on_delete=models.SET_NULL, null=True, blank=True)
|
manager = models.ForeignKey(User, verbose_name="负责人", on_delete=models.SET_NULL, null=True, blank=True, related_name='trainplan_manager')
|
||||||
period = models.IntegerField('预计学时', default=0)
|
period = models.IntegerField('预计学时', default=0)
|
||||||
group = models.ForeignKey(Group, verbose_name='组', on_delete=models.SET_NULL, null=True, blank=True)
|
group = models.ForeignKey(Group, verbose_name='组', on_delete=models.SET_NULL, null=True, blank=True, related_name='trainplan_group')
|
||||||
|
usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE)
|
||||||
|
createtime = models.DateTimeField(default=timezone.now)
|
||||||
|
modifytime = models.DateTimeField(auto_now=True)
|
||||||
|
deletemark = models.IntegerField(default=1)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return str(self.year)+'年'+str(self.month)+'月计划'
|
return str(self.year)+'年'+str(self.month)+'月计划'
|
||||||
|
|
|
@ -47,3 +47,13 @@ class EquipmentCheckFormSerializers2(serializers.Serializer):
|
||||||
desc = serializers.CharField()
|
desc = serializers.CharField()
|
||||||
usecomp = serializers.PrimaryKeyRelatedField(read_only=True)
|
usecomp = serializers.PrimaryKeyRelatedField(read_only=True)
|
||||||
createby = UserSerializer(read_only=True)
|
createby = UserSerializer(read_only=True)
|
||||||
|
|
||||||
|
class TrainPlanSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = TrainPlan
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TrainPlanUpdateSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = TrainPlan
|
||||||
|
fields = ('purpose','year','month', 'manager', 'period', 'group')
|
|
@ -0,0 +1,180 @@
|
||||||
|
<table id="pxjhtable" style="width:auto;height:100%;"></table>
|
||||||
|
<div id="pxjhtablebar" style="padding:4px;height:auto">
|
||||||
|
<div>
|
||||||
|
<form id='searchpxjhff'>
|
||||||
|
<label>考试状态</label>
|
||||||
|
<select name='state' style='width:150px' class="easyui-combobox" editable=false>
|
||||||
|
<option value="">请选择</option>
|
||||||
|
<option value="open">进行中</option>
|
||||||
|
<option value="close">已关闭</option>
|
||||||
|
</select>
|
||||||
|
<label>开始时间</label>
|
||||||
|
<a class="easyui-datebox" name="starttime1" editable=false></a>
|
||||||
|
<label>-</label>
|
||||||
|
<a class="easyui-datebox" name="starttime2" editable=false></a>
|
||||||
|
<a class="easyui-textbox" name="search" data-options="prompt:'考试名或试卷名'"></a>
|
||||||
|
|
||||||
|
<a onclick="kssearch()" class="easyui-linkbutton">查询</a>
|
||||||
|
<a onclick="ksreset()" class="easyui-linkbutton">重置</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{% load myfilter %}
|
||||||
|
{% if request|has_permission:'b_examtest_add1' %}
|
||||||
|
<a class="easyui-linkbutton" data-options="iconCls: 'fa-plus',plain:true" onclick="addks()">试卷库考试</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if request|has_permission:'b_examtest_add2' %}
|
||||||
|
<a class="easyui-linkbutton" data-options="iconCls: 'fa-plus',plain:true" onclick="addks2()">自动抽题考试</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if request|has_permission:'b_examtest_close' %}
|
||||||
|
<a class="easyui-linkbutton" data-options="iconCls: 'fa-times',plain:true" onclick="closeks()">关闭考试</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if request|has_permission:'b_examtest_del' %}
|
||||||
|
<a id="delks" class="easyui-linkbutton" onclick="delks()" data-options="iconCls: 'fa-trash',plain:true">删除</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if request|has_permission:'b_examtest_detail' %}
|
||||||
|
<a id="ksdetail" onclick="ksdetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">查看详情</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
var option = $('#main').attr('value')
|
||||||
|
$('#pxjhtable').datagrid({url:'api/examtest',queryParams:{a:option}});
|
||||||
|
})
|
||||||
|
function addks(obj){
|
||||||
|
opendg('发布考试','html/examtest/add')
|
||||||
|
}
|
||||||
|
function kssearch() {
|
||||||
|
var querydata = $('#searchpxjhff').serializeJSON();
|
||||||
|
querydata['a'] = 'listall'
|
||||||
|
$('#pxjhtable').datagrid('load', querydata);
|
||||||
|
}
|
||||||
|
function ksreset() {
|
||||||
|
$('#searchpxjhff').form('clear')
|
||||||
|
$('#pxjhtable').datagrid('options').queryParams = {
|
||||||
|
a:'listall'
|
||||||
|
}
|
||||||
|
$('#pxjhtable').datagrid('load');
|
||||||
|
|
||||||
|
}
|
||||||
|
function addks2(obj){
|
||||||
|
opendg('发布考试','html/examtest/add2')
|
||||||
|
}
|
||||||
|
$('#pxjhtable').datagrid({
|
||||||
|
url: '',
|
||||||
|
rownumbers: true,
|
||||||
|
singleSelect: true,
|
||||||
|
striped: true,
|
||||||
|
fitColumns: true,
|
||||||
|
method: 'get',
|
||||||
|
pagination: 'true',
|
||||||
|
pageSize: 20,
|
||||||
|
toolbar: '#pxjhtablebar',
|
||||||
|
border:false,
|
||||||
|
columns: [[
|
||||||
|
{ field: 'id', title: 'ID', hidden: true },
|
||||||
|
{ field: 'num', title: '编号', width: 60 },
|
||||||
|
{ field: 'type', title: '类型', width: 60 ,formatter: function (value, row, index) {
|
||||||
|
switch (value) {
|
||||||
|
case 1: return '正式考试'; break;
|
||||||
|
case 2: return '模拟考试'; break;
|
||||||
|
}
|
||||||
|
} },
|
||||||
|
{ field: 'name', title: '考试名', width: 160 },
|
||||||
|
{ field: 'exampaper__name', title: '试卷名', width: 160 },
|
||||||
|
{ field: 'duration', title: '答卷时长', width: 60 },
|
||||||
|
{ field: 'starttime', title: '开启时间', width: 80 },
|
||||||
|
{ field: 'createuser__name', title: '发布人', width: 80 },
|
||||||
|
{ field: 'state', title: '状态', width: 40,styler: function (value, row, index) {
|
||||||
|
switch (value) {
|
||||||
|
case 0: return 'background-color:yellow;'; break;
|
||||||
|
case 1: return 'background-color:green;color:white'; break;
|
||||||
|
}
|
||||||
|
},formatter: function (value, row, index) {
|
||||||
|
switch (value) {
|
||||||
|
case 1: return '进行中'; break;
|
||||||
|
case 0: return '已结束'; break;
|
||||||
|
}
|
||||||
|
} },
|
||||||
|
]]
|
||||||
|
});
|
||||||
|
function delks(){
|
||||||
|
var row = $('#pxjhtable').datagrid('getSelected');
|
||||||
|
if (row) {
|
||||||
|
$.messager.confirm('提示', '将会删除该考试所有考生答题记录,确定删除吗?', function (r) {
|
||||||
|
if (r) {
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: 'api/examtest?a=del',
|
||||||
|
data: { 'id': row.id },
|
||||||
|
datatype: "json",
|
||||||
|
beforeSend: function () { },
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 1) {
|
||||||
|
$("#pxjhtable").datagrid('reload');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.messager.alert('提示', '你无权删除该条记录!');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function (XMLHttpRequest, textStatus) {
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.messager.alert('提示', '请选择一行数据!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function closeks(){
|
||||||
|
var row = $('#pxjhtable').datagrid('getSelected');
|
||||||
|
if (row) {
|
||||||
|
$.messager.confirm('提示', '确定关闭考试吗?', function (r) {
|
||||||
|
if (r) {
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: 'api/examtest?a=close',
|
||||||
|
data: { 'id': row.id },
|
||||||
|
datatype: "json",
|
||||||
|
beforeSend: function () { },
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 1) {
|
||||||
|
$("#pxjhtable").datagrid('reload');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.messager.alert('提示', '你无权关闭该考试!');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function (XMLHttpRequest, textStatus) {
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.messager.alert('提示', '请选择一行数据!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function ksdetail(){
|
||||||
|
var row = $('#pxjhtable').datagrid('getSelected');
|
||||||
|
if (row) {
|
||||||
|
var url = 'html/examtest/detail/' + row.id
|
||||||
|
opendg('查看详情',url,1000)
|
||||||
|
}
|
||||||
|
else { $.messager.alert('提示', '请选择一行数据!'); }
|
||||||
|
}
|
||||||
|
function exportksexcel() {
|
||||||
|
var querydata = $('#searchpxjhff').serialize();
|
||||||
|
let url = 'api/suggest?a=exportexcel&'+querydata
|
||||||
|
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -6105,6 +6105,24 @@ def apiexampaper(req):
|
||||||
return JsonResponse({"code": 1})
|
return JsonResponse({"code": 1})
|
||||||
|
|
||||||
|
|
||||||
|
def apitrainplan(req):
|
||||||
|
a = req.GET.get('a')
|
||||||
|
userid = req.session['userid']
|
||||||
|
companyid = getcompany(userid)
|
||||||
|
if a == 'listall':
|
||||||
|
objs = TrainPlan.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||||
|
total = objs.count()
|
||||||
|
startnum, endnum = fenye(req)
|
||||||
|
objs = objs[startnum:endnum].values('id', 'purpose', 'year', 'month', 'manager', 'group_name')
|
||||||
|
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||||
|
elif a == 'add':
|
||||||
|
pass
|
||||||
|
elif a == 'edit':
|
||||||
|
pass
|
||||||
|
elif a == 'del':
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def apiexamtest(req):
|
def apiexamtest(req):
|
||||||
a = req.GET.get('a')
|
a = req.GET.get('a')
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from .models import *
|
from .models import *
|
||||||
from .serializers import *
|
from .serializers import *
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
from rest_framework.generics import ListAPIView
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue