You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
234 lines
9.0 KiB
JavaScript
234 lines
9.0 KiB
JavaScript
layui.define(['laydate', 'form', 'laydate', 'table','generalQuestionSettingApi','laytpl'], function(exports) {
|
|
var form = layui.form;
|
|
var generalQuestionSettingApi = layui.generalQuestionSettingApi;
|
|
var index = layui.index;
|
|
var laydate= layui.laydate;
|
|
var table = layui.table;
|
|
var laytpl = layui.laytpl;
|
|
var questionTypeGroupInfoTable = null;
|
|
var resourcesQuestionTable =null;
|
|
var resourcesQuestionTable1 = null;
|
|
var classData = Common.getAjax('/jlw/schoolClass/getValues.json').data;//上课班级多选框data
|
|
|
|
var xmSeValue = $("#generalQuestionSettingSchoolClassIds").data('value');
|
|
var courseInfoIds = '';
|
|
|
|
var xmSeInitValue = [];
|
|
if(!$.isEmpty(xmSeValue)){
|
|
if(xmSeValue.toString().indexOf(",")>=0){
|
|
xmSeValue.split(',').forEach(function (value) {
|
|
xmSeInitValue.push(parseInt(value))
|
|
});
|
|
}else {
|
|
xmSeInitValue.push(xmSeValue)
|
|
}
|
|
}
|
|
|
|
/*班级下拉多选*/
|
|
var xmClassIds = xmSelect.render({
|
|
el: '#generalQuestionSettingSchoolClassIds',
|
|
name: 'generalQuestionSettingSchoolClassIds',
|
|
toolbar: {
|
|
show: true,
|
|
},
|
|
filterable: true,
|
|
pageSize: 3,
|
|
data: classData,
|
|
initValue: xmSeInitValue,//xxxx为你当前的value值
|
|
prop: { // 也许你的数据库返回的并不是name和value, 也许你提交的时候不止name和value, 怎么办? 自定义就行
|
|
name: 'className',
|
|
value: 'classId'
|
|
},
|
|
});
|
|
|
|
if (!$.isEmpty(xmSeValue)) {
|
|
if (xmSeValue === "ALL") {
|
|
xmClassIds.setValue(classData)
|
|
}
|
|
}
|
|
//日期时间范围
|
|
laydate.render({
|
|
elem: '#generalQuestionStartTime'
|
|
,type: 'date'
|
|
, range: "~"
|
|
, rigger: 'click'
|
|
});
|
|
|
|
$('#manualProblemSetting').click(function () {//手动出题
|
|
courseInfoIds = $("#courseInfoIds").find("option:selected").val();
|
|
if ($.isEmpty(courseInfoIds)) {
|
|
Common.info("请选择需要设置的课程");
|
|
return;
|
|
}
|
|
layer.open({
|
|
type: 1
|
|
, title: '选择题库>归属课程:'+'<span style="color: red;border: 2px solid red;border-radius: 5px;">'+$("#courseInfoIds").find("option:selected").text()+'</span>'
|
|
,fixed:false//固定页面后,弹出框随着滚动
|
|
, shadeClose: true
|
|
, scrollbar: true//滚动条
|
|
, content: $("#resourcesQuestionTable_demo")
|
|
, btn: ['保存', '关闭']
|
|
,success:function () {
|
|
resourcesQuestionTable();
|
|
Lib.getCourseInfo($("select[name='courseInfoId_1']"), courseInfoIds);
|
|
}
|
|
, yes: function (index, layero) {
|
|
layer.close(index);
|
|
$('#resourcesQuestionTable_demo').hide();
|
|
}
|
|
, btn2: function (index, layero) {
|
|
$('#resourcesQuestionTable_demo').hide();
|
|
layer.close(index);
|
|
}
|
|
, end: function () {
|
|
$('#resourcesQuestionTable_demo').hide();
|
|
}
|
|
});
|
|
});
|
|
$('#randomlySetQuestions').click(function () {
|
|
console.log("dianj")
|
|
});
|
|
$("#del").click(function () {
|
|
|
|
});
|
|
var view = {
|
|
init:function(){
|
|
this.initTable();
|
|
this.initSearchForm();
|
|
Lib.initGenrealForm($("#addForm"),form);
|
|
this.initSubmit();
|
|
},
|
|
initTable: function () {
|
|
questionTypeGroupInfoTable = table.render({
|
|
elem: '#questionTypeGroupInfoTable',
|
|
cellMinWidth: 100,
|
|
method: 'post',
|
|
url: Common.ctxPath + '/jlw/resourcesQuestion/questionTypeGroupInfo.json' // 数据接口
|
|
, limit: Number.MAX_VALUE
|
|
, page: false
|
|
/*,toolbar: '#toolbar_generalQuestionSetting' //自定义头部左侧工具栏
|
|
,defaultToolbar: ['filter', 'print', 'exports'] //头部右侧工具栏*/
|
|
//, limit: 10,
|
|
,totalRow: true
|
|
,cols: [[ // 表头
|
|
{
|
|
field: 'questionTypeText',
|
|
title: '题型',
|
|
align: "center",
|
|
fixed: 'left',
|
|
totalRowText: '总计',
|
|
rowspan:4
|
|
},
|
|
{
|
|
field: 'totalCount',
|
|
title: '总数量',
|
|
align: "center",
|
|
},
|
|
{
|
|
field: 'questionNum',
|
|
title: '选题量',
|
|
align: "center",
|
|
totalRow:true
|
|
},
|
|
{
|
|
field: 'questionScore',
|
|
title: '分值',
|
|
align: "center",
|
|
totalRow: true
|
|
},
|
|
{
|
|
field: 'questionTotal',
|
|
title: '合计',
|
|
align: "center",
|
|
totalRow: true
|
|
}
|
|
]]
|
|
|
|
});
|
|
resourcesQuestionTable= function(){
|
|
resourcesQuestionTable1=table.render({
|
|
elem: '#resourcesQuestionTable',
|
|
cellMinWidth: 100,
|
|
method: 'post',
|
|
even: true,
|
|
size: "sms",
|
|
url: Common.ctxPath + '/jlw/resourcesQuestion/list.json' // 数据接口
|
|
, page: Lib.tablePage // 开启分页
|
|
, limit: 4
|
|
, where: {"courseInfoId": courseInfoIds},
|
|
cols: [[ // 表头
|
|
{
|
|
type: 'checkbox', align: "center"
|
|
},
|
|
{
|
|
field: 'questionStem', width: 320,
|
|
title: '题干', align: "center"
|
|
},
|
|
{
|
|
field: 'questionType', align: "center", width: 80,
|
|
title: '题型', templet: function (d) {//(1单选 2多选 3判断 4填空 5分析)
|
|
return d.questionType == 1 ? '单选' : d.questionType == 2 ? '多选' : d.questionType == 3 ? '判断' : '-';
|
|
}
|
|
},
|
|
{
|
|
field: 'courseInfoParentName',
|
|
title: '归属课程', align: "center"
|
|
},
|
|
{
|
|
field: 'courseInfoName',
|
|
title: '归属章节', align: "center"
|
|
}
|
|
]]
|
|
|
|
});
|
|
}
|
|
},
|
|
initSearchForm: function () {
|
|
var btn = $("#searchFormQuestion");
|
|
btn.on('click', function () {
|
|
resourcesQuestionTable1.reload({
|
|
where: {
|
|
'courseInfoParentId':courseInfoIds,
|
|
'courseInfoId':$("#resourcesQuestionTable_demo select[name='courseInfoId_1']").find("option:selected").val(),
|
|
"questionStem":$("#resourcesQuestionTable_demo input[name='generalQuestionSettingName']").val(),
|
|
'questionType':$("#resourcesQuestionTable_demo select[name='questionType']").find("option:selected").val()
|
|
},
|
|
});
|
|
});
|
|
form.on('select(select_courseInfoIds)', function (data) {
|
|
courseInfoIds = data.value;
|
|
questionTypeGroupInfoTable.reload({
|
|
where: {"courseId": data.value},
|
|
});
|
|
});
|
|
},
|
|
initSubmit:function(){
|
|
$("#addButton").click(function(){
|
|
form.on('submit(form)', function(){
|
|
var generalQuestionSettingId = $("#addForm input[name='generalQuestionSettingId']").val();
|
|
if(!$.isEmpty(generalQuestionSettingId)){
|
|
generalQuestionSettingApi.updateGeneralQuestionSetting($('#addForm'),function(){
|
|
parent.window.dataReload();
|
|
Common.info("更新成功");
|
|
Lib.closeFrame();
|
|
});
|
|
}else{
|
|
generalQuestionSettingApi.addGeneralQuestionSetting($('#addForm'),function(){
|
|
parent.window.dataReload();
|
|
Common.info("添加成功");
|
|
Lib.closeFrame();
|
|
});
|
|
}
|
|
|
|
});
|
|
});
|
|
|
|
$("#addButton-cancel").click(function(){
|
|
Lib.closeFrame();
|
|
});
|
|
}
|
|
|
|
}
|
|
exports('add',view);
|
|
});
|