safesite/safesite/templates/question.html

240 lines
9.2 KiB
HTML

<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'west',split:true,border:false" style="width:240px;height:100%;">
<div id="mrfl" height="40%" title="默认分类">
<ul id="mrfltree" data-options="animate:true,toolbar:'#mrflbar'"></ul>
</div>
<!-- <div id="gwfl" height="30%"></div> -->
<div id="zjfl" height="60%" title="自建分类">
<div id="zjflbar" style="padding:5px;height:auto">
<a id="addtmfl2" onclick="javascript:opendg('新建分类','html/questioncat/add')" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">新增</a>
<a id="edittmfl2" onclick="edittmfl2()" class="easyui-linkbutton" data-options="iconCls:'fa-pencil',plain:true">编辑</a>
<a id="deltmfl2" onclick="deltmfl2()" class="easyui-linkbutton" data-options="iconCls:'fa-trash',plain:true">删除</a>
</div>
<ul id="zjfltree" data-options="animate:true,toolbar:'#zjflbar'"></ul>
</div>
</div>
<div data-options="region:'center',title:'题目',split:true,border:false" style="height:100%;">
<div id="tmbar" style="padding:5px;height:auto">
<a id="addtm" onclick="javascript:opendg('新增单选','html/question/add')" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">单选题</a>
<a onclick="javascript:opendg('新增多选','html/question/add2')" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">多选题</a>
<a onclick="javascript:opendg('新增判断','html/question/add3')" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">判断题</a>
<a id="edittm" onclick="edittm()" class="easyui-linkbutton"
data-options="iconCls:'fa-pencil',plain:true">编辑</a>
<a id="deltm" onclick="deltm()" class="easyui-linkbutton"
data-options="iconCls:'fa-trash',plain:true">删除</a>
<!-- <a id="drtms" onclick="javascript:$('#drtmdg').dialog('open').window('center');" class="easyui-linkbutton"
data-options="iconCls:'fa-upload',plain:true">导入试题</a> -->
</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>
<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 += '&nbsp;<span style=\'color:blue\'>(' + node.children.length + ')</span>';
}
return s;
},
onSelect: function (row) {
$("#tmtable").datagrid({
url: 'api/question?a=listall&tmlx=' + row.id,
});
}
});
$('#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 += '&nbsp;<span style=\'color:blue\'>(' + node.children.length + ')</span>';
}
return s;
},
onSelect: function (row) {
$("#tmtable").datagrid({
url: 'api/question?a=listall&tmlx=' + row.id,
});
}
});
$('#gwfl').datagrid({
url: 'grouphandle?a=list',
rownumbers: true,
singleSelect: true,
striped: true,
method: 'get',
border:false,
title:'按岗位',
columns: [[
{ field: 'groupid', title: '用户组ID', hidden: true },
{ field: 'groupname', title: '名称', width: 100 },
{ field: 'grouptype', title: '类型', hidden:true,width: 100 },
]],
onClickRow: function (index, row) {
$("#tmtable").datagrid({
url: 'api/question?a=listall&gwlx=' + row.groupid,
});
}
});
$('#tmtable').datagrid({
url:'api/question?a=listall',
rownumbers: true,
singleSelect: true,
striped: true,
method: 'get',
toolbar: '#tmbar',
pagination: 'true',
pageSize: 20,
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ 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 deltm() {
var row = $('#tmtable').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定删除吗?', function (r) {
if (r) {
$.ajax({
type: "GET",
url: 'api/question?a=del&id=' + row.id,
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('提示', '请选择一道题目!');
}
}
</script>