试题管理

beetlsql3-dev
姚丹ab 2 years ago
parent 895c5d340a
commit fa4f3037fb

@ -1,163 +1,169 @@
layui.define([ 'form', 'laydate', 'table' ], function(exports) {
layui.define(['form', 'laydate', 'table'], function (exports) {
var form = layui.form;
var laydate = layui.laydate;
var table = layui.table;
var resourcesQuestionTable = null;
var view ={
init:function(){
var view = {
init: function () {
this.initTable();
this.initSearchForm();
this.initToolBar();
window.dataReload = function(){
Lib.doSearchForm($("#searchForm"),resourcesQuestionTable)
window.dataReload = function () {
Lib.doSearchForm($("#searchForm"), resourcesQuestionTable)
}
},
initTable:function(){
initTable: function () {
resourcesQuestionTable = table.render({
elem : '#resourcesQuestionTable',
height : Lib.getTableHeight(),
elem: '#resourcesQuestionTable',
height: Lib.getTableHeight(),
cellMinWidth: 100,
method : 'post',
even:true,
size:"lg",
url : Common.ctxPath + '/jlw/resourcesQuestion/list.json' // 数据接口
,page : Lib.tablePage // 开启分页
,limit : 10,
cols : [ [ // 表头
method: 'post',
even: true,
size: "lg",
url: Common.ctxPath + '/jlw/resourcesQuestion/list.json' // 数据接口
, page: Lib.tablePage // 开启分页
, limit: 10,
cols: [[ // 表头
{
type : 'checkbox',align:"center"
type: 'checkbox', align: "center"
},
{
field : 'questionStem',
title : '题干',align:"center"
},
{
field : 'questionType',align:"center",width:150,
title : '题型', templet: function (d) {//(1单选 2多选 3判断)
return d.questionType == 1?'单选':d.questionType == 2?'多选':d.questionType == 3?'判断':'-';
}
},
{
field : 'courseInfoParentName',width:200,
title : '归属课程',align:"center"
},
{
field : 'courseInfoName',width:200,
title : '归属章节',align:"center"
},
{
field : 'questionStatus',width:200,
title : '状态',align:"center", templet(d) {
return d.questionStatus === 1
? `<span class="layui-badge layui-bg-green" style="background-color: #c0e7dd !important; color: #30b08f!important">上架</span>`
: '<span class="layui-badge layui-bg-gray" style="background-color: #dadada !important; color: #6c6c6c!important">下架</span>'}
},
{
field : 'userId',title : '操作',align:"center",width:260, templet: function (d) {
// TODO 上下架前端逻辑待开发
return `
<button type="button" class="layui-btn layui-btn-xs" lay-event="up" data-item="${JSON.stringify(d)}" style="background-color: #30b08f !important; color: #ffffff!important">上架</button>
<button type="button" class="layui-btn layui-btn-xs" lay-event="down" data-item="${JSON.stringify(d)}" style="background-color: #bebebe !important; color: #ffffff!important">下架</button>
<button type="button" class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>
<button type="button" class="layui-btn layui-btn-xs" lay-event="del">删除</button>
`;
{
field: 'questionStem', width: 320,
title: '题干', align: "center"
},
{
field: 'questionType', align: "center", width: 80,
title: '题型', templet: function (d) {//(1单选 2多选 3判断)
return d.questionType == 1 ? '单选' : d.questionType == 2 ? '多选' : d.questionType == 3 ? '判断' : '-';
}
},
{
field: 'courseInfoParentName',
title: '归属课程', align: "center"
},
{
field: 'courseInfoName',
title: '归属章节', align: "center"
},
{
field: 'undefinedYD',
title: '上传院校', align: "center"
},
{
field: 'questionStatus', width: 80,
title: '状态', align: "center", templet: function (d) {
return d.questionStatus === 1
? '<span class="layui-badge layui-bg-green" style="background-color: #abd5ff !important; color: #088eed!important">已上架</span>'
: '<span class="layui-badge layui-bg-gray" style="background-color: #dadada !important; color: #6c6c6c!important">已下架</span>'
}
},
{
field: 'userId', title: '操作', align: "center", width: 220, templet: function (d) {
// TODO 上下架前端逻辑待开发
return '<a class="layui-table-link" lay-event="up" data-item="${JSON.stringify(d)}" >上架</a>\n' +
'<a class="layui-table-link" lay-event="down" data-item="${JSON.stringify(d)}" style="color: #bebebe!important">下架</a>\n' +
'<a class="layui-table-link" lay-event="edit">编辑</a>\n' +
'<a class="layui-table-link" lay-event="del">删除</a>';
}
}
}
] ]
]]
});
});
table.on('checkbox(resourcesQuestionTable)', function(obj){
table.on('checkbox(resourcesQuestionTable)', function (obj) {
var resourcesQuestion = obj.data;
if(obj.checked){
if (obj.checked) {
//按钮逻辑Lib.buttonEnable()
}else{
} else {
}
})
},
initSearchForm:function(){
Lib.initSearchForm( $("#searchForm"),resourcesQuestionTable,form);
initSearchForm: function () {
Lib.initSearchForm($("#searchForm"), resourcesQuestionTable, form);
},
initToolBar:function(){
initToolBar: function () {
toolbar = {
add : function() { // 获取选中数据
add: function () { // 获取选中数据
var url = "/jlw/resourcesQuestion/add.do";
Common.openDlg(url,"题库管理/新增题目");
Common.openDlg(url, "题库管理/新增题目");
},
refresh: function () {//刷新
searchForm.reset();
Lib.doSearchForm($("#searchForm"), resourcesQuestionTable, 1);
},
up: function() {
up: function () {
alert('up')
},
down: function() {
down: function () {
alert('down')
},
search:function () {
search: function () {
Lib.doSearchForm($("#searchForm"), resourcesQuestionTable, 1);
},import:function (){
}, import: function () {
var url = "/jlw/resourcesQuestion/importPage.do";
Common.openDlg(url,"");
},allDel:function (){
Common.openDlg(url, "");
}, allDel: function () {
var checkStatus = table.checkStatus('resourcesQuestionTable').data;
if(checkStatus.length <= 0){
if (checkStatus.length <= 0) {
layer.msg("请选择需要删除的题目!", {
offset: ['50%'],
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
return ;
return;
}
var ids = "";
for(var i = 0; i < checkStatus.length;i++){
for (var i = 0; i < checkStatus.length; i++) {
ids += checkStatus[i].resourcesQuestionId;
if(i < checkStatus.length - 1){
if (i < checkStatus.length - 1) {
ids += ",";
}
}
allDelete(ids);
},chapter:function (){ //批量章节调整
}, chapter: function () { //批量章节调整
$("select[name='courseInfoIds_1'],select[name='courseInfoIds_2']").val("");
$("select[name='courseInfoId_1'],select[name='courseInfoId_2']").html("<option value=\"\">请选择</option>");
form.render();
layer.open({
type: 1,
offset: 'auto',
title:'批量章节调整',
shadeClose:'true',
title: '批量章节调整',
shadeClose: 'true',
area: ['800px', '300px'],
scrollbar:'false',
scrollbar: 'false',
btnAlign: 'c',
content: $("#chapter_dialog"),
btn: ['确定', '取消'],
yes: function(index,layero){
yes: function (index, layero) {
var oldCourseInfoId = $("#chapter_dialog select[name='courseInfoId_1']").val(),
newCourseInfoId= $("#chapter_dialog select[name='courseInfoId_2']").val();
if($.isEmpty(oldCourseInfoId)){
newCourseInfoId = $("#chapter_dialog select[name='courseInfoId_2']").val();
if ($.isEmpty(oldCourseInfoId)) {
layer.msg("请选择题目来源章节!", {
offset: ['50%'],
icon: 2,
time: 1500 //2秒关闭如果不配置默认是3秒
});
return ;
return;
}
if($.isEmpty(newCourseInfoId)){
if ($.isEmpty(newCourseInfoId)) {
layer.msg("请选择题去向源章节!", {
offset: ['50%'],
icon: 2,
time: 1500 //2秒关闭如果不配置默认是3秒
});
return ;
return;
}
layer.confirm('是否确定调整该章节信息?', function (index1) {
layer.close(index1);
layer.load(3);
setTimeout(function (){
var ret = Common.postAjax("/jlw/resourcesQuestion/changAll.json",{oldCourseInfoId:oldCourseInfoId,newCourseInfoId:newCourseInfoId})
setTimeout(function () {
var ret = Common.postAjax("/jlw/resourcesQuestion/changAll.json", {
oldCourseInfoId: oldCourseInfoId,
newCourseInfoId: newCourseInfoId
})
layer.closeAll("loading");
layer.msg(ret.msg, {
offset: ['50%'],
@ -169,29 +175,33 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) {
Lib.tableRefresh();
}
});
},200);
}, 200);
});
}
});
}
};
$('.ext-toolbar').on('click', function() {
};
$('.ext-toolbar').on('click', function () {
var type = $(this).data('type');
toolbar[type] ? toolbar[type].call(this) : '';
});
}, initTableTool: table.on('tool(resourcesQuestionTable)', function (obj) {
var data = obj.data;
if (obj.event === 'edit') {
var url = "/jlw/resourcesQuestion/add.do?resourcesQuestionId="+data.resourcesQuestionId;
Common.openDlg(url,"题库管理/编辑题目");
}else if(obj.event === "del"){
var url = "/jlw/resourcesQuestion/add.do?resourcesQuestionId=" + data.resourcesQuestionId;
Common.openDlg(url, "题库管理/编辑题目");
} else if (obj.event === "del") {
allDelete(data.resourcesQuestionId);
} else if (obj.event === "up") {
alert('up')
} else if (obj.event === "down") {
alert('down')
}
})
}
//删除
function allDelete(ids){
function allDelete(ids) {
layer.confirm('是否确定删除该信息?', function (index) {
var ret = Common.postAjax("/jlw/resourcesQuestion/delete.json", {ids: ids});
layer.msg(ret.code == 0 ? "删除成功!" : ret.msg, {
@ -208,14 +218,14 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) {
//选择归属课程 并且根据选择的课程查询章节 resourcesQuestionIdsIsNotNull:查询题目不为空的章节
form.on('select(select_courseInfoIds)', function (obj) {
Lib.getCourseInfo($("select[name='courseInfoId_1']"),obj.value,1);
Lib.getCourseInfo($("select[name='courseInfoId_1']"), obj.value, 1);
});
//选择归属课程 并且根据选择的课程查询章节
form.on('select(select_courseInfoIds_)', function (obj) {
Lib.getCourseInfo($("select[name='courseInfoId_2']"),obj.value);
Lib.getCourseInfo($("select[name='courseInfoId_2']"), obj.value);
});
exports('index',view);
exports('index', view);
});

@ -2,7 +2,7 @@
<link rel="stylesheet" type="text/css" href="${ctxPath}/css/plugin.css?v=${jsVer}" media="all"/>
<form class="layui-form" id="addForm">
<div>
<layui:submitButtons id="addButton" buttonType="" />
<layui:submitButtons id="addButton" buttonType=""/>
</div>
<div class="layui-row">
<div class="layui-form-item">
@ -17,7 +17,7 @@
<label class="layui-form-label">批量导入模板下载:</label>
<div class="layui-form-mid layui-word-aux">
<a href="${ctxPath}/jlw/resourcesQuestion/downloadTemplate.json">
<i class="iconfont" style="font-size: 30px;color: #2469f5;">&#xe6f6;</i>
<i class="iconfont" style="font-size: 30px;color: #2469f5;">&#xebc7;</i>下载模板
</a>
</div>
</div>
@ -25,7 +25,7 @@
<label class="layui-form-label">上传批量导入文件:</label>
<div class="layui-form-mid layui-word-aux">
<a id="importTemplate" style="cursor: pointer;">
<i class="iconfont" style="font-size: 30px;color: #73a2f8;">&#xe60e;</i>
<i class="iconfont" style="font-size: 40px;">&#xebb8;</i>
</a>
</div>
</div>
@ -48,10 +48,10 @@
<tr style="background-color: #e3e3e3;">
<th style="text-align: center;">序号</th>
<th>提示信息</th>
<!-- <th style="text-align: center;border-left:1px solid #dddddd;">操作</th>-->
<!-- <th style="text-align: center;border-left:1px solid #dddddd;">操作</th>-->
</tr>
</thead>
<tbody id="view" >
<tbody id="view">
</tbody>
</table>
</form>
@ -60,25 +60,25 @@
<tr>
<td style="text-align: center;">{{index + 1}}</td>
<td>{{item[0]}}</td>
<!-- <td style="text-align: center;">-->
<!-- {{#if(item.length ==2){}}-->
<!-- <a resourcesQuestionId="{{item[1]}}" class="layui-btn layui-btn-sm bg_button del">删除</a>-->
<!-- {{#}}}-->
<!-- </td>-->
<!-- <td style="text-align: center;">-->
<!-- {{#if(item.length ==2){}}-->
<!-- <a resourcesQuestionId="{{item[1]}}" class="layui-btn layui-btn-sm bg_button del">删除</a>-->
<!-- {{#}}}-->
<!-- </td>-->
</tr>
{{# }); }}
</script>
<!--#} -->
<script>
layui.use(['upload'], function(){
layui.use(['upload'], function () {
var upload = layui.upload;
var laytpl = layui.laytpl;
var resourcesQuestionLocal = localStorage.getItem("resourcesQuestionLocal"); //取出上次导入出现错误的数据
if(!$.isEmpty(resourcesQuestionLocal)){
if (!$.isEmpty(resourcesQuestionLocal)) {
var getTpl = demo.innerHTML
,view = document.getElementById('view');
laytpl(getTpl).render({list:JSON.parse(resourcesQuestionLocal)}, function(html){
, view = document.getElementById('view');
laytpl(getTpl).render({list: JSON.parse(resourcesQuestionLocal)}, function (html) {
view.innerHTML = html;
$(".del").click(deleteInfo);
});
@ -89,8 +89,7 @@
url: Common.ctxPath + "/jlw/resourcesQuestion/importTemplate.json",
size: 5120,
accept: 'file',
data: {
},
data: {},
before: function (obj) { //上传前
layer.load();
},
@ -100,8 +99,8 @@
localStorage.setItem("resourcesQuestionLocal", JSON.stringify(res.data)); //存入本次导入出现错误的数据
layer.msg(res.msg, {icon: 1});
var getTpl = demo.innerHTML
,view = document.getElementById('view');
laytpl(getTpl).render({list:res.data}, function(html){
, view = document.getElementById('view');
laytpl(getTpl).render({list: res.data}, function (html) {
view.innerHTML = html;
$(".del").click(deleteInfo);
});
@ -115,7 +114,7 @@
});
//删除数据
function deleteInfo(){
function deleteInfo() {
layer.confirm('是否确定删除该信息?', function (index) {
var resourcesQuestionId = $(this).attr("resourcesQuestionId");
var ret = Common.postAjax("/jlw/resourcesQuestion/delete.json", {ids: resourcesQuestionId});
@ -127,11 +126,11 @@
});
}
$("#addButton").click(function(){
$("#addButton").click(function () {
});
$("#addButton-cancel").click(function(){
$("#addButton-cancel").click(function () {
Lib.closeFrame();
});
});

@ -1,27 +1,51 @@
<!--#layout("/common/layout.html",{"jsBase":"/js/jlw/resourcesQuestion/"}){ -->
<style>
.layui-laypage .layui-laypage-curr .layui-laypage-em,button{
background-color: #73a2f8 !important;
}
/* 分页确定按钮*/
.layui-laypage-btn{
color: white!important;
.layui-laypage-btn {
color: white !important;
}
.layui-layer-page .layui-layer-content {
position: relative;
overflow: visible !important;
}
.layui-table a {
margin-right: 10px;
}
</style>
<layui:searchForm formId="searchForm" searchList="" condition="${search}">
<div class="layui-inline">
<label class="layui-form-label">课程筛选</label>
<div class="layui-input-inline">
<layui:simpleDictSelect style='layui-input-inline'
type="course_info.course_info_name.course_info_status=1,course_info_type=1,find_in_set(course_label_id,(select group_concat(course_label_id) from course_label where course_label_status = 1))"
id="courseInfoIds" name="courseInfoId_0"
layFilter="select_courseInfoIds"/>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">归属章节:</label>
<div class="layui-input-block">
<layui:simpleDictSelect style='layui-input-inline'
type="course_info.course_info_name.course_info_status=1,course_info_type=2"
id="courseInfoId1" name="courseInfoId_1" layFilter="select_courseInfoIds_"/>
</div>
</div>
</layui:searchForm>
<div class="layui-btn-group">
<layui:accessButton function="resourcesQuestion.query" id="searchFormSearch" action="search"><i class="layui-icon">&#xe615;</i>搜索</layui:accessButton>
<layui:accessButton function="resourcesQuestion.add" action="add"><i class="layui-icon">&#xe61f;</i>新增</layui:accessButton>
<layui:accessButton function="resourcesQuestion.add" action="import">批量导入</layui:accessButton>
<layui:accessButton function="resourcesQuestion.add" action="allDel">批量删除</layui:accessButton>
<layui:accessButton function="resourcesQuestion.add" action="chapter">批量章节调整</layui:accessButton>
<layui:accessButton function="resourcesQuestion.query" action="refresh"><i class="layui-icon">&#xe669;</i>刷新</layui:accessButton>
<!-- <layui:accessButton function="resourcesQuestion.query" id="searchFormSearch" action="search"><i class="layui-icon">&#xe615;</i>搜索</layui:accessButton>-->
<layui:accessButton function="resourcesQuestion.add" action="add"><i class="layui-icon">&#xe61f;</i>新增
</layui:accessButton>
<layui:accessButton function="resourcesQuestion.add" action="import"><i class="iconfont">&#xebc9;</i>批量导入
</layui:accessButton>
<layui:accessButton function="resourcesQuestion.add" action="allDel" class="layui-btn-danger"><i
class="layui-icon">&#xe640;</i>批量删除
</layui:accessButton>
<!-- <layui:accessButton function="resourcesQuestion.add" action="chapter">批量章节调整</layui:accessButton>-->
<layui:accessButton function="resourcesQuestion.query" action="refresh"><i class="layui-icon">&#xe669;</i>刷新
</layui:accessButton>
</div>
<table id="resourcesQuestionTable" lay-filter="resourcesQuestionTable"></table>
@ -35,8 +59,10 @@
<div class="layui-inline">
<label class="layui-form-label">课程:</label>
<div class="layui-input-inline">
<layui:simpleDictSelect style='layui-input-inline' type="course_info.course_info_name.course_info_status=1,course_info_type=1,find_in_set(course_label_id,(select group_concat(course_label_id) from course_label where course_label_status = 1))"
id="courseInfoIds1" name="courseInfoIds_1" layFilter="select_courseInfoIds"/>
<layui:simpleDictSelect style='layui-input-inline'
type="course_info.course_info_name.course_info_status=1,course_info_type=1,find_in_set(course_label_id,(select group_concat(course_label_id) from course_label where course_label_status = 1))"
id="courseInfoIds1" name="courseInfoIds_1"
layFilter="select_courseInfoIds"/>
</div>
</div>
</div>
@ -60,9 +86,11 @@
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">课程:</label>
<div class="layui-input-inline" >
<layui:simpleDictSelect style='layui-input-inline' type="course_info.course_info_name.course_info_status=1,course_info_type=1,find_in_set(course_label_id,(select group_concat(course_label_id) from course_label where course_label_status = 1))"
id="courseInfoIds" name="courseInfoIds_2" layFilter="select_courseInfoIds_"/>
<div class="layui-input-inline">
<layui:simpleDictSelect style='layui-input-inline'
type="course_info.course_info_name.course_info_status=1,course_info_type=1,find_in_set(course_label_id,(select group_concat(course_label_id) from course_label where course_label_status = 1))"
id="courseInfoIds" name="courseInfoIds_2"
layFilter="select_courseInfoIds_"/>
</div>
</div>
</div>
@ -85,9 +113,9 @@
<!--#} -->
<script>
layui.use(['index'], function(){
var index = layui.index;
index.init();
});
layui.use(['index'], function () {
var index = layui.index;
index.init();
});
</script>

Loading…
Cancel
Save