464 lines
18 KiB
HTML
464 lines
18 KiB
HTML
<div class="easyui-layout" style="width:100%;height:100%;">
|
||
<div data-options="region:'west',split:true,border:false" style="width:260px;height:100%;">
|
||
<div id="mrfl" height="30%" title="默认分类">
|
||
<ul id="mrfltree" data-options="animate:true,toolbar:'#mrflbar'"></ul>
|
||
</div>
|
||
<!-- <div id="gwfl" height="30%"></div> -->
|
||
<div id="zjfl" height="30%" title="自建分类">
|
||
<div id="zjflbar" style="padding:5px;height:auto">
|
||
|
||
{% load myfilter %}
|
||
{% if request|has_permission:'b_question_user_add' %}
|
||
<a id="addtmfl2" onclick="javascript:opendg('新建分类','html/questioncat/add')" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">新增</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_user_upd' %}
|
||
<a id="edittmfl2" onclick="edittmfl2()" class="easyui-linkbutton" data-options="iconCls:'fa-pencil',plain:true">编辑</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_user_del' %}
|
||
<a id="deltmfl2" onclick="deltmfl2()" class="easyui-linkbutton" data-options="iconCls:'fa-trash',plain:true">删除</a>
|
||
{% endif %}
|
||
|
||
|
||
|
||
|
||
|
||
</div>
|
||
<ul id="zjfltree" data-options="animate:true,toolbar:'#zjflbar'"></ul>
|
||
</div>
|
||
<div id="gxfl" height="40%" title="集团共享分类" class="easyui-panel">
|
||
<ul id="gxfltree" data-options="animate:true"></ul>
|
||
</div>
|
||
</div>
|
||
<div data-options="region:'center',title:'题目',split:true,border:false" style="height:100%;">
|
||
|
||
<div id="tmbar" style="padding:5px;height:auto">
|
||
|
||
{% if request|has_permission:'b_question_danxuan' %}
|
||
<a id="addtm" onclick="javascript:opendg('新增单选','html/question/add')" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">单选题</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_duoxuan' %}
|
||
<a onclick="javascript:opendg('新增多选','html/question/add2')" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">多选题</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_panduan' %}
|
||
<a onclick="javascript:opendg('新增判断','html/question/add3')" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">判断题</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_upd' %}
|
||
<a id="edittm" onclick="edittm()" class="easyui-linkbutton"
|
||
data-options="iconCls:'fa-pencil',plain:true">单题编辑</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_del' %}
|
||
<a id="deltms" onclick="deltms()" class="easyui-linkbutton"
|
||
data-options="iconCls:'fa-trash',plain:true">批量删除</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_daoru' %}
|
||
<a id="drtms" onclick="javascript:$('#drtmdg').dialog('open').window('center');" class="easyui-linkbutton"
|
||
data-options="iconCls:'fa-upload',plain:true">导入试题</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_copy' %}
|
||
<a id="fztms" onclick="javascript:$('#fztmdg').dialog('open').window('center');" class="easyui-linkbutton"
|
||
data-options="iconCls:'fa-clone',plain:true">复制题目至自建分类</a>
|
||
{% endif %}
|
||
{% if request|has_permission:'b_question_export' %}
|
||
<a id="exportquestionexcel" onclick="exportquestionexcel()" class="easyui-linkbutton" data-options="iconCls: 'fa-download',plain:true">导出Excel</a>
|
||
{% endif %}
|
||
<div>
|
||
<form id='searchtmff'>
|
||
<select name='type' style="width:100px" class="easyui-combobox" data-options="prompt:'题型'">
|
||
<option value=""></option>
|
||
<option value="1">单选</option>
|
||
<option value="2">多选</option>
|
||
<option value="3">判断</option>
|
||
</select>
|
||
<input class="easyui-textbox" style="width:300px" name="title" data-options="prompt:'题干/分类名'"></input>
|
||
{% if request|has_permission:'b_question_showall' %}
|
||
<label>显示全部</label>
|
||
<input type="checkbox" id="showAll" name="all" value="1">
|
||
{% endif %}
|
||
<a onclick="searchTm()" class="easyui-linkbutton" data-options="iconCls:'fa-search',plain:true">查询</a>
|
||
<a onclick="reset()" class="easyui-linkbutton"
|
||
data-options="iconCls:'fa-undo',plain:true">重置</a>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
<table id="tmtable" style="height:100%;"></table>
|
||
|
||
</div>
|
||
<div id="drtmdg" class="easyui-dialog" title="导入" style="width:400px;height:200px;" data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:false">
|
||
<p style="color:red;margin-left: 10px">请按模板录入后导入</p>
|
||
<p style="margin-left: 10px"><a href="/static/safesite/muban/tm.xlsx" target="_blank">点击下载模板</a></p>
|
||
<p style="margin-left: 10px">录入完成后点击下方按钮上传文件</p>
|
||
<input type="file" id="drfile" name="" accept=".xls,.xlsx" style="margin-left: 10px" />
|
||
</div>
|
||
<div id="fztmdg" class="easyui-dialog" title="复制题目至" style="width:400px;height:200px;" data-options="iconCls:'fa-clone',resizable:true,modal:true,closed:true,border:false">
|
||
<form id="fztmff">
|
||
<p style="margin-left: 10px"><input class="easyui-combotree" name="questioncat" style="width:300px;margin-top:6px" data-options="
|
||
label:'自建分类',
|
||
url: 'api/questioncat?a=tree2',
|
||
method: 'get',
|
||
editable: false,
|
||
loadFilter: function (rows) {
|
||
return convert(rows);
|
||
},
|
||
formatter: function (node) {
|
||
var s = node.text;
|
||
if (node.children) {
|
||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||
}
|
||
return s;
|
||
},"
|
||
required=true></p>
|
||
<p style="margin-left: 10px">
|
||
<a id="confirmfzb" onclick="confirmfz()" class="easyui-linkbutton" >确定</a></p>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
$('#mrfl').panel()
|
||
$('#mrfltree').tree({
|
||
url: 'api/questioncat?a=tree1',
|
||
animate: true,
|
||
toolbar: '#mrflbar',
|
||
loadFilter: function (rows) {
|
||
return convert(rows);
|
||
},
|
||
formatter: function (node) {
|
||
var s = node.text;
|
||
if (node.children) {
|
||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||
}
|
||
return s;
|
||
},
|
||
onSelect: function (row) {
|
||
$('#tmtable').datagrid('options').queryParams.tmlx = row.id
|
||
$("#tmtable").datagrid('reload');
|
||
}
|
||
});
|
||
$('#zjfl').panel()
|
||
$('#zjfltree').tree({
|
||
url: 'api/questioncat?a=tree2',
|
||
animate: true,
|
||
toolbar: '#zjflbar',
|
||
loadFilter: function (rows) {
|
||
return convert(rows);
|
||
},
|
||
formatter: function (node) {
|
||
var s = node.text;
|
||
|
||
if (node.children) {
|
||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||
}
|
||
if(node.isopen==1){
|
||
s +='<span style=\'color:red\'>(已共享)</span>'
|
||
}
|
||
return s;
|
||
},
|
||
onSelect: function (row) {
|
||
$('#tmtable').datagrid('options').queryParams.tmlx = row.id
|
||
$("#tmtable").datagrid('reload');
|
||
}
|
||
});
|
||
$('#gxfltree').tree({
|
||
url: 'api/questioncat?a=tree3',
|
||
animate: true,
|
||
loadFilter: function (rows) {
|
||
return convert(rows, 'closed');
|
||
},
|
||
formatter: function (node) {
|
||
var s = node.text;
|
||
|
||
if (node.children) {
|
||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||
}
|
||
return s;
|
||
},
|
||
onSelect: function (row) {
|
||
$('#tmtable').datagrid('options').queryParams.tmlx = row.id
|
||
$("#tmtable").datagrid('reload');
|
||
}
|
||
});
|
||
$('#tmtable').datagrid({
|
||
url:'api/question',
|
||
queryParams:{a:'listall'},
|
||
rownumbers: true,
|
||
singleSelect: false,
|
||
striped: true,
|
||
method: 'get',
|
||
toolbar: '#tmbar',
|
||
pagination: 'true',
|
||
pageSize: 20,
|
||
columns: [[
|
||
{ field: 'id', title: 'ID', hidden: true },
|
||
{ field: 'ck', checkbox: true , width: '5%'},
|
||
{ field: 'title', title: '题目', width: '45%' },
|
||
{ field: 'type', title: '题型', width: '10%', formatter: function (value, row, index) {
|
||
if (value == 1) {
|
||
return '单选题';
|
||
}
|
||
else if(value==2){
|
||
return '多选题'
|
||
}
|
||
else if(value==3){
|
||
return '判断题'
|
||
}
|
||
} },
|
||
{ field: 'mark', title: '标签', width: '10%' },
|
||
{ field: 'level', title: '难易度', width: '10%', formatter: function (value, row, index) {
|
||
if (value == 1) {
|
||
return '低';
|
||
}
|
||
else if(value==2){
|
||
return '中'
|
||
}
|
||
else if(value==3){
|
||
return '高'
|
||
}
|
||
} },
|
||
{ field: 'questioncat__name', title: '所属分类', width: '25%' },
|
||
|
||
]],
|
||
});
|
||
|
||
//ajax接收的才是js对象
|
||
function deltms() {
|
||
var rows = $('#tmtable').datagrid('getSelections');
|
||
if(rows.length>0){
|
||
var data = {'ids':[]}
|
||
for(var i=0;i<rows.length;i++){
|
||
data.ids.push(rows[i].id)
|
||
}
|
||
$.messager.confirm('提示', '确定删除吗?', function (r) {
|
||
if (r) {
|
||
$.ajax({
|
||
type: "POST",
|
||
url: 'api/question?a=dels',
|
||
data: JSON.stringify(data),
|
||
datatype: "json",
|
||
beforeSend: function () { },
|
||
success: function (data) {
|
||
if (data.code == 1) {
|
||
$("#tmtable").datagrid('reload');
|
||
} else {
|
||
$.messager.alert('提示', '您无权删除!');
|
||
}
|
||
|
||
},
|
||
|
||
complete: function (XMLHttpRequest, textStatus) {
|
||
},
|
||
|
||
error: function () {
|
||
|
||
}
|
||
});
|
||
}
|
||
}
|
||
);
|
||
}
|
||
else {
|
||
$.messager.alert('提示', '未选择数据!');
|
||
}
|
||
}
|
||
//ajax接收的才是js对象
|
||
function deltmfl2() {
|
||
var row = $('#zjfltree').tree('getSelected');
|
||
if (row) {
|
||
$.messager.confirm('提示', '确定删除吗?', function (r) {
|
||
if (r) {
|
||
$.ajax({
|
||
type: "GET",
|
||
url: 'api/questioncat?a=del&id=' + row.id,
|
||
datatype: "json",
|
||
beforeSend: function () { },
|
||
success: function (data) {
|
||
if (data.code == 1) {
|
||
$("#zjfltree").tree('reload');
|
||
} else {
|
||
$.messager.alert('提示', '您无权删除!');
|
||
}
|
||
|
||
},
|
||
|
||
complete: function (XMLHttpRequest, textStatus) {
|
||
},
|
||
|
||
error: function () {
|
||
|
||
}
|
||
});
|
||
}
|
||
}
|
||
);
|
||
}
|
||
else {
|
||
$.messager.alert('提示', '未选择数据!');
|
||
}
|
||
}
|
||
function edittmfl2() {
|
||
var row = $('#zjfltree').tree('getSelected');
|
||
if (row) {
|
||
|
||
opendg('编辑分类','html/questioncat/edit/'+row.id)
|
||
|
||
|
||
}
|
||
else {
|
||
$.messager.alert('提示', '未选择数据!');
|
||
}
|
||
}
|
||
function edittm() {
|
||
var row = $('#tmtable').datagrid('getSelected');
|
||
if (row) {
|
||
$.get('api/question?a=canedit&id='+row.id,function(res){
|
||
if(res.code==1){
|
||
opendg('编辑题目','html/question/edit/'+row.id)
|
||
}
|
||
else{
|
||
$.messager.alert('提示', '非自建题目不可编辑!');
|
||
}
|
||
})
|
||
|
||
}
|
||
else {
|
||
$.messager.alert('提示', '请选择一道题目!');
|
||
}
|
||
}
|
||
function searchTm() {
|
||
var querydata = $('#searchtmff').serializeJSON();
|
||
querydata['a'] = 'listall'
|
||
querydata['tmlx'] = ''
|
||
$('#tmtable').datagrid('options').queryParams = querydata
|
||
$('#tmtable').datagrid('reload');
|
||
}
|
||
function confirmfz() {
|
||
var rows = $('#tmtable').datagrid('getSelections');
|
||
if(rows.length>0){
|
||
var data = $('#fztmff').serializeJSON();
|
||
var ids = []
|
||
for(var i=0;i<rows.length;i++){
|
||
ids.push(rows[i].id)
|
||
}
|
||
data['ids'] = ids
|
||
$.ajax({
|
||
type: "POST",
|
||
url: 'api/question?a=copy',
|
||
data: JSON.stringify(data),
|
||
datatype: "json",
|
||
processData: false,
|
||
contentType: "application/json;charset=utf-8",
|
||
beforeSend: function () {
|
||
var bo = $('#fztmff').form('validate')
|
||
if (bo == false) {
|
||
return bo
|
||
} else {
|
||
$('#confirmfzb').linkbutton('disable');
|
||
}
|
||
},
|
||
success: function (data) {
|
||
if (data.code == 1) {
|
||
$.messager.show({
|
||
title:'复制成功',
|
||
msg:'成功复制'+rows.length+'道题,'+'可在自建分类下查看',
|
||
timeout:5000,
|
||
showType:'slide'
|
||
});
|
||
$("#fztmdg").dialog("close");
|
||
} else { $.messager.alert('提示', '失败!'); }
|
||
$('#confirmfzb').linkbutton('enable');
|
||
},
|
||
complete:function(){
|
||
$('#confirmfzb').linkbutton('enable');
|
||
}
|
||
});
|
||
}else{
|
||
$.messager.alert('','未选择题目');
|
||
}
|
||
}
|
||
function reset() {
|
||
$('#searchtmff').form('clear')
|
||
$('#tmtable').datagrid('options').queryParams = {
|
||
a:'listall'
|
||
}
|
||
$('#tmtable').datagrid('reload');
|
||
}
|
||
document.getElementById('drfile').onchange = function () {
|
||
var fileObj = this.files[0];
|
||
var url = 'drapi?a=question'
|
||
var form = new FormData();
|
||
form.append("upfile", fileObj); // 文件对象
|
||
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
|
||
xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
|
||
xhr.send(form)
|
||
$('#drtmdg').dialog('close')
|
||
loading('导入中。。');
|
||
xhr.onload = function (evt) { //服务断接收完文件返回的结果
|
||
var data = JSON.parse(evt.target.responseText);
|
||
removeLoading();
|
||
if (data.code == 1) {
|
||
$.messager.alert('提示', '上传成功!', 'info', function () {
|
||
$("#main").panel({ href: 'html/question', title: '题库管理' });
|
||
});
|
||
}
|
||
else if (data.code == 2) {
|
||
msg = ''
|
||
msg += '因重复部分未成功'
|
||
$.messager.alert('提示', msg, 'info', function () {
|
||
$("#main").panel({ href: 'html/question', title: '题库管理' });
|
||
});
|
||
}
|
||
else {
|
||
$.messager.alert('提示', '失败!文件内容有误');
|
||
}
|
||
document.getElementById('drfile').value = '';
|
||
|
||
}; //请求完成
|
||
xhr.onerror = function (evt) { $.messager.alert('提示', '失败!文件内容有误'); document.getElementById('drfile').value = ''; }; //请求失败
|
||
}
|
||
function exportquestionexcel(){
|
||
var data = $('#tmtable').datagrid('getData');
|
||
var datalist = data.rows;
|
||
|
||
var datalist_ = []
|
||
for (var j = 0, len = datalist.length; j < len; j++) {
|
||
var dic = datalist[j]
|
||
var i = {}
|
||
i["题目"] = dic.title
|
||
i["分类"] = dic.questioncat__name
|
||
i["题型"] = '单选'
|
||
if(dic.type==2){
|
||
i["题型"] = '多选'
|
||
}
|
||
else if(dic.type==3){
|
||
i["题型"] = '判断'
|
||
}
|
||
i['选项A'] = ''
|
||
i['选项B'] = ''
|
||
i['选项C'] = ''
|
||
i['选项D'] = ''
|
||
i['选项E'] = ''
|
||
i['选项F'] = ''
|
||
if(dic.answer.A){
|
||
i['选项A'] = dic.answer.A
|
||
}
|
||
if(dic.answer.B){
|
||
i['选项B'] = dic.answer.B
|
||
}
|
||
if(dic.answer.C){
|
||
i['选项C'] = dic.answer.C
|
||
}
|
||
if(dic.answer.D){
|
||
i['选项D'] = dic.answer.D
|
||
}
|
||
if(dic.answer.E){
|
||
i['选项E'] = dic.answer.E
|
||
}
|
||
if(dic.answer.F){
|
||
i['选项F'] = dic.answer.F
|
||
}
|
||
i['正确答案'] = dic.right
|
||
datalist_.push(i)
|
||
}
|
||
JSONToCSVConvertor(JSON.stringify(datalist_), "题目列表", true);
|
||
}
|
||
</script> |