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 6.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn)
  2. * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2022-08-30 11:05
  5. * 描 述:学生证书管理
  6. */
  7. var acceptClick;
  8. var keyValue = request('keyValue');
  9. var type = request('type');
  10. // 设置权限
  11. var setAuthorize;
  12. // 设置表单数据
  13. var setFormData;
  14. // 验证数据是否填写完整
  15. var validForm;
  16. // 保存数据
  17. var save;
  18. var bootstrap = function ($, learun) {
  19. "use strict";
  20. // 设置权限
  21. setAuthorize = function (data) {
  22. if (!!data) {
  23. for (var field in data) {
  24. if (data[field].isLook != 1) {// 如果没有查看权限就直接移除
  25. $('#' + data[field].fieldId).parent().remove();
  26. }
  27. else {
  28. if (data[field].isEdit != 1) {
  29. $('#' + data[field].fieldId).attr('disabled', 'disabled');
  30. if ($('#' + data[field].fieldId).hasClass('lrUploader-wrap')) {
  31. $('#' + data[field].fieldId).css({ 'padding-right': '58px' });
  32. $('#' + data[field].fieldId).find('.btn-success').remove();
  33. }
  34. }
  35. }
  36. }
  37. }
  38. };
  39. var page = {
  40. init: function () {
  41. $('.lr-form-wrap').lrscroll();
  42. page.bind();
  43. page.initData();
  44. },
  45. bind: function () {
  46. //学年
  47. $('#AcademicYearNo').lrselect({
  48. placeholder: "请选择学年",
  49. allowSearch: true,
  50. url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetAcademicYearNo',
  51. value: 'value',
  52. text: 'text'
  53. });
  54. //学期
  55. $('#Semester').lrselect({
  56. placeholder: "请选择学年",
  57. allowSearch: true,
  58. url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetSemester',
  59. value: 'value',
  60. text: 'text'
  61. });
  62. $('#DeptNo').lrDataSourceSelect({ code: 'CdDeptInfo', value: 'deptno', text: 'deptname' });
  63. $('#MajorNo').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno', text: 'majorname' });
  64. $('#ClassNo').lrDataSourceSelect({ code: 'bjsj', value: 'classno', text: 'classname' });
  65. $('#SCUrl').lrUploader();
  66. $('#StuNo').blur(function () {
  67. learun.httpAsyncGet(top.$.rootUrl + '/EducationalAdministration/StudentCertificate/GetStuData?stuno=' + $('#StuNo').val(), function (res) {
  68. learun.loading(false);
  69. if (res.code == learun.httpCode.success) {
  70. var data = res.data;
  71. if (!!data) {
  72. $('#StuName').val(data.StuName);
  73. $('#DeptNo').lrselectSet(data.DeptNo);
  74. $('#MajorNo').lrselectSet(data.MajorNo);
  75. $('#ClassNo').lrselectSet(data.ClassNo);
  76. } else {
  77. $('#StuName').val();
  78. $('#DeptNo').lrselectSet();
  79. $('#MajorNo').lrselectSet();
  80. $('#ClassNo').lrselectSet();
  81. }
  82. }
  83. else {
  84. learun.alert.error(res.info);
  85. }
  86. });
  87. });
  88. $('#StuName').blur(function () {
  89. learun.httpAsyncGet(top.$.rootUrl + '/EducationalAdministration/StudentCertificate/GetStuData?stuname=' + $('#StuName').val(), function (res) {
  90. learun.loading(false);
  91. if (res.code == learun.httpCode.success) {
  92. var data = res.data;
  93. if (!!data) {
  94. $('#StuNo').val(data.StuNo);
  95. $('#DeptNo').lrselectSet(data.DeptNo);
  96. $('#MajorNo').lrselectSet(data.MajorNo);
  97. $('#ClassNo').lrselectSet(data.ClassNo);
  98. } else {
  99. $('#StuName').val();
  100. $('#DeptNo').lrselectSet();
  101. $('#MajorNo').lrselectSet();
  102. $('#ClassNo').lrselectSet();
  103. }
  104. }
  105. else {
  106. learun.alert.error(res.info);
  107. }
  108. });
  109. });
  110. },
  111. initData: function () {
  112. if (!!keyValue) {
  113. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StudentCertificate/GetFormData?keyValue=' + keyValue, function (data) {
  114. for (var id in data) {
  115. if (!!data[id].length && data[id].length > 0) {
  116. $('#' + id).jfGridSet('refreshdata', data[id]);
  117. }
  118. else {
  119. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  120. }
  121. }
  122. });
  123. }
  124. }
  125. };
  126. // 设置表单数据
  127. setFormData = function (processId, param, callback) {
  128. if (!!processId) {
  129. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StudentCertificate/GetFormDataByProcessId?processId=' + processId, function (data) {
  130. for (var id in data) {
  131. if (!!data[id] && data[id].length > 0) {
  132. $('#' + id).jfGridSet('refreshdata', data[id]);
  133. }
  134. else {
  135. if (id == 'StudentCertificate' && data[id]) {
  136. keyValue = data[id].Id;
  137. }
  138. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  139. }
  140. }
  141. });
  142. }
  143. callback && callback();
  144. }
  145. // 验证数据是否填写完整
  146. validForm = function () {
  147. if (!$('body').lrValidform()) {
  148. return false;
  149. }
  150. return true;
  151. };
  152. // 保存数据
  153. save = function (processId, callBack, i) {
  154. var formData = $('body').lrGetFormData();
  155. if (!!processId) {
  156. formData.processId = processId;
  157. }
  158. if (type == 'copy') {
  159. keyValue = '';
  160. }
  161. var postData = {
  162. strEntity: JSON.stringify(formData)
  163. };
  164. $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/StudentCertificate/SaveForm?keyValue=' + keyValue, postData, function (res) {
  165. // 保存成功后才回调
  166. if (!!callBack) {
  167. callBack(res, i);
  168. }
  169. });
  170. };
  171. page.init();
  172. }