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.

IndexLessonTerm.js 16 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. var refreshGirdData;
  2. var bootstrap = function ($, learun) {
  3. var classNo;
  4. var curWeek;
  5. var weekList;
  6. var page = {
  7. init: function () {
  8. page.bind();
  9. page.bindSelect();
  10. },
  11. loadData: function (param) {
  12. $.lrSetFormWithParam(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetDataInEducation', param,
  13. function (data) {
  14. //console.log('res', data);
  15. // 数据处理
  16. var html = '<tr style="height: 30px;"><td>节次/星期</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td><td>星期日</td><td>星期八</td><td>星期九</td><td>星期十</td></tr>';
  17. var weekLists = data.weekList;
  18. //十节课 2022.6.14 修改为一天十一节课
  19. for (var i = 1; i < 12; i++) {
  20. (function (arg) {
  21. var args = arg - 1;
  22. var datas = flogs(arg, weekLists, 'time');
  23. //console.log('datas', datas);
  24. html += ' <tr><td>' + arg + '节</td>';
  25. if (datas) {
  26. var lists = datas.list;
  27. html += tdHandles(lists);
  28. } else {
  29. html += tdHandle(arg);
  30. }
  31. html += '</tr>';
  32. })(i); //调用时参数
  33. }
  34. $('.personT').text(data.schoolName);
  35. $('.perSemester').text(data.semester);
  36. $('.perFestivalsBox table').html(html);
  37. function flogs(num, data, obj) {
  38. var flog = false;
  39. $.each(data,
  40. function (i, n) {
  41. if (n[obj] == num) {
  42. flog = n;
  43. return;
  44. }
  45. })
  46. return flog;
  47. }
  48. function flogs2(num, data, obj) {
  49. var arr = new Array();
  50. $.each(data,
  51. function (i, n) {
  52. if (n[obj] == num) {
  53. arr.push(n);
  54. }
  55. })
  56. return arr;
  57. }
  58. //某节课空
  59. function tdHandle() {
  60. var html = '';
  61. for (var j = 0; j < 11; j++) {
  62. html += '<td class="active" id="" num="' + (j + 1) + '"><div></div><div></div><div></div><div></div></td>';
  63. }
  64. return html;
  65. }
  66. //某节课不空
  67. function tdHandles(lists) {
  68. var html = '';
  69. for (var k = 1; k < 12; k++) {
  70. (function (arg) {
  71. var args = arg - 1;
  72. var datas = flogs2(arg, lists, 'day');
  73. if (datas.length > 0) {
  74. html += '<td class="active" id="' + datas[0].ALTId + '" num="' + k + '">';
  75. $.each(datas, function (i, item) {
  76. if (i > 0) {
  77. html += '<hr>';
  78. }
  79. html += '<div>' +
  80. item.curriculum +
  81. '</div>' +
  82. '<div>' +
  83. item.teacher +
  84. '</div>' +
  85. '<div>' +
  86. item.classRoom +
  87. '</div>';
  88. //html += '<div>课程:' +
  89. // item.curriculum +
  90. // '</div>' +
  91. // '<div>教师:' +
  92. // item.teacher +
  93. // '</div>' +
  94. // '<div>班级:' +
  95. // item.className +
  96. // '</div>' +
  97. // '<div>教室:' +
  98. // item.classRoom +
  99. // '</div>';
  100. });
  101. html += '</td>';
  102. } else {
  103. html += '<td class="active" id="" num="' + k + '"><div></div><div></div><div></div><div></div></td>';
  104. }
  105. })(k);
  106. }
  107. return html;
  108. }
  109. });
  110. },
  111. bind: function () {
  112. //左侧树形导航
  113. $('#dataTree').lrtree({
  114. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetTree',
  115. nodeClick: function (item) {
  116. if (item && item.value) {
  117. classNo = item.value;
  118. }
  119. page.search({ classNo: item.value });
  120. }
  121. });
  122. //获取周次
  123. learun.httpAsyncGet(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetWeekTime', function (res) {
  124. if (res.code == 200) {
  125. weekList = res.data.weekList;
  126. $('#WeekTimes').lrRadioCheckbox({
  127. type: 'radio',
  128. data: res.data.weekList,
  129. value: 'value',
  130. text: 'text'
  131. //data: [{ text: '分析清晰', value: '1' }, { text: '需要改进', value: '2' }]
  132. });
  133. curWeek = res.data.curWeek;
  134. if (!$('#WeekTimes').find('input[value="' + res.data.curWeek + '"]').is(":checked")) {
  135. $('#WeekTimes').find('input[value="' + res.data.curWeek + '"]').trigger('click');
  136. }
  137. //周次
  138. $('#WeekTimeSelect').lrselect({
  139. placeholder: "请选择周次",
  140. maxHeight: 300,
  141. allowSearch: true,
  142. type: 'multiple',
  143. //data: res.data.weekList,
  144. value: 'value',
  145. text: 'text'
  146. });
  147. $('#WeekTimeSelect').lrselectRefresh({
  148. data: res.data.weekList
  149. }
  150. );
  151. }
  152. });
  153. //切换周次
  154. $('#WeekTimes').change(function () {
  155. curWeek = $('#WeekTimes input[name="WeekTimes"]:checked ').val();
  156. page.search();
  157. });
  158. //单元格选中事件
  159. $("#lessonTermTable").on('click', '.active', function () {
  160. var id = $(this).attr('id');
  161. $('#ALTId').val(id);
  162. //console.log('id',id);
  163. if (id.length > 0 && id != 'undefined') {
  164. learun.httpAsyncGet(
  165. top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetFormData?keyValue=' + id,
  166. function (res) {
  167. if (res.data) {
  168. $('#LessonInfo').lrselectSet(res.data.LessonNo);
  169. $('#EmpInfo').lrselectSet(res.data.EmpNo);
  170. $('#ClassroomInfo').lrselectSet(res.data.ClassroomNo);
  171. $('#edit').text('修改');
  172. } else {
  173. $('#LessonInfo').lrselectSet('');
  174. $('#EmpInfo').lrselectSet('');
  175. $('#ClassroomInfo').lrselectSet('');
  176. $('#edit').text('新增');
  177. }
  178. });
  179. } else {
  180. $('#LessonInfo').lrselectSet('');
  181. $('#EmpInfo').lrselectSet('');
  182. $('#ClassroomInfo').lrselectSet('');
  183. $('#edit').text('新增');
  184. }
  185. $('#WeekTimeSelect').lrselectRefresh({
  186. data: weekList
  187. });
  188. $('#WeekTimeSelect').lrselectSet(curWeek);
  189. $('#WeekSelect').lrselectSet($(this).attr('num'));
  190. $('#NodeSelect').lrselectSet(($(this).closest("tr").find("td:eq(0)").text()).replace('节', ''));
  191. });
  192. // 刷新
  193. $('#lr_refresh').on('click', function () {
  194. location.reload();
  195. });
  196. //删除
  197. $('#delete').on('click', function () {
  198. if ($('#ALTId').val()) {
  199. learun.layerConfirm('是否确认删除该项!', function (res) {
  200. if (res) {
  201. learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/DeleteLessonTerm', { keyValue: $('#ALTId').val(), WeekTime: $('#WeekTimeSelect').lrselectGet() }, function () {
  202. refreshGirdData();
  203. });
  204. }
  205. });
  206. }
  207. });
  208. //修改
  209. $('#edit').on('click', function () {
  210. if (!classNo || classNo.length === 0 || classNo === 'undefined') {
  211. return learun.alert.warning('请选择班级!');
  212. }
  213. learun.layerConfirm('是否确认保存该项!', function (res) {
  214. if (res) {
  215. var keyValue = $('#ALTId').val();
  216. var postdata = {
  217. //keyValue: $('#ALTId').val(),
  218. TeachClassNo: classNo,
  219. LessonNo: $('#LessonInfo').lrselectGet(),
  220. LessonName: $('#LessonInfo').lrselectGetText(),
  221. EmpNo: $('#EmpInfo').lrselectGet(),
  222. EmpName: $('#EmpInfo').lrselectGetText(),
  223. ClassroomNo: $('#ClassroomInfo').lrselectGet(),
  224. WeekTimeSelect: $('#WeekTimeSelect').lrselectGet(),
  225. WeekSelect: $('#WeekSelect').lrselectGet(),
  226. NodeSelect: $('#NodeSelect').lrselectGet()
  227. };
  228. learun.postForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/UpdateLessonTerm?keyValue=' + keyValue, { postdata: JSON.stringify(postdata) }, function () {
  229. refreshGirdData();
  230. })
  231. };
  232. });
  233. });
  234. //查询
  235. //$('#lr_search').on('click', function () {
  236. // var p = {};
  237. // p.schoolId = $('#F_SchoolId').lrselectGet();
  238. // p.ClassNo = $('#ClassNo').lrselectGet();
  239. // p.EmpNo = $('#EmpNo').lrselectGet();
  240. // page.search(p);
  241. //});
  242. //打印课程表
  243. $('#perBtn').on('click',
  244. function () {
  245. AddPrintContent();
  246. });
  247. var LODOP, P_ID = "", TaskID1, TaskID2, t, waiting = false, c = 0, loop = 0; //声明为全局变量
  248. function AddPrintContent() {
  249. var myHtml = myHtml = $('.personalBox').html();
  250. var strBodyStyle = "<style>" + document.getElementById("style1").innerHTML + "</style>";
  251. var strFormHtml = strBodyStyle + "<body>" + myHtml + "</body>";
  252. LODOP = getLodop();
  253. LODOP.PRINT_INIT("个人授课表");
  254. LODOP.SET_PRINT_PAGESIZE(2, 0, 0, "A4");
  255. LODOP.SET_PRINT_MODE("PRINT_DUPLEX", 2);
  256. LODOP.SET_PRINT_MODE("PRINT_DEFAULTSOURCE", 7);
  257. LODOP.ADD_PRINT_HTM(10, 10, '284mm', '185mm', strFormHtml);
  258. //打印预览
  259. LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED", 1); //横向时的正向显示
  260. var TaskID1 = LODOP.PREVIEW();
  261. // 直接打印
  262. // var TaskID1=LODOP.PRINT();
  263. }
  264. },
  265. bindSelect: function () {
  266. //课程
  267. $('#LessonInfo').lrDataSourceSelect({
  268. // 展开最大高度
  269. maxHeight: '100px',
  270. placeholder: "请选择课程",
  271. allowSearch: true,
  272. code: 'LessonInfo',
  273. value: 'lessonno',
  274. text: 'lessonname'
  275. });
  276. //教师
  277. $('#EmpInfo').lrDataSourceSelect({
  278. placeholder: "请选择教师",
  279. maxHeight: 300,
  280. allowSearch: true,
  281. code: 'EmpInfo',
  282. value: 'empno',
  283. text: 'empname'
  284. });
  285. //教室
  286. $('#ClassroomInfo').lrDataSourceSelect({
  287. placeholder: "请选择教室",
  288. maxHeight: 300,
  289. allowSearch: true,
  290. code: 'ClassroomInfo',
  291. value: 'classroomno',
  292. text: 'classroomname'
  293. });
  294. ////周次
  295. //$('#WeekTimeSelect').lrselect({
  296. // placeholder: "请选择周次",
  297. // maxHeight: 300,
  298. // allowSearch: true,
  299. // type:'multiple',
  300. // data: weekList
  301. //});
  302. //星期
  303. $('#WeekSelect').lrselect({
  304. placeholder: "请选择星期",
  305. maxHeight: 300,
  306. allowSearch: true,
  307. //type: 'multiple',
  308. data: [{ text: '星期一', value: '1' }, { text: '星期二', value: '2' }, { text: '星期三', value: '3' }, { text: '星期四', value: '4' }, { text: '星期五', value: '5' }, { text: '星期六', value: '6' }, { text: '星期日', value: '7' }, { text: '星期八', value: '8' }, { text: '星期九', value: '9' }, { text: '星期十', value: '10' }],
  309. value: 'value',
  310. text: 'text'
  311. });
  312. //节次
  313. $('#NodeSelect').lrselect({
  314. placeholder: "请选择节次",
  315. maxHeight: 300,
  316. allowSearch: true,
  317. //type: 'multiple',
  318. data: [{ text: '1节', value: '1' }, { text: '2节', value: '2' }, { text: '3节', value: '3' }, { text: '4节', value: '4' }, { text: '5节', value: '5' }, { text: '6节', value: '6' }, { text: '7节', value: '7' }, { text: '8节', value: '8' }, { text: '9节', value: '9' }, { text: '10节', value: '10' }, { text: '11节', value: '11' }],
  319. value: 'value',
  320. text: 'text'
  321. });
  322. },
  323. search: function (param) {
  324. param = param || {};
  325. //当前第几周
  326. param.curWeek = curWeek;
  327. //班级
  328. param.classNo = classNo;//'202010';//
  329. page.loadData(param);
  330. $('#WeekTimeSelect').lrselectRefresh({
  331. data: weekList
  332. });
  333. $('#LessonInfo').lrselectSet('');
  334. $('#EmpInfo').lrselectSet('');
  335. $('#ClassroomInfo').lrselectSet('');
  336. $('#WeekTimeSelect').lrselectSet('');
  337. $('#WeekSelect').lrselectSet('');
  338. $('#NodeSelect').lrselectSet('');
  339. }
  340. };
  341. refreshGirdData = function () {
  342. page.search();
  343. };
  344. page.init();
  345. };