/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:超级管理员 * 日 期:2019-05-14 10:02 * 描 述:选修课课程信息 */ var weekChina = ["一", "二", "三", "四", "五", "六", "日"]; var refreshGirdData; var bootstrap = function ($, learun) { "use strict"; var page = { init: function () { //选课开始后无法进行编辑 //learun.httpAsyncGet(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/IsSelectElectiveLesson', function (result) { // if (result.code == 200) { // } else { // learun.alert.warning("学生选课已开始,合班编辑功能已停用。"); // $('#lr_edit').hide(); // } //}); page.initGird(); page.bind(); page.bindSemesterAndYear(); }, bind: function () { $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { page.search(queryJson); }, 220, 400); // 刷新 $('#lr_refresh').on('click', function () { location.reload(); }); $('#AcademicYearNo').lrselect({ placeholder: "学年", allowSearch: false, url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetAcademicYearNo', value: 'value', text: 'text' }); //学期 $('#Semester').lrselect({ placeholder: "学期", allowSearch: false, url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetSemester', value: 'value', text: 'text' }); $('#LessonName').lrDataSourceSelect({ code: 'LessonInfo', value: 'lessonno', text: 'lessonname' }); //设置选课专业 $('#lr_editMajor').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { var rowdata = $('#gridtable').jfGridGet('rowdata'); //判断选中记录是否可以批量管理专业 $.ajax({ url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/IsBatchEditMajor', data: { data: JSON.stringify(rowdata) }, type: "post", dataType: "json", async: false, cache: false, success: function (data) { if (data.data == true) { learun.layerForm({ id: 'formmajor', title: '管理选课专业', url: top.$.rootUrl + '/EducationalAdministration/ElectiveMajor/Index?OLPOEId=' + keyValue, width: 1000, height: 700, //btn: null callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } else { return learun.alert.warning('只有同学期同课程支持批量管理专业!'); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { learun.httpErrorLog(textStatus); }, beforeSend: function () { }, complete: function () { } }); } }); //新增 $('#lr_add').on('click', function () { learun.layerForm({ id: 'formadd', title: '新增', url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/FormElective', width: 700, height: 500, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); }); //设置人数 $('#lr_edit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (keyValue.indexOf(",") === -1) { if (learun.checkrow(keyValue)) { //选课开始后无法进行编辑 //learun.httpAsyncGet(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/IsSelectElectiveLesson', function (result) { // if (result.code == 200) { learun.layerForm({ id: 'OpenLessonPlanOfElectiveform', title: '设置人数', url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/Form?keyValue=' + keyValue, width: 600, height: 400, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); // } else { // learun.alert.warning("学生选课已开始,合班编辑功能已停用。"); // $('#lr_edit').hide(); // } //}); } } else { //批量设置 learun.layerForm({ id: 'OpenLessonPlanOfElectiveform', title: '设置人数', url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/FormBatch?keyValue=' + keyValue, width: 400, height: 300, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } }); //查看学生 $('#lr_view').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'form', title: '查看学生', url: top.$.rootUrl + '/EducationalAdministration/StuSelectLessonListOfElective/FinishIndex?OLPEId=' + keyValue, width: 1000, height: 700, btn: null, end: function () { refreshGirdData(); } }); } }); //学生选课次数维护 $('#lr_StuSelectCount').on('click', function () { learun.layerForm({ id: 'StuSelectCountIndex', title: '学生选课次数', url: top.$.rootUrl + '/EducationalAdministration/OLPElectiveStuSelectCount/Index', width: 1000, height: 700, btn: null, end: function () { //refreshGirdData(); } }); }); //审核学生 $('#lr_audit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'form', title: '审核学生', url: top.$.rootUrl + '/EducationalAdministration/StuSelectLessonListOfElective/AuditIndex?OLPEId=' + keyValue, width: 1000, height: 700, btn: null, end: function () { refreshGirdData(); } }); } }); //查看已审学生(预) $('#lr_viewPre').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'form', title: '查看学生', url: top.$.rootUrl + '/EducationalAdministration/StuSelectLessonListOfElectivePre/FinishIndex?OLPEId=' + keyValue, width: 1000, height: 700, btn: null, end: function () { refreshGirdData(); } }); } }); //审核学生(预) $('#lr_auditPre').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'form', title: '审核学生', url: top.$.rootUrl + '/EducationalAdministration/StuSelectLessonListOfElectivePre/AuditIndex?OLPEId=' + keyValue, width: 1000, height: 700, btn: null, end: function () { refreshGirdData(); } }); } }); //编辑 $('#lr_modify').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'OpenLessonPlanOfElectiveModifyForm', title: '编辑', url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/ModifyForm?keyValue=' + keyValue, width: 600, height: 400, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } }); //初始化学生选课记录 $('#lr_initStuSelectLesson').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { //选课专业 var ElectiveMajorList = $('#gridtable').jfGridValue('ElectiveMajorList'); if (ElectiveMajorList.length <= 0) { return learun.alert.warning("请先管理选课专业!"); } learun.layerConfirm('是否确认初始化学生选课记录!', function (res) { if (res) { learun.postForm(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/InitStuSelectLesson', { keyValue: keyValue }, function () { refreshGirdData(); }); } }); } }); //删除 $('#lr_delete').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { var rowdata = $('#gridtable').jfGridGet('rowdata'); try { rowdata.forEach(function (item, index, row) { if (!!item.StuNumMax || !!item.StuNumOfApply || !!item.StuNum) { throw learun.alert.warning("人数上限、已报人数、通过人数大于0的不能删除!"); } if (!!item.ElectiveMajorList && item.ElectiveMajorList.length > 0) { throw learun.alert.warning("已选专业的数据不允许删除!"); } }); learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/DeleteElective', { keyValue: keyValue }, function () { refreshGirdData(); }); } catch (e) { } } }); //设置可选 $('#lr_AllowSelect').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/SetUpIsAllowSelect', { keyValue: keyValue, IsAllowSelect: 1 }, function () { refreshGirdData(); }); } }); //取消可选 $('#lr_CancelSelect').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/SetUpIsAllowSelect', { keyValue: keyValue, IsAllowSelect: 0 }, function () { refreshGirdData(); }); } }); }, bindSemesterAndYear: function () { $.ajax({ url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/GetSemesterAndYear', type: "GET", dataType: "json", async: false, cache: false, success: function (res) { var data = res.data; if (!!data) { $('#AcademicYearNo').lrselectSet(data.AcademicYearShort); var Semester = data.Semester; $('#Semester').lrselectSet(Semester); var param = { "AcademicYearNo": data.AcademicYearShort, "Semester": data.Semester }; page.search(param); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { learun.httpErrorLog(textStatus); }, beforeSend: function () { }, complete: function () { } }); }, // 初始化列表 initGird: function () { $('#gridtable').jfGrid({ url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/GetPageListOfMerge', headData: [ { label: "学年", name: "AcademicYearNo", width: 45, align: "left" }, { label: "学期", name: "Semester", width: 35, align: "left" }, { label: "课程号", name: "LessonNo", width: 100, align: "left" }, //{ // label: "课程名称", name: "LessonNo2", width: 170, align: "left", // formatterAsync: function (callback, value, row, op, $cell) { // learun.clientdata.getAsync('custmerData', { // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'LessonInfo', // key: value, // keyId: 'lessonno', // callback: function (_data) { // callback(_data['lessonname']); // } // }); // } //}, { label: "课程名称", name: "LessonName", width: 170, align: "left" }, { label: "上课节次", name: "LessonSection", width: 100, 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: 150, align: "left" }, { label: "学分", name: "StudyScore", width: 50, align: "left" }, { label: "教师号", name: "EmpNo", width: 75, align: "left" }, { label: "教师姓名", name: "EmpNo2", 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']); } }); } }, { label: "教室", name: "ClassRoomNo", width: 60, 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: 60, align: "left" }, { label: "已报人数", name: "StuNumOfApply", width: 60, align: "left" }, { label: "通过人数", name: "StuNum", width: 60, align: "left" }, { label: "已报人数(预)", name: "StuNumOfApplyPre", width: 80, align: "left" }, { label: "通过人数(预)", name: "StuNumPre", width: 80, align: "left" }, { label: "是否可选", name: "IsAllowSelect", width: 80, align: "left", formatter: function (cellvalue, rowObject) { return cellvalue == 1 ? "" : ""; } }, { label: "是否已选专业", name: "IsElectiveMajor", width: 100, align: "left", formatter: function (cellvalue, row) { if (!!row.ElectiveMajorList && row.ElectiveMajorList.length > 0) { return ""; } else { return ""; } } }, { label: "选课专业", name: "ElectiveMajorList", width: 150, align: "left", formatter: function (cellvalue, row) { var str = ""; if (!!cellvalue && cellvalue.length > 0) { for (var i = 0; i < cellvalue.length; i++) { str += cellvalue[i].Grade + "级" + cellvalue[i].MajorName; if (i != cellvalue.length - 1) { str += ","; } } } return str; } } ], mainId: 'Id', isPage: true, isMultiselect: true, sidx: 'AcademicYearNo DESC, Semester DESC, LessonName ASC', sord: 'desc' }); //page.search(); }, search: function (param) { param = param || {}; $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } }; refreshGirdData = function () { page.search(); }; page.init(); }