safesite/safesite/templates/examtest.html

149 lines
6.0 KiB
HTML

<table id="kstable" style="width:auto;height:100%;"></table>
<div id="kstablebar" style="padding:4px;height:auto">
<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')
$('#kstable').datagrid({url:'api/examtest',queryParams:{a:option}});
})
function addks(obj){
opendg('发布考试','html/examtest/add')
}
function addks2(obj){
opendg('发布考试','html/examtest/add2')
}
$('#kstable').datagrid({
url: '',
rownumbers: true,
singleSelect: true,
striped: true,
fitColumns: true,
method: 'get',
pagination: 'true',
pageSize: 20,
toolbar: '#kstablebar',
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;'; break;
}
},formatter: function (value, row, index) {
switch (value) {
case 1: return '进行中'; break;
case 0: return '已结束'; break;
}
} },
]]
});
function delks(){
var row = $('#kstable').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) {
$("#kstable").datagrid('reload');
}
else {
$.messager.alert('提示', '你无权删除该条记录!');
}
},
complete: function (XMLHttpRequest, textStatus) {
},
error: function () {
}
});
}
});
}
else {
$.messager.alert('提示', '请选择一行数据!');
}
}
function closeks(){
var row = $('#kstable').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) {
$("#kstable").datagrid('reload');
}
else {
$.messager.alert('提示', '你无权关闭该考试!');
}
},
complete: function (XMLHttpRequest, textStatus) {
},
error: function () {
}
});
}
});
}
else {
$.messager.alert('提示', '请选择一行数据!');
}
}
function ksdetail(){
var row = $('#kstable').datagrid('getSelected');
if (row) {
var url = 'html/examtest/detail/' + row.id
opendg('查看详情',url,1000)
}
else { $.messager.alert('提示', '请选择一行数据!'); }
}
function exportksexcel() {
var querydata = $('#searchksff').serialize();
let url = 'api/suggest?a=exportexcel&'+querydata
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
}
</script>