You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

277 lines
12 KiB

  1. var refreshGirdData;
  2. var bootstrap = function ($, learun) {
  3. var startTime;
  4. var endTime;
  5. var Printdata;
  6. var page = {
  7. init: function () {
  8. page.bind();
  9. page.bindSelect();
  10. },
  11. loadData: function (param) {
  12. $.lrSetFormWithParam(top.$.rootUrl + '/PersonnelManagement/TimeTable/GetDataInEducation', param,
  13. function (data) {
  14. Printdata = '';
  15. for (var key in param) {
  16. Printdata += key + '=' + param[key]+'&'
  17. }
  18. //console.log(data, "data")
  19. var classList = data.classinfolist;
  20. var classListNow = [];
  21. if (classList == '' || classList == undefined) {
  22. learun.alert.warning('未查询到数据,请更换搜索条件');
  23. return
  24. }
  25. for (var i = 0; i < classList.length; i++) {
  26. classListNow.push(classList[i][0]);
  27. }
  28. data.classinfolist = classListNow;
  29. var dom = '<tr><td></td>'
  30. var week = 7
  31. var weekObj = {
  32. 0: '一',
  33. 1: '二',
  34. 2: '三',
  35. 3: '四',
  36. 4: '五',
  37. 5: '六',
  38. 6: '日',
  39. }
  40. // 生成一周七天表头
  41. for (var i = 0; i < week; i++) {
  42. dom += '<td colspan=' + data.maxlessontime + '>星期' + weekObj[i] + '</td>'
  43. }
  44. dom += '</tr><tr><td>班级|节次</td>'
  45. // 生成课程节次表头
  46. for (var j = 0; j < week; j++) {
  47. var index = 0
  48. for (var i = 0; i < data.maxlessontime; i++) {
  49. index++
  50. dom += '<td>' + (index) + '</td>'
  51. }
  52. }
  53. dom += '</tr>'
  54. // 生成每个班级的课程
  55. for (var i = 0; i < data.classinfolist.length; i++) {
  56. var classMsg = data.classinfolist[i]
  57. dom += '<tr classId=' + classMsg.TeachClassNo + '><td>' + classMsg.ClassName + '</td>'
  58. for (var j = 0; j < week; j++) {
  59. var index = 0
  60. for (var k = 0; k < data.maxlessontime; k++) {
  61. index++
  62. dom += '<td classId=' + classMsg.TeachClassNo + ' week=' + (j + 1) + ' time=' + index + '></td>'
  63. }
  64. }
  65. dom += '</td>'
  66. }
  67. table.innerHTML = dom
  68. var tableWidth = data.maxlessontime * 7 * 100
  69. table.style.width = tableWidth + 'px'
  70. // 开始渲染数据
  71. var domObj = {}
  72. var trsObj = {}
  73. var trs = document.getElementsByTagName('tr')
  74. for (var j = 0; j < trs.length; j++) {
  75. var id = trs[j].getAttribute('classId')
  76. if (id) {
  77. trsObj[id] = trs[j]
  78. }
  79. }
  80. //console.log(trsObj,'trsObj')
  81. for (var i = 0; i < data.weekList.length; i++) {
  82. var weekObj = data.weekList[i]
  83. for (var j = 0; j < weekObj.list.length; j++) {
  84. var weekList = weekObj.list[j]
  85. weekList['time'] = weekObj.time
  86. var tds = trsObj[weekList.teachClassNo].getElementsByTagName('td')
  87. for (var k = 0; k < tds.length; k++) {
  88. var time = tds[k].getAttribute('time')
  89. var classId = tds[k].getAttribute('classId')
  90. var week = tds[k].getAttribute('week')
  91. if (week == weekList.day && classId == weekList.teachClassNo && time == weekList.time) {
  92. tds[k].innerHTML = '<div>课程:' + weekList.curriculum + '</div><div>教师:' + weekList.teacher + '</div><div>教室:' + weekList.classRoom + '</div>'
  93. }
  94. }
  95. }
  96. }
  97. }
  98. );
  99. },
  100. bind: function () {
  101. // 刷新
  102. $('#lr_refresh').on('click', function () {
  103. location.reload();
  104. });
  105. $('#datesearch').lrdate({
  106. dfdata: [
  107. {
  108. name: '上周',
  109. begin: function () { return learun.getTime(7); },
  110. end: function () {
  111. return learun.getTime(1);
  112. }
  113. },
  114. {
  115. name: '本周',
  116. begin: function () { return learun.getTime(0); },
  117. end: function () {
  118. return learun.getTime(-6);
  119. }
  120. },
  121. {
  122. name: '下周',
  123. begin: function () { return learun.getTime(-7); },
  124. end: function () {
  125. return learun.getTime(-13);
  126. }
  127. }],
  128. // 月
  129. mShow: false,
  130. premShow: false,
  131. // 季度
  132. jShow: false,
  133. prejShow: false,
  134. // 年
  135. ysShow: false,
  136. yxShow: false,
  137. preyShow: false,
  138. yShow: false,
  139. // 默认
  140. dfvalue: 'currentWeek',
  141. selectfn: function (begin, end) {
  142. startTime = begin;
  143. endTime = end;
  144. page.search();
  145. }
  146. });
  147. //查询
  148. $('#lr_search').on('click', function () {
  149. var p = {};
  150. p.schoolId = $('#F_SchoolId').lrselectGet();
  151. p.ClassNo = $('#ClassNo').lrselectGet();
  152. p.EmpNo = $('#EmpNo').lrselectGet();
  153. page.search(p);
  154. });
  155. // 按条件清空排课数据
  156. $('#emptyByCondition').on('click', function () {
  157. learun.layerForm({
  158. id: 'EmptyByConditionForm',
  159. title: '按条件清空排课数据',
  160. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/EmptyByConditionForm',
  161. width: 600,
  162. height: 400,
  163. callBack: function (id) {
  164. return top[id].acceptClick(refreshGirdData);
  165. }
  166. });
  167. });
  168. // 按条件同步排课数据
  169. $('#syncByCondition').on('click', function () {
  170. learun.layerForm({
  171. id: 'SyncByConditionForm',
  172. title: '按条件同步排课数据',
  173. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/SyncByConditionForm',
  174. width: 600,
  175. height: 400,
  176. callBack: function (id) {
  177. return top[id].acceptClick(refreshGirdData);
  178. }
  179. });
  180. });
  181. //按条件重置基础数据同步状态
  182. $('#initByCondition').on('click', function () {
  183. learun.layerForm({
  184. id: 'SyncByConditionForm',
  185. title: '按条件重置基础数据同步状态',
  186. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/ClearByConditionForm',
  187. width: 600,
  188. height: 400,
  189. callBack: function (id) {
  190. return top[id].acceptClick();
  191. }
  192. });
  193. });
  194. $('#lr_export').on('click',
  195. function () {
  196. window.open(window.origin+"/PersonnelManagement/TimeTable/PrintSchedule?" + Printdata.slice(0, Printdata.length-1));
  197. //console.log(Printdata, "data");
  198. });
  199. },
  200. bindSelect: function () {
  201. //校区
  202. $('#F_SchoolId').lrDataSourceSelect({
  203. code: 'company', value: 'f_companyid', text: 'f_fullname', select: function (item) {
  204. if (!!item) {
  205. // 班级
  206. $('#ClassNo').lrselectRefresh({
  207. placeholder: "请选择班级",
  208. allowSearch: true,
  209. url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetClassData',
  210. param: { schoolId: item.f_companyid },
  211. value: 'value',
  212. text: 'text'
  213. });
  214. // 教师
  215. $('#EmpNo').lrselectRefresh({
  216. placeholder: "请选择教师",
  217. allowSearch: true,
  218. url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetTeacherData',
  219. param: { schoolId: item.f_companyid },
  220. value: 'value',
  221. text: 'text'
  222. });
  223. } else {
  224. //班级
  225. $('#ClassNo').lrselectRefresh({
  226. placeholder: "请选择班级",
  227. allowSearch: true,
  228. url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetClassData',
  229. param: { schoolId: "" },
  230. value: 'value',
  231. text: 'text'
  232. });
  233. //教师
  234. $('#EmpNo').lrselectRefresh({
  235. placeholder: "请选择教师",
  236. allowSearch: true,
  237. url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetTeacherData',
  238. param: { schoolId: "" },
  239. value: 'value',
  240. text: 'text'
  241. });
  242. }
  243. }
  244. });
  245. //班级
  246. $('#ClassNo').lrselect({
  247. placeholder: "请选择班级",
  248. allowSearch: true,
  249. url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetClassData',
  250. value: 'value',
  251. text: 'text'
  252. });
  253. //教师
  254. $('#EmpNo').lrselect({
  255. placeholder: "请选择教师",
  256. allowSearch: true,
  257. url: top.$.rootUrl + '/PersonnelManagement/TimeTable/GetTeacherData',
  258. value: 'value',
  259. text: 'text'
  260. });
  261. },
  262. search: function (param) {
  263. param = param || {};
  264. param.StartTime = startTime;
  265. param.EndTime = endTime;
  266. page.loadData(param);
  267. }
  268. };
  269. page.init();
  270. };