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.

FormView.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. $('#NewEmpNo').attr('readonly', 'readonly');
  218. $('#NewClassroomNo').attr('readonly', 'readonly');
  219. if (data[id].AttemperType == "01") {
  220. $('.AttemperTypeTiao').show();
  221. $("#AttemperTimeType").attr("isvalid", "yes");
  222. $("#AttemperTimeType").attr("checkexpession", "NotNull");
  223. $("#AttemperStartTime").attr("isvalid", "yes");
  224. $("#AttemperStartTime").attr("checkexpession", "NotNull");
  225. $("#AttemperEndTime").attr("isvalid", "yes");
  226. $("#AttemperEndTime").attr("checkexpession", "NotNull");
  227. } else if (data[id].AttemperType == "02") {
  228. } else if (data[id].AttemperType == "03") {
  229. $('.AttemperTypeDuiDiao').show();
  230. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes");
  231. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull");
  232. $(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly');
  233. $('#NewEmpNo').siblings('div').html('教师<font face="宋体">*</font>');
  234. $('#NewClassroomNo').siblings('div').html('教室<font face="宋体">*</font>');
  235. }
  236. }
  237. page.query();
  238. }
  239. });
  240. }
  241. }
  242. };
  243. bindData = function (temprow) {
  244. if (!!temprow) {
  245. //$('#F_SchoolId').lrselectSet(temprow.schooldId);
  246. $('#AcademicYearNo').lrselectSet(temprow.academicyear);
  247. $('#Semester').lrselectSet(temprow.semester);
  248. $('#DeptNo').lrselectSet(temprow.deptNo);
  249. $('#MajorNo').lrselectSet(temprow.majorNo);
  250. $('#LessonNo').lrselectSet(temprow.lessonNo);
  251. $('#TeachClassNo').lrselectSet(temprow.teachClassNo);
  252. $('#EmpNo').lrselectSet(temprow.empno);
  253. $('#ClassroomNo').lrselectSet(temprow.classRoomNo);
  254. page.query();
  255. }
  256. };
  257. bindDataNew = function (temprow) {
  258. if (!!temprow) {
  259. //$('#NewF_SchoolId').lrselectSet(temprow.schooldId);
  260. $('#NewAcademicYearNo').lrselectSet(temprow.academicyear);
  261. $('#NewSemester').lrselectSet(temprow.semester);
  262. $('#NewDeptNo').lrselectSet(temprow.deptNo);
  263. $('#NewMajorNo').lrselectSet(temprow.majorNo);
  264. $('#NewLessonNo').lrselectSet(temprow.lessonNo);
  265. $('#NewTeachClassNo').lrselectSet(temprow.teachClassNo);
  266. $('#NewEmpNo').lrselectSet(temprow.empno);
  267. $('#NewClassroomNo').lrselectSet(temprow.classRoomNo);
  268. }
  269. };
  270. // 设置表单数据
  271. setFormData = function (processId) {
  272. if (!!processId) {
  273. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/ArrangeLessonTermAttemper/GetFormDataByProcessId?processId=' + processId, function (data) {
  274. for (var id in data) {
  275. if (!!data[id] && data[id].length > 0) {
  276. $('#' + id).jfGridSet('refreshdata', data[id]);
  277. }
  278. else {
  279. if (id == 'ArrangeLessonTermAttemper') {
  280. keyValue = data[id].Id;
  281. }
  282. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  283. $('.AttemperType').hide();
  284. $("#AttemperTimeType").removeAttr("isvalid");
  285. $("#AttemperTimeType").removeAttr("checkexpession");
  286. $("#AttemperStartTime").removeAttr("isvalid");
  287. $("#AttemperStartTime").removeAttr("checkexpession");
  288. $("#AttemperEndTime").removeAttr("isvalid");
  289. $("#AttemperEndTime").removeAttr("checkexpession");
  290. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("isvalid");
  291. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr("checkexpession");
  292. $(".AttemperTypeDuiDiao").find('.contentDiv').removeAttr('readonly');
  293. $('#NewEmpNo').siblings('div').html('教师');
  294. $('#NewClassroomNo').siblings('div').html('教室');
  295. $('#NewEmpNo').attr('readonly', 'readonly');
  296. $('#NewClassroomNo').attr('readonly', 'readonly');
  297. if (data[id].AttemperType == "01") {
  298. $('.AttemperTypeTiao').show();
  299. $("#AttemperTimeType").attr("isvalid", "yes");
  300. $("#AttemperTimeType").attr("checkexpession", "NotNull");
  301. $("#AttemperStartTime").attr("isvalid", "yes");
  302. $("#AttemperStartTime").attr("checkexpession", "NotNull");
  303. $("#AttemperEndTime").attr("isvalid", "yes");
  304. $("#AttemperEndTime").attr("checkexpession", "NotNull");
  305. } else if (data[id].AttemperType == "02") {
  306. } else if (data[id].AttemperType == "03") {
  307. $('.AttemperTypeDuiDiao').show();
  308. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("isvalid", "yes");
  309. $(".AttemperTypeDuiDiao").find('.contentDiv').attr("checkexpession", "NotNull");
  310. $(".AttemperTypeDuiDiao").find('.contentDiv').attr('readonly', 'readonly');
  311. $('#NewEmpNo').siblings('div').html('教师<font face="宋体">*</font>');
  312. $('#NewClassroomNo').siblings('div').html('教室<font face="宋体">*</font>');
  313. }
  314. }
  315. }
  316. });
  317. }
  318. }
  319. // 验证数据是否填写完整
  320. validForm = function () {
  321. if (!$('#form').lrValidform()) {
  322. return false;
  323. }
  324. return true;
  325. };
  326. // 保存数据
  327. save = function (processId, callBack, i) {
  328. var formData = $('body').lrGetFormData();
  329. if (formData.AttemperType == "03") { //对调:校区、学年、学期需要一致
  330. //if (formData.F_SchoolId !== formData.NewF_SchoolId || formData.AcademicYearNo !== formData.NewAcademicYearNo || formData.Semester !== formData.NewSemester) {
  331. if (formData.AcademicYearNo !== formData.NewAcademicYearNo || formData.Semester !== formData.NewSemester) {
  332. learun.alert.warning("校区、学年、学期不一致!");
  333. return false;
  334. }
  335. } else if (formData.AttemperType == "01") { //调课:调度时间比较
  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. }