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.
 
 
 
 
 
 

274 lines
12 KiB

  1. /* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn)
  2. * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2022-02-18 14:27
  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 order = 0;
  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. $("#detailadd").on('click', function () {
  30. selectedRow = null;
  31. learun.layerForm({
  32. id: 'formTextBookIndentDetail',
  33. title: '新增明细',
  34. url: top.$.rootUrl + '/EducationalAdministration/TextBookIndent/FormDetail',
  35. width: 600,
  36. height: 350,
  37. callBack: function (id) {
  38. return top[id].acceptClick(refreshGirdData);
  39. }
  40. });
  41. });
  42. $("#detailedit").on('click', function () {
  43. var keyValue = $('#TextBookIndentDetail').jfGridValue('ID');
  44. selectedRow = $('#TextBookIndentDetail').jfGridGet('rowdata');
  45. if (learun.checkrow(keyValue)) {
  46. learun.layerForm({
  47. id: 'formTextBookIndentDetail',
  48. title: '编辑明细',
  49. url: top.$.rootUrl + '/EducationalAdministration/TextBookIndent/FormDetail?keyValue=' + keyValue,
  50. width: 600,
  51. height: 350,
  52. callBack: function (id) {
  53. return top[id].acceptClick(refreshGirdData);
  54. }
  55. });
  56. }
  57. });
  58. $("#detaildel").on('click', function () {
  59. var keyValue = $('#TextBookIndentDetail').jfGridValue('ID');
  60. if (learun.checkrow(keyValue)) {
  61. learun.layerConfirm('是否确认删除该项!', function (res, index) {
  62. if (res) {
  63. order = 0;
  64. $.each(tempdatra, function (key, val) {
  65. if (tempdatra[key].ID === keyValue) {
  66. // order -= tempdatra[key].TeachSum + tempdatra[key].StuSum;
  67. tempdatra.splice(key, 1);
  68. } else {
  69. order += (parseInt(tempdatra[key].TeachSum) + parseInt(tempdatra[key].StuSum));
  70. }
  71. });
  72. $("#OrderNum").val(order);
  73. $('#TextBookIndentDetail').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
  74. top.layer.close(index);
  75. }
  76. });
  77. }
  78. });
  79. page.bind();
  80. page.initData();
  81. },
  82. bind: function () {
  83. $('#DeptNo').lrDataSourceSelect({ code: 'CdDeptInfo', value: 'deptno', text: 'deptname' });
  84. $('#MajorNo').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorname', text: 'majorname' });
  85. $('#LessonNo').lrDataSourceSelect({ code: 'LessonInfo', value: 'lessonno', text: 'lessonname' });
  86. $('#AcademicYearNo').lrselect({
  87. placeholder: "请选择学年",
  88. allowSearch: true,
  89. url: top.$.rootUrl + '/EducationalAdministration/TextBookIndent/GetAcademicYear',
  90. value: 'value',
  91. text: 'text'
  92. });
  93. //学期
  94. $('#Semester').lrselect({
  95. placeholder: "请选择学期",
  96. allowSearch: true,
  97. url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetSemester',
  98. value: 'value',
  99. text: 'text'
  100. });
  101. $('#TextBookIndentDetail').jfGrid({
  102. headData: [
  103. {
  104. label: "班级", name: "ClassNo", width: 100, align: "left",
  105. formatterAsync: function (callback, value, row, op, $cell) {
  106. learun.clientdata.getAsync('custmerData', {
  107. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'bjsj',
  108. key: value,
  109. keyId: 'classno',
  110. callback: function (_data) {
  111. callback(_data['classname']);
  112. }
  113. });
  114. }
  115. },
  116. { label: '教师人数', name: 'TeachSum', width: 80, align: 'left' },
  117. { label: '学生人数', name: 'StuSum', width: 80, align: 'left' },
  118. { label: '备注', name: 'Remark', width: 100, align: 'left' },
  119. ],
  120. height: 400,
  121. mainId: 'ID,IndentID',
  122. reloadSelected: false,
  123. });
  124. $('#TextBookName').lrGirdSelect({
  125. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=TextBookInfo',
  126. param: { strWhere: " IsDel = '0' and IsValid ='true' " },
  127. height: 800,
  128. width: 1100,
  129. selectWord: 'textbookname',
  130. value: 'textbookname',
  131. text: 'textbookname',
  132. headData:
  133. [
  134. { label: "教材号", name: "publishno", width: 150, align: "left" },
  135. { label: "教材名称", name: "textbookname", width: 150, align: "left" },
  136. { label: "作者", name: "firstauthor", width: 150, align: "left" },
  137. { label: "其他作者", name: "otherauthor", width: 100, align: "left" },
  138. { label: "出版社", name: "publisher", width: 100, align: "left" },
  139. {
  140. label: "教材类型", name: "textbooktype", width: 100, align: "left",
  141. formatterAsync: function (callback, value, row, op, $cell) {
  142. learun.clientdata.getAsync('dataItem', {
  143. key: value,
  144. code: 'TextBookType',
  145. callback: function (_data) {
  146. callback(_data.text);
  147. }
  148. });
  149. }
  150. },
  151. {
  152. label: "教材性质", name: "textbooknature", width: 100, align: "left",
  153. formatterAsync: function (callback, value, row, op, $cell) {
  154. learun.clientdata.getAsync('dataItem', {
  155. key: value,
  156. code: 'TextBookNature',
  157. callback: function (_data) {
  158. callback(_data.text);
  159. }
  160. });
  161. }
  162. },
  163. { label: "价格", name: "price", width: 50, align: "left" },
  164. { label: "版次", name: "edition", width: 100, align: "left" },
  165. { label: "印次", name: "impression", width: 100, align: "left" },
  166. ],
  167. select: function (item) {
  168. ////赋值
  169. $("#Price").val(item.price);
  170. $("#PublishNo").val(item.publishno);
  171. $("#FirstAuthor").val(item.firstauthor);
  172. $("#TextBookName").val(item.textbookname);
  173. $("#OtherAuthor").val(item.otherauthor);
  174. $("#Publisher").val(item.publisher);
  175. $("#Edition").val(item.edition);
  176. }
  177. });
  178. $('#Status').val(0);
  179. $('#CreateTime').val(learun.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'));
  180. $('#CreateUserID')[0].lrvalue = learun.clientdata.get(['userinfo']).userId;
  181. $('#CreateUserID').val(learun.clientdata.get(['userinfo']).realName);
  182. },
  183. initData: function () {
  184. if (!!keyValue) {
  185. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookIndent/GetFormData?keyValue=' + keyValue, function (data) {
  186. for (var id in data) {
  187. if (!!data[id].length && data[id].length > 0) {
  188. $('#' + id).jfGridSet('refreshdata', data[id]);
  189. tempdatra = data[id];
  190. }
  191. else {
  192. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  193. //if (data[id].AAPrice) {
  194. // pricecount = data[id].AAPrice;
  195. //}
  196. }
  197. }
  198. });
  199. }
  200. }
  201. };
  202. refreshGirdData = function (temprow) {
  203. var ifnewrow = true;
  204. $.each(tempdatra, function (key, val) {
  205. if (tempdatra[key].ID === temprow.ID) {
  206. tempdatra[key] = temprow;
  207. ifnewrow = false;
  208. }
  209. });
  210. if (ifnewrow) {
  211. tempdatra.push(temprow);
  212. }
  213. //订购数量
  214. order = 0;
  215. for (var i = 0; i < tempdatra.length; i++) {
  216. order += (parseInt(tempdatra[i].TeachSum) + parseInt(tempdatra[i].StuSum));
  217. }
  218. $("#OrderNum").val(order);
  219. $('#TextBookIndentDetail').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
  220. };
  221. function sortNumber(a, b) {
  222. return a.StuSum - b.StuSum;
  223. }
  224. // 设置表单数据
  225. setFormData = function (processId, param, callback) {
  226. if (!!processId) {
  227. $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookIndent/GetFormDataByProcessId?processId=' + processId, function (data) {
  228. for (var id in data) {
  229. if (!!data[id] && data[id].length > 0) {
  230. $('#' + id).jfGridSet('refreshdata', data[id]);
  231. }
  232. else {
  233. if (id == 'TextBookIndent' && data[id]) {
  234. keyValue = data[id].ID;
  235. }
  236. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  237. }
  238. }
  239. });
  240. }
  241. }
  242. // 验证数据是否填写完整
  243. validForm = function () {
  244. if (!$('.lr-form-wrap').lrValidform()) {
  245. return false;
  246. }
  247. var datas = $('#TextBookIndentDetail').jfGridGet('rowdatas');
  248. if (datas == null || datas.length == 0) {
  249. learun.alert.warning("申请未包含明细!请先新增明细!");
  250. return false;
  251. }
  252. return true;
  253. };
  254. // 保存数据
  255. save = function (processId, callBack, i) {
  256. var postData = {};
  257. var formData = $('[data-table="TextBookIndent"]').lrGetFormData();
  258. if (!!processId) {
  259. formData.processId = processId;
  260. }
  261. postData.strEntity = JSON.stringify(formData);
  262. postData.strTextBookIndentDetailList = JSON.stringify($('#TextBookIndentDetail').jfGridGet('rowdatas'));
  263. $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TextBookIndent/SaveForm?keyValue=' + keyValue, postData, function (res) {
  264. // 保存成功后才回调
  265. if (!!callBack) {
  266. callBack(res, formData, i);
  267. }
  268. });
  269. };
  270. page.init();
  271. }