@ -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" > 上架 < / b u t t o n >
< 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" > 下架 < / b u t t o n >
< button type = "button" class = "layui-btn layui-btn-xs" lay - event = "edit" > 编辑 < / b u t t o n >
< button type = "button" class = "layui-btn layui-btn-xs" lay - event = "del" > 删除 < / b u t t o n >
` ;
{
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 ) ;
} ) ;