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.

Form.js 19 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 北京泉江科技有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2019-09-26 10:47
  5. * 描 述:教学调度
  6. */
  7. var acceptClick;
  8. var keyValue = request('keyValue');
  9. // 设置权限
  10. var setAuthorize;
  11. // 设置表单数据
  12. var setFormData;
  13. // 验证数据是否填写完整
  14. var validForm;
  15. // 保存数据
  16. var save;
  17. //绑定原课程安排
  18. var bindData;
  19. //绑定新课程安排
  20. var bindDataNew;
  21. var bootstrap = function ($, learun) {
  22. "use strict";
  23. // 设置权限
  24. setAuthorize = function (data) {
  25. };
  26. var page = {
  27. init: function () {
  28. $('.lr-form-wrap').lrscroll();
  29. page.bindSelect();
  30. page.bind();
  31. page.initData();
  32. },
  33. query: function () {
  34. var p = {};
  35. //p.F_SchoolId = $('#F_SchoolId').lrselectGet();
  36. p.AcademicYearNo = $('#AcademicYearNo').lrselectGet();
  37. p.Semester = $('#Semester').lrselectGet();
  38. p.DeptNo = $('#DeptNo').lrselectGet();
  39. p.MajorNo = $('#MajorNo').lrselectGet();
  40. p.LessonNo = $('#LessonNo').lrselectGet();
  41. p.TeachClassNo = $('#TeachClassNo').lrselectGet();
  42. p.EmpNo = $('#EmpNo').lrselectGet();
  43. p.ClassroomNo = $('#ClassroomNo').lrselectGet();
  44. //if (!!p.F_SchoolId && !!p.AcademicYearNo && !!p.Semester && !!p.DeptNo && !!p.MajorNo && !!p.LessonNo && !!p.TeachClassNo && !!p.EmpNo && !!p.ClassroomNo) {
  45. if (!!p.AcademicYearNo && !!p.Semester && !!p.DeptNo && !!p.MajorNo && !!p.LessonNo && !!p.TeachClassNo && !!p.EmpNo && !!p.ClassroomNo) {
  46. //调度开始时间
  47. $('#AttemperStartTime').lrselectRefresh({
  48. allowSearch: true,
  49. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetList?queryJson=' + JSON.stringify(p),
  50. value: 'LessonDate',
  51. text: 'LessonDate'
  52. });
  53. //调度结束时间
  54. $('#AttemperEndTime').lrselectRefresh({
  55. allowSearch: true,
  56. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetList?queryJson=' + JSON.stringify(p),
  57. value: 'LessonDate',
  58. text: 'LessonDate'
  59. });
  60. }
  61. },
  62. bind: function () {
  63. $('#CreateTime')[0].lrvalue = learun.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
  64. $('#CreateTime').val(learun.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'));
  65. $('#CreateUserId')[0].lrvalue = learun.clientdata.get(['userinfo']).userId;
  66. $('#CreateUserId').val(learun.clientdata.get(['userinfo']).realName);
  67. $('#CreateUserName')[0].lrvalue = learun.clientdata.get(['userinfo']).realName;
  68. //选择课程安排
  69. $("#btn1").on('click', function () {
  70. learun.layerForm({
  71. id: 'IndexInEducationSelect',
  72. title: '课程表',
  73. url: top.$.rootUrl + '/PersonnelManagement/TimeTable/IndexInEducationSelect',
  74. width: 1200,
  75. height: 800,
  76. callBack: function (id) {
  77. return top[id].acceptClick(bindData);
  78. }
  79. });
  80. });
  81. $("#btn2").on('click', function () {
  82. learun.layerForm({
  83. id: 'IndexInEducationSelect',
  84. title: '课程表',
  85. url: top.$.rootUrl + '/PersonnelManagement/TimeTable/IndexInEducationSelect',
  86. width: 1200,
  87. height: 800,
  88. callBack: function (id) {
  89. return top[id].acceptClick(bindDataNew);
  90. }
  91. });
  92. });
  93. },
  94. bindSelect: function () {
  95. $('#AttemperType').lrDataItemSelect({
  96. code: 'AttemperType', select: function (item) {
  97. $('.AttemperType').hide();
  98. $("#AttemperTimeType").removeAttr("isvalid");
  99. $("#AttemperTimeType").removeAttr("checkexpession");
  100. $("#AttemperStartTime").removeAttr("isvalid");
  101. $("#AttemperStartTime").removeAttr("checkexpession");
  102. $("#AttemperEndTime").removeAttr("isvalid");
  103. $("#AttemperEndTime").removeAttr("checkexpession");
  104. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("isvalid");
  105. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("checkexpession");
  106. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr('readonly');
  107. $('#NewEmpNo').siblings('div').html('教师');
  108. $('#NewClassroomNo').siblings('div').html('教室');
  109. if (item != null && item != undefined) {
  110. if (item.id === "01") { //调课
  111. $('.AttemperTypeTiao').show();
  112. $("#AttemperTimeType").attr("isvalid", "yes");
  113. $("#AttemperTimeType").attr("checkexpession", "NotNull");
  114. $("#AttemperStartTime").attr("isvalid", "yes");
  115. $("#AttemperStartTime").attr("checkexpession", "NotNull");
  116. $("#AttemperEndTime").attr("isvalid", "yes");
  117. $("#AttemperEndTime").attr("checkexpession", "NotNull");
  118. } else if (item.id === "02") { //停课
  119. } else if (item.id === "03") { //对调
  120. $('.AttemperTypeDuiDiao').show();
  121. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes");
  122. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull");
  123. $(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly');
  124. $('#NewEmpNo').siblings('div').html('教师<font face="宋体">*</font>');
  125. $('#NewClassroomNo').siblings('div').html('教室<font face="宋体">*</font>');
  126. }
  127. }
  128. }
  129. });
  130. $('#AttemperTimeType').lrDataItemSelect({ code: 'AttemperTimeType' });
  131. //$('#F_SchoolId').lrDataSourceSelect({ code: 'company', value: 'f_companyid', text: 'f_fullname' });
  132. //$('#NewF_SchoolId').lrDataSourceSelect({ code: 'company', value: 'f_companyid', text: 'f_fullname' });
  133. //学年
  134. $('#AcademicYearNo').lrselect({
  135. allowSearch: true,
  136. url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetAcademicYearNo',
  137. value: 'value',
  138. text: 'text'
  139. });
  140. $('#NewAcademicYearNo').lrselect({
  141. allowSearch: true,
  142. url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetAcademicYearNo',
  143. value: 'value',
  144. text: 'text'
  145. });
  146. //学期
  147. $('#Semester').lrselect({
  148. allowSearch: true,
  149. url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetSemesterData',
  150. value: 'value',
  151. text: 'text'
  152. });
  153. $('#NewSemester').lrselect({
  154. allowSearch: true,
  155. url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetSemesterData',
  156. value: 'value',
  157. text: 'text'
  158. });
  159. $('#DeptNo').lrDataSourceSelect({ code: 'CdDeptInfo', value: 'deptno', text: 'deptname' });
  160. $('#NewDeptNo').lrDataSourceSelect({ code: 'CdDeptInfo', value: 'deptno', text: 'deptname' });
  161. $('#MajorNo').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno', text: 'majorname' });
  162. $('#NewMajorNo').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno', text: 'majorname' });
  163. $('#LessonNo').lrselect({
  164. allowSearch: true,
  165. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetLessonDataInTerm',
  166. value: 'value',
  167. text: 'text',
  168. });
  169. $('#NewLessonNo').lrselect({
  170. allowSearch: true,
  171. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetLessonDataInTerm',
  172. value: 'value',
  173. text: 'text',
  174. });
  175. $('#TeachClassNo').lrDataSourceSelect({ code: 'bjsj', value: 'classno', text: 'classname' });
  176. $('#NewTeachClassNo').lrDataSourceSelect({ code: 'bjsj', value: 'classno', text: 'classname' });
  177. $('#EmpNo').lrDataSourceSelect({ code: 'EmpInfo', value: 'empno', text: 'empname' });
  178. $('#NewEmpNo').lrDataSourceSelect({ code: 'EmpInfo', value: 'empno', text: 'empname' });
  179. $('#ClassroomNo').lrDataSourceSelect({ code: 'ClassRoomInfo', value: 'classroomno', text: 'classroomname' });
  180. $('#NewClassroomNo').lrDataSourceSelect({ code: 'ClassRoomInfo', value: 'classroomno', text: 'classroomname' });
  181. //调度开始时间
  182. $('#AttemperStartTime').lrselect({
  183. allowSearch: true,
  184. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetList?queryJson=' + JSON.stringify({}),
  185. value: 'LessonDate',
  186. text: 'LessonDate'
  187. });
  188. //调度结束时间
  189. $('#AttemperEndTime').lrselect({
  190. allowSearch: true,
  191. url: top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTerm/GetList?queryJson=' + JSON.stringify({}),
  192. value: 'LessonDate',
  193. text: 'LessonDate'
  194. });
  195. },
  196. initData: function () {
  197. if (!!keyValue) {
  198. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetFormData?keyValue=' + keyValue, function (data) {
  199. for (var id in data) {
  200. if (!!data[id].length && data[id].length > 0) {
  201. $('#' + id).jfGridSet('refreshdata', data[id]);
  202. }
  203. else {
  204. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  205. $('.AttemperType').hide();
  206. $("#AttemperTimeType").removeAttr("isvalid");
  207. $("#AttemperTimeType").removeAttr("checkexpession");
  208. $("#AttemperStartTime").removeAttr("isvalid");
  209. $("#AttemperStartTime").removeAttr("checkexpession");
  210. $("#AttemperEndTime").removeAttr("isvalid");
  211. $("#AttemperEndTime").removeAttr("checkexpession");
  212. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("isvalid");
  213. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("checkexpession");
  214. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr('readonly');
  215. $('#NewEmpNo').siblings('div').html('教师');
  216. $('#NewClassroomNo').siblings('div').html('教室');
  217. if (data[id].AttemperType == "01") {
  218. $('.AttemperTypeTiao').show();
  219. $("#AttemperTimeType").attr("isvalid", "yes");
  220. $("#AttemperTimeType").attr("checkexpession", "NotNull");
  221. $("#AttemperStartTime").attr("isvalid", "yes");
  222. $("#AttemperStartTime").attr("checkexpession", "NotNull");
  223. $("#AttemperEndTime").attr("isvalid", "yes");
  224. $("#AttemperEndTime").attr("checkexpession", "NotNull");
  225. } else if (data[id].AttemperType == "02") {
  226. } else if (data[id].AttemperType == "03") {
  227. $('.AttemperTypeDuiDiao').show();
  228. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes");
  229. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull");
  230. $(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly');
  231. $('#NewEmpNo').siblings('div').html('教师<font face="宋体">*</font>');
  232. $('#NewClassroomNo').siblings('div').html('教室<font face="宋体">*</font>');
  233. }
  234. }
  235. page.query();
  236. }
  237. });
  238. }
  239. }
  240. };
  241. bindData = function (temprow) {
  242. if (!!temprow) {
  243. //$('#F_SchoolId').lrselectSet(temprow.schooldId);
  244. $('#AcademicYearNo').lrselectSet(temprow.academicyear);
  245. $('#Semester').lrselectSet(temprow.semester);
  246. $('#DeptNo').lrselectSet(temprow.deptNo);
  247. $('#MajorNo').lrselectSet(temprow.majorNo);
  248. $('#LessonNo').lrselectSet(temprow.lessonNo);
  249. $('#TeachClassNo').lrselectSet(temprow.teachClassNo);
  250. $('#EmpNo').lrselectSet(temprow.empno);
  251. $('#ClassroomNo').lrselectSet(temprow.classRoomNo);
  252. page.query();
  253. }
  254. };
  255. bindDataNew = function (temprow) {
  256. if (!!temprow) {
  257. //$('#NewF_SchoolId').lrselectSet(temprow.schooldId);
  258. $('#NewAcademicYearNo').lrselectSet(temprow.academicyear);
  259. $('#NewSemester').lrselectSet(temprow.semester);
  260. $('#NewDeptNo').lrselectSet(temprow.deptNo);
  261. $('#NewMajorNo').lrselectSet(temprow.majorNo);
  262. $('#NewLessonNo').lrselectSet(temprow.lessonNo);
  263. $('#NewTeachClassNo').lrselectSet(temprow.teachClassNo);
  264. $('#NewEmpNo').lrselectSet(temprow.empno);
  265. $('#NewClassroomNo').lrselectSet(temprow.classRoomNo);
  266. }
  267. };
  268. // 设置表单数据
  269. setFormData = function (processId) {
  270. if (!!processId) {
  271. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetFormDataByProcessId?processId=' + processId, function (data) {
  272. for (var id in data) {
  273. if (!!data[id] && data[id].length > 0) {
  274. $('#' + id).jfGridSet('refreshdata', data[id]);
  275. }
  276. else {
  277. if (id == 'ArrangeLessonTermAttemper') {
  278. keyValue = data[id].Id;
  279. }
  280. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  281. $('.AttemperType').hide();
  282. $("#AttemperTimeType").removeAttr("isvalid");
  283. $("#AttemperTimeType").removeAttr("checkexpession");
  284. $("#AttemperStartTime").removeAttr("isvalid");
  285. $("#AttemperStartTime").removeAttr("checkexpession");
  286. $("#AttemperEndTime").removeAttr("isvalid");
  287. $("#AttemperEndTime").removeAttr("checkexpession");
  288. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("isvalid");
  289. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("checkexpession");
  290. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr('readonly');
  291. $('#NewEmpNo').siblings('div').html('教师');
  292. $('#NewClassroomNo').siblings('div').html('教室');
  293. if (data[id].AttemperType == "01") {
  294. $('.AttemperTypeTiao').show();
  295. $("#AttemperTimeType").attr("isvalid", "yes");
  296. $("#AttemperTimeType").attr("checkexpession", "NotNull");
  297. $("#AttemperStartTime").attr("isvalid", "yes");
  298. $("#AttemperStartTime").attr("checkexpession", "NotNull");
  299. $("#AttemperEndTime").attr("isvalid", "yes");
  300. $("#AttemperEndTime").attr("checkexpession", "NotNull");
  301. } else if (data[id].AttemperType == "02") {
  302. } else if (data[id].AttemperType == "03") {
  303. $('.AttemperTypeDuiDiao').show();
  304. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes");
  305. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull");
  306. $(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly');
  307. $('#NewEmpNo').siblings('div').html('教师<font face="宋体">*</font>');
  308. $('#NewClassroomNo').siblings('div').html('教室<font face="宋体">*</font>');
  309. }
  310. }
  311. }
  312. });
  313. }
  314. }
  315. // 验证数据是否填写完整
  316. validForm = function () {
  317. if (!$('#form').lrValidform()) {
  318. return false;
  319. }
  320. return true;
  321. };
  322. // 保存数据
  323. save = function (processId, callBack, i) {
  324. var formData = $('body').lrGetFormData();
  325. if (formData.AttemperType == "03") { //对调:校区、学年、学期需要一致
  326. //if (formData.F_SchoolId !== formData.NewF_SchoolId || formData.AcademicYearNo !== formData.NewAcademicYearNo || formData.Semester !== formData.NewSemester) {
  327. if (formData.AcademicYearNo !== formData.NewAcademicYearNo || formData.Semester !== formData.NewSemester) {
  328. learun.alert.warning("校区、学年、学期不一致!");
  329. return false;
  330. }
  331. } else if (formData.AttemperType == "01") { //调课:调度时间比较;教师或教室必填一个;
  332. if ((formData.NewEmpNo == null || formData.NewEmpNo == "") && (formData.NewClassroomNo == null || formData.NewClassroomNo == "")) {
  333. learun.alert.warning("课程新安排中教师或教室不能为空!");
  334. return false;
  335. }
  336. if (formData.AttemperEndTime < formData.AttemperStartTime) {
  337. learun.alert.warning("调度结束时间应该大于调度开始时间!");
  338. return false;
  339. }
  340. }
  341. if (!!processId) {
  342. formData.ProcessId = processId;
  343. }
  344. var postData = {
  345. strEntity: JSON.stringify(formData)
  346. };
  347. $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/SaveForm?keyValue=' + keyValue, postData, function (res) {
  348. // 保存成功后才回调
  349. if (!!callBack) {
  350. callBack(res, formData, i);
  351. }
  352. });
  353. };
  354. page.init();
  355. }