|
- var refreshGirdData;
- var bootstrap = function ($, learun) {
- var startTime;
- var endTime;
- var Printdata;
- var page = {
- init: function () {
- page.bind();
- page.bindSelect();
- },
- loadData: function (param) {
- $.lrSetFormWithParam(top.$.rootUrl + '/PersonnelManagement/TimeTable/GetDataInEducation', param,
- function (data) {
- Printdata = '';
- for (var key in param) {
- Printdata += key + '=' + param[key]+'&'
- }
- //console.log(data, "data")
- var classList = data.classinfolist;
- var classListNow = [];
- if (classList == '' || classList == undefined) {
- learun.alert.warning('未查询到数据,请更换搜索条件');
- return
- }
- for (var i = 0; i < classList.length; i++) {
- classListNow.push(classList[i][0]);
- }
-
- data.classinfolist = classListNow;
- var dom = '<tr><td></td>'
- var week = 7
- var weekObj = {
- 0: '一',
- 1: '二',
- 2: '三',
- 3: '四',
- 4: '五',
- 5: '六',
- 6: '日',
- }
- // 生成一周七天表头
- for (var i = 0; i < week; i++) {
- dom += '<td colspan=' + data.maxlessontime + '>星期' + weekObj[i] + '</td>'
- }
- dom += '</tr><tr><td>班级|节次</td>'
- // 生成课程节次表头
- for (var j = 0; j < week; j++) {
- var index = 0
- for (var i = 0; i < data.maxlessontime; i++) {
- index++
- dom += '<td>' + (index) + '</td>'
- }
- }
- dom += '</tr>'
- // 生成每个班级的课程
- for (var i = 0; i < data.classinfolist.length; i++) {
- var classMsg = data.classinfolist[i]
- dom += '<tr classId=' + classMsg.TeachClassNo + '><td>' + classMsg.ClassName + '</td>'
- for (var j = 0; j < week; j++) {
- var index = 0
- for (var k = 0; k < data.maxlessontime; k++) {
- index++
- dom += '<td classId=' + classMsg.TeachClassNo + ' week=' + (j + 1) + ' time=' + index + '></td>'
- }
- }
- dom += '</td>'
- }
- table.innerHTML = dom
-
- var tableWidth = data.maxlessontime * 7 * 100
- table.style.width = tableWidth + 'px'
- // 开始渲染数据
- var domObj = {}
- var trsObj = {}
- var trs = document.getElementsByTagName('tr')
- for (var j = 0; j < trs.length; j++) {
- var id = trs[j].getAttribute('classId')
- if (id) {
- trsObj[id] = trs[j]
- }
-
- }
- //console.log(trsObj,'trsObj')
- for (var i = 0; i < data.weekList.length; i++) {
- var weekObj = data.weekList[i]
- for (var j = 0; j < weekObj.list.length; j++) {
- var weekList = weekObj.list[j]
- weekList['time'] = weekObj.time
-
- var tds = trsObj[weekList.teachClassNo].getElementsByTagName('td')
- for (var k = 0; k < tds.length; k++) {
- var time = tds[k].getAttribute('time')
- var classId = tds[k].getAttribute('classId')
- var week = tds[k].getAttribute('week')
- if (week == weekList.day && classId == weekList.teachClassNo && time == weekList.time) {
- tds[k].innerHTML = '<div>课程:' + weekList.curriculum + '</div><div>教师:' + weekList.teacher + '</div><div>教室:' + weekList.classRoom + '</div>'
- }
- }
- }
- }
- }
-
- );
- },
- bind: function () {
- // 刷新
- $('#lr_refresh').on('click', function () {
- location.reload();
- });
- $('#datesearch').lrdate({
- dfdata: [
- {
- name: '上周',
- begin: function () { return learun.getTime(7); },
- end: function () {
- return learun.getTime(1);
- }
- },
- {
- name: '本周',
- begin: function () { return learun.getTime(0); },
- end: function () {
- return learun.getTime(-6);
- }
- },
- {
- name: '下周',
- begin: function () { return learun.getTime(-7); },
- end: function () {
- return learun.getTime(-13);
- }
- }],
- // 月
- mShow: false,
- premShow: false,
- // 季度
- jShow: false,
- prejShow: false,
- // 年
- ysShow: false,
- yxShow: false,
- preyShow: false,
- yShow: false,
- // 默认
- dfvalue: 'currentWeek',
- selectfn: function (begin, end) {
- startTime = begin;
- endTime = end;
- page.search();
- }
- });
- //查询
- $('#lr_search').on('click', function () {
- var p = {};
- p.schoolId = $('#F_SchoolId').lrselectGet();
- p.ClassNo = $('#ClassNo').lrselectGet();
- p.EmpNo = $('#EmpNo').lrselectGet();
- page.search(p);
- });
- // 按条件清空排课数据
- $('#emptyByCondition').on('click', function () {
- learun.layerForm({
- id: 'EmptyByConditionForm',
- title: '按条件清空排课数据',
- url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/EmptyByConditionForm',
- width: 600,
- height: 400,
- callBack: function (id) {
- return top[id].acceptClick(refreshGirdData);
- }
- });
- });
- // 按条件同步排课数据
- $('#syncByCondition').on('click', function () {
- learun.layerForm({
- id: 'SyncByConditionForm',
- title: '按条件同步排课数据',
- url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/SyncByConditionForm',
- width: 600,
- height: 400,
- callBack: function (id) {
- return top[id].acceptClick(refreshGirdData);
- }
- });
- });
-
- //按条件重置基础数据同步状态
- $('#initByCondition').on('click', function () {
- learun.layerForm({
- id: 'SyncByConditionForm',
- title: '按条件重置基础数据同步状态',
- url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/ClearByConditionForm',
- width: 600,
- height: 400,
- callBack: function (id) {
- return top[id].acceptClick();
- }
- });
- });
- $('#lr_export').on('click',
- function () {
- window.open(window.origin+"/PersonnelManagement/TimeTable/PrintSchedule?" + Printdata.slice(0, Printdata.length-1));
- //console.log(Printdata, "data");
- });
- },
- bindSelect: function () {
- //校区
- $('#F_SchoolId').lrDataSourceSelect({
- code: 'company', value: 'f_companyid', text: 'f_fullname', select: function (item) {
- if (!!item) {
- // 班级
- $('#ClassNo').lrselectRefresh({
- placeholder: "请选择班级",
- allowSearch: true,
- url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetClassData',
- param: { schoolId: item.f_companyid },
- value: 'value',
- text: 'text'
- });
- // 教师
- $('#EmpNo').lrselectRefresh({
- placeholder: "请选择教师",
- allowSearch: true,
- url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetTeacherData',
- param: { schoolId: item.f_companyid },
- value: 'value',
- text: 'text'
- });
- } else {
- //班级
- $('#ClassNo').lrselectRefresh({
- placeholder: "请选择班级",
- allowSearch: true,
- url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetClassData',
- param: { schoolId: "" },
- value: 'value',
- text: 'text'
- });
- //教师
- $('#EmpNo').lrselectRefresh({
- placeholder: "请选择教师",
- allowSearch: true,
- url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetTeacherData',
- param: { schoolId: "" },
- value: 'value',
- text: 'text'
- });
- }
- }
- });
- //班级
- $('#ClassNo').lrselect({
- placeholder: "请选择班级",
- allowSearch: true,
- url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetClassData',
- value: 'value',
- text: 'text'
- });
- //教师
- $('#EmpNo').lrselect({
- placeholder: "请选择教师",
- allowSearch: true,
- url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetTeacherData',
- value: 'value',
- text: 'text'
- });
- },
- search: function (param) {
- param = param || {};
- param.StartTime = startTime;
- param.EndTime = endTime;
- page.loadData(param);
- }
- };
- page.init();
- };
|