/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:超级管理员 * 日 期:2019-09-26 10:47 * 描 述:教学调度 */ var acceptClick; var keyValue = request('keyValue'); // 设置权限 var setAuthorize; // 设置表单数据 var setFormData; // 验证数据是否填写完整 var validForm; // 保存数据 var save; //绑定原课程安排 var bindData; //绑定新课程安排 var bindDataNew; var bootstrap = function ($, learun) { "use strict"; // 设置权限 setAuthorize = function (data) { }; var page = { init: function () { $('.lr-form-wrap').lrscroll(); page.bindSelect(); page.bind(); page.initData(); }, query: function () { var p = {}; //p.F_SchoolId = $('#F_SchoolId').lrselectGet(); p.AcademicYearNo = $('#AcademicYearNo').lrselectGet(); p.Semester = $('#Semester').lrselectGet(); p.DeptNo = $('#DeptNo').lrselectGet(); p.MajorNo = $('#MajorNo').lrselectGet(); p.LessonNo = $('#LessonNo').lrselectGet(); p.TeachClassNo = $('#TeachClassNo').lrselectGet(); p.EmpNo = $('#EmpNo').lrselectGet(); p.ClassroomNo = $('#ClassroomNo').lrselectGet(); //console.log(p); //if (!!p.F_SchoolId && !!p.AcademicYearNo && !!p.Semester && !!p.DeptNo && !!p.MajorNo && !!p.LessonNo && !!p.TeachClassNo && !!p.EmpNo && !!p.ClassroomNo) { if (!!p.AcademicYearNo && !!p.Semester && !!p.DeptNo && !!p.MajorNo && !!p.LessonNo && !!p.TeachClassNo && !!p.EmpNo && !!p.ClassroomNo) { //调度开始时间 $('#AttemperStartTime').lrselectRefresh({ allowSearch: true, url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetLessonDateList?queryJson=' + JSON.stringify(p), value: 'value', text: 'text' }); //调度结束时间 $('#AttemperEndTime').lrselectRefresh({ allowSearch: true, url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetLessonDateList?queryJson=' + JSON.stringify(p), value: 'value', text: 'text' }); } }, bind: function () { $('#CreateTime')[0].lrvalue = learun.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'); $('#CreateTime').val(learun.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')); $('#CreateUserId')[0].lrvalue = learun.clientdata.get(['userinfo']).userId; $('#CreateUserId').val(learun.clientdata.get(['userinfo']).realName); $('#CreateUserName')[0].lrvalue = learun.clientdata.get(['userinfo']).realName; //选择课程安排 //$("#btn1").on('click', function () { // learun.layerForm({ // id: 'IndexInEducationSelect', // title: '课程表', // url: top.$.rootUrl + '/PersonnelManagement/TimeTable/IndexInEducationSelect', // width: 1200, // height: 800, // callBack: function (id) { // return top[id].acceptClick(bindData); // } // }); //}); //$("#btn2").on('click', function () { // learun.layerForm({ // id: 'IndexInEducationSelect', // title: '课程表', // url: top.$.rootUrl + '/PersonnelManagement/TimeTable/IndexInEducationSelect', // width: 1200, // height: 800, // callBack: function (id) { // return top[id].acceptClick(bindDataNew); // } // }); //}); }, bindSelect: function () { $('#AttemperType').lrDataItemSelect({ code: 'AttemperType', select: function (item) { $('.AttemperType').hide(); $("#AttemperTimeType").removeAttr("isvalid"); $("#AttemperTimeType").removeAttr("checkexpession"); $("#AttemperStartTime").removeAttr("isvalid"); $("#AttemperStartTime").removeAttr("checkexpession"); $("#AttemperEndTime").removeAttr("isvalid"); $("#AttemperEndTime").removeAttr("checkexpession"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("isvalid"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("checkexpession"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr('readonly'); $('#NewEmpNo').siblings('div').html('教师'); $('#NewClassroomNo').siblings('div').html('教室'); if (item != null && item != undefined) { if (item.id === "01") { //换课 $('.AttemperTypeTiao').show(); $("#AttemperTimeType").attr("isvalid", "yes"); $("#AttemperTimeType").attr("checkexpession", "NotNull"); $("#AttemperStartTime").attr("isvalid", "yes"); $("#AttemperStartTime").attr("checkexpession", "NotNull"); $("#AttemperEndTime").attr("isvalid", "yes"); $("#AttemperEndTime").attr("checkexpession", "NotNull"); } else if (item.id === "02") { //停课 } else if (item.id === "03") { //对调 $('.AttemperTypeDuiDiao').show(); $(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes"); $(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull"); $(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly'); $('#NewEmpNo').siblings('div').html('教师*'); $('#NewClassroomNo').siblings('div').html('教室*'); } else if (item.id === "04") { //调课 $("#sourcedata").hide(); $("#oldgridtable").show(); $("#targetdata").hide(); $("#targetgridtable").show(); $(".olddata").removeAttr("isvalid"); $(".olddata").removeAttr("checkexpession"); $(".olddata").removeAttr('readonly'); } } } }); $('#AttemperTimeType').lrDataItemSelect({ code: 'AttemperTimeType' }); //$('#F_SchoolId').lrDataSourceSelect({ code: 'company', value: 'f_companyid', text: 'f_fullname' }); //$('#NewF_SchoolId').lrDataSourceSelect({ code: 'company', value: 'f_companyid', text: 'f_fullname' }); //学年 $('#AcademicYearNo').lrselect({ allowSearch: true, url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetAcademicYearNo', value: 'value', text: 'text' }); $('#NewAcademicYearNo').lrselect({ allowSearch: true, url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetAcademicYearNo', value: 'value', text: 'text' }); //学期 $('#Semester').lrselect({ allowSearch: true, url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetSemesterData', value: 'value', text: 'text' }); $('#NewSemester').lrselect({ allowSearch: true, url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetSemesterData', value: 'value', text: 'text' }); $('#DeptNo').lrDataSourceSelect({ code: 'CdDeptInfo', value: 'deptno', text: 'deptname' }); $('#NewDeptNo').lrDataSourceSelect({ code: 'CdDeptInfo', value: 'deptno', text: 'deptname' }); $('#MajorNo').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno', text: 'majorname' }); $('#NewMajorNo').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno', text: 'majorname' }); $('#LessonNo').lrselect({ allowSearch: true, url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetLessonDataInTerm', value: 'value', text: 'text', }); $('#NewLessonNo').lrselect({ allowSearch: true, url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetLessonDataInTerm', value: 'value', text: 'text', }); $('#TeachClassNo').lrDataSourceSelect({ code: 'bjsj', value: 'classno', text: 'classname' }); $('#NewTeachClassNo').lrDataSourceSelect({ code: 'bjsj', value: 'classno', text: 'classname' }); $('#EmpNo').lrDataSourceSelect({ code: 'EmpInfo', value: 'empno', text: 'empname' }); $('#NewEmpNo').lrDataSourceSelect({ code: 'EmpInfo', value: 'empno', text: 'empname' }); $('#ClassroomNo').lrDataSourceSelect({ code: 'ClassRoomInfo', value: 'classroomno', text: 'classroomname' }); $('#NewClassroomNo').lrDataSourceSelect({ code: 'ClassRoomInfo', value: 'classroomno', text: 'classroomname' }); }, initData: function () { if (!!keyValue) { $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetFormData?keyValue=' + keyValue, function (data) { for (var id in data) { if (!!data[id].length && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); } else { $('[data-table="' + id + '"]').lrSetFormData(data[id]); $('.AttemperType').hide(); $("#AttemperTimeType").removeAttr("isvalid"); $("#AttemperTimeType").removeAttr("checkexpession"); $("#AttemperStartTime").removeAttr("isvalid"); $("#AttemperStartTime").removeAttr("checkexpession"); $("#AttemperEndTime").removeAttr("isvalid"); $("#AttemperEndTime").removeAttr("checkexpession"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("isvalid"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("checkexpession"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr('readonly'); $('#NewEmpNo').siblings('div').html('教师'); $('#NewClassroomNo').siblings('div').html('教室'); $('#NewEmpNo').attr('readonly', 'readonly'); $('#NewClassroomNo').attr('readonly', 'readonly'); if (data[id].AttemperType == "01") { $('.AttemperTypeTiao').show(); $("#AttemperTimeType").attr("isvalid", "yes"); $("#AttemperTimeType").attr("checkexpession", "NotNull"); $("#AttemperStartTime").attr("isvalid", "yes"); $("#AttemperStartTime").attr("checkexpession", "NotNull"); $("#AttemperEndTime").attr("isvalid", "yes"); $("#AttemperEndTime").attr("checkexpession", "NotNull"); } else if (data[id].AttemperType == "02") { } else if (data[id].AttemperType == "03") { $('.AttemperTypeDuiDiao').show(); $(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes"); $(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull"); $(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly'); $('#NewEmpNo').siblings('div').html('教师*'); $('#NewClassroomNo').siblings('div').html('教室*'); } else if (data[id].AttemperType == "04") { $("#sourcedata").hide(); $("#oldgridtable").show(); $("#targetdata").hide(); $("#targetgridtable").show(); $(".olddata").removeAttr("isvalid"); $(".olddata").removeAttr("checkexpession"); $(".olddata").removeAttr('readonly'); $("#gridtable").attr("data-val", JSON.stringify(data[id].query)); var html1 = ""; var html2 = ""; var oldtime = ""; var oldjieci = []; var course = ''; var teacher = ''; var class_ = []; var classroom = ''; var newtime = ''; var newjieci = []; for (var i = 0; i < data[id].query.length; i++) { var item = data[id].query[i]; var jieci1 = item.LessonTime.substring(1, item.LessonTime.length) + '节'; var jieci2 = item.NewLessonTime.substring(1, item.NewLessonTime.length) + '节'; if (i == 0) { oldtime = item.LessonDate.substring(0, 10); course = item.LessonName; teacher = item.EmpName; classroom = item.ClassroomName; newtime = item.NewLessonDate.substring(0, 10) } if (oldjieci.indexOf(jieci1) < 0) { oldjieci.push(jieci1) } if (class_.indexOf(item.Classname) < 0) { class_.push(item.Classname) } if (newjieci.indexOf(jieci2) < 0) { newjieci.push(jieci2) } } html1 += '日期:' + oldtime + '
节次:' + oldjieci.join(';') + '
课程:' + course + '
教师:' + teacher + ';
班级:' + class_.join(';') + '
教室:' + classroom; html2 += '调整到:' + newtime + '的' + newjieci.join(';'); //console.log(html1) $("#gridtable").html(html1); //{"targettime":"2023-6-24","targetjieci":"1节;2节;"} var target_json = { "targettime": newtime, "targetjieci": newjieci.join(';') } $('#gridtable1').attr("data-val", JSON.stringify(target_json)); $("#gridtable1").html(html2) } } } }); } } }; bindData = function (temprow) { if (!!temprow) { if ($("#AttemperType").lrselectGet() == "04") { //console.log(temprow) var dataparams = temprow.predata; //$('#gridtable').jfGridSet('refreshdata', temprow.predata); var datahtml = temprow.predatastr;//tardata.targettime + '的' + tardata.targetjieci; $('#gridtable').html(datahtml); $('#gridtable').attr("data-val", JSON.stringify(dataparams)) var tardata = (temprow.tardata); var html = '调整到:' + tardata.targettime + '的' + tardata.targetjieci; $('#gridtable1').html(html); $('#gridtable1').attr("data-val", JSON.stringify(tardata)) //$('#gridtable1').jfGridSet('refreshdata', temprow.predata); //$('#gridtable'). } else { //$('#F_SchoolId').lrselectSet(temprow.schooldId); $('#AcademicYearNo').lrselectSet(temprow.academicyear); $('#Semester').lrselectSet(temprow.semester); $('#DeptNo').lrselectSet(temprow.deptNo); $('#MajorNo').lrselectSet(temprow.majorNo); $('#LessonNo').lrselectSet(temprow.lessonNo); $('#TeachClassNo').lrselectSet(temprow.teachClassNo); $('#EmpNo').lrselectSet(temprow.empno); $('#ClassroomNo').lrselectSet(temprow.classRoomNo); } page.query(); } }; bindDataNew = function (temprow) { if (!!temprow) { //$('#NewF_SchoolId').lrselectSet(temprow.schooldId); $('#NewAcademicYearNo').lrselectSet(temprow.academicyear); $('#NewSemester').lrselectSet(temprow.semester); $('#NewDeptNo').lrselectSet(temprow.deptNo); $('#NewMajorNo').lrselectSet(temprow.majorNo); $('#NewLessonNo').lrselectSet(temprow.lessonNo); $('#NewTeachClassNo').lrselectSet(temprow.teachClassNo); $('#NewEmpNo').lrselectSet(temprow.empno); $('#NewClassroomNo').lrselectSet(temprow.classRoomNo); } }; // 设置表单数据 setFormData = function (processId, param, callback) { if (!!processId) { $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetFormDataByProcessId?processId=' + processId, function (data) { for (var id in data) { if (!!data[id] && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); } else { if (id == 'ArrangeLessonTermAttemper') { keyValue = data[id].Id; } $('[data-table="' + id + '"]').lrSetFormData(data[id]); $('.AttemperType').hide(); $("#AttemperTimeType").removeAttr("isvalid"); $("#AttemperTimeType").removeAttr("checkexpession"); $("#AttemperStartTime").removeAttr("isvalid"); $("#AttemperStartTime").removeAttr("checkexpession"); $("#AttemperEndTime").removeAttr("isvalid"); $("#AttemperEndTime").removeAttr("checkexpession"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("isvalid"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("checkexpession"); $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr('readonly'); $('#NewEmpNo').siblings('div').html('教师'); $('#NewClassroomNo').siblings('div').html('教室'); $('#NewEmpNo').attr('readonly', 'readonly'); $('#NewClassroomNo').attr('readonly', 'readonly'); if (data[id].AttemperType == "01") { $('.AttemperTypeTiao').show(); $("#AttemperTimeType").attr("isvalid", "yes"); $("#AttemperTimeType").attr("checkexpession", "NotNull"); $("#AttemperStartTime").attr("isvalid", "yes"); $("#AttemperStartTime").attr("checkexpession", "NotNull"); $("#AttemperEndTime").attr("isvalid", "yes"); $("#AttemperEndTime").attr("checkexpession", "NotNull"); } else if (data[id].AttemperType == "02") { } else if (data[id].AttemperType == "03") { $('.AttemperTypeDuiDiao').show(); $(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes"); $(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull"); $(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly'); $('#NewEmpNo').siblings('div').html('教师*'); $('#NewClassroomNo').siblings('div').html('教室*'); } else if (data[id].AttemperType == "04") { $("#sourcedata").hide(); $("#oldgridtable").show(); $("#targetdata").hide(); $("#targetgridtable").show(); $(".olddata").removeAttr("isvalid"); $(".olddata").removeAttr("checkexpession"); $(".olddata").removeAttr('readonly'); $("#gridtable").attr("data-val", JSON.stringify(data[id].query)); var html1 = ""; var html2 = ""; var oldtime = ""; var oldjieci = []; var course = ''; var teacher = ''; var class_ = []; var classroom = ''; var newtime = ''; var newjieci = []; for (var i = 0; i < data[id].query.length; i++) { var item = data[id].query[i]; var jieci1 = item.LessonTime.substring(1, item.LessonTime.length) + '节'; var jieci2 = item.NewLessonTime.substring(1, item.NewLessonTime.length) + '节'; if (i == 0) { oldtime = item.LessonDate.substring(0, 10); course = item.LessonName; teacher = item.EmpName; classroom = item.ClassroomName; newtime = item.NewLessonDate.substring(0, 10) } if (oldjieci.indexOf(jieci1) < 0) { oldjieci.push(jieci1) } if (class_.indexOf(item.Classname) < 0) { class_.push(item.Classname) } if (newjieci.indexOf(jieci2) < 0) { newjieci.push(jieci2) } } html1 += '日期:' + oldtime + '
节次:' + oldjieci.join(';') + '
课程:' + course + '
教师:' + teacher + ';
班级:' + class_.join(';') + '
教室:' + classroom; html2 += '调整到:' + newtime + '的' + newjieci.join(';'); //console.log(html1) $("#gridtable").html(html1); //{"targettime":"2023-6-24","targetjieci":"1节;2节;"} var target_json = { "targettime": newtime, "targetjieci": newjieci.join(';') } $('#gridtable1').attr("data-val", JSON.stringify(target_json)); $("#gridtable1").html(html2) } } } }); } callback && callback(); } // 验证数据是否填写完整 validForm = function () { if (!$('#form').lrValidform()) { return false; } return true; }; // 保存数据 save = function (processId, callBack, i) { //if (data[id].AttemperType != "04") { // var formData = $('body').lrGetFormData(); // if (formData.AttemperType == "03") { //对调:校区、学年、学期需要一致 // //if (formData.F_SchoolId !== formData.NewF_SchoolId || formData.AcademicYearNo !== formData.NewAcademicYearNo || formData.Semester !== formData.NewSemester) { // if (formData.AcademicYearNo !== formData.NewAcademicYearNo || formData.Semester !== formData.NewSemester) { // learun.alert.warning("校区、学年、学期不一致!"); // return false; // } // } else if (formData.AttemperType == "01") { //调课:调度时间比较 // if (formData.AttemperEndTime < formData.AttemperStartTime) { // learun.alert.warning("调度结束时间不能小于调度开始时间!"); // return false; // } // } // if (!!processId) { // formData.ProcessId = processId; // } // var postData = { // strEntity: JSON.stringify(formData) // }; // $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/SaveForm?keyValue=' + keyValue, postData, function (res) { // // 保存成功后才回调 // if (!!callBack) { // callBack(res, i); // } // }); //} callBack({code:200}, i); }; page.init(); }