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.

Index.js 12 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 北京泉江科技有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2019-03-29 11:49
  5. * 描 述:出库申请
  6. */
  7. var refreshGirdData;
  8. var bootstrap = function ($, learun) {
  9. "use strict";
  10. var startTime;
  11. var endTime;
  12. var processId = '';
  13. var page = {
  14. init: function () {
  15. page.initGird();
  16. page.bind();
  17. },
  18. bind: function () {
  19. // 时间搜索框
  20. $('#datesearch').lrdate({
  21. dfdata: [
  22. { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  23. { name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  24. { name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  25. { name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }
  26. ],
  27. // 月
  28. mShow: false,
  29. premShow: false,
  30. // 季度
  31. jShow: false,
  32. prejShow: false,
  33. // 年
  34. ysShow: false,
  35. yxShow: false,
  36. preyShow: false,
  37. yShow: false,
  38. // 默认
  39. dfvalue: '3',
  40. selectfn: function (begin, end) {
  41. startTime = begin;
  42. endTime = end;
  43. page.search();
  44. }
  45. });
  46. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  47. page.search(queryJson);
  48. }, 220, 400);
  49. // 刷新
  50. $('#lr_refresh').on('click', function () {
  51. location.reload();
  52. });
  53. // 新增
  54. $('#lr_add').on('click', function () {
  55. learun.layerForm({
  56. id: 'formAss_AssetsOutApply',
  57. title: '新增',
  58. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/Form',
  59. width: 1000,
  60. height: 700,
  61. callBack: function (id) {
  62. var res = false;
  63. // 验证数据
  64. res = top[id].validForm();
  65. // 保存数据
  66. if (res) {
  67. //processId = learun.newGuid();
  68. //res = top[id].save(processId, refreshGirdData);
  69. res = top[id].save('', function () {
  70. page.search();
  71. });
  72. }
  73. return res;
  74. }
  75. });
  76. });
  77. // 编辑
  78. $('#lr_edit').on('click', function () {
  79. var keyValue = $('#gridtable').jfGridValue('AOId');
  80. if (learun.checkrow(keyValue)) {
  81. var AAStatus = $('#gridtable').jfGridValue('AOStatus');
  82. if (AAStatus !== 0) {
  83. learun.alert.warning("当前项目已提交不能编辑!");
  84. return;
  85. }
  86. learun.layerForm({
  87. id: 'formAss_AssetsOutApply',
  88. title: '编辑',
  89. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/Form?keyValue=' + keyValue,
  90. width: 1000,
  91. height: 700,
  92. callBack: function (id) {
  93. var res = false;
  94. // 验证数据
  95. res = top[id].validForm();
  96. // 保存数据
  97. if (res) {
  98. res = top[id].save('', function () {
  99. page.search();
  100. });
  101. }
  102. return res;
  103. }
  104. });
  105. }
  106. });
  107. // 查看申请
  108. $('#lr_view').on('click', function () {
  109. var keyValue = $('#gridtable').jfGridValue('AOId');
  110. if (learun.checkrow(keyValue)) {
  111. learun.layerForm({
  112. id: 'formAss_AssetsInfoApply',
  113. title: '查看调拨申请',
  114. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/FormView?keyValue=' + keyValue,
  115. width: 1000,
  116. height: 600,
  117. btn: null
  118. });
  119. }
  120. });
  121. // 删除
  122. $('#lr_delete').on('click', function () {
  123. var keyValue = $('#gridtable').jfGridValue('AOId');
  124. if (learun.checkrow(keyValue)) {
  125. var AAStatus = $('#gridtable').jfGridValue('AOStatus');
  126. if (AAStatus !== 0) {
  127. learun.alert.warning("当前项目已提交不能删除!");
  128. return;
  129. }
  130. learun.layerConfirm('是否确认删除该项!', function (res) {
  131. if (res) {
  132. learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/DeleteForm', { keyValue: keyValue }, function () {
  133. refreshGirdData();
  134. });
  135. }
  136. });
  137. }
  138. });
  139. //  提交
  140. $('#lr_submit').on('click', function () {
  141. var keyValue = $('#gridtable').jfGridValue('AOId');
  142. if (learun.checkrow(keyValue)) {
  143. var AAStatus = $('#gridtable').jfGridValue('AOStatus');
  144. if (AAStatus !== 0) {
  145. learun.alert.warning("当前项目已提交,请耐心等待审批!");
  146. return;
  147. }
  148. learun.layerConfirm('是否确认提交该项!', function (res) {
  149. if (res) {
  150. processId = learun.newGuid();
  151. learun.postForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/ChangeStatusById', { keyValue: keyValue, processId: processId }, function (res) {
  152. refreshGirdData(res, {});
  153. });
  154. }
  155. });
  156. }
  157. });
  158. //缺货单
  159. $('#lr_incom').on('click', function () {
  160. var keyValue = $('#gridtable').jfGridValue('AOId');
  161. if (learun.checkrow(keyValue)) {
  162. var AOAIId = $('#gridtable').jfGridValue('AOAIId');
  163. if (AOAIId == null || AOAIId === undefined || AOAIId === "") {
  164. learun.alert.warning("当前项目不含缺货单!");
  165. return;
  166. }
  167. learun.layerForm({
  168. id: 'formAss_AssetsOutApplyIncomplete',
  169. title: '查看缺货单',
  170. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApplyIncomplete/Form?keyValue=' + keyValue,
  171. width: 1000,
  172. height: 700,
  173. btn: ["调拨", "关闭"],
  174. callBack: function (id) {
  175. return top[id].acceptClick(refreshGirdData);
  176. }
  177. });
  178. }
  179. });
  180. },
  181. // 初始化列表
  182. initGird: function () {
  183. $('#gridtable').lrAuthorizeJfGrid({
  184. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/GetPageList',
  185. headData: [
  186. { label: "调拨单流水号", name: "AOCode", width: 200, align: "left" },
  187. { label: "调拨总价", name: "AOPrice", width: 100, align: "left" },
  188. //{
  189. // label: "出库原因", name: "AOReasonType", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) {
  190. // learun.clientdata.getAsync('dataItem', {
  191. // key: value,
  192. // code: 'ReasonType',
  193. // callback: function (_data) {
  194. // callback(_data.text);
  195. // }
  196. // });
  197. // }
  198. //},
  199. { label: "项目名称", name: "AOProjectName", width: 150, align: "left" },
  200. { label: "申请时间", name: "AOCreateTime", width: 150, align: "left" },
  201. {
  202. label: "申请人", name: "AOCreateUserId", width: 100, align: "left",
  203. formatterAsync: function (callback, value, row, op, $cell) {
  204. learun.clientdata.getAsync('user', {
  205. key: value,
  206. callback: function (_data) {
  207. callback(_data.name);
  208. }
  209. });
  210. }
  211. },
  212. {
  213. label: "审批状态", name: "AOStatus", width: 100, align: "left",
  214. formatter: function (cellvalue, row) {
  215. if (cellvalue === 1) {
  216. return '<span class=\"label label-warning\">审批中</span>';
  217. } else if (cellvalue === 2) {
  218. return '<span class=\"label label-success\">审批通过</span>';
  219. } else {
  220. return '<span class=\"label label-default\" >草稿</span>';
  221. }
  222. }
  223. },
  224. {
  225. label: "调拨状态", name: "AOOutStatus", width: 100, align: "left",
  226. formatter: function (cellvalue, row) {
  227. if (cellvalue === 0) {
  228. return '<span class=\"label label-warning\">待调拨</span>';
  229. } else if (cellvalue === 2) {
  230. return '<span class=\"label label-success\">调拨完成</span>';
  231. } else {
  232. return '<span class=\"label label-default\" >部分调拨</span>';
  233. }
  234. }
  235. }
  236. ],
  237. mainId: 'AOId',
  238. isPage: true,
  239. sidx: 'AOCreateTime',
  240. sord: 'DASC'
  241. });
  242. },
  243. search: function (param) {
  244. param = param || {};
  245. param.StartTime = startTime;
  246. param.EndTime = endTime;
  247. $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  248. }
  249. };
  250. refreshGirdData = function (res, postData) {
  251. if (res && res.code && res.code == 200) {
  252. // 发起流程
  253. var postData = {
  254. schemeCode: 'Ass_AssetsOutApply',// 填写流程对应模板编号
  255. processId: processId,
  256. level: '1',
  257. };
  258. learun.httpAsync('Post', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/CreateFlow', postData, function (data) {
  259. learun.loading(false);
  260. });
  261. }
  262. page.search();
  263. };
  264. page.init();
  265. }