/* * 版 本 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();
page.initGird();
},
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();
//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 () {
//如果是调课,需要传参给选课界面
var params = '?attempertype=' + $('#AttemperType').lrselectGet();
var urls = top.$.rootUrl + '/PersonnelManagement/TimeTable/IndexInEducationSelect' + params;
if ($("#AttemperType").lrselectGet() == "04") {
urls = top.$.rootUrl + '/PersonnelManagement/TimeTable/IndexInEducationSelect_' + params;
}
console.log(1)
learun.layerForm({
id: 'IndexInEducationSelect',
title: '课程表',
url: urls,
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('教室');
$(".olddata").attr("isvalid","yes");
$(".olddata").attr("checkexpession", "NotNull");
$(".olddata").attr('readonly', "readonly");
if (item != null && item != undefined) {
$('#btn1').show()
//调课需要隐藏所有的表单列表(备注:只是隐藏,表单的验证还是要使用到,只不过换一种方式展现数据),显示两个表格
$("#sourcedata").show();
$("#oldgridtable").hide();
$("#targetdata").show();
$("#targetgridtable").hide();
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") { //调课
//$('#gridtable').jfGridSet('refreshdata', []);
$("#sourcedata").hide();
$("#oldgridtable").show();
$("#targetdata").hide();
$("#targetgridtable").show();
//$(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes");
//$(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull");
//$(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly');
$(".olddata").removeAttr("isvalid");
$(".olddata").removeAttr("checkexpession");
$(".olddata").removeAttr('readonly');
//$(".gridtable").attr("isvalid", "yes");
//$(".gridtable").attr("checkexpession", "NotNull");
//$(".gridtable").attr('readonly', "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' });
//调度开始时间
$('#AttemperStartTime').lrselect({ allowSearch: true });
//调度结束时间
$('#AttemperEndTime').lrselect({ allowSearch: true });
},
initData: function () {
if (!!keyValue) {
$.lrSetForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetFormData?keyValue=' + keyValue, function (data) {
console.log(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('教室');
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") {
//$('#gridtable').jfGridSet('refreshdata', []);
$("#sourcedata").hide();
$("#oldgridtable").show();
$("#targetdata").hide();
$("#targetgridtable").show();
$(".olddata").removeAttr("isvalid");
$(".olddata").removeAttr("checkexpession");
$(".olddata").removeAttr('readonly');
//[{"AltId":"53a08619-9a54-49a2-80e9-5a30ce5051df","LessonTime":"31","LessonDate":"2023-06-21","time":"2023-6-21","jieci":"1节;2节","curriculum":"职业规划","AcademicYearNo":"22-23","Semester":"2","DeptNo":"1","MajorNo":"101","LessonNo":"1000001010","TeachClassNo":"2210102","EmpNo":"20210117","EmpName":"白晓丽","ClassroomNo":"12020401","classRoom":"2-401"}]
$("#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)
}
}
var timer = setTimeout(function () {
page.query();
clearTimeout(timer);
}, 3000)
}
});
}
},
initGird: function () {
//$('#gridtable').jfGrid({
// headData: [
// { label: "日期", name: "time", width: 100, align: "left" },
// { label: "节次", name: "jieci", width: 100, align: "left" },
// { label: "课程", name: "curriculum", width: 100, align: "left" },
// { label: "班级", name: "ClassName", width: 100, align: "left" },
// { label: "教师", name: "EmpName", width: 100, align: "left" },
// { label: "教室", name: "classRoom", width: 100, align: "left" },
// ],
// mainId: 'Id',
// isPage: true,
// sord: 'desc',
// sidx: 'CreateTime'
//});
//$('#gridtable1').jfGrid({
// headData: [
// { label: "日期", name: "time", width: 100, align: "left" },
// { label: "节次", name: "jieci", width: 100, align: "left" },
// { label: "课程", name: "curriculum", width: 100, align: "left" },
// { label: "班级", name: "ClassName", width: 100, align: "left" },
// { label: "教师", name: "EmpName", width: 100, align: "left" },
// { label: "教室", name: "classRoom", width: 100, align: "left" },
// ],
// mainId: 'Id',
// isPage: true,
// sord: 'desc',
// sidx: 'CreateTime'
//});
},
};
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);
}
};
// 验证数据是否填写完整
validForm = function () {
if (!$('#form').lrValidform()) {
return false;
}
if ($("#AttemperType").lrselectGet() == "04") {
var predata = $('#gridtable').attr('data-val');
var tardata = $('#gridtable1').attr('data-val');
if (!predata) {
learun.alert.warning("未选择需要调度的课程");
return false;
}
if (!tardata) {
learun.alert.warning("未选择将要调整的课程");
return false;
}
//var datas = $('#gridtable').jfGridGet('rowdatas');
//if (datas == null || datas.length == 0) {
// learun.alert.warning("未选择需要调度的课程");
// return false;
//}
//var datas1 = $('#gridtable1').jfGridGet('rowdatas');
//if (datas1 == null || datas1.length == 0) {
// learun.alert.warning("未选择将要调整的课程");
// return false;
//}
}
return true;
};
// 设置表单数据
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('教室');
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('教室*');
}
}
var timer = setTimeout(function () {
page.query();
clearTimeout(timer);
}, 3000)
}
});
}
callback && callback();
}
// 保存数据
save = function (processId, callBack, i) {
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.NewEmpNo == null || formData.NewEmpNo == "") && (formData.NewClassroomNo == null || formData.NewClassroomNo == "")) {
learun.alert.warning("课程新安排中教师或教室不能为空!");
return false;
}
if (formData.AttemperEndTime < formData.AttemperStartTime) {
learun.alert.warning("调度结束时间不能小于调度开始时间!");
return false;
}
} else if (formData.AttemperType == "04") { //调课
if (formData) {
formData.predata = JSON.parse($('#gridtable').attr("data-val"));
formData.tardata = JSON.parse( $('#gridtable1').attr("data-val"));
}
}
console.log(formData)
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);
}
});
};
page.init();
}