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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn)
  2. * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2022-03-02 10:37
  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. var selectedRow;
  18. var refreshGirdData;
  19. var tempdatra = new Array();
  20. var bootstrap = function ($, learun) {
  21. "use strict";
  22. // 设置权限
  23. setAuthorize = function (data) {
  24. };
  25. var page = {
  26. init: function () {
  27. $('.lr-form-wrap').lrscroll();
  28. $("#detailadd").on('click', function () {
  29. selectedRow = null;
  30. learun.layerForm({
  31. id: 'formTextBookIn',
  32. title: '申请出库',
  33. url: top.$.rootUrl + '/EducationalAdministration/TextBookOut/FormOut',
  34. width: 800,
  35. height: 500,
  36. callBack: function (id) {
  37. return top[id].acceptClick(refreshGirdData);
  38. }
  39. });
  40. });
  41. $("#detaildel").on('click', function () {
  42. var keyValue = $('#TextBookOut').jfGridValue('ID');
  43. if (learun.checkrow(keyValue)) {
  44. learun.layerConfirm('是否确认删除该项!', function (res, index) {
  45. if (res) {
  46. $.each(tempdatra, function (key, val) {
  47. if (tempdatra[key].ID === keyValue) {
  48. tempdatra.splice(key, 1);
  49. }
  50. });
  51. $('#TextBookOut').jfGridSet('refreshdata', tempdatra);
  52. learun.layerClose(window.name);
  53. top.layer.close(index);
  54. }
  55. });
  56. }
  57. });
  58. page.bind();
  59. page.initData();
  60. },
  61. bind: function () {
  62. $('#LessonNo').lrDataSourceSelect({ code: 'LessonInfo', value: 'lessonno', text: 'lessonname' });
  63. $('#TextBookOut').jfGrid({
  64. headData: [
  65. { label: '出库单', name: 'BookCode', width: 180, align: 'left' },
  66. {
  67. label: "专业部", name: "DeptNo", width: 100, align: "left",
  68. formatterAsync: function (callback, value, row, op, $cell) {
  69. learun.clientdata.getAsync('custmerData', {
  70. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo',
  71. key: value,
  72. keyId: 'deptno',
  73. callback: function (_data) {
  74. callback(_data['deptname']);
  75. }
  76. });
  77. }
  78. },
  79. {
  80. label: "专业", name: "MajorNo", width: 120, align: "left",
  81. formatterAsync: function (callback, value, row, op, $cell) {
  82. learun.clientdata.getAsync('custmerData', {
  83. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdMajorInfo',
  84. key: value,
  85. keyId: 'majorno',
  86. callback: function (_data) {
  87. callback(_data['majorname']);
  88. }
  89. });
  90. }
  91. },
  92. {
  93. label: "课程", name: "LessonNo", width: 150, align: "left",
  94. formatterAsync: function (callback, value, row, op, $cell) {
  95. learun.clientdata.getAsync('custmerData', {
  96. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'LessonInfo',
  97. key: value,
  98. keyId: 'lessonno',
  99. callback: function (_data) {
  100. callback(_data['lessonname']);
  101. }
  102. });
  103. }
  104. },
  105. {
  106. label: "班级", name: "ClassNo", width: 100, align: "left",
  107. formatterAsync: function (callback, value, row, op, $cell) {
  108. learun.clientdata.getAsync('custmerData', {
  109. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'bjsj',
  110. key: value,
  111. keyId: 'classno',
  112. callback: function (_data) {
  113. callback(_data['classname']);
  114. }
  115. });
  116. }
  117. },
  118. { label: '学年', name: 'AcademicYearNo', width: 80, align: 'left' },
  119. { label: '学期', name: 'Semester', width: 80, align: 'left' },
  120. { label: '领用人', name: 'Recipient', width: 100, align: 'left' },
  121. { label: '出库数量', name: 'Variate', width: 100, align: 'left' },
  122. { label: '出库时间', name: 'CreateTime', width: 200, align: 'left' },
  123. { label: '出库用户', name: 'CrateUserID', width: 100, align: 'left' },
  124. { label: '备注', name: 'Remark', width: 100, align: 'left' },
  125. ],
  126. height: 400,
  127. mainId: 'CreateTime desc',
  128. reloadSelected: false,
  129. });
  130. },
  131. initData: function () {
  132. if (!!keyValue) {
  133. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookOut/GetFormDataEdit?keyValue=' + keyValue, function (data) {
  134. for (var id in data) {
  135. if (!!data[id].length && data[id].length > 0) {
  136. $('#' + id).jfGridSet('refreshdata', data[id]);
  137. }
  138. else {
  139. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  140. }
  141. }
  142. });
  143. }
  144. }
  145. };
  146. refreshGirdData = function (temprow) {
  147. var ifnewrow = true;
  148. $.each(tempdatra, function (key, val) {
  149. if (tempdatra[key].BookCode === temprow.InOutBook) {
  150. tempdatra[key] = temprow;
  151. ifnewrow = false;
  152. }
  153. });
  154. if (ifnewrow) {
  155. tempdatra.push(temprow);
  156. }
  157. $('#TextBookOut').jfGridSet('refreshdata', tempdatra);
  158. };
  159. // 设置表单数据
  160. setFormData = function (processId, param, callback) {
  161. if (!!processId) {
  162. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookOut/GetFormDataByProcessId?processId=' + processId, function (data) {
  163. for (var id in data) {
  164. if (!!data[id] && data[id].length > 0) {
  165. $('#' + id).jfGridSet('refreshdata', data[id]);
  166. }
  167. else {
  168. if (id == 'TextBookOut' && data[id]) {
  169. keyValue = data[id].ID;
  170. }
  171. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  172. }
  173. }
  174. });
  175. }
  176. }
  177. // 验证数据是否填写完整
  178. validForm = function () {
  179. var datas = $('#TextBookOut').jfGridGet('rowdatas');
  180. if (datas == null || datas.length == 0) {
  181. learun.alert.warning("申请未包含出库申请!请先添加入库申请!");
  182. return false;
  183. }
  184. return true;
  185. };
  186. // 保存数据
  187. save = function (callBack) {
  188. var postData = {};
  189. var formData = $('[data-table="TextBookInOut"]').lrGetFormData();
  190. postData.strEntity = JSON.stringify(formData);
  191. postData.strTextBookOutList = JSON.stringify($('#TextBookOut').jfGridGet('rowdatas'));
  192. $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TextBookOut/SaveForm?keyValue=' + keyValue, postData, function (res) {
  193. // 保存成功后才回调
  194. if (!!callBack) {
  195. callBack();
  196. }
  197. });
  198. };
  199. page.init();
  200. }