/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
* Copyright (c) 2013-2018 北京泉江科技有限公司
* 创建人:超级管理员
* 日 期:2019-05-14 10:02
* 描 述:选课中心
*/
var weekChina = ["一", "二", "三", "四", "五", "六", "日"];
var refreshGirdData;
//点击课程名称
function LessonIntroduction(lessonno) {
var html = "";
top.learun.httpAsyncGet(top.$.rootUrl + '/EducationalAdministration/LessonInfo/GetLessonInfoEntityByLessonNo?lessonNo=' + lessonno, function (result) {
if (result.code == 200) {
if (result.data.Introduction == null) {
top.learun.alert.warning("暂无课程简介。");
return;
}
html = result.data.Introduction;
layer.open({
type: 1,
closeBtn: 2,
title: "课程简介",
area: ['800px', '60%'],
content: html
});
} else {
top.learun.alert.warning("暂无课程简介。");
}
});
}
//点击教师名称
function EmpIntroduction(empno) {
var html = "";
top.learun.httpAsyncGet(top.$.rootUrl + '/EducationalAdministration/EmpInfo/GetEmpInfoEntityByEmpNo?empNo=' + empno, function (result) {
if (result.code == 200) {
if (result.data.resume == null) {
top.learun.alert.warning("暂无教师简介。");
return;
}
html = result.data.resume;
layer.open({
type: 1,
closeBtn: 2,
title: "教师简介",
area: ['800px', '60%'],
content: html
});
} else {
top.learun.alert.warning("暂无教师简介。");
}
});
}
var bootstrap = function ($, learun) {
"use strict";
var page = {
init: function () {
//是否为选课时间
learun.httpAsyncGet(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/IsSelectElectiveLesson', function (result) {
if (result.code == 200) {//选课还未开始
learun.alert.warning("当前时间不是选课时间!");
return;
} else {//选课已经开始
page.initGird();
}
});
page.bind();
},
bind: function () {
$('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
page.search(queryJson);
}, 220, 400);
// 刷新
$('#lr_refresh').on('click', function () {
location.reload();
});
// 报名
$('#lr_apply').on('click', function () {
var keyValue = $('#gridtable').jfGridValue('Id');
if (learun.checkrow(keyValue)) {
learun.layerConfirm('是否确认报名该课程!', function (res) {
if (res) {
//learun.postForm(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/ElectiveLessonApply', { keyValue: keyValue }, function () {
// refreshGirdData();
//});
//模式二:
var _postData = {};
_postData.keyValue = keyValue;
_postData.StuNo = learun.clientdata.get(['userinfo']).enCode;
$.ajax({
url: WebApiUrl + '/Learun/OpenLessonPlanOfElectiveStudent/SignIn',
data: _postData,
type: "POST",
dataType: "json",
async: false,
cache: false,
success: function (res) {
if (res.code == 200) {
learun.loading(true, '正在提交报名数据');
//判断队列结果
var timer = setInterval(function () {
$.ajax({
url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/GetApplyResult',
data: { keyValue: keyValue },
type: "POST",
dataType: "json",
async: false,
cache: false,
success: function (res) {
if (res.code == 200) {
refreshGirdData();
clearInterval(timer);
learun.loading(false);
learun.alert.warning(res.info);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
learun.alert.warning("网络出错,请刷新!");
},
});
}, 5000);
} else {
learun.alert.warning("系统异常,请稍后!");
return false;
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
learun.alert.warning("网络出错,请刷新!");
},
});
}
});
}
});
//取消报名
$('#lr_cancel').on('click', function () {
var keyValue = $('#gridtable').jfGridValue('Id');
if (learun.checkrow(keyValue)) {
learun.layerConfirm('是否确认取消报名该课程!', function (res) {
if (res) {
learun.postForm(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/CancelApply', { keyValue: keyValue }, function () {
refreshGirdData();
});
}
});
}
});
// 报名(预)
$('#lr_applyPre').on('click', function () {
var keyValue = $('#gridtable').jfGridValue('Id');
if (learun.checkrow(keyValue)) {
learun.layerConfirm('是否确认报名该课程!', function (res) {
if (res) {
learun.postForm(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/ElectiveLessonApplyPre', { keyValue: keyValue }, function () {
refreshGirdData();
});
}
});
}
});
//取消报名(预)
$('#lr_cancelPre').on('click', function () {
var keyValue = $('#gridtable').jfGridValue('Id');
if (learun.checkrow(keyValue)) {
learun.layerConfirm('是否确认取消报名该课程!', function (res) {
if (res) {
learun.postForm(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/CancelApplyPre', { keyValue: keyValue }, function () {
refreshGirdData();
});
}
});
}
});
},
// 初始化列表
initGird: function () {
$('#gridtable').jfGrid({
url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/GetPageListOfStudent',
headData: [
{ label: "学年", name: "AcademicYearNo", width: 100, align: "left" },
{ label: "学期", name: "Semester", width: 100, align: "left" },
//{ label: "课程号", name: "LessonNo", width: 100, align: "left" },
{
label: "课程名称", name: "LessonName", width: 200, align: "left",
formatterAsync: function (callback, value, row, op, $cell) {
learun.clientdata.getAsync('custmerData', {
url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'LessonInfo',
key: row.LessonNo,
keyId: 'lessonno',
callback: function (_data) {
//callback(_data['lessonname']);
callback('' + _data['lessonname'] + '');
}
});
}
},
{
label: "课程类型", name: "LessonTypeId", width: 100, align: "left",
formatterAsync: function (callback, value, row, op, $cell) {
console.log(row.LessonTypeId);
learun.clientdata.getAsync('custmerData', {
url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdLessonType',
key: row.LessonTypeId,
keyId: 'ltid',
callback: function (_data) {
callback(_data['lessontypename']);
}
});
}
},
{
label: "上课节次", name: "LessonSection", width: 150, align: "left",
formatter: function (cellvalue, row) {
if (cellvalue.indexOf(',') == -1)
return "星期" + weekChina[cellvalue.slice(0, 1) - 1] + "第" + cellvalue.slice(1) + "节";
else
return "星期" + weekChina[cellvalue.slice(0, 1) - 1] + "第" + cellvalue.slice(1, 2) + "、" + cellvalue.slice(4) + "节";
}
},
{ label: "上课时间", name: "LessonTime", width: 180, align: "left" },
{ label: "学分", name: "StudyScore", width: 80, align: "left" },
{
label: "教师姓名", name: "EmpName", width: 100, align: "left",
formatterAsync: function (callback, value, row, op, $cell) {
learun.clientdata.getAsync('custmerData', {
url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'EmpInfo',
key: row.EmpNo,
keyId: 'empno',
callback: function (_data) {
//callback(_data['empname']);
callback('' + _data['empname'] + '');
}
});
}
},
{
label: "教室名称", name: "ClassRoomNo", width: 100, align: "left",
formatterAsync: function (callback, value, row, op, $cell) {
learun.clientdata.getAsync('custmerData', {
url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'ClassRoomInfo',
key: value,
keyId: 'classroomno',
callback: function (_data) {
callback(_data['classroomname']);
}
});
}
},
{ label: "报名人数上限", name: "StuNumMax", width: 100, align: "left" },
{ label: "已报名人数", name: "StuNumOfApply", width: 100, align: "left" },
{
label: "报名状态", name: "Status", width: 100, align: "left",
formatter: function (cellvalue, row) {
if (cellvalue == 1) {
return '审核中';
} else if (cellvalue == 2) {
return '报名成功';
} else if (cellvalue == 3) {
return '报名失败';
} else {
return '未报名';
}
}
},
{ label: "已报名人数(预)", name: "StuNumOfApplyPre", width: 100, align: "left" },
{
label: "报名状态(预)", name: "StatusPre", width: 100, align: "left",
formatter: function (cellvalue, row) {
if (cellvalue == 1) {
return '审核中';
} else if (cellvalue == 2) {
return '报名成功';
} else if (cellvalue == 3) {
return '报名失败';
} else {
return '未报名';
}
}
},
],
mainId: 'Id',
isPage: true,
sidx: 'AcademicYearNo,Semester',
sord: 'desc'
});
page.search();
},
search: function (param) {
param = param || {};
param.StuNo = learun.clientdata.get(['userinfo']).enCode;
param.StuMajorNo = StuMajorNo;
param.StuGrade = StuGrade;
$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
}
};
refreshGirdData = function () {
page.search();
};
page.init();
}